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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // When impl-side painting is enabled, this will ensure PictureLayers always 87 // When impl-side painting is enabled, this will ensure PictureLayers always
88 // can have LCD text, to match the previous behaviour with ContentLayers, 88 // can have LCD text, to match the previous behaviour with ContentLayers,
89 // where LCD-not-allowed notifications were ignored. 89 // where LCD-not-allowed notifications were ignored.
90 settings.layers_always_allowed_lcd_text = true; 90 settings.layers_always_allowed_lcd_text = true;
91 settings.renderer_settings.refresh_rate = 91 settings.renderer_settings.refresh_rate =
92 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate 92 context_factory_->DoesCreateTestContexts() ? kTestRefreshRate
93 : kDefaultRefreshRate; 93 : kDefaultRefreshRate;
94 settings.main_frame_before_activation_enabled = false; 94 settings.main_frame_before_activation_enabled = false;
95 settings.throttle_frame_production = 95 settings.throttle_frame_production =
96 !command_line->HasSwitch(switches::kDisableGpuVsync); 96 !command_line->HasSwitch(switches::kDisableGpuVsync);
97 settings.forward_begin_frames_to_children =
98 command_line->HasSwitch(cc::switches::kEnableBeginFrameScheduling);
97 #if !defined(OS_MACOSX) 99 #if !defined(OS_MACOSX)
98 settings.renderer_settings.partial_swap_enabled = 100 settings.renderer_settings.partial_swap_enabled =
99 !command_line->HasSwitch(cc::switches::kUIDisablePartialSwap); 101 !command_line->HasSwitch(cc::switches::kUIDisablePartialSwap);
100 #endif 102 #endif
101 #if defined(OS_CHROMEOS) 103 #if defined(OS_CHROMEOS)
102 settings.per_tile_painting_enabled = true; 104 settings.per_tile_painting_enabled = true;
103 #endif 105 #endif
104 #if defined(OS_WIN) 106 #if defined(OS_WIN)
105 settings.disable_hi_res_timer_tasks_on_battery = 107 settings.disable_hi_res_timer_tasks_on_battery =
106 !context_factory_->DoesCreateTestContexts(); 108 !context_factory_->DoesCreateTestContexts();
(...skipping 23 matching lines...) Expand all
130 command_line->HasSwitch(cc::switches::kUIShowNonOccludingRects); 132 command_line->HasSwitch(cc::switches::kUIShowNonOccludingRects);
131 133
132 settings.initial_debug_state.SetRecordRenderingStats( 134 settings.initial_debug_state.SetRecordRenderingStats(
133 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 135 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
134 136
135 settings.impl_side_painting = IsUIImplSidePaintingEnabled(); 137 settings.impl_side_painting = IsUIImplSidePaintingEnabled();
136 settings.use_zero_copy = IsUIZeroCopyEnabled(); 138 settings.use_zero_copy = IsUIZeroCopyEnabled();
137 139
138 base::TimeTicks before_create = base::TimeTicks::Now(); 140 base::TimeTicks before_create = base::TimeTicks::Now();
139 if (compositor_thread_loop_.get()) { 141 if (compositor_thread_loop_.get()) {
142 // Unified BeginFrame scheduling shouldn't be enabled with threaded
143 // compositing.
144 DCHECK(!settings.forward_begin_frames_to_children);
140 host_ = cc::LayerTreeHost::CreateThreaded( 145 host_ = cc::LayerTreeHost::CreateThreaded(
141 this, 146 this,
142 context_factory_->GetSharedBitmapManager(), 147 context_factory_->GetSharedBitmapManager(),
143 context_factory_->GetGpuMemoryBufferManager(), 148 context_factory_->GetGpuMemoryBufferManager(),
144 settings, 149 settings,
145 task_runner_, 150 task_runner_,
146 compositor_thread_loop_, 151 compositor_thread_loop_,
147 nullptr); 152 nullptr);
148 } else { 153 } else {
149 host_ = cc::LayerTreeHost::CreateSingleThreaded( 154 host_ = cc::LayerTreeHost::CreateSingleThreaded(
(...skipping 11 matching lines...) Expand all
161 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); 166 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace());
162 host_->SetLayerTreeHostClientReady(); 167 host_->SetLayerTreeHostClientReady();
163 } 168 }
164 169
165 Compositor::~Compositor() { 170 Compositor::~Compositor() {
166 TRACE_EVENT0("shutdown", "Compositor::destructor"); 171 TRACE_EVENT0("shutdown", "Compositor::destructor");
167 172
168 CancelCompositorLock(); 173 CancelCompositorLock();
169 DCHECK(!compositor_lock_); 174 DCHECK(!compositor_lock_);
170 175
176 DCHECK(!begin_frame_observer_list_.might_have_observers());
177
171 if (root_layer_) 178 if (root_layer_)
172 root_layer_->SetCompositor(NULL); 179 root_layer_->SetCompositor(NULL);
173 180
174 // Stop all outstanding draws before telling the ContextFactory to tear 181 // Stop all outstanding draws before telling the ContextFactory to tear
175 // down any contexts that the |host_| may rely upon. 182 // down any contexts that the |host_| may rely upon.
176 host_.reset(); 183 host_.reset();
177 184
178 context_factory_->RemoveCompositor(this); 185 context_factory_->RemoveCompositor(this);
179 } 186 }
180 187
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void Compositor::RemoveAnimationObserver( 302 void Compositor::RemoveAnimationObserver(
296 CompositorAnimationObserver* observer) { 303 CompositorAnimationObserver* observer) {
297 animation_observer_list_.RemoveObserver(observer); 304 animation_observer_list_.RemoveObserver(observer);
298 } 305 }
299 306
300 bool Compositor::HasAnimationObserver( 307 bool Compositor::HasAnimationObserver(
301 const CompositorAnimationObserver* observer) const { 308 const CompositorAnimationObserver* observer) const {
302 return animation_observer_list_.HasObserver(observer); 309 return animation_observer_list_.HasObserver(observer);
303 } 310 }
304 311
312 void Compositor::AddBeginFrameObserver(
313 CompositorBeginFrameObserver* observer,
314 const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer) {
315 // If |last_begin_frame_args_| is still effective, send it to the new
316 // |observer| immediately.
317 if (!last_begin_frame_args_sent_to_observer.deadline.is_null() &&
318 last_begin_frame_args_sent_to_observer != last_begin_frame_args_ &&
319 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
320 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.
321
322 if (!begin_frame_observer_list_.might_have_observers())
323 SetChildrenNeedBeginFrames(true);
324 begin_frame_observer_list_.AddObserver(observer);
325 }
326
327 void Compositor::RemoveBeginFrameObserver(
328 CompositorBeginFrameObserver* observer) {
329 DCHECK(begin_frame_observer_list_.might_have_observers());
330 begin_frame_observer_list_.RemoveObserver(observer);
331
332 if (!begin_frame_observer_list_.might_have_observers())
333 SetChildrenNeedBeginFrames(false);
334 }
335
336 bool Compositor::HasBeginFrameObserver(CompositorBeginFrameObserver* observer) {
337 return begin_frame_observer_list_.HasObserver(observer);
338 }
339
305 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { 340 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) {
306 FOR_EACH_OBSERVER(CompositorAnimationObserver, 341 FOR_EACH_OBSERVER(CompositorAnimationObserver,
307 animation_observer_list_, 342 animation_observer_list_,
308 OnAnimationStep(args.frame_time)); 343 OnAnimationStep(args.frame_time));
309 if (animation_observer_list_.might_have_observers()) 344 if (animation_observer_list_.might_have_observers())
310 host_->SetNeedsAnimate(); 345 host_->SetNeedsAnimate();
311 } 346 }
312 347
313 void Compositor::Layout() { 348 void Compositor::Layout() {
314 // We're sending damage that will be addressed during this composite 349 // We're sending damage that will be addressed during this composite
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, 387 FOR_EACH_OBSERVER(CompositorObserver, observer_list_,
353 OnCompositingStarted(this, start_time)); 388 OnCompositingStarted(this, start_time));
354 } 389 }
355 390
356 void Compositor::DidAbortSwapBuffers() { 391 void Compositor::DidAbortSwapBuffers() {
357 FOR_EACH_OBSERVER(CompositorObserver, 392 FOR_EACH_OBSERVER(CompositorObserver,
358 observer_list_, 393 observer_list_,
359 OnCompositingAborted(this)); 394 OnCompositingAborted(this));
360 } 395 }
361 396
397 void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) {
398 FOR_EACH_OBSERVER(CompositorBeginFrameObserver,
399 begin_frame_observer_list_,
400 OnSendBeginFrame(args));
401 last_begin_frame_args_ = args;
402 }
403
362 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { 404 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
363 return host_->debug_state(); 405 return host_->debug_state();
364 } 406 }
365 407
366 void Compositor::SetLayerTreeDebugState( 408 void Compositor::SetLayerTreeDebugState(
367 const cc::LayerTreeDebugState& debug_state) { 409 const cc::LayerTreeDebugState& debug_state) {
368 host_->SetDebugState(debug_state); 410 host_->SetDebugState(debug_state);
369 } 411 }
370 412
371 const cc::RendererSettings& Compositor::GetRendererSettings() const { 413 const cc::RendererSettings& Compositor::GetRendererSettings() const {
(...skipping 18 matching lines...) Expand all
390 FOR_EACH_OBSERVER(CompositorObserver, 432 FOR_EACH_OBSERVER(CompositorObserver,
391 observer_list_, 433 observer_list_,
392 OnCompositingLockStateChanged(this)); 434 OnCompositingLockStateChanged(this));
393 } 435 }
394 436
395 void Compositor::CancelCompositorLock() { 437 void Compositor::CancelCompositorLock() {
396 if (compositor_lock_) 438 if (compositor_lock_)
397 compositor_lock_->CancelLock(); 439 compositor_lock_->CancelLock();
398 } 440 }
399 441
442 void Compositor::SetChildrenNeedBeginFrames(bool need_begin_frames) {
443 host_->SetChildrenNeedBeginFrames(need_begin_frames);
444 }
445
400 } // namespace ui 446 } // namespace ui
OLDNEW
« 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