Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c6f40e1

Browse files
authored
Revert "[Impeller] Reland: Refactor color source resolution to use explicit factory types (#37677)"
This reverts commit 3c83b27.
1 parent 487ee66 commit c6f40e1

16 files changed

+579
-1015
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,6 @@ FILE: ../../../flutter/impeller/aiks/aiks_playground.h
10301030
FILE: ../../../flutter/impeller/aiks/aiks_unittests.cc
10311031
FILE: ../../../flutter/impeller/aiks/canvas.cc
10321032
FILE: ../../../flutter/impeller/aiks/canvas.h
1033-
FILE: ../../../flutter/impeller/aiks/color_source_factory.cc
1034-
FILE: ../../../flutter/impeller/aiks/color_source_factory.h
10351033
FILE: ../../../flutter/impeller/aiks/image.cc
10361034
FILE: ../../../flutter/impeller/aiks/image.h
10371035
FILE: ../../../flutter/impeller/aiks/paint.cc
@@ -1131,10 +1129,6 @@ FILE: ../../../flutter/impeller/compiler/types.cc
11311129
FILE: ../../../flutter/impeller/compiler/types.h
11321130
FILE: ../../../flutter/impeller/compiler/utilities.cc
11331131
FILE: ../../../flutter/impeller/compiler/utilities.h
1134-
FILE: ../../../flutter/impeller/display_list/conversion_utilities.cc
1135-
FILE: ../../../flutter/impeller/display_list/conversion_utilities.h
1136-
FILE: ../../../flutter/impeller/display_list/display_list_color_source_factory.cc
1137-
FILE: ../../../flutter/impeller/display_list/display_list_color_source_factory.h
11381132
FILE: ../../../flutter/impeller/display_list/display_list_dispatcher.cc
11391133
FILE: ../../../flutter/impeller/display_list/display_list_dispatcher.h
11401134
FILE: ../../../flutter/impeller/display_list/display_list_image_impeller.cc

impeller/aiks/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ impeller_component("aiks") {
1010
"aiks_context.h",
1111
"canvas.cc",
1212
"canvas.h",
13-
"color_source_factory.cc",
14-
"color_source_factory.h",
1513
"image.cc",
1614
"image.h",
1715
"paint.cc",

impeller/aiks/aiks_unittests.cc

Lines changed: 191 additions & 234 deletions
Large diffs are not rendered by default.

impeller/aiks/canvas.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ void Canvas::DrawPaint(const Paint& paint) {
160160
bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
161161
Scalar corner_radius,
162162
const Paint& paint) {
163-
if (!paint.color_source || paint.style != Paint::Style::kFill) {
163+
if (paint.color_source == nullptr ||
164+
paint.color_source_type != Paint::ColorSourceType::kColor ||
165+
paint.style != Paint::Style::kFill) {
164166
return false;
165167
}
166168

@@ -373,16 +375,17 @@ void Canvas::DrawTextFrame(const TextFrame& text_frame,
373375

374376
void Canvas::DrawVertices(const Vertices& vertices,
375377
BlendMode blend_mode,
376-
const Paint& paint) {
378+
Paint paint) {
377379
auto geometry = Geometry::MakeVertices(vertices);
378380

379381
Entity entity;
380382
entity.SetTransformation(GetCurrentTransformation());
381383
entity.SetStencilDepth(GetStencilDepth());
382384
entity.SetBlendMode(paint.blend_mode);
383385

384-
if (paint.color_source) {
385-
auto contents = paint.color_source->MakeContents();
386+
if (paint.color_source.has_value()) {
387+
auto& source = paint.color_source.value();
388+
auto contents = source();
386389
contents->SetGeometry(std::move(geometry));
387390
contents->SetAlpha(paint.color.alpha);
388391
entity.SetContents(paint.WithFilters(std::move(contents), true));

impeller/aiks/canvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Canvas {
9999

100100
void DrawVertices(const Vertices& vertices,
101101
BlendMode blend_mode,
102-
const Paint& paint);
102+
Paint paint);
103103

104104
void DrawAtlas(const std::shared_ptr<Image>& atlas,
105105
std::vector<Matrix> transforms,

impeller/aiks/color_source_factory.cc

Lines changed: 0 additions & 11 deletions
This file was deleted.

impeller/aiks/color_source_factory.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

impeller/aiks/paint.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ std::shared_ptr<Contents> Paint::CreateContentsForEntity(const Path& path,
2727

2828
std::shared_ptr<Contents> Paint::CreateContentsForGeometry(
2929
std::unique_ptr<Geometry> geometry) const {
30-
if (color_source) {
31-
auto contents = color_source->MakeContents();
30+
if (color_source.has_value()) {
31+
auto& source = color_source.value();
32+
auto contents = source();
3233
contents->SetGeometry(std::move(geometry));
3334
contents->SetAlpha(color.alpha);
3435
return contents;

impeller/aiks/paint.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <memory>
88

99
#include "flutter/fml/macros.h"
10-
#include "impeller/aiks/color_source_factory.h"
1110
#include "impeller/entity/contents/contents.h"
1211
#include "impeller/entity/contents/filters/color_filter_contents.h"
1312
#include "impeller/entity/contents/filters/filter_contents.h"
@@ -30,12 +29,23 @@ struct Paint {
3029
FilterInput::Ref,
3130
bool is_solid_color,
3231
const Matrix& effect_transform)>;
32+
using ColorSourceProc = std::function<std::shared_ptr<ColorSourceContents>()>;
3333

3434
enum class Style {
3535
kFill,
3636
kStroke,
3737
};
3838

39+
enum class ColorSourceType {
40+
kColor,
41+
kImage,
42+
kLinearGradient,
43+
kRadialGradient,
44+
kConicalGradient,
45+
kSweepGradient,
46+
kRuntimeEffect,
47+
};
48+
3949
struct MaskBlurDescriptor {
4050
FilterContents::BlurStyle style;
4151
Sigma sigma;
@@ -46,9 +56,10 @@ struct Paint {
4656
const Matrix& effect_matrix) const;
4757
};
4858

49-
std::shared_ptr<ColorSourceFactory> color_source;
50-
5159
Color color = Color::Black();
60+
std::optional<ColorSourceProc> color_source;
61+
ColorSourceType color_source_type = ColorSourceType::kColor;
62+
5263
Scalar stroke_width = 0.0;
5364
Cap stroke_cap = Cap::kButt;
5465
Join stroke_join = Join::kMiter;

impeller/display_list/BUILD.gn

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import("//flutter/impeller/tools/impeller.gni")
66

77
impeller_component("display_list") {
88
sources = [
9-
"conversion_utilities.cc",
10-
"conversion_utilities.h",
11-
"display_list_color_source_factory.cc",
12-
"display_list_color_source_factory.h",
139
"display_list_dispatcher.cc",
1410
"display_list_dispatcher.h",
1511
"display_list_image_impeller.cc",

impeller/display_list/conversion_utilities.cc

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)