OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "cc/layers/empty_content_layer_client.h" | 10 #include "cc/layers/empty_content_layer_client.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 proto::LayerTreeHost proto; | 102 proto::LayerTreeHost proto; |
103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); | 103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree(); | 104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree(); |
105 | 105 |
106 std::unordered_set<Layer*> layers_that_should_push_properties_src = | 106 std::unordered_set<Layer*> layers_that_should_push_properties_src = |
107 layer_tree_src->LayersThatShouldPushProperties(); | 107 layer_tree_src->LayersThatShouldPushProperties(); |
108 std::vector<std::unique_ptr<SwapPromise>> swap_promises; | 108 std::vector<std::unique_ptr<SwapPromise>> swap_promises; |
109 layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises); | 109 layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises); |
110 layer_tree_host_dst_->FromProtobufForCommit(proto); | 110 layer_tree_host_dst_->FromProtobufForCommit(proto); |
111 | 111 |
112 EXPECT_EQ(layer_tree_host_src_->needs_full_tree_sync_, | 112 EXPECT_EQ(layer_tree_src->needs_full_tree_sync_, |
113 layer_tree_host_dst_->needs_full_tree_sync_); | 113 layer_tree_dst->needs_full_tree_sync_); |
114 EXPECT_EQ(layer_tree_host_src_->needs_meta_info_recomputation_, | 114 EXPECT_EQ(layer_tree_src->needs_meta_info_recomputation_, |
115 layer_tree_host_dst_->needs_meta_info_recomputation_); | 115 layer_tree_dst->needs_meta_info_recomputation_); |
116 EXPECT_EQ(layer_tree_host_src_->source_frame_number_, | 116 EXPECT_EQ(layer_tree_host_src_->source_frame_number_, |
117 layer_tree_host_dst_->source_frame_number_); | 117 layer_tree_host_dst_->source_frame_number_); |
118 EXPECT_EQ(layer_tree_host_src_->root_layer()->id(), | 118 EXPECT_EQ(layer_tree_host_src_->root_layer()->id(), |
119 layer_tree_host_dst_->root_layer()->id()); | 119 layer_tree_host_dst_->root_layer()->id()); |
120 EXPECT_EQ(layer_tree_host_dst_.get(), | 120 EXPECT_EQ(layer_tree_host_dst_.get(), |
121 layer_tree_host_dst_->root_layer_->layer_tree_host()); | 121 layer_tree_dst->inputs_.root_layer->layer_tree_host()); |
122 EXPECT_EQ(layer_tree_host_src_->root_layer_->double_sided(), | 122 EXPECT_EQ(layer_tree_src->inputs_.root_layer->double_sided(), |
123 layer_tree_host_dst_->root_layer_->double_sided()); | 123 layer_tree_dst->inputs_.root_layer->double_sided()); |
124 EXPECT_EQ( | 124 EXPECT_EQ( |
125 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects, | 125 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects, |
126 layer_tree_host_dst_->debug_state_.show_replica_screen_space_rects); | 126 layer_tree_host_dst_->debug_state_.show_replica_screen_space_rects); |
127 EXPECT_EQ(layer_tree_host_src_->device_viewport_size_, | 127 EXPECT_EQ(layer_tree_src->inputs_.device_viewport_size, |
128 layer_tree_host_dst_->device_viewport_size_); | 128 layer_tree_dst->inputs_.device_viewport_size); |
129 EXPECT_EQ(layer_tree_host_src_->top_controls_shrink_blink_size_, | 129 EXPECT_EQ(layer_tree_src->inputs_.top_controls_shrink_blink_size, |
130 layer_tree_host_dst_->top_controls_shrink_blink_size_); | 130 layer_tree_dst->inputs_.top_controls_shrink_blink_size); |
131 EXPECT_EQ(layer_tree_host_src_->top_controls_height_, | 131 EXPECT_EQ(layer_tree_src->inputs_.top_controls_height, |
132 layer_tree_host_dst_->top_controls_height_); | 132 layer_tree_dst->inputs_.top_controls_height); |
133 EXPECT_EQ(layer_tree_host_src_->top_controls_shown_ratio_, | 133 EXPECT_EQ(layer_tree_src->inputs_.top_controls_shown_ratio, |
134 layer_tree_host_dst_->top_controls_shown_ratio_); | 134 layer_tree_dst->inputs_.top_controls_shown_ratio); |
135 EXPECT_EQ(layer_tree_host_src_->device_scale_factor_, | 135 EXPECT_EQ(layer_tree_src->inputs_.device_scale_factor, |
136 layer_tree_host_dst_->device_scale_factor_); | 136 layer_tree_dst->inputs_.device_scale_factor); |
137 EXPECT_EQ(layer_tree_host_src_->painted_device_scale_factor_, | 137 EXPECT_EQ(layer_tree_src->inputs_.painted_device_scale_factor, |
138 layer_tree_host_dst_->painted_device_scale_factor_); | 138 layer_tree_dst->inputs_.painted_device_scale_factor); |
139 EXPECT_EQ(layer_tree_host_src_->page_scale_factor_, | 139 EXPECT_EQ(layer_tree_src->inputs_.page_scale_factor, |
140 layer_tree_host_dst_->page_scale_factor_); | 140 layer_tree_dst->inputs_.page_scale_factor); |
141 EXPECT_EQ(layer_tree_host_src_->min_page_scale_factor_, | 141 EXPECT_EQ(layer_tree_src->inputs_.min_page_scale_factor, |
142 layer_tree_host_dst_->min_page_scale_factor_); | 142 layer_tree_dst->inputs_.min_page_scale_factor); |
143 EXPECT_EQ(layer_tree_host_src_->max_page_scale_factor_, | 143 EXPECT_EQ(layer_tree_src->inputs_.max_page_scale_factor, |
144 layer_tree_host_dst_->max_page_scale_factor_); | 144 layer_tree_dst->inputs_.max_page_scale_factor); |
145 EXPECT_EQ(layer_tree_host_src_->elastic_overscroll_, | 145 EXPECT_EQ(layer_tree_src->elastic_overscroll_, |
146 layer_tree_host_dst_->elastic_overscroll_); | 146 layer_tree_dst->elastic_overscroll_); |
147 EXPECT_EQ(layer_tree_host_src_->has_gpu_rasterization_trigger_, | 147 EXPECT_EQ(layer_tree_host_src_->has_gpu_rasterization_trigger_, |
148 layer_tree_host_dst_->has_gpu_rasterization_trigger_); | 148 layer_tree_host_dst_->has_gpu_rasterization_trigger_); |
149 EXPECT_EQ(layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_, | 149 EXPECT_EQ(layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_, |
150 layer_tree_host_dst_->content_is_suitable_for_gpu_rasterization_); | 150 layer_tree_host_dst_->content_is_suitable_for_gpu_rasterization_); |
151 EXPECT_EQ(layer_tree_host_src_->background_color_, | 151 EXPECT_EQ(layer_tree_src->inputs_.background_color, |
152 layer_tree_host_dst_->background_color_); | 152 layer_tree_dst->inputs_.background_color); |
153 EXPECT_EQ(layer_tree_host_src_->has_transparent_background_, | 153 EXPECT_EQ(layer_tree_src->inputs_.has_transparent_background, |
154 layer_tree_host_dst_->has_transparent_background_); | 154 layer_tree_dst->inputs_.has_transparent_background); |
155 EXPECT_EQ(layer_tree_src->in_paint_layer_contents(), | 155 EXPECT_EQ(layer_tree_src->in_paint_layer_contents(), |
156 layer_tree_dst->in_paint_layer_contents()); | 156 layer_tree_dst->in_paint_layer_contents()); |
157 EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_); | 157 EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_); |
158 EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_, | 158 EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_, |
159 layer_tree_host_dst_->next_commit_forces_redraw_); | 159 layer_tree_host_dst_->next_commit_forces_redraw_); |
160 for (auto* layer : layers_that_should_push_properties_src) { | 160 for (auto* layer : layers_that_should_push_properties_src) { |
161 EXPECT_TRUE(layer_tree_dst->LayerNeedsPushPropertiesForTesting( | 161 EXPECT_TRUE(layer_tree_dst->LayerNeedsPushPropertiesForTesting( |
162 layer_tree_dst->LayerById(layer->id()))); | 162 layer_tree_dst->LayerById(layer->id()))); |
163 } | 163 } |
164 | 164 |
165 if (layer_tree_host_src_->hud_layer_) { | 165 if (layer_tree_src->hud_layer_) { |
166 EXPECT_EQ(layer_tree_host_src_->hud_layer_->id(), | 166 EXPECT_EQ(layer_tree_src->hud_layer_->id(), |
167 layer_tree_host_dst_->hud_layer_->id()); | 167 layer_tree_dst->hud_layer_->id()); |
168 // The HUD layer member is a HeadsUpDisplayLayer instead of Layer, so | 168 // The HUD layer member is a HeadsUpDisplayLayer instead of Layer, so |
169 // inspect the proto to see if it contains the the right layer type. | 169 // inspect the proto to see if it contains the the right layer type. |
170 bool found_hud_layer_type = false; | 170 bool found_hud_layer_type = false; |
171 for (int i = 0; i < proto.root_layer().children_size(); ++i) { | 171 for (int i = 0; i < proto.layer_tree().root_layer().children_size(); |
172 if (proto.root_layer().children(i).id() == | 172 ++i) { |
173 layer_tree_host_src_->hud_layer_->id()) { | 173 if (proto.layer_tree().root_layer().children(i).id() == |
| 174 layer_tree_src->hud_layer_->id()) { |
174 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, | 175 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, |
175 proto.root_layer().children(i).type()); | 176 proto.layer_tree().root_layer().children(i).type()); |
176 found_hud_layer_type = true; | 177 found_hud_layer_type = true; |
177 break; | 178 break; |
178 } | 179 } |
179 } | 180 } |
180 EXPECT_TRUE(found_hud_layer_type); | 181 EXPECT_TRUE(found_hud_layer_type); |
181 } else { | 182 } else { |
182 EXPECT_FALSE(layer_tree_host_dst_->hud_layer_); | 183 EXPECT_FALSE(layer_tree_dst->hud_layer_); |
183 } | 184 } |
184 if (layer_tree_host_src_->overscroll_elasticity_layer_) { | 185 if (layer_tree_src->overscroll_elasticity_layer()) { |
185 EXPECT_EQ(layer_tree_host_src_->overscroll_elasticity_layer_->id(), | 186 EXPECT_EQ(layer_tree_src->overscroll_elasticity_layer()->id(), |
186 layer_tree_host_dst_->overscroll_elasticity_layer_->id()); | 187 layer_tree_dst->overscroll_elasticity_layer()->id()); |
187 } else { | 188 } else { |
188 EXPECT_FALSE(layer_tree_host_dst_->overscroll_elasticity_layer_); | 189 EXPECT_FALSE(layer_tree_dst->overscroll_elasticity_layer()); |
189 } | 190 } |
190 if (layer_tree_host_src_->page_scale_layer_) { | 191 if (layer_tree_src->page_scale_layer()) { |
191 EXPECT_EQ(layer_tree_host_src_->page_scale_layer_->id(), | 192 EXPECT_EQ(layer_tree_src->page_scale_layer()->id(), |
192 layer_tree_host_dst_->page_scale_layer_->id()); | 193 layer_tree_dst->page_scale_layer()->id()); |
193 } else { | 194 } else { |
194 EXPECT_FALSE(layer_tree_host_dst_->page_scale_layer_); | 195 EXPECT_FALSE(layer_tree_dst->page_scale_layer()); |
195 } | 196 } |
196 if (layer_tree_host_src_->inner_viewport_scroll_layer_) { | 197 if (layer_tree_src->inner_viewport_scroll_layer()) { |
197 EXPECT_EQ(layer_tree_host_src_->inner_viewport_scroll_layer_->id(), | 198 EXPECT_EQ(layer_tree_src->inner_viewport_scroll_layer()->id(), |
198 layer_tree_host_dst_->inner_viewport_scroll_layer_->id()); | 199 layer_tree_dst->inner_viewport_scroll_layer()->id()); |
199 } else { | 200 } else { |
200 EXPECT_FALSE(layer_tree_host_dst_->inner_viewport_scroll_layer_); | 201 EXPECT_FALSE(layer_tree_dst->inner_viewport_scroll_layer()); |
201 } | 202 } |
202 if (layer_tree_host_src_->outer_viewport_scroll_layer_) { | 203 if (layer_tree_src->outer_viewport_scroll_layer()) { |
203 EXPECT_EQ(layer_tree_host_src_->outer_viewport_scroll_layer_->id(), | 204 EXPECT_EQ(layer_tree_src->outer_viewport_scroll_layer()->id(), |
204 layer_tree_host_dst_->outer_viewport_scroll_layer_->id()); | 205 layer_tree_dst->outer_viewport_scroll_layer()->id()); |
205 } else { | 206 } else { |
206 EXPECT_FALSE(layer_tree_host_dst_->outer_viewport_scroll_layer_); | 207 EXPECT_FALSE(layer_tree_dst->outer_viewport_scroll_layer()); |
207 } | 208 } |
208 EXPECT_EQ(layer_tree_host_src_->selection_, | 209 EXPECT_EQ(layer_tree_src->inputs_.selection, |
209 layer_tree_host_dst_->selection_); | 210 layer_tree_dst->inputs_.selection); |
210 EXPECT_EQ(layer_tree_host_src_->property_trees_, | 211 EXPECT_EQ(layer_tree_src->property_trees_, layer_tree_dst->property_trees_); |
211 layer_tree_host_dst_->property_trees_); | |
212 EXPECT_EQ(layer_tree_host_src_->surface_client_id_, | 212 EXPECT_EQ(layer_tree_host_src_->surface_client_id_, |
213 layer_tree_host_dst_->surface_client_id_); | 213 layer_tree_host_dst_->surface_client_id_); |
214 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_, | 214 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_, |
215 layer_tree_host_dst_->next_surface_sequence_); | 215 layer_tree_host_dst_->next_surface_sequence_); |
216 | 216 |
217 // All layers must have a property tree index that matches PropertyTrees. | 217 // All layers must have a property tree index that matches PropertyTrees. |
218 if (layer_tree_host_dst_->property_trees_.sequence_number) { | 218 if (layer_tree_dst->property_trees_.sequence_number) { |
219 int seq_num = layer_tree_host_dst_->property_trees_.sequence_number; | 219 int seq_num = layer_tree_dst->property_trees_.sequence_number; |
220 LayerTreeHostCommon::CallFunctionForEveryLayer( | 220 LayerTreeHostCommon::CallFunctionForEveryLayer( |
221 layer_tree_host_dst_.get(), [seq_num](Layer* layer) { | 221 layer_tree_host_dst_.get(), [seq_num](Layer* layer) { |
222 EXPECT_EQ(seq_num, layer->property_tree_sequence_number()); | 222 EXPECT_EQ(seq_num, layer->property_tree_sequence_number()); |
223 }); | 223 }); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 void RunAllMembersChangedTest() { | 227 void RunAllMembersChangedTest() { |
228 layer_tree_host_src_->needs_full_tree_sync_ = | 228 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
229 !layer_tree_host_src_->needs_full_tree_sync_; | 229 |
230 layer_tree_host_src_->needs_meta_info_recomputation_ = | 230 layer_tree_src->needs_full_tree_sync_ = |
231 !layer_tree_host_src_->needs_meta_info_recomputation_; | 231 !layer_tree_src->needs_full_tree_sync_; |
| 232 layer_tree_src->needs_meta_info_recomputation_ = |
| 233 !layer_tree_src->needs_meta_info_recomputation_; |
232 layer_tree_host_src_->source_frame_number_ *= 3; | 234 layer_tree_host_src_->source_frame_number_ *= 3; |
233 | 235 |
234 // Just fake setup a layer for both source and dest. | 236 // Just fake setup a layer for both source and dest. |
235 scoped_refptr<Layer> root_layer_src = Layer::Create(); | 237 scoped_refptr<Layer> root_layer_src = Layer::Create(); |
236 layer_tree_host_src_->SetRootLayer(root_layer_src); | 238 layer_tree_host_src_->SetRootLayer(root_layer_src); |
237 layer_tree_host_dst_->SetRootLayer(Layer::Create()); | 239 layer_tree_host_dst_->SetRootLayer(Layer::Create()); |
238 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); | 240 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); |
239 | 241 |
240 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects = | 242 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects = |
241 !layer_tree_host_src_->debug_state_.show_replica_screen_space_rects; | 243 !layer_tree_host_src_->debug_state_.show_replica_screen_space_rects; |
242 layer_tree_host_src_->device_viewport_size_ = gfx::Size(3, 14); | 244 layer_tree_src->inputs_.device_viewport_size = gfx::Size(3, 14); |
243 layer_tree_host_src_->top_controls_shrink_blink_size_ = | 245 layer_tree_src->inputs_.top_controls_shrink_blink_size = |
244 !layer_tree_host_src_->top_controls_shrink_blink_size_; | 246 !layer_tree_src->inputs_.top_controls_shrink_blink_size; |
245 layer_tree_host_src_->top_controls_height_ = | 247 layer_tree_src->inputs_.top_controls_height = |
246 layer_tree_host_src_->top_controls_height_ * 3 + 1; | 248 layer_tree_src->inputs_.top_controls_height * 3 + 1; |
247 layer_tree_host_src_->top_controls_shown_ratio_ = | 249 layer_tree_src->inputs_.top_controls_shown_ratio = |
248 layer_tree_host_src_->top_controls_shown_ratio_ * 3 + 1; | 250 layer_tree_src->inputs_.top_controls_shown_ratio * 3 + 1; |
249 layer_tree_host_src_->device_scale_factor_ = | 251 layer_tree_src->inputs_.device_scale_factor = |
250 layer_tree_host_src_->device_scale_factor_ * 3 + 1; | 252 layer_tree_src->inputs_.device_scale_factor * 3 + 1; |
251 layer_tree_host_src_->painted_device_scale_factor_ = | 253 layer_tree_src->inputs_.painted_device_scale_factor = |
252 layer_tree_host_src_->painted_device_scale_factor_ * 3 + 1; | 254 layer_tree_src->inputs_.painted_device_scale_factor * 3 + 1; |
253 layer_tree_host_src_->page_scale_factor_ = | 255 layer_tree_src->inputs_.page_scale_factor = |
254 layer_tree_host_src_->page_scale_factor_ * 3 + 1; | 256 layer_tree_src->inputs_.page_scale_factor * 3 + 1; |
255 layer_tree_host_src_->min_page_scale_factor_ = | 257 layer_tree_src->inputs_.min_page_scale_factor = |
256 layer_tree_host_src_->min_page_scale_factor_ * 3 + 1; | 258 layer_tree_src->inputs_.min_page_scale_factor * 3 + 1; |
257 layer_tree_host_src_->max_page_scale_factor_ = | 259 layer_tree_src->inputs_.max_page_scale_factor = |
258 layer_tree_host_src_->max_page_scale_factor_ * 3 + 1; | 260 layer_tree_src->inputs_.max_page_scale_factor * 3 + 1; |
259 layer_tree_host_src_->elastic_overscroll_ = gfx::Vector2dF(3, 14); | 261 layer_tree_host_src_->elastic_overscroll_ = gfx::Vector2dF(3, 14); |
260 layer_tree_host_src_->has_gpu_rasterization_trigger_ = | 262 layer_tree_host_src_->has_gpu_rasterization_trigger_ = |
261 !layer_tree_host_src_->has_gpu_rasterization_trigger_; | 263 !layer_tree_host_src_->has_gpu_rasterization_trigger_; |
262 layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_ = | 264 layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_ = |
263 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_; | 265 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_; |
264 layer_tree_host_src_->background_color_ = SK_ColorMAGENTA; | 266 layer_tree_src->inputs_.background_color = SK_ColorMAGENTA; |
265 layer_tree_host_src_->has_transparent_background_ = | 267 layer_tree_src->inputs_.has_transparent_background = |
266 !layer_tree_host_src_->has_transparent_background_; | 268 !layer_tree_src->inputs_.has_transparent_background; |
267 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1; | 269 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1; |
268 layer_tree_host_src_->next_commit_forces_redraw_ = | 270 layer_tree_host_src_->next_commit_forces_redraw_ = |
269 !layer_tree_host_src_->next_commit_forces_redraw_; | 271 !layer_tree_host_src_->next_commit_forces_redraw_; |
270 | 272 |
271 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create(); | 273 layer_tree_src->hud_layer_ = HeadsUpDisplayLayer::Create(); |
272 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_); | 274 root_layer_src->AddChild(layer_tree_src->hud_layer_); |
273 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create(); | 275 |
274 root_layer_src->AddChild( | 276 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create(); |
275 layer_tree_host_src_->overscroll_elasticity_layer_); | 277 scoped_refptr<Layer> page_scale_layer = Layer::Create(); |
276 layer_tree_host_src_->page_scale_layer_ = Layer::Create(); | 278 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); |
277 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); | 279 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); |
278 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create(); | 280 |
279 root_layer_src->AddChild( | 281 root_layer_src->AddChild(overscroll_elasticity_layer); |
280 layer_tree_host_src_->inner_viewport_scroll_layer_); | 282 root_layer_src->AddChild(page_scale_layer); |
281 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create(); | 283 root_layer_src->AddChild(inner_viewport_scroll_layer); |
282 root_layer_src->AddChild( | 284 root_layer_src->AddChild(outer_viewport_scroll_layer); |
283 layer_tree_host_src_->outer_viewport_scroll_layer_); | 285 |
| 286 layer_tree_src->RegisterViewportLayers( |
| 287 overscroll_elasticity_layer, page_scale_layer, |
| 288 inner_viewport_scroll_layer, outer_viewport_scroll_layer); |
284 | 289 |
285 // Set in_paint_layer_contents_ only after all calls to AddChild() have | 290 // Set in_paint_layer_contents_ only after all calls to AddChild() have |
286 // finished to ensure it's allowed to do so at that time. | 291 // finished to ensure it's allowed to do so at that time. |
287 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); | |
288 layer_tree_src->in_paint_layer_contents_ = | 292 layer_tree_src->in_paint_layer_contents_ = |
289 !layer_tree_src->in_paint_layer_contents(); | 293 !layer_tree_src->in_paint_layer_contents(); |
290 | 294 |
291 LayerSelectionBound sel_bound; | 295 LayerSelectionBound sel_bound; |
292 sel_bound.edge_top = gfx::Point(14, 3); | 296 sel_bound.edge_top = gfx::Point(14, 3); |
293 LayerSelection selection; | 297 LayerSelection selection; |
294 selection.start = sel_bound; | 298 selection.start = sel_bound; |
295 layer_tree_host_src_->selection_ = selection; | 299 layer_tree_src->inputs_.selection = selection; |
296 | 300 |
297 layer_tree_host_src_->property_trees_.sequence_number = | 301 layer_tree_src->property_trees_.sequence_number = |
298 layer_tree_host_src_->property_trees_.sequence_number * 3 + 1; | 302 layer_tree_src->property_trees_.sequence_number * 3 + 1; |
299 | 303 |
300 layer_tree_host_src_->surface_client_id_ = | 304 layer_tree_host_src_->surface_client_id_ = |
301 layer_tree_host_src_->surface_client_id_ * 3 + 1; | 305 layer_tree_host_src_->surface_client_id_ * 3 + 1; |
302 layer_tree_host_src_->next_surface_sequence_ = | 306 layer_tree_host_src_->next_surface_sequence_ = |
303 layer_tree_host_src_->next_surface_sequence_ * 3 + 1; | 307 layer_tree_host_src_->next_surface_sequence_ * 3 + 1; |
304 | 308 |
305 VerifySerializationAndDeserialization(); | 309 VerifySerializationAndDeserialization(); |
306 } | 310 } |
307 | 311 |
308 void RunLayersChangedTest() { | 312 void RunLayersChangedTest() { |
309 // Just fake setup a layer for both source and dest. | 313 // Just fake setup a layer for both source and dest. |
310 scoped_refptr<Layer> root_layer_src = Layer::Create(); | 314 scoped_refptr<Layer> root_layer_src = Layer::Create(); |
311 layer_tree_host_src_->SetRootLayer(root_layer_src); | 315 layer_tree_host_src_->SetRootLayer(root_layer_src); |
312 layer_tree_host_dst_->SetRootLayer(Layer::Create()); | 316 layer_tree_host_dst_->SetRootLayer(Layer::Create()); |
313 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); | 317 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); |
314 | 318 |
315 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer | 319 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer |
316 // viewport scroll layers. | 320 // viewport scroll layers. |
317 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create(); | 321 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create(); |
318 root_layer_src->AddChild( | 322 layer_tree_host_src_->GetLayerTree()->inputs_.overscroll_elasticity_layer = |
319 layer_tree_host_src_->overscroll_elasticity_layer_); | 323 overscroll_elasticity_layer; |
| 324 root_layer_src->AddChild(overscroll_elasticity_layer); |
320 | 325 |
321 VerifySerializationAndDeserialization(); | 326 VerifySerializationAndDeserialization(); |
322 } | 327 } |
323 | 328 |
324 void RunLayersChangedMultipleSerializations() { | 329 void RunLayersChangedMultipleSerializations() { |
325 // Just fake setup a layer for both source and dest. | 330 // Just fake setup a layer for both source and dest. |
326 scoped_refptr<Layer> root_layer_src = Layer::Create(); | 331 scoped_refptr<Layer> root_layer_src = Layer::Create(); |
327 layer_tree_host_src_->SetRootLayer(root_layer_src); | 332 layer_tree_host_src_->SetRootLayer(root_layer_src); |
328 layer_tree_host_dst_->SetRootLayer(Layer::Create()); | 333 layer_tree_host_dst_->SetRootLayer(Layer::Create()); |
329 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); | 334 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); |
330 | 335 |
| 336 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
| 337 |
331 // Ensure that all the layers work correctly for multiple rounds of | 338 // Ensure that all the layers work correctly for multiple rounds of |
332 // serialization and deserialization. | 339 // serialization and deserialization. |
333 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create(); | 340 layer_tree_src->hud_layer_ = HeadsUpDisplayLayer::Create(); |
334 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_); | 341 root_layer_src->AddChild(layer_tree_src->hud_layer_); |
335 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create(); | 342 |
336 root_layer_src->AddChild( | 343 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create(); |
337 layer_tree_host_src_->overscroll_elasticity_layer_); | 344 scoped_refptr<Layer> page_scale_layer = Layer::Create(); |
338 layer_tree_host_src_->page_scale_layer_ = Layer::Create(); | 345 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); |
339 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); | 346 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); |
340 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create(); | 347 |
341 root_layer_src->AddChild( | 348 root_layer_src->AddChild(overscroll_elasticity_layer); |
342 layer_tree_host_src_->inner_viewport_scroll_layer_); | 349 root_layer_src->AddChild(page_scale_layer); |
343 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create(); | 350 root_layer_src->AddChild(inner_viewport_scroll_layer); |
344 root_layer_src->AddChild( | 351 root_layer_src->AddChild(outer_viewport_scroll_layer); |
345 layer_tree_host_src_->outer_viewport_scroll_layer_); | 352 layer_tree_host_src_->GetLayerTree()->RegisterViewportLayers( |
| 353 overscroll_elasticity_layer, page_scale_layer, |
| 354 inner_viewport_scroll_layer, outer_viewport_scroll_layer); |
346 | 355 |
347 VerifySerializationAndDeserialization(); | 356 VerifySerializationAndDeserialization(); |
348 VerifySerializationAndDeserialization(); | 357 VerifySerializationAndDeserialization(); |
349 | 358 |
350 layer_tree_host_src_->hud_layer_ = nullptr; | 359 layer_tree_src->hud_layer_ = nullptr; |
351 VerifySerializationAndDeserialization(); | 360 VerifySerializationAndDeserialization(); |
352 layer_tree_host_src_->overscroll_elasticity_layer_ = nullptr; | 361 layer_tree_host_src_->GetLayerTree()->inputs_.overscroll_elasticity_layer = |
| 362 nullptr; |
353 VerifySerializationAndDeserialization(); | 363 VerifySerializationAndDeserialization(); |
354 layer_tree_host_src_->page_scale_layer_ = nullptr; | 364 layer_tree_host_src_->GetLayerTree()->inputs_.page_scale_layer = nullptr; |
355 VerifySerializationAndDeserialization(); | 365 VerifySerializationAndDeserialization(); |
356 layer_tree_host_src_->inner_viewport_scroll_layer_ = nullptr; | 366 layer_tree_host_src_->GetLayerTree()->inputs_.inner_viewport_scroll_layer = |
| 367 nullptr; |
357 VerifySerializationAndDeserialization(); | 368 VerifySerializationAndDeserialization(); |
358 layer_tree_host_src_->outer_viewport_scroll_layer_ = nullptr; | 369 layer_tree_host_src_->GetLayerTree()->inputs_.outer_viewport_scroll_layer = |
| 370 nullptr; |
359 VerifySerializationAndDeserialization(); | 371 VerifySerializationAndDeserialization(); |
360 } | 372 } |
361 | 373 |
362 void RunPictureLayerMultipleSerializationsTest() { | 374 void RunPictureLayerMultipleSerializationsTest() { |
363 // Just fake setup a layer for both source and dest. | 375 // Just fake setup a layer for both source and dest. |
364 scoped_refptr<Layer> root_layer_src = Layer::Create(); | 376 scoped_refptr<Layer> root_layer_src = Layer::Create(); |
365 layer_tree_host_src_->SetRootLayer(root_layer_src); | 377 layer_tree_host_src_->SetRootLayer(root_layer_src); |
366 layer_tree_host_dst_->SetRootLayer(Layer::Create()); | 378 layer_tree_host_dst_->SetRootLayer(Layer::Create()); |
367 | 379 |
368 // Ensure that a PictureLayer work correctly for multiple rounds of | 380 // Ensure that a PictureLayer work correctly for multiple rounds of |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 463 |
452 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { | 464 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { |
453 RunAddAndRemoveNodeFromLayerTree(); | 465 RunAddAndRemoveNodeFromLayerTree(); |
454 } | 466 } |
455 | 467 |
456 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { | 468 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { |
457 RunPictureLayerMultipleSerializationsTest(); | 469 RunPictureLayerMultipleSerializationsTest(); |
458 } | 470 } |
459 | 471 |
460 } // namespace cc | 472 } // namespace cc |
OLD | NEW |