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 #include "SkLayerInfo.h" | 8 #include "SkLayerInfo.h" |
9 #include "SkRecordDraw.h" | 9 #include "SkRecordDraw.h" |
10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 } | 214 } |
215 | 215 |
216 return rect; | 216 return rect; |
217 } | 217 } |
218 | 218 |
219 private: | 219 private: |
220 struct SaveBounds { | 220 struct SaveBounds { |
221 int controlOps; // Number of control ops in this Save block, incl uding the Save. | 221 int controlOps; // Number of control ops in this Save block, incl uding the Save. |
222 Bounds bounds; // Bounds of everything in the block. | 222 Bounds bounds; // Bounds of everything in the block. |
223 const SkPaint* paint; // Unowned. If set, adjusts the bounds of all op s in this block. | 223 const SkPaint* paint; // Unowned. If set, adjusts the bounds of all op s in this block. |
224 SkMatrix ctm; | |
224 }; | 225 }; |
225 | 226 |
226 // Only Restore, SetMatrix, and Concat change the CTM. | 227 // Only Restore, SetMatrix, and Concat change the CTM. |
227 template <typename T> void updateCTM(const T&) {} | 228 template <typename T> void updateCTM(const T&) {} |
228 void updateCTM(const Restore& op) { fCTM = op.matrix; } | 229 void updateCTM(const Restore& op) { fCTM = op.matrix; } |
229 void updateCTM(const SetMatrix& op) { fCTM = op.matrix; } | 230 void updateCTM(const SetMatrix& op) { fCTM = op.matrix; } |
230 void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); } | 231 void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); } |
231 | 232 |
232 // Most ops don't change the clip. | 233 // Most ops don't change the clip. |
233 template <typename T> void updateClipBounds(const T&) {} | 234 template <typename T> void updateClipBounds(const T&) {} |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 | 295 |
295 void pushSaveBlock(const SkPaint* paint) { | 296 void pushSaveBlock(const SkPaint* paint) { |
296 // Starting a new Save block. Push a new entry to represent that. | 297 // Starting a new Save block. Push a new entry to represent that. |
297 SaveBounds sb; | 298 SaveBounds sb; |
298 sb.controlOps = 0; | 299 sb.controlOps = 0; |
299 // If the paint affects transparent black, the bound shouldn't be smalle r | 300 // If the paint affects transparent black, the bound shouldn't be smalle r |
300 // than the current clip bounds. | 301 // than the current clip bounds. |
301 sb.bounds = | 302 sb.bounds = |
302 PaintMayAffectTransparentBlack(paint) ? fCurrentClipBounds : Bounds: :MakeEmpty(); | 303 PaintMayAffectTransparentBlack(paint) ? fCurrentClipBounds : Bounds: :MakeEmpty(); |
303 sb.paint = paint; | 304 sb.paint = paint; |
305 sb.ctm = this->fCTM; | |
304 | 306 |
305 fSaveStack.push(sb); | 307 fSaveStack.push(sb); |
306 this->pushControl(); | 308 this->pushControl(); |
307 } | 309 } |
308 | 310 |
309 static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { | 311 static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { |
310 if (paint) { | 312 if (paint) { |
311 // FIXME: this is very conservative | 313 // FIXME: this is very conservative |
312 if (paint->getImageFilter() || paint->getColorFilter()) { | 314 if (paint->getImageFilter() || paint->getColorFilter()) { |
313 return true; | 315 return true; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 *rect = paint->computeFastBounds(*rect, rect); | 558 *rect = paint->computeFastBounds(*rect, rect); |
557 return true; | 559 return true; |
558 } | 560 } |
559 return false; | 561 return false; |
560 } | 562 } |
561 return true; | 563 return true; |
562 } | 564 } |
563 | 565 |
564 bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const { | 566 bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const { |
565 for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) { | 567 for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) { |
568 SkMatrix inverse; | |
569 if (!fSaveStack[i].ctm.invert(&inverse)) { | |
570 return false; | |
571 } | |
572 inverse.mapRect(rect); | |
566 if (!AdjustForPaint(fSaveStack[i].paint, rect)) { | 573 if (!AdjustForPaint(fSaveStack[i].paint, rect)) { |
567 return false; | 574 return false; |
568 } | 575 } |
576 fSaveStack[i].ctm.mapRect(rect); | |
mtklein
2015/12/09 16:59:41
Is it important that we do rect = (M (M^-1 rect))
mtklein
2015/12/09 17:00:53
(Or put (M^-1 rect) into another SkRect instead of
Stephen White
2015/12/09 17:02:57
The problem is that we don't know the rect at save
mtklein
2015/12/09 17:06:04
So, (*rect at line 577) != (*rect at line 571)?
Stephen White
2015/12/09 17:10:52
Yeah. It may have been munged by AdjustForPaint().
mtklein
2015/12/09 17:15:25
Oh, of course. That's the whole point of this met
| |
569 } | 577 } |
570 return true; | 578 return true; |
571 } | 579 } |
572 | 580 |
573 const int fNumRecords; | 581 const int fNumRecords; |
574 | 582 |
575 // We do not guarantee anything for operations outside of the cull rect | 583 // We do not guarantee anything for operations outside of the cull rect |
576 const SkRect fCullRect; | 584 const SkRect fCullRect; |
577 | 585 |
578 // Conservative identity-space bounds for each op in the SkRecord. | 586 // Conservative identity-space bounds for each op in the SkRecord. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkRec t bounds[], | 808 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkRec t bounds[], |
801 const SkBigPicture::SnapshotArray* pictList, SkLayerI nfo* data) { | 809 const SkBigPicture::SnapshotArray* pictList, SkLayerI nfo* data) { |
802 SkRecords::CollectLayers visitor(cullRect, record, bounds, pictList, data); | 810 SkRecords::CollectLayers visitor(cullRect, record, bounds, pictList, data); |
803 for (int curOp = 0; curOp < record.count(); curOp++) { | 811 for (int curOp = 0; curOp < record.count(); curOp++) { |
804 visitor.setCurrentOp(curOp); | 812 visitor.setCurrentOp(curOp); |
805 record.visit<void>(curOp, visitor); | 813 record.visit<void>(curOp, visitor); |
806 } | 814 } |
807 visitor.cleanUp(); | 815 visitor.cleanUp(); |
808 } | 816 } |
809 | 817 |
OLD | NEW |