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

Unified Diff: ui/compositor/compositor.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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698