Flutter Engine
The Flutter Engine
color_source.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_AIKS_COLOR_SOURCE_H_
6#define FLUTTER_IMPELLER_AIKS_COLOR_SOURCE_H_
7
8#include <functional>
9#include <memory>
10#include <variant>
11#include <vector>
12
19
20#if IMPELLER_ENABLE_3D
21#include "impeller/scene/node.h" // nogncheck
22#endif // IMPELLER_ENABLE_3D
23
24namespace impeller {
25
26struct Paint;
27
31 std::vector<Color> colors;
32 std::vector<Scalar> stops;
35};
36
40 std::vector<Color> colors;
41 std::vector<Scalar> stops;
44};
45
49 std::vector<Color> colors;
50 std::vector<Scalar> stops;
55};
56
61 std::vector<Color> colors;
62 std::vector<Scalar> stops;
65};
66
67struct ImageData {
68 std::shared_ptr<Texture> texture;
73};
74
76 std::shared_ptr<RuntimeStage> runtime_stage;
77 std::shared_ptr<std::vector<uint8_t>> uniform_data;
78 std::vector<RuntimeEffectContents::TextureInput> texture_inputs;
79};
80
81#if IMPELLER_ENABLE_3D
82struct SceneData {
83 std::shared_ptr<scene::Node> scene_node;
84 Matrix camera_transform;
85};
86#endif // IMPELLER_ENABLE_3D
87
94#if IMPELLER_ENABLE_3D
95 SceneData,
96#endif // IMPELLER_ENABLE_3D
97 std::monostate>;
98
100 public:
101 enum class Type {
102 kColor,
103 kImage,
104 kLinearGradient,
105 kRadialGradient,
106 kConicalGradient,
107 kSweepGradient,
108 kRuntimeEffect,
109 kScene,
110 };
111
112 ColorSource() noexcept;
113
115
116 static ColorSource MakeColor();
117
118 static ColorSource MakeLinearGradient(Point start_point,
119 Point end_point,
120 std::vector<Color> colors,
121 std::vector<Scalar> stops,
122 Entity::TileMode tile_mode,
123 Matrix effect_transform);
124
126 Scalar radius,
127 std::vector<Color> colors,
128 std::vector<Scalar> stops,
129 Point focus_center,
130 Scalar focus_radius,
131 Entity::TileMode tile_mode,
132 Matrix effect_transform);
133
135 Scalar radius,
136 std::vector<Color> colors,
137 std::vector<Scalar> stops,
138 Entity::TileMode tile_mode,
139 Matrix effect_transform);
140
141 static ColorSource MakeSweepGradient(Point center,
142 Degrees start_angle,
143 Degrees end_angle,
144 std::vector<Color> colors,
145 std::vector<Scalar> stops,
146 Entity::TileMode tile_mode,
147 Matrix effect_transform);
148
149 static ColorSource MakeImage(std::shared_ptr<Texture> texture,
150 Entity::TileMode x_tile_mode,
151 Entity::TileMode y_tile_mode,
152 SamplerDescriptor sampler_descriptor,
153 Matrix effect_transform);
154
156 std::shared_ptr<RuntimeStage> runtime_stage,
157 std::shared_ptr<std::vector<uint8_t>> uniform_data,
158 std::vector<RuntimeEffectContents::TextureInput> texture_inputs);
159
160#if IMPELLER_ENABLE_3D
161 static ColorSource MakeScene(std::shared_ptr<scene::Node> scene_node,
162 Matrix camera_transform);
163#endif // IMPELLER_ENABLE_3D
164
165 Type GetType() const;
166
167 std::shared_ptr<ColorSourceContents> GetContents(const Paint& paint) const;
168
169 const ColorSourceData& GetData() const;
170
171 private:
172 Type type_ = Type::kColor;
173 ColorSourceData color_source_data_;
174};
175
176} // namespace impeller
177
178#endif // FLUTTER_IMPELLER_AIKS_COLOR_SOURCE_H_
const ColorSourceData & GetData() const
static ColorSource MakeLinearGradient(Point start_point, Point end_point, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeColor()
static ColorSource MakeRadialGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeImage(std::shared_ptr< Texture > texture, Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode, SamplerDescriptor sampler_descriptor, Matrix effect_transform)
static ColorSource MakeSweepGradient(Point center, Degrees start_angle, Degrees end_angle, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
std::shared_ptr< ColorSourceContents > GetContents(const Paint &paint) const
static ColorSource MakeConicalGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Point focus_center, Scalar focus_radius, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeRuntimeEffect(std::shared_ptr< RuntimeStage > runtime_stage, std::shared_ptr< std::vector< uint8_t > > uniform_data, std::vector< RuntimeEffectContents::TextureInput > texture_inputs)
const Paint & paint
Definition: color_source.cc:38
FlTexture * texture
PODArray< SkColor > colors
Definition: SkRecords.h:276
float Scalar
Definition: scalar.h:18
std::variant< LinearGradientData, RadialGradientData, ConicalGradientData, SweepGradientData, ImageData, RuntimeEffectData, std::monostate > ColorSourceData
Definition: color_source.h:97
SkTileMode TileMode(jint tm)
Definition: Utils.cpp:26
Definition: ref_ptr.h:256
std::vector< Scalar > stops
Definition: color_source.h:50
std::vector< Color > colors
Definition: color_source.h:49
Entity::TileMode tile_mode
Definition: color_source.h:53
std::shared_ptr< Texture > texture
Definition: color_source.h:68
SamplerDescriptor sampler_descriptor
Definition: color_source.h:71
Entity::TileMode y_tile_mode
Definition: color_source.h:70
Entity::TileMode x_tile_mode
Definition: color_source.h:69
Entity::TileMode tile_mode
Definition: color_source.h:33
std::vector< Color > colors
Definition: color_source.h:31
std::vector< Scalar > stops
Definition: color_source.h:32
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
std::vector< Color > colors
Definition: color_source.h:40
std::vector< Scalar > stops
Definition: color_source.h:41
Entity::TileMode tile_mode
Definition: color_source.h:42
std::shared_ptr< std::vector< uint8_t > > uniform_data
Definition: color_source.h:77
std::shared_ptr< RuntimeStage > runtime_stage
Definition: color_source.h:76
std::vector< RuntimeEffectContents::TextureInput > texture_inputs
Definition: color_source.h:78
std::vector< Scalar > stops
Definition: color_source.h:62
Entity::TileMode tile_mode
Definition: color_source.h:63
std::vector< Color > colors
Definition: color_source.h:61