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

Unified Diff: ui/aura/root_window.cc

Issue 9838045: aura: fast resizes for accelerated pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 8 years, 9 months 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
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/gfx/compositor/compositor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window.cc
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 01093de12a496aae29f4582a7bf5f4ad3013b85a..b6db89d2950f7eb34330e67545b2e7b3aa98ce8f 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -54,8 +54,29 @@ void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
}
}
+const int kCompositorLockTimeoutMs = 67;
+
} // namespace
+CompositorLock::CompositorLock(RootWindow* root_window)
+ : root_window_(root_window) {
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&CompositorLock::CancelLock, AsWeakPtr()),
+ kCompositorLockTimeoutMs);
+}
+
+CompositorLock::~CompositorLock() {
+ CancelLock();
+}
+
+void CompositorLock::CancelLock() {
+ if (!root_window_)
+ return;
+ root_window_->UnlockCompositor();
+ root_window_ = NULL;
+}
+
bool RootWindow::hide_host_cursor_ = false;
////////////////////////////////////////////////////////////////////////////////
@@ -80,7 +101,9 @@ RootWindow::RootWindow(const gfx::Rect& initial_bounds)
draw_on_compositing_end_(false),
defer_draw_scheduling_(false),
mouse_move_hold_count_(0),
- should_hold_mouse_moves_(false) {
+ should_hold_mouse_moves_(false),
+ compositor_lock_(NULL),
+ draw_on_compositor_unlock_(false) {
SetName("RootWindow");
last_mouse_location_ = host_->QueryMouseLocation();
@@ -95,6 +118,12 @@ RootWindow::RootWindow(const gfx::Rect& initial_bounds)
}
RootWindow::~RootWindow() {
+ if (compositor_lock_) {
+ // No need to schedule a draw, we're going away.
+ draw_on_compositor_unlock_ = false;
+ compositor_lock_->CancelLock();
+ DCHECK(!compositor_lock_);
+ }
compositor_->RemoveObserver(this);
// Make sure to destroy the compositor before terminating so that state is
// cleared and we don't hit asserts.
@@ -163,6 +192,11 @@ void RootWindow::Draw() {
defer_draw_scheduling_ = false;
return;
}
+ if (compositor_lock_) {
+ draw_on_compositor_unlock_ = true;
+ defer_draw_scheduling_ = false;
+ return;
+ }
waiting_on_compositing_end_ = true;
compositor_->Draw(false);
@@ -400,6 +434,12 @@ void RootWindow::ReleaseMouseMoves() {
}
}
+scoped_refptr<CompositorLock> RootWindow::GetCompositorLock() {
+ if (!compositor_lock_)
+ compositor_lock_ = new CompositorLock(this);
+ return compositor_lock_;
+}
+
void RootWindow::SetFocusWhenShown(bool focused) {
host_->SetFocusWhenShown(focused);
}
@@ -428,7 +468,9 @@ void RootWindow::SetTransform(const ui::Transform& transform) {
// RootWindow, ui::CompositorDelegate implementation:
void RootWindow::ScheduleDraw() {
- if (!defer_draw_scheduling_) {
+ if (compositor_lock_) {
+ draw_on_compositor_unlock_ = true;
+ } else if (!defer_draw_scheduling_) {
defer_draw_scheduling_ = true;
MessageLoop::current()->PostTask(
FROM_HERE,
@@ -825,4 +867,13 @@ void RootWindow::SynthesizeMouseMoveEvent() {
#endif
}
+void RootWindow::UnlockCompositor() {
+ DCHECK(compositor_lock_);
+ compositor_lock_ = NULL;
+ if (draw_on_compositor_unlock_) {
+ draw_on_compositor_unlock_ = false;
+ ScheduleDraw();
+ }
+}
+
} // namespace aura
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/gfx/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698