25 #if IMPELLER_ENABLE_3D
28 #endif // IMPELLER_ENABLE_3D
34 auto contents = std::make_shared<SolidColorContents>();
35 contents->SetColor(paint.color);
47 std::vector<Color> colors,
48 std::vector<Scalar> stops,
53 result.proc_ = [start_point, end_point, colors = std::move(colors),
54 stops = std::move(stops), tile_mode,
55 effect_transform](
const Paint& paint) {
56 auto contents = std::make_shared<LinearGradientContents>();
57 contents->SetOpacityFactor(paint.color.alpha);
58 contents->SetColors(colors);
59 contents->SetStops(stops);
60 contents->SetEndPoints(start_point, end_point);
61 contents->SetTileMode(tile_mode);
62 contents->SetDither(paint.dither);
63 contents->SetEffectTransform(effect_transform);
65 std::vector<Point> bounds{start_point, end_point};
67 if (intrinsic_size.has_value()) {
68 contents->SetColorSourceSize(intrinsic_size->size);
77 std::vector<Color> colors,
78 std::vector<Scalar> stops,
85 result.proc_ = [center, radius, colors = std::move(colors),
86 stops = std::move(stops), focus_center, focus_radius,
87 tile_mode, effect_transform](
const Paint& paint) {
88 std::shared_ptr<ConicalGradientContents> contents =
89 std::make_shared<ConicalGradientContents>();
90 contents->SetOpacityFactor(paint.color.alpha);
91 contents->SetColors(colors);
92 contents->SetStops(stops);
93 contents->SetCenterAndRadius(center, radius);
94 contents->SetTileMode(tile_mode);
95 contents->SetDither(paint.dither);
96 contents->SetEffectTransform(effect_transform);
97 contents->SetFocus(focus_center, focus_radius);
99 auto radius_pt =
Point(radius, radius);
100 std::vector<Point> bounds{center + radius_pt, center - radius_pt};
102 if (intrinsic_size.has_value()) {
103 contents->SetColorSourceSize(intrinsic_size->size);
112 std::vector<Color> colors,
113 std::vector<Scalar> stops,
115 Matrix effect_transform) {
118 result.proc_ = [center, radius, colors = std::move(colors),
119 stops = std::move(stops), tile_mode,
120 effect_transform](
const Paint& paint) {
121 auto contents = std::make_shared<RadialGradientContents>();
122 contents->SetOpacityFactor(paint.color.alpha);
123 contents->SetColors(colors);
124 contents->SetStops(stops);
125 contents->SetCenterAndRadius(center, radius);
126 contents->SetTileMode(tile_mode);
127 contents->SetDither(paint.dither);
128 contents->SetEffectTransform(effect_transform);
130 auto radius_pt =
Point(radius, radius);
131 std::vector<Point> bounds{center + radius_pt, center - radius_pt};
133 if (intrinsic_size.has_value()) {
134 contents->SetColorSourceSize(intrinsic_size->size);
144 std::vector<Color> colors,
145 std::vector<Scalar> stops,
147 Matrix effect_transform) {
150 result.proc_ = [center, start_angle, end_angle, colors = std::move(colors),
151 stops = std::move(stops), tile_mode,
152 effect_transform](
const Paint& paint) {
153 auto contents = std::make_shared<SweepGradientContents>();
154 contents->SetOpacityFactor(paint.color.alpha);
155 contents->SetCenterAndAngles(center, start_angle, end_angle);
156 contents->SetColors(colors);
157 contents->SetStops(stops);
158 contents->SetTileMode(tile_mode);
159 contents->SetDither(paint.dither);
160 contents->SetEffectTransform(effect_transform);
171 Matrix effect_transform) {
174 result.proc_ = [texture = std::move(texture), x_tile_mode, y_tile_mode,
175 sampler_descriptor = std::move(sampler_descriptor),
176 effect_transform](
const Paint& paint) {
177 auto contents = std::make_shared<TiledTextureContents>();
178 contents->SetOpacityFactor(paint.color.alpha);
179 contents->SetTexture(texture);
180 contents->SetTileModes(x_tile_mode, y_tile_mode);
181 contents->SetSamplerDescriptor(sampler_descriptor);
182 contents->SetEffectTransform(effect_transform);
183 if (paint.color_filter) {
186 return color_filter->WrapWithGPUColorFilter(
189 contents->SetColorFilter(filter_proc);
191 contents->SetColorSourceSize(
Size::Ceil(texture->GetSize()));
198 std::shared_ptr<RuntimeStage> runtime_stage,
199 std::shared_ptr<std::vector<uint8_t>> uniform_data,
200 std::vector<RuntimeEffectContents::TextureInput> texture_inputs) {
203 result.proc_ = [runtime_stage = std::move(runtime_stage),
204 uniform_data = std::move(uniform_data),
206 std::move(texture_inputs)](
const Paint& paint) {
207 auto contents = std::make_shared<RuntimeEffectContents>();
208 contents->SetOpacityFactor(paint.color.alpha);
209 contents->SetRuntimeStage(runtime_stage);
210 contents->SetUniformData(uniform_data);
211 contents->SetTextureInputs(texture_inputs);
217 #if IMPELLER_ENABLE_3D
218 ColorSource ColorSource::MakeScene(std::shared_ptr<scene::Node> scene_node,
219 Matrix camera_transform) {
222 result.proc_ = [scene_node = std::move(scene_node),
223 camera_transform](
const Paint& paint) {
224 auto contents = std::make_shared<SceneContents>();
225 contents->SetOpacityFactor(paint.color.alpha);
226 contents->SetNode(scene_node);
227 contents->SetCameraTransform(camera_transform);
232 #endif // IMPELLER_ENABLE_3D
239 const Paint& paint)
const {