Index: ui/compositor/compositor.cc |
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc |
index 287eaf19751ffc5e0d4f4fe09826482f812fef7c..c4cf8402db19297e1d4f71d9b7925356fff86855 100644 |
--- a/ui/compositor/compositor.cc |
+++ b/ui/compositor/compositor.cc |
@@ -26,7 +26,6 @@ |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "ui/compositor/compositor_observer.h" |
#include "ui/compositor/compositor_switches.h" |
-#include "ui/compositor/compositor_vsync_manager.h" |
#include "ui/compositor/dip_util.h" |
#include "ui/compositor/layer.h" |
#include "ui/compositor/layer_animator_collection.h" |
@@ -72,7 +71,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, |
widget_(widget), |
surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), |
task_runner_(task_runner), |
- vsync_manager_(new CompositorVSyncManager()), |
device_scale_factor_(0.0f), |
last_started_frame_(0), |
last_ended_frame_(0), |
@@ -153,6 +151,8 @@ Compositor::~Compositor() { |
FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
OnCompositingShuttingDown(this)); |
+ DCHECK(!begin_frame_observer_list_.might_have_observers()); |
+ |
if (root_layer_) |
root_layer_->SetCompositor(NULL); |
@@ -249,8 +249,9 @@ bool Compositor::IsVisible() { |
return host_->visible(); |
} |
-scoped_refptr<CompositorVSyncManager> Compositor::vsync_manager() const { |
- return vsync_manager_; |
+void Compositor::SetAuthoritativeVSyncInterval( |
+ const base::TimeDelta& interval) { |
+ host_->SetAuthoritativeVSyncInterval(interval); |
} |
void Compositor::AddObserver(CompositorObserver* observer) { |
@@ -280,6 +281,30 @@ bool Compositor::HasAnimationObserver( |
return animation_observer_list_.HasObserver(observer); |
} |
+void Compositor::AddBeginFrameObserver( |
+ CompositorBeginFrameObserver* observer, |
+ const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer) { |
+ // If |last_begin_frame_args_| is still effective, send it to the new |
+ // |observer| immediately. |
+ if (last_begin_frame_args_sent_to_observer.frame_time != |
+ missed_begin_frame_args_.frame_time) { |
+ observer->OnSendBeginFrame(missed_begin_frame_args_); |
+ } |
+ |
+ if (!begin_frame_observer_list_.might_have_observers()) |
+ SetChildrenNeedBeginFrames(true); |
+ begin_frame_observer_list_.AddObserver(observer); |
+} |
+ |
+void Compositor::RemoveBeginFrameObserver( |
+ CompositorBeginFrameObserver* observer) { |
+ DCHECK(begin_frame_observer_list_.HasObserver(observer)); |
+ begin_frame_observer_list_.RemoveObserver(observer); |
+ |
+ if (!begin_frame_observer_list_.might_have_observers()) |
+ SetChildrenNeedBeginFrames(false); |
+} |
+ |
void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
FOR_EACH_OBSERVER(CompositorAnimationObserver, |
animation_observer_list_, |
@@ -340,6 +365,14 @@ void Compositor::DidAbortSwapBuffers() { |
OnCompositingAborted(this)); |
} |
+void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) { |
+ FOR_EACH_OBSERVER(CompositorBeginFrameObserver, |
+ begin_frame_observer_list_, |
+ OnSendBeginFrame(args)); |
+ missed_begin_frame_args_ = args; |
+ missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED; |
+} |
+ |
const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
return host_->debug_state(); |
} |
@@ -378,4 +411,8 @@ void Compositor::CancelCompositorLock() { |
compositor_lock_->CancelLock(); |
} |
+void Compositor::SetChildrenNeedBeginFrames(bool need_begin_frames) { |
+ host_->SetChildrenNeedBeginFrames(need_begin_frames); |
+} |
+ |
} // namespace ui |