From d7e2d53564ac91ca8756db4fa322af09479a0ff8 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 18 Feb 2021 14:51:03 -0800 Subject: [PATCH] Improve resize (flutter/engine#24428) --- .../platform/windows/angle_surface_manager.cc | 24 ++++--------------- .../platform/windows/flutter_window_winuwp.cc | 6 +++-- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/engine/src/flutter/shell/platform/windows/angle_surface_manager.cc b/engine/src/flutter/shell/platform/windows/angle_surface_manager.cc index add11195d52..d210f7c76e0 100644 --- a/engine/src/flutter/shell/platform/windows/angle_surface_manager.cc +++ b/engine/src/flutter/shell/platform/windows/angle_surface_manager.cc @@ -205,13 +205,7 @@ bool AngleSurfaceManager::CreateSurface(WindowsRenderTarget* render_target, EGLSurface surface = EGL_NO_SURFACE; - // Disable Angle's automatic surface sizing logic and provide and exlicit - // size. AngleSurfaceManager is responsible for initiating Angle surface size - // changes to avoid race conditions with rendering when automatic mode is - // used. - const EGLint surfaceAttributes[] = { - EGL_FIXED_SIZE_ANGLE, EGL_TRUE, EGL_WIDTH, width, - EGL_HEIGHT, height, EGL_NONE}; + const EGLint surfaceAttributes[] = {EGL_NONE}; #ifdef WINUWP #ifdef USECOREWINDOW @@ -244,19 +238,9 @@ void AngleSurfaceManager::ResizeSurface(WindowsRenderTarget* render_target, EGLint existing_width, existing_height; GetSurfaceDimensions(&existing_width, &existing_height); if (width != existing_width || height != existing_height) { - // Destroy existing surface with previous stale dimensions and create new - // surface at new size. Since the Windows compositor retains the front - // buffer until the new surface has been presented, no need to manually - // preserve the previous surface contents. This resize approach could be - // further optimized if Angle exposed a public entrypoint for - // SwapChain11::reset or SwapChain11::resize. - // a possible starting point for that could build on - // eglPostSubBufferNV(egl_display_, render_surface_, 1, 1, width, height); - DestroySurface(); - if (!CreateSurface(render_target, width, height)) { - std::cerr << "AngleSurfaceManager::ResizeSurface failed to create surface" - << std::endl; - } + // Resize render_surface_. Internaly this calls mSwapChain->ResizeBuffers + // avoiding the need to destory and recreate the underlying SwapChain. + eglPostSubBufferNV(egl_display_, render_surface_, 1, 1, width, height); } } diff --git a/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc b/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc index 8593b8580cd..7c68cfd9b05 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc +++ b/engine/src/flutter/shell/platform/windows/flutter_window_winuwp.cc @@ -245,15 +245,17 @@ double FlutterWindowWinUWP::GetPosY( void FlutterWindowWinUWP::OnBoundsChanged( winrt::Windows::UI::ViewManagement::ApplicationView const& app_view, winrt::Windows::Foundation::IInspectable const&) { -#ifndef USECOREWINDOW if (binding_handler_delegate_) { auto bounds = GetBounds(current_display_info_, true); binding_handler_delegate_->OnWindowSizeChanged( static_cast(bounds.width), static_cast(bounds.height)); +#ifndef USECOREWINDOW + render_target_.Size({bounds.width, bounds.height}); - } + #endif + } } void FlutterWindowWinUWP::OnKeyUp(