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

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

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Address comments 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
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 dependency_tracker_ = std::move(dependency_tracker); 69 dependency_tracker_ = std::move(dependency_tracker);
70 } 70 }
71 71
72 void SurfaceManager::RequestSurfaceResolution(Surface* pending_surface) { 72 void SurfaceManager::RequestSurfaceResolution(Surface* pending_surface) {
73 if (dependency_tracker_) 73 if (dependency_tracker_)
74 dependency_tracker_->RequestSurfaceResolution(pending_surface); 74 dependency_tracker_->RequestSurfaceResolution(pending_surface);
75 } 75 }
76 76
77 std::unique_ptr<Surface> SurfaceManager::CreateSurface( 77 std::unique_ptr<Surface> SurfaceManager::CreateSurface(
78 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support, 78 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support,
79 const LocalSurfaceId& local_surface_id) { 79 const SurfaceInfo& surface_info) {
80 DCHECK(thread_checker_.CalledOnValidThread()); 80 DCHECK(thread_checker_.CalledOnValidThread());
81 DCHECK(local_surface_id.is_valid() && compositor_frame_sink_support); 81 DCHECK(surface_info.is_valid());
82 82 DCHECK(compositor_frame_sink_support);
83 SurfaceId surface_id(compositor_frame_sink_support->frame_sink_id(), 83 DCHECK_EQ(surface_info.id().frame_sink_id(),
84 local_surface_id); 84 compositor_frame_sink_support->frame_sink_id());
85 85
86 // If no surface with this SurfaceId exists, simply create the surface and 86 // If no surface with this SurfaceId exists, simply create the surface and
87 // return. 87 // return.
88 auto surface_iter = surface_map_.find(surface_id); 88 auto surface_iter = surface_map_.find(surface_info.id());
89 if (surface_iter == surface_map_.end()) { 89 if (surface_iter == surface_map_.end()) {
90 auto surface = 90 auto surface =
91 base::MakeUnique<Surface>(surface_id, compositor_frame_sink_support); 91 base::MakeUnique<Surface>(surface_info, compositor_frame_sink_support);
92 surface_map_[surface->surface_id()] = surface.get(); 92 surface_map_[surface->surface_id()] = surface.get();
93 return surface; 93 return surface;
94 } 94 }
95 95
96 // If a surface with this SurfaceId exists and it's not marked as destroyed, 96 // If a surface with this SurfaceId exists and it's not marked as destroyed,
97 // we should not receive a request to create a new surface with the same 97 // we should not receive a request to create a new surface with the same
98 // SurfaceId. 98 // SurfaceId.
99 DCHECK(surface_iter->second->destroyed()); 99 DCHECK(surface_iter->second->destroyed());
100 100
101 // If a surface with this SurfaceId exists and it's marked as destroyed, 101 // If a surface with this SurfaceId exists and it's marked as destroyed,
102 // it means it's in the garbage collector's queue. We simply take it out of 102 // it means it's in the garbage collector's queue. We simply take it out of
103 // the queue and reuse it. 103 // the queue and reuse it.
104 auto it = 104 auto it =
105 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(), 105 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(),
106 [&surface_id](const std::unique_ptr<Surface>& surface) { 106 [&surface_info](const std::unique_ptr<Surface>& surface) {
107 return surface->surface_id() == surface_id; 107 return surface->surface_id() == surface_info.id();
108 }); 108 });
109 DCHECK(it != surfaces_to_destroy_.end()); 109 DCHECK(it != surfaces_to_destroy_.end());
110 std::unique_ptr<Surface> surface = std::move(*it); 110 std::unique_ptr<Surface> surface = std::move(*it);
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
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 543 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
544 std::sort(children.begin(), children.end()); 544 std::sort(children.begin(), children.end());
545 545
546 for (const SurfaceId& child_id : children) 546 for (const SurfaceId& child_id : children)
547 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 547 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
548 } 548 }
549 } 549 }
550 #endif // DCHECK_IS_ON() 550 #endif // DCHECK_IS_ON()
551 551
552 } // namespace cc 552 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698