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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « samplecode/SamplePathFuzz.cpp ('k') | src/core/SkTaskGroup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // Need to include something before #if SK_SUPPORT_GPU so that the Android 8 // Need to include something before #if SK_SUPPORT_GPU so that the Android
9 // framework build, which gets its defines from SkTypes rather than a makefile, 9 // framework build, which gets its defines from SkTypes rather than a makefile,
10 // has the definition before checking it. 10 // has the definition before checking it.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ~AutoMPDReset() { fMPD->reset(); } 84 ~AutoMPDReset() { fMPD->reset(); }
85 }; 85 };
86 86
87 //#define FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING 87 //#define FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
88 88
89 void SkMultiPictureDraw::draw(bool flush) { 89 void SkMultiPictureDraw::draw(bool flush) {
90 AutoMPDReset mpdreset(this); 90 AutoMPDReset mpdreset(this);
91 91
92 #ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING 92 #ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
93 for (int i = 0; i < fThreadSafeDrawData.count(); ++i) { 93 for (int i = 0; i < fThreadSafeDrawData.count(); ++i) {
94 DrawData* dd = &fThreadSafeDrawData.begin()[i]; 94 fThreadSafeDrawData[i].draw();
95 dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint);
96 } 95 }
97 #else 96 #else
98 // we place the taskgroup after the MPDReset, to ensure that we don't delete the DrawData 97 sk_parallel_for(fThreadSafeDrawData.count(), [&](int i) {
99 // objects until after we're finished the tasks (which have pointers to the data). 98 fThreadSafeDrawData[i].draw();
100 SkTaskGroup group; 99 });
101 group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData .count());
102 #endif 100 #endif
103 // we deliberately don't call wait() here, since the destructor will do that , this allows us 101
104 // to continue processing gpu-data without having to wait on the cpu tasks. 102 // N.B. we could get going on any GPU work from this main thread while the C PU work runs.
103 // But in practice, we've either got GPU work or CPU work, not both.
105 104
106 const int count = fGPUDrawData.count(); 105 const int count = fGPUDrawData.count();
107 if (0 == count) { 106 if (0 == count) {
108 return; 107 return;
109 } 108 }
110 109
111 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU 110 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU
112 GrContext* context = fGPUDrawData[0].fCanvas->getGrContext(); 111 GrContext* context = fGPUDrawData[0].fCanvas->getGrContext();
113 SkASSERT(context); 112 SkASSERT(context);
114 113
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 198
200 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU 199 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU
201 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); 200 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering);
202 GrLayerHoister::UnlockLayers(context, atlasedRecycled); 201 GrLayerHoister::UnlockLayers(context, atlasedRecycled);
203 #if !GR_CACHE_HOISTED_LAYERS 202 #if !GR_CACHE_HOISTED_LAYERS
204 GrLayerHoister::PurgeCache(context); 203 GrLayerHoister::PurgeCache(context);
205 #endif 204 #endif
206 #endif 205 #endif
207 } 206 }
208 207
OLDNEW
« 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