| 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/SkSVGShape.h" |
| 9 |
|
| 10 |
#include "include/core/SkPaint.h" // IWYU pragma: keep |
| 11 |
#include "include/private/base/SkDebug.h" |
| 12 |
#include "modules/svg/include/SkSVGAttribute.h" |
| 13 |
#include "modules/svg/include/SkSVGRenderContext.h" |
| 14 |
#include "modules/svg/include/SkSVGTypes.h" |
| 15 |
|
| 16 |
class SkSVGNode; |
| 17 |
enum class SkSVGTag; |
| 18 |
|
| 19 |
SkSVGShape::SkSVGShape(SkSVGTag t) : INHERITED(t) {} |
| 20 |
|
| 21 |
void SkSVGShape::onRender(const SkSVGRenderContext& ctx) const { |
| 22 |
const auto fillType = ctx.presentationContext().fInherited.fFillRule->asFillType(); |
| 23 |
|
| 24 |
const auto fillPaint = ctx.fillPaint(), |
| 25 |
strokePaint = ctx.strokePaint(); |
| 26 |
|
| 27 |
// TODO: this approach forces duplicate geometry resolution in onDraw(); refactor to avoid. |
| 28 |
if (fillPaint.has_value()) { |
| 29 |
this->onDraw(ctx.canvas(), ctx.lengthContext(), *fillPaint, fillType); |
| 30 |
} |
| 31 |
|
| 32 |
if (strokePaint.has_value()) { |
| 33 |
this->onDraw(ctx.canvas(), ctx.lengthContext(), *strokePaint, fillType); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
void SkSVGShape::appendChild(sk_sp<SkSVGNode>) { |
| 38 |
SkDEBUGF("cannot append child nodes to an SVG shape.\n"); |
| 39 |
} |