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

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: 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..85edbe8cdd5a1c162f7933d6f2de6a2dc74a9870 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -94,6 +94,9 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
settings.main_frame_before_activation_enabled = false;
settings.throttle_frame_production =
!command_line->HasSwitch(switches::kDisableGpuVsync);
+#if defined(USE_AURA)
+ settings.forward_begin_frames_to_children = true;
+#endif
#if !defined(OS_MACOSX)
settings.renderer_settings.partial_swap_enabled =
!command_line->HasSwitch(cc::switches::kUIDisablePartialSwap);
@@ -137,6 +140,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 +174,8 @@ Compositor::~Compositor() {
CancelCompositorLock();
DCHECK(!compositor_lock_);
+ DCHECK(!begin_frame_observer_list_.might_have_observers());
+
if (root_layer_)
root_layer_->SetCompositor(NULL);
@@ -302,6 +310,31 @@ 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 != missed_begin_frame_args_) {
+ missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED;
+ 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_,
@@ -359,6 +392,13 @@ 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;
+}
+
const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
return host_->debug_state();
}
@@ -397,4 +437,8 @@ void Compositor::CancelCompositorLock() {
compositor_lock_->CancelLock();
}
+void Compositor::SetChildrenNeedBeginFrames(bool need_begin_frames) {
+ host_->SetChildrenNeedBeginFrames(need_begin_frames);
+}
+
} // namespace ui
« content/browser/compositor/delegated_frame_host.cc ('K') | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698