Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
modules
svg
src
SkSVGLine.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/SkSVGLine.h
"
10
#include "
modules/svg/include/SkSVGRenderContext.h
"
11
#include "
modules/svg/include/SkSVGValue.h
"
12
13
SkSVGLine::SkSVGLine() :
INHERITED
(
SkSVGTag
::
kLine
) {}
14
15
bool
SkSVGLine::parseAndSetAttribute
(
const
char
* n,
const
char
* v) {
16
return
INHERITED::parseAndSetAttribute
(n, v) ||
17
this->setX1(SkSVGAttributeParser::parse<SkSVGLength>(
"x1"
, n, v)) ||
18
this->setY1(SkSVGAttributeParser::parse<SkSVGLength>(
"y1"
, n, v)) ||
19
this->setX2(SkSVGAttributeParser::parse<SkSVGLength>(
"x2"
, n, v)) ||
20
this->setY2(SkSVGAttributeParser::parse<SkSVGLength>(
"y2"
, n, v));
21
}
22
23
std::tuple<SkPoint, SkPoint> SkSVGLine::resolve(
const
SkSVGLengthContext
& lctx)
const
{
24
return
std::make_tuple(
25
SkPoint::Make
(lctx.
resolve
(fX1,
SkSVGLengthContext::LengthType::kHorizontal
),
26
lctx.
resolve
(fY1,
SkSVGLengthContext::LengthType::kVertical
)),
27
SkPoint::Make
(lctx.
resolve
(fX2,
SkSVGLengthContext::LengthType::kHorizontal
),
28
lctx.
resolve
(fY2,
SkSVGLengthContext::LengthType::kVertical
)));
29
}
30
31
void
SkSVGLine::onDraw
(
SkCanvas
* canvas,
const
SkSVGLengthContext
& lctx,
32
const
SkPaint
&
paint
,
SkPathFillType
)
const
{
33
SkPoint
p0, p1;
34
std::tie(p0, p1) = this->resolve(lctx);
35
36
canvas->
drawLine
(p0, p1,
paint
);
37
}
38
39
SkPath
SkSVGLine::onAsPath
(
const
SkSVGRenderContext
& ctx)
const
{
40
SkPoint
p0, p1;
41
std::tie(p0, p1) = this->resolve(ctx.
lengthContext
());
42
43
SkPath
path =
SkPath::Line
(p0, p1);
44
this->
mapToParent
(&path);
45
46
return
path;
47
}
SkCanvas.h
SkPathFillType
SkPathFillType
Definition
SkPathTypes.h:11
SkPathVerb::kLine
@ kLine
SkPath::RawIter returns 2 points.
INHERITED
#define INHERITED(method,...)
Definition
SkRecorder.cpp:128
SkSVGLine.h
SkSVGTag
SkSVGTag
Definition
SkSVGNode.h:23
SkSVGRenderContext.h
SkSVGValue.h
SkCanvas
Definition
SkCanvas.h:106
SkCanvas::drawLine
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition
SkCanvas.cpp:3127
SkPaint
Definition
SkPaint.h:44
SkPath
Definition
SkPath.h:59
SkPath::Line
static SkPath Line(const SkPoint a, const SkPoint b)
Definition
SkPath.h:106
SkSVGLengthContext
Definition
SkSVGRenderContext.h:29
SkSVGLengthContext::LengthType::kVertical
@ kVertical
SkSVGLengthContext::LengthType::kHorizontal
@ kHorizontal
SkSVGLengthContext::resolve
SkScalar resolve(const SkSVGLength &, LengthType) const
Definition
SkSVGRenderContext.cpp:54
SkSVGLine::onAsPath
SkPath onAsPath(const SkSVGRenderContext &) const override
Definition
SkSVGLine.cpp:39
SkSVGLine::onDraw
void onDraw(SkCanvas *, const SkSVGLengthContext &, const SkPaint &, SkPathFillType) const override
Definition
SkSVGLine.cpp:31
SkSVGLine::parseAndSetAttribute
bool parseAndSetAttribute(const char *, const char *) override
Definition
SkSVGLine.cpp:15
SkSVGNode::parseAndSetAttribute
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition
SkSVGNode.cpp:90
SkSVGRenderContext
Definition
SkSVGRenderContext.h:63
SkSVGRenderContext::lengthContext
const SkSVGLengthContext & lengthContext() const
Definition
SkSVGRenderContext.h:85
SkSVGTransformableNode::mapToParent
void mapToParent(SkPath *) const
Definition
SkSVGTransformableNode.cpp:40
paint
const Paint & paint
Definition
color_source.cc:38
SkPoint
Definition
SkPoint_impl.h:163
SkPoint::Make
static constexpr SkPoint Make(float x, float y)
Definition
SkPoint_impl.h:173
Generated on Fri Apr 26 2024 06:16:29 for Flutter Engine by
1.9.8