| Flutter Impeller |

Public Types | Public Member Functions | Static Public Member Functions | List of all members
impeller::ColorSource Class Reference

`#include <color_source.h>`

## Public Types
enum | Type { Type::kColor, Type::kImage, Type::kLinearGradient, Type::kRadialGradient, Type::kConicalGradient, Type::kSweepGradient, Type::kRuntimeEffect, Type::kScene }

## Public Member Functions
| ColorSource () noexcept
| ~ColorSource ()
Type | GetType () const
std::shared_ptr< ColorSourceContents > | GetContents (const Paint &paint) const
const ColorSourceData & | GetData () const

## Static Public Member Functions
static ColorSource | MakeColor ()
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 | 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 | MakeRadialGradient (Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, 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)
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 | MakeRuntimeEffect (std::shared_ptr< RuntimeStage > runtime_stage, std::shared_ptr< std::vector< uint8_t >> uniform_data, std::vector< RuntimeEffectContents::TextureInput > texture_inputs)

## Detailed Description

Definition at line 99 of file color_source.h.

## Member Enumeration Documentation

## ◆ Type

enum impeller::ColorSource::Type
| strong

Enumerator
kColor |
kImage |
kLinearGradient |
kRadialGradient |
kConicalGradient |
kSweepGradient |
kRuntimeEffect |
kScene |

Definition at line 101 of file color_source.h.

101 {
102 kColor,
103 kImage,
104 kLinearGradient,
105 kRadialGradient,
106 kConicalGradient,
107 kSweepGradient,
108 kRuntimeEffect,
109 kScene,
110 };

## Constructor & Destructor Documentation

## ◆ ColorSource()

impeller::ColorSource::ColorSource | ( |  | ) |
| noexcept

Definition at line 158 of file color_source.cc.

158 : color_source_data_(std::monostate()) {}

## ◆ ~ColorSource()

impeller::ColorSource::~ColorSource | ( |  | ) |
| default

## Member Function Documentation

## ◆ GetContents()

std::shared_ptr< ColorSourceContents > impeller::ColorSource::GetContents | ( | const Paint & | paint | ) | const

Definition at line 264 of file color_source.cc.

265 {
266 return std::visit(CreateContentsVisitor{paint}, color_source_data_);
267 }

References paint.

Referenced by impeller::Paint::CreateContentsForGeometry().

## ◆ GetData()

const ColorSourceData & impeller::ColorSource::GetData | ( |  | ) | const

Definition at line 269 of file color_source.cc.

269 {
270 return color_source_data_;
271 }

## ◆ GetType()

ColorSource::Type impeller::ColorSource::GetType | ( |  | ) | const

Definition at line 260 of file color_source.cc.

260 {
261 return type_;
262 }

## ◆ MakeColor()

ColorSource impeller::ColorSource::MakeColor | ( |  | ) |
| static

Definition at line 162 of file color_source.cc.

162 {
163 return {};
164 }

Referenced by impeller::DlDispatcherBase::setColorSource().

## ◆ MakeConicalGradient()

ColorSource impeller::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

Definition at line 180 of file color_source.cc.

187 {
188 ColorSource result;
189 result.type_ = Type::kConicalGradient;
190 result.color_source_data_ = ConicalGradientData{
191 center, radius, std::move(colors), std::move(stops),
192 focus_center, focus_radius, tile_mode, effect_transform};
193 return result;
194 }

References kConicalGradient.

Referenced by impeller::DlDispatcherBase::setColorSource(), and impeller::testing::TEST_F().

## ◆ MakeImage()

ColorSource impeller::ColorSource::MakeImage | ( | std::shared_ptr< Texture > | texture,
|  | Entity::TileMode | x_tile_mode,
|  | Entity::TileMode | y_tile_mode,
|  | SamplerDescriptor | sampler_descriptor,
|  | Matrix | effect_transform
| ) |  |
| static

Definition at line 225 of file color_source.cc.

