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

Side by Side Diff: Source/WebCore/platform/graphics/filters/FEConvolveMatrix.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) 2010 Zoltan Herczeg <zherczeg@webkit.org> 6 * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // Drawing fully covered pixels 437 // Drawing fully covered pixels
438 int clipRight = paintSize.width() - m_kernelSize.width(); 438 int clipRight = paintSize.width() - m_kernelSize.width();
439 int clipBottom = paintSize.height() - m_kernelSize.height(); 439 int clipBottom = paintSize.height() - m_kernelSize.height();
440 440
441 if (clipRight >= 0 && clipBottom >= 0) { 441 if (clipRight >= 0 && clipBottom >= 0) {
442 442
443 int optimalThreadNumber = (absolutePaintRect().width() * absolutePaintRe ct().height()) / s_minimalRectDimension; 443 int optimalThreadNumber = (absolutePaintRect().width() * absolutePaintRe ct().height()) / s_minimalRectDimension;
444 if (optimalThreadNumber > 1) { 444 if (optimalThreadNumber > 1) {
445 WTF::ParallelJobs<InteriorPixelParameters> parallelJobs(&WebCore::FE ConvolveMatrix::setInteriorPixelsWorker, optimalThreadNumber); 445 WTF::ParallelJobs<InteriorPixelParameters> parallelJobs(&WebCore::FE ConvolveMatrix::setInteriorPixelsWorker, optimalThreadNumber);
446 const int numOfThreads = parallelJobs.numberOfJobs(); 446 const int numOfThreads = parallelJobs.numberOfJobs();
447
448 // Split the job into "heightPerThread" jobs but there a few jobs th at need to be slightly larger since
449 // heightPerThread * jobs < total size. These extras are handled by the remainder "jobsWithExtra".
447 const int heightPerThread = clipBottom / numOfThreads; 450 const int heightPerThread = clipBottom / numOfThreads;
451 const int jobsWithExtra = clipBottom % numOfThreads;
452
448 int startY = 0; 453 int startY = 0;
449
450 for (int job = 0; job < numOfThreads; ++job) { 454 for (int job = 0; job < numOfThreads; ++job) {
451 InteriorPixelParameters& param = parallelJobs.parameter(job); 455 InteriorPixelParameters& param = parallelJobs.parameter(job);
452 param.filter = this; 456 param.filter = this;
453 param.paintingData = &paintingData; 457 param.paintingData = &paintingData;
454 param.clipRight = clipRight; 458 param.clipRight = clipRight;
455 param.clipBottom = clipBottom; 459 param.clipBottom = clipBottom;
456 param.yStart = startY; 460 param.yStart = startY;
457 if (job < numOfThreads - 1) { 461 startY += job < jobsWithExtra ? heightPerThread + 1 : heightPerT hread;
458 startY += heightPerThread; 462 param.yEnd = startY;
459 param.yEnd = startY - 1;
460 } else
461 param.yEnd = clipBottom;
462 } 463 }
463 464
464 parallelJobs.execute(); 465 parallelJobs.execute();
465 } else { 466 } else {
466 // Fallback to single threaded mode. 467 // Fallback to single threaded mode.
467 setInteriorPixels(paintingData, clipRight, clipBottom, 0, clipBottom ); 468 setInteriorPixels(paintingData, clipRight, clipBottom, 0, clipBottom );
468 } 469 }
469 470
470 clipRight += m_targetOffset.x() + 1; 471 clipRight += m_targetOffset.x() + 1;
471 clipBottom += m_targetOffset.y() + 1; 472 clipBottom += m_targetOffset.y() + 1;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 << "edgeMode=\"" << m_edgeMode << "\" " 520 << "edgeMode=\"" << m_edgeMode << "\" "
520 << "kernelUnitLength=\"" << m_kernelUnitLength << "\" " 521 << "kernelUnitLength=\"" << m_kernelUnitLength << "\" "
521 << "preserveAlpha=\"" << m_preserveAlpha << "\"]\n"; 522 << "preserveAlpha=\"" << m_preserveAlpha << "\"]\n";
522 inputEffect(0)->externalRepresentation(ts, indent + 1); 523 inputEffect(0)->externalRepresentation(ts, indent + 1);
523 return ts; 524 return ts;
524 } 525 }
525 526
526 }; // namespace WebCore 527 }; // namespace WebCore
527 528
528 #endif // ENABLE(FILTERS) 529 #endif // ENABLE(FILTERS)
OLDNEW
« no previous file with comments | « LayoutTests/svg/filters/feMorphology-crash-expected.txt ('k') | Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698