blob: 617d8f7d1f527b1e0b7cf6a2b5cef67994049bec [file] [log] [blame]
fmalitabffc2562016-08-03 10:21:11 -07001/*
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
Florin Malitab3418102020-10-15 18:10:29 -04008#include "modules/svg/include/SkSVGRenderContext.h"
9#include "modules/svg/include/SkSVGShape.h"
fmalitabffc2562016-08-03 10:21:11 -070010
11SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {}
12
fmalita397a5172016-08-08 11:38:55 -070013void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const {
John Stilesa008b0f2020-08-16 08:48:02 -040014 const auto fillType = ctx.presentationContext().fInherited.fFillRule->asFillType();
Florin Malitae932d4b2016-12-01 13:35:11 -050015
Florin Malitabde06cc2021-01-19 10:12:37 -050016 const auto fillPaint = ctx.fillPaint(),
17 strokePaint = ctx.strokePaint();
18
fmalita286a8652016-08-10 17:11:29 -070019 // TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid.
Florin Malitabde06cc2021-01-19 10:12:37 -050020 if (fillPaint.isValid()) {
Florin Malitae932d4b2016-12-01 13:35:11 -050021 this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType);
fmalitabffc2562016-08-03 10:21:11 -070022 }
23
Florin Malitabde06cc2021-01-19 10:12:37 -050024 if (strokePaint.isValid()) {
Florin Malitae932d4b2016-12-01 13:35:11 -050025 this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType);
fmalitabffc2562016-08-03 10:21:11 -070026 }
27}
28
29void SkSVGShape::appendChild(sk_sp<SkSVGNode>) {
30 SkDebugf("cannot append child nodes to an SVG shape.\n");
31}