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 | |
| 8 | #include "SkSVGRenderContext.h" |
| 9 | #include "SkSVGShape.h" |
| 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 { |
Florin Malita | 57a0edf | 2017-10-10 11:22:08 -0400 | [diff] [blame] | 14 | const auto fillType = ctx.presentationContext().fInherited.fFillRule.get()->asFillType(); |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 15 | |
fmalita | 286a865 | 2016-08-10 17:11:29 -0700 | [diff] [blame] | 16 | // TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid. |
fmalita | 2d961e0 | 2016-08-11 09:16:29 -0700 | [diff] [blame] | 17 | if (const SkPaint* fillPaint = ctx.fillPaint()) { |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 18 | this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType); |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 19 | } |
| 20 | |
fmalita | 2d961e0 | 2016-08-11 09:16:29 -0700 | [diff] [blame] | 21 | if (const SkPaint* strokePaint = ctx.strokePaint()) { |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 22 | this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType); |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 23 | } |
| 24 | } |
| 25 | |
| 26 | void SkSVGShape::appendChild(sk_sp<SkSVGNode>) { |
| 27 | SkDebugf("cannot append child nodes to an SVG shape.\n"); |
| 28 | } |