OLD | NEW |
---|---|
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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 } | 57 } |
58 | 58 |
59 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { | 59 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { |
60 Layer::PushPropertiesTo(impl); | 60 Layer::PushPropertiesTo(impl); |
61 | 61 |
62 DelegatedRendererLayerImpl* delegated_impl = | 62 DelegatedRendererLayerImpl* delegated_impl = |
63 static_cast<DelegatedRendererLayerImpl*>(impl); | 63 static_cast<DelegatedRendererLayerImpl*>(impl); |
64 | 64 |
65 delegated_impl->SetDisplaySize(display_size_); | 65 delegated_impl->SetDisplaySize(display_size_); |
66 | 66 |
67 delegated_impl->CreateChildIdIfNeeded( | |
68 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
| |
69 | |
67 if (frame_data_) | 70 if (frame_data_) |
68 delegated_impl->SetFrameData(frame_data_.Pass(), damage_in_frame_); | 71 delegated_impl->SetFrameData(frame_data_.Pass(), damage_in_frame_); |
69 frame_data_.reset(); | 72 frame_data_.reset(); |
70 damage_in_frame_ = gfx::RectF(); | 73 damage_in_frame_ = gfx::RectF(); |
71 | 74 |
72 delegated_impl->CollectUnusedResources( | 75 // The ResourceProvider will have the new frame as soon as we push it to the |
73 &unused_resources_for_child_compositor_); | 76 // pending tree. So unused resources will be returned as well. |
74 | |
75 if (client_) | 77 if (client_) |
76 client_->DidCommitFrameData(); | 78 client_->DidCommitFrameData(); |
77 | 79 |
78 // TODO(danakj): TakeUnusedResourcesForChildCompositor requires a push | 80 // TODO(danakj): The DidCommitFrameData() notification requires a push |
79 // properties to happen in order to collect unused resources returned | 81 // properties to happen in order to notify about unused resources returned |
80 // from the parent compositor. crbug.com/259090 | 82 // from the parent compositor. crbug.com/259090 |
81 needs_push_properties_ = true; | 83 needs_push_properties_ = true; |
82 } | 84 } |
83 | 85 |
84 void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) { | 86 void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) { |
85 if (display_size_ == size) | 87 if (display_size_ == size) |
86 return; | 88 return; |
87 display_size_ = size; | 89 display_size_ = size; |
88 SetNeedsCommit(); | 90 SetNeedsCommit(); |
89 } | 91 } |
90 | 92 |
91 void DelegatedRendererLayer::SetFrameData( | 93 void DelegatedRendererLayer::SetFrameData( |
92 scoped_ptr<DelegatedFrameData> new_frame_data) { | 94 scoped_ptr<DelegatedFrameData> new_frame_data) { |
95 DCHECK(new_frame_data); | |
96 | |
93 if (frame_data_) { | 97 if (frame_data_) { |
94 // Copy the resources from the last provided frame into the unused resources | 98 // Copy the resources from the last provided frame into the unused resources |
95 // list, as the new frame will provide its own resources. | 99 // list, as the new frame will provide its own resources. |
96 TransferableResource::ReturnResources( | 100 TransferableResource::ReturnResources( |
97 frame_data_->resource_list, | 101 frame_data_->resource_list, |
98 &unused_resources_for_child_compositor_); | 102 &unused_resources_for_child_compositor_); |
99 } | 103 } |
100 frame_data_ = new_frame_data.Pass(); | 104 frame_data_ = new_frame_data.Pass(); |
101 if (!frame_data_->render_pass_list.empty()) { | 105 if (!frame_data_->render_pass_list.empty()) { |
102 RenderPass* root_pass = frame_data_->render_pass_list.back(); | 106 RenderPass* root_pass = frame_data_->render_pass_list.back(); |
(...skipping 26 matching lines...) Expand all Loading... | |
129 // The active frame needs to be replaced and resources returned before the | 133 // The active frame needs to be replaced and resources returned before the |
130 // commit is called complete. | 134 // commit is called complete. |
131 SetNextCommitWaitsForActivation(); | 135 SetNextCommitWaitsForActivation(); |
132 } | 136 } |
133 | 137 |
134 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( | 138 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( |
135 ReturnedResourceArray* array) { | 139 ReturnedResourceArray* array) { |
136 DCHECK(array->empty()); | 140 DCHECK(array->empty()); |
137 array->clear(); | 141 array->clear(); |
138 | 142 |
143 base::AutoLock lock(unused_resources_lock_); | |
139 array->swap(unused_resources_for_child_compositor_); | 144 array->swap(unused_resources_for_child_compositor_); |
140 } | 145 } |
141 | 146 |
147 void DelegatedRendererLayer::ReceiveUnusedResources( | |
148 const ReturnedResourceArray& unused) { | |
149 base::AutoLock lock(unused_resources_lock_); | |
150 unused_resources_for_child_compositor_.insert( | |
151 unused_resources_for_child_compositor_.end(), | |
152 unused.begin(), | |
153 unused.end()); | |
154 } | |
155 | |
142 } // namespace cc | 156 } // namespace cc |
OLD | NEW |