aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGShape.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2016-12-01 13:35:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-06 16:05:41 +0000
commite932d4b3a99905a6272c5574f21ac651632f4e82 (patch)
tree667289b43423b6183ac76eb657b32aef201b1b13 /experimental/svg/model/SkSVGShape.cpp
parentebe79ffd8627e3fea945a82895e64cede4ec21bf (diff)
[SVGDom] Add fill-rule support
There's a bit of friction with this attribute, because per spec it is an inherited presentation attribute, but in Skia it is part of the actual SkPath state. So we must add some plumbing to SkSVGShape & friends to allow overriding the fill type at render-time. R=robertphillips@google.com,stephana@google.com Change-Id: I9c926d653c6211beb3914bffac50d4349dbdd2c0 Reviewed-on: https://skia-review.googlesource.com/5415 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/svg/model/SkSVGShape.cpp')
-rw-r--r--experimental/svg/model/SkSVGShape.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/experimental/svg/model/SkSVGShape.cpp b/experimental/svg/model/SkSVGShape.cpp
index 38af4c9303..9351a2f096 100644
--- a/experimental/svg/model/SkSVGShape.cpp
+++ b/experimental/svg/model/SkSVGShape.cpp
@@ -11,16 +11,31 @@
SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {}
void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const {
+ const SkPath::FillType fillType =
+ FillRuleToFillType(*ctx.presentationContext().fInherited.fFillRule.get());
+
// TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid.
if (const SkPaint* fillPaint = ctx.fillPaint()) {
- this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint);
+ this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType);
}
if (const SkPaint* strokePaint = ctx.strokePaint()) {
- this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint);
+ this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType);
}
}
void SkSVGShape::appendChild(sk_sp<SkSVGNode>) {
SkDebugf("cannot append child nodes to an SVG shape.\n");
}
+
+SkPath::FillType SkSVGShape::FillRuleToFillType(const SkSVGFillRule& fillRule) {
+ switch (fillRule.type()) {
+ case SkSVGFillRule::Type::kNonZero:
+ return SkPath::kWinding_FillType;
+ case SkSVGFillRule::Type::kEvenOdd:
+ return SkPath::kEvenOdd_FillType;
+ default:
+ SkASSERT(false);
+ return SkPath::kWinding_FillType;
+ }
+}