diff --git a/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc b/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc index 1a292c04a41..6f10d82cd43 100644 --- a/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc +++ b/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.cc @@ -64,6 +64,9 @@ FlutterDesktopViewRef FlutterDesktopViewControllerGetView( return reinterpret_cast(1); } +void FlutterDesktopViewControllerForceRedraw( + FlutterDesktopViewControllerRef controller) {} + bool FlutterDesktopViewControllerHandleTopLevelWindowProc( FlutterDesktopViewControllerRef controller, HWND hwnd, diff --git a/shell/platform/windows/flutter_windows.cc b/shell/platform/windows/flutter_windows.cc index 267983b397e..4e1ef6ecc5a 100644 --- a/shell/platform/windows/flutter_windows.cc +++ b/shell/platform/windows/flutter_windows.cc @@ -76,6 +76,11 @@ FlutterDesktopViewRef FlutterDesktopViewControllerGetView( return HandleForView(controller->view.get()); } +void FlutterDesktopViewControllerForceRedraw( + FlutterDesktopViewControllerRef controller) { + controller->view->ForceRedraw(); +} + FlutterDesktopEngineRef FlutterDesktopEngineCreate( const FlutterDesktopEngineProperties& engine_properties) { flutter::FlutterProjectBundle project(engine_properties); diff --git a/shell/platform/windows/flutter_windows_view.cc b/shell/platform/windows/flutter_windows_view.cc index 60ac0cb6954..cebf4d1a920 100644 --- a/shell/platform/windows/flutter_windows_view.cc +++ b/shell/platform/windows/flutter_windows_view.cc @@ -95,6 +95,16 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) { return kWindowFrameBufferID; } +void FlutterWindowsView::ForceRedraw() { + if (resize_status_ == ResizeState::kDone) { + // Request new frame + // TODO(knopp): Replace with more specific call once there is API for it + // https://github.com/flutter/flutter/issues/69716 + SendWindowMetrics(resize_target_width_, resize_target_height_, + binding_handler_->GetDpiScale()); + } +} + void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) { // Called on the platform thread. std::unique_lock lock(resize_mutex_); diff --git a/shell/platform/windows/flutter_windows_view.h b/shell/platform/windows/flutter_windows_view.h index 75bdba645ee..d65acb7adc9 100644 --- a/shell/platform/windows/flutter_windows_view.h +++ b/shell/platform/windows/flutter_windows_view.h @@ -64,6 +64,9 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate, // Returns the engine backing this view. FlutterWindowsEngine* GetEngine(); + // Tells the engine to generate a new frame + void ForceRedraw(); + // Callbacks for clearing context, settings context and swapping buffers, // these are typically called on an engine-controlled (non-platform) thread. bool ClearContext(); diff --git a/shell/platform/windows/public/flutter_windows.h b/shell/platform/windows/public/flutter_windows.h index e1efbef34e7..0b52c97ad72 100644 --- a/shell/platform/windows/public/flutter_windows.h +++ b/shell/platform/windows/public/flutter_windows.h @@ -107,6 +107,10 @@ FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine( FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef controller); +// Requests new frame from engine and repaints the view +FLUTTER_EXPORT void FlutterDesktopViewControllerForceRedraw( + FlutterDesktopViewControllerRef controller); + #ifndef WINUWP // Allows the Flutter engine and any interested plugins an opportunity to // handle the given message.