Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
36
45
56
66
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,
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
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_
static SkScalar center(float pos0, float pos1)
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
FlTexture * texture
float Scalar
Definition scalar.h:18
std::variant< LinearGradientData, RadialGradientData, ConicalGradientData, SweepGradientData, ImageData, RuntimeEffectData, std::monostate > ColorSourceData
Definition ref_ptr.h:256
std::vector< Scalar > stops
std::vector< Color > colors
std::shared_ptr< Texture > texture
SamplerDescriptor sampler_descriptor
Entity::TileMode y_tile_mode
Entity::TileMode x_tile_mode
std::vector< Color > colors
std::vector< Scalar > stops
A 4x4 matrix using column-major storage.
Definition matrix.h:37
std::vector< Color > colors
std::vector< Scalar > stops
std::shared_ptr< std::vector< uint8_t > > uniform_data
std::shared_ptr< RuntimeStage > runtime_stage
std::vector< RuntimeEffectContents::TextureInput > texture_inputs
std::vector< Scalar > stops
Entity::TileMode tile_mode
std::vector< Color > colors