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/layers/layer_proto_converter.h" | 5 #include "cc/layers/layer_proto_converter.h" |
6 | 6 |
7 #include "cc/layers/empty_content_layer_client.h" | 7 #include "cc/layers/empty_content_layer_client.h" |
8 #include "cc/layers/heads_up_display_layer.h" | 8 #include "cc/layers/heads_up_display_layer.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 layer_src_a->AddChild(layer_src_c); | 196 layer_src_a->AddChild(layer_src_c); |
197 layer_src_b->AddChild(layer_src_d); | 197 layer_src_b->AddChild(layer_src_d); |
198 layer_src_b->SetMaskLayer(layer_src_b_mask.get()); | 198 layer_src_b->SetMaskLayer(layer_src_b_mask.get()); |
199 layer_src_b->SetReplicaLayer(layer_src_b_replica.get()); | 199 layer_src_b->SetReplicaLayer(layer_src_b_replica.get()); |
200 | 200 |
201 proto::LayerUpdate layer_update; | 201 proto::LayerUpdate layer_update; |
202 LayerProtoConverter::SerializeLayerProperties( | 202 LayerProtoConverter::SerializeLayerProperties( |
203 layer_src_root->layer_tree_host(), &layer_update); | 203 layer_src_root->layer_tree_host(), &layer_update); |
204 | 204 |
205 // All flags for pushing properties should have been cleared. | 205 // All flags for pushing properties should have been cleared. |
| 206 EXPECT_FALSE(layer_src_root->layer_tree_host() |
| 207 ->GetLayerTree() |
| 208 ->LayerNeedsPushPropertiesForTesting(layer_src_root.get())); |
| 209 EXPECT_FALSE(layer_src_a->layer_tree_host() |
| 210 ->GetLayerTree() |
| 211 ->LayerNeedsPushPropertiesForTesting(layer_src_a.get())); |
| 212 EXPECT_FALSE(layer_src_b->layer_tree_host() |
| 213 ->GetLayerTree() |
| 214 ->LayerNeedsPushPropertiesForTesting(layer_src_b.get())); |
206 EXPECT_FALSE( | 215 EXPECT_FALSE( |
207 layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 216 layer_src_b_mask->layer_tree_host() |
208 layer_src_root.get())); | 217 ->GetLayerTree() |
209 EXPECT_FALSE( | 218 ->LayerNeedsPushPropertiesForTesting(layer_src_b_mask.get())); |
210 layer_src_a->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
211 layer_src_a.get())); | |
212 EXPECT_FALSE( | |
213 layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
214 layer_src_b.get())); | |
215 EXPECT_FALSE( | |
216 layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
217 layer_src_b_mask.get())); | |
218 EXPECT_FALSE( | 219 EXPECT_FALSE( |
219 layer_src_b_replica->layer_tree_host() | 220 layer_src_b_replica->layer_tree_host() |
| 221 ->GetLayerTree() |
220 ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get())); | 222 ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get())); |
221 EXPECT_FALSE( | 223 EXPECT_FALSE(layer_src_c->layer_tree_host() |
222 layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 224 ->GetLayerTree() |
223 layer_src_c.get())); | 225 ->LayerNeedsPushPropertiesForTesting(layer_src_c.get())); |
224 EXPECT_FALSE( | 226 EXPECT_FALSE(layer_src_d->layer_tree_host() |
225 layer_src_d->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 227 ->GetLayerTree() |
226 layer_src_d.get())); | 228 ->LayerNeedsPushPropertiesForTesting(layer_src_d.get())); |
227 | 229 |
228 // All layers needs to push properties as their layer tree host changed. | 230 // All layers needs to push properties as their layer tree host changed. |
229 ASSERT_EQ(7, layer_update.layers_size()); | 231 ASSERT_EQ(7, layer_update.layers_size()); |
230 layer_update.Clear(); | 232 layer_update.Clear(); |
231 | 233 |
232 std::unordered_set<int> dirty_layer_ids; | 234 std::unordered_set<int> dirty_layer_ids; |
233 layer_src_a->SetNeedsPushProperties(); | 235 layer_src_a->SetNeedsPushProperties(); |
234 dirty_layer_ids.insert(layer_src_a->id()); | 236 dirty_layer_ids.insert(layer_src_a->id()); |
235 layer_src_b->SetNeedsPushProperties(); | 237 layer_src_b->SetNeedsPushProperties(); |
236 dirty_layer_ids.insert(layer_src_b->id()); | 238 dirty_layer_ids.insert(layer_src_b->id()); |
237 layer_src_b_mask->SetNeedsPushProperties(); | 239 layer_src_b_mask->SetNeedsPushProperties(); |
238 dirty_layer_ids.insert(layer_src_b_mask->id()); | 240 dirty_layer_ids.insert(layer_src_b_mask->id()); |
239 layer_src_d->SetNeedsPushProperties(); | 241 layer_src_d->SetNeedsPushProperties(); |
240 dirty_layer_ids.insert(layer_src_d->id()); | 242 dirty_layer_ids.insert(layer_src_d->id()); |
241 | 243 |
242 LayerProtoConverter::SerializeLayerProperties( | 244 LayerProtoConverter::SerializeLayerProperties( |
243 layer_src_root->layer_tree_host(), &layer_update); | 245 layer_src_root->layer_tree_host(), &layer_update); |
244 | 246 |
245 // All flags for pushing properties should have been cleared. | 247 // All flags for pushing properties should have been cleared. |
| 248 EXPECT_FALSE(layer_src_root->layer_tree_host() |
| 249 ->GetLayerTree() |
| 250 ->LayerNeedsPushPropertiesForTesting(layer_src_root.get())); |
| 251 EXPECT_FALSE(layer_src_a->layer_tree_host() |
| 252 ->GetLayerTree() |
| 253 ->LayerNeedsPushPropertiesForTesting(layer_src_a.get())); |
| 254 EXPECT_FALSE(layer_src_b->layer_tree_host() |
| 255 ->GetLayerTree() |
| 256 ->LayerNeedsPushPropertiesForTesting(layer_src_b.get())); |
246 EXPECT_FALSE( | 257 EXPECT_FALSE( |
247 layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 258 layer_src_b_mask->layer_tree_host() |
248 layer_src_root.get())); | 259 ->GetLayerTree() |
249 EXPECT_FALSE( | 260 ->LayerNeedsPushPropertiesForTesting(layer_src_b_mask.get())); |
250 layer_src_a->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
251 layer_src_a.get())); | |
252 EXPECT_FALSE( | |
253 layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
254 layer_src_b.get())); | |
255 EXPECT_FALSE( | |
256 layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
257 layer_src_b_mask.get())); | |
258 EXPECT_FALSE( | 261 EXPECT_FALSE( |
259 layer_src_b_replica->layer_tree_host() | 262 layer_src_b_replica->layer_tree_host() |
| 263 ->GetLayerTree() |
260 ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get())); | 264 ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get())); |
261 EXPECT_FALSE( | 265 EXPECT_FALSE(layer_src_c->layer_tree_host() |
262 layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 266 ->GetLayerTree() |
263 layer_src_c.get())); | 267 ->LayerNeedsPushPropertiesForTesting(layer_src_c.get())); |
264 EXPECT_FALSE( | 268 EXPECT_FALSE(layer_src_d->layer_tree_host() |
265 layer_src_d->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 269 ->GetLayerTree() |
266 layer_src_d.get())); | 270 ->LayerNeedsPushPropertiesForTesting(layer_src_d.get())); |
267 | 271 |
268 // Only 4 of the layers should have been serialized. | 272 // Only 4 of the layers should have been serialized. |
269 ASSERT_EQ(4, layer_update.layers_size()); | 273 ASSERT_EQ(4, layer_update.layers_size()); |
270 for (int index = 0; index < layer_update.layers_size(); index++) | 274 for (int index = 0; index < layer_update.layers_size(); index++) |
271 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()), | 275 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()), |
272 dirty_layer_ids.end()); | 276 dirty_layer_ids.end()); |
273 layer_src_root->SetLayerTreeHost(nullptr); | 277 layer_src_root->SetLayerTreeHost(nullptr); |
274 } | 278 } |
275 | 279 |
276 TEST_F(LayerProtoConverterTest, RecursivePropertiesSerializationSingleChild) { | 280 TEST_F(LayerProtoConverterTest, RecursivePropertiesSerializationSingleChild) { |
(...skipping 26 matching lines...) Expand all Loading... |
303 std::unordered_set<int> dirty_layer_ids; | 307 std::unordered_set<int> dirty_layer_ids; |
304 layer_src_b->SetNeedsPushProperties(); | 308 layer_src_b->SetNeedsPushProperties(); |
305 dirty_layer_ids.insert(layer_src_b->id()); | 309 dirty_layer_ids.insert(layer_src_b->id()); |
306 layer_src_b_mask->SetNeedsPushProperties(); | 310 layer_src_b_mask->SetNeedsPushProperties(); |
307 dirty_layer_ids.insert(layer_src_b_mask->id()); | 311 dirty_layer_ids.insert(layer_src_b_mask->id()); |
308 | 312 |
309 LayerProtoConverter::SerializeLayerProperties( | 313 LayerProtoConverter::SerializeLayerProperties( |
310 layer_src_root->layer_tree_host(), &layer_update); | 314 layer_src_root->layer_tree_host(), &layer_update); |
311 | 315 |
312 // All flags for pushing properties should have been cleared. | 316 // All flags for pushing properties should have been cleared. |
| 317 EXPECT_FALSE(layer_src_root->layer_tree_host() |
| 318 ->GetLayerTree() |
| 319 ->LayerNeedsPushPropertiesForTesting(layer_src_root.get())); |
| 320 EXPECT_FALSE(layer_src_b->layer_tree_host() |
| 321 ->GetLayerTree() |
| 322 ->LayerNeedsPushPropertiesForTesting(layer_src_b.get())); |
313 EXPECT_FALSE( | 323 EXPECT_FALSE( |
314 layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 324 layer_src_b_mask->layer_tree_host() |
315 layer_src_root.get())); | 325 ->GetLayerTree() |
316 EXPECT_FALSE( | 326 ->LayerNeedsPushPropertiesForTesting(layer_src_b_mask.get())); |
317 layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 327 EXPECT_FALSE(layer_src_c->layer_tree_host() |
318 layer_src_b.get())); | 328 ->GetLayerTree() |
319 EXPECT_FALSE( | 329 ->LayerNeedsPushPropertiesForTesting(layer_src_c.get())); |
320 layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
321 layer_src_b_mask.get())); | |
322 EXPECT_FALSE( | |
323 layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
324 layer_src_c.get())); | |
325 | 330 |
326 // Only 2 of the layers should have been serialized. | 331 // Only 2 of the layers should have been serialized. |
327 ASSERT_EQ(2, layer_update.layers_size()); | 332 ASSERT_EQ(2, layer_update.layers_size()); |
328 for (int index = 0; index < layer_update.layers_size(); index++) | 333 for (int index = 0; index < layer_update.layers_size(); index++) |
329 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()), | 334 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()), |
330 dirty_layer_ids.end()); | 335 dirty_layer_ids.end()); |
331 layer_src_root->SetLayerTreeHost(nullptr); | 336 layer_src_root->SetLayerTreeHost(nullptr); |
332 } | 337 } |
333 | 338 |
334 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) { | 339 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 // serialize to. | 401 // serialize to. |
397 proto::LayerNode layer_node; | 402 proto::LayerNode layer_node; |
398 new_root->SetTypeForProtoSerialization(&layer_node); | 403 new_root->SetTypeForProtoSerialization(&layer_node); |
399 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type()); | 404 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type()); |
400 | 405 |
401 new_root->SetLayerTreeHost(nullptr); | 406 new_root->SetLayerTreeHost(nullptr); |
402 } | 407 } |
403 | 408 |
404 } // namespace | 409 } // namespace |
405 } // namespace cc | 410 } // namespace cc |
OLD | NEW |