From bdfceb2b792c145a6dbf3476cdf5a46e7f37fb5a Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 4 Dec 2023 11:26:29 -0800 Subject: [PATCH] [Windows] Decouple GL context from view --- shell/platform/windows/flutter_windows_engine.cc | 12 ++++++------ shell/platform/windows/flutter_windows_view.cc | 12 ------------ shell/platform/windows/flutter_windows_view.h | 11 ++++++----- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/shell/platform/windows/flutter_windows_engine.cc b/shell/platform/windows/flutter_windows_engine.cc index fa43c05749017..d58a576eae099 100644 --- a/shell/platform/windows/flutter_windows_engine.cc +++ b/shell/platform/windows/flutter_windows_engine.cc @@ -53,17 +53,17 @@ FlutterRendererConfig GetOpenGLRendererConfig() { config.open_gl.struct_size = sizeof(config.open_gl); config.open_gl.make_current = [](void* user_data) -> bool { auto host = static_cast(user_data); - if (!host->view()) { + if (!host->surface_manager()) { return false; } - return host->view()->MakeCurrent(); + return host->surface_manager()->MakeCurrent(); }; config.open_gl.clear_current = [](void* user_data) -> bool { auto host = static_cast(user_data); - if (!host->view()) { + if (!host->surface_manager()) { return false; } - return host->view()->ClearContext(); + return host->surface_manager()->ClearContext(); }; config.open_gl.present = [](void* user_data) -> bool { auto host = static_cast(user_data); @@ -89,10 +89,10 @@ FlutterRendererConfig GetOpenGLRendererConfig() { }; config.open_gl.make_resource_current = [](void* user_data) -> bool { auto host = static_cast(user_data); - if (!host->view()) { + if (!host->surface_manager()) { return false; } - return host->view()->MakeResourceCurrent(); + return host->surface_manager()->MakeResourceCurrent(); }; config.open_gl.gl_external_texture_frame_callback = [](void* user_data, int64_t texture_id, size_t width, size_t height, diff --git a/shell/platform/windows/flutter_windows_view.cc b/shell/platform/windows/flutter_windows_view.cc index dc5488122e5c6..00623ff810e64 100644 --- a/shell/platform/windows/flutter_windows_view.cc +++ b/shell/platform/windows/flutter_windows_view.cc @@ -535,18 +535,6 @@ void FlutterWindowsView::SendPointerEventWithData( } } -bool FlutterWindowsView::MakeCurrent() { - return engine_->surface_manager()->MakeCurrent(); -} - -bool FlutterWindowsView::MakeResourceCurrent() { - return engine_->surface_manager()->MakeResourceCurrent(); -} - -bool FlutterWindowsView::ClearContext() { - return engine_->surface_manager()->ClearContext(); -} - bool FlutterWindowsView::SwapBuffers() { // Called on an engine-controlled (non-platform) thread. std::unique_lock lock(resize_mutex_); diff --git a/shell/platform/windows/flutter_windows_view.h b/shell/platform/windows/flutter_windows_view.h index 3f11677902576..55125f8551fa2 100644 --- a/shell/platform/windows/flutter_windows_view.h +++ b/shell/platform/windows/flutter_windows_view.h @@ -65,11 +65,12 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate { // Tells the engine to generate a new frame void ForceRedraw(); - // Callbacks for clearing context, settings context and swapping buffers, - // these are typically called on an engine-controlled (non-platform) thread. - bool ClearContext(); - bool MakeCurrent(); - bool MakeResourceCurrent(); + // Swap the view's surface buffers. Must be called on the engine's raster + // thread. Returns true if the buffers were swapped. + // + // If the view is resizing, this returns false if the frame is not the target + // size. Otherwise, it unblocks the platform thread and blocks the raster + // thread until the v-blank. bool SwapBuffers(); // Callback for presenting a software bitmap.