From 444d91fec1b51b53a77e79a47a63a944f64b32f8 Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 3 Nov 2015 09:45:03 -0800 Subject: [PATCH] SkRemote: saveLayer https://gold.skia.org/search2?issue=1432593002&unt=true&query=source_type%3Dgm&master=false&include=true BUG=skia: Review URL: https://codereview.chromium.org/1432593002 --- src/core/SkRemote.cpp | 19 ++++++++++++++++++- src/core/SkRemote.h | 11 ++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp index dd0b25d62c..236a1a8c24 100644 --- a/src/core/SkRemote.cpp +++ b/src/core/SkRemote.cpp @@ -165,7 +165,15 @@ namespace SkRemote { SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags) override { - // TODO + SkPath path; + if (bounds) { + path.addRect(*bounds); + } + const SkPaint defaultPaint; + if (!paint) { + paint = &defaultPaint; + } + fEncoder->saveLayer(this->id(path), this->commonIDs(*paint), flags); return kNoLayer_SaveLayerStrategy; } @@ -473,6 +481,12 @@ namespace SkRemote { void save() override { fCanvas->save(); } void restore() override { fCanvas->restore(); } + void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) override { + SkPaint paint; + this->applyCommon(common, &paint); + SkRect rect; + fCanvas->saveLayer(fPath.find(bounds).isRect(&rect) ? &rect : nullptr, &paint, flags); + } void setMatrix(ID matrix) override { fCanvas->setMatrix(fMatrix.find(matrix)); } @@ -636,6 +650,9 @@ namespace SkRemote { void save() override { fWrapped-> save(); } void restore() override { fWrapped->restore(); } + void saveLayer(ID bounds, CommonIDs common, SkCanvas::SaveFlags flags) override { + fWrapped->saveLayer(bounds, common, flags); + } void setMatrix(ID matrix) override { fWrapped->setMatrix(matrix); } diff --git a/src/core/SkRemote.h b/src/core/SkRemote.h index 5fb20242fe..b33309449c 100644 --- a/src/core/SkRemote.h +++ b/src/core/SkRemote.h @@ -81,17 +81,18 @@ namespace SkRemote { virtual void undefine(ID) = 0; - virtual void save() = 0; - virtual void restore() = 0; - - virtual void setMatrix(ID matrix) = 0; - // TODO: do these all belong here in CommonIDs? struct CommonIDs { ID misc, patheffect, shader, xfermode, maskfilter, colorfilter, rasterizer, looper, imagefilter, annotation; }; + virtual void save() = 0; + virtual void restore() = 0; + virtual void saveLayer(ID bounds, CommonIDs, SkCanvas::SaveFlags) = 0; + + virtual void setMatrix(ID matrix) = 0; + virtual void clipPath(ID path, SkRegion::Op, bool aa) = 0; virtual void fillPath(ID path, CommonIDs) = 0; virtual void strokePath(ID path, CommonIDs, ID stroke) = 0;