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

Unified Diff: ui/compositor/compositor.cc

Issue 775143003: cc: Implement unified BeginFrame on aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move common logic to DelegatedFrameHost Created 6 years 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.cc
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 0fae1937acb265839fc48a516aa597dfa96184b0..6c176beb06fe7dc3b14af17322d9f07b2a02fd70 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -94,6 +94,8 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
settings.main_frame_before_activation_enabled = false;
settings.throttle_frame_production =
!command_line->HasSwitch(switches::kDisableGpuVsync);
+ settings.forward_begin_frames_to_children =
+ command_line->HasSwitch(cc::switches::kEnableBeginFrameScheduling);
#if !defined(OS_MACOSX)
settings.renderer_settings.partial_swap_enabled =
!command_line->HasSwitch(cc::switches::kUIDisablePartialSwap);
@@ -137,6 +139,9 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
base::TimeTicks before_create = base::TimeTicks::Now();
if (compositor_thread_loop_.get()) {
+ // Unified BeginFrame scheduling shouldn't be enabled with threaded
+ // compositing.
+ DCHECK(!settings.forward_begin_frames_to_children);
host_ = cc::LayerTreeHost::CreateThreaded(
this,
context_factory_->GetSharedBitmapManager(),
@@ -168,6 +173,8 @@ Compositor::~Compositor() {
CancelCompositorLock();
DCHECK(!compositor_lock_);
+ DCHECK(!begin_frame_observer_list_.might_have_observers());
+
if (root_layer_)
root_layer_->SetCompositor(NULL);
@@ -302,6 +309,34 @@ 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.deadline.is_null() &&
+ last_begin_frame_args_sent_to_observer != last_begin_frame_args_ &&
+ last_begin_frame_args_.deadline > base::TimeTicks::Now())
brianderson 2014/12/09 03:00:32 Let's not do the deadline check here and just let
simonhong 2014/12/09 17:09:27 Yep. If this is already expired, it will be droppe
+ observer->OnSendBeginFrame(last_begin_frame_args_);
brianderson 2014/12/09 03:00:32 In this case, can you set the BeginFrame "type" to
simonhong 2014/12/09 17:09:27 Done.
+
+ 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_.might_have_observers());
+ begin_frame_observer_list_.RemoveObserver(observer);
+
+ if (!begin_frame_observer_list_.might_have_observers())
+ SetChildrenNeedBeginFrames(false);
+}
+
+bool Compositor::HasBeginFrameObserver(CompositorBeginFrameObserver* observer) {
+ return begin_frame_observer_list_.HasObserver(observer);
+}
+
void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) {
FOR_EACH_OBSERVER(CompositorAnimationObserver,
animation_observer_list_,
@@ -359,6 +394,13 @@ void Compositor::DidAbortSwapBuffers() {
OnCompositingAborted(this));
}
+void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) {
+ FOR_EACH_OBSERVER(CompositorBeginFrameObserver,
+ begin_frame_observer_list_,
+ OnSendBeginFrame(args));
+ last_begin_frame_args_ = args;
+}
+
const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
return host_->debug_state();
}
@@ -397,4 +439,8 @@ void Compositor::CancelCompositorLock() {
compositor_lock_->CancelLock();
}
+void Compositor::SetChildrenNeedBeginFrames(bool need_begin_frames) {
+ host_->SetChildrenNeedBeginFrames(need_begin_frames);
+}
+
} // namespace ui
« ui/base/compositor/compositor_begin_frame_observer.h ('K') | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698