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

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

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Rebase SurfaceSynchronizationTest 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_manager_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>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "cc/surfaces/compositor_frame_sink_support.h"
14 #include "cc/surfaces/direct_surface_reference_factory.h" 15 #include "cc/surfaces/direct_surface_reference_factory.h"
15 #include "cc/surfaces/local_surface_id_allocator.h" 16 #include "cc/surfaces/local_surface_id_allocator.h"
16 #include "cc/surfaces/surface.h" 17 #include "cc/surfaces/surface.h"
17 #include "cc/surfaces/surface_factory_client.h"
18 #include "cc/surfaces/surface_info.h" 18 #include "cc/surfaces/surface_info.h"
19 19
20 #if DCHECK_IS_ON() 20 #if DCHECK_IS_ON()
21 #include <sstream> 21 #include <sstream>
22 #endif 22 #endif
23 23
24 namespace cc { 24 namespace cc {
25 25
26 SurfaceManager::SurfaceManager(LifetimeType lifetime_type) 26 SurfaceManager::SurfaceManager(LifetimeType lifetime_type)
27 : lifetime_type_(lifetime_type), 27 : lifetime_type_(lifetime_type),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker) { 68 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker) {
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<CompositorFrameSinkSupport> compositor_frame_sink_support,
79 const LocalSurfaceId& local_surface_id) { 79 const LocalSurfaceId& local_surface_id) {
80 DCHECK(thread_checker_.CalledOnValidThread()); 80 DCHECK(thread_checker_.CalledOnValidThread());
81 DCHECK(local_surface_id.is_valid() && surface_factory); 81 DCHECK(local_surface_id.is_valid() && compositor_frame_sink_support);
82 82
83 SurfaceId surface_id(surface_factory->frame_sink_id(), local_surface_id); 83 SurfaceId surface_id(compositor_frame_sink_support->frame_sink_id(),
84 local_surface_id);
84 85
85 // 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
86 // return. 87 // return.
87 auto surface_iter = surface_map_.find(surface_id); 88 auto surface_iter = surface_map_.find(surface_id);
88 if (surface_iter == surface_map_.end()) { 89 if (surface_iter == surface_map_.end()) {
89 auto surface = base::MakeUnique<Surface>(surface_id, surface_factory); 90 auto surface =
91 base::MakeUnique<Surface>(surface_id, compositor_frame_sink_support);
90 surface_map_[surface->surface_id()] = surface.get(); 92 surface_map_[surface->surface_id()] = surface.get();
91 return surface; 93 return surface;
92 } 94 }
93 95
94 // 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,
95 // 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
96 // SurfaceId. 98 // SurfaceId.
97 DCHECK(surface_iter->second->destroyed()); 99 DCHECK(surface_iter->second->destroyed());
98 100
99 // 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,
100 // 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
101 // the queue and reuse it. 103 // the queue and reuse it.
102 auto it = 104 auto it =
103 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(), 105 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(),
104 [&surface_id](const std::unique_ptr<Surface>& surface) { 106 [&surface_id](const std::unique_ptr<Surface>& surface) {
105 return surface->surface_id() == surface_id; 107 return surface->surface_id() == surface_id;
106 }); 108 });
107 DCHECK(it != surfaces_to_destroy_.end()); 109 DCHECK(it != surfaces_to_destroy_.end());
108 std::unique_ptr<Surface> surface = std::move(*it); 110 std::unique_ptr<Surface> surface = std::move(*it);
109 surfaces_to_destroy_.erase(it); 111 surfaces_to_destroy_.erase(it);
110 surface->set_destroyed(false); 112 surface->set_destroyed(false);
111 DCHECK_EQ(surface_factory.get(), surface->factory().get()); 113 DCHECK_EQ(compositor_frame_sink_support.get(),
114 surface->compositor_frame_sink_support().get());
112 return surface; 115 return surface;
113 } 116 }
114 117
115 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { 118 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) {
116 DCHECK(thread_checker_.CalledOnValidThread()); 119 DCHECK(thread_checker_.CalledOnValidThread());
117 surface->set_destroyed(true); 120 surface->set_destroyed(true);
118 surfaces_to_destroy_.push_back(std::move(surface)); 121 surfaces_to_destroy_.push_back(std::move(surface));
119 GarbageCollectSurfaces(); 122 GarbageCollectSurfaces();
120 } 123 }
121 124
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 523 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
521 std::sort(children.begin(), children.end()); 524 std::sort(children.begin(), children.end());
522 525
523 for (const SurfaceId& child_id : children) 526 for (const SurfaceId& child_id : children)
524 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 527 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
525 } 528 }
526 } 529 }
527 #endif // DCHECK_IS_ON() 530 #endif // DCHECK_IS_ON()
528 531
529 } // namespace cc 532 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698