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

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

Issue 849243002: Why are we afraid of saveLayer() bounds? (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | tests/RecordOptsTest.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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Run until they stop changing things. 83 // Run until they stop changing things.
84 while (apply(&onlyDraws, record) || apply(&noDraws, record)); 84 while (apply(&onlyDraws, record) || apply(&noDraws, record));
85 } 85 }
86 86
87 // For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's alpha into the 87 // For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's alpha into the
88 // draw, and no-op the SaveLayer and Restore. 88 // draw, and no-op the SaveLayer and Restore.
89 struct SaveLayerDrawRestoreNooper { 89 struct SaveLayerDrawRestoreNooper {
90 typedef Pattern3<Is<SaveLayer>, IsDraw, Is<Restore> > Pattern; 90 typedef Pattern3<Is<SaveLayer>, IsDraw, Is<Restore> > Pattern;
91 91
92 bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned en d) { 92 bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned en d) {
93 SaveLayer* saveLayer = pattern->first<SaveLayer>(); 93 // A SaveLayer's bounds field is just a hint, so we should be free to ig nore it.
94 if (saveLayer->bounds != NULL) { 94 SkPaint* layerPaint = pattern->first<SaveLayer>()->paint;
95 // SaveLayer with bounds is too tricky for us.
96 return false;
97 }
98
99 SkPaint* layerPaint = saveLayer->paint;
100 if (NULL == layerPaint) { 95 if (NULL == layerPaint) {
101 // There wasn't really any point to this SaveLayer at all. 96 // There wasn't really any point to this SaveLayer at all.
102 return KillSaveLayerAndRestore(record, begin); 97 return KillSaveLayerAndRestore(record, begin);
103 } 98 }
104 99
105 SkPaint* drawPaint = pattern->second<SkPaint>(); 100 SkPaint* drawPaint = pattern->second<SkPaint>();
106 if (drawPaint == NULL) { 101 if (drawPaint == NULL) {
107 // We can just give the draw the SaveLayer's paint. 102 // We can just give the draw the SaveLayer's paint.
108 // TODO(mtklein): figure out how to do this clearly 103 // TODO(mtklein): figure out how to do this clearly
109 return false; 104 return false;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 150 }
156 static bool IsOnlyAlpha(SkColor color) { 151 static bool IsOnlyAlpha(SkColor color) {
157 return SK_ColorTRANSPARENT == SkColorSetA(color, SK_AlphaTRANSPARENT); 152 return SK_ColorTRANSPARENT == SkColorSetA(color, SK_AlphaTRANSPARENT);
158 } 153 }
159 }; 154 };
160 void SkRecordNoopSaveLayerDrawRestores(SkRecord* record) { 155 void SkRecordNoopSaveLayerDrawRestores(SkRecord* record) {
161 SaveLayerDrawRestoreNooper pass; 156 SaveLayerDrawRestoreNooper pass;
162 apply(&pass, record); 157 apply(&pass, record);
163 } 158 }
164 159
OLDNEW
« no previous file with comments | « no previous file | tests/RecordOptsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698