From 8edf328c62fc2f15e049904ff38d6b887dc6b92b Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 12 Sep 2024 20:31:33 -0700 Subject: [PATCH 1/9] ++ --- impeller/display_list/dl_dispatcher.cc | 43 ++++++++++++++++--- impeller/display_list/dl_dispatcher.h | 7 ++- shell/common/snapshot_controller_impeller.cc | 7 ++- shell/gpu/gpu_surface_gl_impeller.cc | 5 ++- shell/gpu/gpu_surface_metal_impeller.mm | 12 ++++-- shell/gpu/gpu_surface_vulkan_impeller.cc | 5 ++- .../embedder/embedder_external_view.cc | 7 ++- 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index 7788ae3a593e8..676c6108001e3 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1362,22 +1362,40 @@ Canvas& ExperimentalDlDispatcher::GetCanvas() { //// Text Frame Dispatcher TextFrameDispatcher::TextFrameDispatcher(const ContentContext& renderer, - const Matrix& initial_matrix) - : renderer_(renderer), matrix_(initial_matrix) {} + const Matrix& initial_matrix, + const Rect cull_rect) + : renderer_(renderer), matrix_(initial_matrix) { + cull_rect_state_.push_back(cull_rect); +} void TextFrameDispatcher::save() { stack_.emplace_back(matrix_); + cull_rect_state_.push_back(cull_rect_state_.back()); } void TextFrameDispatcher::saveLayer(const DlRect& bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter* backdrop) { save(); + + // This dispatcher does not track enough state to accurately compute + // cull rects with image filters. + if (paint_.image_filter) { + cull_rect_state_.push_back(Rect::MakeMaximum()); + } else { + auto new_cull_rect = GetCurrentLocalCullingBounds().Intersection(bounds); + if (new_cull_rect.has_value()) { + cull_rect_state_.push_back(new_cull_rect.value()); + } else { + cull_rect_state_.push_back(Rect::MakeLTRB(0, 0, 0, 0)); + } + } } void TextFrameDispatcher::restore() { matrix_ = stack_.back(); stack_.pop_back(); + cull_rect_state_.pop_back(); } void TextFrameDispatcher::translate(DlScalar tx, DlScalar ty) { @@ -1453,6 +1471,15 @@ void TextFrameDispatcher::drawTextFrame( ); } +const Rect TextFrameDispatcher::GetCurrentLocalCullingBounds() const { + auto cull_rect = cull_rect_state_.back(); + if (!cull_rect.IsEmpty() && !cull_rect.IsMaximum()) { + Matrix inverse = matrix_.Invert(); + cull_rect = cull_rect.TransformBounds(inverse); + } + return cull_rect; +} + void TextFrameDispatcher::drawDisplayList( const sk_sp display_list, DlScalar opacity) { @@ -1460,7 +1487,13 @@ void TextFrameDispatcher::drawDisplayList( save(); Paint old_paint = paint_; paint_ = Paint{}; - display_list->Dispatch(*this); + + auto cull_rect = IRect::RoundOut(GetCurrentLocalCullingBounds()); + display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), // + cull_rect.GetTop(), // + cull_rect.GetRight(), // + cull_rect.GetBottom() // + )); restore(); paint_ = old_paint; FML_DCHECK(stack_depth == stack_.size()); @@ -1547,8 +1580,8 @@ std::shared_ptr DisplayListToTexture( } SkIRect sk_cull_rect = SkIRect::MakeWH(size.width, size.height); - impeller::TextFrameDispatcher collector(context.GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector( + context.GetContentContext(), impeller::Matrix(), Rect::MakeSize(size)); display_list->Dispatch(collector, sk_cull_rect); impeller::ExperimentalDlDispatcher impeller_dispatcher( context.GetContentContext(), target, diff --git a/impeller/display_list/dl_dispatcher.h b/impeller/display_list/dl_dispatcher.h index 4bda27218b9a9..7842f32198368 100644 --- a/impeller/display_list/dl_dispatcher.h +++ b/impeller/display_list/dl_dispatcher.h @@ -15,6 +15,7 @@ #include "impeller/aiks/paint.h" #include "impeller/entity/contents/content_context.h" #include "impeller/geometry/color.h" +#include "impeller/geometry/rect.h" namespace impeller { @@ -326,7 +327,8 @@ class TextFrameDispatcher : public flutter::IgnoreAttributeDispatchHelper, public flutter::IgnoreDrawDispatchHelper { public: TextFrameDispatcher(const ContentContext& renderer, - const Matrix& initial_matrix); + const Matrix& initial_matrix, + const Rect cull_rect); void save() override; void saveLayer(const DlRect& bounds, @@ -383,9 +385,12 @@ class TextFrameDispatcher : public flutter::IgnoreAttributeDispatchHelper, void setStrokeJoin(flutter::DlStrokeJoin join) override; private: + const Rect GetCurrentLocalCullingBounds() const; + const ContentContext& renderer_; Matrix matrix_; std::vector stack_; + std::vector cull_rect_state_; Paint paint_; }; diff --git a/shell/common/snapshot_controller_impeller.cc b/shell/common/snapshot_controller_impeller.cc index 2b06c04e4d113..89583f9eafcc0 100644 --- a/shell/common/snapshot_controller_impeller.cc +++ b/shell/common/snapshot_controller_impeller.cc @@ -73,8 +73,11 @@ sk_sp DoMakeRasterSnapshot( ); } - impeller::TextFrameDispatcher collector(context->GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector( + context->GetContentContext(), // + impeller::Matrix(), // + impeller::Rect::MakeSize(render_target_size) // + ); display_list->Dispatch(collector, SkIRect::MakeSize(size)); impeller::ExperimentalDlDispatcher impeller_dispatcher( context->GetContentContext(), target, diff --git a/shell/gpu/gpu_surface_gl_impeller.cc b/shell/gpu/gpu_surface_gl_impeller.cc index cc4d74b3cfbad..7542d040fb946 100644 --- a/shell/gpu/gpu_surface_gl_impeller.cc +++ b/shell/gpu/gpu_surface_gl_impeller.cc @@ -120,8 +120,9 @@ std::unique_ptr GPUSurfaceGLImpeller::AcquireFrame( #if EXPERIMENTAL_CANVAS auto skia_cull_rect = SkIRect::MakeWH(cull_rect.width, cull_rect.height); - impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector( + aiks_context->GetContentContext(), impeller::Matrix(), + impeller::Rect::MakeSize(cull_rect)); display_list->Dispatch(collector, skia_cull_rect); impeller::ExperimentalDlDispatcher impeller_dispatcher( diff --git a/shell/gpu/gpu_surface_metal_impeller.mm b/shell/gpu/gpu_surface_metal_impeller.mm index 6e8c43763e092..a842e50a7ebc8 100644 --- a/shell/gpu/gpu_surface_metal_impeller.mm +++ b/shell/gpu/gpu_surface_metal_impeller.mm @@ -171,8 +171,10 @@ surface->SetFrameBoundary(surface_frame.submit_info().frame_boundary); #if EXPERIMENTAL_CANVAS - impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), // + impeller::Matrix(), // + impeller::Rect::MakeSize(cull_rect.GetSize()) // + ); display_list->Dispatch(collector, sk_cull_rect); impeller::ExperimentalDlDispatcher impeller_dispatcher( @@ -299,8 +301,10 @@ impeller::IRect cull_rect = surface->coverage(); SkIRect sk_cull_rect = SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight()); #if EXPERIMENTAL_CANVAS - impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), // + impeller::Matrix(), // + impeller::Rect::MakeSize(cull_rect.GetSize()) // + ); display_list->Dispatch(collector, sk_cull_rect); impeller::RenderTarget render_target = surface->GetTargetRenderPassDescriptor(); impeller::ExperimentalDlDispatcher impeller_dispatcher( diff --git a/shell/gpu/gpu_surface_vulkan_impeller.cc b/shell/gpu/gpu_surface_vulkan_impeller.cc index 263c3db64bf7b..d04937edc6b81 100644 --- a/shell/gpu/gpu_surface_vulkan_impeller.cc +++ b/shell/gpu/gpu_surface_vulkan_impeller.cc @@ -81,8 +81,9 @@ std::unique_ptr GPUSurfaceVulkanImpeller::AcquireFrame( } #if EXPERIMENTAL_CANVAS - impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector( + aiks_context->GetContentContext(), impeller::Matrix(), + impeller::Rect::MakeSize(cull_rect)); display_list->Dispatch(collector, SkIRect::MakeWH(cull_rect.width, cull_rect.height)); impeller::ExperimentalDlDispatcher impeller_dispatcher( diff --git a/shell/platform/embedder/embedder_external_view.cc b/shell/platform/embedder/embedder_external_view.cc index 8aa524359d08b..f92445dde139e 100644 --- a/shell/platform/embedder/embedder_external_view.cc +++ b/shell/platform/embedder/embedder_external_view.cc @@ -135,8 +135,11 @@ bool EmbedderExternalView::Render(const EmbedderRenderTarget& render_target, SkIRect sk_cull_rect = SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight()); - impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(), - impeller::Matrix()); + impeller::TextFrameDispatcher collector( + aiks_context->GetContentContext(), // + impeller::Matrix(), // + impeller::Rect::MakeSize(cull_rect.GetSize()) // + ); impeller::ExperimentalDlDispatcher impeller_dispatcher( aiks_context->GetContentContext(), *impeller_target, From 2a1e88043848a3ca5f7e9d6378212a935b1d8505 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 12 Sep 2024 21:39:27 -0700 Subject: [PATCH 2/9] update dl playground. --- impeller/aiks/aiks_playground.cc | 6 +++++- impeller/display_list/dl_playground.cc | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/impeller/aiks/aiks_playground.cc b/impeller/aiks/aiks_playground.cc index 882e0d66a99c2..b95ef8630880c 100644 --- a/impeller/aiks/aiks_playground.cc +++ b/impeller/aiks/aiks_playground.cc @@ -90,7 +90,11 @@ bool AiksPlayground::OpenPlaygroundHere( [&renderer, &callback](RenderTarget& render_target) -> bool { #if EXPERIMENTAL_CANVAS auto display_list = callback(); - TextFrameDispatcher collector(renderer.GetContentContext(), Matrix()); + TextFrameDispatcher collector( + renderer.GetContentContext(), // + Matrix(), // + Rect::MakeMaximum() // + ); display_list->Dispatch(collector); ExperimentalDlDispatcher impeller_dispatcher( diff --git a/impeller/display_list/dl_playground.cc b/impeller/display_list/dl_playground.cc index cf74a095465cd..ee3ee438028ce 100644 --- a/impeller/display_list/dl_playground.cc +++ b/impeller/display_list/dl_playground.cc @@ -49,7 +49,10 @@ bool DlPlayground::OpenPlaygroundHere(DisplayListPlaygroundCallback callback) { auto list = callback(); #if EXPERIMENTAL_CANVAS - TextFrameDispatcher collector(context.GetContentContext(), Matrix()); + TextFrameDispatcher collector(context.GetContentContext(), // + Matrix(), // + Rect::MakeMaximum() // + ); list->Dispatch(collector); ExperimentalDlDispatcher impeller_dispatcher( From a1666767fc80bc546666ffe769e69a8bfc5c10d7 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 12 Sep 2024 21:41:30 -0700 Subject: [PATCH 3/9] ++ --- impeller/aiks/aiks_playground.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/impeller/aiks/aiks_playground.cc b/impeller/aiks/aiks_playground.cc index b95ef8630880c..6ad968a27646f 100644 --- a/impeller/aiks/aiks_playground.cc +++ b/impeller/aiks/aiks_playground.cc @@ -90,10 +90,9 @@ bool AiksPlayground::OpenPlaygroundHere( [&renderer, &callback](RenderTarget& render_target) -> bool { #if EXPERIMENTAL_CANVAS auto display_list = callback(); - TextFrameDispatcher collector( - renderer.GetContentContext(), // - Matrix(), // - Rect::MakeMaximum() // + TextFrameDispatcher collector(renderer.GetContentContext(), // + Matrix(), // + Rect::MakeMaximum() // ); display_list->Dispatch(collector); From 3c3cbc7f6340d0b3a08956b5985950d5698209dc Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 12 Sep 2024 21:42:41 -0700 Subject: [PATCH 4/9] ++ --- impeller/display_list/dl_dispatcher.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index 676c6108001e3..cb1c44afbd1ed 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1381,7 +1381,7 @@ void TextFrameDispatcher::saveLayer(const DlRect& bounds, // This dispatcher does not track enough state to accurately compute // cull rects with image filters. if (paint_.image_filter) { - cull_rect_state_.push_back(Rect::MakeMaximum()); + cull_rect_state_.push_back(bounds); } else { auto new_cull_rect = GetCurrentLocalCullingBounds().Intersection(bounds); if (new_cull_rect.has_value()) { From d1e0b8a6e4e5c0352686b5dd703ef27116691d5d Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 23 Sep 2024 16:28:49 -0700 Subject: [PATCH 5/9] fix unbalanced save.' g --- impeller/display_list/dl_dispatcher.cc | 36 +++++++++++++++---- impeller/display_list/dl_dispatcher.h | 9 +++++ .../backends/skia/typographer_context_skia.cc | 1 + 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index cb1c44afbd1ed..3d6b7359a7e34 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1368,20 +1368,30 @@ TextFrameDispatcher::TextFrameDispatcher(const ContentContext& renderer, cull_rect_state_.push_back(cull_rect); } -void TextFrameDispatcher::save() { +TextFrameDispatcher::~TextFrameDispatcher() { + FML_DCHECK(cull_rect_state_.size() == 1); +} + +void TextFrameDispatcher::Save(bool push_cull_rect) { stack_.emplace_back(matrix_); - cull_rect_state_.push_back(cull_rect_state_.back()); + if (push_cull_rect) { + cull_rect_state_.push_back(cull_rect_state_.back()); + } +} + +void TextFrameDispatcher::save() { + Save(/*push_cull_rect=*/true); } void TextFrameDispatcher::saveLayer(const DlRect& bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter* backdrop) { - save(); + Save(/*push_cull_rect=*/false); // This dispatcher does not track enough state to accurately compute // cull rects with image filters. - if (paint_.image_filter) { - cull_rect_state_.push_back(bounds); + if (has_image_filter_) { + cull_rect_state_.push_back(Rect::MakeMaximum()); } else { auto new_cull_rect = GetCurrentLocalCullingBounds().Intersection(bounds); if (new_cull_rect.has_value()) { @@ -1484,11 +1494,13 @@ void TextFrameDispatcher::drawDisplayList( const sk_sp display_list, DlScalar opacity) { [[maybe_unused]] size_t stack_depth = stack_.size(); - save(); + Save(/*push_cull_rect=*/true); Paint old_paint = paint_; paint_ = Paint{}; + bool old_has_image_filter = has_image_filter_; - auto cull_rect = IRect::RoundOut(GetCurrentLocalCullingBounds()); + has_image_filter_ = false; + IRect cull_rect = IRect::RoundOut(GetCurrentLocalCullingBounds()); display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), // cull_rect.GetTop(), // cull_rect.GetRight(), // @@ -1496,6 +1508,7 @@ void TextFrameDispatcher::drawDisplayList( )); restore(); paint_ = old_paint; + has_image_filter_ = old_has_image_filter; FML_DCHECK(stack_depth == stack_.size()); } @@ -1549,6 +1562,15 @@ void TextFrameDispatcher::setStrokeJoin(flutter::DlStrokeJoin join) { } } +// |flutter::DlOpReceiver| +void TextFrameDispatcher::setImageFilter(const flutter::DlImageFilter* filter) { + if (filter == nullptr) { + has_image_filter_ = false; + } else { + has_image_filter_ = true; + } +} + std::shared_ptr DisplayListToTexture( const sk_sp& display_list, ISize size, diff --git a/impeller/display_list/dl_dispatcher.h b/impeller/display_list/dl_dispatcher.h index 7842f32198368..a11b13f37439c 100644 --- a/impeller/display_list/dl_dispatcher.h +++ b/impeller/display_list/dl_dispatcher.h @@ -329,6 +329,9 @@ class TextFrameDispatcher : public flutter::IgnoreAttributeDispatchHelper, TextFrameDispatcher(const ContentContext& renderer, const Matrix& initial_matrix, const Rect cull_rect); + + ~TextFrameDispatcher(); + void save() override; void saveLayer(const DlRect& bounds, @@ -384,13 +387,19 @@ class TextFrameDispatcher : public flutter::IgnoreAttributeDispatchHelper, // |flutter::DlOpReceiver| void setStrokeJoin(flutter::DlStrokeJoin join) override; + // |flutter::DlOpReceiver| + void setImageFilter(const flutter::DlImageFilter* filter) override; + private: const Rect GetCurrentLocalCullingBounds() const; + void Save(bool push_cull_rect); + const ContentContext& renderer_; Matrix matrix_; std::vector stack_; std::vector cull_rect_state_; + bool has_image_filter_ = false; Paint paint_; }; diff --git a/impeller/typographer/backends/skia/typographer_context_skia.cc b/impeller/typographer/backends/skia/typographer_context_skia.cc index a86e2ee6b8b41..b015e8525886c 100644 --- a/impeller/typographer/backends/skia/typographer_context_skia.cc +++ b/impeller/typographer/backends/skia/typographer_context_skia.cc @@ -471,6 +471,7 @@ std::shared_ptr TypographerContextSkia::CreateGlyphAtlas( if (new_glyphs.size() == 0) { return last_atlas; } + FML_LOG(ERROR) << "new_glyphs: " << new_glyphs.size(); // --------------------------------------------------------------------------- // Step 2: Determine if the additional missing glyphs can be appended to the From 90b85aa571d47bd945bda88167a7ebe81cdec8a4 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 23 Sep 2024 16:55:13 -0700 Subject: [PATCH 6/9] ++ --- impeller/toolkit/interop/surface.cc | 3 ++- impeller/typographer/backends/skia/typographer_context_skia.cc | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/impeller/toolkit/interop/surface.cc b/impeller/toolkit/interop/surface.cc index 20a2f4c4188a4..d37fad66407f3 100644 --- a/impeller/toolkit/interop/surface.cc +++ b/impeller/toolkit/interop/surface.cc @@ -61,7 +61,8 @@ bool Surface::DrawDisplayList(const DisplayList& dl) const { const auto cull_rect = IRect::MakeSize(surface_->GetSize()); auto skia_cull_rect = SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight()); - impeller::TextFrameDispatcher collector(content_context, impeller::Matrix{}); + impeller::TextFrameDispatcher collector(content_context, impeller::Matrix{}, + Rect::MakeSize(surface_->GetSize())); display_list->Dispatch(collector, skia_cull_rect); impeller::ExperimentalDlDispatcher impeller_dispatcher( diff --git a/impeller/typographer/backends/skia/typographer_context_skia.cc b/impeller/typographer/backends/skia/typographer_context_skia.cc index b015e8525886c..a86e2ee6b8b41 100644 --- a/impeller/typographer/backends/skia/typographer_context_skia.cc +++ b/impeller/typographer/backends/skia/typographer_context_skia.cc @@ -471,7 +471,6 @@ std::shared_ptr TypographerContextSkia::CreateGlyphAtlas( if (new_glyphs.size() == 0) { return last_atlas; } - FML_LOG(ERROR) << "new_glyphs: " << new_glyphs.size(); // --------------------------------------------------------------------------- // Step 2: Determine if the additional missing glyphs can be appended to the From 2397f96ce9a4bb09c58b8691ebefa68e26249ab3 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 24 Sep 2024 11:30:38 -0700 Subject: [PATCH 7/9] keep in global coordinate space. --- impeller/display_list/dl_dispatcher.cc | 6 ++++-- impeller/display_list/dl_dispatcher.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index 57b63be8294ca..0011f58646b59 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1396,10 +1396,12 @@ void TextFrameDispatcher::saveLayer(const DlRect& bounds, // This dispatcher does not track enough state to accurately compute // cull rects with image filters. - if (has_image_filter_) { + auto global_cull_rect = cull_rect_state_.back(); + if (has_image_filter_ || global_cull_rect.IsMaximum()) { cull_rect_state_.push_back(Rect::MakeMaximum()); } else { - auto new_cull_rect = GetCurrentLocalCullingBounds().Intersection(bounds); + auto global_save_bounds = bounds.TransformBounds(matrix_); + auto new_cull_rect = global_cull_rect.Intersection(global_save_bounds); if (new_cull_rect.has_value()) { cull_rect_state_.push_back(new_cull_rect.value()); } else { diff --git a/impeller/display_list/dl_dispatcher.h b/impeller/display_list/dl_dispatcher.h index c979e09d6aaf9..d8da2fa81fdce 100644 --- a/impeller/display_list/dl_dispatcher.h +++ b/impeller/display_list/dl_dispatcher.h @@ -403,6 +403,7 @@ class TextFrameDispatcher : public flutter::IgnoreAttributeDispatchHelper, const ContentContext& renderer_; Matrix matrix_; std::vector stack_; + // note: cull rects are always in the global coordinate space. std::vector cull_rect_state_; bool has_image_filter_ = false; Paint paint_; From a0b04d063eef1d840d08383c913057b015d4ff2c Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 24 Sep 2024 12:29:28 -0700 Subject: [PATCH 8/9] ++ --- impeller/display_list/dl_dispatcher.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index 0011f58646b59..37b082907cad9 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1506,14 +1506,20 @@ void TextFrameDispatcher::drawDisplayList( Paint old_paint = paint_; paint_ = Paint{}; bool old_has_image_filter = has_image_filter_; - has_image_filter_ = false; - IRect cull_rect = IRect::RoundOut(GetCurrentLocalCullingBounds()); - display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), // - cull_rect.GetTop(), // - cull_rect.GetRight(), // - cull_rect.GetBottom() // - )); + + auto local_cull_bounds = GetCurrentLocalCullingBounds(); + if (!local_cull_bounds.IsMaximum()) { + IRect cull_rect = IRect::RoundOut(local_cull_bounds); + display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), // + cull_rect.GetTop(), // + cull_rect.GetRight(), // + cull_rect.GetBottom() // + )); + } else { + display_list->Dispatch(*this); + } + restore(); paint_ = old_paint; has_image_filter_ = old_has_image_filter; From e620776228929314011bb44abb9f03a78854ee91 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 24 Sep 2024 14:27:37 -0700 Subject: [PATCH 9/9] jim review. --- impeller/display_list/dl_dispatcher.cc | 28 ++++++++++---------------- impeller/display_list/dl_dispatcher.h | 2 -- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/impeller/display_list/dl_dispatcher.cc b/impeller/display_list/dl_dispatcher.cc index 37b082907cad9..2e1870da19376 100644 --- a/impeller/display_list/dl_dispatcher.cc +++ b/impeller/display_list/dl_dispatcher.cc @@ -1378,34 +1378,28 @@ TextFrameDispatcher::~TextFrameDispatcher() { FML_DCHECK(cull_rect_state_.size() == 1); } -void TextFrameDispatcher::Save(bool push_cull_rect) { - stack_.emplace_back(matrix_); - if (push_cull_rect) { - cull_rect_state_.push_back(cull_rect_state_.back()); - } -} - void TextFrameDispatcher::save() { - Save(/*push_cull_rect=*/true); + stack_.emplace_back(matrix_); + cull_rect_state_.push_back(cull_rect_state_.back()); } void TextFrameDispatcher::saveLayer(const DlRect& bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter* backdrop) { - Save(/*push_cull_rect=*/false); + save(); // This dispatcher does not track enough state to accurately compute // cull rects with image filters. auto global_cull_rect = cull_rect_state_.back(); if (has_image_filter_ || global_cull_rect.IsMaximum()) { - cull_rect_state_.push_back(Rect::MakeMaximum()); + cull_rect_state_.back() = Rect::MakeMaximum(); } else { auto global_save_bounds = bounds.TransformBounds(matrix_); auto new_cull_rect = global_cull_rect.Intersection(global_save_bounds); if (new_cull_rect.has_value()) { - cull_rect_state_.push_back(new_cull_rect.value()); + cull_rect_state_.back() = new_cull_rect.value(); } else { - cull_rect_state_.push_back(Rect::MakeLTRB(0, 0, 0, 0)); + cull_rect_state_.back() = Rect::MakeLTRB(0, 0, 0, 0); } } } @@ -1502,22 +1496,22 @@ void TextFrameDispatcher::drawDisplayList( const sk_sp display_list, DlScalar opacity) { [[maybe_unused]] size_t stack_depth = stack_.size(); - Save(/*push_cull_rect=*/true); + save(); Paint old_paint = paint_; paint_ = Paint{}; bool old_has_image_filter = has_image_filter_; has_image_filter_ = false; - auto local_cull_bounds = GetCurrentLocalCullingBounds(); - if (!local_cull_bounds.IsMaximum()) { + Rect local_cull_bounds = GetCurrentLocalCullingBounds(); + if (local_cull_bounds.IsMaximum()) { + display_list->Dispatch(*this); + } else if (!local_cull_bounds.IsEmpty()) { IRect cull_rect = IRect::RoundOut(local_cull_bounds); display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), // cull_rect.GetTop(), // cull_rect.GetRight(), // cull_rect.GetBottom() // )); - } else { - display_list->Dispatch(*this); } restore(); diff --git a/impeller/display_list/dl_dispatcher.h b/impeller/display_list/dl_dispatcher.h index d8da2fa81fdce..61f8efd5a9dca 100644 --- a/impeller/display_list/dl_dispatcher.h +++ b/impeller/display_list/dl_dispatcher.h @@ -398,8 +398,6 @@ class TextFrameDispatcher : public flutter::IgnoreAttributeDispatchHelper, private: const Rect GetCurrentLocalCullingBounds() const; - void Save(bool push_cull_rect); - const ContentContext& renderer_; Matrix matrix_; std::vector stack_;