Upstream version 10.38.208.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / core / SkBBoxHierarchyRecord.cpp
index 16ade77..8cdd1d9 100644 (file)
@@ -26,16 +26,32 @@ void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) {
     fBoundingHierarchy->insert(draw, r, true);
 }
 
-void SkBBoxHierarchyRecord::willSave(SaveFlags flags) {
+void SkBBoxHierarchyRecord::willSave() {
     fStateTree->appendSave();
-    this->INHERITED::willSave(flags);
+    this->INHERITED::willSave();
 }
 
 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) {
+        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() {