|
8 | 8 |
|
9 | 9 | namespace flutter { |
10 | 10 |
|
| 11 | +/// Returns true if the surface will be updated as part of the resize process. |
| 12 | +static bool SurfaceWillUpdate(size_t cur_width, |
| 13 | + size_t cur_height, |
| 14 | + size_t target_width, |
| 15 | + size_t target_height) { |
| 16 | + // TODO (https://github.com/flutter/flutter/issues/65061) : Avoid special |
| 17 | + // handling for zero dimensions. |
| 18 | + bool non_zero_dims = target_height > 0 && target_width > 0; |
| 19 | + bool not_same_size = |
| 20 | + (cur_height != target_height) || (cur_width != target_width); |
| 21 | + return non_zero_dims && not_same_size; |
| 22 | +} |
| 23 | + |
11 | 24 | FlutterWindowsView::FlutterWindowsView( |
12 | 25 | std::unique_ptr<WindowBindingHandler> window_binding) { |
13 | 26 | surface_manager_ = std::make_unique<AngleSurfaceManager>(); |
@@ -80,12 +93,18 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) { |
80 | 93 | void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) { |
81 | 94 | // Called on the platform thread. |
82 | 95 | std::unique_lock<std::mutex> lock(resize_mutex_); |
83 | | - resize_status_ = ResizeState::kResizeStarted; |
84 | | - resize_target_width_ = width; |
85 | | - resize_target_height_ = height; |
| 96 | + |
| 97 | + bool surface_will_update = SurfaceWillUpdate( |
| 98 | + resize_target_width_, resize_target_height_, width, height); |
| 99 | + if (surface_will_update) { |
| 100 | + resize_status_ = ResizeState::kResizeStarted; |
| 101 | + resize_target_width_ = width; |
| 102 | + resize_target_height_ = height; |
| 103 | + } |
| 104 | + |
86 | 105 | SendWindowMetrics(width, height, binding_handler_->GetDpiScale()); |
87 | 106 |
|
88 | | - if (width > 0 && height > 0) { |
| 107 | + if (surface_will_update) { |
89 | 108 | // Block the platform thread until: |
90 | 109 | // 1. GetFrameBufferId is called with the right frame size. |
91 | 110 | // 2. Any pending SwapBuffers calls have been invoked. |
|
0 commit comments