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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 452 } |
451 | 453 |
452 Surface* SurfaceManager::GetSurfaceForId(const SurfaceId& surface_id) { | 454 Surface* SurfaceManager::GetSurfaceForId(const SurfaceId& surface_id) { |
453 DCHECK(thread_checker_.CalledOnValidThread()); | 455 DCHECK(thread_checker_.CalledOnValidThread()); |
454 SurfaceMap::iterator it = surface_map_.find(surface_id); | 456 SurfaceMap::iterator it = surface_map_.find(surface_id); |
455 if (it == surface_map_.end()) | 457 if (it == surface_map_.end()) |
456 return nullptr; | 458 return nullptr; |
457 return it->second; | 459 return it->second; |
458 } | 460 } |
459 | 461 |
460 bool SurfaceManager::SurfaceModified(const SurfaceId& surface_id) { | 462 bool SurfaceManager::SurfaceModified(const SurfaceId& surface_id, |
| 463 const BeginFrameAck& ack) { |
461 CHECK(thread_checker_.CalledOnValidThread()); | 464 CHECK(thread_checker_.CalledOnValidThread()); |
462 bool changed = false; | 465 bool changed = false; |
463 for (auto& observer : observer_list_) | 466 for (auto& observer : observer_list_) |
464 observer.OnSurfaceDamaged(surface_id, &changed); | 467 observer.OnSurfaceDamaged(surface_id, ack, &changed); |
465 return changed; | 468 return changed; |
466 } | 469 } |
467 | 470 |
468 void SurfaceManager::SurfaceCreated(const SurfaceInfo& surface_info) { | 471 void SurfaceManager::SurfaceCreated(const SurfaceInfo& surface_info) { |
469 CHECK(thread_checker_.CalledOnValidThread()); | 472 CHECK(thread_checker_.CalledOnValidThread()); |
470 | 473 |
471 if (lifetime_type_ == LifetimeType::REFERENCES) { | 474 if (lifetime_type_ == LifetimeType::REFERENCES) { |
472 // We can get into a situation where multiple CompositorFrames arrive for | 475 // We can get into a situation where multiple CompositorFrames arrive for |
473 // a CompositorFrameSink before the client can add any references for the | 476 // a CompositorFrameSink before the client can add any references for the |
474 // frame. When the second frame with a new size arrives, the first will be | 477 // frame. When the second frame with a new size arrives, the first will be |
(...skipping 22 matching lines...) Expand all Loading... |
497 } | 500 } |
498 } | 501 } |
499 | 502 |
500 void SurfaceManager::SurfaceDiscarded(Surface* surface) { | 503 void SurfaceManager::SurfaceDiscarded(Surface* surface) { |
501 for (auto& observer : observer_list_) | 504 for (auto& observer : observer_list_) |
502 observer.OnSurfaceDiscarded(surface->surface_id()); | 505 observer.OnSurfaceDiscarded(surface->surface_id()); |
503 if (dependency_tracker_) | 506 if (dependency_tracker_) |
504 dependency_tracker_->OnSurfaceDiscarded(surface); | 507 dependency_tracker_->OnSurfaceDiscarded(surface); |
505 } | 508 } |
506 | 509 |
| 510 void SurfaceManager::SurfaceDamageExpected(const SurfaceId& surface_id, |
| 511 const BeginFrameArgs& args) { |
| 512 DCHECK(thread_checker_.CalledOnValidThread()); |
| 513 for (auto& observer : observer_list_) |
| 514 observer.OnSurfaceDamageExpected(surface_id, args); |
| 515 } |
| 516 |
507 void SurfaceManager::UnregisterSurface(const SurfaceId& surface_id) { | 517 void SurfaceManager::UnregisterSurface(const SurfaceId& surface_id) { |
508 DCHECK(thread_checker_.CalledOnValidThread()); | 518 DCHECK(thread_checker_.CalledOnValidThread()); |
509 SurfaceMap::iterator it = surface_map_.find(surface_id); | 519 SurfaceMap::iterator it = surface_map_.find(surface_id); |
510 DCHECK(it != surface_map_.end()); | 520 DCHECK(it != surface_map_.end()); |
511 surface_map_.erase(it); | 521 surface_map_.erase(it); |
512 RemoveAllSurfaceReferences(surface_id); | 522 RemoveAllSurfaceReferences(surface_id); |
513 } | 523 } |
514 | 524 |
515 #if DCHECK_IS_ON() | 525 #if DCHECK_IS_ON() |
516 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... |
549 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); | 559 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); |
550 std::sort(children.begin(), children.end()); | 560 std::sort(children.begin(), children.end()); |
551 | 561 |
552 for (const SurfaceId& child_id : children) | 562 for (const SurfaceId& child_id : children) |
553 SurfaceReferencesToStringImpl(child_id, indent + " ", str); | 563 SurfaceReferencesToStringImpl(child_id, indent + " ", str); |
554 } | 564 } |
555 } | 565 } |
556 #endif // DCHECK_IS_ON() | 566 #endif // DCHECK_IS_ON() |
557 | 567 |
558 } // namespace cc | 568 } // namespace cc |
OLD | NEW |