| Index: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
|
| diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
|
| index 48368f962f2f3433b76c5ad20746ad28f135a481..cf5a8fa9421056ab598b733b695078da86562b43 100644
|
| --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
|
| +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
|
| @@ -15,6 +15,7 @@
|
| #include "ui/base/cursor/cursor_loader_win.h"
|
| #include "ui/base/ime/input_method.h"
|
| #include "ui/base/win/shell.h"
|
| +#include "ui/base/window_resize_helper.h"
|
| #include "ui/compositor/compositor_constants.h"
|
| #include "ui/compositor/paint_context.h"
|
| #include "ui/gfx/geometry/insets.h"
|
| @@ -908,6 +909,10 @@ void DesktopWindowTreeHostWin::HandleWindowSizeChanged() {
|
| if (compositor())
|
| compositor()->SetScaleAndSize(compositor()->device_scale_factor(),
|
| compositor()->size());
|
| +
|
| + // If the window size has changed and this is a visible window, we may
|
| + // want to try to immediately produce a frame.
|
| + MaybeWaitForFrame();
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -949,6 +954,32 @@ bool DesktopWindowTreeHostWin::IsModalWindowActive() const {
|
| return false;
|
| }
|
|
|
| +void DesktopWindowTreeHostWin::MaybeWaitForFrame() {
|
| + if (!compositor() || !compositor()->IsVisible() ||
|
| + compositor()->has_swapped_frame_at_current_size()) {
|
| + return;
|
| + }
|
| +
|
| + const int kPaintMsgTimeoutMS = 50;
|
| + const base::TimeTicks start_time = base::TimeTicks::Now();
|
| + const base::TimeTicks timeout_time =
|
| + start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS);
|
| + const gfx::Size target_size = compositor()->size();
|
| +
|
| + ui::WindowResizeHelper* resize_helper = ui::WindowResizeHelper::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(target_size == compositor()->size());
|
| + if (compositor()->has_swapped_frame_at_current_size()) {
|
| + return; // Frame arrived.
|
| + }
|
| + }
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // DesktopWindowTreeHost, public:
|
|
|
|
|