2 * Copyright (C) 2010 University of Szeged
3 * Copyright (C) 2010 Zoltan Herczeg
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "FilterEffect.h"
34 #include "LightSource.h"
35 #include "PointLightSource.h"
36 #include "SpotLightSource.h"
37 #include <wtf/ByteArray.h>
38 #include <wtf/Platform.h>
40 // Common base class for FEDiffuseLighting and FESpecularLighting
44 struct FELightingPaintingDataForNeon;
46 class FELighting : public FilterEffect {
48 virtual void platformApplySoftware();
50 virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
53 #if ENABLE(PARALLEL_JOBS)
54 static const int s_minimalRectDimension = 100 * 100; // Empirical data limit for parallel jobs
63 // This structure contains only read-only (SMP safe) data
66 int widthMultipliedByPixelSize;
67 int widthDecreasedByOne;
68 int heightDecreasedByOne;
70 inline void topLeft(int offset, IntPoint& normalVector);
71 inline void topRow(int offset, IntPoint& normalVector);
72 inline void topRight(int offset, IntPoint& normalVector);
73 inline void leftColumn(int offset, IntPoint& normalVector);
74 inline void interior(int offset, IntPoint& normalVector);
75 inline void rightColumn(int offset, IntPoint& normalVector);
76 inline void bottomLeft(int offset, IntPoint& normalVector);
77 inline void bottomRow(int offset, IntPoint& normalVector);
78 inline void bottomRight(int offset, IntPoint& normalVector);
81 #if ENABLE(PARALLEL_JOBS)
82 template<typename Type>
83 friend class ParallelJobs;
85 struct PlatformApplyGenericParameters {
88 LightSource::PaintingData paintingData;
93 static void platformApplyGenericWorker(PlatformApplyGenericParameters*);
94 static void platformApplyNeonWorker(FELightingPaintingDataForNeon*);
97 FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>);
99 bool drawLighting(ByteArray*, int, int);
100 inline void inlineSetPixel(int offset, LightingData&, LightSource::PaintingData&,
101 int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector);
103 // Not worth to inline every occurence of setPixel.
104 void setPixel(int offset, LightingData&, LightSource::PaintingData&,
105 int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector);
107 inline void platformApply(LightingData&, LightSource::PaintingData&);
109 inline void platformApplyGenericPaint(LightingData&, LightSource::PaintingData&, int startX, int startY);
110 inline void platformApplyGeneric(LightingData&, LightSource::PaintingData&);
112 static int getPowerCoefficients(float exponent);
113 inline void platformApplyNeon(LightingData&, LightSource::PaintingData&);
115 LightingType m_lightingType;
116 RefPtr<LightSource> m_lightSource;
118 Color m_lightingColor;
119 float m_surfaceScale;
120 float m_diffuseConstant;
121 float m_specularConstant;
122 float m_specularExponent;
123 float m_kernelUnitLengthX;
124 float m_kernelUnitLengthY;
127 } // namespace WebCore
129 #endif // ENABLE(FILTERS)
131 #endif // FELighting_h