OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/surfaces/surface_manager.h" | 5 #include "cc/surfaces/surface_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 surfaces_to_destroy_.erase(it); | 111 surfaces_to_destroy_.erase(it); |
112 surface->set_destroyed(false); | 112 surface->set_destroyed(false); |
113 DCHECK_EQ(compositor_frame_sink_support.get(), | 113 DCHECK_EQ(compositor_frame_sink_support.get(), |
114 surface->compositor_frame_sink_support().get()); | 114 surface->compositor_frame_sink_support().get()); |
115 return surface; | 115 return surface; |
116 } | 116 } |
117 | 117 |
118 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { | 118 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { |
119 DCHECK(thread_checker_.CalledOnValidThread()); | 119 DCHECK(thread_checker_.CalledOnValidThread()); |
120 surface->set_destroyed(true); | 120 surface->set_destroyed(true); |
| 121 for (auto& observer : observer_list_) |
| 122 observer.OnSurfaceDestroyed(surface->surface_id()); |
121 surfaces_to_destroy_.push_back(std::move(surface)); | 123 surfaces_to_destroy_.push_back(std::move(surface)); |
122 GarbageCollectSurfaces(); | 124 GarbageCollectSurfaces(); |
123 } | 125 } |
124 | 126 |
125 void SurfaceManager::RequireSequence(const SurfaceId& surface_id, | 127 void SurfaceManager::RequireSequence(const SurfaceId& surface_id, |
126 const SurfaceSequence& sequence) { | 128 const SurfaceSequence& sequence) { |
127 auto* surface = GetSurfaceForId(surface_id); | 129 auto* surface = GetSurfaceForId(surface_id); |
128 if (!surface) { | 130 if (!surface) { |
129 DLOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 131 DLOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
130 return; | 132 return; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 dependency_tracker_->OnSurfaceDependenciesChanged( | 493 dependency_tracker_->OnSurfaceDependenciesChanged( |
492 surface, added_dependencies, removed_dependencies); | 494 surface, added_dependencies, removed_dependencies); |
493 } | 495 } |
494 } | 496 } |
495 | 497 |
496 void SurfaceManager::SurfaceDiscarded(Surface* surface) { | 498 void SurfaceManager::SurfaceDiscarded(Surface* surface) { |
497 if (dependency_tracker_) | 499 if (dependency_tracker_) |
498 dependency_tracker_->OnSurfaceDiscarded(surface); | 500 dependency_tracker_->OnSurfaceDiscarded(surface); |
499 } | 501 } |
500 | 502 |
| 503 void SurfaceManager::SurfaceReceivedBeginFrame(const SurfaceId& surface_id, |
| 504 const BeginFrameArgs& args) { |
| 505 DCHECK(thread_checker_.CalledOnValidThread()); |
| 506 for (auto& observer : observer_list_) |
| 507 observer.OnSurfaceReceivedBeginFrame(surface_id, args); |
| 508 } |
| 509 |
| 510 void SurfaceManager::SurfaceFinishedBeginFrame(const SurfaceId& surface_id, |
| 511 const BeginFrameAck& ack) { |
| 512 DCHECK(thread_checker_.CalledOnValidThread()); |
| 513 for (auto& observer : observer_list_) |
| 514 observer.OnSurfaceFinishedBeginFrame(surface_id, ack); |
| 515 } |
| 516 |
501 void SurfaceManager::UnregisterSurface(const SurfaceId& surface_id) { | 517 void SurfaceManager::UnregisterSurface(const SurfaceId& surface_id) { |
502 DCHECK(thread_checker_.CalledOnValidThread()); | 518 DCHECK(thread_checker_.CalledOnValidThread()); |
503 SurfaceMap::iterator it = surface_map_.find(surface_id); | 519 SurfaceMap::iterator it = surface_map_.find(surface_id); |
504 DCHECK(it != surface_map_.end()); | 520 DCHECK(it != surface_map_.end()); |
505 surface_map_.erase(it); | 521 surface_map_.erase(it); |
506 RemoveAllSurfaceReferences(surface_id); | 522 RemoveAllSurfaceReferences(surface_id); |
507 } | 523 } |
508 | 524 |
509 #if DCHECK_IS_ON() | 525 #if DCHECK_IS_ON() |
510 void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id, | 526 void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); | 559 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); |
544 std::sort(children.begin(), children.end()); | 560 std::sort(children.begin(), children.end()); |
545 | 561 |
546 for (const SurfaceId& child_id : children) | 562 for (const SurfaceId& child_id : children) |
547 SurfaceReferencesToStringImpl(child_id, indent + " ", str); | 563 SurfaceReferencesToStringImpl(child_id, indent + " ", str); |
548 } | 564 } |
549 } | 565 } |
550 #endif // DCHECK_IS_ON() | 566 #endif // DCHECK_IS_ON() |
551 | 567 |
552 } // namespace cc | 568 } // namespace cc |
OLD | NEW |