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

Revert "[Impeller] Refactor ColorSource resolution to use explicit factory types" #37673

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,6 @@ FILE: ../../../flutter/impeller/aiks/aiks_playground.h
FILE: ../../../flutter/impeller/aiks/aiks_unittests.cc
FILE: ../../../flutter/impeller/aiks/canvas.cc
FILE: ../../../flutter/impeller/aiks/canvas.h
FILE: ../../../flutter/impeller/aiks/color_source_factory.cc
FILE: ../../../flutter/impeller/aiks/color_source_factory.h
FILE: ../../../flutter/impeller/aiks/image.cc
FILE: ../../../flutter/impeller/aiks/image.h
FILE: ../../../flutter/impeller/aiks/paint.cc
Expand Down Expand Up @@ -1131,10 +1129,6 @@ FILE: ../../../flutter/impeller/compiler/types.cc
FILE: ../../../flutter/impeller/compiler/types.h
FILE: ../../../flutter/impeller/compiler/utilities.cc
FILE: ../../../flutter/impeller/compiler/utilities.h
FILE: ../../../flutter/impeller/display_list/conversion_utilities.cc
FILE: ../../../flutter/impeller/display_list/conversion_utilities.h
FILE: ../../../flutter/impeller/display_list/display_list_color_source_factory.cc
FILE: ../../../flutter/impeller/display_list/display_list_color_source_factory.h
FILE: ../../../flutter/impeller/display_list/display_list_dispatcher.cc
FILE: ../../../flutter/impeller/display_list/display_list_dispatcher.h
FILE: ../../../flutter/impeller/display_list/display_list_image_impeller.cc
Expand Down
2 changes: 0 additions & 2 deletions impeller/aiks/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ impeller_component("aiks") {
"aiks_context.h",
"canvas.cc",
"canvas.h",
"color_source_factory.cc",
"color_source_factory.h",
"image.cc",
"image.h",
"paint.cc",
Expand Down
425 changes: 191 additions & 234 deletions impeller/aiks/aiks_unittests.cc

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ void Canvas::DrawPaint(const Paint& paint) {
bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
Scalar corner_radius,
const Paint& paint) {
if (!paint.color_source || paint.style != Paint::Style::kFill) {
if (paint.color_source == nullptr ||
paint.color_source_type != Paint::ColorSourceType::kColor ||
paint.style != Paint::Style::kFill) {
return false;
}

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

void Canvas::DrawVertices(const Vertices& vertices,
BlendMode blend_mode,
const Paint& paint) {
Paint paint) {
auto geometry = Geometry::MakeVertices(vertices);

Entity entity;
entity.SetTransformation(GetCurrentTransformation());
entity.SetStencilDepth(GetStencilDepth());
entity.SetBlendMode(paint.blend_mode);

if (paint.color_source) {
auto contents = paint.color_source->MakeContents();
if (paint.color_source.has_value()) {
auto& source = paint.color_source.value();
auto contents = source();
contents->SetGeometry(std::move(geometry));
contents->SetAlpha(paint.color.alpha);
entity.SetContents(paint.WithFilters(std::move(contents), true));
Expand Down
2 changes: 1 addition & 1 deletion impeller/aiks/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Canvas {

void DrawVertices(const Vertices& vertices,
BlendMode blend_mode,
const Paint& paint);
Paint paint);

void DrawAtlas(const std::shared_ptr<Image>& atlas,
std::vector<Matrix> transforms,
Expand Down
11 changes: 0 additions & 11 deletions impeller/aiks/color_source_factory.cc

This file was deleted.

32 changes: 0 additions & 32 deletions impeller/aiks/color_source_factory.h

This file was deleted.

5 changes: 3 additions & 2 deletions impeller/aiks/paint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ std::shared_ptr<Contents> Paint::CreateContentsForEntity(const Path& path,

std::shared_ptr<Contents> Paint::CreateContentsForGeometry(
std::unique_ptr<Geometry> geometry) const {
if (color_source) {
auto contents = color_source->MakeContents();
if (color_source.has_value()) {
auto& source = color_source.value();
auto contents = source();
contents->SetGeometry(std::move(geometry));
contents->SetAlpha(color.alpha);
return contents;
Expand Down
17 changes: 14 additions & 3 deletions impeller/aiks/paint.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <memory>

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

enum class Style {
kFill,
kStroke,
};

enum class ColorSourceType {
kColor,
kImage,
kLinearGradient,
kRadialGradient,
kConicalGradient,
kSweepGradient,
kRuntimeEffect,
};

struct MaskBlurDescriptor {
FilterContents::BlurStyle style;
Sigma sigma;
Expand All @@ -46,9 +56,10 @@ struct Paint {
const Matrix& effect_matrix) const;
};

std::shared_ptr<ColorSourceFactory> color_source;

Color color = Color::Black();
std::optional<ColorSourceProc> color_source;
ColorSourceType color_source_type = ColorSourceType::kColor;

Scalar stroke_width = 0.0;
Cap stroke_cap = Cap::kButt;
Join stroke_join = Join::kMiter;
Expand Down
4 changes: 0 additions & 4 deletions impeller/display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import("//flutter/impeller/tools/impeller.gni")

impeller_component("display_list") {
sources = [
"conversion_utilities.cc",
"conversion_utilities.h",
"display_list_color_source_factory.cc",
"display_list_color_source_factory.h",
"display_list_dispatcher.cc",
"display_list_dispatcher.h",
"display_list_image_impeller.cc",
Expand Down
179 changes: 0 additions & 179 deletions impeller/display_list/conversion_utilities.cc

This file was deleted.

Loading