Index: ui/compositor/compositor.h |
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h |
index ea5772480c321aaa0cc6146331827bcf56d675cf..756cd1674cff4d00cffa751c9210cd274a87bab7 100644 |
--- a/ui/compositor/compositor.h |
+++ b/ui/compositor/compositor.h |
@@ -126,6 +126,32 @@ class COMPOSITOR_EXPORT CompositorDelegate { |
virtual ~CompositorDelegate() {} |
}; |
+// This class represents a lock on the compositor, that can be used to prevent a |
+// updates to the compositor tree while we're waiting for an asynchronous |
+// event. The typical use case is when waiting for a renderer to produce a frame |
+// at the right size. The caller keeps a reference on this object, and drops the |
+// reference once it desires to release the lock. |
+// Note however that the lock is canceled after a short timeout to ensure |
+// responsiveness of the UI, so the compositor tree should be kept in a |
+// "reasonable" state while the lock is held. |
+// Don't instantiate this class directly, use Compositor::GetCompositorLock. |
+class COMPOSITOR_EXPORT CompositorLock |
+ : public base::RefCounted<CompositorLock>, |
+ public base::SupportsWeakPtr<CompositorLock> { |
+ private: |
+ friend class base::RefCounted<CompositorLock>; |
+ friend class Compositor; |
+ |
+ explicit CompositorLock(Compositor* compositor); |
+ ~CompositorLock(); |
+ |
+ void CancelLock(); |
+ |
+ Compositor* compositor_; |
+ DISALLOW_COPY_AND_ASSIGN(CompositorLock); |
+}; |
+ |
+ |
// Compositor object to take care of GPU painting. |
// A Browser compositor object is responsible for generating the final |
// displayable form of pixels comprising a single widget's contents. It draws an |
@@ -191,9 +217,8 @@ class COMPOSITOR_EXPORT Compositor |
// and the OnCompositingEnded. |
bool DrawPending() const { return swap_posted_; } |
- // Returns whether the drawing is issued from a separate thread |
- // (i.e. |Compositor::Initialize(true)| was called). |
- bool IsThreaded() const; |
+ // Creates a compositor lock. |
+ scoped_refptr<CompositorLock> GetCompositorLock(); |
// Internal functions, called back by command-buffer contexts on swap buffer |
// events. |
@@ -221,9 +246,14 @@ class COMPOSITOR_EXPORT Compositor |
int last_started_frame() { return last_started_frame_; } |
int last_ended_frame() { return last_ended_frame_; } |
+ int last_commit_id() { return last_commit_id_; } |
private: |
friend class base::RefCounted<Compositor>; |
+ friend class CompositorLock; |
+ |
+ // Called by CompositorLock. |
+ void Unlock(); |
// When reading back pixel data we often get RGBA rather than BGRA pixels and |
// and the image often needs to be flipped vertically. |
@@ -256,8 +286,25 @@ class COMPOSITOR_EXPORT Compositor |
int last_started_frame_; |
int last_ended_frame_; |
+ int last_commit_id_; |
+ |
bool disable_schedule_composite_; |
+ enum UpdatesAllowedState { |
+ // We've told |root_layer_| to enable updates, but no update has cleared. |
piman
2012/07/31 23:42:17
"update" is a very overloaded term... Should we us
jonathan.backer
2012/08/01 17:22:43
Done.
|
+ ENABLED_NEEDS_UPDATE, |
+ // We've updated since being enabled. |
+ ENABLED_DID_UPDATE, |
+ // We will tell |root_layer_| to defer updates once an update clears. |
+ DISABLED_PENDING_UPDATE, |
+ // We told |root_layer_| to disable updates. |
+ DISABLED, |
+ }; |
+ |
+ int updates_allowed_; |
piman
2012/07/31 23:42:17
UpdatesAllowedState instead of int?
jonathan.backer
2012/08/01 17:22:43
Done.
|
+ |
+ CompositorLock* compositor_lock_; |
+ |
DISALLOW_COPY_AND_ASSIGN(Compositor); |
}; |