Changeset 86759 in webkit
- Timestamp:
- May 18, 2011 7:27:28 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86758 r86759 1 2011-05-18 Gabor Loki <loki@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Apply the ParallelJobs support to FELighting 6 https://bugs.webkit.org/show_bug.cgi?id=61048 7 8 The lighting filter of SVG can consume lots of resources if it is 9 applied to a large area. The computation can be distributed to multiple 10 cores if the architecture supports. 11 The average performance progression is 10-20% on dual-core machines. 12 13 Developed in cooperation with Zoltan Herczeg. 14 15 * platform/graphics/filters/FELighting.cpp: 16 (WebCore::FELighting::platformApplyGenericPaint): 17 (WebCore::FELighting::platformApplyGenericWorker): 18 (WebCore::FELighting::platformApplyGeneric): 19 * platform/graphics/filters/FELighting.h: 20 * platform/graphics/filters/arm/FELightingNEON.cpp: 21 (WebCore::FELighting::platformApplyNeonWorker): 22 * platform/graphics/filters/arm/FELightingNEON.h: 23 (WebCore::FELighting::platformApplyNeon): 24 1 25 2011-05-18 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2 26 -
trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp
r85180 r86759 31 31 32 32 #include "FELightingNEON.h" 33 #include <wtf/ParallelJobs.h> 33 34 34 35 namespace WebCore { … … 228 229 } 229 230 230 inline void FELighting::platformApplyGeneric (LightingData& data, LightSource::PaintingData& paintingData)231 inline void FELighting::platformApplyGenericPaint(LightingData& data, LightSource::PaintingData& paintingData, int startY, int endY) 231 232 { 232 233 IntPoint normalVector; 233 234 int offset = 0; 234 235 235 for (int y = 1; y < data.heightDecreasedByOne; ++y) {236 for (int y = startY; y < endY; ++y) { 236 237 offset = y * data.widthMultipliedByPixelSize + cPixelSize; 237 238 for (int x = 1; x < data.widthDecreasedByOne; ++x, offset += cPixelSize) { … … 240 241 } 241 242 } 243 } 244 245 #if ENABLE(PARALLEL_JOBS) 246 void FELighting::platformApplyGenericWorker(PlatformApplyGenericParameters* parameters) 247 { 248 parameters->filter->platformApplyGenericPaint(parameters->data, parameters->paintingData, parameters->yStart, parameters->yEnd); 249 } 250 #endif // ENABLE(PARALLEL_JOBS) 251 252 inline void FELighting::platformApplyGeneric(LightingData& data, LightSource::PaintingData& paintingData) 253 { 254 #if ENABLE(PARALLEL_JOBS) 255 int optimalThreadNumber = ((data.widthDecreasedByOne - 1) * (data.heightDecreasedByOne - 1)) / s_minimalRectDimension; 256 if (optimalThreadNumber > 1) { 257 // Initialize parallel jobs 258 ParallelJobs<PlatformApplyGenericParameters> parallelJobs(&platformApplyGenericWorker, optimalThreadNumber); 259 260 // Fill the parameter array 261 int job = parallelJobs.numberOfJobs(); 262 if (job > 1) { 263 int yStart = 1; 264 int yStep = (data.widthDecreasedByOne - 1) / job; 265 for (--job; job >= 0; --job) { 266 PlatformApplyGenericParameters& params = parallelJobs.parameter(job); 267 params.filter = this; 268 params.data = data; 269 params.paintingData = paintingData; 270 params.yStart = yStart; 271 if (job > 0) { 272 params.yEnd = yStart + yStep; 273 yStart += yStep; 274 } else 275 params.yEnd = data.heightDecreasedByOne; 276 } 277 parallelJobs.execute(); 278 return; 279 } 280 } 281 #endif 282 platformApplyGenericPaint(data, paintingData, 1, data.heightDecreasedByOne); 242 283 } 243 284 -
trunk/Source/WebCore/platform/graphics/filters/FELighting.h
r85926 r86759 42 42 namespace WebCore { 43 43 44 struct FELightingPaintingDataForNeon; 45 44 46 class FELighting : public FilterEffect { 45 47 public: … … 49 51 50 52 protected: 53 #if ENABLE(PARALLEL_JOBS) 54 static const int s_minimalRectDimension = 100 * 100; // Empirical data limit for parallel jobs 55 #endif 56 51 57 enum LightingType { 52 58 DiffuseLighting, … … 73 79 }; 74 80 81 #if ENABLE(PARALLEL_JOBS) 82 template<typename Type> 83 friend class ParallelJobs; 84 85 struct PlatformApplyGenericParameters { 86 FELighting* filter; 87 LightingData data; 88 LightSource::PaintingData paintingData; 89 int yStart; 90 int yEnd; 91 }; 92 93 static void platformApplyGenericWorker(PlatformApplyGenericParameters*); 94 static void platformApplyNeonWorker(FELightingPaintingDataForNeon*); 95 #endif 96 75 97 FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); 76 98 … … 85 107 inline void platformApply(LightingData&, LightSource::PaintingData&); 86 108 109 inline void platformApplyGenericPaint(LightingData&, LightSource::PaintingData&, int startX, int startY); 87 110 inline void platformApplyGeneric(LightingData&, LightSource::PaintingData&); 111 88 112 static int getPowerCoefficients(float exponent); 89 113 inline void platformApplyNeon(LightingData&, LightSource::PaintingData&); -
trunk/Source/WebCore/platform/graphics/filters/arm/FELightingNEON.cpp
r85180 r86759 51 51 } 52 52 53 #if ENABLE(PARALLEL_JOBS) 54 void FELighting::platformApplyNeonWorker(FELightingPaintingDataForNeon* parameters) 55 { 56 neonDrawLighting(parameters); 57 } 58 #endif 59 53 60 #define ASSTRING(str) #str 54 61 #define TOSTRING(value) ASSTRING(value) 55 62 56 63 #define PIXELS_OFFSET TOSTRING(0) 57 #define WIDTH_OFFSET TOSTRING(4) 58 #define HEIGHT_OFFSET TOSTRING(8) 59 #define FLAGS_OFFSET TOSTRING(12) 60 #define SPECULAR_EXPONENT_OFFSET TOSTRING(16) 61 #define CONE_EXPONENT_OFFSET TOSTRING(20) 62 #define FLOAT_ARGUMENTS_OFFSET TOSTRING(24) 63 #define PAINTING_CONSTANTS_OFFSET TOSTRING(28) 64 #define YSTART_OFFSET TOSTRING(4) 65 #define WIDTH_OFFSET TOSTRING(8) 66 #define HEIGHT_OFFSET TOSTRING(12) 67 #define FLAGS_OFFSET TOSTRING(16) 68 #define SPECULAR_EXPONENT_OFFSET TOSTRING(20) 69 #define CONE_EXPONENT_OFFSET TOSTRING(24) 70 #define FLOAT_ARGUMENTS_OFFSET TOSTRING(28) 71 #define PAINTING_CONSTANTS_OFFSET TOSTRING(32) 64 72 #define NL "\n" 65 73 … … 222 230 "ldr r1, [" PAINTING_DATA_R ", #" PAINTING_CONSTANTS_OFFSET "]" NL 223 231 "ldr " PIXELS_R ", [" PAINTING_DATA_R ", #" PIXELS_OFFSET "]" NL 232 "vldr.f32 " POSITION_Y_S ", [" PAINTING_DATA_R ", #" YSTART_OFFSET "]" NL 224 233 "ldr " WIDTH_R ", [" PAINTING_DATA_R ", #" WIDTH_OFFSET "]" NL 225 234 "ldr " HEIGHT_R ", [" PAINTING_DATA_R ", #" HEIGHT_OFFSET "]" NL … … 242 251 "mov r0, #0" NL 243 252 "vmov.f32 " CONST_ZERO_S ", r0" NL 244 "vmov.f32 " POSITION_Y_S ", " CONST_ONE_S NL245 253 "tst " FLAGS_R ", #" TOSTRING(FLAG_SPOT_LIGHT) NL 246 254 "vmov.f32 " SPOT_COLOR_Q ", " COLOR_Q NL -
trunk/Source/WebCore/platform/graphics/filters/arm/FELightingNEON.h
r85180 r86759 34 34 #include "FELighting.h" 35 35 #include <wtf/Alignment.h> 36 #include <wtf/ParallelJobs.h> 36 37 37 38 namespace WebCore { … … 77 78 struct FELightingPaintingDataForNeon { 78 79 unsigned char* pixels; 80 float yStart; 79 81 int widthDecreasedByTwo; 80 int heightDecreasedByTwo;82 int absoluteHeight; 81 83 // Combination of FLAG constants above. 82 84 int flags; … … 99 101 FELightingPaintingDataForNeon neonData = { 100 102 data.pixels->data(), 103 1, 101 104 data.widthDecreasedByOne - 1, 102 105 data.heightDecreasedByOne - 1, … … 165 168 neonData.flags |= FLAG_DIFFUSE_CONST_IS_1; 166 169 170 #if ENABLE(PARALLEL_JOBS) 171 int optimalThreadNumber = ((data.widthDecreasedByOne - 1) * (data.heightDecreasedByOne - 1)) / s_minimalRectDimension; 172 if (optimalThreadNumber > 1) { 173 // Initialize parallel jobs 174 ParallelJobs<FELightingPaintingDataForNeon> parallelJobs(&WebCore::FELighting::platformApplyNeonWorker, optimalThreadNumber); 175 176 // Fill the parameter array 177 int job = parallelJobs.numberOfJobs(); 178 if (job > 1) { 179 int yStart = 1; 180 int yStep = (data.heightDecreasedByOne - 1) / job; 181 for (--job; job >= 0; --job) { 182 FELightingPaintingDataForNeon& params = parallelJobs.parameter(job); 183 params = neonData; 184 params.yStart = yStart; 185 params.pixels += (yStart - 1) * (data.widthDecreasedByOne + 1) * 4; 186 if (job > 0) { 187 params.absoluteHeight = yStep; 188 yStart += yStep; 189 } else 190 params.absoluteHeight = data.heightDecreasedByOne - yStart; 191 } 192 parallelJobs.execute(); 193 return; 194 } 195 } 196 #endif 197 167 198 neonDrawLighting(&neonData); 168 199 }
Note: See TracChangeset
for help on using the changeset viewer.