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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <deque> | 10 #include <deque> |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 void Compositor::RemoveAnimationObserver( | 390 void Compositor::RemoveAnimationObserver( |
391 CompositorAnimationObserver* observer) { | 391 CompositorAnimationObserver* observer) { |
392 animation_observer_list_.RemoveObserver(observer); | 392 animation_observer_list_.RemoveObserver(observer); |
393 } | 393 } |
394 | 394 |
395 bool Compositor::HasAnimationObserver( | 395 bool Compositor::HasAnimationObserver( |
396 const CompositorAnimationObserver* observer) const { | 396 const CompositorAnimationObserver* observer) const { |
397 return animation_observer_list_.HasObserver(observer); | 397 return animation_observer_list_.HasObserver(observer); |
398 } | 398 } |
399 | 399 |
400 void Compositor::AddBeginFrameObserver(CompositorBeginFrameObserver* observer) { | |
401 if (!begin_frame_observer_list_.might_have_observers()) | |
402 host_->SetChildrenNeedBeginFrames(true); | |
403 | |
404 begin_frame_observer_list_.AddObserver(observer); | |
405 | |
406 if (missed_begin_frame_args_.IsValid()) | |
407 observer->OnSendBeginFrame(missed_begin_frame_args_); | |
408 } | |
409 | |
410 void Compositor::RemoveBeginFrameObserver( | |
411 CompositorBeginFrameObserver* observer) { | |
412 begin_frame_observer_list_.RemoveObserver(observer); | |
413 | |
414 // As this call may take place while iterating over observers, unsubscription | |
415 // from |host_| is performed after iteration in |SendBeginFramesToChildren()|. | |
416 } | |
417 | |
418 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 400 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
419 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 401 FOR_EACH_OBSERVER(CompositorAnimationObserver, |
420 animation_observer_list_, | 402 animation_observer_list_, |
421 OnAnimationStep(args.frame_time)); | 403 OnAnimationStep(args.frame_time)); |
422 if (animation_observer_list_.might_have_observers()) | 404 if (animation_observer_list_.might_have_observers()) |
423 host_->SetNeedsAnimate(); | 405 host_->SetNeedsAnimate(); |
424 } | 406 } |
425 | 407 |
426 void Compositor::BeginMainFrameNotExpectedSoon() { | 408 void Compositor::BeginMainFrameNotExpectedSoon() { |
427 } | 409 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 FOR_EACH_OBSERVER(CompositorObserver, | 461 FOR_EACH_OBSERVER(CompositorObserver, |
480 observer_list_, | 462 observer_list_, |
481 OnCompositingAborted(this)); | 463 OnCompositingAborted(this)); |
482 } | 464 } |
483 | 465 |
484 void Compositor::SetOutputIsSecure(bool output_is_secure) { | 466 void Compositor::SetOutputIsSecure(bool output_is_secure) { |
485 host_->SetOutputIsSecure(output_is_secure); | 467 host_->SetOutputIsSecure(output_is_secure); |
486 host_->SetNeedsRedraw(); | 468 host_->SetNeedsRedraw(); |
487 } | 469 } |
488 | 470 |
489 void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) { | |
490 FOR_EACH_OBSERVER(CompositorBeginFrameObserver, begin_frame_observer_list_, | |
491 OnSendBeginFrame(args)); | |
492 | |
493 // Unsubscription is performed here, after iteration, to handle the case where | |
494 // the last BeginFrame observer is removed while iterating over the observers. | |
495 if (!begin_frame_observer_list_.might_have_observers()) { | |
496 host_->SetChildrenNeedBeginFrames(false); | |
497 // Unsubscription should reset |missed_begin_frame_args_|, avoiding stale | |
498 // BeginFrame dispatch when the next BeginFrame observer is added. | |
499 missed_begin_frame_args_ = cc::BeginFrameArgs(); | |
500 return; | |
501 } | |
502 | |
503 missed_begin_frame_args_ = args; | |
504 missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED; | |
505 } | |
506 | |
507 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { | 471 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
508 return host_->debug_state(); | 472 return host_->debug_state(); |
509 } | 473 } |
510 | 474 |
511 void Compositor::SetLayerTreeDebugState( | 475 void Compositor::SetLayerTreeDebugState( |
512 const cc::LayerTreeDebugState& debug_state) { | 476 const cc::LayerTreeDebugState& debug_state) { |
513 host_->SetDebugState(debug_state); | 477 host_->SetDebugState(debug_state); |
514 } | 478 } |
515 | 479 |
516 const cc::RendererSettings& Compositor::GetRendererSettings() const { | 480 const cc::RendererSettings& Compositor::GetRendererSettings() const { |
(...skipping 19 matching lines...) Expand all Loading... |
536 observer_list_, | 500 observer_list_, |
537 OnCompositingLockStateChanged(this)); | 501 OnCompositingLockStateChanged(this)); |
538 } | 502 } |
539 | 503 |
540 void Compositor::CancelCompositorLock() { | 504 void Compositor::CancelCompositorLock() { |
541 if (compositor_lock_) | 505 if (compositor_lock_) |
542 compositor_lock_->CancelLock(); | 506 compositor_lock_->CancelLock(); |
543 } | 507 } |
544 | 508 |
545 } // namespace ui | 509 } // namespace ui |
OLD | NEW |