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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 | 149 |
| 150 Compositor::~Compositor() { | 150 Compositor::~Compositor() { |
| 151 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 151 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 152 | 152 |
| 153 CancelCompositorLock(); | 153 CancelCompositorLock(); |
| 154 DCHECK(!compositor_lock_); | 154 DCHECK(!compositor_lock_); |
| 155 | 155 |
| 156 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 156 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
| 157 OnCompositingShuttingDown(this)); | 157 OnCompositingShuttingDown(this)); |
| 158 | 158 |
| 159 DCHECK(begin_frame_observer_list_.empty()); | |
| 160 | |
| 159 if (root_layer_) | 161 if (root_layer_) |
| 160 root_layer_->SetCompositor(NULL); | 162 root_layer_->SetCompositor(NULL); |
| 161 | 163 |
| 162 // Stop all outstanding draws before telling the ContextFactory to tear | 164 // Stop all outstanding draws before telling the ContextFactory to tear |
| 163 // down any contexts that the |host_| may rely upon. | 165 // down any contexts that the |host_| may rely upon. |
| 164 host_.reset(); | 166 host_.reset(); |
| 165 | 167 |
| 166 context_factory_->RemoveCompositor(this); | 168 context_factory_->RemoveCompositor(this); |
| 167 } | 169 } |
| 168 | 170 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 void Compositor::RemoveAnimationObserver( | 278 void Compositor::RemoveAnimationObserver( |
| 277 CompositorAnimationObserver* observer) { | 279 CompositorAnimationObserver* observer) { |
| 278 animation_observer_list_.RemoveObserver(observer); | 280 animation_observer_list_.RemoveObserver(observer); |
| 279 } | 281 } |
| 280 | 282 |
| 281 bool Compositor::HasAnimationObserver( | 283 bool Compositor::HasAnimationObserver( |
| 282 const CompositorAnimationObserver* observer) const { | 284 const CompositorAnimationObserver* observer) const { |
| 283 return animation_observer_list_.HasObserver(observer); | 285 return animation_observer_list_.HasObserver(observer); |
| 284 } | 286 } |
| 285 | 287 |
| 288 void Compositor::AddBeginFrameObserver( | |
| 289 CompositorBeginFrameObserver* observer, | |
| 290 const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer) { | |
| 291 // If |last_begin_frame_args_| is still effective, send it to the new | |
|
danakj
2015/03/19 22:36:41
what does "still effective" mean? You're checking
simonhong
2015/03/20 16:07:36
Ah... I got your meaning now.
You mean that making
| |
| 292 // |observer| immediately. | |
| 293 if (last_begin_frame_args_sent_to_observer.frame_time != | |
|
brianderson
2015/03/19 22:48:59
Now that there's a shared CompositorBeginFrameObse
simonhong
2015/03/20 16:07:36
Yep, moved to there.
| |
| 294 missed_begin_frame_args_.frame_time) { | |
| 295 observer->OnSendBeginFrame(missed_begin_frame_args_); | |
|
brianderson
2015/03/19 22:48:59
Then the call to OnSendBeginFrame can move to belo
simonhong
2015/03/20 16:07:36
Done.
| |
| 296 } | |
| 297 | |
| 298 if (begin_frame_observer_list_.empty()) | |
| 299 host_->SetChildrenNeedBeginFrames(true); | |
|
brianderson
2015/03/19 22:48:59
else if (missed_begin_frame_args_.IsValid())
obs
simonhong
2015/03/20 16:07:36
Done.
| |
| 300 | |
| 301 std::list<CompositorBeginFrameObserver*>::iterator it = | |
|
danakj
2015/03/19 22:36:41
do all of this inside the DCHECK please, temp vars
brianderson
2015/03/19 22:48:59
auto? Here and elsewhere.
simonhong
2015/03/20 16:07:36
Done.
| |
| 302 std::find(begin_frame_observer_list_.begin(), | |
| 303 begin_frame_observer_list_.end(), observer); | |
| 304 DCHECK(begin_frame_observer_list_.end() == it); | |
|
danakj
2015/03/19 22:36:41
DCHECK(it != end)
Like we do foo != 5 not 5 != fo
simonhong
2015/03/20 16:07:36
Done.
| |
| 305 | |
| 306 begin_frame_observer_list_.push_back(observer); | |
| 307 } | |
| 308 | |
| 309 void Compositor::RemoveBeginFrameObserver( | |
| 310 CompositorBeginFrameObserver* observer) { | |
| 311 std::list<CompositorBeginFrameObserver*>::iterator it = | |
| 312 std::find(begin_frame_observer_list_.begin(), | |
| 313 begin_frame_observer_list_.end(), observer); | |
| 314 DCHECK(begin_frame_observer_list_.end() != it); | |
|
danakj
2015/03/19 22:36:40
DCHECK(it != end)
simonhong
2015/03/20 16:07:36
Done.
| |
| 315 begin_frame_observer_list_.erase(it); | |
| 316 | |
| 317 if (begin_frame_observer_list_.empty()) | |
| 318 host_->SetChildrenNeedBeginFrames(false); | |
|
brianderson
2015/03/19 22:48:59
To make missed_begin_frame_args_ invalid:
missed_b
simonhong
2015/03/20 16:07:36
Done.
| |
| 319 } | |
| 320 | |
| 286 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 321 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
| 287 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 322 FOR_EACH_OBSERVER(CompositorAnimationObserver, |
| 288 animation_observer_list_, | 323 animation_observer_list_, |
| 289 OnAnimationStep(args.frame_time)); | 324 OnAnimationStep(args.frame_time)); |
| 290 if (animation_observer_list_.might_have_observers()) | 325 if (animation_observer_list_.might_have_observers()) |
| 291 host_->SetNeedsAnimate(); | 326 host_->SetNeedsAnimate(); |
| 292 } | 327 } |
| 293 | 328 |
| 294 void Compositor::BeginMainFrameNotExpectedSoon() { | 329 void Compositor::BeginMainFrameNotExpectedSoon() { |
| 295 } | 330 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 373 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
| 339 OnCompositingStarted(this, start_time)); | 374 OnCompositingStarted(this, start_time)); |
| 340 } | 375 } |
| 341 | 376 |
| 342 void Compositor::DidAbortSwapBuffers() { | 377 void Compositor::DidAbortSwapBuffers() { |
| 343 FOR_EACH_OBSERVER(CompositorObserver, | 378 FOR_EACH_OBSERVER(CompositorObserver, |
| 344 observer_list_, | 379 observer_list_, |
| 345 OnCompositingAborted(this)); | 380 OnCompositingAborted(this)); |
| 346 } | 381 } |
| 347 | 382 |
| 383 void Compositor::SendBeginFramesToChildren(const cc::BeginFrameArgs& args) { | |
| 384 std::list<CompositorBeginFrameObserver*>::iterator it = | |
| 385 begin_frame_observer_list_.begin(); | |
| 386 while(it != begin_frame_observer_list_.end()) { | |
|
danakj
2015/03/19 22:36:41
for (auto* observer : begin_..._list_)
simonhong
2015/03/20 16:07:36
Done.
| |
| 387 (*it)->OnSendBeginFrame(args); | |
| 388 it++; | |
| 389 } | |
| 390 missed_begin_frame_args_ = args; | |
| 391 missed_begin_frame_args_.type = cc::BeginFrameArgs::MISSED; | |
| 392 } | |
| 393 | |
| 348 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { | 394 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
| 349 return host_->debug_state(); | 395 return host_->debug_state(); |
| 350 } | 396 } |
| 351 | 397 |
| 352 void Compositor::SetLayerTreeDebugState( | 398 void Compositor::SetLayerTreeDebugState( |
| 353 const cc::LayerTreeDebugState& debug_state) { | 399 const cc::LayerTreeDebugState& debug_state) { |
| 354 host_->SetDebugState(debug_state); | 400 host_->SetDebugState(debug_state); |
| 355 } | 401 } |
| 356 | 402 |
| 357 const cc::RendererSettings& Compositor::GetRendererSettings() const { | 403 const cc::RendererSettings& Compositor::GetRendererSettings() const { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 377 observer_list_, | 423 observer_list_, |
| 378 OnCompositingLockStateChanged(this)); | 424 OnCompositingLockStateChanged(this)); |
| 379 } | 425 } |
| 380 | 426 |
| 381 void Compositor::CancelCompositorLock() { | 427 void Compositor::CancelCompositorLock() { |
| 382 if (compositor_lock_) | 428 if (compositor_lock_) |
| 383 compositor_lock_->CancelLock(); | 429 compositor_lock_->CancelLock(); |
| 384 } | 430 } |
| 385 | 431 |
| 386 } // namespace ui | 432 } // namespace ui |
| OLD | NEW |