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 8293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8304 expected.insert(grand_parent_raw); | 8304 expected.insert(grand_parent_raw); |
8305 expected.insert(parent_raw); | 8305 expected.insert(parent_raw); |
8306 expected.insert(child_raw); | 8306 expected.insert(child_raw); |
8307 expected.insert(grand_child1_raw); | 8307 expected.insert(grand_child1_raw); |
8308 expected.insert(grand_child2_raw); | 8308 expected.insert(grand_child2_raw); |
8309 | 8309 |
8310 actual.clear(); | 8310 actual.clear(); |
8311 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8311 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
8312 EXPECT_EQ(expected, actual); | 8312 EXPECT_EQ(expected, actual); |
8313 } | 8313 } |
| 8314 |
| 8315 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { |
| 8316 FakeImplProxy proxy; |
| 8317 TestSharedBitmapManager shared_bitmap_manager; |
| 8318 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 8319 |
| 8320 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
| 8321 LayerImpl* root_layer = root.get(); |
| 8322 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); |
| 8323 LayerImpl* child1_layer = child1.get(); |
| 8324 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); |
| 8325 LayerImpl* child2_layer = child2.get(); |
| 8326 |
| 8327 root->AddChild(child1.Pass()); |
| 8328 root->AddChild(child2.Pass()); |
| 8329 |
| 8330 gfx::Transform identity_matrix, scale_transform_child1, |
| 8331 scale_transform_child2; |
| 8332 scale_transform_child1.Scale(2, 3); |
| 8333 scale_transform_child2.Scale(4, 5); |
| 8334 |
| 8335 SetLayerPropertiesForTesting(root_layer, |
| 8336 identity_matrix, |
| 8337 gfx::PointF(), |
| 8338 gfx::PointF(), |
| 8339 gfx::Size(1, 1), |
| 8340 true, |
| 8341 false); |
| 8342 SetLayerPropertiesForTesting(child1_layer, |
| 8343 scale_transform_child1, |
| 8344 gfx::PointF(), |
| 8345 gfx::PointF(), |
| 8346 gfx::Size(), |
| 8347 true, |
| 8348 false); |
| 8349 |
| 8350 ExecuteCalculateDrawProperties(root_layer); |
| 8351 |
| 8352 TransformOperations scale; |
| 8353 scale.AppendScale(5.f, 8.f, 3.f); |
| 8354 |
| 8355 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); |
| 8356 SetLayerPropertiesForTesting(child2_layer, |
| 8357 scale_transform_child2, |
| 8358 gfx::PointF(), |
| 8359 gfx::PointF(), |
| 8360 gfx::Size(), |
| 8361 true, |
| 8362 false); |
| 8363 |
| 8364 ExecuteCalculateDrawProperties(root_layer); |
| 8365 |
| 8366 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); |
| 8367 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); |
| 8368 EXPECT_FLOAT_EQ(5.f, child2_layer->draw_properties().ideal_contents_scale); |
| 8369 |
| 8370 EXPECT_FLOAT_EQ( |
| 8371 0.f, root_layer->draw_properties().maximum_animation_contents_scale); |
| 8372 EXPECT_FLOAT_EQ( |
| 8373 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); |
| 8374 EXPECT_FLOAT_EQ( |
| 8375 8.f, child2_layer->draw_properties().maximum_animation_contents_scale); |
| 8376 |
| 8377 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); |
| 8378 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor); |
| 8379 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().page_scale_factor); |
| 8380 |
| 8381 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); |
| 8382 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); |
| 8383 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); |
| 8384 |
| 8385 // Changing page-scale would affect ideal_contents_scale and |
| 8386 // maximum_animation_contents_scale. |
| 8387 |
| 8388 float page_scale_factor = 3.f; |
| 8389 float device_scale_factor = 1.0f; |
| 8390 std::vector<LayerImpl*> render_surface_layer_list; |
| 8391 gfx::Size device_viewport_size = |
| 8392 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 8393 root_layer->bounds().height() * device_scale_factor); |
| 8394 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 8395 root_layer, device_viewport_size, &render_surface_layer_list); |
| 8396 |
| 8397 inputs.page_scale_factor = page_scale_factor; |
| 8398 inputs.can_adjust_raster_scales = true; |
| 8399 inputs.page_scale_application_layer = root_layer; |
| 8400 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 8401 |
| 8402 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); |
| 8403 EXPECT_FLOAT_EQ(9.f, child1_layer->draw_properties().ideal_contents_scale); |
| 8404 EXPECT_FLOAT_EQ(15.f, child2_layer->draw_properties().ideal_contents_scale); |
| 8405 |
| 8406 EXPECT_FLOAT_EQ( |
| 8407 0.f, root_layer->draw_properties().maximum_animation_contents_scale); |
| 8408 EXPECT_FLOAT_EQ( |
| 8409 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); |
| 8410 EXPECT_FLOAT_EQ( |
| 8411 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); |
| 8412 |
| 8413 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); |
| 8414 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); |
| 8415 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); |
| 8416 |
| 8417 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); |
| 8418 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); |
| 8419 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); |
| 8420 |
| 8421 // Changing device-scale would affect ideal_contents_scale and |
| 8422 // maximum_animation_contents_scale. |
| 8423 |
| 8424 device_scale_factor = 4.0f; |
| 8425 inputs.device_scale_factor = device_scale_factor; |
| 8426 inputs.can_adjust_raster_scales = true; |
| 8427 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 8428 |
| 8429 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().ideal_contents_scale); |
| 8430 EXPECT_FLOAT_EQ(36.f, child1_layer->draw_properties().ideal_contents_scale); |
| 8431 EXPECT_FLOAT_EQ(60.f, child2_layer->draw_properties().ideal_contents_scale); |
| 8432 |
| 8433 EXPECT_FLOAT_EQ( |
| 8434 0.f, root_layer->draw_properties().maximum_animation_contents_scale); |
| 8435 EXPECT_FLOAT_EQ( |
| 8436 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); |
| 8437 EXPECT_FLOAT_EQ( |
| 8438 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); |
| 8439 |
| 8440 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); |
| 8441 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); |
| 8442 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); |
| 8443 |
| 8444 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().device_scale_factor); |
| 8445 EXPECT_FLOAT_EQ(4.f, child1_layer->draw_properties().device_scale_factor); |
| 8446 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); |
| 8447 } |
| 8448 |
8314 } // namespace | 8449 } // namespace |
8315 } // namespace cc | 8450 } // namespace cc |
OLD | NEW |