#ifndef FELightingNeon_h
#define FELightingNeon_h
#include <wtf/Platform.h>
#if CPU(ARM_NEON) && COMPILER(GCC)
#include "FELighting.h"
#include <wtf/Alignment.h>
namespace WebCore {
#define FLAG_POINT_LIGHT 0x01
#define FLAG_SPOT_LIGHT 0x02
#define FLAG_CONE_EXPONENT_IS_1 0x04
#define FLAG_SPECULAR_LIGHT 0x10
#define FLAG_DIFFUSE_CONST_IS_1 0x20
#define FLAG_SPECULAR_EXPONENT_IS_1 0x40
struct FELightingFloatArgumentsForNeon {
float surfaceScale;
float minusSurfaceScaleDividedByFour;
float diffuseConstant;
float padding1;
float coneCutOffLimit;
float coneFullLight;
float coneCutOffRange;
float constOne;
float lightX;
float lightY;
float lightZ;
float padding2;
float directionX;
float directionY;
float directionZ;
float padding3;
float colorRed;
float colorGreen;
float colorBlue;
float padding4;
};
struct FELightingPaintingDataForNeon {
unsigned char* pixels;
int widthDecreasedByTwo;
int heightDecreasedByTwo;
int flags;
int specularExponent;
int coneExponent;
FELightingFloatArgumentsForNeon* floatArguments;
short* paintingConstants;
};
short* feLightingConstantsForNeon();
extern "C" {
void neonDrawLighting(FELightingPaintingDataForNeon*);
}
inline void FELighting::platformApplyNeon(LightingData& data, LightSource::PaintingData& paintingData)
{
WTF_ALIGNED(FELightingFloatArgumentsForNeon, floatArguments, 16);
FELightingPaintingDataForNeon neonData = {
data.pixels->data(),
data.widthDecreasedByOne - 1,
data.heightDecreasedByOne - 1,
0,
0,
0,
&floatArguments,
feLightingConstantsForNeon()
};
floatArguments.constOne = 1;
floatArguments.colorRed = m_lightingColor.red();
floatArguments.colorGreen = m_lightingColor.green();
floatArguments.colorBlue = m_lightingColor.blue();
floatArguments.padding4 = 0;
if (m_lightSource->type() == LS_POINT) {
neonData.flags |= FLAG_POINT_LIGHT;
PointLightSource* pointLightSource = static_cast<PointLightSource*>(m_lightSource.get());
floatArguments.lightX = pointLightSource->position().x();
floatArguments.lightY = pointLightSource->position().y();
floatArguments.lightZ = pointLightSource->position().z();
floatArguments.padding2 = 0;
} else if (m_lightSource->type() == LS_SPOT) {
neonData.flags |= FLAG_SPOT_LIGHT;
SpotLightSource* spotLightSource = static_cast<SpotLightSource*>(m_lightSource.get());
floatArguments.lightX = spotLightSource->position().x();
floatArguments.lightY = spotLightSource->position().y();
floatArguments.lightZ = spotLightSource->position().z();
floatArguments.padding2 = 0;
floatArguments.directionX = paintingData.directionVector.x();
floatArguments.directionY = paintingData.directionVector.y();
floatArguments.directionZ = paintingData.directionVector.z();
floatArguments.padding3 = 0;
floatArguments.coneCutOffLimit = paintingData.coneCutOffLimit;
floatArguments.coneFullLight = paintingData.coneFullLight;
floatArguments.coneCutOffRange = paintingData.coneCutOffLimit - paintingData.coneFullLight;
neonData.coneExponent = getPowerCoefficients(spotLightSource->specularExponent());
if (spotLightSource->specularExponent() == 1)
neonData.flags |= FLAG_CONE_EXPONENT_IS_1;
} else {
ASSERT(m_lightSource.type == LS_DISTANT);
floatArguments.lightX = paintingData.lightVector.x();
floatArguments.lightY = paintingData.lightVector.y();
floatArguments.lightZ = paintingData.lightVector.z();
floatArguments.padding2 = 1;
}
floatArguments.surfaceScale = data.surfaceScale;
floatArguments.minusSurfaceScaleDividedByFour = -data.surfaceScale / 4;
if (m_lightingType == FELighting::DiffuseLighting)
floatArguments.diffuseConstant = m_diffuseConstant;
else {
neonData.flags |= FLAG_SPECULAR_LIGHT;
floatArguments.diffuseConstant = m_specularConstant;
neonData.specularExponent = getPowerCoefficients(m_specularExponent);
if (m_specularExponent == 1)
neonData.flags |= FLAG_SPECULAR_EXPONENT_IS_1;
}
if (floatArguments.diffuseConstant == 1)
neonData.flags |= FLAG_DIFFUSE_CONST_IS_1;
neonDrawLighting(&neonData);
}
}
#endif // CPU(ARM_NEON) && COMPILER(GCC)
#endif // FELightingNeon_h