#ifndef FELighting_h
#define FELighting_h
#if ENABLE(FILTERS)
#include "Color.h"
#include "Filter.h"
#include "FilterEffect.h"
#include "LightSource.h"
#include "PointLightSource.h"
#include "SpotLightSource.h"
#include <wtf/ByteArray.h>
#include <wtf/Platform.h>
namespace WebCore {
class FELighting : public FilterEffect {
public:
virtual void apply();
virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
protected:
enum LightingType {
DiffuseLighting,
SpecularLighting
};
struct LightingData {
ByteArray* pixels;
float surfaceScale;
int widthMultipliedByPixelSize;
int widthDecreasedByOne;
int heightDecreasedByOne;
inline void topLeft(int offset, IntPoint& normalVector);
inline void topRow(int offset, IntPoint& normalVector);
inline void topRight(int offset, IntPoint& normalVector);
inline void leftColumn(int offset, IntPoint& normalVector);
inline void interior(int offset, IntPoint& normalVector);
inline void rightColumn(int offset, IntPoint& normalVector);
inline void bottomLeft(int offset, IntPoint& normalVector);
inline void bottomRow(int offset, IntPoint& normalVector);
inline void bottomRight(int offset, IntPoint& normalVector);
};
FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>);
bool drawLighting(ByteArray*, int, int);
inline void inlineSetPixel(int offset, LightingData&, LightSource::PaintingData&,
int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector);
void setPixel(int offset, LightingData&, LightSource::PaintingData&,
int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector);
inline void platformApply(LightingData&, LightSource::PaintingData&);
inline void platformApplyGeneric(LightingData&, LightSource::PaintingData&);
static int getPowerCoefficients(float exponent);
inline void platformApplyNeon(LightingData&, LightSource::PaintingData&);
LightingType m_lightingType;
RefPtr<LightSource> m_lightSource;
Color m_lightingColor;
float m_surfaceScale;
float m_diffuseConstant;
float m_specularConstant;
float m_specularExponent;
float m_kernelUnitLengthX;
float m_kernelUnitLengthY;
};
}
#endif // ENABLE(FILTERS)
#endif // FELighting_h