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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); | 168 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); |
169 host_->SetLayerTreeHostClientReady(); | 169 host_->SetLayerTreeHostClientReady(); |
170 } | 170 } |
171 | 171 |
172 Compositor::~Compositor() { | 172 Compositor::~Compositor() { |
173 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 173 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
174 | 174 |
175 CancelCompositorLock(); | 175 CancelCompositorLock(); |
176 DCHECK(!compositor_lock_); | 176 DCHECK(!compositor_lock_); |
177 | 177 |
| 178 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
| 179 OnCompositingShuttingDown(this)); |
| 180 |
178 if (root_layer_) | 181 if (root_layer_) |
179 root_layer_->SetCompositor(NULL); | 182 root_layer_->SetCompositor(NULL); |
180 | 183 |
181 // Stop all outstanding draws before telling the ContextFactory to tear | 184 // Stop all outstanding draws before telling the ContextFactory to tear |
182 // down any contexts that the |host_| may rely upon. | 185 // down any contexts that the |host_| may rely upon. |
183 host_.reset(); | 186 host_.reset(); |
184 | 187 |
185 context_factory_->RemoveCompositor(this); | 188 context_factory_->RemoveCompositor(this); |
186 } | 189 } |
187 | 190 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 295 |
293 void Compositor::SetVisible(bool visible) { | 296 void Compositor::SetVisible(bool visible) { |
294 host_->SetVisible(visible); | 297 host_->SetVisible(visible); |
295 } | 298 } |
296 | 299 |
297 scoped_refptr<CompositorVSyncManager> Compositor::vsync_manager() const { | 300 scoped_refptr<CompositorVSyncManager> Compositor::vsync_manager() const { |
298 return vsync_manager_; | 301 return vsync_manager_; |
299 } | 302 } |
300 | 303 |
301 void Compositor::AddObserver(CompositorObserver* observer) { | 304 void Compositor::AddObserver(CompositorObserver* observer) { |
302 #if defined(OS_MACOSX) | |
303 // Debugging instrumentation for crbug.com/401630. | |
304 // TODO(ccameron): remove this. | |
305 CHECK(observer); | |
306 if (!observer_list_.HasObserver(observer)) | |
307 observer->observing_count_ += 1; | |
308 #endif | |
309 | |
310 observer_list_.AddObserver(observer); | 305 observer_list_.AddObserver(observer); |
311 } | 306 } |
312 | 307 |
313 void Compositor::RemoveObserver(CompositorObserver* observer) { | 308 void Compositor::RemoveObserver(CompositorObserver* observer) { |
314 #if defined(OS_MACOSX) | |
315 // Debugging instrumentation for crbug.com/401630. | |
316 // TODO(ccameron): remove this. | |
317 if (observer_list_.HasObserver(observer)) | |
318 observer->observing_count_ -= 1; | |
319 #endif | |
320 | |
321 observer_list_.RemoveObserver(observer); | 309 observer_list_.RemoveObserver(observer); |
322 } | 310 } |
323 | 311 |
324 bool Compositor::HasObserver(const CompositorObserver* observer) const { | 312 bool Compositor::HasObserver(const CompositorObserver* observer) const { |
325 return observer_list_.HasObserver(observer); | 313 return observer_list_.HasObserver(observer); |
326 } | 314 } |
327 | 315 |
328 void Compositor::AddAnimationObserver(CompositorAnimationObserver* observer) { | 316 void Compositor::AddAnimationObserver(CompositorAnimationObserver* observer) { |
329 animation_observer_list_.AddObserver(observer); | 317 animation_observer_list_.AddObserver(observer); |
330 host_->SetNeedsAnimate(); | 318 host_->SetNeedsAnimate(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // Call ScheduleDraw() instead of Draw() in order to allow other | 471 // Call ScheduleDraw() instead of Draw() in order to allow other |
484 // CompositorObservers to be notified before starting another | 472 // CompositorObservers to be notified before starting another |
485 // draw cycle. | 473 // draw cycle. |
486 ScheduleDraw(); | 474 ScheduleDraw(); |
487 } | 475 } |
488 FOR_EACH_OBSERVER( | 476 FOR_EACH_OBSERVER( |
489 CompositorObserver, observer_list_, OnCompositingEnded(this)); | 477 CompositorObserver, observer_list_, OnCompositingEnded(this)); |
490 } | 478 } |
491 | 479 |
492 } // namespace ui | 480 } // namespace ui |
OLD | NEW |