diff options
Diffstat (limited to 'experimental/svg/model/SkSVGRenderContext.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGRenderContext.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/experimental/svg/model/SkSVGRenderContext.cpp b/experimental/svg/model/SkSVGRenderContext.cpp index d8c269a56f..7fa61d48a3 100644 --- a/experimental/svg/model/SkSVGRenderContext.cpp +++ b/experimental/svg/model/SkSVGRenderContext.cpp @@ -333,6 +333,15 @@ void SkSVGRenderContext::applyOpacity(SkScalar opacity, uint32_t flags) { } } +void SkSVGRenderContext::saveOnce() { + // The canvas only needs to be saved once, per local SkSVGRenderContext. + if (fCanvas->getSaveCount() == fCanvasSaveCount) { + fCanvas->save(); + } + + SkASSERT(fCanvas->getSaveCount() > fCanvasSaveCount); +} + void SkSVGRenderContext::applyClip(const SkSVGClip& clip) { if (clip.type() != SkSVGClip::Type::kIRI) { return; @@ -352,10 +361,7 @@ void SkSVGRenderContext::applyClip(const SkSVGClip& clip) { // // TODO: the two uses are exclusive, avoid canvas churn when non needed. - // Only save if needed - if (fCanvas->getSaveCount() == fCanvasSaveCount) { - fCanvas->save(); - } + this->saveOnce(); fCanvas->clipPath(clipPath, true); fClipPath.set(clipPath); |