| 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 23 matching lines...) Expand all Loading... |
| 34 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, | 34 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, |
| 35 const SkPaint*
paint, | 35 const SkPaint*
paint, |
| 36 SaveFlags flags
) { | 36 SaveFlags flags
) { |
| 37 // For now, assume all filters affect transparent black. | 37 // For now, assume all filters affect transparent black. |
| 38 // FIXME: This could be made less conservative as an optimization. | 38 // FIXME: This could be made less conservative as an optimization. |
| 39 bool paintAffectsTransparentBlack = NULL != paint && | 39 bool paintAffectsTransparentBlack = NULL != paint && |
| 40 ((NULL != paint->getImageFilter()) || | 40 ((NULL != paint->getImageFilter()) || |
| 41 (NULL != paint->getColorFilter())); | 41 (NULL != paint->getColorFilter())); |
| 42 SkRect drawBounds; | 42 SkRect drawBounds; |
| 43 if (paintAffectsTransparentBlack) { | 43 if (paintAffectsTransparentBlack) { |
| 44 if (bounds) { | 44 SkIRect deviceBounds; |
| 45 drawBounds = *bounds; | 45 this->getClipDeviceBounds(&deviceBounds); |
| 46 this->getTotalMatrix().mapRect(&drawBounds); | 46 drawBounds.set(deviceBounds); |
| 47 } else { | |
| 48 SkIRect deviceBounds; | |
| 49 this->getClipDeviceBounds(&deviceBounds); | |
| 50 drawBounds.set(deviceBounds); | |
| 51 } | |
| 52 } | 47 } |
| 53 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); | 48 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); |
| 54 SkCanvas::SaveLayerStrategy strategy = this->INHERITED::willSaveLayer(bounds
, paint, flags); | 49 SkCanvas::SaveLayerStrategy strategy = this->INHERITED::willSaveLayer(bounds
, paint, flags); |
| 55 if (paintAffectsTransparentBlack) { | 50 if (paintAffectsTransparentBlack) { |
| 56 this->handleBBox(drawBounds); | 51 this->handleBBox(drawBounds); |
| 57 this->addNoOp(); | 52 this->addNoOp(); |
| 58 } | 53 } |
| 59 return strategy; | 54 return strategy; |
| 60 } | 55 } |
| 61 | 56 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 98 |
| 104 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { | 99 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { |
| 105 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the | 100 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the |
| 106 // SkPicture has rewound its command stream. To match that rewind in the | 101 // SkPicture has rewound its command stream. To match that rewind in the |
| 107 // BBH, we rewind all draws that reference commands that were recorded | 102 // BBH, we rewind all draws that reference commands that were recorded |
| 108 // past the point to which the SkPicture has rewound, which is given by | 103 // past the point to which the SkPicture has rewound, which is given by |
| 109 // writeStream().bytesWritten(). | 104 // writeStream().bytesWritten(). |
| 110 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); | 105 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); |
| 111 return draw->fOffset >= writeStream().bytesWritten(); | 106 return draw->fOffset >= writeStream().bytesWritten(); |
| 112 } | 107 } |
| OLD | NEW |