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

Unified Diff: src/core/SkMultiPictureDraw.cpp

Issue 1184373003: Add sk_parallel_for() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SamplePathFuzz.cpp ('k') | src/core/SkTaskGroup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMultiPictureDraw.cpp
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp
index 22fd05fb08170328bdcffaa2e08d961b6ee8a002..286d3b648952a27cd2d65a9ee2d85cc5a9af5829 100644
--- a/src/core/SkMultiPictureDraw.cpp
+++ b/src/core/SkMultiPictureDraw.cpp
@@ -91,17 +91,16 @@ void SkMultiPictureDraw::draw(bool flush) {
#ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
for (int i = 0; i < fThreadSafeDrawData.count(); ++i) {
- DrawData* dd = &fThreadSafeDrawData.begin()[i];
- dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint);
+ fThreadSafeDrawData[i].draw();
}
#else
- // we place the taskgroup after the MPDReset, to ensure that we don't delete the DrawData
- // objects until after we're finished the tasks (which have pointers to the data).
- SkTaskGroup group;
- group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData.count());
+ sk_parallel_for(fThreadSafeDrawData.count(), [&](int i) {
+ fThreadSafeDrawData[i].draw();
+ });
#endif
- // we deliberately don't call wait() here, since the destructor will do that, this allows us
- // to continue processing gpu-data without having to wait on the cpu tasks.
+
+ // N.B. we could get going on any GPU work from this main thread while the CPU work runs.
+ // But in practice, we've either got GPU work or CPU work, not both.
const int count = fGPUDrawData.count();
if (0 == count) {
« no previous file with comments | « samplecode/SamplePathFuzz.cpp ('k') | src/core/SkTaskGroup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698