diff options
Diffstat (limited to 'src/core/SkBBoxHierarchyRecord.cpp')
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/core/SkBBoxHierarchyRecord.cpp b/src/core/SkBBoxHierarchyRecord.cpp index f0382e6470..d6fbd21239 100644 --- a/src/core/SkBBoxHierarchyRecord.cpp +++ b/src/core/SkBBoxHierarchyRecord.cpp @@ -35,8 +35,29 @@ void SkBBoxHierarchyRecord::willSave(SaveFlags flags) { SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags) { + // For now, assume all filters affect transparent black. + // FIXME: This could be made less conservative as an optimization. + bool paintAffectsTransparentBlack = NULL != paint && + ((NULL != paint->getImageFilter()) || + (NULL != paint->getColorFilter())); + SkRect drawBounds; + if (paintAffectsTransparentBlack) { + if (bounds) { + drawBounds = *bounds; + this->getTotalMatrix().mapRect(&drawBounds); + } else { + SkIRect deviceBounds; + this->getClipDeviceBounds(&deviceBounds); + drawBounds.set(deviceBounds); + } + } fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); - return this->INHERITED::willSaveLayer(bounds, paint, flags); + SkCanvas::SaveLayerStrategy strategy = this->INHERITED::willSaveLayer(bounds, paint, flags); + if (paintAffectsTransparentBlack) { + this->handleBBox(drawBounds); + this->addNoOp(); + } + return strategy; } void SkBBoxHierarchyRecord::willRestore() { |