e932d4b3a9
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>
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SkSVGRenderContext.h"
|
|
#include "SkSVGShape.h"
|
|
|
|
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, fillType);
|
|
}
|
|
|
|
if (const SkPaint* strokePaint = ctx.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;
|
|
}
|
|
}
|