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

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

Issue 2661543002: Rename LocalFrameId to LocalSurfaceId (Closed)
Patch Set: c Created 3 years, 10 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
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_manager_ref_unittest.cc » ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 19 matching lines...) Expand all
30 const FrameSinkSourceMapping& other) = default; 30 const FrameSinkSourceMapping& other) = default;
31 31
32 SurfaceManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() { 32 SurfaceManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() {
33 DCHECK(is_empty()) << "client: " << client 33 DCHECK(is_empty()) << "client: " << client
34 << ", children: " << children.size(); 34 << ", children: " << children.size();
35 } 35 }
36 36
37 SurfaceManager::SurfaceManager(LifetimeType lifetime_type) 37 SurfaceManager::SurfaceManager(LifetimeType lifetime_type)
38 : lifetime_type_(lifetime_type), 38 : lifetime_type_(lifetime_type),
39 root_surface_id_(FrameSinkId(0u, 0u), 39 root_surface_id_(FrameSinkId(0u, 0u),
40 LocalFrameId(1u, base::UnguessableToken::Create())), 40 LocalSurfaceId(1u, base::UnguessableToken::Create())),
41 weak_factory_(this) { 41 weak_factory_(this) {
42 thread_checker_.DetachFromThread(); 42 thread_checker_.DetachFromThread();
43 reference_factory_ = 43 reference_factory_ =
44 new DirectSurfaceReferenceFactory(weak_factory_.GetWeakPtr()); 44 new DirectSurfaceReferenceFactory(weak_factory_.GetWeakPtr());
45 } 45 }
46 46
47 SurfaceManager::~SurfaceManager() { 47 SurfaceManager::~SurfaceManager() {
48 DCHECK(thread_checker_.CalledOnValidThread()); 48 DCHECK(thread_checker_.CalledOnValidThread());
49 49
50 if (lifetime_type_ == LifetimeType::REFERENCES) { 50 if (lifetime_type_ == LifetimeType::REFERENCES) {
51 // Remove all temporary references on shutdown. 51 // Remove all temporary references on shutdown.
52 for (const auto& map_entry : temp_references_) { 52 for (const auto& map_entry : temp_references_) {
53 const FrameSinkId& frame_sink_id = map_entry.first; 53 const FrameSinkId& frame_sink_id = map_entry.first;
54 for (const auto& local_frame_id : map_entry.second) { 54 for (const auto& local_surface_id : map_entry.second) {
55 RemoveSurfaceReferenceImpl(GetRootSurfaceId(), 55 RemoveSurfaceReferenceImpl(GetRootSurfaceId(),
56 SurfaceId(frame_sink_id, local_frame_id)); 56 SurfaceId(frame_sink_id, local_surface_id));
57 } 57 }
58 } 58 }
59 GarbageCollectSurfaces(); 59 GarbageCollectSurfaces();
60 } 60 }
61 61
62 for (SurfaceDestroyList::iterator it = surfaces_to_destroy_.begin(); 62 for (SurfaceDestroyList::iterator it = surfaces_to_destroy_.begin();
63 it != surfaces_to_destroy_.end(); 63 it != surfaces_to_destroy_.end();
64 ++it) { 64 ++it) {
65 DeregisterSurface((*it)->surface_id()); 65 DeregisterSurface((*it)->surface_id());
66 } 66 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // sent over IPC. We don't trust |child_id|, since it is sent over IPC. 150 // sent over IPC. We don't trust |child_id|, since it is sent over IPC.
151 if (surface_map_.count(child_id) == 0) { 151 if (surface_map_.count(child_id) == 0) {
152 DLOG(ERROR) << "No surface in map for " << child_id.ToString(); 152 DLOG(ERROR) << "No surface in map for " << child_id.ToString();
153 return; 153 return;
154 } 154 }
155 155
156 // There could be a temporary reference to |child_id| which we should now 156 // There could be a temporary reference to |child_id| which we should now
157 // remove because a real reference is being added to it. To find out whether 157 // remove because a real reference is being added to it. To find out whether
158 // or not a temporary reference exists, we need to first look up the 158 // or not a temporary reference exists, we need to first look up the
159 // FrameSinkId of |child_id| in |temp_references_|, which returns a vector of 159 // FrameSinkId of |child_id| in |temp_references_|, which returns a vector of
160 // LocalFrameIds, and then search for the LocalFrameId of |child_id| in the 160 // LocalSurfaceIds, and then search for the LocalSurfaceId of |child_id| in
161 // the
161 // said vector. If there is no temporary reference, we can immediately add the 162 // said vector. If there is no temporary reference, we can immediately add the
162 // reference from |parent_id| and return. 163 // reference from |parent_id| and return.
163 auto refs_iter = temp_references_.find(child_id.frame_sink_id()); 164 auto refs_iter = temp_references_.find(child_id.frame_sink_id());
164 if (refs_iter == temp_references_.end()) { 165 if (refs_iter == temp_references_.end()) {
165 AddSurfaceReferenceImpl(parent_id, child_id); 166 AddSurfaceReferenceImpl(parent_id, child_id);
166 return; 167 return;
167 } 168 }
168 std::vector<LocalFrameId>& refs = refs_iter->second; 169 std::vector<LocalSurfaceId>& refs = refs_iter->second;
169 auto temp_ref_iter = 170 auto temp_ref_iter =
170 std::find(refs.begin(), refs.end(), child_id.local_frame_id()); 171 std::find(refs.begin(), refs.end(), child_id.local_surface_id());
171 if (temp_ref_iter == refs.end()) { 172 if (temp_ref_iter == refs.end()) {
172 AddSurfaceReferenceImpl(parent_id, child_id); 173 AddSurfaceReferenceImpl(parent_id, child_id);
173 return; 174 return;
174 } 175 }
175 176
176 // Temporary references are implemented by holding a reference from the top 177 // Temporary references are implemented by holding a reference from the top
177 // level root to the child. If |parent_id| is the top level root, we do 178 // level root to the child. If |parent_id| is the top level root, we do
178 // nothing because the reference already exists. Otherwise, remove the 179 // nothing because the reference already exists. Otherwise, remove the
179 // temporary reference and add the reference. 180 // temporary reference and add the reference.
180 if (parent_id != GetRootSurfaceId()) { 181 if (parent_id != GetRootSurfaceId()) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 588
588 if (lifetime_type_ == LifetimeType::REFERENCES) { 589 if (lifetime_type_ == LifetimeType::REFERENCES) {
589 // We can get into a situation where multiple CompositorFrames arrive for a 590 // We can get into a situation where multiple CompositorFrames arrive for a
590 // CompositorFrameSink before the client can add any references for the 591 // CompositorFrameSink before the client can add any references for the
591 // frame. When the second frame with a new size arrives, the first will be 592 // frame. When the second frame with a new size arrives, the first will be
592 // destroyed in SurfaceFactory and then if there are no references it will 593 // destroyed in SurfaceFactory and then if there are no references it will
593 // be deleted during surface GC. A temporary reference, removed when a real 594 // be deleted during surface GC. A temporary reference, removed when a real
594 // reference is received, is added to prevent this from happening. 595 // reference is received, is added to prevent this from happening.
595 AddSurfaceReferenceImpl(GetRootSurfaceId(), surface_info.id()); 596 AddSurfaceReferenceImpl(GetRootSurfaceId(), surface_info.id());
596 temp_references_[surface_info.id().frame_sink_id()].push_back( 597 temp_references_[surface_info.id().frame_sink_id()].push_back(
597 surface_info.id().local_frame_id()); 598 surface_info.id().local_surface_id());
598 } 599 }
599 600
600 for (auto& observer : observer_list_) 601 for (auto& observer : observer_list_)
601 observer.OnSurfaceCreated(surface_info); 602 observer.OnSurfaceCreated(surface_info);
602 } 603 }
603 604
604 #if DCHECK_IS_ON() 605 #if DCHECK_IS_ON()
605 void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id, 606 void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
606 std::string indent, 607 std::string indent,
607 std::stringstream* str) { 608 std::stringstream* str) {
(...skipping 22 matching lines...) Expand all
630 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 631 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
631 std::sort(children.begin(), children.end()); 632 std::sort(children.begin(), children.end());
632 633
633 for (const SurfaceId& child_id : children) 634 for (const SurfaceId& child_id : children)
634 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 635 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
635 } 636 }
636 } 637 }
637 #endif // DCHECK_IS_ON() 638 #endif // DCHECK_IS_ON()
638 639
639 } // namespace cc 640 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_manager_ref_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698