From 5439fdc0862e78ef8e8149b1acdfa874e63fd5cc Mon Sep 17 00:00:00 2001 From: David Reveman Date: Mon, 20 Apr 2020 13:29:08 -0400 Subject: [PATCH] [fuchsia] Enable raster cache on Fuchsia (flutter/engine#17753) The raster cache is critical for good performance. This enables the cache and provides a GrContext to ScopedFrame instances so the cache can be efficiently populated. Small increase in peak GPU memory usage is expected from this change. Otherwise, no change in behavior expected. Fixes https://github.com/flutter/flutter/issues/54950 Co-authored-by: David Reveman --- .../fuchsia/flutter/compositor_context.cc | 19 ++++++++++--------- .../fuchsia/flutter/session_connection.h | 4 ++++ .../fuchsia/flutter/vulkan_surface_producer.h | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/compositor_context.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/compositor_context.cc index 91513883ff..78d675a70b 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/compositor_context.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/compositor_context.cc @@ -14,14 +14,15 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { const SkMatrix& root_surface_transformation, bool instrumentation_enabled, SessionConnection& session_connection) - : flutter::CompositorContext::ScopedFrame(context, - nullptr, - nullptr, - nullptr, - root_surface_transformation, - instrumentation_enabled, - true, - nullptr), + : flutter::CompositorContext::ScopedFrame( + context, + session_connection.vulkan_surface_producer()->gr_context(), + nullptr, + nullptr, + root_surface_transformation, + instrumentation_enabled, + true, + nullptr), session_connection_(session_connection) {} private: @@ -37,7 +38,7 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { // Preroll the Flutter layer tree. This allows Flutter to perform // pre-paint optimizations. TRACE_EVENT0("flutter", "Preroll"); - layer_tree.Preroll(*this, true /* ignore raster cache */); + layer_tree.Preroll(*this, ignore_raster_cache); } { diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/session_connection.h b/engine/src/flutter/shell/platform/fuchsia/flutter/session_connection.h index 54ba846ee8..5c7af13c85 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/session_connection.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/session_connection.h @@ -68,6 +68,10 @@ class SessionConnection final { void OnSessionSizeChangeHint(float width_change_factor, float height_change_factor); + VulkanSurfaceProducer* vulkan_surface_producer() { + return surface_producer_.get(); + } + private: const std::string debug_label_; scenic::Session session_wrapper_; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h b/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h index 5ea1415cf5..efc7275c53 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/vulkan_surface_producer.h @@ -66,6 +66,8 @@ class VulkanSurfaceProducer final width_change_factor, height_change_factor); } + GrContext* gr_context() { return context_.get(); } + private: // VulkanProvider const vulkan::VulkanProcTable& vk() override { return *vk_.get(); }