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 8340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8351 expected.insert(grand_parent_raw); | 8351 expected.insert(grand_parent_raw); |
8352 expected.insert(parent_raw); | 8352 expected.insert(parent_raw); |
8353 expected.insert(child_raw); | 8353 expected.insert(child_raw); |
8354 expected.insert(grand_child1_raw); | 8354 expected.insert(grand_child1_raw); |
8355 expected.insert(grand_child2_raw); | 8355 expected.insert(grand_child2_raw); |
8356 | 8356 |
8357 actual.clear(); | 8357 actual.clear(); |
8358 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8358 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
8359 EXPECT_EQ(expected, actual); | 8359 EXPECT_EQ(expected, actual); |
8360 } | 8360 } |
8361 | |
8362 TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { | |
8363 FakeImplProxy proxy; | |
8364 TestSharedBitmapManager shared_bitmap_manager; | |
8365 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | |
8366 | |
8367 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | |
8368 LayerImpl* root_layer = root.get(); | |
8369 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(host_impl.active_tree(), 2); | |
8370 LayerImpl* child1_layer = child1.get(); | |
8371 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(host_impl.active_tree(), 3); | |
8372 LayerImpl* child2_layer = child2.get(); | |
8373 | |
8374 root->AddChild(child1.Pass()); | |
8375 root->AddChild(child2.Pass()); | |
8376 | |
8377 gfx::Transform identity_matrix, scale_transform_child1, | |
8378 scale_transform_child2; | |
8379 scale_transform_child1.Scale(2, 3); | |
8380 scale_transform_child2.Scale(4, 5); | |
8381 | |
8382 SetLayerPropertiesForTesting(root_layer, | |
8383 identity_matrix, | |
8384 gfx::Point3F(), | |
8385 gfx::PointF(), | |
8386 gfx::Size(1, 1), | |
8387 true, | |
8388 false); | |
8389 SetLayerPropertiesForTesting(child1_layer, | |
8390 scale_transform_child1, | |
8391 gfx::Point3F(), | |
8392 gfx::PointF(), | |
8393 gfx::Size(), | |
8394 true, | |
8395 false); | |
8396 | |
8397 child1_layer->SetMaskLayer( | |
8398 LayerImpl::Create(host_impl.active_tree(), 4).Pass()); | |
8399 | |
8400 scoped_ptr<LayerImpl> replica_layer = | |
8401 LayerImpl::Create(host_impl.active_tree(), 5); | |
8402 replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); | |
8403 child1_layer->SetReplicaLayer(replica_layer.Pass()); | |
8404 | |
8405 ExecuteCalculateDrawProperties(root_layer); | |
8406 | |
8407 TransformOperations scale; | |
8408 scale.AppendScale(5.f, 8.f, 3.f); | |
8409 | |
8410 AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); | |
8411 SetLayerPropertiesForTesting(child2_layer, | |
8412 scale_transform_child2, | |
8413 gfx::Point3F(), | |
8414 gfx::PointF(), | |
8415 gfx::Size(), | |
8416 true, | |
8417 false); | |
8418 | |
8419 ExecuteCalculateDrawProperties(root_layer); | |
8420 | |
8421 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
8422 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().ideal_contents_scale); | |
8423 EXPECT_FLOAT_EQ( | |
8424 3.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); | |
8425 EXPECT_FLOAT_EQ(3.f, | |
8426 child1_layer->replica_layer() | |
8427 ->mask_layer() | |
8428 ->draw_properties() | |
8429 .ideal_contents_scale); | |
8430 EXPECT_FLOAT_EQ(5.f, child2_layer->draw_properties().ideal_contents_scale); | |
8431 | |
8432 EXPECT_FLOAT_EQ( | |
8433 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8434 EXPECT_FLOAT_EQ( | |
8435 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8436 EXPECT_FLOAT_EQ(0.f, | |
8437 child1_layer->mask_layer() | |
8438 ->draw_properties() | |
8439 .maximum_animation_contents_scale); | |
8440 EXPECT_FLOAT_EQ(0.f, | |
8441 child1_layer->replica_layer() | |
8442 ->mask_layer() | |
8443 ->draw_properties() | |
8444 .maximum_animation_contents_scale); | |
8445 EXPECT_FLOAT_EQ( | |
8446 8.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8447 | |
8448 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8449 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().page_scale_factor); | |
8450 EXPECT_FLOAT_EQ( | |
8451 1.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); | |
8452 EXPECT_FLOAT_EQ(1.f, | |
8453 child1_layer->replica_layer() | |
8454 ->mask_layer() | |
8455 ->draw_properties() | |
8456 .page_scale_factor); | |
8457 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().page_scale_factor); | |
8458 | |
8459 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8460 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8461 EXPECT_FLOAT_EQ( | |
8462 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); | |
8463 EXPECT_FLOAT_EQ(1.f, | |
8464 child1_layer->replica_layer() | |
8465 ->mask_layer() | |
8466 ->draw_properties() | |
8467 .device_scale_factor); | |
8468 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); | |
8469 | |
8470 // Changing page-scale would affect ideal_contents_scale and | |
8471 // maximum_animation_contents_scale. | |
8472 | |
8473 float page_scale_factor = 3.f; | |
8474 float device_scale_factor = 1.0f; | |
8475 std::vector<LayerImpl*> render_surface_layer_list; | |
8476 gfx::Size device_viewport_size = | |
8477 gfx::Size(root_layer->bounds().width() * device_scale_factor, | |
8478 root_layer->bounds().height() * device_scale_factor); | |
8479 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
8480 root_layer, device_viewport_size, &render_surface_layer_list); | |
8481 | |
8482 inputs.page_scale_factor = page_scale_factor; | |
8483 inputs.can_adjust_raster_scales = true; | |
8484 inputs.page_scale_application_layer = root_layer; | |
8485 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
8486 | |
8487 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().ideal_contents_scale); | |
8488 EXPECT_FLOAT_EQ(9.f, child1_layer->draw_properties().ideal_contents_scale); | |
8489 EXPECT_FLOAT_EQ( | |
8490 9.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); | |
8491 EXPECT_FLOAT_EQ(9.f, | |
8492 child1_layer->replica_layer() | |
8493 ->mask_layer() | |
8494 ->draw_properties() | |
8495 .ideal_contents_scale); | |
8496 EXPECT_FLOAT_EQ(15.f, child2_layer->draw_properties().ideal_contents_scale); | |
8497 | |
8498 EXPECT_FLOAT_EQ( | |
8499 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8500 EXPECT_FLOAT_EQ( | |
8501 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8502 EXPECT_FLOAT_EQ(0.f, | |
8503 child1_layer->mask_layer() | |
8504 ->draw_properties() | |
8505 .maximum_animation_contents_scale); | |
8506 EXPECT_FLOAT_EQ(0.f, | |
8507 child1_layer->replica_layer() | |
8508 ->mask_layer() | |
8509 ->draw_properties() | |
8510 .maximum_animation_contents_scale); | |
8511 EXPECT_FLOAT_EQ( | |
8512 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8513 | |
8514 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8515 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); | |
8516 EXPECT_FLOAT_EQ( | |
8517 3.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); | |
8518 EXPECT_FLOAT_EQ(3.f, | |
8519 child1_layer->replica_layer() | |
8520 ->mask_layer() | |
8521 ->draw_properties() | |
8522 .page_scale_factor); | |
8523 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); | |
8524 | |
8525 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().device_scale_factor); | |
8526 EXPECT_FLOAT_EQ(1.f, child1_layer->draw_properties().device_scale_factor); | |
8527 EXPECT_FLOAT_EQ( | |
8528 1.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); | |
8529 EXPECT_FLOAT_EQ(1.f, | |
8530 child1_layer->replica_layer() | |
8531 ->mask_layer() | |
8532 ->draw_properties() | |
8533 .device_scale_factor); | |
8534 EXPECT_FLOAT_EQ(1.f, child2_layer->draw_properties().device_scale_factor); | |
8535 | |
8536 // Changing device-scale would affect ideal_contents_scale and | |
8537 // maximum_animation_contents_scale. | |
8538 | |
8539 device_scale_factor = 4.0f; | |
8540 inputs.device_scale_factor = device_scale_factor; | |
8541 inputs.can_adjust_raster_scales = true; | |
8542 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
8543 | |
8544 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().ideal_contents_scale); | |
8545 EXPECT_FLOAT_EQ(36.f, child1_layer->draw_properties().ideal_contents_scale); | |
8546 EXPECT_FLOAT_EQ( | |
8547 36.f, child1_layer->mask_layer()->draw_properties().ideal_contents_scale); | |
8548 EXPECT_FLOAT_EQ(36.f, | |
8549 child1_layer->replica_layer() | |
8550 ->mask_layer() | |
8551 ->draw_properties() | |
8552 .ideal_contents_scale); | |
8553 EXPECT_FLOAT_EQ(60.f, child2_layer->draw_properties().ideal_contents_scale); | |
8554 | |
8555 EXPECT_FLOAT_EQ( | |
8556 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | |
8557 EXPECT_FLOAT_EQ( | |
8558 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
8559 EXPECT_FLOAT_EQ(0.f, | |
8560 child1_layer->mask_layer() | |
8561 ->draw_properties() | |
8562 .maximum_animation_contents_scale); | |
8563 EXPECT_FLOAT_EQ(0.f, | |
8564 child1_layer->replica_layer() | |
8565 ->mask_layer() | |
8566 ->draw_properties() | |
8567 .maximum_animation_contents_scale); | |
8568 EXPECT_FLOAT_EQ( | |
8569 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
8570 | |
8571 EXPECT_FLOAT_EQ(1.f, root_layer->draw_properties().page_scale_factor); | |
8572 EXPECT_FLOAT_EQ(3.f, child1_layer->draw_properties().page_scale_factor); | |
8573 EXPECT_FLOAT_EQ( | |
8574 3.f, child1_layer->mask_layer()->draw_properties().page_scale_factor); | |
8575 EXPECT_FLOAT_EQ(3.f, | |
8576 child1_layer->replica_layer() | |
8577 ->mask_layer() | |
8578 ->draw_properties() | |
8579 .page_scale_factor); | |
8580 EXPECT_FLOAT_EQ(3.f, child2_layer->draw_properties().page_scale_factor); | |
8581 | |
8582 EXPECT_FLOAT_EQ(4.f, root_layer->draw_properties().device_scale_factor); | |
8583 EXPECT_FLOAT_EQ(4.f, child1_layer->draw_properties().device_scale_factor); | |
8584 EXPECT_FLOAT_EQ( | |
8585 4.f, child1_layer->mask_layer()->draw_properties().device_scale_factor); | |
8586 EXPECT_FLOAT_EQ(4.f, | |
8587 child1_layer->replica_layer() | |
8588 ->mask_layer() | |
8589 ->draw_properties() | |
8590 .device_scale_factor); | |
8591 EXPECT_FLOAT_EQ(4.f, child2_layer->draw_properties().device_scale_factor); | |
8592 } | |
8593 | |
8594 } // namespace | 8361 } // namespace |
8595 } // namespace cc | 8362 } // namespace cc |
OLD | NEW |