Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
modules
svg
src
SkSVGPoly.cpp
Go to the documentation of this file.
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 "
include/core/SkCanvas.h
"
9
#include "
modules/svg/include/SkSVGPoly.h
"
10
#include "
modules/svg/include/SkSVGRenderContext.h
"
11
#include "
modules/svg/include/SkSVGValue.h
"
12
#include "
src/base/SkTLazy.h
"
13
14
SkSVGPoly::SkSVGPoly(
SkSVGTag
t) :
INHERITED
(t) {}
15
16
bool
SkSVGPoly::parseAndSetAttribute
(
const
char
* n,
const
char
* v) {
17
if
(
INHERITED::parseAndSetAttribute
(n, v)) {
18
return
true
;
19
}
20
21
if
(this->setPoints(SkSVGAttributeParser::parse<SkSVGPointsType>(
"points"
, n, v))) {
22
// TODO: we can likely just keep the points array and create the SkPath when needed.
23
fPath =
SkPath::Polygon
(
24
fPoints.data(), fPoints.size(),
25
this->tag() ==
SkSVGTag::kPolygon
);
// only polygons are auto-closed
26
}
27
28
// No other attributes on this node
29
return
false
;
30
}
31
32
void
SkSVGPoly::onDraw
(
SkCanvas
* canvas,
const
SkSVGLengthContext
&,
const
SkPaint
&
paint
,
33
SkPathFillType
fillType)
const
{
34
// the passed fillType follows inheritance rules and needs to be applied at draw time.
35
fPath.
setFillType
(fillType);
36
canvas->
drawPath
(fPath,
paint
);
37
}
38
39
SkPath
SkSVGPoly::onAsPath
(
const
SkSVGRenderContext
& ctx)
const
{
40
SkPath
path = fPath;
41
42
// clip-rule can be inherited and needs to be applied at clip time.
43
path.setFillType(ctx.
presentationContext
().
fInherited
.
fClipRule
->
asFillType
());
44
45
this->
mapToParent
(&path);
46
return
path;
47
}
48
49
SkRect
SkSVGPoly::onObjectBoundingBox
(
const
SkSVGRenderContext
& ctx)
const
{
50
return
fPath.
getBounds
();
51
}
SkCanvas.h
SkPathFillType
SkPathFillType
Definition
SkPathTypes.h:11
INHERITED
#define INHERITED(method,...)
Definition
SkRecorder.cpp:128
SkSVGTag
SkSVGTag
Definition
SkSVGNode.h:23
SkSVGTag::kPolygon
@ kPolygon
SkSVGPoly.h
SkSVGRenderContext.h
SkSVGValue.h
SkTLazy.h
SkCanvas
Definition
SkCanvas.h:106
SkCanvas::drawPath
void drawPath(const SkPath &path, const SkPaint &paint)
Definition
SkCanvas.cpp:2071
SkPaint
Definition
SkPaint.h:44
SkPath
Definition
SkPath.h:59
SkPath::setFillType
void setFillType(SkPathFillType ft)
Definition
SkPath.h:235
SkPath::getBounds
const SkRect & getBounds() const
Definition
SkPath.cpp:420
SkPath::Polygon
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition
SkPath.cpp:3546
SkSVGFillRule::asFillType
SkPathFillType asFillType() const
Definition
SkSVGTypes.h:361
SkSVGLengthContext
Definition
SkSVGRenderContext.h:29
SkSVGNode::parseAndSetAttribute
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition
SkSVGNode.cpp:90
SkSVGPoly::onObjectBoundingBox
SkRect onObjectBoundingBox(const SkSVGRenderContext &) const override
Definition
SkSVGPoly.cpp:49
SkSVGPoly::onDraw
void onDraw(SkCanvas *, const SkSVGLengthContext &, const SkPaint &, SkPathFillType) const override
Definition
SkSVGPoly.cpp:32
SkSVGPoly::onAsPath
SkPath onAsPath(const SkSVGRenderContext &) const override
Definition
SkSVGPoly.cpp:39
SkSVGPoly::parseAndSetAttribute
bool parseAndSetAttribute(const char *, const char *) override
Definition
SkSVGPoly.cpp:16
SkSVGRenderContext
Definition
SkSVGRenderContext.h:63
SkSVGRenderContext::presentationContext
const SkSVGPresentationContext & presentationContext() const
Definition
SkSVGRenderContext.h:88
SkSVGTransformableNode::mapToParent
void mapToParent(SkPath *) const
Definition
SkSVGTransformableNode.cpp:40
paint
const Paint & paint
Definition
color_source.cc:38
SkRect
Definition
extension.cpp:13
SkSVGPresentationAttributes::fClipRule
SkSVGProperty< SkSVGFillRule, true > fClipRule
Definition
SkSVGAttribute.h:77
SkSVGPresentationContext::fInherited
SkSVGPresentationAttributes fInherited
Definition
SkSVGRenderContext.h:60
Generated on Fri Apr 26 2024 06:16:30 for Flutter Engine by
1.9.8