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

Side by Side Diff: src/core/SkMultiPictureDraw.cpp

Issue 698493002: Always enable layer hoisting in Skia (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-gpu build Created 6 years, 1 month 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 | « gyp/skia_for_chromium_defines.gypi ('k') | no next file » | 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 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 #include "GrLayerHoister.h" 9 #include "GrLayerHoister.h"
10 #include "GrRecordReplaceDraw.h" 10 #include "GrRecordReplaceDraw.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const SkPaint* paint) { 64 const SkPaint* paint) {
65 if (NULL == canvas || NULL == picture) { 65 if (NULL == canvas || NULL == picture) {
66 SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-NULL"); 66 SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-NULL");
67 return; 67 return;
68 } 68 }
69 69
70 SkTDArray<DrawData>& array = canvas->getGrContext() ? fGPUDrawData : fThread SafeDrawData; 70 SkTDArray<DrawData>& array = canvas->getGrContext() ? fGPUDrawData : fThread SafeDrawData;
71 array.append()->init(canvas, picture, matrix, paint); 71 array.append()->init(canvas, picture, matrix, paint);
72 } 72 }
73 73
74 #undef SK_IGNORE_GPU_LAYER_HOISTING
75 #define SK_IGNORE_GPU_LAYER_HOISTING 1
76
77 class AutoMPDReset : SkNoncopyable { 74 class AutoMPDReset : SkNoncopyable {
78 SkMultiPictureDraw* fMPD; 75 SkMultiPictureDraw* fMPD;
79 public: 76 public:
80 AutoMPDReset(SkMultiPictureDraw* mpd) : fMPD(mpd) {} 77 AutoMPDReset(SkMultiPictureDraw* mpd) : fMPD(mpd) {}
81 ~AutoMPDReset() { fMPD->reset(); } 78 ~AutoMPDReset() { fMPD->reset(); }
82 }; 79 };
83 80
84 void SkMultiPictureDraw::draw() { 81 void SkMultiPictureDraw::draw() {
85 AutoMPDReset mpdreset(this); 82 AutoMPDReset mpdreset(this);
86 // we place the taskgroup after the MPDReset, to ensure that we don't delete the DrawData 83 // we place the taskgroup after the MPDReset, to ensure that we don't delete the DrawData
87 // objects until after we're finished the tasks (which have pointers to the data). 84 // objects until after we're finished the tasks (which have pointers to the data).
88 85
89 #if 0 86 #if 0
90 SkTaskGroup group; 87 SkTaskGroup group;
91 group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData .count()); 88 group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData .count());
92 // we deliberately don't call wait() here, since the destructor will do that , this allows us 89 // we deliberately don't call wait() here, since the destructor will do that , this allows us
93 // to continue processing gpu-data without having to wait on the cpu tasks. 90 // to continue processing gpu-data without having to wait on the cpu tasks.
94 #else 91 #else
95 for (int i = 0; i < fThreadSafeDrawData.count(); i++) { 92 for (int i = 0; i < fThreadSafeDrawData.count(); i++) {
96 DrawData::Draw(&fThreadSafeDrawData[i]); 93 DrawData::Draw(&fThreadSafeDrawData[i]);
97 } 94 }
98 #endif 95 #endif
99 96
100 const int count = fGPUDrawData.count(); 97 const int count = fGPUDrawData.count();
101 if (0 == count) { 98 if (0 == count) {
102 return; 99 return;
103 } 100 }
104 101
105 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 102 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU
106 GrContext* context = fGPUDrawData[0].fCanvas->getGrContext(); 103 GrContext* context = fGPUDrawData[0].fCanvas->getGrContext();
107 SkASSERT(context); 104 SkASSERT(context);
108 105
109 // Start by collecting all the layers that are going to be atlased and rende r 106 // Start by collecting all the layers that are going to be atlased and rende r
110 // them (if necessary). Hoisting the free floating layers is deferred until 107 // them (if necessary). Hoisting the free floating layers is deferred until
111 // drawing the canvas that requires them. 108 // drawing the canvas that requires them.
112 SkTDArray<GrHoistedLayer> atlasedNeedRendering, atlasedRecycled; 109 SkTDArray<GrHoistedLayer> atlasedNeedRendering, atlasedRecycled;
113 110
114 for (int i = 0; i < count; ++i) { 111 for (int i = 0; i < count; ++i) {
115 const DrawData& data = fGPUDrawData[i]; 112 const DrawData& data = fGPUDrawData[i];
(...skipping 23 matching lines...) Expand all
139 GrLayerHoister::DrawLayersToAtlas(context, atlasedNeedRendering); 136 GrLayerHoister::DrawLayersToAtlas(context, atlasedNeedRendering);
140 137
141 SkTDArray<GrHoistedLayer> needRendering, recycled; 138 SkTDArray<GrHoistedLayer> needRendering, recycled;
142 #endif 139 #endif
143 140
144 for (int i = 0; i < count; ++i) { 141 for (int i = 0; i < count; ++i) {
145 const DrawData& data = fGPUDrawData[i]; 142 const DrawData& data = fGPUDrawData[i];
146 SkCanvas* canvas = data.fCanvas; 143 SkCanvas* canvas = data.fCanvas;
147 const SkPicture* picture = data.fPicture; 144 const SkPicture* picture = data.fPicture;
148 145
149 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 146 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU
150 if (!data.fPaint && data.fMatrix.isIdentity()) { 147 if (!data.fPaint && data.fMatrix.isIdentity()) {
151 148
152 SkRect clipBounds; 149 SkRect clipBounds;
153 if (!canvas->getClipBounds(&clipBounds)) { 150 if (!canvas->getClipBounds(&clipBounds)) {
154 continue; 151 continue;
155 } 152 }
156 153
157 // Find the layers required by this canvas. It will return atlased 154 // Find the layers required by this canvas. It will return atlased
158 // layers in the 'recycled' list since they have already been drawn. 155 // layers in the 'recycled' list since they have already been drawn.
159 GrLayerHoister::FindLayersToHoist(context, picture, 156 GrLayerHoister::FindLayersToHoist(context, picture,
(...skipping 16 matching lines...) Expand all
176 173
177 needRendering.rewind(); 174 needRendering.rewind();
178 recycled.rewind(); 175 recycled.rewind();
179 } else 176 } else
180 #endif 177 #endif
181 { 178 {
182 canvas->drawPicture(picture, &data.fMatrix, data.fPaint); 179 canvas->drawPicture(picture, &data.fMatrix, data.fPaint);
183 } 180 }
184 } 181 }
185 182
186 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 183 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU
187 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); 184 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering);
188 GrLayerHoister::UnlockLayers(context, atlasedRecycled); 185 GrLayerHoister::UnlockLayers(context, atlasedRecycled);
189 #if !GR_CACHE_HOISTED_LAYERS 186 #if !GR_CACHE_HOISTED_LAYERS
190 GrLayerHoister::PurgeCache(context); 187 GrLayerHoister::PurgeCache(context);
191 #endif 188 #endif
192 #endif 189 #endif
193 } 190 }
194 191
OLDNEW
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698