diff options
author | Mike Reed <reed@google.com> | 2016-11-15 11:52:55 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-15 17:32:03 +0000 |
commit | 584ca89d3b7a7781ea0407ee4d1c953fc7085e75 (patch) | |
tree | a3ce8ce64779b55a0a08b82c0b0692c8eff0c85f /src/utils/SkCanvasStack.cpp | |
parent | d5a78805c5133bc55e07c5da21f8d72b91a3df4f (diff) |
change SkCanvasStack to take ownership of its subcanvases
Inspired by https://bugs.chromium.org/p/chromium/issues/detail?id=663959
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4799
Change-Id: I69f7ac73386bb7ca96778e2fec4cb2757b982a52
Reviewed-on: https://skia-review.googlesource.com/4799
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/utils/SkCanvasStack.cpp')
-rw-r--r-- | src/utils/SkCanvasStack.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/utils/SkCanvasStack.cpp b/src/utils/SkCanvasStack.cpp index 58607d7d29..8e4bd37540 100644 --- a/src/utils/SkCanvasStack.cpp +++ b/src/utils/SkCanvasStack.cpp @@ -13,18 +13,19 @@ SkCanvasStack::~SkCanvasStack() { this->removeAll(); } -void SkCanvasStack::pushCanvas(SkCanvas* canvas, const SkIPoint& origin) { +void SkCanvasStack::pushCanvas(std::unique_ptr<SkCanvas> canvas, const SkIPoint& origin) { if (canvas) { // compute the bounds of this canvas const SkIRect canvasBounds = SkIRect::MakeSize(canvas->getDeviceSize()); // push the canvas onto the stack - this->INHERITED::addCanvas(canvas); + this->INHERITED::addCanvas(canvas.get()); // push the canvas data onto the stack CanvasData* data = &fCanvasData.push_back(); data->origin = origin; data->requiredClip.setRect(canvasBounds); + data->ownedCanvas = std::move(canvas); // subtract this region from the canvas objects already on the stack. // This ensures they do not draw into the space occupied by the layers @@ -41,8 +42,8 @@ void SkCanvasStack::pushCanvas(SkCanvas* canvas, const SkIPoint& origin) { } void SkCanvasStack::removeAll() { + this->INHERITED::removeAll(); // call the baseclass *before* we actually delete the canvases fCanvasData.reset(); - this->INHERITED::removeAll(); } /** |