OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |