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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 class AutoMPDReset : SkNoncopyable { | 80 class AutoMPDReset : SkNoncopyable { |
81 SkMultiPictureDraw* fMPD; | 81 SkMultiPictureDraw* fMPD; |
82 public: | 82 public: |
83 AutoMPDReset(SkMultiPictureDraw* mpd) : fMPD(mpd) {} | 83 AutoMPDReset(SkMultiPictureDraw* mpd) : fMPD(mpd) {} |
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() { | 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 DrawData* dd = &fThreadSafeDrawData.begin()[i]; |
95 dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint); | 95 dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint); |
96 } | 96 } |
97 #else | 97 #else |
98 // we place the taskgroup after the MPDReset, to ensure that we don't delete
the DrawData | 98 // we place the taskgroup after the MPDReset, to ensure that we don't delete
the DrawData |
99 // objects until after we're finished the tasks (which have pointers to the
data). | 99 // objects until after we're finished the tasks (which have pointers to the
data). |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 GrLayerHoister::UnlockLayers(context, needRendering); | 185 GrLayerHoister::UnlockLayers(context, needRendering); |
186 GrLayerHoister::UnlockLayers(context, recycled); | 186 GrLayerHoister::UnlockLayers(context, recycled); |
187 | 187 |
188 needRendering.rewind(); | 188 needRendering.rewind(); |
189 recycled.rewind(); | 189 recycled.rewind(); |
190 } else | 190 } else |
191 #endif | 191 #endif |
192 { | 192 { |
193 canvas->drawPicture(picture, &data.fMatrix, data.fPaint); | 193 canvas->drawPicture(picture, &data.fMatrix, data.fPaint); |
194 } | 194 } |
| 195 if (flush) { |
| 196 canvas->flush(); |
| 197 } |
195 } | 198 } |
196 | 199 |
197 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU | 200 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU |
198 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); | 201 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); |
199 GrLayerHoister::UnlockLayers(context, atlasedRecycled); | 202 GrLayerHoister::UnlockLayers(context, atlasedRecycled); |
200 #if !GR_CACHE_HOISTED_LAYERS | 203 #if !GR_CACHE_HOISTED_LAYERS |
201 GrLayerHoister::PurgeCache(context); | 204 GrLayerHoister::PurgeCache(context); |
202 #endif | 205 #endif |
203 #endif | 206 #endif |
204 } | 207 } |
205 | 208 |
OLD | NEW |