| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 host_->SetFrameSinkId(frame_sink_id_); | 207 host_->SetFrameSinkId(frame_sink_id_); |
| 208 host_->SetVisible(true); | 208 host_->SetVisible(true); |
| 209 } | 209 } |
| 210 | 210 |
| 211 Compositor::~Compositor() { | 211 Compositor::~Compositor() { |
| 212 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 212 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 213 | 213 |
| 214 CancelCompositorLock(); | 214 CancelCompositorLock(); |
| 215 DCHECK(!compositor_lock_); | 215 DCHECK(!compositor_lock_); |
| 216 | 216 |
| 217 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 217 for (auto& observer : observer_list_) |
| 218 OnCompositingShuttingDown(this)); | 218 observer.OnCompositingShuttingDown(this); |
| 219 | 219 |
| 220 FOR_EACH_OBSERVER(CompositorAnimationObserver, animation_observer_list_, | 220 for (auto& observer : animation_observer_list_) |
| 221 OnCompositingShuttingDown(this)); | 221 observer.OnCompositingShuttingDown(this); |
| 222 | 222 |
| 223 if (root_layer_) | 223 if (root_layer_) |
| 224 root_layer_->ResetCompositor(); | 224 root_layer_->ResetCompositor(); |
| 225 | 225 |
| 226 if (animation_timeline_) | 226 if (animation_timeline_) |
| 227 host_->GetLayerTree()->animation_host()->RemoveAnimationTimeline( | 227 host_->GetLayerTree()->animation_host()->RemoveAnimationTimeline( |
| 228 animation_timeline_.get()); | 228 animation_timeline_.get()); |
| 229 | 229 |
| 230 // Stop all outstanding draws before telling the ContextFactory to tear | 230 // Stop all outstanding draws before telling the ContextFactory to tear |
| 231 // down any contexts that the |host_| may rely upon. | 231 // down any contexts that the |host_| may rely upon. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 CompositorAnimationObserver* observer) { | 436 CompositorAnimationObserver* observer) { |
| 437 animation_observer_list_.RemoveObserver(observer); | 437 animation_observer_list_.RemoveObserver(observer); |
| 438 } | 438 } |
| 439 | 439 |
| 440 bool Compositor::HasAnimationObserver( | 440 bool Compositor::HasAnimationObserver( |
| 441 const CompositorAnimationObserver* observer) const { | 441 const CompositorAnimationObserver* observer) const { |
| 442 return animation_observer_list_.HasObserver(observer); | 442 return animation_observer_list_.HasObserver(observer); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 445 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
| 446 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 446 for (auto& observer : animation_observer_list_) |
| 447 animation_observer_list_, | 447 observer.OnAnimationStep(args.frame_time); |
| 448 OnAnimationStep(args.frame_time)); | |
| 449 if (animation_observer_list_.might_have_observers()) | 448 if (animation_observer_list_.might_have_observers()) |
| 450 host_->SetNeedsAnimate(); | 449 host_->SetNeedsAnimate(); |
| 451 } | 450 } |
| 452 | 451 |
| 453 void Compositor::BeginMainFrameNotExpectedSoon() { | 452 void Compositor::BeginMainFrameNotExpectedSoon() { |
| 454 } | 453 } |
| 455 | 454 |
| 456 static void SendDamagedRectsRecursive(ui::Layer* layer) { | 455 static void SendDamagedRectsRecursive(ui::Layer* layer) { |
| 457 layer->SendDamagedRects(); | 456 layer->SendDamagedRects(); |
| 458 for (auto* child : layer->children()) | 457 for (auto* child : layer->children()) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 476 | 475 |
| 477 void Compositor::DidFailToInitializeCompositorFrameSink() { | 476 void Compositor::DidFailToInitializeCompositorFrameSink() { |
| 478 // The CompositorFrameSink should already be bound/initialized before being | 477 // The CompositorFrameSink should already be bound/initialized before being |
| 479 // given to | 478 // given to |
| 480 // the Compositor. | 479 // the Compositor. |
| 481 NOTREACHED(); | 480 NOTREACHED(); |
| 482 } | 481 } |
| 483 | 482 |
| 484 void Compositor::DidCommit() { | 483 void Compositor::DidCommit() { |
| 485 DCHECK(!IsLocked()); | 484 DCHECK(!IsLocked()); |
| 486 FOR_EACH_OBSERVER(CompositorObserver, | 485 for (auto& observer : observer_list_) |
| 487 observer_list_, | 486 observer.OnCompositingDidCommit(this); |
| 488 OnCompositingDidCommit(this)); | |
| 489 } | 487 } |
| 490 | 488 |
| 491 void Compositor::DidCommitAndDrawFrame() { | 489 void Compositor::DidCommitAndDrawFrame() { |
| 492 } | 490 } |
| 493 | 491 |
| 494 void Compositor::DidCompleteSwapBuffers() { | 492 void Compositor::DidCompleteSwapBuffers() { |
| 495 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 493 for (auto& observer : observer_list_) |
| 496 OnCompositingEnded(this)); | 494 observer.OnCompositingEnded(this); |
| 497 } | 495 } |
| 498 | 496 |
| 499 void Compositor::DidPostSwapBuffers() { | 497 void Compositor::DidPostSwapBuffers() { |
| 500 base::TimeTicks start_time = base::TimeTicks::Now(); | 498 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 501 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 499 for (auto& observer : observer_list_) |
| 502 OnCompositingStarted(this, start_time)); | 500 observer.OnCompositingStarted(this, start_time); |
| 503 } | 501 } |
| 504 | 502 |
| 505 void Compositor::DidAbortSwapBuffers() { | 503 void Compositor::DidAbortSwapBuffers() { |
| 506 FOR_EACH_OBSERVER(CompositorObserver, | 504 for (auto& observer : observer_list_) |
| 507 observer_list_, | 505 observer.OnCompositingAborted(this); |
| 508 OnCompositingAborted(this)); | |
| 509 } | 506 } |
| 510 | 507 |
| 511 void Compositor::SetOutputIsSecure(bool output_is_secure) { | 508 void Compositor::SetOutputIsSecure(bool output_is_secure) { |
| 512 context_factory_->SetOutputIsSecure(this, output_is_secure); | 509 context_factory_->SetOutputIsSecure(this, output_is_secure); |
| 513 } | 510 } |
| 514 | 511 |
| 515 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { | 512 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
| 516 return host_->GetDebugState(); | 513 return host_->GetDebugState(); |
| 517 } | 514 } |
| 518 | 515 |
| 519 void Compositor::SetLayerTreeDebugState( | 516 void Compositor::SetLayerTreeDebugState( |
| 520 const cc::LayerTreeDebugState& debug_state) { | 517 const cc::LayerTreeDebugState& debug_state) { |
| 521 host_->SetDebugState(debug_state); | 518 host_->SetDebugState(debug_state); |
| 522 } | 519 } |
| 523 | 520 |
| 524 const cc::RendererSettings& Compositor::GetRendererSettings() const { | 521 const cc::RendererSettings& Compositor::GetRendererSettings() const { |
| 525 return host_->GetSettings().renderer_settings; | 522 return host_->GetSettings().renderer_settings; |
| 526 } | 523 } |
| 527 | 524 |
| 528 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { | 525 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { |
| 529 if (!compositor_lock_) { | 526 if (!compositor_lock_) { |
| 530 compositor_lock_ = new CompositorLock(this); | 527 compositor_lock_ = new CompositorLock(this); |
| 531 host_->SetDeferCommits(true); | 528 host_->SetDeferCommits(true); |
| 532 FOR_EACH_OBSERVER(CompositorObserver, | 529 for (auto& observer : observer_list_) |
| 533 observer_list_, | 530 observer.OnCompositingLockStateChanged(this); |
| 534 OnCompositingLockStateChanged(this)); | |
| 535 } | 531 } |
| 536 return compositor_lock_; | 532 return compositor_lock_; |
| 537 } | 533 } |
| 538 | 534 |
| 539 void Compositor::UnlockCompositor() { | 535 void Compositor::UnlockCompositor() { |
| 540 DCHECK(compositor_lock_); | 536 DCHECK(compositor_lock_); |
| 541 compositor_lock_ = NULL; | 537 compositor_lock_ = NULL; |
| 542 host_->SetDeferCommits(false); | 538 host_->SetDeferCommits(false); |
| 543 FOR_EACH_OBSERVER(CompositorObserver, | 539 for (auto& observer : observer_list_) |
| 544 observer_list_, | 540 observer.OnCompositingLockStateChanged(this); |
| 545 OnCompositingLockStateChanged(this)); | |
| 546 } | 541 } |
| 547 | 542 |
| 548 void Compositor::CancelCompositorLock() { | 543 void Compositor::CancelCompositorLock() { |
| 549 if (compositor_lock_) | 544 if (compositor_lock_) |
| 550 compositor_lock_->CancelLock(); | 545 compositor_lock_->CancelLock(); |
| 551 } | 546 } |
| 552 | 547 |
| 553 } // namespace ui | 548 } // namespace ui |
| OLD | NEW |