Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc

Issue 1513053002: WIP - Gutterless resize on Windows Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ce30eb0941a57cd0f7fbf70705825359e4a682f6 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,36 @@ bool DesktopWindowTreeHostWin::IsModalWindowActive() const {
return false;
}
+void DesktopWindowTreeHostWin::MaybeWaitForFrame() {
+ if (!compositor())
+ return;
+
+ const gfx::Size target_size = compositor()->size();
+
+ if (!compositor()->IsVisible() ||
+ compositor()->last_swapped_frame_size() == target_size) {
+ return;
+ }
+
+ const int kPaintMsgTimeoutMS = 55;
piman 2015/12/15 07:15:36 Any specific reason for 55 vs 50? My gut feeling i
+ const base::TimeTicks start_time = base::TimeTicks::Now();
+ const base::TimeTicks timeout_time =
+ start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS);
+
+ 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()->last_swapped_frame_size() == target_size) {
+ return; // Frame arrived.
+ }
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHost, public:
« ui/compositor/compositor.cc ('K') | « ui/views/widget/desktop_aura/desktop_window_tree_host_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698