From f3bf571559377ee14fd79079541a0b0f53fbc3ff Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Wed, 22 Nov 2017 14:12:25 +0100 Subject: [PATCH] Revert "Move texture registry ownership to platform view (#4348)" (flutter/engine#4387) This reverts commit 2c2ddf97d3bc0b385a4f2e38e6a52066efbe4f25. --- engine/src/flutter/flow/compositor_context.cc | 4 ++-- engine/src/flutter/flow/compositor_context.h | 8 ++------ engine/src/flutter/shell/common/null_rasterizer.cc | 7 +------ engine/src/flutter/shell/common/null_rasterizer.h | 4 +--- engine/src/flutter/shell/common/platform_view.cc | 1 - engine/src/flutter/shell/common/platform_view.h | 1 - engine/src/flutter/shell/common/rasterizer.h | 2 -- engine/src/flutter/shell/gpu/gpu_rasterizer.cc | 4 ---- engine/src/flutter/shell/gpu/gpu_rasterizer.h | 2 -- 9 files changed, 6 insertions(+), 27 deletions(-) diff --git a/engine/src/flutter/flow/compositor_context.cc b/engine/src/flutter/flow/compositor_context.cc index e0d17229e7..9f87eed8db 100644 --- a/engine/src/flutter/flow/compositor_context.cc +++ b/engine/src/flutter/flow/compositor_context.cc @@ -58,11 +58,11 @@ CompositorContext::ScopedFrame::~ScopedFrame() { } void CompositorContext::OnGrContextCreated() { - texture_registry_->OnGrContextCreated(); + texture_registry_.OnGrContextCreated(); } void CompositorContext::OnGrContextDestroyed() { - texture_registry_->OnGrContextDestroyed(); + texture_registry_.OnGrContextDestroyed(); raster_cache_.Clear(); } diff --git a/engine/src/flutter/flow/compositor_context.h b/engine/src/flutter/flow/compositor_context.h index 2d31042274..0b40bb5ed3 100644 --- a/engine/src/flutter/flow/compositor_context.h +++ b/engine/src/flutter/flow/compositor_context.h @@ -62,7 +62,7 @@ class CompositorContext { RasterCache& raster_cache() { return raster_cache_; } - TextureRegistry& texture_registry() { return *texture_registry_; } + TextureRegistry& texture_registry() { return texture_registry_; } const Counter& frame_count() const { return frame_count_; } @@ -72,13 +72,9 @@ class CompositorContext { const CounterValues& memory_usage() const { return memory_usage_; } - void SetTextureRegistry(TextureRegistry* textureRegistry) { - texture_registry_ = textureRegistry; - } - private: RasterCache raster_cache_; - TextureRegistry* texture_registry_; + TextureRegistry texture_registry_; std::unique_ptr process_info_; Counter frame_count_; Stopwatch frame_time_; diff --git a/engine/src/flutter/shell/common/null_rasterizer.cc b/engine/src/flutter/shell/common/null_rasterizer.cc index 81efdd11d4..adcb3bbacc 100644 --- a/engine/src/flutter/shell/common/null_rasterizer.cc +++ b/engine/src/flutter/shell/common/null_rasterizer.cc @@ -38,7 +38,7 @@ void NullRasterizer::DrawLastLayerTree() { } flow::TextureRegistry& NullRasterizer::GetTextureRegistry() { - return *texture_registry_; + return texture_registry_; } void NullRasterizer::Clear(SkColor color, const SkISize& size) { @@ -59,9 +59,4 @@ void NullRasterizer::AddNextFrameCallback(fxl::Closure nextFrameCallback) { // Null rasterizer. Nothing to do. } -void NullRasterizer::SetTextureRegistry( - flow::TextureRegistry* textureRegistry) { - texture_registry_ = textureRegistry; -} - } // namespace shell diff --git a/engine/src/flutter/shell/common/null_rasterizer.h b/engine/src/flutter/shell/common/null_rasterizer.h index 8558a3c3ac..d629f167d1 100644 --- a/engine/src/flutter/shell/common/null_rasterizer.h +++ b/engine/src/flutter/shell/common/null_rasterizer.h @@ -36,12 +36,10 @@ class NullRasterizer : public Rasterizer { void AddNextFrameCallback(fxl::Closure nextFrameCallback) override; - void SetTextureRegistry(flow::TextureRegistry* textureRegistry) override; - private: std::unique_ptr surface_; fml::WeakPtrFactory weak_factory_; - flow::TextureRegistry* texture_registry_; + flow::TextureRegistry texture_registry_; FXL_DISALLOW_COPY_AND_ASSIGN(NullRasterizer); }; diff --git a/engine/src/flutter/shell/common/platform_view.cc b/engine/src/flutter/shell/common/platform_view.cc index bc631e4baf..6d3d3f61e2 100644 --- a/engine/src/flutter/shell/common/platform_view.cc +++ b/engine/src/flutter/shell/common/platform_view.cc @@ -35,7 +35,6 @@ void PlatformView::SetRasterizer(std::unique_ptr rasterizer) { Rasterizer* r = rasterizer_.release(); blink::Threads::Gpu()->PostTask([r]() { delete r; }); rasterizer_ = std::move(rasterizer); - rasterizer_->SetTextureRegistry(&texture_registry_); engine_->set_rasterizer(rasterizer_->GetWeakRasterizerPtr()); } diff --git a/engine/src/flutter/shell/common/platform_view.h b/engine/src/flutter/shell/common/platform_view.h index a377f721ef..29970ec3e6 100644 --- a/engine/src/flutter/shell/common/platform_view.h +++ b/engine/src/flutter/shell/common/platform_view.h @@ -90,7 +90,6 @@ class PlatformView : public std::enable_shared_from_this { SurfaceConfig surface_config_; std::unique_ptr rasterizer_; - flow::TextureRegistry texture_registry_; std::unique_ptr engine_; std::unique_ptr vsync_waiter_; SkISize size_; diff --git a/engine/src/flutter/shell/common/rasterizer.h b/engine/src/flutter/shell/common/rasterizer.h index 6f45f49d81..fdecdec7cf 100644 --- a/engine/src/flutter/shell/common/rasterizer.h +++ b/engine/src/flutter/shell/common/rasterizer.h @@ -42,8 +42,6 @@ class Rasterizer { // Set a callback to be called once when the next frame is drawn. virtual void AddNextFrameCallback(fxl::Closure nextFrameCallback) = 0; - - virtual void SetTextureRegistry(flow::TextureRegistry* textureRegistry) = 0; }; } // namespace shell diff --git a/engine/src/flutter/shell/gpu/gpu_rasterizer.cc b/engine/src/flutter/shell/gpu/gpu_rasterizer.cc index 9431293280..fe60f62486 100644 --- a/engine/src/flutter/shell/gpu/gpu_rasterizer.cc +++ b/engine/src/flutter/shell/gpu/gpu_rasterizer.cc @@ -161,8 +161,4 @@ void GPURasterizer::NotifyNextFrameOnce() { } } -void GPURasterizer::SetTextureRegistry(flow::TextureRegistry* textureRegistry) { - compositor_context_.SetTextureRegistry(std::move(textureRegistry)); -} - } // namespace shell diff --git a/engine/src/flutter/shell/gpu/gpu_rasterizer.h b/engine/src/flutter/shell/gpu/gpu_rasterizer.h index ad16ee2c47..d92fe63122 100644 --- a/engine/src/flutter/shell/gpu/gpu_rasterizer.h +++ b/engine/src/flutter/shell/gpu/gpu_rasterizer.h @@ -42,8 +42,6 @@ class GPURasterizer : public Rasterizer { // Set a callback to be called once when the next frame is drawn. void AddNextFrameCallback(fxl::Closure nextFrameCallback) override; - void SetTextureRegistry(flow::TextureRegistry* textureRegistry) override; - private: std::unique_ptr surface_; flow::CompositorContext compositor_context_;