diff options
author | Florin Malita <fmalita@chromium.org> | 2016-12-08 09:26:47 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-08 15:00:18 +0000 |
commit | ce8840e3842f3a702c5d7bf440ff730bdfaf8e70 (patch) | |
tree | 0a94cdeb3d2d8632644490b70fdb0c40d185b8ec /experimental/svg/model/SkSVGEllipse.cpp | |
parent | c5a8366d9922902cffbd351fdd15755dd2ac99bf (diff) |
[SVGDom] ClipPath support
* clip-path attribute handling
* clipPath container element
* asPath() SkSVGNode virtual for capturing subtree geometry
R=robertphillips@google.com,stephana@google.com
Change-Id: I9597534fe3047b631da6309eafac055dff5696e9
Reviewed-on: https://skia-review.googlesource.com/5650
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/svg/model/SkSVGEllipse.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGEllipse.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/experimental/svg/model/SkSVGEllipse.cpp b/experimental/svg/model/SkSVGEllipse.cpp index 481af5c3ab..3f38b222d5 100644 --- a/experimental/svg/model/SkSVGEllipse.cpp +++ b/experimental/svg/model/SkSVGEllipse.cpp @@ -55,14 +55,26 @@ void SkSVGEllipse::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { } } -void SkSVGEllipse::onDraw(SkCanvas* canvas, const SkSVGLengthContext& lctx, - const SkPaint& paint, SkPath::FillType) const { +SkRect SkSVGEllipse::resolve(const SkSVGLengthContext& lctx) const { const auto cx = lctx.resolve(fCx, SkSVGLengthContext::LengthType::kHorizontal); const auto cy = lctx.resolve(fCy, SkSVGLengthContext::LengthType::kVertical); const auto rx = lctx.resolve(fRx, SkSVGLengthContext::LengthType::kHorizontal); const auto ry = lctx.resolve(fRy, SkSVGLengthContext::LengthType::kVertical); - if (rx > 0 && ry > 0) { - canvas->drawOval(SkRect::MakeXYWH(cx - rx, cy - ry, rx * 2, ry * 2), paint); - } + return (rx > 0 && ry > 0) + ? SkRect::MakeXYWH(cx - rx, cy - ry, rx * 2, ry * 2) + : SkRect::MakeEmpty(); +} + +void SkSVGEllipse::onDraw(SkCanvas* canvas, const SkSVGLengthContext& lctx, + const SkPaint& paint, SkPath::FillType) const { + canvas->drawOval(this->resolve(lctx), paint); +} + +SkPath SkSVGEllipse::onAsPath(const SkSVGRenderContext& ctx) const { + SkPath path; + path.addOval(this->resolve(ctx.lengthContext())); + this->mapToParent(&path); + + return path; } |