diff --git a/shell/platform/windows/flutter_window.cc b/shell/platform/windows/flutter_window.cc index 8c0b39abf1348..b7630340ecfd5 100644 --- a/shell/platform/windows/flutter_window.cc +++ b/shell/platform/windows/flutter_window.cc @@ -185,12 +185,6 @@ void FlutterWindow::SetFlutterCursor(HCURSOR cursor) { ::SetCursor(current_cursor_); } -void FlutterWindow::OnWindowResized() { - // Blocking the raster thread until DWM flushes alleviates glitches where - // previous size surface is stretched over current size view. - DwmFlush(); -} - void FlutterWindow::OnDpiScale(unsigned int dpi) {}; // When DesktopWindow notifies that a WM_Size message has come in diff --git a/shell/platform/windows/flutter_window.h b/shell/platform/windows/flutter_window.h index 202c21b78c20c..e461476d39175 100644 --- a/shell/platform/windows/flutter_window.h +++ b/shell/platform/windows/flutter_window.h @@ -170,9 +170,6 @@ class FlutterWindow : public KeyboardManager::WindowDelegate, // |FlutterWindowBindingHandler| virtual void SetFlutterCursor(HCURSOR cursor) override; - // |FlutterWindowBindingHandler| - virtual void OnWindowResized() override; - // |FlutterWindowBindingHandler| virtual bool OnBitmapSurfaceCleared() override; diff --git a/shell/platform/windows/flutter_windows_view.cc b/shell/platform/windows/flutter_windows_view.cc index d902d1e7b2acf..13c10ed4491d6 100644 --- a/shell/platform/windows/flutter_windows_view.cc +++ b/shell/platform/windows/flutter_windows_view.cc @@ -613,7 +613,11 @@ bool FlutterWindowsView::SwapBuffers() { resize_status_ = ResizeState::kDone; lock.unlock(); resize_cv_.notify_all(); - binding_handler_->OnWindowResized(); + + // Blocking the raster thread until DWM flushes alleviates glitches where + // previous size surface is stretched over current size view. + windows_proc_table_->DwmFlush(); + if (!visible) { swap_buffers_result = engine_->surface_manager()->SwapBuffers(); } diff --git a/shell/platform/windows/testing/mock_window_binding_handler.h b/shell/platform/windows/testing/mock_window_binding_handler.h index 8aa3bce69576a..22185f057ac4c 100644 --- a/shell/platform/windows/testing/mock_window_binding_handler.h +++ b/shell/platform/windows/testing/mock_window_binding_handler.h @@ -23,7 +23,6 @@ class MockWindowBindingHandler : public WindowBindingHandler { MOCK_METHOD(HWND, GetWindowHandle, (), (override)); MOCK_METHOD(float, GetDpiScale, (), (override)); MOCK_METHOD(bool, IsVisible, (), (override)); - MOCK_METHOD(void, OnWindowResized, (), (override)); MOCK_METHOD(PhysicalWindowBounds, GetPhysicalWindowBounds, (), (override)); MOCK_METHOD(void, UpdateFlutterCursor, diff --git a/shell/platform/windows/testing/mock_windows_proc_table.h b/shell/platform/windows/testing/mock_windows_proc_table.h index af03f66db37c0..0d79e67c8e43c 100644 --- a/shell/platform/windows/testing/mock_windows_proc_table.h +++ b/shell/platform/windows/testing/mock_windows_proc_table.h @@ -32,6 +32,8 @@ class MockWindowsProcTable : public WindowsProcTable { MOCK_METHOD(bool, DwmIsCompositionEnabled, (), (const, override)); + MOCK_METHOD(HRESULT, DwmFlush, (), (const, override)); + private: FML_DISALLOW_COPY_AND_ASSIGN(MockWindowsProcTable); }; diff --git a/shell/platform/windows/window_binding_handler.h b/shell/platform/windows/window_binding_handler.h index 83fa57b8acf7e..29f4c6b8eba24 100644 --- a/shell/platform/windows/window_binding_handler.h +++ b/shell/platform/windows/window_binding_handler.h @@ -57,9 +57,6 @@ class WindowBindingHandler { // Returns the bounds of the backing window in physical pixels. virtual PhysicalWindowBounds GetPhysicalWindowBounds() = 0; - // Invoked after the window has been resized. - virtual void OnWindowResized() = 0; - // Sets the cursor that should be used when the mouse is over the Flutter // content. See mouse_cursor.dart for the values and meanings of cursor_name. virtual void UpdateFlutterCursor(const std::string& cursor_name) = 0; diff --git a/shell/platform/windows/windows_proc_table.cc b/shell/platform/windows/windows_proc_table.cc index 36a4f4153cc67..663faaa73e789 100644 --- a/shell/platform/windows/windows_proc_table.cc +++ b/shell/platform/windows/windows_proc_table.cc @@ -54,4 +54,8 @@ bool WindowsProcTable::DwmIsCompositionEnabled() const { return true; } +HRESULT WindowsProcTable::DwmFlush() const { + return ::DwmFlush(); +} + } // namespace flutter diff --git a/shell/platform/windows/windows_proc_table.h b/shell/platform/windows/windows_proc_table.h index 1063310394932..ed0ed04ae6de8 100644 --- a/shell/platform/windows/windows_proc_table.h +++ b/shell/platform/windows/windows_proc_table.h @@ -50,6 +50,13 @@ class WindowsProcTable { // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled virtual bool DwmIsCompositionEnabled() const; + // Issues a flush call that blocks the caller until all of the outstanding + // surface updates have been made. + // + // See: + // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmflush + virtual HRESULT DwmFlush() const; + private: using GetPointerType_ = BOOL __stdcall(UINT32 pointerId, POINTER_INPUT_TYPE* pointerType);