Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSGPaint.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 SkSGPaint_DEFINED
9#define SkSGPaint_DEFINED
10
14#include "include/core/SkRect.h"
18
19class SkMatrix;
20
21namespace skottie::internal {
22class AnimationBuilder;
23} // namespace skottie::internal
24
25namespace sksg {
26class InvalidationController;
27class Shader;
28
29/**
30 * Base class for nodes which provide a 'paint' (as opposed to geometry) for
31 * drawing (e.g. colors, gradients, patterns).
32 *
33 * Roughly equivalent to Skia's SkPaint.
34 */
35class PaintNode : public Node {
36public:
37 SkPaint makePaint() const;
38
39 SG_ATTRIBUTE(AntiAlias , bool , fAntiAlias )
40 SG_ATTRIBUTE(Opacity , SkScalar , fOpacity )
41 SG_ATTRIBUTE(BlendMode , SkBlendMode , fBlendMode )
42 SG_ATTRIBUTE(StrokeWidth, SkScalar , fStrokeWidth)
43 SG_ATTRIBUTE(StrokeMiter, SkScalar , fStrokeMiter)
44 SG_ATTRIBUTE(Style , SkPaint::Style, fStyle )
45 SG_ATTRIBUTE(StrokeJoin , SkPaint::Join , fStrokeJoin )
46 SG_ATTRIBUTE(StrokeCap , SkPaint::Cap , fStrokeCap )
47
48protected:
49 PaintNode();
50
51 virtual void onApplyToPaint(SkPaint*) const = 0;
52
53private:
54 SkScalar fOpacity = 1,
55 fStrokeWidth = 1,
56 fStrokeMiter = 4;
57 bool fAntiAlias = false;
62
63 using INHERITED = Node;
64};
65
66/**
67 * Concrete Paint node, wrapping an SkColor.
68 */
69class Color : public PaintNode {
70public:
71 static sk_sp<Color> Make(SkColor c);
72
73 SG_ATTRIBUTE(Color, SkColor, fColor)
74
75protected:
77
78 void onApplyToPaint(SkPaint*) const override;
79
80private:
81 explicit Color(SkColor);
82
83 SkColor fColor;
84
86};
87
88/**
89 * Shader-based paint.
90 */
91class ShaderPaint final : public PaintNode {
92public:
93 ~ShaderPaint() override;
94
96
97protected:
99
100 void onApplyToPaint(SkPaint*) const override;
101
102private:
103 explicit ShaderPaint(sk_sp<Shader>);
104
105 const sk_sp<Shader> fShader;
106
107 using INHERITED = PaintNode;
108};
109
110} // namespace sksg
111
112#endif // SkSGPaint_DEFINED
SkBlendMode
Definition SkBlendMode.h:38
@ kSrcOver
r = s + (1-sa)*d
uint32_t SkColor
Definition SkColor.h:37
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
Definition SkSGNode.h:100
@ kButt_Cap
no stroke extension
Definition SkPaint.h:334
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
@ kMiter_Join
extends to miter limit
Definition SkPaint.h:359
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition SkSGPaint.cpp:50
void onApplyToPaint(SkPaint *) const override
Definition SkSGPaint.cpp:56
static sk_sp< Color > Make(SkColor c)
Definition SkSGPaint.cpp:44
SkPaint makePaint() const
Definition SkSGPaint.cpp:23
virtual void onApplyToPaint(SkPaint *) const =0
~ShaderPaint() override
Definition SkSGPaint.cpp:70
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition SkSGPaint.cpp:74
static sk_sp< ShaderPaint > Make(sk_sp< Shader >)
Definition SkSGPaint.cpp:60
void onApplyToPaint(SkPaint *) const override
Definition SkSGPaint.cpp:80
float SkScalar
Definition extension.cpp:12
Definition Skottie.h:32