| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 array.append()->init(canvas, picture, matrix, paint); | 77 array.append()->init(canvas, picture, matrix, paint); |
| 78 } | 78 } |
| 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 |
| 88 |
| 87 void SkMultiPictureDraw::draw() { | 89 void SkMultiPictureDraw::draw() { |
| 88 AutoMPDReset mpdreset(this); | 90 AutoMPDReset mpdreset(this); |
| 91 |
| 92 #ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING |
| 93 for (int i = 0; i < fThreadSafeDrawData.count(); ++i) { |
| 94 DrawData* dd = &fThreadSafeDrawData.begin()[i]; |
| 95 dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint); |
| 96 } |
| 97 #else |
| 89 // 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 |
| 90 // 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). |
| 91 | |
| 92 SkTaskGroup group; | 100 SkTaskGroup group; |
| 93 group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData
.count()); | 101 group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData
.count()); |
| 102 #endif |
| 94 // we deliberately don't call wait() here, since the destructor will do that
, this allows us | 103 // we deliberately don't call wait() here, since the destructor will do that
, this allows us |
| 95 // to continue processing gpu-data without having to wait on the cpu tasks. | 104 // to continue processing gpu-data without having to wait on the cpu tasks. |
| 96 | 105 |
| 97 const int count = fGPUDrawData.count(); | 106 const int count = fGPUDrawData.count(); |
| 98 if (0 == count) { | 107 if (0 == count) { |
| 99 return; | 108 return; |
| 100 } | 109 } |
| 101 | 110 |
| 102 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU | 111 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU |
| 103 GrContext* context = fGPUDrawData[0].fCanvas->getGrContext(); | 112 GrContext* context = fGPUDrawData[0].fCanvas->getGrContext(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 196 |
| 188 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU | 197 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU |
| 189 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); | 198 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); |
| 190 GrLayerHoister::UnlockLayers(context, atlasedRecycled); | 199 GrLayerHoister::UnlockLayers(context, atlasedRecycled); |
| 191 #if !GR_CACHE_HOISTED_LAYERS | 200 #if !GR_CACHE_HOISTED_LAYERS |
| 192 GrLayerHoister::PurgeCache(context); | 201 GrLayerHoister::PurgeCache(context); |
| 193 #endif | 202 #endif |
| 194 #endif | 203 #endif |
| 195 } | 204 } |
| 196 | 205 |
| OLD | NEW |