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

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

Issue 10690168: Aura: Resize locks with --ui-enable-threaded-compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New approach. Created 8 years, 4 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 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 30 matching lines...) Expand all
41 class FocusManager; 41 class FocusManager;
42 class GestureEvent; 42 class GestureEvent;
43 class KeyEvent; 43 class KeyEvent;
44 class MouseEvent; 44 class MouseEvent;
45 class RootWindow; 45 class RootWindow;
46 class RootWindowHost; 46 class RootWindowHost;
47 class RootWindowObserver; 47 class RootWindowObserver;
48 class ScrollEvent; 48 class ScrollEvent;
49 class TouchEvent; 49 class TouchEvent;
50 50
51 // This class represents a lock on the compositor, that can be used to prevent a
52 // compositing pass from happening while we're waiting for an asynchronous
53 // event. The typical use case is when waiting for a renderer to produce a frame
54 // at the right size. The caller keeps a reference on this object, and drops the
55 // reference once it desires to release the lock.
56 // Note however that the lock is canceled after a short timeout to ensure
57 // responsiveness of the UI, so the compositor tree should be kept in a
58 // "reasonable" state while the lock is held.
59 // Don't instantiate this class directly, use RootWindow::GetCompositorLock.
60 class AURA_EXPORT CompositorLock
61 : public base::RefCounted<CompositorLock>,
62 public base::SupportsWeakPtr<CompositorLock> {
63 private:
64 friend class base::RefCounted<CompositorLock>;
65 friend class RootWindow;
66
67 explicit CompositorLock(RootWindow* root_window);
68 ~CompositorLock();
69
70 void CancelLock();
71
72 RootWindow* root_window_;
73 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
74 };
75
76 // RootWindow is responsible for hosting a set of windows. 51 // RootWindow is responsible for hosting a set of windows.
77 class AURA_EXPORT RootWindow : public ui::CompositorDelegate, 52 class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
78 public ui::CompositorObserver, 53 public ui::CompositorObserver,
79 public Window, 54 public Window,
80 public ui::GestureEventHelper, 55 public ui::GestureEventHelper,
81 public ui::LayerAnimationObserver, 56 public ui::LayerAnimationObserver,
82 public aura::client::CaptureDelegate, 57 public aura::client::CaptureDelegate,
83 public aura::RootWindowHostDelegate { 58 public aura::RootWindowHostDelegate {
84 public: 59 public:
85 explicit RootWindow(const gfx::Rect& initial_bounds); 60 explicit RootWindow(const gfx::Rect& initial_bounds);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // These methods are used to defer the processing of mouse events related 184 // These methods are used to defer the processing of mouse events related
210 // to resize. A client (typically a RenderWidgetHostViewAura) can call 185 // to resize. A client (typically a RenderWidgetHostViewAura) can call
211 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves 186 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves
212 // once the resize is completed. 187 // once the resize is completed.
213 // 188 //
214 // More than one hold can be invoked and each hold must be cancelled by a 189 // More than one hold can be invoked and each hold must be cancelled by a
215 // release before we resume normal operation. 190 // release before we resume normal operation.
216 void HoldMouseMoves(); 191 void HoldMouseMoves();
217 void ReleaseMouseMoves(); 192 void ReleaseMouseMoves();
218 193
219 // Creates a compositor lock.
220 scoped_refptr<CompositorLock> GetCompositorLock();
221
222 // Sets if the window should be focused when shown. 194 // Sets if the window should be focused when shown.
223 void SetFocusWhenShown(bool focus_when_shown); 195 void SetFocusWhenShown(bool focus_when_shown);
224 196
225 // Grabs the snapshot of the root window by using the platform-dependent APIs. 197 // Grabs the snapshot of the root window by using the platform-dependent APIs.
226 bool GrabSnapshot(const gfx::Rect& snapshot_bounds, 198 bool GrabSnapshot(const gfx::Rect& snapshot_bounds,
227 std::vector<unsigned char>* png_representation); 199 std::vector<unsigned char>* png_representation);
228 200
229 // Gets the last location seen in a mouse event in this root window's 201 // Gets the last location seen in a mouse event in this root window's
230 // coordinates. This may return a point outside the root window's bounds. 202 // coordinates. This may return a point outside the root window's bounds.
231 gfx::Point GetLastMouseLocationInRoot() const; 203 gfx::Point GetLastMouseLocationInRoot() const;
232 204
233 // Overridden from Window: 205 // Overridden from Window:
234 virtual RootWindow* GetRootWindow() OVERRIDE; 206 virtual RootWindow* GetRootWindow() OVERRIDE;
235 virtual const RootWindow* GetRootWindow() const OVERRIDE; 207 virtual const RootWindow* GetRootWindow() const OVERRIDE;
236 virtual void SetTransform(const ui::Transform& transform) OVERRIDE; 208 virtual void SetTransform(const ui::Transform& transform) OVERRIDE;
237 209
238 // Overridden from ui::CompositorDelegate: 210 // Overridden from ui::CompositorDelegate:
239 virtual void ScheduleDraw() OVERRIDE; 211 virtual void ScheduleDraw() OVERRIDE;
240 212
241 // Overridden from ui::CompositorObserver: 213 // Overridden from ui::CompositorObserver:
242 virtual void OnCompositingDidCommit(ui::Compositor*) OVERRIDE;
243 virtual void OnCompositingWillStart(ui::Compositor*) OVERRIDE;
244 virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE; 214 virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE;
245 virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE; 215 virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE;
246 virtual void OnCompositingAborted(ui::Compositor*) OVERRIDE; 216 virtual void OnCompositingAborted(ui::Compositor*) OVERRIDE;
247 217
248 // Overridden from ui::LayerDelegate: 218 // Overridden from ui::LayerDelegate:
249 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; 219 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
250 220
251 // Overridden from Window: 221 // Overridden from Window:
252 virtual bool CanFocus() const OVERRIDE; 222 virtual bool CanFocus() const OVERRIDE;
253 virtual bool CanReceiveEvents() const OVERRIDE; 223 virtual bool CanReceiveEvents() const OVERRIDE;
254 virtual FocusManager* GetFocusManager() OVERRIDE; 224 virtual FocusManager* GetFocusManager() OVERRIDE;
255 225
256 // Overridden from aura::client::CaptureDelegate: 226 // Overridden from aura::client::CaptureDelegate:
257 virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE; 227 virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE;
258 virtual void SetNativeCapture() OVERRIDE; 228 virtual void SetNativeCapture() OVERRIDE;
259 virtual void ReleaseNativeCapture() OVERRIDE; 229 virtual void ReleaseNativeCapture() OVERRIDE;
260 230
261 // Exposes RootWindowHost::QueryMouseLocation() for test purposes. 231 // Exposes RootWindowHost::QueryMouseLocation() for test purposes.
262 gfx::Point QueryMouseLocationForTest() const; 232 gfx::Point QueryMouseLocationForTest() const;
263 233
264 private: 234 private:
265 friend class Window; 235 friend class Window;
266 friend class CompositorLock;
267 236
268 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, 237 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
269 // sending exited and entered events as its value changes. 238 // sending exited and entered events as its value changes.
270 void HandleMouseMoved(const MouseEvent& event, Window* target); 239 void HandleMouseMoved(const MouseEvent& event, Window* target);
271 240
272 bool ProcessMouseEvent(Window* target, MouseEvent* event); 241 bool ProcessMouseEvent(Window* target, MouseEvent* event);
273 bool ProcessKeyEvent(Window* target, KeyEvent* event); 242 bool ProcessKeyEvent(Window* target, KeyEvent* event);
274 ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event); 243 ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event);
275 ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event); 244 ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event);
276 bool ProcessGestures(ui::GestureRecognizer::Gestures* gestures); 245 bool ProcessGestures(ui::GestureRecognizer::Gestures* gestures);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 gfx::Rect GetInitialHostWindowBounds() const; 304 gfx::Rect GetInitialHostWindowBounds() const;
336 305
337 // Posts a task to send synthesized mouse move event if there 306 // Posts a task to send synthesized mouse move event if there
338 // is no a pending task. 307 // is no a pending task.
339 void PostMouseMoveEventAfterWindowChange(); 308 void PostMouseMoveEventAfterWindowChange();
340 309
341 // Creates and dispatches synthesized mouse move event using the 310 // Creates and dispatches synthesized mouse move event using the
342 // current mouse location. 311 // current mouse location.
343 void SynthesizeMouseMoveEvent(); 312 void SynthesizeMouseMoveEvent();
344 313
345 // Called by CompositorLock.
346 void UnlockCompositor();
347
348 scoped_ptr<ui::Compositor> compositor_; 314 scoped_ptr<ui::Compositor> compositor_;
349 315
350 scoped_ptr<RootWindowHost> host_; 316 scoped_ptr<RootWindowHost> host_;
351 317
352 // If set before the RootWindow is created, the cursor will be drawn within 318 // If set before the RootWindow is created, the cursor will be drawn within
353 // the Aura root window but hidden outside of it, and it'll remain hidden 319 // the Aura root window but hidden outside of it, and it'll remain hidden
354 // after the Aura window is closed. 320 // after the Aura window is closed.
355 static bool hide_host_cursor_; 321 static bool hide_host_cursor_;
356 322
357 // Used to schedule painting. 323 // Used to schedule painting.
(...skipping 30 matching lines...) Expand all
388 bool defer_draw_scheduling_; 354 bool defer_draw_scheduling_;
389 355
390 // How many holds are outstanding. We try to defer dispatching mouse moves 356 // How many holds are outstanding. We try to defer dispatching mouse moves
391 // while the count is > 0. 357 // while the count is > 0.
392 int mouse_move_hold_count_; 358 int mouse_move_hold_count_;
393 scoped_ptr<MouseEvent> held_mouse_move_; 359 scoped_ptr<MouseEvent> held_mouse_move_;
394 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes 360 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes
395 // to 0. 361 // to 0.
396 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_; 362 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_;
397 363
398 CompositorLock* compositor_lock_;
399 bool draw_on_compositor_unlock_;
400
401 DISALLOW_COPY_AND_ASSIGN(RootWindow); 364 DISALLOW_COPY_AND_ASSIGN(RootWindow);
402 }; 365 };
403 366
404 } // namespace aura 367 } // namespace aura
405 368
406 #endif // UI_AURA_ROOT_WINDOW_H_ 369 #endif // UI_AURA_ROOT_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698