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

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

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_sequence.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_id_allocator.h" 9 #include "cc/surfaces/surface_id_allocator.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 SurfaceManager::SurfaceManager() { 13 SurfaceManager::SurfaceManager() {
14 thread_checker_.DetachFromThread(); 14 thread_checker_.DetachFromThread();
15 } 15 }
16 16
17 SurfaceManager::~SurfaceManager() { 17 SurfaceManager::~SurfaceManager() {
18 DCHECK(thread_checker_.CalledOnValidThread()); 18 DCHECK(thread_checker_.CalledOnValidThread());
19 for (SurfaceDestroyList::iterator it = surfaces_to_destroy_.begin(); 19 for (SurfaceDestroyList::iterator it = surfaces_to_destroy_.begin();
20 it != surfaces_to_destroy_.end(); 20 it != surfaces_to_destroy_.end();
21 ++it) { 21 ++it) {
22 DeregisterSurface(it->first->surface_id()); 22 DeregisterSurface((*it)->surface_id());
23 delete it->first; 23 delete *it;
24 } 24 }
25 } 25 }
26 26
27 void SurfaceManager::RegisterSurface(Surface* surface) { 27 void SurfaceManager::RegisterSurface(Surface* surface) {
28 DCHECK(thread_checker_.CalledOnValidThread()); 28 DCHECK(thread_checker_.CalledOnValidThread());
29 DCHECK(surface); 29 DCHECK(surface);
30 DCHECK(!surface_map_.count(surface->surface_id())); 30 DCHECK(!surface_map_.count(surface->surface_id()));
31 surface_map_[surface->surface_id()] = surface; 31 surface_map_[surface->surface_id()] = surface;
32 } 32 }
33 33
34 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) { 34 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) {
35 DCHECK(thread_checker_.CalledOnValidThread()); 35 DCHECK(thread_checker_.CalledOnValidThread());
36 SurfaceMap::iterator it = surface_map_.find(surface_id); 36 SurfaceMap::iterator it = surface_map_.find(surface_id);
37 DCHECK(it != surface_map_.end()); 37 DCHECK(it != surface_map_.end());
38 surface_map_.erase(it); 38 surface_map_.erase(it);
39 } 39 }
40 40
41 void SurfaceManager::DestroyOnSequence( 41 void SurfaceManager::Destroy(scoped_ptr<Surface> surface) {
42 scoped_ptr<Surface> surface, 42 DCHECK(thread_checker_.CalledOnValidThread());
43 const std::set<SurfaceSequence>& dependency_set) { 43 surfaces_to_destroy_.push_back(surface.release());
44 surfaces_to_destroy_.push_back(make_pair(surface.release(), dependency_set));
45 SearchForSatisfaction(); 44 SearchForSatisfaction();
46 } 45 }
47 46
48 void SurfaceManager::DidSatisfySequences(SurfaceId id, 47 void SurfaceManager::DidSatisfySequences(uint32_t id_namespace,
49 std::vector<uint32_t>* sequence) { 48 std::vector<uint32_t>* sequence) {
49 DCHECK(thread_checker_.CalledOnValidThread());
50 for (std::vector<uint32_t>::iterator it = sequence->begin(); 50 for (std::vector<uint32_t>::iterator it = sequence->begin();
51 it != sequence->end(); 51 it != sequence->end();
52 ++it) { 52 ++it) {
53 satisfied_sequences_.insert( 53 satisfied_sequences_.insert(SurfaceSequence(id_namespace, *it));
54 SurfaceSequence(SurfaceIdAllocator::NamespaceForId(id), *it));
55 } 54 }
56 sequence->clear(); 55 sequence->clear();
57 SearchForSatisfaction(); 56 SearchForSatisfaction();
58 } 57 }
59 58
60 void SurfaceManager::SearchForSatisfaction() { 59 void SurfaceManager::SearchForSatisfaction() {
61 for (SurfaceDestroyList::iterator dest_it = surfaces_to_destroy_.begin(); 60 for (SurfaceDestroyList::iterator dest_it = surfaces_to_destroy_.begin();
62 dest_it != surfaces_to_destroy_.end();) { 61 dest_it != surfaces_to_destroy_.end();) {
63 std::set<SurfaceSequence>& dependency_set = dest_it->second; 62 (*dest_it)->SatisfyDestructionDependencies(&satisfied_sequences_);
64 63 if (!(*dest_it)->GetDestructionDependencyCount()) {
65 for (std::set<SurfaceSequence>::iterator it = dependency_set.begin(); 64 scoped_ptr<Surface> surf(*dest_it);
66 it != dependency_set.end();) {
67 if (satisfied_sequences_.count(*it) > 0) {
68 satisfied_sequences_.erase(*it);
69 std::set<SurfaceSequence>::iterator old_it = it;
70 ++it;
71 dependency_set.erase(old_it);
72 } else {
73 ++it;
74 }
75 }
76 if (dependency_set.empty()) {
77 scoped_ptr<Surface> surf(dest_it->first);
78 DeregisterSurface(surf->surface_id()); 65 DeregisterSurface(surf->surface_id());
79 dest_it = surfaces_to_destroy_.erase(dest_it); 66 dest_it = surfaces_to_destroy_.erase(dest_it);
80 } else { 67 } else {
81 ++dest_it; 68 ++dest_it;
82 } 69 }
83 } 70 }
84 } 71 }
85 72
86 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) { 73 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) {
87 DCHECK(thread_checker_.CalledOnValidThread()); 74 DCHECK(thread_checker_.CalledOnValidThread());
88 SurfaceMap::iterator it = surface_map_.find(surface_id); 75 SurfaceMap::iterator it = surface_map_.find(surface_id);
89 if (it == surface_map_.end()) 76 if (it == surface_map_.end())
90 return NULL; 77 return NULL;
91 return it->second; 78 return it->second;
92 } 79 }
93 80
94 void SurfaceManager::SurfaceModified(SurfaceId surface_id) { 81 void SurfaceManager::SurfaceModified(SurfaceId surface_id) {
95 DCHECK(thread_checker_.CalledOnValidThread()); 82 DCHECK(thread_checker_.CalledOnValidThread());
96 FOR_EACH_OBSERVER( 83 FOR_EACH_OBSERVER(
97 SurfaceDamageObserver, observer_list_, OnSurfaceDamaged(surface_id)); 84 SurfaceDamageObserver, observer_list_, OnSurfaceDamaged(surface_id));
98 } 85 }
99 86
100 } // namespace cc 87 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_sequence.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698