fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 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 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 8 | #include "modules/svg/include/SkSVGRenderContext.h" |
| 9 | #include "modules/svg/include/SkSVGShape.h" |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 10 | |
| 11 | SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {} |
| 12 | |
fmalita | 397a517 | 2016-08-08 11:38:55 -0700 | [diff] [blame] | 13 | void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const { |
John Stiles | a008b0f | 2020-08-16 08:48:02 -0400 | [diff] [blame] | 14 | const auto fillType = ctx.presentationContext().fInherited.fFillRule->asFillType(); |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 15 | |
Florin Malita | bde06cc | 2021-01-19 10:12:37 -0500 | [diff] [blame^] | 16 | const auto fillPaint = ctx.fillPaint(), |
| 17 | strokePaint = ctx.strokePaint(); |
| 18 | |
fmalita | 286a865 | 2016-08-10 17:11:29 -0700 | [diff] [blame] | 19 | // TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid. |
Florin Malita | bde06cc | 2021-01-19 10:12:37 -0500 | [diff] [blame^] | 20 | if (fillPaint.isValid()) { |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 21 | this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType); |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Florin Malita | bde06cc | 2021-01-19 10:12:37 -0500 | [diff] [blame^] | 24 | if (strokePaint.isValid()) { |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 25 | this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType); |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 26 | } |
| 27 | } |
| 28 | |
| 29 | void SkSVGShape::appendChild(sk_sp<SkSVGNode>) { |
| 30 | SkDebugf("cannot append child nodes to an SVG shape.\n"); |
| 31 | } |