diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index d5f80eca9d797..ef782f31bb79e 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1185,8 +1185,6 @@ ORIGIN: ../../../flutter/impeller/entity/contents/clip_contents.cc + ../../../fl ORIGIN: ../../../flutter/impeller/entity/contents/clip_contents.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/color_source_contents.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/color_source_contents.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/entity/contents/color_source_text_contents.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/impeller/entity/contents/color_source_text_contents.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/conical_gradient_contents.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/conical_gradient_contents.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/content_context.cc + ../../../flutter/LICENSE @@ -3932,8 +3930,6 @@ FILE: ../../../flutter/impeller/entity/contents/clip_contents.cc FILE: ../../../flutter/impeller/entity/contents/clip_contents.h FILE: ../../../flutter/impeller/entity/contents/color_source_contents.cc FILE: ../../../flutter/impeller/entity/contents/color_source_contents.h -FILE: ../../../flutter/impeller/entity/contents/color_source_text_contents.cc -FILE: ../../../flutter/impeller/entity/contents/color_source_text_contents.h FILE: ../../../flutter/impeller/entity/contents/conical_gradient_contents.cc FILE: ../../../flutter/impeller/entity/contents/conical_gradient_contents.h FILE: ../../../flutter/impeller/entity/contents/content_context.cc diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index cec91e8ed0ee8..9fe792d2097ea 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3031,6 +3031,9 @@ TEST_P(AiksTest, CanDrawPointsWithTextureMap) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +// This currently renders solid blue, as the support for text color sources was +// moved into DLDispatching. Path data requires the SkTextBlobs which are not +// used in impeller::TextFrames. TEST_P(AiksTest, TextForegroundShaderWithTransform) { auto mapping = OpenFixtureAsSkData("Roboto-Regular.ttf"); ASSERT_NE(mapping, nullptr); diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc index 99d03ed5779e9..3929d8fdc3ad6 100644 --- a/impeller/aiks/canvas.cc +++ b/impeller/aiks/canvas.cc @@ -12,7 +12,6 @@ #include "impeller/aiks/paint_pass_delegate.h" #include "impeller/entity/contents/atlas_contents.h" #include "impeller/entity/contents/clip_contents.h" -#include "impeller/entity/contents/color_source_text_contents.h" #include "impeller/entity/contents/solid_rrect_blur_contents.h" #include "impeller/entity/contents/text_contents.h" #include "impeller/entity/contents/texture_contents.h" @@ -543,37 +542,6 @@ void Canvas::DrawTextFrame(const TextFrame& text_frame, auto text_contents = std::make_shared(); text_contents->SetTextFrame(TextFrame(text_frame)); - - if (paint.color_source.GetType() != ColorSource::Type::kColor) { - auto color_text_contents = std::make_shared(); - entity.SetTransformation(GetCurrentTransformation()); - - Entity test; - auto maybe_cvg = text_contents->GetCoverage(test); - FML_CHECK(maybe_cvg.has_value()); - // Covered by FML_CHECK. - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto cvg = maybe_cvg.value(); - color_text_contents->SetTextPosition(cvg.origin + position); - - text_contents->SetOffset(-cvg.origin); - color_text_contents->SetTextContents(std::move(text_contents)); - color_text_contents->SetColorSourceContents( - paint.color_source.GetContents(paint)); - - // TODO(bdero): This mask blur application is a hack. It will always wind up - // doing a gaussian blur that affects the color source itself - // instead of just the mask. The color filter text support - // needs to be reworked in order to interact correctly with - // mask filters. - // https://github.com/flutter/flutter/issues/133297 - entity.SetContents(paint.WithFilters( - paint.WithMaskBlur(std::move(color_text_contents), true))); - - GetCurrentPass().AddEntity(entity); - return; - } - text_contents->SetColor(paint.color); entity.SetTransformation(GetCurrentTransformation() * diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index 60c7b0bb4b85e..09f6417f5ad31 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1111,7 +1111,9 @@ void DlDispatcher::drawDisplayList( void DlDispatcher::drawTextBlob(const sk_sp& blob, SkScalar x, SkScalar y) { - if (paint_.style == Paint::Style::kStroke) { + const auto text_frame = MakeTextFrameFromTextBlobSkia(blob); + if (paint_.style == Paint::Style::kStroke || + paint_.color_source.GetType() != ColorSource::Type::kColor) { auto path = skia_conversions::PathDataFromTextBlob(blob); auto bounds = blob->bounds(); canvas_.Save(); @@ -1121,7 +1123,6 @@ void DlDispatcher::drawTextBlob(const sk_sp& blob, return; } - const auto text_frame = MakeTextFrameFromTextBlobSkia(blob); canvas_.DrawTextFrame(text_frame, // impeller::Point{x, y}, // paint_ // diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index 57113a7b7bbc5..e4c76f9c9ffec 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -151,8 +151,6 @@ impeller_component("entity") { "contents/clip_contents.h", "contents/color_source_contents.cc", "contents/color_source_contents.h", - "contents/color_source_text_contents.cc", - "contents/color_source_text_contents.h", "contents/conical_gradient_contents.cc", "contents/conical_gradient_contents.h", "contents/content_context.cc", diff --git a/impeller/entity/contents/color_source_text_contents.cc b/impeller/entity/contents/color_source_text_contents.cc deleted file mode 100644 index 8032bbb629d55..0000000000000 --- a/impeller/entity/contents/color_source_text_contents.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "impeller/entity/contents/color_source_text_contents.h" - -#include "color_source_text_contents.h" -#include "impeller/entity/contents/content_context.h" -#include "impeller/entity/contents/texture_contents.h" -#include "impeller/renderer/render_pass.h" - -namespace impeller { - -ColorSourceTextContents::ColorSourceTextContents() = default; - -ColorSourceTextContents::~ColorSourceTextContents() = default; - -void ColorSourceTextContents::SetTextContents( - std::shared_ptr text_contents) { - text_contents_ = std::move(text_contents); -} - -void ColorSourceTextContents::SetColorSourceContents( - std::shared_ptr color_source_contents) { - color_source_contents_ = std::move(color_source_contents); -} - -std::optional ColorSourceTextContents::GetCoverage( - const Entity& entity) const { - return text_contents_->GetCoverage(entity); -} - -void ColorSourceTextContents::SetTextPosition(Point position) { - position_ = position; -} - -void ColorSourceTextContents::PopulateGlyphAtlas( - const std::shared_ptr& lazy_glyph_atlas, - Scalar scale) { - text_contents_->PopulateGlyphAtlas(lazy_glyph_atlas, scale); -} - -bool ColorSourceTextContents::Render(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) const { - auto text_bounds = text_contents_->GetTextFrameBounds(); - if (!text_bounds.has_value()) { - return true; - } - - text_contents_->SetColor(Color::Black()); - color_source_contents_->SetGeometry( - Geometry::MakeRect(Rect::MakeSize(text_bounds->size))); - - // offset the color source so it behaves as if it were drawn in the original - // position. - auto effect_transform = - color_source_contents_->GetInverseEffectTransform().Invert().Translate( - -position_); - color_source_contents_->SetEffectTransform(effect_transform); - - auto new_texture = renderer.MakeSubpass( - "Text Color Blending", ISize::Ceil(text_bounds.value().size), - [&](const ContentContext& context, RenderPass& pass) { - Entity sub_entity; - sub_entity.SetContents(text_contents_); - sub_entity.SetBlendMode(BlendMode::kSource); - if (!sub_entity.Render(context, pass)) { - return false; - } - - sub_entity.SetContents(color_source_contents_); - sub_entity.SetBlendMode(BlendMode::kSourceIn); - return sub_entity.Render(context, pass); - }); - if (!new_texture) { - return false; - } - - auto dest_rect = Rect::MakeSize(new_texture->GetSize()).Shift(position_); - - auto texture_contents = TextureContents::MakeRect(dest_rect); - texture_contents->SetTexture(new_texture); - texture_contents->SetSourceRect(Rect::MakeSize(new_texture->GetSize())); - return texture_contents->Render(renderer, entity, pass); -} - -} // namespace impeller diff --git a/impeller/entity/contents/color_source_text_contents.h b/impeller/entity/contents/color_source_text_contents.h deleted file mode 100644 index 18aa1a450ad4a..0000000000000 --- a/impeller/entity/contents/color_source_text_contents.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#pragma once - -#include -#include -#include -#include - -#include "flutter/fml/macros.h" -#include "impeller/entity/contents/color_source_contents.h" -#include "impeller/entity/contents/contents.h" -#include "impeller/entity/contents/text_contents.h" - -namespace impeller { - -class ColorSourceTextContents final : public Contents { - public: - ColorSourceTextContents(); - - ~ColorSourceTextContents(); - - void SetTextContents(std::shared_ptr text_contents); - - void SetColorSourceContents( - std::shared_ptr color_source_contents); - - void SetTextPosition(Point position); - - // |Contents| - std::optional GetCoverage(const Entity& entity) const override; - - // |Contents| - void PopulateGlyphAtlas( - const std::shared_ptr& lazy_glyph_atlas, - Scalar scale) override; - - // |Contents| - bool Render(const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) const override; - - private: - Point position_; - std::shared_ptr text_contents_; - std::shared_ptr color_source_contents_; - - FML_DISALLOW_COPY_AND_ASSIGN(ColorSourceTextContents); -}; - -} // namespace impeller