OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBBoxHierarchyRecord.h" | 9 #include "SkBBoxHierarchyRecord.h" |
10 #include "SkPictureStateTree.h" | 10 #include "SkPictureStateTree.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 void SkBBoxHierarchyRecord::willSave(SaveFlags flags) { | 30 void SkBBoxHierarchyRecord::willSave(SaveFlags flags) { |
31 fStateTree->appendSave(); | 31 fStateTree->appendSave(); |
32 this->INHERITED::willSave(flags); | 32 this->INHERITED::willSave(flags); |
33 } | 33 } |
34 | 34 |
35 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, | 35 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, |
36 const SkPaint*
paint, | 36 const SkPaint*
paint, |
37 SaveFlags flags
) { | 37 SaveFlags flags
) { |
| 38 // For now, assume all filters affect transparent black. |
| 39 // FIXME: This could be made less conservative as an optimization. |
| 40 bool paintAffectsTransparentBlack = NULL != paint && |
| 41 ((NULL != paint->getImageFilter()) || |
| 42 (NULL != paint->getColorFilter())); |
| 43 SkRect drawBounds; |
| 44 if (paintAffectsTransparentBlack) { |
| 45 if (bounds) { |
| 46 drawBounds = *bounds; |
| 47 this->getTotalMatrix().mapRect(&drawBounds); |
| 48 } else { |
| 49 SkIRect deviceBounds; |
| 50 this->getClipDeviceBounds(&deviceBounds); |
| 51 drawBounds.set(deviceBounds); |
| 52 } |
| 53 } |
38 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); | 54 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); |
39 return this->INHERITED::willSaveLayer(bounds, paint, flags); | 55 SkCanvas::SaveLayerStrategy strategy = this->INHERITED::willSaveLayer(bounds
, paint, flags); |
| 56 if (paintAffectsTransparentBlack) { |
| 57 this->handleBBox(drawBounds); |
| 58 this->addNoOp(); |
| 59 } |
| 60 return strategy; |
40 } | 61 } |
41 | 62 |
42 void SkBBoxHierarchyRecord::willRestore() { | 63 void SkBBoxHierarchyRecord::willRestore() { |
43 fStateTree->appendRestore(); | 64 fStateTree->appendRestore(); |
44 this->INHERITED::willRestore(); | 65 this->INHERITED::willRestore(); |
45 } | 66 } |
46 | 67 |
47 void SkBBoxHierarchyRecord::didConcat(const SkMatrix& matrix) { | 68 void SkBBoxHierarchyRecord::didConcat(const SkMatrix& matrix) { |
48 fStateTree->appendTransform(getTotalMatrix()); | 69 fStateTree->appendTransform(getTotalMatrix()); |
49 INHERITED::didConcat(matrix); | 70 INHERITED::didConcat(matrix); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 104 |
84 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { | 105 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { |
85 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the | 106 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the |
86 // SkPicture has rewound its command stream. To match that rewind in the | 107 // SkPicture has rewound its command stream. To match that rewind in the |
87 // BBH, we rewind all draws that reference commands that were recorded | 108 // BBH, we rewind all draws that reference commands that were recorded |
88 // past the point to which the SkPicture has rewound, which is given by | 109 // past the point to which the SkPicture has rewound, which is given by |
89 // writeStream().bytesWritten(). | 110 // writeStream().bytesWritten(). |
90 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); | 111 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); |
91 return draw->fOffset >= writeStream().bytesWritten(); | 112 return draw->fOffset >= writeStream().bytesWritten(); |
92 } | 113 } |
OLD | NEW |