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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/delegated_renderer_layer.h" 5 #include "cc/layers/delegated_renderer_layer.h"
6 6
7 #include "cc/layers/delegated_renderer_layer_client.h" 7 #include "cc/layers/delegated_renderer_layer_client.h"
8 #include "cc/layers/delegated_renderer_layer_impl.h" 8 #include "cc/layers/delegated_renderer_layer_impl.h"
9 #include "cc/output/delegated_frame_data.h" 9 #include "cc/output/delegated_frame_data.h"
10 #include "cc/quads/render_pass_draw_quad.h" 10 #include "cc/quads/render_pass_draw_quad.h"
11 #include "cc/trees/blocking_task_runner.h"
11 #include "cc/trees/layer_tree_host.h" 12 #include "cc/trees/layer_tree_host.h"
12 13
13 namespace cc { 14 namespace cc {
14 15
15 scoped_refptr<DelegatedRendererLayer> DelegatedRendererLayer::Create( 16 scoped_refptr<DelegatedRendererLayer> DelegatedRendererLayer::Create(
16 DelegatedRendererLayerClient* client) { 17 DelegatedRendererLayerClient* client) {
17 return scoped_refptr<DelegatedRendererLayer>( 18 return scoped_refptr<DelegatedRendererLayer>(
18 new DelegatedRendererLayer(client)); 19 new DelegatedRendererLayer(client));
19 } 20 }
20 21
21 DelegatedRendererLayer::DelegatedRendererLayer( 22 DelegatedRendererLayer::DelegatedRendererLayer(
22 DelegatedRendererLayerClient* client) 23 DelegatedRendererLayerClient* client)
23 : Layer(), 24 : Layer(),
24 client_(client), 25 client_(client),
25 needs_filter_context_(false) {} 26 needs_filter_context_(false),
27 main_thread_runner_(BlockingTaskRunner::current()),
28 weak_ptrs_(this) {}
26 29
27 DelegatedRendererLayer::~DelegatedRendererLayer() {} 30 DelegatedRendererLayer::~DelegatedRendererLayer() {}
28 31
29 scoped_ptr<LayerImpl> DelegatedRendererLayer::CreateLayerImpl( 32 scoped_ptr<LayerImpl> DelegatedRendererLayer::CreateLayerImpl(
30 LayerTreeImpl* tree_impl) { 33 LayerTreeImpl* tree_impl) {
31 return DelegatedRendererLayerImpl::Create( 34 return DelegatedRendererLayerImpl::Create(
32 tree_impl, layer_id_).PassAs<LayerImpl>(); 35 tree_impl, layer_id_).PassAs<LayerImpl>();
33 } 36 }
34 37
35 void DelegatedRendererLayer::SetLayerTreeHost(LayerTreeHost* host) { 38 void DelegatedRendererLayer::SetLayerTreeHost(LayerTreeHost* host) {
(...skipping 21 matching lines...) Expand all
57 } 60 }
58 61
59 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { 62 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) {
60 Layer::PushPropertiesTo(impl); 63 Layer::PushPropertiesTo(impl);
61 64
62 DelegatedRendererLayerImpl* delegated_impl = 65 DelegatedRendererLayerImpl* delegated_impl =
63 static_cast<DelegatedRendererLayerImpl*>(impl); 66 static_cast<DelegatedRendererLayerImpl*>(impl);
64 67
65 delegated_impl->SetDisplaySize(display_size_); 68 delegated_impl->SetDisplaySize(display_size_);
66 69
70 delegated_impl->CreateChildIdIfNeeded(
71 base::Bind(&DelegatedRendererLayer::ReceiveUnusedResourcesOnImplThread,
72 main_thread_runner_,
73 weak_ptrs_.GetWeakPtr()));
74
67 if (frame_data_) 75 if (frame_data_)
68 delegated_impl->SetFrameData(frame_data_.Pass(), damage_in_frame_); 76 delegated_impl->SetFrameData(frame_data_.Pass(), damage_in_frame_);
69 frame_data_.reset(); 77 frame_data_.reset();
70 damage_in_frame_ = gfx::RectF(); 78 damage_in_frame_ = gfx::RectF();
71 79
72 delegated_impl->CollectUnusedResources( 80 // The ResourceProvider will have the new frame as soon as we push it to the
73 &unused_resources_for_child_compositor_); 81 // pending tree. So unused resources will be returned as well.
74
75 if (client_) 82 if (client_)
76 client_->DidCommitFrameData(); 83 client_->DidCommitFrameData();
77 84
78 // TODO(danakj): TakeUnusedResourcesForChildCompositor requires a push 85 // TODO(danakj): The DidCommitFrameData() notification requires a push
79 // properties to happen in order to collect unused resources returned 86 // properties to happen in order to notify about unused resources returned
80 // from the parent compositor. crbug.com/259090 87 // from the parent compositor. crbug.com/259090
81 needs_push_properties_ = true; 88 needs_push_properties_ = true;
82 } 89 }
83 90
84 void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) { 91 void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) {
85 if (display_size_ == size) 92 if (display_size_ == size)
86 return; 93 return;
87 display_size_ = size; 94 display_size_ = size;
88 SetNeedsCommit(); 95 SetNeedsCommit();
89 } 96 }
90 97
91 void DelegatedRendererLayer::SetFrameData( 98 void DelegatedRendererLayer::SetFrameData(
92 scoped_ptr<DelegatedFrameData> new_frame_data) { 99 scoped_ptr<DelegatedFrameData> new_frame_data) {
100 DCHECK(new_frame_data);
101
93 if (frame_data_) { 102 if (frame_data_) {
94 // Copy the resources from the last provided frame into the unused resources 103 // Copy the resources from the last provided frame into the unused resources
95 // list, as the new frame will provide its own resources. 104 // list, as the new frame will provide its own resources.
96 TransferableResource::ReturnResources( 105 TransferableResource::ReturnResources(
97 frame_data_->resource_list, 106 frame_data_->resource_list,
98 &unused_resources_for_child_compositor_); 107 &unused_resources_for_child_compositor_);
99 } 108 }
100 frame_data_ = new_frame_data.Pass(); 109 frame_data_ = new_frame_data.Pass();
101 if (!frame_data_->render_pass_list.empty()) { 110 if (!frame_data_->render_pass_list.empty()) {
102 RenderPass* root_pass = frame_data_->render_pass_list.back(); 111 RenderPass* root_pass = frame_data_->render_pass_list.back();
(...skipping 29 matching lines...) Expand all
132 } 141 }
133 142
134 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( 143 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor(
135 ReturnedResourceArray* array) { 144 ReturnedResourceArray* array) {
136 DCHECK(array->empty()); 145 DCHECK(array->empty());
137 array->clear(); 146 array->clear();
138 147
139 array->swap(unused_resources_for_child_compositor_); 148 array->swap(unused_resources_for_child_compositor_);
140 } 149 }
141 150
151 void DelegatedRendererLayer::ReceiveUnusedResources(
152 const ReturnedResourceArray& unused) {
153 unused_resources_for_child_compositor_.insert(
154 unused_resources_for_child_compositor_.end(),
155 unused.begin(),
156 unused.end());
157 }
158
159 // static
160 void DelegatedRendererLayer::ReceiveUnusedResourcesOnImplThread(
161 scoped_refptr<BlockingTaskRunner> task_runner,
162 base::WeakPtr<DelegatedRendererLayer> self,
163 const ReturnedResourceArray& unused) {
164 task_runner->PostTask(
165 FROM_HERE,
166 base::Bind(
167 &DelegatedRendererLayer::ReceiveUnusedResources, self, unused));
168 }
169
142 } // namespace cc 170 } // namespace cc
OLDNEW
« 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