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

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

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: 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
« cc/surfaces/surface.cc ('K') | « cc/surfaces/surface_manager.h ('k') | no next file » | 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<SurfaceFactory> surface_factory, 78 base::WeakPtr<SurfaceFactory> surface_factory,
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() && surface_factory); 81 DCHECK(surface_info.is_valid() && surface_factory);
82 82 DCHECK_EQ(surface_info.id().frame_sink_id(),
83 SurfaceId surface_id(surface_factory->frame_sink_id(), local_surface_id); 83 surface_factory->frame_sink_id());
84 84
85 // If no surface with this SurfaceId exists, simply create the surface and 85 // If no surface with this SurfaceId exists, simply create the surface and
86 // return. 86 // return.
87 auto surface_iter = surface_map_.find(surface_id); 87 auto surface_iter = surface_map_.find(surface_info.id());
88 if (surface_iter == surface_map_.end()) { 88 if (surface_iter == surface_map_.end()) {
89 auto surface = base::MakeUnique<Surface>(surface_id, surface_factory); 89 auto surface = base::MakeUnique<Surface>(surface_info, surface_factory);
90 surface_map_[surface->surface_id()] = surface.get(); 90 surface_map_[surface->surface_id()] = surface.get();
91 return surface; 91 return surface;
92 } 92 }
93 93
94 // If a surface with this SurfaceId exists and it's not marked as destroyed, 94 // If a surface with this SurfaceId exists and it's not marked as destroyed,
95 // we should not receive a request to create a new surface with the same 95 // we should not receive a request to create a new surface with the same
96 // SurfaceId. 96 // SurfaceId.
97 DCHECK(surface_iter->second->destroyed()); 97 DCHECK(surface_iter->second->destroyed());
98 98
99 // If a surface with this SurfaceId exists and it's marked as destroyed, 99 // If a surface with this SurfaceId exists and it's marked as destroyed,
100 // it means it's in the garbage collector's queue. We simply take it out of 100 // it means it's in the garbage collector's queue. We simply take it out of
101 // the queue and reuse it. 101 // the queue and reuse it.
102 auto it = 102 auto it =
103 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(), 103 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(),
104 [&surface_id](const std::unique_ptr<Surface>& surface) { 104 [&surface_info](const std::unique_ptr<Surface>& surface) {
105 return surface->surface_id() == surface_id; 105 return surface->surface_id() == surface_info.id();
106 }); 106 });
107 DCHECK(it != surfaces_to_destroy_.end()); 107 DCHECK(it != surfaces_to_destroy_.end());
108 std::unique_ptr<Surface> surface = std::move(*it); 108 std::unique_ptr<Surface> surface = std::move(*it);
109 surfaces_to_destroy_.erase(it); 109 surfaces_to_destroy_.erase(it);
110 surface->set_destroyed(false); 110 surface->set_destroyed(false);
111 DCHECK_EQ(surface_factory.get(), surface->factory().get()); 111 DCHECK_EQ(surface_factory.get(), surface->factory().get());
112 return surface; 112 return surface;
113 } 113 }
114 114
115 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { 115 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 524 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
525 std::sort(children.begin(), children.end()); 525 std::sort(children.begin(), children.end());
526 526
527 for (const SurfaceId& child_id : children) 527 for (const SurfaceId& child_id : children)
528 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 528 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
529 } 529 }
530 } 530 }
531 #endif // DCHECK_IS_ON() 531 #endif // DCHECK_IS_ON()
532 532
533 } // namespace cc 533 } // namespace cc
OLDNEW
« cc/surfaces/surface.cc ('K') | « cc/surfaces/surface_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698