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

Unified Diff: ui/compositor/compositor.h

Issue 775143003: cc: Implement unified BeginFrame on aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unittest 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 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 7c4a706a5175cbec50cec49b392bd105670633b9..cc53f5e5fcb3a4046fb742ae7bb1389c1af8490c 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -13,6 +13,7 @@
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
+#include "cc/output/begin_frame_args.h"
#include "cc/surfaces/surface_sequence.h"
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/layer_tree_host_single_thread_client.h"
@@ -53,7 +54,6 @@ struct Mailbox;
namespace ui {
class Compositor;
-class CompositorVSyncManager;
class Layer;
class Reflector;
class Texture;
@@ -128,6 +128,14 @@ class COMPOSITOR_EXPORT CompositorLock
DISALLOW_COPY_AND_ASSIGN(CompositorLock);
};
+// This class observes BeginFrame notification from LayerTreeHost.
+class COMPOSITOR_EXPORT CompositorBeginFrameObserver {
+ public:
+ virtual ~CompositorBeginFrameObserver() {}
+
+ virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) = 0;
+};
+
// 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
@@ -201,12 +209,17 @@ class COMPOSITOR_EXPORT Compositor
// Gets the visibility of the underlying compositor.
bool IsVisible();
+ // The "authoritative" vsync interval, if provided, will override interval
+ // reported from 3D context. This is typically the value reported by a more
+ // reliable source, e.g, the platform display configuration.
+ // In the particular case of ChromeOS -- this is the value queried through
+ // XRandR, which is more reliable than the value queried through the 3D
+ // context.
+ void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval);
+
// Returns the widget for this compositor.
gfx::AcceleratedWidget widget() const { return widget_; }
- // Returns the vsync manager for this compositor.
- scoped_refptr<CompositorVSyncManager> vsync_manager() const;
-
// Returns the main thread task runner this compositor uses. Users of the
// compositor generally shouldn't use this.
scoped_refptr<base::SingleThreadTaskRunner> task_runner() const {
@@ -223,6 +236,11 @@ class COMPOSITOR_EXPORT Compositor
void RemoveAnimationObserver(CompositorAnimationObserver* observer);
bool HasAnimationObserver(const CompositorAnimationObserver* observer) const;
+ void AddBeginFrameObserver(
+ CompositorBeginFrameObserver* observer,
+ const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer);
+ void RemoveBeginFrameObserver(CompositorBeginFrameObserver* observer);
+
// 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();
@@ -261,6 +279,7 @@ class COMPOSITOR_EXPORT Compositor
void DidCommitAndDrawFrame() override;
void DidCompleteSwapBuffers() override;
void DidCompletePageScaleAnimation() override {}
+ void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override;
// cc::LayerTreeHostSingleThreadClient implementation.
void DidPostSwapBuffers() override;
@@ -283,6 +302,7 @@ class COMPOSITOR_EXPORT Compositor
private:
friend class base::RefCounted<Compositor>;
friend class CompositorLock;
+ friend class CompositorTestAPI;
brianderson 2015/03/06 20:36:59 Instead of adding a CompositorTestAPI as a friend,
// Called by CompositorLock.
void UnlockCompositor();
@@ -290,6 +310,9 @@ class COMPOSITOR_EXPORT Compositor
// Called to release any pending CompositorLock
void CancelCompositorLock();
+ // Request scheduling of next BeginFrame to LayerTreeHost.
+ void SetChildrenNeedBeginFrames(bool need_begin_frame);
+
gfx::Size size_;
ui::ContextFactory* context_factory_;
@@ -299,6 +322,7 @@ class COMPOSITOR_EXPORT Compositor
ObserverList<CompositorObserver, true> observer_list_;
ObserverList<CompositorAnimationObserver> animation_observer_list_;
+ ObserverList<CompositorBeginFrameObserver> begin_frame_observer_list_;
gfx::AcceleratedWidget widget_;
scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
@@ -306,9 +330,6 @@ class COMPOSITOR_EXPORT Compositor
scoped_ptr<cc::LayerTreeHost> host_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- // The manager of vsync parameters for this compositor.
- scoped_refptr<CompositorVSyncManager> vsync_manager_;
-
// The device scale factor of the monitor that this compositor is compositing
// layers on.
float device_scale_factor_;
@@ -322,6 +343,9 @@ class COMPOSITOR_EXPORT Compositor
LayerAnimatorCollection layer_animator_collection_;
+ // Used to send to any new CompositorBeginFrameObserver immediately.
+ cc::BeginFrameArgs missed_begin_frame_args_;
+
base::WeakPtrFactory<Compositor> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(Compositor);

Powered by Google App Engine
This is Rietveld 408576698