| 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 19 matching lines...) Expand all Loading... |
| 30 fPicture = SkRef(picture); | 30 fPicture = SkRef(picture); |
| 31 fCanvas = SkRef(canvas); | 31 fCanvas = SkRef(canvas); |
| 32 if (matrix) { | 32 if (matrix) { |
| 33 fMatrix = *matrix; | 33 fMatrix = *matrix; |
| 34 } else { | 34 } else { |
| 35 fMatrix.setIdentity(); | 35 fMatrix.setIdentity(); |
| 36 } | 36 } |
| 37 if (paint) { | 37 if (paint) { |
| 38 fPaint = new SkPaint(*paint); | 38 fPaint = new SkPaint(*paint); |
| 39 } else { | 39 } else { |
| 40 fPaint = NULL; | 40 fPaint = nullptr; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 void SkMultiPictureDraw::DrawData::Reset(SkTDArray<DrawData>& data) { | 44 void SkMultiPictureDraw::DrawData::Reset(SkTDArray<DrawData>& data) { |
| 45 for (int i = 0; i < data.count(); ++i) { | 45 for (int i = 0; i < data.count(); ++i) { |
| 46 data[i].fPicture->unref(); | 46 data[i].fPicture->unref(); |
| 47 data[i].fCanvas->unref(); | 47 data[i].fCanvas->unref(); |
| 48 delete data[i].fPaint; | 48 delete data[i].fPaint; |
| 49 } | 49 } |
| 50 data.rewind(); | 50 data.rewind(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 | 61 |
| 62 void SkMultiPictureDraw::reset() { | 62 void SkMultiPictureDraw::reset() { |
| 63 DrawData::Reset(fGPUDrawData); | 63 DrawData::Reset(fGPUDrawData); |
| 64 DrawData::Reset(fThreadSafeDrawData); | 64 DrawData::Reset(fThreadSafeDrawData); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void SkMultiPictureDraw::add(SkCanvas* canvas, | 67 void SkMultiPictureDraw::add(SkCanvas* canvas, |
| 68 const SkPicture* picture, | 68 const SkPicture* picture, |
| 69 const SkMatrix* matrix, | 69 const SkMatrix* matrix, |
| 70 const SkPaint* paint) { | 70 const SkPaint* paint) { |
| 71 if (NULL == canvas || NULL == picture) { | 71 if (nullptr == canvas || nullptr == picture) { |
| 72 SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-NULL"); | 72 SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-nullptr
"); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 | 75 |
| 76 SkTDArray<DrawData>& array = canvas->getGrContext() ? fGPUDrawData : fThread
SafeDrawData; | 76 SkTDArray<DrawData>& array = canvas->getGrContext() ? fGPUDrawData : fThread
SafeDrawData; |
| 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: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Find the layers required by this canvas. It will return atlased | 172 // Find the layers required by this canvas. It will return atlased |
| 173 // layers in the 'recycled' list since they have already been drawn. | 173 // layers in the 'recycled' list since they have already been drawn. |
| 174 GrLayerHoister::FindLayersToHoist(context, picture, initialMatrix, | 174 GrLayerHoister::FindLayersToHoist(context, picture, initialMatrix, |
| 175 clipBounds, &needRendering, &recyc
led, | 175 clipBounds, &needRendering, &recyc
led, |
| 176 rt->numColorSamples()); | 176 rt->numColorSamples()); |
| 177 | 177 |
| 178 GrLayerHoister::DrawLayers(context, needRendering); | 178 GrLayerHoister::DrawLayers(context, needRendering); |
| 179 | 179 |
| 180 // Render the entire picture using new layers | 180 // Render the entire picture using new layers |
| 181 GrRecordReplaceDraw(picture, canvas, context->getLayerCache(), | 181 GrRecordReplaceDraw(picture, canvas, context->getLayerCache(), |
| 182 initialMatrix, NULL); | 182 initialMatrix, nullptr); |
| 183 | 183 |
| 184 GrLayerHoister::UnlockLayers(context, needRendering); | 184 GrLayerHoister::UnlockLayers(context, needRendering); |
| 185 GrLayerHoister::UnlockLayers(context, recycled); | 185 GrLayerHoister::UnlockLayers(context, recycled); |
| 186 | 186 |
| 187 needRendering.rewind(); | 187 needRendering.rewind(); |
| 188 recycled.rewind(); | 188 recycled.rewind(); |
| 189 } else | 189 } else |
| 190 #endif | 190 #endif |
| 191 { | 191 { |
| 192 canvas->drawPicture(picture, &data.fMatrix, data.fPaint); | 192 canvas->drawPicture(picture, &data.fMatrix, data.fPaint); |
| 193 } | 193 } |
| 194 if (flush) { | 194 if (flush) { |
| 195 canvas->flush(); | 195 canvas->flush(); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU | 199 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU |
| 200 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); | 200 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); |
| 201 GrLayerHoister::UnlockLayers(context, atlasedRecycled); | 201 GrLayerHoister::UnlockLayers(context, atlasedRecycled); |
| 202 #if !GR_CACHE_HOISTED_LAYERS | 202 #if !GR_CACHE_HOISTED_LAYERS |
| 203 GrLayerHoister::PurgeCache(context); | 203 GrLayerHoister::PurgeCache(context); |
| 204 #endif | 204 #endif |
| 205 #endif | 205 #endif |
| 206 } | 206 } |
| 207 | 207 |
| OLD | NEW |