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

Commit 446e16b

Browse files
author
Jonah Williams
authored
[Impeller] Simplify color source + text with new Skia API. (#45090)
The original implementation of arbitrary color source + text was quite complicated due to the fact that I had to use blending to emulate this functionality. Now that we can get paths from a given text data, I can instead make non solid color color sources and text just use the regular geometry + color source pipelines. Fixes flutter/flutter#132928 Fixes flutter/flutter#132972
1 parent 14d38f8 commit 446e16b

File tree

7 files changed

+6
-181
lines changed

7 files changed

+6
-181
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,6 @@ ORIGIN: ../../../flutter/impeller/entity/contents/clip_contents.cc + ../../../fl
11851185
ORIGIN: ../../../flutter/impeller/entity/contents/clip_contents.h + ../../../flutter/LICENSE
11861186
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_contents.cc + ../../../flutter/LICENSE
11871187
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_contents.h + ../../../flutter/LICENSE
1188-
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_text_contents.cc + ../../../flutter/LICENSE
1189-
ORIGIN: ../../../flutter/impeller/entity/contents/color_source_text_contents.h + ../../../flutter/LICENSE
11901188
ORIGIN: ../../../flutter/impeller/entity/contents/conical_gradient_contents.cc + ../../../flutter/LICENSE
11911189
ORIGIN: ../../../flutter/impeller/entity/contents/conical_gradient_contents.h + ../../../flutter/LICENSE
11921190
ORIGIN: ../../../flutter/impeller/entity/contents/content_context.cc + ../../../flutter/LICENSE
@@ -3932,8 +3930,6 @@ FILE: ../../../flutter/impeller/entity/contents/clip_contents.cc
39323930
FILE: ../../../flutter/impeller/entity/contents/clip_contents.h
39333931
FILE: ../../../flutter/impeller/entity/contents/color_source_contents.cc
39343932
FILE: ../../../flutter/impeller/entity/contents/color_source_contents.h
3935-
FILE: ../../../flutter/impeller/entity/contents/color_source_text_contents.cc
3936-
FILE: ../../../flutter/impeller/entity/contents/color_source_text_contents.h
39373933
FILE: ../../../flutter/impeller/entity/contents/conical_gradient_contents.cc
39383934
FILE: ../../../flutter/impeller/entity/contents/conical_gradient_contents.h
39393935
FILE: ../../../flutter/impeller/entity/contents/content_context.cc

impeller/aiks/aiks_unittests.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,9 @@ TEST_P(AiksTest, CanDrawPointsWithTextureMap) {
30313031
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
30323032
}
30333033

3034+
// This currently renders solid blue, as the support for text color sources was
3035+
// moved into DLDispatching. Path data requires the SkTextBlobs which are not
3036+
// used in impeller::TextFrames.
30343037
TEST_P(AiksTest, TextForegroundShaderWithTransform) {
30353038
auto mapping = OpenFixtureAsSkData("Roboto-Regular.ttf");
30363039
ASSERT_NE(mapping, nullptr);

impeller/aiks/canvas.cc

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "impeller/aiks/paint_pass_delegate.h"
1313
#include "impeller/entity/contents/atlas_contents.h"
1414
#include "impeller/entity/contents/clip_contents.h"
15-
#include "impeller/entity/contents/color_source_text_contents.h"
1615
#include "impeller/entity/contents/solid_rrect_blur_contents.h"
1716
#include "impeller/entity/contents/text_contents.h"
1817
#include "impeller/entity/contents/texture_contents.h"
@@ -543,37 +542,6 @@ void Canvas::DrawTextFrame(const TextFrame& text_frame,
543542

544543
auto text_contents = std::make_shared<TextContents>();
545544
text_contents->SetTextFrame(TextFrame(text_frame));
546-
547-
if (paint.color_source.GetType() != ColorSource::Type::kColor) {
548-
auto color_text_contents = std::make_shared<ColorSourceTextContents>();
549-
entity.SetTransformation(GetCurrentTransformation());
550-
551-
Entity test;
552-
auto maybe_cvg = text_contents->GetCoverage(test);
553-
FML_CHECK(maybe_cvg.has_value());
554-
// Covered by FML_CHECK.
555-
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
556-
auto cvg = maybe_cvg.value();
557-
color_text_contents->SetTextPosition(cvg.origin + position);
558-
559-
text_contents->SetOffset(-cvg.origin);
560-
color_text_contents->SetTextContents(std::move(text_contents));
561-
color_text_contents->SetColorSourceContents(
562-
paint.color_source.GetContents(paint));
563-
564-
// TODO(bdero): This mask blur application is a hack. It will always wind up
565-
// doing a gaussian blur that affects the color source itself
566-
// instead of just the mask. The color filter text support
567-
// needs to be reworked in order to interact correctly with
568-
// mask filters.
569-
// https://github.com/flutter/flutter/issues/133297
570-
entity.SetContents(paint.WithFilters(
571-
paint.WithMaskBlur(std::move(color_text_contents), true)));
572-
573-
GetCurrentPass().AddEntity(entity);
574-
return;
575-
}
576-
577545
text_contents->SetColor(paint.color);
578546

579547
entity.SetTransformation(GetCurrentTransformation() *

impeller/display_list/dl_dispatcher.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,9 @@ void DlDispatcher::drawDisplayList(
11111111
void DlDispatcher::drawTextBlob(const sk_sp<SkTextBlob>& blob,
11121112
SkScalar x,
11131113
SkScalar y) {
1114-
if (paint_.style == Paint::Style::kStroke) {
1114+
const auto text_frame = MakeTextFrameFromTextBlobSkia(blob);
1115+
if (paint_.style == Paint::Style::kStroke ||
1116+
paint_.color_source.GetType() != ColorSource::Type::kColor) {
11151117
auto path = skia_conversions::PathDataFromTextBlob(blob);
11161118
auto bounds = blob->bounds();
11171119
canvas_.Save();
@@ -1121,7 +1123,6 @@ void DlDispatcher::drawTextBlob(const sk_sp<SkTextBlob>& blob,
11211123
return;
11221124
}
11231125

1124-
const auto text_frame = MakeTextFrameFromTextBlobSkia(blob);
11251126
canvas_.DrawTextFrame(text_frame, //
11261127
impeller::Point{x, y}, //
11271128
paint_ //

impeller/entity/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ impeller_component("entity") {
151151
"contents/clip_contents.h",
152152
"contents/color_source_contents.cc",
153153
"contents/color_source_contents.h",
154-
"contents/color_source_text_contents.cc",
155-
"contents/color_source_text_contents.h",
156154
"contents/conical_gradient_contents.cc",
157155
"contents/conical_gradient_contents.h",
158156
"contents/content_context.cc",

impeller/entity/contents/color_source_text_contents.cc

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

impeller/entity/contents/color_source_text_contents.h

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

0 commit comments

Comments
 (0)