mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add API to force redraw of flutter view (#24186)
Currently when creating hidden window and showing it later the content does not get repainted automatically (unless something else triggers the repaint). This adds public `FlutterDesktopViewControllerForceRedraw()` to trigger repaint. The current implementation triggers this via a call to `SendWindowMetrics` but this should eventually be replaced by an embedder API call. See: https://github.com/flutter/flutter/issues/75319 See: https://github.com/flutter/flutter/issues/69716
This commit is contained in:
parent
368bacf453
commit
d1a763c17c
@ -64,6 +64,9 @@ FlutterDesktopViewRef FlutterDesktopViewControllerGetView(
|
||||
return reinterpret_cast<FlutterDesktopViewRef>(1);
|
||||
}
|
||||
|
||||
void FlutterDesktopViewControllerForceRedraw(
|
||||
FlutterDesktopViewControllerRef controller) {}
|
||||
|
||||
bool FlutterDesktopViewControllerHandleTopLevelWindowProc(
|
||||
FlutterDesktopViewControllerRef controller,
|
||||
HWND hwnd,
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<std::mutex> lock(resize_mutex_);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user