Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: cc/surfaces/surface_manager.cc

Issue 2854163003: [cc] Plumb BeginFrameAcks through SurfaceManager to DisplayScheduler. (Closed)
Patch Set: Pass ack via SurfaceDamaged, add back tests. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_)
sunnyps 2017/05/25 20:49:13 nit: Why OnSurfaceDestroyed in addition to OnSurfa
Eric Seckler 2017/05/26 10:57:52 I want to avoid waiting for destroyed Surfaces (th
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 448 }
447 449
448 Surface* SurfaceManager::GetSurfaceForId(const SurfaceId& surface_id) { 450 Surface* SurfaceManager::GetSurfaceForId(const SurfaceId& surface_id) {
449 DCHECK(thread_checker_.CalledOnValidThread()); 451 DCHECK(thread_checker_.CalledOnValidThread());
450 SurfaceMap::iterator it = surface_map_.find(surface_id); 452 SurfaceMap::iterator it = surface_map_.find(surface_id);
451 if (it == surface_map_.end()) 453 if (it == surface_map_.end())
452 return nullptr; 454 return nullptr;
453 return it->second; 455 return it->second;
454 } 456 }
455 457
456 bool SurfaceManager::SurfaceModified(const SurfaceId& surface_id) { 458 bool SurfaceManager::SurfaceModified(const SurfaceId& surface_id,
459 const BeginFrameAck& ack) {
457 CHECK(thread_checker_.CalledOnValidThread()); 460 CHECK(thread_checker_.CalledOnValidThread());
458 bool changed = false; 461 bool changed = false;
459 for (auto& observer : observer_list_) 462 for (auto& observer : observer_list_)
460 observer.OnSurfaceDamaged(surface_id, &changed); 463 observer.OnSurfaceDamaged(surface_id, ack, &changed);
461 return changed; 464 return changed;
462 } 465 }
463 466
464 void SurfaceManager::SurfaceCreated(const SurfaceInfo& surface_info) { 467 void SurfaceManager::SurfaceCreated(const SurfaceInfo& surface_info) {
465 CHECK(thread_checker_.CalledOnValidThread()); 468 CHECK(thread_checker_.CalledOnValidThread());
466 469
467 if (lifetime_type_ == LifetimeType::REFERENCES) { 470 if (lifetime_type_ == LifetimeType::REFERENCES) {
468 // We can get into a situation where multiple CompositorFrames arrive for 471 // We can get into a situation where multiple CompositorFrames arrive for
469 // a CompositorFrameSink before the client can add any references for the 472 // a CompositorFrameSink before the client can add any references for the
470 // frame. When the second frame with a new size arrives, the first will be 473 // frame. When the second frame with a new size arrives, the first will be
(...skipping 22 matching lines...) Expand all
493 } 496 }
494 } 497 }
495 498
496 void SurfaceManager::SurfaceDiscarded(Surface* surface) { 499 void SurfaceManager::SurfaceDiscarded(Surface* surface) {
497 for (auto& observer : observer_list_) 500 for (auto& observer : observer_list_)
498 observer.OnSurfaceDiscarded(surface->surface_id()); 501 observer.OnSurfaceDiscarded(surface->surface_id());
499 if (dependency_tracker_) 502 if (dependency_tracker_)
500 dependency_tracker_->OnSurfaceDiscarded(surface); 503 dependency_tracker_->OnSurfaceDiscarded(surface);
501 } 504 }
502 505
506 void SurfaceManager::SurfaceDamageExpected(const SurfaceId& surface_id,
507 const BeginFrameArgs& args) {
508 DCHECK(thread_checker_.CalledOnValidThread());
509 for (auto& observer : observer_list_)
510 observer.OnSurfaceDamageExpected(surface_id, args);
511 }
512
503 void SurfaceManager::UnregisterSurface(const SurfaceId& surface_id) { 513 void SurfaceManager::UnregisterSurface(const SurfaceId& surface_id) {
504 DCHECK(thread_checker_.CalledOnValidThread()); 514 DCHECK(thread_checker_.CalledOnValidThread());
505 SurfaceMap::iterator it = surface_map_.find(surface_id); 515 SurfaceMap::iterator it = surface_map_.find(surface_id);
506 DCHECK(it != surface_map_.end()); 516 DCHECK(it != surface_map_.end());
507 surface_map_.erase(it); 517 surface_map_.erase(it);
508 RemoveAllSurfaceReferences(surface_id); 518 RemoveAllSurfaceReferences(surface_id);
509 } 519 }
510 520
511 #if DCHECK_IS_ON() 521 #if DCHECK_IS_ON()
512 void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id, 522 void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 555 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
546 std::sort(children.begin(), children.end()); 556 std::sort(children.begin(), children.end());
547 557
548 for (const SurfaceId& child_id : children) 558 for (const SurfaceId& child_id : children)
549 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 559 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
550 } 560 }
551 } 561 }
552 #endif // DCHECK_IS_ON() 562 #endif // DCHECK_IS_ON()
553 563
554 } // namespace cc 564 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698