From c0d3d65c06358a1838e11b86978db115ea6391e0 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sat, 22 Jul 2023 11:47:10 -0700 Subject: [PATCH] [Impeller] Propagate PopulateGlyphAtlas through filters. (flutter/engine#43920) Resolves https://github.com/flutter/flutter/issues/131012. --- .../impeller/entity/contents/filters/filter_contents.cc | 8 ++++++++ .../impeller/entity/contents/filters/filter_contents.h | 5 +++++ .../contents/filters/inputs/contents_filter_input.cc | 6 ++++++ .../contents/filters/inputs/contents_filter_input.h | 5 +++++ .../filters/inputs/filter_contents_filter_input.cc | 6 ++++++ .../filters/inputs/filter_contents_filter_input.h | 5 +++++ .../entity/contents/filters/inputs/filter_input.cc | 4 ++++ .../entity/contents/filters/inputs/filter_input.h | 5 +++++ 8 files changed, 44 insertions(+) diff --git a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc index 7997d0150a..36bb7bfecd 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc @@ -193,6 +193,14 @@ std::optional FilterContents::GetCoverage(const Entity& entity) const { return GetLocalCoverage(entity_with_local_transform); } +void FilterContents::PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) { + for (auto& input : inputs_) { + input->PopulateGlyphAtlas(lazy_glyph_atlas, scale); + } +} + std::optional FilterContents::GetFilterCoverage( const FilterInput::Vector& inputs, const Entity& entity, diff --git a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h index 1a00060c47..270277d1d1 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h +++ b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.h @@ -115,6 +115,11 @@ class FilterContents : public Contents { // |Contents| std::optional GetCoverage(const Entity& entity) const override; + // |Contents| + void PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) override; + // |Contents| std::optional RenderToSnapshot( const ContentContext& renderer, diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc index e990bfc3d2..8fd28f5e14 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.cc @@ -46,4 +46,10 @@ std::optional ContentsFilterInput::GetCoverage( return contents_->GetCoverage(entity); } +void ContentsFilterInput::PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) { + contents_->PopulateGlyphAtlas(lazy_glyph_atlas, scale); +} + } // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h index 288cfe9a81..983161fa72 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/contents_filter_input.h @@ -25,6 +25,11 @@ class ContentsFilterInput final : public FilterInput { // |FilterInput| std::optional GetCoverage(const Entity& entity) const override; + // |FilterInput| + void PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) override; + private: ContentsFilterInput(std::shared_ptr contents, bool msaa_enabled); diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc index 96b5f7e75c..c1960a1640 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc @@ -52,4 +52,10 @@ Matrix FilterContentsFilterInput::GetTransform(const Entity& entity) const { return filter_->GetTransform(entity.GetTransformation()); } +void FilterContentsFilterInput::PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) { + filter_->PopulateGlyphAtlas(lazy_glyph_atlas, scale); +} + } // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h index c546b85fa1..a4daf41066 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_contents_filter_input.h @@ -31,6 +31,11 @@ class FilterContentsFilterInput final : public FilterInput { // |FilterInput| Matrix GetTransform(const Entity& entity) const override; + // |FilterInput| + void PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) override; + private: FilterContentsFilterInput(std::shared_ptr filter); diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.cc index 3a50a44b48..8b9b10daca 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.cc @@ -64,6 +64,10 @@ Matrix FilterInput::GetTransform(const Entity& entity) const { return entity.GetTransformation() * GetLocalTransform(entity); } +void FilterInput::PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale) {} + FilterInput::~FilterInput() = default; } // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h index 37d4209555..019c2acf91 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/filter_input.h @@ -62,6 +62,11 @@ class FilterInput { /// @brief Get the transform of this `FilterInput`. This is equivalent to /// calling `entity.GetTransformation() * GetLocalTransform()`. virtual Matrix GetTransform(const Entity& entity) const; + + /// @see `Contents::PopulateGlyphAtlas` + virtual void PopulateGlyphAtlas( + const std::shared_ptr& lazy_glyph_atlas, + Scalar scale); }; } // namespace impeller