| Index: ui/views/cocoa/bridged_native_widget.mm
|
| diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
|
| index b79029c300d7f392699bb36439d9b13024ce2dd7..4f299e5d3edf8706fc66b003d32951207b998db2 100644
|
| --- a/ui/views/cocoa/bridged_native_widget.mm
|
| +++ b/ui/views/cocoa/bridged_native_widget.mm
|
| @@ -1063,6 +1063,15 @@ void BridgedNativeWidget::ReorderChildViews() {
|
| [bridged_view_ sortSubviewsUsingFunction:&SubviewSorter context:&rank];
|
| }
|
|
|
| +void BridgedNativeWidget::PumpCompositor() {
|
| + // Set the "needs commit" flag in the LayerTreeHost if isn't already set.
|
| + compositor_->ScheduleDraw();
|
| + frame_swapped_ = false;
|
| +
|
| + constexpr int kPumpTimeoutMS = 100;
|
| + WaitForFrame(kPumpTimeoutMS, [this] { return frame_swapped_; });
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // BridgedNativeWidget, internal::InputMethodDelegate:
|
|
|
| @@ -1158,6 +1167,8 @@ void BridgedNativeWidget::AcceleratedWidgetSwapCompleted() {
|
| invalidate_shadow_on_frame_swap_ = false;
|
| [window_ invalidateShadow];
|
| }
|
| +
|
| + frame_swapped_ = true;
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -1373,20 +1384,26 @@ void BridgedNativeWidget::MaybeWaitForFrame(const gfx::Size& size_in_dip) {
|
| if (!layer()->IsDrawn() || compositor_widget_->HasFrameOfSize(size_in_dip))
|
| return;
|
|
|
| - const int kPaintMsgTimeoutMS = 50;
|
| + constexpr int kPaintMsgTimeoutMS = 50;
|
| + WaitForFrame(kPaintMsgTimeoutMS, [&, this] {
|
| + // Since the UI thread is blocked, the size shouldn't change.
|
| + DCHECK(size_in_dip == GetClientAreaSize());
|
| + return compositor_widget_->HasFrameOfSize(size_in_dip);
|
| + });
|
| +}
|
| +
|
| +void BridgedNativeWidget::WaitForFrame(int timeout_ms,
|
| + std::function<bool()> predicate) {
|
| const base::TimeTicks start_time = base::TimeTicks::Now();
|
| const base::TimeTicks timeout_time =
|
| - start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS);
|
| + start_time + base::TimeDelta::FromMilliseconds(timeout_ms);
|
|
|
| ui::WindowResizeHelperMac* resize_helper = ui::WindowResizeHelperMac::Get();
|
| for (base::TimeTicks now = start_time; now < timeout_time;
|
| now = base::TimeTicks::Now()) {
|
| if (!resize_helper->WaitForSingleTaskToRun(timeout_time - now))
|
| return; // Timeout.
|
| -
|
| - // Since the UI thread is blocked, the size shouldn't change.
|
| - DCHECK(size_in_dip == GetClientAreaSize());
|
| - if (compositor_widget_->HasFrameOfSize(size_in_dip))
|
| + if (predicate())
|
| return; // Frame arrived.
|
| }
|
| }
|
|
|