Skia
2D Graphics Library
SkSVGGradient.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 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 #ifndef SkSVGGradient_DEFINED
9 #define SkSVGGradient_DEFINED
10 
11 #include "include/core/SkShader.h"
14 
15 class SkMatrix;
16 class SkSVGRenderContext;
17 class SkSVGStop;
18 
19 class SK_API SkSVGGradient : public SkSVGHiddenContainer {
20 public:
21  SVG_ATTR(Href, SkSVGIRI, SkSVGIRI())
24  SVG_ATTR(GradientUnits,
27 
28 protected:
29  explicit SkSVGGradient(SkSVGTag t) : INHERITED(t) {}
30 
31  bool parseAndSetAttribute(const char*, const char*) override;
32 
33  bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const final;
34 
36  const SkColor4f*, const SkScalar*, int count,
37  SkTileMode, const SkMatrix& localMatrix) const = 0;
38 
39 private:
40  using StopPositionArray = skia_private::STArray<2, SkScalar , true>;
41  using StopColorArray = skia_private::STArray<2, SkColor4f, true>;
42  void collectColorStops(const SkSVGRenderContext&, StopPositionArray*, StopColorArray*) const;
43  SkColor4f resolveStopColor(const SkSVGRenderContext&, const SkSVGStop&) const;
44 
46 };
47 
48 #endif // SkSVGGradient_DEFINED
SkSVGTag
Definition: SkSVGNode.h:23
#define SVG_ATTR(attr_name, attr_type, attr_default)
Definition: SkSVGNode.h:203
float SkScalar
Definition: SkScalar.h:14
SkTileMode
Definition: SkTileMode.h:13
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
Definition: SkSVGGradient.h:19
bool onAsPaint(const SkSVGRenderContext &, SkPaint *) const final
bool parseAndSetAttribute(const char *, const char *) override
virtual sk_sp< SkShader > onMakeShader(const SkSVGRenderContext &, const SkColor4f *, const SkScalar *, int count, SkTileMode, const SkMatrix &localMatrix) const =0
Definition: SkSVGHiddenContainer.h:13
SkSVGHiddenContainer(SkSVGTag t)
Definition: SkSVGHiddenContainer.h:15
Definition: SkSVGTypes.h:152
Definition: SkSVGTypes.h:454
Definition: SkSVGRenderContext.h:61
Definition: SkSVGTypes.h:318
Definition: SkSVGStop.h:16
Definition: SkSVGTransformableNode.h:14
RGBA color value, holding four floating point components.