1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "modules/svg/include/SkSVGRenderContext.h"
9 #include "modules/svg/include/SkSVGShape.h"
10 
SkSVGShape(SkSVGTag t)11 SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {}
12 
onRender(const SkSVGRenderContext & ctx) const13 void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const {
14     const auto fillType = ctx.presentationContext().fInherited.fFillRule->asFillType();
15 
16     const auto fillPaint = ctx.fillPaint(),
17              strokePaint = ctx.strokePaint();
18 
19     // TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid.
20     if (fillPaint.isValid()) {
21         this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType);
22     }
23 
24     if (strokePaint.isValid()) {
25         this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType);
26     }
27 }
28 
appendChild(sk_sp<SkSVGNode>)29 void SkSVGShape::appendChild(sk_sp<SkSVGNode>) {
30     SkDebugf("cannot append child nodes to an SVG shape.\n");
31 }
32