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

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

Issue 2760433002: SurfaceManager::CreateSurface must set the surface's factory (Closed)
Patch Set: Reset Created 3 years, 9 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.cc ('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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // the queue and reuse it. 115 // the queue and reuse it.
116 auto it = 116 auto it =
117 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(), 117 std::find_if(surfaces_to_destroy_.begin(), surfaces_to_destroy_.end(),
118 [&surface_id](const std::unique_ptr<Surface>& surface) { 118 [&surface_id](const std::unique_ptr<Surface>& surface) {
119 return surface->surface_id() == surface_id; 119 return surface->surface_id() == surface_id;
120 }); 120 });
121 DCHECK(it != surfaces_to_destroy_.end()); 121 DCHECK(it != surfaces_to_destroy_.end());
122 std::unique_ptr<Surface> surface = std::move(*it); 122 std::unique_ptr<Surface> surface = std::move(*it);
123 surfaces_to_destroy_.erase(it); 123 surfaces_to_destroy_.erase(it);
124 surface->set_destroyed(false); 124 surface->set_destroyed(false);
125 // If the surface was used by another factory, we should update its factory.
126 // The old frames must be evicted because the new factory is not capable of
127 // returning their resources.
128 // TODO(samans): This should not be necessary once crbug.com/701988 is fixed.
129 if (surface->factory() == nullptr) {
130 DLOG(ERROR) << "Surface is being reused by another factory. "
131 "Resources can potentially leak. id="
132 << surface_id;
133 surface->Reset();
134 surface->set_factory(surface_factory);
135 }
125 DCHECK_EQ(surface_factory.get(), surface->factory().get()); 136 DCHECK_EQ(surface_factory.get(), surface->factory().get());
126 return surface; 137 return surface;
127 } 138 }
128 139
129 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) { 140 void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) {
130 DCHECK(thread_checker_.CalledOnValidThread()); 141 DCHECK(thread_checker_.CalledOnValidThread());
142
131 surface->set_destroyed(true); 143 surface->set_destroyed(true);
132 surfaces_to_destroy_.push_back(std::move(surface)); 144 surfaces_to_destroy_.push_back(std::move(surface));
133 GarbageCollectSurfaces(); 145 GarbageCollectSurfaces();
134 } 146 }
135 147
136 void SurfaceManager::RequireSequence(const SurfaceId& surface_id, 148 void SurfaceManager::RequireSequence(const SurfaceId& surface_id,
137 const SurfaceSequence& sequence) { 149 const SurfaceSequence& sequence) {
138 auto* surface = GetSurfaceForId(surface_id); 150 auto* surface = GetSurfaceForId(surface_id);
139 if (!surface) { 151 if (!surface) {
140 DLOG(ERROR) << "Attempting to require callback on nonexistent surface"; 152 DLOG(ERROR) << "Attempting to require callback on nonexistent surface";
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 700 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
689 std::sort(children.begin(), children.end()); 701 std::sort(children.begin(), children.end());
690 702
691 for (const SurfaceId& child_id : children) 703 for (const SurfaceId& child_id : children)
692 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 704 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
693 } 705 }
694 } 706 }
695 #endif // DCHECK_IS_ON() 707 #endif // DCHECK_IS_ON()
696 708
697 } // namespace cc 709 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698