OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
10 #include "cc/animation/transform_operations.h" | 10 #include "cc/animation/transform_operations.h" |
(...skipping 8294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8305 expected.insert(grand_parent_raw); | 8305 expected.insert(grand_parent_raw); |
8306 expected.insert(parent_raw); | 8306 expected.insert(parent_raw); |
8307 expected.insert(child_raw); | 8307 expected.insert(child_raw); |
8308 expected.insert(grand_child1_raw); | 8308 expected.insert(grand_child1_raw); |
8309 expected.insert(grand_child2_raw); | 8309 expected.insert(grand_child2_raw); |
8310 | 8310 |
8311 actual.clear(); | 8311 actual.clear(); |
8312 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8312 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
8313 EXPECT_EQ(expected, actual); | 8313 EXPECT_EQ(expected, actual); |
8314 } | 8314 } |
8315 | |
8316 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { | |
8317 FakeImplProxy proxy; | |
8318 TestSharedBitmapManager shared_bitmap_manager; | |
8319 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | |
8320 | |
8321 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | |
8322 LayerImpl* root_layer = root.get(); | |
8323 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); | |
8324 LayerImpl* child1_layer = child1.get(); | |
8325 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); | |
8326 LayerImpl* child2_layer = child2.get(); | |
8327 | |
8328 root->AddChild(child1.Pass()); | |
8329 root->AddChild(child2.Pass()); | |
8330 | |
8331 gfx::Transform identity_matrix, scale_transform_child1, | |
8332 scale_transform_child2; | |
8333 scale_transform_child1.Scale(2, 3); | |
8334 scale_transform_child2.Scale(4, 5); | |
8335 | |
8336 SetLayerPropertiesForTesting(root_layer, | |
8337 identity_matrix, | |
8338 gfx::Point3F(), | |
8339 gfx::PointF(), | |
8340 gfx::Size(1, 1), | |
8341 true, | |
8342 false); | |
8343 SetLayerPropertiesForTesting(child1_layer, | |
8344 scale_transform_child1, | |
8345 gfx::Point3F(), | |
8346 gfx::PointF(), | |
8347 gfx::Size(), | |
8348 true, | |
8349 false); | |
8350 | |
8351 child1_layer->SetMaskLayer( | |
8352 LayerImpl::Create(host_impl.active_tree(), 4).Pass()); | |
8353 | |
8354 scoped_ptr<LayerImpl> replica_layer = | |
8355 LayerImpl::Create(host_impl.active_tree(), 5); | |
8356 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); | |
8357 child1_layer->SetReplicaLayer(replica_layer.Pass()); | |
8358 | |
8359 ExecuteCalculateDrawProperties(root_layer); | |
8360 | |
8361 TransformOperations scale; | |
8362 scale.AppendScale(5.f, 8.f, 3.f); | |
8363 | |
8364 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); | |
8365 SetLayerPropertiesForTesting(child2_layer, | |
8366 scale_transform_child2, | |
8367 gfx::Point3F(), | |
8368 gfx::PointF(), | |
8369 gfx::Size(), | |
8370 true, | |
8371 false); | |
8372 | |
8373 ExecuteCalculateDrawProperties(root_layer); | |
8374 | |
8375 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
8376 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); | |
8377 EXPECT_FLOAT_EQ( | |
8378 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); | |
8379 EXPECT_FLOAT_EQ(3.f, | |
8380 child1_layer->replica_layer() | |
8381 ->mask_layer() | |
8382 ->draw_properties() | |
8383 .ideal_contents_scale); | |
8384 EXPECT_FLOAT_EQ(5.f, child2_layer->draw_properties().ideal_contents_scale); | |
8385 | |
8386 EXPECT_FLOAT_EQ( | |
8387 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8388 EXPECT_FLOAT_EQ( | |
8389 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8390 EXPECT_FLOAT_EQ(0.f, | |
8391 child1_layer->mask_layer() | |
8392 ->draw_properties() | |
8393 .maximum_animation_contents_scale); | |
8394 EXPECT_FLOAT_EQ(0.f, | |
8395 child1_layer->replica_layer() | |
8396 ->mask_layer() | |
8397 ->draw_properties() | |
8398 .maximum_animation_contents_scale); | |
8399 EXPECT_FLOAT_EQ( | |
8400 8.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8401 | |
8402 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8403 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor); | |
8404 EXPECT_FLOAT_EQ( | |
8405 1.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); | |
8406 EXPECT_FLOAT_EQ(1.f, | |
8407 child1_layer->replica_layer() | |
8408 ->mask_layer() | |
8409 ->draw_properties() | |
8410 .page_scale_factor); | |
8411 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().page_scale_factor); | |
8412 | |
8413 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8414 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8415 EXPECT_FLOAT_EQ( | |
8416 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); | |
8417 EXPECT_FLOAT_EQ(1.f, | |
8418 child1_layer->replica_layer() | |
8419 ->mask_layer() | |
8420 ->draw_properties() | |
8421 .device_scale_factor); | |
8422 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); | |
8423 | |
8424 // Changing page-scale would affect ideal_contents_scale and | |
8425 // maximum_animation_contents_scale. | |
8426 | |
8427 float page_scale_factor = 3.f; | |
8428 float device_scale_factor = 1.0f; | |
8429 std::vector<LayerImpl*> render_surface_layer_list; | |
8430 gfx::Size device_viewport_size = | |
8431 gfx::Size(root_layer->bounds().width() * device_scale_factor, | |
8432 root_layer->bounds().height() * device_scale_factor); | |
8433 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
8434 root_layer, device_viewport_size, &render_surface_layer_list); | |
8435 | |
8436 inputs.page_scale_factor = page_scale_factor; | |
8437 inputs.can_adjust_raster_scales = true; | |
8438 inputs.page_scale_application_layer = root_layer; | |
8439 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
8440 | |
8441 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
8442 EXPECT_FLOAT_EQ(9.f, child1_layer->draw_properties().ideal_contents_scale); | |
8443 EXPECT_FLOAT_EQ(15.f, child2_layer->draw_properties().ideal_contents_scale); | |
danakj
2014/06/12 16:00:46
You could also test the mask layer down here throu
| |
8444 | |
8445 EXPECT_FLOAT_EQ( | |
8446 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8447 EXPECT_FLOAT_EQ( | |
8448 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8449 EXPECT_FLOAT_EQ( | |
8450 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8451 | |
8452 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8453 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); | |
8454 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); | |
8455 | |
8456 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8457 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8458 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); | |
8459 | |
8460 // Changing device-scale would affect ideal_contents_scale and | |
8461 // maximum_animation_contents_scale. | |
8462 | |
8463 device_scale_factor = 4.0f; | |
8464 inputs.device_scale_factor = device_scale_factor; | |
8465 inputs.can_adjust_raster_scales = true; | |
8466 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
8467 | |
8468 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().ideal_contents_scale); | |
8469 EXPECT_FLOAT_EQ(36.f, child1_layer->draw_properties().ideal_contents_scale); | |
8470 EXPECT_FLOAT_EQ(60.f, child2_layer->draw_properties().ideal_contents_scale); | |
8471 | |
8472 EXPECT_FLOAT_EQ( | |
8473 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8474 EXPECT_FLOAT_EQ( | |
8475 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8476 EXPECT_FLOAT_EQ( | |
8477 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8478 | |
8479 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8480 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); | |
8481 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); | |
8482 | |
8483 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().device_scale_factor); | |
8484 EXPECT_FLOAT_EQ(4.f, child1_layer->draw_properties().device_scale_factor); | |
8485 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); | |
8486 } | |
8487 | |
8315 } // namespace | 8488 } // namespace |
8316 } // namespace cc | 8489 } // namespace cc |
OLD | NEW |