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

Side by Side Diff: ui/aura/root_window.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_AURA_ROOT_WINDOW_H_ 5 #ifndef UI_AURA_ROOT_WINDOW_H_
6 #define UI_AURA_ROOT_WINDOW_H_ 6 #define UI_AURA_ROOT_WINDOW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h" 13 #include "base/message_loop.h"
13 #include "ui/aura/aura_export.h" 14 #include "ui/aura/aura_export.h"
14 #include "ui/aura/cursor.h" 15 #include "ui/aura/cursor.h"
15 #include "ui/aura/focus_manager.h" 16 #include "ui/aura/focus_manager.h"
16 #include "ui/aura/gestures/gesture_recognizer.h" 17 #include "ui/aura/gestures/gesture_recognizer.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/base/events.h" 19 #include "ui/base/events.h"
19 #include "ui/gfx/compositor/compositor.h" 20 #include "ui/gfx/compositor/compositor.h"
20 #include "ui/gfx/compositor/compositor_observer.h" 21 #include "ui/gfx/compositor/compositor_observer.h"
21 #include "ui/gfx/compositor/layer_animation_observer.h" 22 #include "ui/gfx/compositor/layer_animation_observer.h"
22 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
23 #include "ui/gfx/point.h" 24 #include "ui/gfx/point.h"
24 25
25 namespace gfx { 26 namespace gfx {
26 class Size; 27 class Size;
27 } 28 }
28 29
29 namespace ui { 30 namespace ui {
30 class LayerAnimationSequence; 31 class LayerAnimationSequence;
31 class Transform; 32 class Transform;
32 } 33 }
33 34
34 namespace aura { 35 namespace aura {
35 36
37 class RootWindow;
36 class RootWindowHost; 38 class RootWindowHost;
37 class RootWindowObserver; 39 class RootWindowObserver;
38 class KeyEvent; 40 class KeyEvent;
39 class MouseEvent; 41 class MouseEvent;
40 class StackingClient; 42 class StackingClient;
41 class ScrollEvent; 43 class ScrollEvent;
42 class TouchEvent; 44 class TouchEvent;
43 class GestureEvent; 45 class GestureEvent;
44 46
47 // This class represents a lock on the compositor, that can be used to prevent a
48 // compositing pass from happening while we're waiting for an asynchronous
49 // event. The typical use case is when waiting for a renderer to produce a frame
50 // at the right size. The caller keeps a reference on this object, and drops the
51 // reference once it desires to release the lock.
52 // Note however that the lock is canceled after a short timeout to ensure
53 // responsiveness of the UI, so the compositor tree should be kept in a
54 // "reasonable" state while the lock is held.
55 // Don't instantiate this class directly, use RootWindow::GetCompositorLock.
56 class CompositorLock :
57 public base::RefCounted<CompositorLock>,
58 public base::SupportsWeakPtr<CompositorLock> {
59 public:
60 ~CompositorLock();
61
62 private:
63 friend class RootWindow;
64
65 CompositorLock(RootWindow* root_window);
66 void CancelLock();
67
68 RootWindow* root_window_;
69 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
70 };
71
45 // RootWindow is responsible for hosting a set of windows. 72 // RootWindow is responsible for hosting a set of windows.
46 class AURA_EXPORT RootWindow : public ui::CompositorDelegate, 73 class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
47 public ui::CompositorObserver, 74 public ui::CompositorObserver,
48 public Window, 75 public Window,
49 public internal::FocusManager, 76 public internal::FocusManager,
50 public ui::LayerAnimationObserver { 77 public ui::LayerAnimationObserver {
51 public: 78 public:
52 explicit RootWindow(const gfx::Rect& initial_bounds); 79 explicit RootWindow(const gfx::Rect& initial_bounds);
53 virtual ~RootWindow(); 80 virtual ~RootWindow();
54 81
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // These methods are used to defer the processing of mouse events related 209 // These methods are used to defer the processing of mouse events related
183 // to resize. A client (typically a RenderWidgetHostViewAura) can call 210 // to resize. A client (typically a RenderWidgetHostViewAura) can call
184 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves 211 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves
185 // once the resize is completed. 212 // once the resize is completed.
186 // 213 //
187 // More than one hold can be invoked and each hold must be cancelled by a 214 // More than one hold can be invoked and each hold must be cancelled by a
188 // release before we resume normal operation. 215 // release before we resume normal operation.
189 void HoldMouseMoves(); 216 void HoldMouseMoves();
190 void ReleaseMouseMoves(); 217 void ReleaseMouseMoves();
191 218
219 // Creates a compositor lock.
220 scoped_refptr<CompositorLock> GetCompositorLock();
221
192 // Overridden from Window: 222 // Overridden from Window:
193 virtual RootWindow* GetRootWindow() OVERRIDE; 223 virtual RootWindow* GetRootWindow() OVERRIDE;
194 virtual const RootWindow* GetRootWindow() const OVERRIDE; 224 virtual const RootWindow* GetRootWindow() const OVERRIDE;
195 virtual void SetTransform(const ui::Transform& transform) OVERRIDE; 225 virtual void SetTransform(const ui::Transform& transform) OVERRIDE;
196 226
197 // Overridden from ui::CompositorDelegate: 227 // Overridden from ui::CompositorDelegate:
198 virtual void ScheduleDraw() OVERRIDE; 228 virtual void ScheduleDraw() OVERRIDE;
199 229
200 // Overridden from ui::CompositorObserver: 230 // Overridden from ui::CompositorObserver:
201 virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE; 231 virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE;
202 virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE; 232 virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE;
203 233
204 private: 234 private:
205 friend class Window; 235 friend class Window;
236 friend class CompositorLock;
206 237
207 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, 238 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
208 // sending exited and entered events as its value changes. 239 // sending exited and entered events as its value changes.
209 void HandleMouseMoved(const MouseEvent& event, Window* target); 240 void HandleMouseMoved(const MouseEvent& event, Window* target);
210 241
211 // Called whenever the |capture_window_| changes. 242 // Called whenever the |capture_window_| changes.
212 // Sends capture changed events to event filters for old capture window. 243 // Sends capture changed events to event filters for old capture window.
213 void HandleMouseCaptureChanged(Window* old_capture_window); 244 void HandleMouseCaptureChanged(Window* old_capture_window);
214 245
215 bool ProcessMouseEvent(Window* target, MouseEvent* event); 246 bool ProcessMouseEvent(Window* target, MouseEvent* event);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 gfx::Rect GetInitialHostWindowBounds() const; 292 gfx::Rect GetInitialHostWindowBounds() const;
262 293
263 // Posts a task to send synthesized mouse move event if there 294 // Posts a task to send synthesized mouse move event if there
264 // is no a pending task. 295 // is no a pending task.
265 void PostMouseMoveEventAfterWindowChange(); 296 void PostMouseMoveEventAfterWindowChange();
266 297
267 // Creates and dispatches synthesized mouse move event using the 298 // Creates and dispatches synthesized mouse move event using the
268 // current mouse location. 299 // current mouse location.
269 void SynthesizeMouseMoveEvent(); 300 void SynthesizeMouseMoveEvent();
270 301
302 // Called by CompositorLock.
303 void UnlockCompositor();
304
271 scoped_ptr<ui::Compositor> compositor_; 305 scoped_ptr<ui::Compositor> compositor_;
272 306
273 scoped_ptr<RootWindowHost> host_; 307 scoped_ptr<RootWindowHost> host_;
274 308
275 // If set before the RootWindow is created, the cursor will be drawn within 309 // If set before the RootWindow is created, the cursor will be drawn within
276 // the Aura root window but hidden outside of it, and it'll remain hidden 310 // the Aura root window but hidden outside of it, and it'll remain hidden
277 // after the Aura window is closed. 311 // after the Aura window is closed.
278 static bool hide_host_cursor_; 312 static bool hide_host_cursor_;
279 313
280 // Used to schedule painting. 314 // Used to schedule painting.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 bool draw_on_compositing_end_; 347 bool draw_on_compositing_end_;
314 348
315 bool defer_draw_scheduling_; 349 bool defer_draw_scheduling_;
316 350
317 // How many holds are outstanding. We try to defer dispatching mouse moves 351 // How many holds are outstanding. We try to defer dispatching mouse moves
318 // while the count is > 0. 352 // while the count is > 0.
319 int mouse_move_hold_count_; 353 int mouse_move_hold_count_;
320 bool should_hold_mouse_moves_; 354 bool should_hold_mouse_moves_;
321 scoped_ptr<MouseEvent> held_mouse_move_; 355 scoped_ptr<MouseEvent> held_mouse_move_;
322 356
357 CompositorLock* compositor_lock_;
358 bool scheduled_while_locked_;
359
323 DISALLOW_COPY_AND_ASSIGN(RootWindow); 360 DISALLOW_COPY_AND_ASSIGN(RootWindow);
324 }; 361 };
325 362
326 } // namespace aura 363 } // namespace aura
327 364
328 #endif // UI_AURA_ROOT_WINDOW_H_ 365 #endif // UI_AURA_ROOT_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698