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

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: Converging... Created 8 years, 5 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
Index: ui/compositor/compositor.h
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
index ea5772480c321aaa0cc6146331827bcf56d675cf..afb67c4380e430f5e63b12c5f705463fa3167ceb 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 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
@@ -195,6 +221,9 @@ class COMPOSITOR_EXPORT Compositor
// (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.
@@ -224,6 +253,10 @@ class COMPOSITOR_EXPORT Compositor
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.
@@ -258,6 +291,21 @@ class COMPOSITOR_EXPORT Compositor
bool disable_schedule_composite_;
+ enum CommitsAllowedState {
+ // We've told |root_layer_| to enable commits, but no commit has cleared.
+ ENABLED_NEEDS_COMMIT,
+ // We've committed since being enabled.
+ ENABLED_DID_COMMIT,
+ // We will tell |root_layer_| to defer commits once an commit clears.
+ DISABLED_PENDING_COMMIT,
+ // We told |root_layer_| to disable commits.
+ DISABLED,
+ };
+
+ CommitsAllowedState commits_allowed_;
+
+ CompositorLock* compositor_lock_;
+
DISALLOW_COPY_AND_ASSIGN(Compositor);
};
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/compositor/compositor.cc » ('j') | ui/compositor/compositor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698