Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: Source/WebCore/platform/graphics/filters/FEMorphology.cpp

Issue 11192059: Merge 129796 - Rewrite multithreaded filter job dispatching (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1271/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 param->filter->platformApplyGeneric(param->paintingData, param->startY, para m->endY); 166 param->filter->platformApplyGeneric(param->paintingData, param->startY, para m->endY);
167 } 167 }
168 168
169 void FEMorphology::platformApply(PaintingData* paintingData) 169 void FEMorphology::platformApply(PaintingData* paintingData)
170 { 170 {
171 int optimalThreadNumber = (paintingData->width * paintingData->height) / s_m inimalArea; 171 int optimalThreadNumber = (paintingData->width * paintingData->height) / s_m inimalArea;
172 if (optimalThreadNumber > 1) { 172 if (optimalThreadNumber > 1) {
173 ParallelJobs<PlatformApplyParameters> parallelJobs(&WebCore::FEMorpholog y::platformApplyWorker, optimalThreadNumber); 173 ParallelJobs<PlatformApplyParameters> parallelJobs(&WebCore::FEMorpholog y::platformApplyWorker, optimalThreadNumber);
174 int numOfThreads = parallelJobs.numberOfJobs(); 174 int numOfThreads = parallelJobs.numberOfJobs();
175 if (numOfThreads > 1) { 175 if (numOfThreads > 1) {
176 const int deltaY = 1 + paintingData->height / numOfThreads; 176 // Split the job into "jobSize"-sized jobs but there a few jobs that need to be slightly larger since
177 // jobSize * jobs < total size. These extras are handled by the rema inder "jobsWithExtra".
178 const int jobSize = paintingData->height / numOfThreads;
179 const int jobsWithExtra = paintingData->height % numOfThreads;
177 int currentY = 0; 180 int currentY = 0;
178 for (int job = numOfThreads - 1; job >= 0; --job) { 181 for (int job = numOfThreads - 1; job >= 0; --job) {
179 PlatformApplyParameters& param = parallelJobs.parameter(job); 182 PlatformApplyParameters& param = parallelJobs.parameter(job);
180 param.filter = this; 183 param.filter = this;
181 param.startY = currentY; 184 param.startY = currentY;
182 currentY += deltaY; 185 currentY += job < jobsWithExtra ? jobSize + 1 : jobSize;
183 param.endY = job ? currentY : paintingData->height; 186 param.endY = currentY;
184 param.paintingData = paintingData; 187 param.paintingData = paintingData;
185 } 188 }
186 parallelJobs.execute(); 189 parallelJobs.execute();
187 return; 190 return;
188 } 191 }
189 // Fallback to single thread model 192 // Fallback to single thread model
190 } 193 }
191 194
192 platformApplyGeneric(paintingData, 0, paintingData->height); 195 platformApplyGeneric(paintingData, 0, paintingData->height);
193 } 196 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 FilterEffect::externalRepresentation(ts); 255 FilterEffect::externalRepresentation(ts);
253 ts << " operator=\"" << morphologyOperator() << "\" " 256 ts << " operator=\"" << morphologyOperator() << "\" "
254 << "radius=\"" << radiusX() << ", " << radiusY() << "\"]\n"; 257 << "radius=\"" << radiusX() << ", " << radiusY() << "\"]\n";
255 inputEffect(0)->externalRepresentation(ts, indent + 1); 258 inputEffect(0)->externalRepresentation(ts, indent + 1);
256 return ts; 259 return ts;
257 } 260 }
258 261
259 } // namespace WebCore 262 } // namespace WebCore
260 263
261 #endif // ENABLE(FILTERS) 264 #endif // ENABLE(FILTERS)
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/filters/FELighting.cpp ('k') | Source/WebCore/platform/graphics/filters/FETurbulence.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698