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

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

Issue 504423002: Fix saveLayer() with a pixel-moving filter vs SkBBoxHierarchyRecord / SkRecordDraw (Closed) Base URL: https://skia.googlesource.com/skia.git@m38_2125
Patch Set: Created 6 years, 3 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/SkBBoxHierarchyRecord.cpp ('k') | tests/ImageFilterTest.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 "SkRecordDraw.h" 8 #include "SkRecordDraw.h"
9 #include "SkTSort.h" 9 #include "SkTSort.h"
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // TODO: remove this trivially-safe default when done bounding all ops 182 // TODO: remove this trivially-safe default when done bounding all ops
183 template <typename T> SkIRect bounds(const T&) { return SkIRect::MakeLargest (); } 183 template <typename T> SkIRect bounds(const T&) { return SkIRect::MakeLargest (); }
184 184
185 void pushSaveBlock() { 185 void pushSaveBlock() {
186 // Starting a new Save block. Push a new entry to represent that. 186 // Starting a new Save block. Push a new entry to represent that.
187 SaveBounds sb = { 0, SkIRect::MakeEmpty() }; 187 SaveBounds sb = { 0, SkIRect::MakeEmpty() };
188 fSaveStack.push(sb); 188 fSaveStack.push(sb);
189 this->pushControl(); 189 this->pushControl();
190 } 190 }
191 191
192 static bool PaintMayAffectTransparentBlack(const SkPaint* paint) {
193 // FIXME: this is very conservative
194 return paint && (paint->getImageFilter() || paint->getColorFilter());
195 }
196
192 SkIRect popSaveBlock() { 197 SkIRect popSaveBlock() {
193 // We're done the Save block. Apply the block's bounds to all control o ps inside it. 198 // We're done the Save block. Apply the block's bounds to all control o ps inside it.
194 SaveBounds sb; 199 SaveBounds sb;
195 fSaveStack.pop(&sb); 200 fSaveStack.pop(&sb);
201
202 // If the paint affects transparent black, we can't trust any of our cal culated bounds.
203 const SkIRect& bounds =
204 PaintMayAffectTransparentBlack(sb.paint) ? fCurrentClipBounds : sb.b ounds;
205
196 while (sb.controlOps --> 0) { 206 while (sb.controlOps --> 0) {
197 this->popControl(sb.bounds); 207 this->popControl(bounds);
198 } 208 }
199 209
200 // This whole Save block may be part another Save block. 210 // This whole Save block may be part another Save block.
201 this->updateSaveBounds(sb.bounds); 211 this->updateSaveBounds(bounds);
202 212
203 // If called from a real Restore (not a phony one for balance), it'll ne ed the bounds. 213 // If called from a real Restore (not a phony one for balance), it'll ne ed the bounds.
204 return sb.bounds; 214 return bounds;
205 } 215 }
206 216
207 void pushControl() { 217 void pushControl() {
208 fControlIndices.push(fCurrentOp); 218 fControlIndices.push(fCurrentOp);
209 if (!fSaveStack.isEmpty()) { 219 if (!fSaveStack.isEmpty()) {
210 fSaveStack.top().controlOps++; 220 fSaveStack.top().controlOps++;
211 } 221 }
212 } 222 }
213 223
214 void popControl(const SkIRect& bounds) { 224 void popControl(const SkIRect& bounds) {
(...skipping 15 matching lines...) Expand all
230 unsigned fCurrentOp; 240 unsigned fCurrentOp;
231 SkTDArray<SaveBounds> fSaveStack; 241 SkTDArray<SaveBounds> fSaveStack;
232 SkTDArray<unsigned> fControlIndices; 242 SkTDArray<unsigned> fControlIndices;
233 }; 243 };
234 244
235 } // namespace SkRecords 245 } // namespace SkRecords
236 246
237 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { 247 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) {
238 SkRecords::FillBounds(record, bbh); 248 SkRecords::FillBounds(record, bbh);
239 } 249 }
OLDNEW
« no previous file with comments | « src/core/SkBBoxHierarchyRecord.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698