229 {
230 ColorSource result;
231 result.type_ = Type::kImage;
232 result.color_source_data_ =
233 ImageData{std::move(texture), x_tile_mode, y_tile_mode,
234 std::move(sampler_descriptor), effect_transform};
235 return result;
236 }

References kImage.

Referenced by impeller::DlDispatcherBase::setColorSource(), and impeller::testing::TEST_P().

## ◆ MakeLinearGradient()

ColorSource impeller::ColorSource::MakeLinearGradient | ( | Point | start_point,
|  | Point | end_point,
|  | std::vector< Color > | colors,
|  | std::vector< Scalar > | stops,
|  | Entity::TileMode | tile_mode,
|  | Matrix | effect_transform
| ) |  |
| static

Definition at line 166 of file color_source.cc.

171 {
172 ColorSource result;
173 result.type_ = Type::kLinearGradient;
174 result.color_source_data_ =
175 LinearGradientData{start_point, end_point, std::move(colors),
176 std::move(stops), tile_mode, effect_transform};
177 return result;
178 }

References kLinearGradient.

Referenced by impeller::DlDispatcherBase::setColorSource(), and impeller::testing::TEST_P().

## ◆ MakeRadialGradient()

ColorSource impeller::ColorSource::MakeRadialGradient | ( | Point | center,
|  | Scalar | radius,
|  | std::vector< Color > | colors,
|  | std::vector< Scalar > | stops,
|  | Entity::TileMode | tile_mode,
|  | Matrix | effect_transform
| ) |  |
| static

Definition at line 196 of file color_source.cc.

201 {
202 ColorSource result;
203 result.type_ = Type::kRadialGradient;
204 result.color_source_data_ =
205 RadialGradientData{center, radius, std::move(colors),
206 std::move(stops), tile_mode, effect_transform};
207 return result;
208 }

References kRadialGradient.

Referenced by impeller::DlDispatcherBase::setColorSource(), and impeller::testing::TEST_P().

## ◆ MakeRuntimeEffect()

ColorSource impeller::ColorSource::MakeRuntimeEffect | ( | std::shared_ptr< RuntimeStage > | runtime_stage,
|  | std::shared_ptr< std::vector< uint8_t >> | uniform_data,
|  | std::vector< RuntimeEffectContents::TextureInput > | texture_inputs
| ) |  |
| static

Definition at line 238 of file color_source.cc.

241 {
242 ColorSource result;
243 result.type_ = Type::kRuntimeEffect;
244 result.color_source_data_ =
245 RuntimeEffectData{std::move(runtime_stage), std::move(uniform_data),
246 std::move(texture_inputs)};
247 return result;
248 }

References kRuntimeEffect.

Referenced by impeller::DlDispatcherBase::setColorSource(), and impeller::testing::TEST_P().

## ◆ MakeSweepGradient()

ColorSource impeller::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
| ) |  |
| static

Definition at line 210 of file color_source.cc.

216 {
217 ColorSource result;
218 result.type_ = Type::kSweepGradient;
219 result.color_source_data_ = SweepGradientData{
220 center, start_angle, end_angle, std::move(colors),
221 std::move(stops), tile_mode, effect_transform};
222 return result;
223 }

References kSweepGradient.

Referenced by impeller::DlDispatcherBase::setColorSource(), and impeller::testing::TEST_P().

The documentation for this class was generated from the following files:

- impeller/aiks/color_source.h
- impeller/aiks/color_source.cc

impeller::ColorSource::Type::kLinearGradient
@ kLinearGradient
impeller::ColorSource::Type::kRadialGradient
@ kRadialGradient
impeller::ShaderType::kImage
@ kImage
impeller::BlendSelectValues::kColor
@ kColor
impeller::ColorSource::Type::kRuntimeEffect
@ kRuntimeEffect
impeller::ColorSource::ColorSource
ColorSource() noexcept
Definition: color_source.cc:158
impeller::ColorSource::Type::kImage
@ kImage
impeller::ColorSource::Type::kConicalGradient
@ kConicalGradient
paint
const Paint & paint
Definition: color_source.cc:38
impeller::ColorSource::Type::kSweepGradient
@ kSweepGradient