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 // Check scales before executing calc draw properties. | |
8352 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
danakj
2014/06/11 17:29:34
There's no guarantee that these are value before e
| |
8353 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().ideal_contents_scale); | |
8354 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8355 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor); | |
8356 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8357 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8358 EXPECT_FLOAT_EQ( | |
8359 1.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8360 EXPECT_FLOAT_EQ( | |
8361 1.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8362 | |
8363 ExecuteCalculateDrawProperties(root_layer); | |
8364 | |
8365 TransformOperations scale; | |
8366 scale.AppendScale(5.f, 8.f, 3.f); | |
8367 | |
8368 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); | |
8369 SetLayerPropertiesForTesting(child2_layer, | |
8370 scale_transform_child2, | |
8371 gfx::Point3F(), | |
8372 gfx::PointF(), | |
8373 gfx::Size(), | |
8374 true, | |
8375 false); | |
8376 | |
8377 ExecuteCalculateDrawProperties(root_layer); | |
8378 | |
8379 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
8380 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); | |
8381 EXPECT_FLOAT_EQ(5.f, child2_layer->draw_properties().ideal_contents_scale); | |
8382 | |
8383 EXPECT_FLOAT_EQ( | |
8384 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8385 EXPECT_FLOAT_EQ( | |
8386 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8387 EXPECT_FLOAT_EQ( | |
8388 8.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8389 | |
8390 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8391 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor); | |
8392 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().page_scale_factor); | |
8393 | |
8394 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8395 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8396 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); | |
8397 | |
8398 // Changing page-scale would affect ideal_contents_scale and | |
8399 // maximum_animation_contents_scale. | |
8400 | |
8401 float page_scale_factor = 3.f; | |
8402 float device_scale_factor = 1.0f; | |
8403 std::vector<LayerImpl*> render_surface_layer_list; | |
8404 gfx::Size device_viewport_size = | |
8405 gfx::Size(root_layer->bounds().width() * device_scale_factor, | |
8406 root_layer->bounds().height() * device_scale_factor); | |
8407 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
8408 root_layer, device_viewport_size, &render_surface_layer_list); | |
8409 | |
8410 inputs.page_scale_factor = page_scale_factor; | |
8411 inputs.can_adjust_raster_scales = true; | |
8412 inputs.page_scale_application_layer = root_layer; | |
8413 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
8414 | |
8415 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
8416 EXPECT_FLOAT_EQ(9.f, child1_layer->draw_properties().ideal_contents_scale); | |
8417 EXPECT_FLOAT_EQ(15.f, child2_layer->draw_properties().ideal_contents_scale); | |
8418 | |
8419 EXPECT_FLOAT_EQ( | |
8420 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8421 EXPECT_FLOAT_EQ( | |
8422 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8423 EXPECT_FLOAT_EQ( | |
8424 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8425 | |
8426 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8427 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); | |
8428 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); | |
8429 | |
8430 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8431 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8432 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); | |
8433 | |
8434 // Changing device-scale would affect ideal_contents_scale and | |
8435 // maximum_animation_contents_scale. | |
8436 | |
8437 device_scale_factor = 4.0f; | |
8438 inputs.device_scale_factor = device_scale_factor; | |
8439 inputs.can_adjust_raster_scales = true; | |
8440 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
8441 | |
8442 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().ideal_contents_scale); | |
8443 EXPECT_FLOAT_EQ(36.f, child1_layer->draw_properties().ideal_contents_scale); | |
8444 EXPECT_FLOAT_EQ(60.f, child2_layer->draw_properties().ideal_contents_scale); | |
8445 | |
8446 EXPECT_FLOAT_EQ( | |
8447 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8448 EXPECT_FLOAT_EQ( | |
8449 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8450 EXPECT_FLOAT_EQ( | |
8451 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8452 | |
8453 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8454 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); | |
8455 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); | |
8456 | |
8457 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().device_scale_factor); | |
8458 EXPECT_FLOAT_EQ(4.f, child1_layer->draw_properties().device_scale_factor); | |
8459 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); | |
8460 } | |
8461 | |
8315 } // namespace | 8462 } // namespace |
8316 } // namespace cc | 8463 } // namespace cc |
OLD | NEW |