diff --git a/engine/src/flutter/shell/common/rasterizer.cc b/engine/src/flutter/shell/common/rasterizer.cc index 20f74cecb8..186db591d3 100644 --- a/engine/src/flutter/shell/common/rasterizer.cc +++ b/engine/src/flutter/shell/common/rasterizer.cc @@ -28,19 +28,17 @@ fml::WeakPtr Rasterizer::GetWeakPtr() const { void Rasterizer::Setup(std::unique_ptr surface) { surface_ = std::move(surface); + compositor_context_.OnGrContextCreated(); } void Rasterizer::Teardown() { + compositor_context_.OnGrContextDestroyed(); surface_.reset(); last_layer_tree_.reset(); } flow::TextureRegistry* Rasterizer::GetTextureRegistry() { - if (!surface_) { - return nullptr; - } - - return &(surface_->GetCompositorContext().texture_registry()); + return &compositor_context_.texture_registry(); } flow::LayerTree* Rasterizer::GetLastLayerTree() { @@ -97,14 +95,12 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) { return false; } - auto& compositor_context = surface_->GetCompositorContext(); - // There is no way for the compositor to know how long the layer tree // construction took. Fortunately, the layer tree does. Grab that time // for instrumentation. - compositor_context.engine_time().SetLapTime(layer_tree.construction_time()); + compositor_context_.engine_time().SetLapTime(layer_tree.construction_time()); - auto compositor_frame = compositor_context.AcquireFrame( + auto compositor_frame = compositor_context_.AcquireFrame( surface_->GetContext(), frame->SkiaCanvas(), true); if (compositor_frame && compositor_frame->Raster(layer_tree, false)) { diff --git a/engine/src/flutter/shell/common/rasterizer.h b/engine/src/flutter/shell/common/rasterizer.h index 908717b74c..e373b1138c 100644 --- a/engine/src/flutter/shell/common/rasterizer.h +++ b/engine/src/flutter/shell/common/rasterizer.h @@ -62,7 +62,7 @@ class Rasterizer final { private: blink::TaskRunners task_runners_; std::unique_ptr surface_; - std::unique_ptr compositor_context_; + flow::CompositorContext compositor_context_; std::unique_ptr last_layer_tree_; fxl::Closure next_frame_callback_; fml::WeakPtr weak_prototype_; diff --git a/engine/src/flutter/shell/common/surface.cc b/engine/src/flutter/shell/common/surface.cc index 228647e8b3..d9b620fbc6 100644 --- a/engine/src/flutter/shell/common/surface.cc +++ b/engine/src/flutter/shell/common/surface.cc @@ -60,22 +60,8 @@ bool SurfaceFrame::PerformSubmit() { return false; } -Surface::Surface() : Surface(std::make_unique()) {} +Surface::Surface() = default; -Surface::Surface(std::unique_ptr compositor_context) - : compositor_context_(std::move(compositor_context)) { - FXL_DCHECK(compositor_context_); - // TODO: Get rid of these explicit calls and move the logic to the c/dtors of - // the compositor context. - compositor_context_->OnGrContextCreated(); -} - -Surface::~Surface() { - compositor_context_->OnGrContextDestroyed(); -} - -flow::CompositorContext& Surface::GetCompositorContext() { - return *compositor_context_; -} +Surface::~Surface() = default; } // namespace shell diff --git a/engine/src/flutter/shell/common/surface.h b/engine/src/flutter/shell/common/surface.h index 6133a7d519..8c3d242193 100644 --- a/engine/src/flutter/shell/common/surface.h +++ b/engine/src/flutter/shell/common/surface.h @@ -45,8 +45,6 @@ class Surface { public: Surface(); - Surface(std::unique_ptr compositor_context); - virtual ~Surface(); virtual bool IsValid() = 0; @@ -55,11 +53,7 @@ class Surface { virtual GrContext* GetContext() = 0; - flow::CompositorContext& GetCompositorContext(); - private: - std::unique_ptr compositor_context_; - FXL_DISALLOW_COPY_AND_ASSIGN(Surface); }; diff --git a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc index 284a10e413..11482e48f6 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_gl.cc +++ b/engine/src/flutter/shell/gpu/gpu_surface_gl.cc @@ -72,8 +72,6 @@ GPUSurfaceGL::~GPUSurfaceGL() { return; } - GetCompositorContext().OnGrContextDestroyed(); - onscreen_surface_ = nullptr; context_->releaseResourcesAndAbandonContext(); context_ = nullptr;