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 | |
49 bool DelegatedRendererLayer::DrawsContent() const { | 32 bool DelegatedRendererLayer::DrawsContent() const { |
50 return Layer::DrawsContent() && !frame_size_.IsEmpty(); | 33 return Layer::DrawsContent() && !frame_size_.IsEmpty(); |
51 } | 34 } |
52 | 35 |
53 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { | 36 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) { |
54 Layer::PushPropertiesTo(impl); | 37 Layer::PushPropertiesTo(impl); |
55 | 38 |
56 DelegatedRendererLayerImpl* delegated_impl = | 39 DelegatedRendererLayerImpl* delegated_impl = |
57 static_cast<DelegatedRendererLayerImpl*>(impl); | 40 static_cast<DelegatedRendererLayerImpl*>(impl); |
58 | 41 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 76 } |
94 frame_data_ = new_frame_data.Pass(); | 77 frame_data_ = new_frame_data.Pass(); |
95 if (!frame_data_->render_pass_list.empty()) { | 78 if (!frame_data_->render_pass_list.empty()) { |
96 RenderPass* root_pass = frame_data_->render_pass_list.back(); | 79 RenderPass* root_pass = frame_data_->render_pass_list.back(); |
97 damage_in_frame_.Union(root_pass->damage_rect); | 80 damage_in_frame_.Union(root_pass->damage_rect); |
98 frame_size_ = root_pass->output_rect.size(); | 81 frame_size_ = root_pass->output_rect.size(); |
99 } else { | 82 } else { |
100 frame_size_ = gfx::Size(); | 83 frame_size_ = gfx::Size(); |
101 } | 84 } |
102 SetNeedsCommit(); | 85 SetNeedsCommit(); |
103 // The active frame needs to be replaced and resources returned before the | |
104 // commit is called complete. | |
105 SetNextCommitWaitsForActivation(); | |
106 } | 86 } |
107 | 87 |
108 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( | 88 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( |
109 ReturnedResourceArray* array) { | 89 ReturnedResourceArray* array) { |
110 DCHECK(array->empty()); | 90 DCHECK(array->empty()); |
111 array->clear(); | 91 array->clear(); |
112 | 92 |
113 array->swap(unused_resources_for_child_compositor_); | 93 array->swap(unused_resources_for_child_compositor_); |
114 } | 94 } |
115 | 95 |
| 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 |
116 } // namespace cc | 104 } // namespace cc |
OLD | NEW |