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

Unified Diff: cc/layers/delegated_renderer_layer.cc

Issue 24078024: cc: Return resources to child compositor via a Callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deletechild: Created 7 years, 3 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
Index: cc/layers/delegated_renderer_layer.cc
diff --git a/cc/layers/delegated_renderer_layer.cc b/cc/layers/delegated_renderer_layer.cc
index 5286874cc6b12b138e35d72faece48f940ff383f..a0e51b029f6e6bacca5ecafa5bf4390ff095ffc9 100644
--- a/cc/layers/delegated_renderer_layer.cc
+++ b/cc/layers/delegated_renderer_layer.cc
@@ -64,19 +64,21 @@ void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) {
delegated_impl->SetDisplaySize(display_size_);
+ delegated_impl->CreateChildIdIfNeeded(
+ base::Bind(&DelegatedRendererLayer::ReceiveUnusedResources, this));
piman 2013/09/20 01:55:01 Layer is only RefCounted, not RefCountedThreadSafe
danakj 2013/09/20 14:54:52 Oh, right. I will use a WeakPtrFactory.
danakj 2013/09/20 15:39:21 Ugh thread issues. The right way to do this is to
danakj 2013/09/20 17:35:12 Ok done. Used a WeakPtrFactory and a BlockingTaskR
+
if (frame_data_)
delegated_impl->SetFrameData(frame_data_.Pass(), damage_in_frame_);
frame_data_.reset();
damage_in_frame_ = gfx::RectF();
- delegated_impl->CollectUnusedResources(
- &unused_resources_for_child_compositor_);
-
+ // The ResourceProvider will have the new frame as soon as we push it to the
+ // pending tree. So unused resources will be returned as well.
if (client_)
client_->DidCommitFrameData();
- // TODO(danakj): TakeUnusedResourcesForChildCompositor requires a push
- // properties to happen in order to collect unused resources returned
+ // TODO(danakj): The DidCommitFrameData() notification requires a push
+ // properties to happen in order to notify about unused resources returned
// from the parent compositor. crbug.com/259090
needs_push_properties_ = true;
}
@@ -90,6 +92,8 @@ void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) {
void DelegatedRendererLayer::SetFrameData(
scoped_ptr<DelegatedFrameData> new_frame_data) {
+ DCHECK(new_frame_data);
+
if (frame_data_) {
// Copy the resources from the last provided frame into the unused resources
// list, as the new frame will provide its own resources.
@@ -136,7 +140,17 @@ void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor(
DCHECK(array->empty());
array->clear();
+ base::AutoLock lock(unused_resources_lock_);
array->swap(unused_resources_for_child_compositor_);
}
+void DelegatedRendererLayer::ReceiveUnusedResources(
+ const ReturnedResourceArray& unused) {
+ base::AutoLock lock(unused_resources_lock_);
+ unused_resources_for_child_compositor_.insert(
+ unused_resources_for_child_compositor_.end(),
+ unused.begin(),
+ unused.end());
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698