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

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

Issue 1567063002: Revert[2] of "add backdrop option to SaveLayerRec" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test and fix for svg-savelayer optimization Created 4 years, 11 months 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 | « src/core/SkRecordDraw.cpp ('k') | src/core/SkRecorder.cpp » ('j') | 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 #include "SkRecordOpts.h" 8 #include "SkRecordOpts.h"
9 9
10 #include "SkRecordPattern.h" 10 #include "SkRecordPattern.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Run until they stop changing things. 170 // Run until they stop changing things.
171 while (apply(&onlyDraws, record) || apply(&noDraws, record)); 171 while (apply(&onlyDraws, record) || apply(&noDraws, record));
172 } 172 }
173 173
174 // For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's alpha into the 174 // For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's alpha into the
175 // draw, and no-op the SaveLayer and Restore. 175 // draw, and no-op the SaveLayer and Restore.
176 struct SaveLayerDrawRestoreNooper { 176 struct SaveLayerDrawRestoreNooper {
177 typedef Pattern<Is<SaveLayer>, IsDraw, Is<Restore>> Match; 177 typedef Pattern<Is<SaveLayer>, IsDraw, Is<Restore>> Match;
178 178
179 bool onMatch(SkRecord* record, Match* match, int begin, int end) { 179 bool onMatch(SkRecord* record, Match* match, int begin, int end) {
180 if (match->first<SaveLayer>()->backdrop) {
181 // can't throw away the layer if we have a backdrop
182 return false;
183 }
184
180 // A SaveLayer's bounds field is just a hint, so we should be free to ig nore it. 185 // A SaveLayer's bounds field is just a hint, so we should be free to ig nore it.
181 SkPaint* layerPaint = match->first<SaveLayer>()->paint; 186 SkPaint* layerPaint = match->first<SaveLayer>()->paint;
182 if (nullptr == layerPaint) { 187 if (nullptr == layerPaint) {
183 // There wasn't really any point to this SaveLayer at all. 188 // There wasn't really any point to this SaveLayer at all.
184 return KillSaveLayerAndRestore(record, begin); 189 return KillSaveLayerAndRestore(record, begin);
185 } 190 }
186 191
187 SkPaint* drawPaint = match->second<SkPaint>(); 192 SkPaint* drawPaint = match->second<SkPaint>();
188 if (drawPaint == nullptr) { 193 if (drawPaint == nullptr) {
189 // We can just give the draw the SaveLayer's paint. 194 // We can just give the draw the SaveLayer's paint.
(...skipping 27 matching lines...) Expand all
217 SaveLayer (typically for SVG filter) 222 SaveLayer (typically for SVG filter)
218 Restore 223 Restore
219 Restore 224 Restore
220 Restore 225 Restore
221 */ 226 */
222 struct SvgOpacityAndFilterLayerMergePass { 227 struct SvgOpacityAndFilterLayerMergePass {
223 typedef Pattern<Is<SaveLayer>, Is<Save>, Is<ClipRect>, Is<SaveLayer>, 228 typedef Pattern<Is<SaveLayer>, Is<Save>, Is<ClipRect>, Is<SaveLayer>,
224 Is<Restore>, Is<Restore>, Is<Restore>> Match; 229 Is<Restore>, Is<Restore>, Is<Restore>> Match;
225 230
226 bool onMatch(SkRecord* record, Match* match, int begin, int end) { 231 bool onMatch(SkRecord* record, Match* match, int begin, int end) {
232 if (match->first<SaveLayer>()->backdrop) {
233 // can't throw away the layer if we have a backdrop
234 return false;
235 }
236
227 SkPaint* opacityPaint = match->first<SaveLayer>()->paint; 237 SkPaint* opacityPaint = match->first<SaveLayer>()->paint;
228 if (nullptr == opacityPaint) { 238 if (nullptr == opacityPaint) {
229 // There wasn't really any point to this SaveLayer at all. 239 // There wasn't really any point to this SaveLayer at all.
230 return KillSaveLayerAndRestore(record, begin); 240 return KillSaveLayerAndRestore(record, begin);
231 } 241 }
232 242
233 // This layer typically contains a filter, but this should work for laye rs with for other 243 // This layer typically contains a filter, but this should work for laye rs with for other
234 // purposes too. 244 // purposes too.
235 SkPaint* filterLayerPaint = match->fourth<SaveLayer>()->paint; 245 SkPaint* filterLayerPaint = match->fourth<SaveLayer>()->paint;
236 if (filterLayerPaint == nullptr) { 246 if (filterLayerPaint == nullptr) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 286
277 void SkRecordOptimize2(SkRecord* record) { 287 void SkRecordOptimize2(SkRecord* record) {
278 multiple_set_matrices(record); 288 multiple_set_matrices(record);
279 SkRecordNoopSaveRestores(record); 289 SkRecordNoopSaveRestores(record);
280 SkRecordNoopSaveLayerDrawRestores(record); 290 SkRecordNoopSaveLayerDrawRestores(record);
281 SkRecordMergeSvgOpacityAndFilterLayers(record); 291 SkRecordMergeSvgOpacityAndFilterLayers(record);
282 292
283 record->defrag(); 293 record->defrag();
284 } 294 }
285 295
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | src/core/SkRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698