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

Unified Diff: cc/delegated_renderer_layer_impl.cc

Issue 12385085: cc: Unused resources should be given back to the child compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/delegated_renderer_layer_impl.h ('k') | cc/layer_tree_host_unittest_delegated.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/delegated_renderer_layer_impl.cc
diff --git a/cc/delegated_renderer_layer_impl.cc b/cc/delegated_renderer_layer_impl.cc
index 156032a0b808a51958188de7c5e032668a29e91f..6a980e44e83b3fb050dd8db2c497550b2dbb73a0 100644
--- a/cc/delegated_renderer_layer_impl.cc
+++ b/cc/delegated_renderer_layer_impl.cc
@@ -77,20 +77,20 @@ void DelegatedRendererLayerImpl::SetFrameData(
setUpdateRect(gfx::UnionRects(updateRect(), damage_in_layer));
}
- // Save the resources from the last frame.
- ResourceProvider::ResourceIdSet new_resources;
-
// Receive the current frame's resources from the child compositor.
ResourceProvider* resource_provider = layerTreeImpl()->resource_provider();
resource_provider->receiveFromChild(child_id_, frame_data->resource_list);
+ const ResourceProvider::ResourceIdMap& resource_map =
+ resource_provider->getChildToParentMap(child_id_);
// Remap resource ids in the current frame's quads to the parent's namespace.
bool invalid_frame = false;
+ ResourceProvider::ResourceIdSet used_resources;
DrawQuad::ResourceIteratorCallback remap_callback = base::Bind(
&ResourceRemapHelper,
&invalid_frame,
- resource_provider->getChildToParentMap(child_id_),
- &new_resources);
+ resource_map,
+ &used_resources);
for (size_t i = 0; i < frame_data->render_pass_list.size(); ++i) {
RenderPass* pass = frame_data->render_pass_list[i];
for (size_t j = 0; j < pass->quad_list.size(); ++j) {
@@ -100,35 +100,23 @@ void DelegatedRendererLayerImpl::SetFrameData(
}
// If the frame has invalid data in it, don't display it.
- if (invalid_frame) {
- // Keep the resources given to us this frame.
- for (ResourceProvider::ResourceIdSet::iterator it = new_resources.begin();
- it != new_resources.end();
- ++it)
- resources_.insert(*it);
+ if (invalid_frame)
return;
- }
-
- // Save the resources that this layer owns now.
- ResourceProvider::ResourceIdSet previous_frame_resources;
- previous_frame_resources.swap(resources_);
- resources_.swap(new_resources);
// Save the remapped quads on the layer. This steals the quads and render
// passes from the frame_data.
SetRenderPasses(frame_data->render_pass_list);
- // Release the resources from the previous frame to prepare them for transport
- // back to the child compositor.
+ // Release unused resources to prepare them for transport back to the child
+ // compositor.
ResourceProvider::ResourceIdArray unused_resources;
- for (ResourceProvider::ResourceIdSet::iterator it =
- previous_frame_resources.begin();
- it != previous_frame_resources.end();
+ for (ResourceProvider::ResourceIdMap::const_iterator it =
+ resource_map.begin();
+ it != resource_map.end();
++it) {
- bool resource_is_not_in_current_frame =
- resources_.find(*it) == resources_.end();
+ bool resource_is_not_in_current_frame = !used_resources.count(it->second);
if (resource_is_not_in_current_frame)
- unused_resources.push_back(*it);
+ unused_resources.push_back(it->second);
piman 2013/03/04 17:20:45 How do these get fed back into the next frame if i
danakj 2013/03/04 17:39:27 If the next frame needs them, I would expect it to
}
resource_provider->prepareSendToChild(
child_id_, unused_resources, resources_for_ack);
« no previous file with comments | « cc/delegated_renderer_layer_impl.h ('k') | cc/layer_tree_host_unittest_delegated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698