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

Commit 54b76b6

Browse files
committed
[Windows] Move DWM flush to Windows proc table for mocking
1 parent 9c73cad commit 54b76b6

File tree

8 files changed

+18
-14
lines changed

8 files changed

+18
-14
lines changed

shell/platform/windows/flutter_window.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ void FlutterWindow::SetFlutterCursor(HCURSOR cursor) {
185185
::SetCursor(current_cursor_);
186186
}
187187

188-
void FlutterWindow::OnWindowResized() {
189-
// Blocking the raster thread until DWM flushes alleviates glitches where
190-
// previous size surface is stretched over current size view.
191-
DwmFlush();
192-
}
193-
194188
void FlutterWindow::OnDpiScale(unsigned int dpi) {};
195189

196190
// When DesktopWindow notifies that a WM_Size message has come in

shell/platform/windows/flutter_window.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ class FlutterWindow : public KeyboardManager::WindowDelegate,
170170
// |FlutterWindowBindingHandler|
171171
virtual void SetFlutterCursor(HCURSOR cursor) override;
172172

173-
// |FlutterWindowBindingHandler|
174-
virtual void OnWindowResized() override;
175-
176173
// |FlutterWindowBindingHandler|
177174
virtual bool OnBitmapSurfaceCleared() override;
178175

shell/platform/windows/flutter_windows_view.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,11 @@ bool FlutterWindowsView::SwapBuffers() {
613613
resize_status_ = ResizeState::kDone;
614614
lock.unlock();
615615
resize_cv_.notify_all();
616-
binding_handler_->OnWindowResized();
616+
617+
// Blocking the raster thread until DWM flushes alleviates glitches where
618+
// previous size surface is stretched over current size view.
619+
windows_proc_table_->DwmFlush();
620+
617621
if (!visible) {
618622
swap_buffers_result = engine_->surface_manager()->SwapBuffers();
619623
}

shell/platform/windows/testing/mock_window_binding_handler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class MockWindowBindingHandler : public WindowBindingHandler {
2323
MOCK_METHOD(HWND, GetWindowHandle, (), (override));
2424
MOCK_METHOD(float, GetDpiScale, (), (override));
2525
MOCK_METHOD(bool, IsVisible, (), (override));
26-
MOCK_METHOD(void, OnWindowResized, (), (override));
2726
MOCK_METHOD(PhysicalWindowBounds, GetPhysicalWindowBounds, (), (override));
2827
MOCK_METHOD(void,
2928
UpdateFlutterCursor,

shell/platform/windows/testing/mock_windows_proc_table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class MockWindowsProcTable : public WindowsProcTable {
3232

3333
MOCK_METHOD(bool, DwmIsCompositionEnabled, (), (const, override));
3434

35+
MOCK_METHOD(HRESULT, DwmFlush, (), (const, override));
36+
3537
private:
3638
FML_DISALLOW_COPY_AND_ASSIGN(MockWindowsProcTable);
3739
};

shell/platform/windows/window_binding_handler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ class WindowBindingHandler {
5757
// Returns the bounds of the backing window in physical pixels.
5858
virtual PhysicalWindowBounds GetPhysicalWindowBounds() = 0;
5959

60-
// Invoked after the window has been resized.
61-
virtual void OnWindowResized() = 0;
62-
6360
// Sets the cursor that should be used when the mouse is over the Flutter
6461
// content. See mouse_cursor.dart for the values and meanings of cursor_name.
6562
virtual void UpdateFlutterCursor(const std::string& cursor_name) = 0;

shell/platform/windows/windows_proc_table.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ bool WindowsProcTable::DwmIsCompositionEnabled() const {
5454
return true;
5555
}
5656

57+
HRESULT WindowsProcTable::DwmFlush() const {
58+
return ::DwmFlush();
59+
}
60+
5761
} // namespace flutter

shell/platform/windows/windows_proc_table.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class WindowsProcTable {
5050
// https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled
5151
virtual bool DwmIsCompositionEnabled() const;
5252

53+
// Issues a flush call that blocks the caller until all of the outstanding
54+
// surface updates have been made.
55+
//
56+
// See:
57+
// https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmflush
58+
virtual HRESULT DwmFlush() const;
59+
5360
private:
5461
using GetPointerType_ = BOOL __stdcall(UINT32 pointerId,
5562
POINTER_INPUT_TYPE* pointerType);

0 commit comments

Comments
 (0)