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

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: 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
Index: ui/aura/root_window.cc
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 1ba6b1d93b9b98fb02ac59e6a58dc83d1f7f1223..b525f7140dd9db7e5a9ce387fa41ed76e76182cc 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -53,8 +53,28 @@ 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();
jonathan.backer 2012/03/23 15:48:00 I think that you want to "root_window_ = NULL" her
piman 2012/03/23 17:41:09 Thanks for paying attention! You're absolutely rig
+}
+
bool RootWindow::hide_host_cursor_ = false;
////////////////////////////////////////////////////////////////////////////////
@@ -79,7 +99,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),
+ scheduled_while_locked_(false) {
SetName("RootWindow");
last_mouse_location_ = host_->QueryMouseLocation();
@@ -94,6 +116,12 @@ RootWindow::RootWindow(const gfx::Rect& initial_bounds)
}
RootWindow::~RootWindow() {
+ if (compositor_lock_) {
+ // No need to schedule a draw, we're going away.
+ scheduled_while_locked_ = 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.
@@ -162,6 +190,11 @@ void RootWindow::Draw() {
defer_draw_scheduling_ = false;
return;
}
+ if (compositor_lock_) {
+ scheduled_while_locked_ = true;
jonathan.backer 2012/03/23 15:48:00 nit: is it conceivable that the draw task had been
piman 2012/03/23 17:41:09 Yes (imagine a caller doing ScheduleDraw() then Ge
+ defer_draw_scheduling_ = false;
+ return;
+ }
waiting_on_compositing_end_ = true;
compositor_->Draw(false);
@@ -394,6 +427,12 @@ void RootWindow::ReleaseMouseMoves() {
}
}
+scoped_refptr<CompositorLock> RootWindow::GetCompositorLock() {
+ if (!compositor_lock_)
+ compositor_lock_ = new CompositorLock(this);
+ return compositor_lock_;
+}
+
////////////////////////////////////////////////////////////////////////////////
// RootWindow, Window overrides:
@@ -418,7 +457,9 @@ void RootWindow::SetTransform(const ui::Transform& transform) {
// RootWindow, ui::CompositorDelegate implementation:
void RootWindow::ScheduleDraw() {
- if (!defer_draw_scheduling_) {
+ if (compositor_lock_) {
+ scheduled_while_locked_ = true;
+ } else if (!defer_draw_scheduling_) {
defer_draw_scheduling_ = true;
MessageLoop::current()->PostTask(
FROM_HERE,
@@ -815,4 +856,13 @@ void RootWindow::SynthesizeMouseMoveEvent() {
#endif
}
+void RootWindow::UnlockCompositor() {
+ DCHECK(compositor_lock_);
+ compositor_lock_ = NULL;
+ if (scheduled_while_locked_) {
+ scheduled_while_locked_ = false;
+ ScheduleDraw();
+ }
+}
+
} // namespace aura

Powered by Google App Engine
This is Rietveld 408576698