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

Side by Side Diff: ui/compositor/compositor.h

Issue 996453002: Allow ui::Compositor to disable commits during tab-switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up version Created 5 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
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_COMPOSITOR_COMPOSITOR_H_ 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_
6 #define UI_COMPOSITOR_COMPOSITOR_H_ 6 #define UI_COMPOSITOR_COMPOSITOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Resize the display corresponding to this compositor to a particular size. 104 // Resize the display corresponding to this compositor to a particular size.
105 virtual void ResizeDisplay(ui::Compositor* compositor, 105 virtual void ResizeDisplay(ui::Compositor* compositor,
106 const gfx::Size& size) = 0; 106 const gfx::Size& size) = 0;
107 }; 107 };
108 108
109 // This class represents a lock on the compositor, that can be used to prevent 109 // This class represents a lock on the compositor, that can be used to prevent
110 // commits to the compositor tree while we're waiting for an asynchronous 110 // commits to the compositor tree while we're waiting for an asynchronous
111 // event. The typical use case is when waiting for a renderer to produce a frame 111 // event. The typical use case is when waiting for a renderer to produce a frame
112 // at the right size. The caller keeps a reference on this object, and drops the 112 // at the right size. The caller keeps a reference on this object, and drops the
113 // reference once it desires to release the lock. 113 // reference once it desires to release the lock.
114 // Note however that the lock is cancelled after a short timeout to ensure 114 // By default, the lock will be cancelled after a short timeout to ensure
115 // responsiveness of the UI, so the compositor tree should be kept in a 115 // responsiveness of the UI, so the compositor tree should be kept in a
116 // "reasonable" state while the lock is held. 116 // "reasonable" state while the lock is held. If the compositor sets
117 // locks to not time out, then the lock will remain in effect until destroyed.
117 // Don't instantiate this class directly, use Compositor::GetCompositorLock. 118 // Don't instantiate this class directly, use Compositor::GetCompositorLock.
118 class COMPOSITOR_EXPORT CompositorLock 119 class COMPOSITOR_EXPORT CompositorLock
119 : public base::RefCounted<CompositorLock>, 120 : public base::RefCounted<CompositorLock>,
120 public base::SupportsWeakPtr<CompositorLock> { 121 public base::SupportsWeakPtr<CompositorLock> {
121 private: 122 private:
122 friend class base::RefCounted<CompositorLock>; 123 friend class base::RefCounted<CompositorLock>;
123 friend class Compositor; 124 friend class Compositor;
124 125
125 explicit CompositorLock(Compositor* compositor); 126 explicit CompositorLock(Compositor* compositor);
126 ~CompositorLock(); 127 ~CompositorLock();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Compositor does not own observers. It is the responsibility of the 220 // Compositor does not own observers. It is the responsibility of the
220 // observer to remove itself when it is done observing. 221 // observer to remove itself when it is done observing.
221 void AddObserver(CompositorObserver* observer); 222 void AddObserver(CompositorObserver* observer);
222 void RemoveObserver(CompositorObserver* observer); 223 void RemoveObserver(CompositorObserver* observer);
223 bool HasObserver(const CompositorObserver* observer) const; 224 bool HasObserver(const CompositorObserver* observer) const;
224 225
225 void AddAnimationObserver(CompositorAnimationObserver* observer); 226 void AddAnimationObserver(CompositorAnimationObserver* observer);
226 void RemoveAnimationObserver(CompositorAnimationObserver* observer); 227 void RemoveAnimationObserver(CompositorAnimationObserver* observer);
227 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const; 228 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const;
228 229
230 // Change the timeout behavior for all future locks that are created. Locks
231 // should time out if there is an expectation that the compositor will be
232 // responsive.
233 void SetLocksWillTimeOut(bool locks_will_time_out) {
234 locks_will_time_out_ = locks_will_time_out;
235 }
236
229 // Creates a compositor lock. Returns NULL if it is not possible to lock at 237 // Creates a compositor lock. Returns NULL if it is not possible to lock at
230 // this time (i.e. we're waiting to complete a previous unlock). 238 // this time (i.e. we're waiting to complete a previous unlock).
231 scoped_refptr<CompositorLock> GetCompositorLock(); 239 scoped_refptr<CompositorLock> GetCompositorLock();
232 240
233 // Internal functions, called back by command-buffer contexts on swap buffer 241 // Internal functions, called back by command-buffer contexts on swap buffer
234 // events. 242 // events.
235 243
236 // Signals swap has been posted. 244 // Signals swap has been posted.
237 void OnSwapBuffersPosted(); 245 void OnSwapBuffersPosted();
238 246
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // The manager of vsync parameters for this compositor. 320 // The manager of vsync parameters for this compositor.
313 scoped_refptr<CompositorVSyncManager> vsync_manager_; 321 scoped_refptr<CompositorVSyncManager> vsync_manager_;
314 322
315 // The device scale factor of the monitor that this compositor is compositing 323 // The device scale factor of the monitor that this compositor is compositing
316 // layers on. 324 // layers on.
317 float device_scale_factor_; 325 float device_scale_factor_;
318 326
319 int last_started_frame_; 327 int last_started_frame_;
320 int last_ended_frame_; 328 int last_ended_frame_;
321 329
322 bool disable_schedule_composite_; 330 bool locks_will_time_out_;
323
324 CompositorLock* compositor_lock_; 331 CompositorLock* compositor_lock_;
325 332
326 LayerAnimatorCollection layer_animator_collection_; 333 LayerAnimatorCollection layer_animator_collection_;
327 334
328 base::WeakPtrFactory<Compositor> weak_ptr_factory_; 335 base::WeakPtrFactory<Compositor> weak_ptr_factory_;
329 336
330 DISALLOW_COPY_AND_ASSIGN(Compositor); 337 DISALLOW_COPY_AND_ASSIGN(Compositor);
331 }; 338 };
332 339
333 } // namespace ui 340 } // namespace ui
334 341
335 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 342 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698