| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 void Compositor::RemoveAnimationObserver( | 379 void Compositor::RemoveAnimationObserver( |
| 380 CompositorAnimationObserver* observer) { | 380 CompositorAnimationObserver* observer) { |
| 381 animation_observer_list_.RemoveObserver(observer); | 381 animation_observer_list_.RemoveObserver(observer); |
| 382 } | 382 } |
| 383 | 383 |
| 384 bool Compositor::HasAnimationObserver( | 384 bool Compositor::HasAnimationObserver( |
| 385 const CompositorAnimationObserver* observer) const { | 385 const CompositorAnimationObserver* observer) const { |
| 386 return animation_observer_list_.HasObserver(observer); | 386 return animation_observer_list_.HasObserver(observer); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void Compositor::AddBeginFrameObserver(CompositorBeginFrameObserver* observer) { | |
| 390 if (!begin_frame_observer_list_.might_have_observers()) | |
| 391 host_->SetChildrenNeedBeginFrames(true); | |
| 392 | |
| 393 begin_frame_observer_list_.AddObserver(observer); | |
| 394 | |
| 395 if (missed_begin_frame_args_.IsValid()) | |
| 396 observer->OnSendBeginFrame(missed_begin_frame_args_); | |
| 397 } | |
| 398 | |
| 399 void Compositor::RemoveBeginFrameObserver( | |
| 400 CompositorBeginFrameObserver* observer) { | |
| 401 begin_frame_observer_list_.RemoveObserver(observer); | |
| 402 | |
| 403 // As this call may take place while iterating over observers, unsubscription | |
| 404 // from |host_| is performed after iteration in |SendBeginFramesToChildren()|. | |
| 405 } | |
| 406 | |
| 407 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 389 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
| 408 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 390 FOR_EACH_OBSERVER(CompositorAnimationObserver, |
| 409 animation_observer_list_, | 391 animation_observer_list_, |
| 410 OnAnimationStep(args.frame_time)); | 392 OnAnimationStep(args.frame_time)); |
| 411 if (animation_observer_list_.might_have_observers()) | 393 if (animation_observer_list_.might_have_observers()) |
| 412 host_->SetNeedsAnimate(); | 394 host_->SetNeedsAnimate(); |
| 413 } | 395 } |
| 414 | 396 |
| 415 void Compositor::BeginMainFrameNotExpectedSoon() { | 397 void Compositor::BeginMainFrameNotExpectedSoon() { |
| 416 } | 398 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 FOR_EACH_OBSERVER(CompositorObserver, | 450 FOR_EACH_OBSERVER(CompositorObserver, |
| 469 observer_list_, | 451 observer_list_, |
| 470 OnCompositingAborted(this)); | 452 OnCompositingAborted(this)); |
| 471 } | 453 } |
| 472 | 454 |
| 473 void Compositor::SetOutputIsSecure(bool output_is_secure) { | 455 void Compositor::SetOutputIsSecure(bool output_is_secure) { |
| 474 host_->SetOutputIsSecure(output_is_secure); | 456 host_->SetOutputIsSecure(output_is_secure); |
| 475 host_->SetNeedsRedraw(); | 457 host_->SetNeedsRedraw(); |
| 476 } | 458 } |
| 477 | 459 |
| 478 void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) { | |
| 479 FOR_EACH_OBSERVER(CompositorBeginFrameObserver, begin_frame_observer_list_, | |
| 480 OnSendBeginFrame(args)); | |
| 481 | |
| 482 // Unsubscription is performed here, after iteration, to handle the case where | |
| 483 // the last BeginFrame observer is removed while iterating over the observers. | |
| 484 if (!begin_frame_observer_list_.might_have_observers()) { | |
| 485 host_->SetChildrenNeedBeginFrames(false); | |
| 486 // Unsubscription should reset |missed_begin_frame_args_|, avoiding stale | |
| 487 // BeginFrame dispatch when the next BeginFrame observer is added. | |
| 488 missed_begin_frame_args_ = cc::BeginFrameArgs(); | |
| 489 return; | |
| 490 } | |
| 491 | |
| 492 missed_begin_frame_args_ = args; | |
| 493 missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED; | |
| 494 } | |
| 495 | |
| 496 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { | 460 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
| 497 return host_->debug_state(); | 461 return host_->debug_state(); |
| 498 } | 462 } |
| 499 | 463 |
| 500 void Compositor::SetLayerTreeDebugState( | 464 void Compositor::SetLayerTreeDebugState( |
| 501 const cc::LayerTreeDebugState& debug_state) { | 465 const cc::LayerTreeDebugState& debug_state) { |
| 502 host_->SetDebugState(debug_state); | 466 host_->SetDebugState(debug_state); |
| 503 } | 467 } |
| 504 | 468 |
| 505 const cc::RendererSettings& Compositor::GetRendererSettings() const { | 469 const cc::RendererSettings& Compositor::GetRendererSettings() const { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 525 observer_list_, | 489 observer_list_, |
| 526 OnCompositingLockStateChanged(this)); | 490 OnCompositingLockStateChanged(this)); |
| 527 } | 491 } |
| 528 | 492 |
| 529 void Compositor::CancelCompositorLock() { | 493 void Compositor::CancelCompositorLock() { |
| 530 if (compositor_lock_) | 494 if (compositor_lock_) |
| 531 compositor_lock_->CancelLock(); | 495 compositor_lock_->CancelLock(); |
| 532 } | 496 } |
| 533 | 497 |
| 534 } // namespace ui | 498 } // namespace ui |
| OLD | NEW |