Skip to content

Commit a61a65d

Browse files
Revert: Handle linear and radial gradients in UberSDF (flutter#191913)
Reverts: [Handle linear and radial gradients in UberSDF](flutter#190874) Initiated by: @b-luk Reason for reverting: Breaks Mac_arm64 wide_gamut_macos https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_arm64%20wide_gamut_macos/1682/overview Original PR Author: @b-luk Reviewed By: @gaaclarke The original PR description is provided below: Adds direct support for linear and radial gradient color sources to UberSDF, enabling single-pass rendering of these gradients without the multi-pass blending that is currently used. - Adds a color_source_sampler input to UberSDF, which is used to sample a texture representing the gradient color ramp for a linear or radial gradient. This sampler may also be extended in the future for image-based color sources, but that is outside the scope of this PR. - Adds properties to UberSDFParameters and to UberSDF's FragInfo for specifying gradient properties. - Factors out code in `linear_gradient_fill.frag` and `radial_gradient_fill.frag` that samples a texture to get a color for linear and radial gradients. This logic is moved to functions in `gradient.glsl`, to share with `uber_sdf.frag`. - Updates `Canvas::AddRenderSDFEntityToCurrentPass` to fill in the gradient texture and gradient related properties when `paint.color_source` is a gradient supported by UberSDF. This supports only linear and radial gradients. It does not support conical and sweep gradients. According to Gemini, linear and radial gradients make up more than 99% of gradient usage. Supporting conical and sweep gradients would require additional complexity to UberSDF, so it may not be worth it. We can revisit optimizing these other gradients in the future if we see performance related to them in real world use cases. This change by itself speeds up gradient rendering significantly, according to the results below. This can be further improved in a follow up PR by adding caching for gradient textures, similar to TextShadowCache in ContentContext. Addresses flutter#190401. Results from the demo app in flutter#190401, run on my Windows VM. Note that my Windows VM may not necessarily reflect real-world performance, but these numbers still show significant improvements with this PR. Also, my Windows VM reports a refresh rate of 500 hz, so almost all frame render times are considered "over budget". So ignore the "over budget" percentages and just look at the raw timing numbers. before: ``` === Windows linear-gradient comparison === mode=profile speed=1400px/s Solid color | frames=953 fps=238.00 | ui p50/p95=0.669/1.231ms | raster p50/p90/p95/p99/max=4.131/5.154/5.519/6.192/6.830ms | raster_over_budget=949/953 (99.6%) Linear gradient | frames=204 fps=50.75 | ui p50/p95=1.231/1.658ms | raster p50/p90/p95/p99/max=19.094/23.040/23.982/26.812/32.019ms | raster_over_budget=204/204 (100.0%) ================================================ ``` after: ``` === Windows linear-gradient comparison === mode=profile speed=1400px/s Solid color | frames=833 fps=208.00 | ui p50/p95=0.635/1.033ms | raster p50/p90/p95/p99/max=4.752/5.570/5.732/6.134/7.504ms | raster_over_budget=833/833 (100.0%) Linear gradient | frames=687 fps=171.50 | ui p50/p95=1.187/1.804ms | raster p50/p90/p95/p99/max=5.665/7.414/7.925/8.951/12.153ms | raster_over_budget=687/687 (100.0%) ================================================ ``` Skia: ``` === Windows linear-gradient comparison === mode=profile speed=1400px/s Solid color | frames=1375 fps=343.50 | ui p50/p95=0.495/0.845ms | raster p50/p90/p95/p99/max=2.679/3.514/3.851/4.631/5.777ms | raster_over_budget=1160/1375 (84.4%) Linear gradient | frames=1234 fps=308.25 | ui p50/p95=1.087/1.645ms | raster p50/p90/p95/p99/max=1.731/2.251/2.445/2.960/3.903ms | raster_over_budget=319/1234 (25.9%) ================================================ ``` ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 53c1746 commit a61a65d

13 files changed

Lines changed: 182 additions & 508 deletions

File tree

‎engine/src/flutter/impeller/compiler/shader_lib/impeller/gradient.glsl‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -149,36 +149,4 @@ vec3 IPComputeFixedGradientValues(float t, float colors_length) {
149149
return vec3(lower_index, upper_index, scale);
150150
}
151151

152-
/// Samples a linear gradient from a 1D gradient ramp texture.
153-
vec4 IPSampleLinearGradient(sampler2D tex,
154-
vec2 start_point,
155-
vec2 end_point,
156-
vec2 pos,
157-
vec2 half_texel,
158-
float tile_mode,
159-
vec4 decal_border_color) {
160-
vec2 start_to_end = end_point - start_point;
161-
vec2 start_to_position = pos - start_point;
162-
float start_to_end_squared = dot(start_to_end, start_to_end);
163-
164-
float t = start_to_end_squared == 0.0
165-
? 0.0
166-
: dot(start_to_position, start_to_end) / start_to_end_squared;
167-
return IPSampleLinearWithTileMode(tex, vec2(t, 0.5), half_texel, tile_mode,
168-
decal_border_color);
169-
}
170-
171-
/// Samples a radial gradient from a 1D gradient ramp texture.
172-
vec4 IPSampleRadialGradient(sampler2D tex,
173-
vec2 center,
174-
float radius,
175-
vec2 pos,
176-
vec2 half_texel,
177-
float tile_mode,
178-
vec4 decal_border_color) {
179-
float t = radius == 0.0 ? 0.0 : length(pos - center) / radius;
180-
return IPSampleLinearWithTileMode(tex, vec2(t, 0.5), half_texel, tile_mode,
181-
decal_border_color);
182-
}
183-
184152
#endif

‎engine/src/flutter/impeller/compiler/shader_lib/impeller/texture.glsl‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,8 @@ vec4 IPSampleLinearWithTileMode(sampler2D tex,
9898
float x_tile_mode,
9999
float y_tile_mode,
100100
vec4 decal_border_color) {
101-
// Unlike 2D image sampling which uses a half-open interval [0, 1) where 1.0
102-
// is outside the texture boundary, linear sampling uses a closed interval
103-
// [0, 1]. Therefore, decal mode checks the ending coordinate using > 1 rather
104-
// than >= 1.
105-
if (x_tile_mode == kTileModeDecal && (coords.x < 0.0 || coords.x > 1.0) ||
106-
y_tile_mode == kTileModeDecal && (coords.y < 0.0 || coords.y > 1.0)) {
101+
if (x_tile_mode == kTileModeDecal && (coords.x < 0 || coords.x >= 1) ||
102+
y_tile_mode == kTileModeDecal && (coords.y < 0 || coords.y >= 1)) {
107103
return decal_border_color;
108104
}
109105

‎engine/src/flutter/impeller/display_list/canvas.cc‎

Lines changed: 15 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "impeller/entity/contents/content_context.h"
3535
#include "impeller/entity/contents/filters/filter_contents.h"
3636
#include "impeller/entity/contents/framebuffer_blend_contents.h"
37-
#include "impeller/entity/contents/gradient_generator.h"
3837
#include "impeller/entity/contents/shadow_vertices_contents.h"
3938
#include "impeller/entity/contents/solid_color_contents.h"
4039
#include "impeller/entity/contents/solid_rrect_blur_contents.h"
@@ -60,7 +59,6 @@
6059
#include "impeller/entity/save_layer_utils.h"
6160
#include "impeller/geometry/color.h"
6261
#include "impeller/geometry/constants.h"
63-
#include "impeller/geometry/gradient.h"
6462
#include "impeller/geometry/round_superellipse_param.h"
6563
#include "impeller/geometry/rounding_radii.h"
6664
#include "impeller/geometry/rstransform.h"
@@ -268,82 +266,6 @@ static std::pair<Rect, Color> ExpandRectToPixelMinimum(const Rect& rect,
268266
return {expanded.value(), color.WithAlpha(color.alpha * alpha_scaling)};
269267
}
270268

271-
/// @brief Attempts to create UberSDF GradientParameters from a DlColorSource,
272-
/// if supported by UberSDF (e.g. for linear and radial gradients).
273-
///
274-
/// @return The GradientParameters if the color source is a supported gradient,
275-
/// otherwise std::nullopt.
276-
static std::optional<UberSDFParameters::GradientParameters>
277-
CreateUberSDFGradientParameters(const ContentContext& renderer,
278-
const flutter::DlColorSource& color_source,
279-
const std::optional<Matrix>& shape_transform) {
280-
if (!color_source.isGradient()) {
281-
// Color source not supported by UberSDF.
282-
return std::nullopt;
283-
}
284-
285-
UberSDFParameters::GradientParameters gradient;
286-
287-
std::vector<Color> colors;
288-
std::vector<float> stops;
289-
290-
// When a shape transform is applied to transform the SDF shape from local
291-
// space into canvas space, the gradient parameters must be mapped from
292-
// canvas space into local space via the inverse shape transform.
293-
Matrix inverted_shape_transform =
294-
shape_transform.has_value() ? shape_transform->Invert() : Matrix();
295-
296-
if (color_source.type() == flutter::DlColorSourceType::kLinearGradient) {
297-
const auto* linear = color_source.asLinearGradient();
298-
FML_DCHECK(linear);
299-
Matrix gradient_transform = inverted_shape_transform * linear->matrix();
300-
if (!gradient_transform.IsAffine()) {
301-
// Non-affine matrix transformation not supported by UberSDF.
302-
return std::nullopt;
303-
}
304-
Paint::ConvertStops(linear, colors, stops);
305-
gradient.type = UberSDFParameters::GradientParameters::Type::kLinear;
306-
gradient.start = gradient_transform * linear->start_point();
307-
gradient.end = gradient_transform * linear->end_point();
308-
gradient.tile_mode = static_cast<Entity::TileMode>(linear->tile_mode());
309-
} else if (color_source.type() ==
310-
flutter::DlColorSourceType::kRadialGradient) {
311-
const auto* radial = color_source.asRadialGradient();
312-
FML_DCHECK(radial);
313-
Matrix gradient_transform = inverted_shape_transform * radial->matrix();
314-
if (!gradient_transform.IsAffine()) {
315-
// Non-affine matrix transformation not supported by UberSDF.
316-
return std::nullopt;
317-
}
318-
auto scales = gradient_transform.GetScales2D();
319-
if (!scales.has_value() ||
320-
!ScalarNearlyEqual(scales->first, scales->second)) {
321-
// Non-uniform scaling on a radial gradient creates an ellipse, which is
322-
// not supported by UberSDF.
323-
return std::nullopt;
324-
}
325-
Paint::ConvertStops(radial, colors, stops);
326-
gradient.type = UberSDFParameters::GradientParameters::Type::kRadial;
327-
gradient.start = gradient_transform * radial->center();
328-
// For radial gradients, gradient.end.x stores the radius.
329-
gradient.end = Point(radial->radius() * scales->first, 0.0f);
330-
gradient.tile_mode = static_cast<Entity::TileMode>(radial->tile_mode());
331-
} else {
332-
// Gradient type not supported by UberSDF.
333-
return std::nullopt;
334-
}
335-
336-
GradientData gradient_data = CreateGradientBuffer(colors, stops);
337-
std::shared_ptr<Texture> texture =
338-
CreateGradientTexture(gradient_data, renderer.GetContext());
339-
if (!texture) {
340-
return std::nullopt;
341-
}
342-
343-
gradient.texture = std::move(texture);
344-
return gradient;
345-
}
346-
347269
} // namespace
348270

349271
class Canvas::RRectBlurShape : public BlurShape {
@@ -2294,32 +2216,22 @@ void Canvas::AddRenderSDFEntityToCurrentPass(
22942216
entity.SetBlendMode(paint.blend_mode);
22952217

22962218
if (paint.color_source) {
2297-
params.gradient = CreateUberSDFGradientParameters(
2298-
renderer_, *paint.color_source, shape_transform);
2299-
}
2300-
2301-
if (!paint.color_source || params.gradient.has_value()) {
2302-
// No color source (solid paint color), or a supported gradient color
2303-
// source.
2304-
auto geometry = std::make_unique<UberSDFGeometry>(params);
2305-
auto contents = UberSDFContents::Make(params, std::move(geometry));
2306-
const Geometry* geom = contents->GetGeometry();
2307-
AddRenderEntityWithFiltersToCurrentPass(entity, geom, paint, reuse_depth,
2308-
/*override_contents=*/
2309-
std::move(contents));
2310-
} else {
2311-
// Color source not directly supported by UberSDF (e.g. image, runtime
2312-
// effect, or an unsupported gradient type). Render a solid white mask with
2313-
// UberSDF and blend with ColorSourceContents.
2219+
// Since we are going to use BlendMode::kSrcIn to implement the color_source
2220+
// the SDF portion of the blend should just be solid white to get the
2221+
// correct color from the color_source.
23142222
params.color = Color::White();
2315-
auto geometry = std::make_unique<UberSDFGeometry>(params);
2316-
auto uber_sdf_contents = UberSDFContents::Make(params, std::move(geometry));
2317-
const Geometry* geom = uber_sdf_contents->GetGeometry();
2223+
}
2224+
auto geometry = std::make_unique<UberSDFGeometry>(params);
2225+
auto contents = UberSDFContents::Make(params, std::move(geometry));
2226+
const Geometry* geom = contents->GetGeometry();
23182227

2228+
if (paint.color_source) {
2229+
// UberSDF doesn't perform things like gradients so we blend the SDF
2230+
// with the color source.
23192231
std::shared_ptr<ColorSourceContents> color_source_contents =
23202232
paint.CreateContents(renderer_, geom, shape_transform);
23212233
std::shared_ptr<Contents> final_contents = ColorFilterContents::MakeBlend(
2322-
BlendMode::kSrcIn, {FilterInput::Make(std::move(uber_sdf_contents)),
2234+
BlendMode::kSrcIn, {FilterInput::Make(std::move(contents)),
23232235
FilterInput::Make(color_source_contents)});
23242236

23252237
Paint new_paint = paint;
@@ -2328,6 +2240,10 @@ void Canvas::AddRenderSDFEntityToCurrentPass(
23282240
reuse_depth,
23292241
/*override_contents=*/
23302242
std::move(final_contents));
2243+
} else {
2244+
AddRenderEntityWithFiltersToCurrentPass(entity, geom, paint, reuse_depth,
2245+
/*override_contents=*/
2246+
std::move(contents));
23312247
}
23322248
}
23332249

‎engine/src/flutter/impeller/entity/contents/uber_sdf_contents.cc‎

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "impeller/entity/contents/uber_sdf_contents.h"
66

7-
#include "fml/logging.h"
87
#include "impeller/entity/contents/color_source_contents.h"
98
#include "impeller/entity/contents/content_context.h"
109
#include "impeller/entity/contents/pipelines.h"
@@ -47,47 +46,6 @@ Scalar ToShaderStrokeJoin(Join join) {
4746
}
4847
}
4948

50-
Scalar ToShaderColorSourceType(const UberSDFParameters& params) {
51-
if (!params.gradient.has_value()) {
52-
return 0.0f;
53-
}
54-
switch (params.gradient->type) {
55-
case UberSDFParameters::GradientParameters::Type::kLinear:
56-
return 1.0f;
57-
case UberSDFParameters::GradientParameters::Type::kRadial:
58-
return 2.0f;
59-
}
60-
}
61-
62-
struct SamplerBinding {
63-
std::shared_ptr<Texture> texture;
64-
raw_ptr<const Sampler> sampler;
65-
};
66-
67-
/// @brief Populates the gradient uniform fields in `frag_info` and returns
68-
/// the texture and sampler for the gradient.
69-
SamplerBinding SetupGradientParameters(
70-
const UberSDFParameters::GradientParameters& gradient,
71-
const ContentContext& renderer,
72-
FS::FragInfo& frag_info) {
73-
FML_DCHECK(gradient.texture);
74-
frag_info.gradient_start = gradient.start;
75-
frag_info.gradient_end = gradient.end;
76-
frag_info.tile_mode = static_cast<Scalar>(gradient.tile_mode);
77-
auto texture_size = gradient.texture->GetSize();
78-
FML_DCHECK(!texture_size.IsEmpty());
79-
frag_info.half_texel =
80-
Point(0.5f, 0.5f) / Point(texture_size.width, texture_size.height);
81-
82-
SamplerDescriptor sampler_desc;
83-
sampler_desc.min_filter = MinMagFilter::kLinear;
84-
sampler_desc.mag_filter = MinMagFilter::kLinear;
85-
raw_ptr<const Sampler> sampler =
86-
renderer.GetContext()->GetSamplerLibrary()->GetSampler(sampler_desc);
87-
88-
return {gradient.texture, sampler};
89-
}
90-
9149
} // namespace
9250

9351
std::unique_ptr<UberSDFContents> UberSDFContents::Make(
@@ -111,7 +69,6 @@ bool UberSDFContents::Render(const ContentContext& renderer,
11169
VS::FrameInfo frame_info;
11270
FS::FragInfo frag_info;
11371
frag_info.type = ToShaderType(params_.type);
114-
frag_info.color_source_type = ToShaderColorSourceType(params_);
11572
frag_info.color =
11673
params_.color.WithAlpha(params_.color.alpha * GetOpacityFactor());
11774
frag_info.center = params_.center;
@@ -127,16 +84,6 @@ bool UberSDFContents::Render(const ContentContext& renderer,
12784
frag_info.circle_center_right = params_.circle_center_right;
12885
frag_info.radii = params_.radii;
12986

130-
SamplerBinding sampler_binding;
131-
if (params_.gradient) {
132-
sampler_binding =
133-
SetupGradientParameters(params_.gradient.value(), renderer, frag_info);
134-
} else {
135-
sampler_binding.texture = renderer.GetEmptyTexture();
136-
sampler_binding.sampler =
137-
renderer.GetContext()->GetSamplerLibrary()->GetSampler({});
138-
}
139-
14087
auto geometry_result =
14188
GetGeometry()->GetPositionBuffer(renderer, entity, pass);
14289

@@ -149,10 +96,7 @@ bool UberSDFContents::Render(const ContentContext& renderer,
14996
this, GetGeometry(), renderer, entity, pass, pipeline_callback,
15097
frame_info,
15198
/*bind_fragment_callback=*/
152-
[&frag_info, &data_host_buffer,
153-
sampler_binding = std::move(sampler_binding)](RenderPass& pass) {
154-
FS::BindColorSourceSampler(pass, sampler_binding.texture,
155-
sampler_binding.sampler);
99+
[&frag_info, &data_host_buffer](RenderPass& pass) {
156100
FS::BindFragInfo(pass, data_host_buffer.EmplaceUniform(frag_info));
157101
pass.SetCommandLabel("UberSDF");
158102
return true;
@@ -179,18 +123,14 @@ Color UberSDFContents::GetColor() const {
179123

180124
bool UberSDFContents::ApplyColorFilter(
181125
const ColorFilterProc& color_filter_proc) {
182-
if (params_.gradient.has_value()) {
183-
return false;
184-
}
185126
params_.color = color_filter_proc(params_.color);
186127
return true;
187128
}
188129

189130
std::optional<Color> UberSDFContents::AsBackgroundColor(
190131
const Entity& entity,
191132
ISize target_size) const {
192-
if (params_.type != UberSDFParameters::Type::kRect ||
193-
params_.gradient.has_value()) {
133+
if (params_.type != UberSDFParameters::Type::kRect) {
194134
return std::nullopt;
195135
}
196136
const Geometry* geometry = GetGeometry();

‎engine/src/flutter/impeller/entity/contents/uber_sdf_contents_unittests.cc‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,6 @@ TEST(UberSDFContentsTest, ApplyColorFilter) {
2929
EXPECT_EQ(contents->GetColor(), Color::Blue());
3030
}
3131

32-
TEST(UberSDFContentsTest, ApplyColorFilterWithGradient) {
33-
auto rect = Rect::MakeXYWH(100, 100, 200, 200);
34-
auto params =
35-
UberSDFParameters::MakeRect(Color::Red(), rect, /*stroke=*/std::nullopt);
36-
UberSDFParameters::GradientParameters gradient;
37-
gradient.type = UberSDFParameters::GradientParameters::Type::kLinear;
38-
gradient.start = Point(0, 0);
39-
gradient.end = Point(200, 200);
40-
params.gradient = gradient;
41-
42-
auto geometry = std::make_unique<UberSDFGeometry>(params);
43-
auto contents = UberSDFContents::Make(params, std::move(geometry));
44-
45-
// Color filters cannot be applied on CPU to pre-baked gradients in
46-
// UberSDFContents, so ApplyColorFilter must return false to trigger GPU
47-
// filter wrapping.
48-
bool result =
49-
contents->ApplyColorFilter([](Color color) { return Color::Blue(); });
50-
51-
EXPECT_FALSE(result);
52-
// The color should remain unchanged.
53-
EXPECT_EQ(contents->GetColor(), Color::Red());
54-
}
55-
5632
TEST(UberSDFContentsTest, AsBackgroundColor) {
5733
auto rect = Rect::MakeXYWH(-2, -2, 504, 504);
5834
auto params =
@@ -124,29 +100,5 @@ TEST(UberSDFContentsTest, AsBackgroundColorStrokedRect) {
124100
EXPECT_FALSE(bg_color.has_value());
125101
}
126102

127-
TEST(UberSDFContentsTest, AsBackgroundColorGradientReturnsNullopt) {
128-
auto rect = Rect::MakeXYWH(-2, -2, 504, 504);
129-
auto params =
130-
UberSDFParameters::MakeRect(Color::Red(), rect, /*stroke=*/std::nullopt);
131-
132-
UberSDFParameters::GradientParameters gradient;
133-
gradient.type = UberSDFParameters::GradientParameters::Type::kLinear;
134-
gradient.start = Point(0, 0);
135-
gradient.end = Point(500, 500);
136-
gradient.tile_mode = Entity::TileMode::kClamp;
137-
params.gradient = gradient;
138-
139-
auto geometry = std::make_unique<UberSDFGeometry>(params);
140-
auto contents = UberSDFContents::Make(params, std::move(geometry));
141-
142-
Entity entity;
143-
entity.SetTransform(Matrix());
144-
145-
// Even though the rect covers the entire area, a gradient is not a single
146-
// solid background color, so AsBackgroundColor must return nullopt.
147-
auto bg_color = contents->AsBackgroundColor(entity, ISize(500, 500));
148-
EXPECT_FALSE(bg_color.has_value());
149-
}
150-
151103
} // namespace testing
152104
} // namespace impeller

0 commit comments

Comments
 (0)