Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 148 |
| 149 Compositor::~Compositor() { | 149 Compositor::~Compositor() { |
| 150 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 150 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 151 | 151 |
| 152 CancelCompositorLock(); | 152 CancelCompositorLock(); |
| 153 DCHECK(!compositor_lock_); | 153 DCHECK(!compositor_lock_); |
| 154 | 154 |
| 155 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 155 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
| 156 OnCompositingShuttingDown(this)); | 156 OnCompositingShuttingDown(this)); |
| 157 | 157 |
| 158 DCHECK(!begin_frame_observer_list_.might_have_observers()); | |
| 159 | |
| 158 if (root_layer_) | 160 if (root_layer_) |
| 159 root_layer_->SetCompositor(NULL); | 161 root_layer_->SetCompositor(NULL); |
| 160 | 162 |
| 161 // Stop all outstanding draws before telling the ContextFactory to tear | 163 // Stop all outstanding draws before telling the ContextFactory to tear |
| 162 // down any contexts that the |host_| may rely upon. | 164 // down any contexts that the |host_| may rely upon. |
| 163 host_.reset(); | 165 host_.reset(); |
| 164 | 166 |
| 165 context_factory_->RemoveCompositor(this); | 167 context_factory_->RemoveCompositor(this); |
| 166 } | 168 } |
| 167 | 169 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 void Compositor::RemoveAnimationObserver( | 277 void Compositor::RemoveAnimationObserver( |
| 276 CompositorAnimationObserver* observer) { | 278 CompositorAnimationObserver* observer) { |
| 277 animation_observer_list_.RemoveObserver(observer); | 279 animation_observer_list_.RemoveObserver(observer); |
| 278 } | 280 } |
| 279 | 281 |
| 280 bool Compositor::HasAnimationObserver( | 282 bool Compositor::HasAnimationObserver( |
| 281 const CompositorAnimationObserver* observer) const { | 283 const CompositorAnimationObserver* observer) const { |
| 282 return animation_observer_list_.HasObserver(observer); | 284 return animation_observer_list_.HasObserver(observer); |
| 283 } | 285 } |
| 284 | 286 |
| 287 void Compositor::AddBeginFrameObserver( | |
| 288 CompositorBeginFrameObserver* observer, | |
| 289 const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer) { | |
| 290 // If |last_begin_frame_args_| is still effective, send it to the new | |
| 291 // |observer| immediately. | |
| 292 if (last_begin_frame_args_sent_to_observer.frame_time != | |
| 293 missed_begin_frame_args_.frame_time) { | |
| 294 observer->OnSendBeginFrame(missed_begin_frame_args_); | |
| 295 } | |
| 296 | |
| 297 if (!begin_frame_observer_list_.might_have_observers()) | |
| 298 SetChildrenNeedBeginFrames(true); | |
| 299 begin_frame_observer_list_.AddObserver(observer); | |
| 300 } | |
| 301 | |
| 302 void Compositor::RemoveBeginFrameObserver( | |
| 303 CompositorBeginFrameObserver* observer) { | |
| 304 DCHECK(begin_frame_observer_list_.HasObserver(observer)); | |
| 305 begin_frame_observer_list_.RemoveObserver(observer); | |
| 306 | |
| 307 if (!begin_frame_observer_list_.might_have_observers()) | |
| 308 SetChildrenNeedBeginFrames(false); | |
| 309 } | |
| 310 | |
| 285 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 311 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
| 286 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 312 FOR_EACH_OBSERVER(CompositorAnimationObserver, |
| 287 animation_observer_list_, | 313 animation_observer_list_, |
| 288 OnAnimationStep(args.frame_time)); | 314 OnAnimationStep(args.frame_time)); |
| 289 if (animation_observer_list_.might_have_observers()) | 315 if (animation_observer_list_.might_have_observers()) |
| 290 host_->SetNeedsAnimate(); | 316 host_->SetNeedsAnimate(); |
| 291 } | 317 } |
| 292 | 318 |
| 293 void Compositor::BeginMainFrameNotExpectedSoon() { | 319 void Compositor::BeginMainFrameNotExpectedSoon() { |
| 294 } | 320 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 361 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
| 336 OnCompositingStarted(this, start_time)); | 362 OnCompositingStarted(this, start_time)); |
| 337 } | 363 } |
| 338 | 364 |
| 339 void Compositor::DidAbortSwapBuffers() { | 365 void Compositor::DidAbortSwapBuffers() { |
| 340 FOR_EACH_OBSERVER(CompositorObserver, | 366 FOR_EACH_OBSERVER(CompositorObserver, |
| 341 observer_list_, | 367 observer_list_, |
| 342 OnCompositingAborted(this)); | 368 OnCompositingAborted(this)); |
| 343 } | 369 } |
| 344 | 370 |
| 371 void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) { | |
| 372 FOR_EACH_OBSERVER(CompositorBeginFrameObserver, | |
| 373 begin_frame_observer_list_, | |
| 374 OnSendBeginFrame(args)); | |
| 375 missed_begin_frame_args_ = args; | |
| 376 missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED; | |
| 377 } | |
| 378 | |
| 345 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { | 379 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
| 346 return host_->debug_state(); | 380 return host_->debug_state(); |
| 347 } | 381 } |
| 348 | 382 |
| 349 void Compositor::SetLayerTreeDebugState( | 383 void Compositor::SetLayerTreeDebugState( |
| 350 const cc::LayerTreeDebugState& debug_state) { | 384 const cc::LayerTreeDebugState& debug_state) { |
| 351 host_->SetDebugState(debug_state); | 385 host_->SetDebugState(debug_state); |
| 352 } | 386 } |
| 353 | 387 |
| 354 const cc::RendererSettings& Compositor::GetRendererSettings() const { | 388 const cc::RendererSettings& Compositor::GetRendererSettings() const { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 373 FOR_EACH_OBSERVER(CompositorObserver, | 407 FOR_EACH_OBSERVER(CompositorObserver, |
| 374 observer_list_, | 408 observer_list_, |
| 375 OnCompositingLockStateChanged(this)); | 409 OnCompositingLockStateChanged(this)); |
| 376 } | 410 } |
| 377 | 411 |
| 378 void Compositor::CancelCompositorLock() { | 412 void Compositor::CancelCompositorLock() { |
| 379 if (compositor_lock_) | 413 if (compositor_lock_) |
| 380 compositor_lock_->CancelLock(); | 414 compositor_lock_->CancelLock(); |
| 381 } | 415 } |
| 382 | 416 |
| 417 void Compositor::SetChildrenNeedBeginFrames(bool need_begin_frames) { | |
|
brianderson
2015/03/10 23:36:46
Does this need it's own method?
simonhong
2015/03/11 02:03:37
Removed.
| |
| 418 host_->SetChildrenNeedBeginFrames(need_begin_frames); | |
| 419 } | |
| 420 | |
| 383 } // namespace ui | 421 } // namespace ui |
| OLD | NEW |