diff options
author | fmalita <fmalita@chromium.org> | 2015-08-17 08:05:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-17 08:05:13 -0700 |
commit | f433bb2bebd441cc0b2b152e8fbf79eac43baf5d (patch) | |
tree | 50748556c038b4ed2a5dec143061b737c8df44ac /src/utils/SkPaintFilterCanvas.cpp | |
parent | 340f3074b49de089e7e8cf9495fd54f67b7f9b8a (diff) |
SkPaintFilterCanvas should inherit the target canvas state
Currently, SkPaintFilterCanvas does not provide any help in cloning
target canvas state. While that could be handled in subclasses, it is
easy to miss (see linked bug).
This CL adds a new constructor variant which ensures that the initial
matrix and clip bounds are inherited from the target canvas.
BUG=516790
R=reed@google.com,robertphillips@google.com
Review URL: https://codereview.chromium.org/1294013002
Diffstat (limited to 'src/utils/SkPaintFilterCanvas.cpp')
-rw-r--r-- | src/utils/SkPaintFilterCanvas.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp index 0ff6ae04d1..dff1514acb 100644 --- a/src/utils/SkPaintFilterCanvas.cpp +++ b/src/utils/SkPaintFilterCanvas.cpp @@ -30,6 +30,18 @@ private: SkPaintFilterCanvas::SkPaintFilterCanvas(int width, int height) : INHERITED(width, height) { } +SkPaintFilterCanvas::SkPaintFilterCanvas(SkCanvas *canvas) + : INHERITED(canvas->imageInfo().width(), canvas->imageInfo().height()) { + + // Transfer matrix & clip state before adding the target canvas. + SkIRect devClip; + canvas->getClipDeviceBounds(&devClip); + this->clipRect(SkRect::Make(devClip)); + this->setMatrix(canvas->getTotalMatrix()); + + this->addCanvas(canvas); +} + void SkPaintFilterCanvas::onDrawPaint(const SkPaint& paint) { AutoPaintFilter apf(this, kPaint_Type, paint); this->INHERITED::onDrawPaint(*apf.paint()); |