diff options
author | Florin Malita <fmalita@chromium.org> | 2016-12-08 16:04:24 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-09 16:06:25 +0000 |
commit | 7d529881c4dfc27782c0bced7c7e3a2788975083 (patch) | |
tree | e25bd0d250fbf3c7aee8c50bcaaaeaa1c470f015 /experimental/svg/model/SkSVGNode.cpp | |
parent | 67702f6322b54470d11de8c66f09216db64f4274 (diff) |
[SVGDom] Clipped clipPath support
ClipPaths can be clipped too, e.g.:
<clipPath id="clip1" clip-path="url(#clip2)">...</clipPath>
Since we're not really drawing clips but resolving their geometry,
asPath() needs to take composed clipping into account (and intersect as
needed).
R=reed@google.com,robertphillips@google.com,stephana@google.com
Change-Id: I25959e22fe50f72042147cfe6b416b6b9ac20cd4
Reviewed-on: https://skia-review.googlesource.com/5720
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/svg/model/SkSVGNode.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGNode.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/experimental/svg/model/SkSVGNode.cpp b/experimental/svg/model/SkSVGNode.cpp index ec452ec9c6..0f3743ffd2 100644 --- a/experimental/svg/model/SkSVGNode.cpp +++ b/experimental/svg/model/SkSVGNode.cpp @@ -7,6 +7,7 @@ #include "SkCanvas.h" #include "SkMatrix.h" +#include "SkPathOps.h" #include "SkSVGNode.h" #include "SkSVGRenderContext.h" #include "SkSVGValue.h" @@ -32,7 +33,18 @@ bool SkSVGNode::asPaint(const SkSVGRenderContext& ctx, SkPaint* paint) const { SkPath SkSVGNode::asPath(const SkSVGRenderContext& ctx) const { SkSVGRenderContext localContext(ctx); - return this->onPrepareToRender(&localContext) ? this->onAsPath(localContext) : SkPath(); + if (!this->onPrepareToRender(&localContext)) { + return SkPath(); + } + + SkPath path = this->onAsPath(localContext); + + if (const auto* clipPath = localContext.clipPath()) { + // There is a clip-path present on the current node. + Op(path, *clipPath, kIntersect_SkPathOp, &path); + } + + return path; } bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const { |