Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b0694c5

Browse files
authored
[Windows] Fix incorrect surface manager comment (#49335)
#24428 attempted to make surface resizing less expensive by using ANGLE's automatic resizing instead of manually destroying and then re-creating the surface. This caused some issues: 1. Flutter's surface size synchronization logic broke: #24682 2. Resizing frameless windows caused the content to wiggle: flutter/flutter#76465 The second issue caused the automatic resizing change to be reverted. However, the first fix was not reverted resulting in an incorrect comment. Relanding this resizing performance improvement is tracked by flutter/flutter#79427
1 parent 737e6f8 commit b0694c5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

shell/platform/windows/angle_surface_manager.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ bool AngleSurfaceManager::CreateSurface(WindowsRenderTarget* render_target,
238238

239239
EGLSurface surface = EGL_NO_SURFACE;
240240

241+
// Disable ANGLE's automatic surface resizing and provide an explicit size.
242+
// The surface will need to be destroyed and re-created if the HWND is
243+
// resized.
241244
const EGLint surfaceAttributes[] = {
242245
EGL_FIXED_SIZE_ANGLE, EGL_TRUE, EGL_WIDTH, width,
243246
EGL_HEIGHT, height, EGL_NONE};
@@ -267,6 +270,9 @@ void AngleSurfaceManager::ResizeSurface(WindowsRenderTarget* render_target,
267270
surface_width_ = width;
268271
surface_height_ = height;
269272

273+
// TODO: Destroying the surface and re-creating it is expensive.
274+
// Ideally this would use ANGLE's automatic surface sizing instead.
275+
// See: https://github.com/flutter/flutter/issues/79427
270276
ClearContext();
271277
DestroySurface();
272278
if (!CreateSurface(render_target, width, height)) {
@@ -285,9 +291,10 @@ void AngleSurfaceManager::GetSurfaceDimensions(EGLint* width, EGLint* height) {
285291
return;
286292
}
287293

288-
// Can't use eglQuerySurface here; Because we're not using
289-
// EGL_FIXED_SIZE_ANGLE flag anymore, Angle may resize the surface before
290-
// Flutter asks it to, which breaks resize redraw synchronization
294+
// This avoids eglQuerySurface as ideally surfaces would be automatically
295+
// sized by ANGLE to avoid expensive surface destroy & re-create. With
296+
// automatic sizing, ANGLE could resize the surface before Flutter asks it to,
297+
// which would break resize redraw synchronization.
291298
*width = surface_width_;
292299
*height = surface_height_;
293300
}

0 commit comments

Comments
 (0)