From efc6a573d9baeaed3a0d2f14457d8ad874a6820e Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Thu, 21 Dec 2023 11:27:47 -0800 Subject: [PATCH 1/2] [Windows] Fix incorrect surface manager comment --- shell/platform/windows/angle_surface_manager.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shell/platform/windows/angle_surface_manager.cc b/shell/platform/windows/angle_surface_manager.cc index 6d972ae723a49..1c614d11761da 100644 --- a/shell/platform/windows/angle_surface_manager.cc +++ b/shell/platform/windows/angle_surface_manager.cc @@ -238,6 +238,9 @@ bool AngleSurfaceManager::CreateSurface(WindowsRenderTarget* render_target, EGLSurface surface = EGL_NO_SURFACE; + // Disable ANGLE's automatic surface resizing and provide an explicit size. + // The surface will need to be destroyed and re-created if the HWND is + // resized. const EGLint surfaceAttributes[] = { EGL_FIXED_SIZE_ANGLE, EGL_TRUE, EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE}; @@ -285,9 +288,10 @@ void AngleSurfaceManager::GetSurfaceDimensions(EGLint* width, EGLint* height) { return; } - // Can't use eglQuerySurface here; Because we're not using - // EGL_FIXED_SIZE_ANGLE flag anymore, Angle may resize the surface before - // Flutter asks it to, which breaks resize redraw synchronization + // This avoids eglQuerySurface as ideally surfaces would be automatically + // sized by ANGLE to avoid expensive surface destroy & re-create. With + // automatic sizing, ANGLE could resize the surface before Flutter asks it to, + // which would break resize redraw synchronization. *width = surface_width_; *height = surface_height_; } From a0e67e52f987aeae8ed0ccf7d6838b7bd2c46893 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Thu, 21 Dec 2023 11:40:13 -0800 Subject: [PATCH 2/2] Add TODO --- shell/platform/windows/angle_surface_manager.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell/platform/windows/angle_surface_manager.cc b/shell/platform/windows/angle_surface_manager.cc index 1c614d11761da..9d5a9ed2b3d8f 100644 --- a/shell/platform/windows/angle_surface_manager.cc +++ b/shell/platform/windows/angle_surface_manager.cc @@ -270,6 +270,9 @@ void AngleSurfaceManager::ResizeSurface(WindowsRenderTarget* render_target, surface_width_ = width; surface_height_ = height; + // TODO: Destroying the surface and re-creating it is expensive. + // Ideally this would use ANGLE's automatic surface sizing instead. + // See: https://github.com/flutter/flutter/issues/79427 ClearContext(); DestroySurface(); if (!CreateSurface(render_target, width, height)) {