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

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: OSX compile fix. Created 8 years, 1 month 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
« no previous file with comments | « ui/aura/bench/bench_main.cc ('k') | ui/aura/root_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 class ViewProp; 43 class ViewProp;
44 } 44 }
45 45
46 namespace aura { 46 namespace aura {
47 47
48 class FocusManager; 48 class FocusManager;
49 class RootWindow; 49 class RootWindow;
50 class RootWindowHost; 50 class RootWindowHost;
51 class RootWindowObserver; 51 class RootWindowObserver;
52 52
53 // This class represents a lock on the compositor, that can be used to prevent a
54 // compositing pass from happening while we're waiting for an asynchronous
55 // event. The typical use case is when waiting for a renderer to produce a frame
56 // at the right size. The caller keeps a reference on this object, and drops the
57 // reference once it desires to release the lock.
58 // Note however that the lock is canceled after a short timeout to ensure
59 // responsiveness of the UI, so the compositor tree should be kept in a
60 // "reasonable" state while the lock is held.
61 // Don't instantiate this class directly, use RootWindow::GetCompositorLock.
62 class AURA_EXPORT CompositorLock
63 : public base::RefCounted<CompositorLock>,
64 public base::SupportsWeakPtr<CompositorLock> {
65 private:
66 friend class base::RefCounted<CompositorLock>;
67 friend class RootWindow;
68
69 explicit CompositorLock(RootWindow* root_window);
70 ~CompositorLock();
71
72 void CancelLock();
73
74 RootWindow* root_window_;
75 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
76 };
77
78 // RootWindow is responsible for hosting a set of windows. 53 // RootWindow is responsible for hosting a set of windows.
79 class AURA_EXPORT RootWindow : public ui::CompositorDelegate, 54 class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
80 public ui::CompositorObserver, 55 public ui::CompositorObserver,
81 public Window, 56 public Window,
82 public ui::EventDispatcher, 57 public ui::EventDispatcher,
83 public ui::GestureEventHelper, 58 public ui::GestureEventHelper,
84 public ui::LayerAnimationObserver, 59 public ui::LayerAnimationObserver,
85 public aura::client::CaptureDelegate, 60 public aura::client::CaptureDelegate,
86 public aura::RootWindowHostDelegate { 61 public aura::RootWindowHostDelegate {
87 public: 62 public:
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // These methods are used to defer the processing of mouse events related 203 // These methods are used to defer the processing of mouse events related
229 // to resize. A client (typically a RenderWidgetHostViewAura) can call 204 // to resize. A client (typically a RenderWidgetHostViewAura) can call
230 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves 205 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves
231 // once the resize is completed. 206 // once the resize is completed.
232 // 207 //
233 // More than one hold can be invoked and each hold must be cancelled by a 208 // More than one hold can be invoked and each hold must be cancelled by a
234 // release before we resume normal operation. 209 // release before we resume normal operation.
235 void HoldMouseMoves(); 210 void HoldMouseMoves();
236 void ReleaseMouseMoves(); 211 void ReleaseMouseMoves();
237 212
238 // Creates a compositor lock.
239 scoped_refptr<CompositorLock> GetCompositorLock();
240
241 // Sets if the window should be focused when shown. 213 // Sets if the window should be focused when shown.
242 void SetFocusWhenShown(bool focus_when_shown); 214 void SetFocusWhenShown(bool focus_when_shown);
243 215
244 // Grabs the snapshot of the root window by using the platform-dependent APIs. 216 // Grabs the snapshot of the root window by using the platform-dependent APIs.
245 bool GrabSnapshot(const gfx::Rect& snapshot_bounds, 217 bool GrabSnapshot(const gfx::Rect& snapshot_bounds,
246 std::vector<unsigned char>* png_representation); 218 std::vector<unsigned char>* png_representation);
247 219
248 // Gets the last location seen in a mouse event in this root window's 220 // Gets the last location seen in a mouse event in this root window's
249 // coordinates. This may return a point outside the root window's bounds. 221 // coordinates. This may return a point outside the root window's bounds.
250 gfx::Point GetLastMouseLocationInRoot() const; 222 gfx::Point GetLastMouseLocationInRoot() const;
251 223
252 // Overridden from Window: 224 // Overridden from Window:
253 virtual RootWindow* GetRootWindow() OVERRIDE; 225 virtual RootWindow* GetRootWindow() OVERRIDE;
254 virtual const RootWindow* GetRootWindow() const OVERRIDE; 226 virtual const RootWindow* GetRootWindow() const OVERRIDE;
255 virtual void SetTransform(const gfx::Transform& transform) OVERRIDE; 227 virtual void SetTransform(const gfx::Transform& transform) OVERRIDE;
256 228
257 // Overridden from ui::EventTarget: 229 // Overridden from ui::EventTarget:
258 virtual ui::EventTarget* GetParentTarget() OVERRIDE; 230 virtual ui::EventTarget* GetParentTarget() OVERRIDE;
259 231
260 // Overridden from ui::CompositorDelegate: 232 // Overridden from ui::CompositorDelegate:
261 virtual void ScheduleDraw() OVERRIDE; 233 virtual void ScheduleDraw() OVERRIDE;
262 234
263 // Overridden from ui::CompositorObserver: 235 // Overridden from ui::CompositorObserver:
264 virtual void OnCompositingDidCommit(ui::Compositor*) OVERRIDE; 236 virtual void OnCompositingDidCommit(ui::Compositor*) OVERRIDE;
265 virtual void OnCompositingWillStart(ui::Compositor*) OVERRIDE;
266 virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE; 237 virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE;
267 virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE; 238 virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE;
268 virtual void OnCompositingAborted(ui::Compositor*) OVERRIDE; 239 virtual void OnCompositingAborted(ui::Compositor*) OVERRIDE;
240 virtual void OnCompositingLockStateChanged(ui::Compositor*) OVERRIDE;
269 241
270 // Overridden from ui::LayerDelegate: 242 // Overridden from ui::LayerDelegate:
271 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; 243 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
272 244
273 // Overridden from Window: 245 // Overridden from Window:
274 virtual bool CanFocus() const OVERRIDE; 246 virtual bool CanFocus() const OVERRIDE;
275 virtual bool CanReceiveEvents() const OVERRIDE; 247 virtual bool CanReceiveEvents() const OVERRIDE;
276 virtual FocusManager* GetFocusManager() OVERRIDE; 248 virtual FocusManager* GetFocusManager() OVERRIDE;
277 249
278 // Overridden from aura::client::CaptureDelegate: 250 // Overridden from aura::client::CaptureDelegate:
279 virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE; 251 virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE;
280 virtual void SetNativeCapture() OVERRIDE; 252 virtual void SetNativeCapture() OVERRIDE;
281 virtual void ReleaseNativeCapture() OVERRIDE; 253 virtual void ReleaseNativeCapture() OVERRIDE;
282 254
283 // Exposes RootWindowHost::QueryMouseLocation() for test purposes. 255 // Exposes RootWindowHost::QueryMouseLocation() for test purposes.
284 gfx::Point QueryMouseLocationForTest() const; 256 gfx::Point QueryMouseLocationForTest() const;
285 257
286 private: 258 private:
287 friend class Window; 259 friend class Window;
288 friend class CompositorLock;
289 260
290 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, 261 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
291 // sending exited and entered events as its value changes. 262 // sending exited and entered events as its value changes.
292 void HandleMouseMoved(const ui::MouseEvent& event, Window* target); 263 void HandleMouseMoved(const ui::MouseEvent& event, Window* target);
293 264
294 bool ProcessMouseEvent(Window* target, ui::MouseEvent* event); 265 bool ProcessMouseEvent(Window* target, ui::MouseEvent* event);
295 bool ProcessKeyEvent(Window* target, ui::KeyEvent* event); 266 bool ProcessKeyEvent(Window* target, ui::KeyEvent* event);
296 ui::EventResult ProcessTouchEvent(Window* target, ui::TouchEvent* event); 267 ui::EventResult ProcessTouchEvent(Window* target, ui::TouchEvent* event);
297 ui::EventResult ProcessGestureEvent(Window* target, 268 ui::EventResult ProcessGestureEvent(Window* target,
298 ui::GestureEvent* event); 269 ui::GestureEvent* event);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 gfx::Rect GetInitialHostWindowBounds() const; 325 gfx::Rect GetInitialHostWindowBounds() const;
355 326
356 // Posts a task to send synthesized mouse move event if there 327 // Posts a task to send synthesized mouse move event if there
357 // is no a pending task. 328 // is no a pending task.
358 void PostMouseMoveEventAfterWindowChange(); 329 void PostMouseMoveEventAfterWindowChange();
359 330
360 // Creates and dispatches synthesized mouse move event using the 331 // Creates and dispatches synthesized mouse move event using the
361 // current mouse location. 332 // current mouse location.
362 void SynthesizeMouseMoveEvent(); 333 void SynthesizeMouseMoveEvent();
363 334
364 // Called by CompositorLock.
365 void UnlockCompositor();
366
367 scoped_ptr<ui::Compositor> compositor_; 335 scoped_ptr<ui::Compositor> compositor_;
368 336
369 scoped_ptr<RootWindowHost> host_; 337 scoped_ptr<RootWindowHost> host_;
370 338
371 // Used to schedule painting. 339 // Used to schedule painting.
372 base::WeakPtrFactory<RootWindow> schedule_paint_factory_; 340 base::WeakPtrFactory<RootWindow> schedule_paint_factory_;
373 341
374 // Use to post mouse move event. 342 // Use to post mouse move event.
375 base::WeakPtrFactory<RootWindow> event_factory_; 343 base::WeakPtrFactory<RootWindow> event_factory_;
376 344
(...skipping 26 matching lines...) Expand all
403 // How many holds are outstanding. We try to defer dispatching mouse moves 371 // How many holds are outstanding. We try to defer dispatching mouse moves
404 // while the count is > 0. 372 // while the count is > 0.
405 int mouse_move_hold_count_; 373 int mouse_move_hold_count_;
406 scoped_ptr<ui::MouseEvent> held_mouse_move_; 374 scoped_ptr<ui::MouseEvent> held_mouse_move_;
407 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes 375 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes
408 // to 0. 376 // to 0.
409 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_; 377 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_;
410 378
411 scoped_ptr<ui::ViewProp> prop_; 379 scoped_ptr<ui::ViewProp> prop_;
412 380
413 CompositorLock* compositor_lock_;
414 bool draw_on_compositor_unlock_;
415
416 DISALLOW_COPY_AND_ASSIGN(RootWindow); 381 DISALLOW_COPY_AND_ASSIGN(RootWindow);
417 }; 382 };
418 383
419 } // namespace aura 384 } // namespace aura
420 385
421 #endif // UI_AURA_ROOT_WINDOW_H_ 386 #endif // UI_AURA_ROOT_WINDOW_H_
OLDNEW
« no previous file with comments | « ui/aura/bench/bench_main.cc ('k') | ui/aura/root_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698