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

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

Issue 2757563003: Remove SurfaceFactory::Reset (Closed)
Patch Set: 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_factory.h ('k') | cc/surfaces/surface_factory_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_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 23 matching lines...) Expand all
34 // could cause a crash or some unexpected behaviour. 34 // could cause a crash or some unexpected behaviour.
35 DCHECK(!current_surface_) << "Please call EvictSurface before destruction"; 35 DCHECK(!current_surface_) << "Please call EvictSurface before destruction";
36 } 36 }
37 37
38 void SurfaceFactory::EvictSurface() { 38 void SurfaceFactory::EvictSurface() {
39 if (!current_surface_) 39 if (!current_surface_)
40 return; 40 return;
41 Destroy(std::move(current_surface_)); 41 Destroy(std::move(current_surface_));
42 } 42 }
43 43
44 void SurfaceFactory::Reset() {
45 EvictSurface();
46 // Disown Surfaces that are still alive so that they don't try to unref
47 // resources that we're not tracking any more.
48 weak_factory_.InvalidateWeakPtrs();
49 holder_.Reset();
50 }
51
52 void SurfaceFactory::SubmitCompositorFrame( 44 void SurfaceFactory::SubmitCompositorFrame(
53 const LocalSurfaceId& local_surface_id, 45 const LocalSurfaceId& local_surface_id,
54 CompositorFrame frame, 46 CompositorFrame frame,
55 const DrawCallback& callback) { 47 const DrawCallback& callback) {
56 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); 48 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame");
57 DCHECK(local_surface_id.is_valid()); 49 DCHECK(local_surface_id.is_valid());
58 std::unique_ptr<Surface> surface; 50 std::unique_ptr<Surface> surface;
59 bool create_new_surface = 51 bool create_new_surface =
60 (!current_surface_ || 52 (!current_surface_ ||
61 local_surface_id != current_surface_->surface_id().local_surface_id()); 53 local_surface_id != current_surface_->surface_id().local_surface_id());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 surface->AddObserver(this); 148 surface->AddObserver(this);
157 return surface; 149 return surface;
158 } 150 }
159 151
160 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { 152 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
161 surface->RemoveObserver(this); 153 surface->RemoveObserver(this);
162 manager_->DestroySurface(std::move(surface)); 154 manager_->DestroySurface(std::move(surface));
163 } 155 }
164 156
165 } // namespace cc 157 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698