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

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: No AndReceiveAck needed, change STP 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
« no previous file with comments | « cc/layers/delegated_renderer_layer.h ('k') | cc/layers/delegated_renderer_layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cc49c753e25a7ec58322b7f268b9c491ee66baca 100644
--- a/cc/layers/delegated_renderer_layer.cc
+++ b/cc/layers/delegated_renderer_layer.cc
@@ -8,6 +8,7 @@
#include "cc/layers/delegated_renderer_layer_impl.h"
#include "cc/output/delegated_frame_data.h"
#include "cc/quads/render_pass_draw_quad.h"
+#include "cc/trees/blocking_task_runner.h"
#include "cc/trees/layer_tree_host.h"
namespace cc {
@@ -22,7 +23,9 @@ DelegatedRendererLayer::DelegatedRendererLayer(
DelegatedRendererLayerClient* client)
: Layer(),
client_(client),
- needs_filter_context_(false) {}
+ needs_filter_context_(false),
+ main_thread_runner_(BlockingTaskRunner::current()),
+ weak_ptrs_(this) {}
DelegatedRendererLayer::~DelegatedRendererLayer() {}
@@ -64,19 +67,23 @@ void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) {
delegated_impl->SetDisplaySize(display_size_);
+ delegated_impl->CreateChildIdIfNeeded(
+ base::Bind(&DelegatedRendererLayer::ReceiveUnusedResourcesOnImplThread,
+ main_thread_runner_,
+ weak_ptrs_.GetWeakPtr()));
+
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 +97,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.
@@ -139,4 +148,23 @@ void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor(
array->swap(unused_resources_for_child_compositor_);
}
+void DelegatedRendererLayer::ReceiveUnusedResources(
+ const ReturnedResourceArray& unused) {
+ unused_resources_for_child_compositor_.insert(
+ unused_resources_for_child_compositor_.end(),
+ unused.begin(),
+ unused.end());
+}
+
+// static
+void DelegatedRendererLayer::ReceiveUnusedResourcesOnImplThread(
+ scoped_refptr<BlockingTaskRunner> task_runner,
+ base::WeakPtr<DelegatedRendererLayer> self,
+ const ReturnedResourceArray& unused) {
+ task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &DelegatedRendererLayer::ReceiveUnusedResources, self, unused));
+}
+
} // namespace cc
« no previous file with comments | « cc/layers/delegated_renderer_layer.h ('k') | cc/layers/delegated_renderer_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698