| Index: ui/compositor/compositor.h
|
| diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
|
| index c5dc3ba076a19d948fe0e2a811291ea65d0cd9d9..f3720bce3cd7a3b81c6e9ceb54bfb3c71720eb16 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
|
| +// commits 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 cancelled 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
|
| @@ -196,9 +222,9 @@ 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. Returns NULL if it is not possible to lock at
|
| + // this time (i.e. we're waiting to complete a previous unlock).
|
| + scoped_refptr<CompositorLock> GetCompositorLock();
|
|
|
| // Internal functions, called back by command-buffer contexts on swap buffer
|
| // events.
|
| @@ -227,8 +253,17 @@ class COMPOSITOR_EXPORT Compositor
|
| int last_started_frame() { return last_started_frame_; }
|
| int last_ended_frame() { return last_ended_frame_; }
|
|
|
| + bool IsLocked() { return compositor_lock_ != NULL; }
|
| +
|
| private:
|
| friend class base::RefCounted<Compositor>;
|
| + friend class CompositorLock;
|
| +
|
| + // Called by CompositorLock.
|
| + void UnlockCompositor();
|
| +
|
| + // Called to release any pending CompositorLock
|
| + void CancelCompositorLock();
|
|
|
| // Notifies the compositor that compositing is complete.
|
| void NotifyEnd();
|
| @@ -258,6 +293,8 @@ class COMPOSITOR_EXPORT Compositor
|
|
|
| bool disable_schedule_composite_;
|
|
|
| + CompositorLock* compositor_lock_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(Compositor);
|
| };
|
|
|
|
|