|
8 | 8 |
|
9 | 9 | namespace flutter { |
10 | 10 |
|
| 11 | +static bool IsValidResize(size_t cur_width, |
| 12 | + size_t cur_height, |
| 13 | + size_t target_width, |
| 14 | + size_t target_height) { |
| 15 | + bool non_zero_dims = target_height > 0 && target_width > 0; |
| 16 | + bool not_same_size = |
| 17 | + (cur_height != target_height) || (cur_width != target_width); |
| 18 | + return non_zero_dims && not_same_size; |
| 19 | +} |
| 20 | + |
11 | 21 | FlutterWindowsView::FlutterWindowsView( |
12 | 22 | std::unique_ptr<WindowBindingHandler> window_binding) { |
13 | 23 | surface_manager_ = std::make_unique<AngleSurfaceManager>(); |
@@ -80,19 +90,22 @@ uint32_t FlutterWindowsView::GetFrameBufferId(size_t width, size_t height) { |
80 | 90 | void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) { |
81 | 91 | // Called on the platform thread. |
82 | 92 | std::unique_lock<std::mutex> lock(resize_mutex_); |
| 93 | + if (!IsValidResize(resize_target_width_, resize_target_height_, width, |
| 94 | + height)) { |
| 95 | + return; |
| 96 | + } |
| 97 | + |
83 | 98 | resize_status_ = ResizeState::kResizeStarted; |
84 | 99 | resize_target_width_ = width; |
85 | 100 | resize_target_height_ = height; |
86 | 101 | SendWindowMetrics(width, height, binding_handler_->GetDpiScale()); |
87 | 102 |
|
88 | | - if (width > 0 && height > 0) { |
89 | | - // Block the platform thread until: |
90 | | - // 1. GetFrameBufferId is called with the right frame size. |
91 | | - // 2. Any pending SwapBuffers calls have been invoked. |
92 | | - resize_cv_.wait(lock, [&resize_status = resize_status_] { |
93 | | - return resize_status == ResizeState::kDone; |
94 | | - }); |
95 | | - } |
| 103 | + // Block the platform thread until: |
| 104 | + // 1. GetFrameBufferId is called with the right frame size. |
| 105 | + // 2. Any pending SwapBuffers calls have been invoked. |
| 106 | + resize_cv_.wait(lock, [&resize_status = resize_status_] { |
| 107 | + return resize_status == ResizeState::kDone; |
| 108 | + }); |
96 | 109 | } |
97 | 110 |
|
98 | 111 | void FlutterWindowsView::OnPointerMove(double x, double y) { |
|
0 commit comments