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 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 client_(client) {} | 22 client_(client) {} |
23 | 23 |
24 DelegatedRendererLayer::~DelegatedRendererLayer() {} | 24 DelegatedRendererLayer::~DelegatedRendererLayer() {} |
25 | 25 |
26 scoped_ptr<LayerImpl> DelegatedRendererLayer::CreateLayerImpl( | 26 scoped_ptr<LayerImpl> DelegatedRendererLayer::CreateLayerImpl( |
27 LayerTreeImpl* tree_impl) { | 27 LayerTreeImpl* tree_impl) { |
28 return DelegatedRendererLayerImpl::Create( | 28 return DelegatedRendererLayerImpl::Create( |
29 tree_impl, layer_id_).PassAs<LayerImpl>(); | 29 tree_impl, layer_id_).PassAs<LayerImpl>(); |
30 } | 30 } |
31 | 31 |
| 32 void DelegatedRendererLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 33 if (layer_tree_host() == host) { |
| 34 Layer::SetLayerTreeHost(host); |
| 35 return; |
| 36 } |
| 37 |
| 38 if (!host) { |
| 39 // The active frame needs to be removed from the active tree and resources |
| 40 // returned before the commit is called complete. |
| 41 // TODO(danakj): Don't need to do this if the last frame commited was empty |
| 42 // or we never commited a frame with resources. |
| 43 SetNextCommitWaitsForActivation(); |
| 44 } |
| 45 |
| 46 Layer::SetLayerTreeHost(host); |
| 47 } |
| 48 |
32 bool DelegatedRendererLayer::DrawsContent() const { | 49 bool DelegatedRendererLayer::DrawsContent() const { |
33 return Layer::DrawsContent() && !frame_size_.IsEmpty(); | 50 return Layer::DrawsContent() && !frame_size_.IsEmpty(); |
34 } | 51 } |
35 | 52 |
36 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { | 53 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { |
37 Layer::PushPropertiesTo(impl); | 54 Layer::PushPropertiesTo(impl); |
38 | 55 |
39 DelegatedRendererLayerImpl* delegated_impl = | 56 DelegatedRendererLayerImpl* delegated_impl = |
40 static_cast<DelegatedRendererLayerImpl*>(impl); | 57 static_cast<DelegatedRendererLayerImpl*>(impl); |
41 | 58 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 93 } |
77 frame_data_ = new_frame_data.Pass(); | 94 frame_data_ = new_frame_data.Pass(); |
78 if (!frame_data_->render_pass_list.empty()) { | 95 if (!frame_data_->render_pass_list.empty()) { |
79 RenderPass* root_pass = frame_data_->render_pass_list.back(); | 96 RenderPass* root_pass = frame_data_->render_pass_list.back(); |
80 damage_in_frame_.Union(root_pass->damage_rect); | 97 damage_in_frame_.Union(root_pass->damage_rect); |
81 frame_size_ = root_pass->output_rect.size(); | 98 frame_size_ = root_pass->output_rect.size(); |
82 } else { | 99 } else { |
83 frame_size_ = gfx::Size(); | 100 frame_size_ = gfx::Size(); |
84 } | 101 } |
85 SetNeedsCommit(); | 102 SetNeedsCommit(); |
| 103 // The active frame needs to be replaced and resources returned before the |
| 104 // commit is called complete. |
| 105 SetNextCommitWaitsForActivation(); |
86 } | 106 } |
87 | 107 |
88 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( | 108 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( |
89 ReturnedResourceArray* array) { | 109 ReturnedResourceArray* array) { |
90 DCHECK(array->empty()); | 110 DCHECK(array->empty()); |
91 array->clear(); | 111 array->clear(); |
92 | 112 |
93 array->swap(unused_resources_for_child_compositor_); | 113 array->swap(unused_resources_for_child_compositor_); |
94 } | 114 } |
95 | 115 |
96 bool DelegatedRendererLayer::BlocksPendingCommit() const { | |
97 // The active frame needs to be replaced and resources returned before the | |
98 // commit is called complete. This is true even whenever there may be | |
99 // resources to return, regardless of if the layer will draw in its new | |
100 // state. | |
101 return true; | |
102 } | |
103 | |
104 } // namespace cc | 116 } // namespace cc |
OLD | NEW |