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

Unified Diff: ui/compositor/compositor.h

Issue 1000503002: Add BeginFrameObserverProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 3a3e4cc829b1d675a2d3d64a7a139c69d94842a1..6c87d9bcd6d3f2b13884dbce81d3af617e635a44 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -5,6 +5,7 @@
#ifndef UI_COMPOSITOR_COMPOSITOR_H_
#define UI_COMPOSITOR_COMPOSITOR_H_
+#include <list>
#include <string>
#include "base/containers/hash_tables.h"
@@ -13,6 +14,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"
@@ -132,6 +134,12 @@ class COMPOSITOR_EXPORT CompositorLock
DISALLOW_COPY_AND_ASSIGN(CompositorLock);
};
+// This class observes BeginFrame notification from LayerTreeHost.
+class COMPOSITOR_EXPORT CompositorBeginFrameObserver {
+ public:
+ 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
@@ -227,6 +235,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);
+
// Change the timeout behavior for all future locks that are created. Locks
// should time out if there is an expectation that the compositor will be
// responsive.
@@ -272,6 +285,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;
@@ -291,6 +305,11 @@ class COMPOSITOR_EXPORT Compositor
return surface_id_allocator_.get();
}
+ // Exposed for testing.
+ std::list<CompositorBeginFrameObserver*>& BeginFrameObserverListForTesting() {
+ return begin_frame_observer_list_;
+ }
+
private:
friend class base::RefCounted<Compositor>;
friend class CompositorLock;
@@ -310,6 +329,7 @@ class COMPOSITOR_EXPORT Compositor
ObserverList<CompositorObserver, true> observer_list_;
ObserverList<CompositorAnimationObserver> animation_observer_list_;
+ std::list<CompositorBeginFrameObserver*> begin_frame_observer_list_;
gfx::AcceleratedWidget widget_;
scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
@@ -332,6 +352,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