2016-08-03 17:21:11 +00:00
|
|
|
/*
|
|
|
|
* 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) {}
|
|
|
|
|
2016-08-08 18:38:55 +00:00
|
|
|
void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const {
|
2016-12-01 18:35:11 +00:00
|
|
|
const SkPath::FillType fillType =
|
|
|
|
FillRuleToFillType(*ctx.presentationContext().fInherited.fFillRule.get());
|
|
|
|
|
2016-08-11 00:11:29 +00:00
|
|
|
// TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid.
|
2016-08-11 16:16:29 +00:00
|
|
|
if (const SkPaint* fillPaint = ctx.fillPaint()) {
|
2016-12-01 18:35:11 +00:00
|
|
|
this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType);
|
2016-08-03 17:21:11 +00:00
|
|
|
}
|
|
|
|
|
2016-08-11 16:16:29 +00:00
|
|
|
if (const SkPaint* strokePaint = ctx.strokePaint()) {
|
2016-12-01 18:35:11 +00:00
|
|
|
this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType);
|
2016-08-03 17:21:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkSVGShape::appendChild(sk_sp<SkSVGNode>) {
|
|
|
|
SkDebugf("cannot append child nodes to an SVG shape.\n");
|
|
|
|
}
|
2016-12-01 18:35:11 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|