Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSVGLinearGradient.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
13
14SkSVGLinearGradient::SkSVGLinearGradient() : INHERITED(SkSVGTag::kLinearGradient) {}
15
16bool SkSVGLinearGradient::parseAndSetAttribute(const char* name, const char* value) {
18 this->setX1(SkSVGAttributeParser::parse<SkSVGLength>("x1", name, value)) ||
19 this->setY1(SkSVGAttributeParser::parse<SkSVGLength>("y1", name, value)) ||
20 this->setX2(SkSVGAttributeParser::parse<SkSVGLength>("x2", name, value)) ||
21 this->setY2(SkSVGAttributeParser::parse<SkSVGLength>("y2", name, value));
22}
23
25 const SkColor4f* colors, const SkScalar* pos,
26 int count, SkTileMode tm,
27 const SkMatrix& localMatrix) const {
28 const SkSVGLengthContext lctx =
29 this->getGradientUnits().type() == SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox
30 ? SkSVGLengthContext({1, 1})
31 : ctx.lengthContext();
32
34 const auto y1 = lctx.resolve(fY1, SkSVGLengthContext::LengthType::kVertical);
36 const auto y2 = lctx.resolve(fY2, SkSVGLengthContext::LengthType::kVertical);
37
38 const SkPoint pts[2] = { {x1, y1}, {x2, y2}};
39
40 return SkGradientShader::MakeLinear(pts, colors, nullptr, pos, count, tm, 0, &localMatrix);
41}
int count
SkPoint pos
#define INHERITED(method,...)
SkSVGTag
Definition SkSVGNode.h:23
@ kLinearGradient
SkTileMode
Definition SkTileMode.h:13
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
bool parseAndSetAttribute(const char *, const char *) override
SkScalar resolve(const SkSVGLength &, LengthType) const
sk_sp< SkShader > onMakeShader(const SkSVGRenderContext &, const SkColor4f *, const SkScalar *, int count, SkTileMode, const SkMatrix &) const override
bool parseAndSetAttribute(const char *, const char *) override
const SkSVGLengthContext & lengthContext() const
float SkScalar
Definition extension.cpp:12
uint8_t value
const char * name
Definition fuchsia.cc:50