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

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

Issue 683623003: Add more WeakPtr checks for SurfaceFactory in SurfaceAggregator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | 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_aggregator.h" 5 #include "cc/surfaces/surface_aggregator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator)); 84 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator));
85 } 85 }
86 allocator->AddKnownPass(surface_local_pass_id); 86 allocator->AddKnownPass(surface_local_pass_id);
87 return allocator->Remap(surface_local_pass_id); 87 return allocator->Remap(surface_local_pass_id);
88 } 88 }
89 89
90 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { 90 int SurfaceAggregator::ChildIdForSurface(Surface* surface) {
91 SurfaceToResourceChildIdMap::iterator it = 91 SurfaceToResourceChildIdMap::iterator it =
92 surface_id_to_resource_child_id_.find(surface->surface_id()); 92 surface_id_to_resource_child_id_.find(surface->surface_id());
93 if (it == surface_id_to_resource_child_id_.end()) { 93 if (it == surface_id_to_resource_child_id_.end()) {
94 int child_id = provider_->CreateChild( 94 int child_id =
95 base::Bind(&UnrefHelper, surface->factory()->AsWeakPtr())); 95 provider_->CreateChild(base::Bind(&UnrefHelper, surface->factory()));
96 surface_id_to_resource_child_id_[surface->surface_id()] = child_id; 96 surface_id_to_resource_child_id_[surface->surface_id()] = child_id;
97 return child_id; 97 return child_id;
98 } else { 98 } else {
99 return it->second; 99 return it->second;
100 } 100 }
101 } 101 }
102 102
103 static ResourceProvider::ResourceId ResourceRemapHelper( 103 static ResourceProvider::ResourceId ResourceRemapHelper(
104 bool* invalid_frame, 104 bool* invalid_frame,
105 const ResourceProvider::ResourceIdMap& child_to_parent_map, 105 const ResourceProvider::ResourceIdMap& child_to_parent_map,
(...skipping 14 matching lines...) Expand all
120 120
121 bool SurfaceAggregator::TakeResources(Surface* surface, 121 bool SurfaceAggregator::TakeResources(Surface* surface,
122 const DelegatedFrameData* frame_data, 122 const DelegatedFrameData* frame_data,
123 RenderPassList* render_pass_list) { 123 RenderPassList* render_pass_list) {
124 RenderPass::CopyAll(frame_data->render_pass_list, render_pass_list); 124 RenderPass::CopyAll(frame_data->render_pass_list, render_pass_list);
125 if (!provider_) // TODO(jamesr): hack for unit tests that don't set up rp 125 if (!provider_) // TODO(jamesr): hack for unit tests that don't set up rp
126 return false; 126 return false;
127 127
128 int child_id = ChildIdForSurface(surface); 128 int child_id = ChildIdForSurface(surface);
129 provider_->ReceiveFromChild(child_id, frame_data->resource_list); 129 provider_->ReceiveFromChild(child_id, frame_data->resource_list);
130 surface->factory()->RefResources(frame_data->resource_list); 130 if (surface->factory())
131 surface->factory()->RefResources(frame_data->resource_list);
131 132
132 typedef ResourceProvider::ResourceIdArray IdArray; 133 typedef ResourceProvider::ResourceIdArray IdArray;
133 IdArray referenced_resources; 134 IdArray referenced_resources;
134 135
135 bool invalid_frame = false; 136 bool invalid_frame = false;
136 DrawQuad::ResourceIteratorCallback remap = 137 DrawQuad::ResourceIteratorCallback remap =
137 base::Bind(&ResourceRemapHelper, 138 base::Bind(&ResourceRemapHelper,
138 &invalid_frame, 139 &invalid_frame,
139 provider_->GetChildToParentMap(child_id), 140 provider_->GetChildToParentMap(child_id),
140 &referenced_resources); 141 &referenced_resources);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 surface->TakeLatencyInfo(&frame->metadata.latency_info); 416 surface->TakeLatencyInfo(&frame->metadata.latency_info);
416 } 417 }
417 418
418 // TODO(jamesr): Aggregate all resource references into the returned frame's 419 // TODO(jamesr): Aggregate all resource references into the returned frame's
419 // resource list. 420 // resource list.
420 421
421 return frame.Pass(); 422 return frame.Pass();
422 } 423 }
423 424
424 } // namespace cc 425 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698