mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[windows] Honor only valid resize requests (#23990)
This commit is contained in:
parent
f9c0985573
commit
3c3e2a4f91
@ -8,6 +8,24 @@
|
||||
|
||||
namespace flutter {
|
||||
|
||||
/// Returns true if the surface will be updated as part of the resize process.
|
||||
///
|
||||
/// This is called on window resize to determine if the platform thread needs
|
||||
/// to be blocked until the frame with the right size has been rendered. It
|
||||
/// should be kept in-sync with how the engine deals with a new surface request
|
||||
/// as seen in `CreateOrUpdateSurface` in `GPUSurfaceGL`.
|
||||
static bool SurfaceWillUpdate(size_t cur_width,
|
||||
size_t cur_height,
|
||||
size_t target_width,
|
||||
size_t target_height) {
|
||||
// TODO (https://github.com/flutter/flutter/issues/65061) : Avoid special
|
||||
// handling for zero dimensions.
|
||||
bool non_zero_dims = target_height > 0 && target_width > 0;
|
||||
bool not_same_size =
|
||||
(cur_height != target_height) || (cur_width != target_width);
|
||||
return non_zero_dims && not_same_size;
|
||||
}
|
||||
|
||||
FlutterWindowsView::FlutterWindowsView(
|
||||
std::unique_ptr<WindowBindingHandler> window_binding) {
|
||||
surface_manager_ = std::make_unique<AngleSurfaceManager>();
|
||||
@ -80,12 +98,18 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) {
|
||||
void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) {
|
||||
// Called on the platform thread.
|
||||
std::unique_lock<std::mutex> lock(resize_mutex_);
|
||||
resize_status_ = ResizeState::kResizeStarted;
|
||||
resize_target_width_ = width;
|
||||
resize_target_height_ = height;
|
||||
|
||||
bool surface_will_update = SurfaceWillUpdate(
|
||||
resize_target_width_, resize_target_height_, width, height);
|
||||
if (surface_will_update) {
|
||||
resize_status_ = ResizeState::kResizeStarted;
|
||||
resize_target_width_ = width;
|
||||
resize_target_height_ = height;
|
||||
}
|
||||
|
||||
SendWindowMetrics(width, height, binding_handler_->GetDpiScale());
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
if (surface_will_update) {
|
||||
// Block the platform thread until:
|
||||
// 1. GetFrameBufferId is called with the right frame size.
|
||||
// 2. Any pending SwapBuffers calls have been invoked.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user