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 "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1365 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1365 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1366 A * B * A * B * A * S2, | 1366 A * B * A * B * A * S2, |
1367 render_surface2->render_surface()->screen_space_transform()); | 1367 render_surface2->render_surface()->screen_space_transform()); |
1368 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1368 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1369 A * B * A * B * R * S2, | 1369 A * B * A * B * R * S2, |
1370 render_surface2->render_surface()->replica_screen_space_transform()); | 1370 render_surface2->render_surface()->replica_screen_space_transform()); |
1371 | 1371 |
1372 // Sanity check. If these fail there is probably a bug in the test itself. It | 1372 // Sanity check. If these fail there is probably a bug in the test itself. It |
1373 // is expected that we correctly set up transforms so that the y-component of | 1373 // is expected that we correctly set up transforms so that the y-component of |
1374 // the screen-space transform encodes the "depth" of the layer in the tree. | 1374 // the screen-space transform encodes the "depth" of the layer in the tree. |
1375 EXPECT_FLOAT_EQ(1.0, | 1375 EXPECT_FLOAT_EQ(1.0, parent->screen_space_transform().matrix().get(1, 3)); |
1376 parent->screen_space_transform().matrix().getDouble(1, 3)); | 1376 EXPECT_FLOAT_EQ(2.0, |
1377 child_of_root->screen_space_transform().matrix().get(1, 3)); | |
1377 EXPECT_FLOAT_EQ( | 1378 EXPECT_FLOAT_EQ( |
1378 2.0, child_of_root->screen_space_transform().matrix().getDouble(1, 3)); | 1379 3.0, grand_child_of_root->screen_space_transform().matrix().get(1, 3)); |
1380 | |
1381 EXPECT_FLOAT_EQ(2.0, | |
1382 render_surface1->screen_space_transform().matrix().get(1, 3)); | |
1383 EXPECT_FLOAT_EQ(3.0, | |
1384 child_of_rs1->screen_space_transform().matrix().get(1, 3)); | |
1379 EXPECT_FLOAT_EQ( | 1385 EXPECT_FLOAT_EQ( |
1380 3.0, | 1386 4.0, grand_child_of_rs1->screen_space_transform().matrix().get(1, 3)); |
1381 grand_child_of_root->screen_space_transform().matrix().getDouble(1, 3)); | |
1382 | 1387 |
1388 EXPECT_FLOAT_EQ(3.0, | |
1389 render_surface2->screen_space_transform().matrix().get(1, 3)); | |
1390 EXPECT_FLOAT_EQ(4.0, | |
1391 child_of_rs2->screen_space_transform().matrix().get(1, 3)); | |
1383 EXPECT_FLOAT_EQ( | 1392 EXPECT_FLOAT_EQ( |
1384 2.0, render_surface1->screen_space_transform().matrix().getDouble(1, 3)); | 1393 5.0, grand_child_of_rs2->screen_space_transform().matrix().get(1, 3)); |
1385 EXPECT_FLOAT_EQ( | |
1386 3.0, child_of_rs1->screen_space_transform().matrix().getDouble(1, 3)); | |
1387 EXPECT_FLOAT_EQ( | |
1388 4.0, | |
1389 grand_child_of_rs1->screen_space_transform().matrix().getDouble(1, 3)); | |
1390 | |
1391 EXPECT_FLOAT_EQ( | |
1392 3.0, render_surface2->screen_space_transform().matrix().getDouble(1, 3)); | |
1393 EXPECT_FLOAT_EQ( | |
1394 4.0, child_of_rs2->screen_space_transform().matrix().getDouble(1, 3)); | |
1395 EXPECT_FLOAT_EQ( | |
1396 5.0, | |
1397 grand_child_of_rs2->screen_space_transform().matrix().getDouble(1, 3)); | |
1398 } | 1394 } |
1399 | 1395 |
1400 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) { | 1396 TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) { |
1401 // For layers that flatten their subtree, there should be an orthographic | 1397 // For layers that flatten their subtree, there should be an orthographic |
1402 // projection (for x and y values) in the middle of the transform sequence. | 1398 // projection (for x and y values) in the middle of the transform sequence. |
1403 // Note that the way the code is currently implemented, it is not expected to | 1399 // Note that the way the code is currently implemented, it is not expected to |
1404 // use a canonical orthographic projection. | 1400 // use a canonical orthographic projection. |
1405 | 1401 |
1406 scoped_refptr<Layer> root = Layer::Create(); | 1402 scoped_refptr<Layer> root = Layer::Create(); |
1407 scoped_refptr<Layer> child = Layer::Create(); | 1403 scoped_refptr<Layer> child = Layer::Create(); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 { | 1653 { |
1658 RenderSurfaceLayerList render_surface_layer_list; | 1654 RenderSurfaceLayerList render_surface_layer_list; |
1659 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 1655 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
1660 root.get(), root->bounds(), composite, &render_surface_layer_list); | 1656 root.get(), root->bounds(), composite, &render_surface_layer_list); |
1661 inputs.can_adjust_raster_scales = true; | 1657 inputs.can_adjust_raster_scales = true; |
1662 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 1658 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
1663 gfx::Transform compositeSquared = composite; | 1659 gfx::Transform compositeSquared = composite; |
1664 compositeSquared.ConcatTransform(composite); | 1660 compositeSquared.ConcatTransform(composite); |
1665 gfx::Transform compositeCubed = compositeSquared; | 1661 gfx::Transform compositeCubed = compositeSquared; |
1666 compositeCubed.ConcatTransform(composite); | 1662 compositeCubed.ConcatTransform(composite); |
1667 EXPECT_EQ(compositeSquared, root->draw_properties().target_space_transform); | 1663 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1668 EXPECT_EQ(compositeCubed, child->draw_properties().target_space_transform); | 1664 compositeSquared, root->draw_properties().target_space_transform); |
1665 EXPECT_TRANSFORMATION_MATRIX_EQ( | |
1666 compositeCubed, child->draw_properties().target_space_transform); | |
1669 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); | 1667 EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform()); |
1670 } | 1668 } |
1671 } | 1669 } |
1672 | 1670 |
1673 TEST_F(LayerTreeHostCommonTest, | 1671 TEST_F(LayerTreeHostCommonTest, |
1674 RenderSurfaceListForRenderSurfaceWithClippedLayer) { | 1672 RenderSurfaceListForRenderSurfaceWithClippedLayer) { |
1675 scoped_refptr<Layer> parent = Layer::Create(); | 1673 scoped_refptr<Layer> parent = Layer::Create(); |
1676 scoped_refptr<Layer> render_surface1 = Layer::Create(); | 1674 scoped_refptr<Layer> render_surface1 = Layer::Create(); |
1677 scoped_refptr<LayerWithForcedDrawsContent> child = | 1675 scoped_refptr<LayerWithForcedDrawsContent> child = |
1678 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 1676 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2631 EXPECT_FALSE(grand_child_of_rs1->screen_space_transform_is_animating()); | 2629 EXPECT_FALSE(grand_child_of_rs1->screen_space_transform_is_animating()); |
2632 EXPECT_TRUE(render_surface2->screen_space_transform_is_animating()); | 2630 EXPECT_TRUE(render_surface2->screen_space_transform_is_animating()); |
2633 EXPECT_TRUE(render_surface2->render_surface() | 2631 EXPECT_TRUE(render_surface2->render_surface() |
2634 ->screen_space_transforms_are_animating()); | 2632 ->screen_space_transforms_are_animating()); |
2635 EXPECT_TRUE(child_of_rs2->screen_space_transform_is_animating()); | 2633 EXPECT_TRUE(child_of_rs2->screen_space_transform_is_animating()); |
2636 EXPECT_TRUE(grand_child_of_rs2->screen_space_transform_is_animating()); | 2634 EXPECT_TRUE(grand_child_of_rs2->screen_space_transform_is_animating()); |
2637 | 2635 |
2638 // Sanity check. If these fail there is probably a bug in the test itself. | 2636 // Sanity check. If these fail there is probably a bug in the test itself. |
2639 // It is expected that we correctly set up transforms so that the y-component | 2637 // It is expected that we correctly set up transforms so that the y-component |
2640 // of the screen-space transform encodes the "depth" of the layer in the tree. | 2638 // of the screen-space transform encodes the "depth" of the layer in the tree. |
2641 EXPECT_FLOAT_EQ(1.0, | 2639 EXPECT_FLOAT_EQ(1.0, parent->screen_space_transform().matrix().get(1, 3)); |
2642 parent->screen_space_transform().matrix().getDouble(1, 3)); | 2640 EXPECT_FLOAT_EQ(2.0, |
2641 child_of_root->screen_space_transform().matrix().get(1, 3)); | |
2643 EXPECT_FLOAT_EQ( | 2642 EXPECT_FLOAT_EQ( |
2644 2.0, child_of_root->screen_space_transform().matrix().getDouble(1, 3)); | 2643 3.0, grand_child_of_root->screen_space_transform().matrix().get(1, 3)); |
2644 | |
2645 EXPECT_FLOAT_EQ(2.0, | |
2646 render_surface1->screen_space_transform().matrix().get(1, 3)); | |
2647 EXPECT_FLOAT_EQ(3.0, | |
2648 child_of_rs1->screen_space_transform().matrix().get(1, 3)); | |
2645 EXPECT_FLOAT_EQ( | 2649 EXPECT_FLOAT_EQ( |
2646 3.0, | 2650 4.0, grand_child_of_rs1->screen_space_transform().matrix().get(1, 3)); |
2647 grand_child_of_root->screen_space_transform().matrix().getDouble(1, 3)); | |
2648 | 2651 |
2652 EXPECT_FLOAT_EQ(3.0, | |
2653 render_surface2->screen_space_transform().matrix().get(1, 3)); | |
2654 EXPECT_FLOAT_EQ(4.0, | |
2655 child_of_rs2->screen_space_transform().matrix().get(1, 3)); | |
2649 EXPECT_FLOAT_EQ( | 2656 EXPECT_FLOAT_EQ( |
2650 2.0, render_surface1->screen_space_transform().matrix().getDouble(1, 3)); | 2657 5.0, grand_child_of_rs2->screen_space_transform().matrix().get(1, 3)); |
2651 EXPECT_FLOAT_EQ( | |
2652 3.0, child_of_rs1->screen_space_transform().matrix().getDouble(1, 3)); | |
2653 EXPECT_FLOAT_EQ( | |
2654 4.0, | |
2655 grand_child_of_rs1->screen_space_transform().matrix().getDouble(1, 3)); | |
2656 | |
2657 EXPECT_FLOAT_EQ( | |
2658 3.0, render_surface2->screen_space_transform().matrix().getDouble(1, 3)); | |
2659 EXPECT_FLOAT_EQ( | |
2660 4.0, child_of_rs2->screen_space_transform().matrix().getDouble(1, 3)); | |
2661 EXPECT_FLOAT_EQ( | |
2662 5.0, | |
2663 grand_child_of_rs2->screen_space_transform().matrix().getDouble(1, 3)); | |
2664 } | 2658 } |
2665 | 2659 |
2666 TEST_F(LayerTreeHostCommonTest, VisibleRectForIdentityTransform) { | 2660 TEST_F(LayerTreeHostCommonTest, VisibleRectForIdentityTransform) { |
2667 // Test the calculateVisibleRect() function works correctly for identity | 2661 // Test the calculateVisibleRect() function works correctly for identity |
2668 // transforms. | 2662 // transforms. |
2669 | 2663 |
2670 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); | 2664 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); |
2671 gfx::Transform layer_to_surface_transform; | 2665 gfx::Transform layer_to_surface_transform; |
2672 | 2666 |
2673 // Case 1: Layer is contained within the surface. | 2667 // Case 1: Layer is contained within the surface. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2789 layer_to_surface_transform.RotateAboutYAxis(45.0); | 2783 layer_to_surface_transform.RotateAboutYAxis(45.0); |
2790 gfx::Rect expected = gfx::Rect(0, 0, 100, 100); | 2784 gfx::Rect expected = gfx::Rect(0, 0, 100, 100); |
2791 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( | 2785 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( |
2792 target_surface_rect, layer_content_rect, layer_to_surface_transform); | 2786 target_surface_rect, layer_content_rect, layer_to_surface_transform); |
2793 EXPECT_RECT_EQ(expected, actual); | 2787 EXPECT_RECT_EQ(expected, actual); |
2794 | 2788 |
2795 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 | 2789 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 |
2796 // degrees, but shifted to the side so only the right-half the layer would be | 2790 // degrees, but shifted to the side so only the right-half the layer would be |
2797 // visible on the surface. | 2791 // visible on the surface. |
2798 // 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width. | 2792 // 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width. |
2799 double half_width_of_rotated_layer = (100.0 / sqrt(2.0)) * 0.5; | 2793 SkMScalar half_width_of_rotated_layer = (100.0 / sqrt(2.0)) * 0.5; |
danakj
2013/09/09 17:57:45
should these be float literals? Or SkDoubleToMScal
enne (OOO)
2013/09/10 22:32:32
I'll do the latter.
| |
2800 layer_to_surface_transform.MakeIdentity(); | 2794 layer_to_surface_transform.MakeIdentity(); |
2801 layer_to_surface_transform.Translate(-half_width_of_rotated_layer, 0.0); | 2795 layer_to_surface_transform.Translate(-half_width_of_rotated_layer, 0.0); |
2802 layer_to_surface_transform.RotateAboutYAxis(45.0); // Rotates about the left | 2796 layer_to_surface_transform.RotateAboutYAxis(45.0); // Rotates about the left |
2803 // edge of the layer. | 2797 // edge of the layer. |
2804 expected = gfx::Rect(50, 0, 50, 100); // Tight half of the layer. | 2798 expected = gfx::Rect(50, 0, 50, 100); // Tight half of the layer. |
2805 actual = LayerTreeHostCommon::CalculateVisibleRect( | 2799 actual = LayerTreeHostCommon::CalculateVisibleRect( |
2806 target_surface_rect, layer_content_rect, layer_to_surface_transform); | 2800 target_surface_rect, layer_content_rect, layer_to_surface_transform); |
2807 EXPECT_RECT_EQ(expected, actual); | 2801 EXPECT_RECT_EQ(expected, actual); |
2808 } | 2802 } |
2809 | 2803 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3212 ExecuteCalculateDrawProperties(root.get()); | 3206 ExecuteCalculateDrawProperties(root.get()); |
3213 | 3207 |
3214 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); | 3208 EXPECT_TRUE(child->visible_content_rect().IsEmpty()); |
3215 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 3209 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
3216 | 3210 |
3217 // Case 2: a matrix with flattened z, technically uninvertible but still | 3211 // Case 2: a matrix with flattened z, technically uninvertible but still |
3218 // drawable and visible. In this case, we must assume that the entire layer | 3212 // drawable and visible. In this case, we must assume that the entire layer |
3219 // bounds are visible since there is no way to inverse-project the surface | 3213 // bounds are visible since there is no way to inverse-project the surface |
3220 // bounds to intersect. | 3214 // bounds to intersect. |
3221 uninvertible_matrix.MakeIdentity(); | 3215 uninvertible_matrix.MakeIdentity(); |
3222 uninvertible_matrix.matrix().setDouble(2, 2, 0.0); | 3216 uninvertible_matrix.matrix().set(2, 2, 0.0); |
3223 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3217 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
3224 | 3218 |
3225 SetLayerPropertiesForTesting(child.get(), | 3219 SetLayerPropertiesForTesting(child.get(), |
3226 uninvertible_matrix, | 3220 uninvertible_matrix, |
3227 identity_matrix, | 3221 identity_matrix, |
3228 gfx::PointF(), | 3222 gfx::PointF(), |
3229 gfx::PointF(5.f, 5.f), | 3223 gfx::PointF(5.f, 5.f), |
3230 gfx::Size(50, 50), | 3224 gfx::Size(50, 50), |
3231 false); | 3225 false); |
3232 | 3226 |
3233 ExecuteCalculateDrawProperties(root.get()); | 3227 ExecuteCalculateDrawProperties(root.get()); |
3234 | 3228 |
3235 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child->visible_content_rect()); | 3229 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child->visible_content_rect()); |
3236 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child->drawable_content_rect()); | 3230 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child->drawable_content_rect()); |
3237 | 3231 |
3238 // Case 3: a matrix with flattened z, technically uninvertible but still | 3232 // Case 3: a matrix with flattened z, technically uninvertible but still |
3239 // drawable, but not visible. In this case, we don't need to conservatively | 3233 // drawable, but not visible. In this case, we don't need to conservatively |
3240 // assume that the whole layer is visible. | 3234 // assume that the whole layer is visible. |
3241 uninvertible_matrix.MakeIdentity(); | 3235 uninvertible_matrix.MakeIdentity(); |
3242 uninvertible_matrix.Translate(500.0, 0.0); | 3236 uninvertible_matrix.Translate(500.0, 0.0); |
3243 uninvertible_matrix.matrix().setDouble(2, 2, 0.0); | 3237 uninvertible_matrix.matrix().set(2, 2, 0.0); |
3244 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3238 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
3245 | 3239 |
3246 SetLayerPropertiesForTesting(child.get(), | 3240 SetLayerPropertiesForTesting(child.get(), |
3247 uninvertible_matrix, | 3241 uninvertible_matrix, |
3248 identity_matrix, | 3242 identity_matrix, |
3249 gfx::PointF(), | 3243 gfx::PointF(), |
3250 gfx::PointF(5.f, 5.f), | 3244 gfx::PointF(5.f, 5.f), |
3251 gfx::Size(50, 50), | 3245 gfx::Size(50, 50), |
3252 false); | 3246 false); |
3253 | 3247 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3562 false); | 3556 false); |
3563 | 3557 |
3564 root->SetMasksToBounds(true); | 3558 root->SetMasksToBounds(true); |
3565 render_surface1->SetForceRenderSurface(true); | 3559 render_surface1->SetForceRenderSurface(true); |
3566 ExecuteCalculateDrawProperties(root.get()); | 3560 ExecuteCalculateDrawProperties(root.get()); |
3567 | 3561 |
3568 ASSERT_TRUE(render_surface1->render_surface()); | 3562 ASSERT_TRUE(render_surface1->render_surface()); |
3569 | 3563 |
3570 // The clipped surface clamps the DrawableContentRect that encloses the | 3564 // The clipped surface clamps the DrawableContentRect that encloses the |
3571 // rotated layer. | 3565 // rotated layer. |
3572 int diagonal_radius = ceil(sqrt(2.0) * 25.0); | 3566 int diagonal_radius = ceil(sqrt(2.0) * 25.0); |
danakj
2013/09/09 17:57:45
does it help if you use floats here?
enne (OOO)
2013/09/10 22:32:32
Sadly, sqrt(2) * 25 = 35.35, so it easily rounds u
| |
3573 gfx::Rect unclipped_surface_content = gfx::Rect(50.0 - diagonal_radius, | 3567 gfx::Rect unclipped_surface_content = gfx::Rect(50.0 - diagonal_radius, |
danakj
2013/09/09 17:57:45
woa wierd, using double literals for an integer re
enne (OOO)
2013/09/10 22:32:32
Done.
| |
3574 50.0 - diagonal_radius, | 3568 50.0 - diagonal_radius, |
3575 diagonal_radius * 2.0, | 3569 diagonal_radius * 2.0, |
3576 diagonal_radius * 2.0); | 3570 diagonal_radius * 2.0); |
3577 gfx::Rect expected_surface_drawable_content = | 3571 gfx::Rect expected_surface_drawable_content = |
3578 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50)); | 3572 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50)); |
3579 EXPECT_RECT_EQ(expected_surface_drawable_content, | 3573 EXPECT_RECT_EQ(expected_surface_drawable_content, |
3580 render_surface1->render_surface()->DrawableContentRect()); | 3574 render_surface1->render_surface()->DrawableContentRect()); |
3581 | 3575 |
3582 // On the clipped surface, only a quarter of the child1 is visible, but when | 3576 // On the clipped surface, only a quarter of the child1 is visible, but when |
3583 // rotating it back to child1's content space, the actual enclosing rect ends | 3577 // rotating it back to child1's content space, the actual enclosing rect ends |
3584 // up covering the full left half of child1. | 3578 // up covering the full left half of child1. |
3579 // | |
3580 // Given the floating point math, this number is a little bit fuzzy. | |
3581 #ifdef SK_MSCALAR_IS_DOUBLE | |
enne (OOO)
2013/09/07 00:01:45
This is the sketchiest part of this patch. I'm no
| |
3582 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_content_rect()); | |
3583 #else | |
3585 EXPECT_RECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect()); | 3584 EXPECT_RECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect()); |
3585 #endif | |
3586 | 3586 |
3587 // The child's DrawableContentRect is unclipped. | 3587 // The child's DrawableContentRect is unclipped. |
3588 EXPECT_RECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); | 3588 EXPECT_RECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); |
3589 } | 3589 } |
3590 | 3590 |
3591 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { | 3591 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { |
3592 MockContentLayerClient client; | 3592 MockContentLayerClient client; |
3593 | 3593 |
3594 scoped_refptr<Layer> root = Layer::Create(); | 3594 scoped_refptr<Layer> root = Layer::Create(); |
3595 scoped_refptr<ContentLayer> render_surface1 = | 3595 scoped_refptr<ContentLayer> render_surface1 = |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4461 EXPECT_EQ(12345, result_layer->id()); | 4461 EXPECT_EQ(12345, result_layer->id()); |
4462 } | 4462 } |
4463 | 4463 |
4464 TEST_F(LayerTreeHostCommonTest, HitTestingForUninvertibleTransform) { | 4464 TEST_F(LayerTreeHostCommonTest, HitTestingForUninvertibleTransform) { |
4465 FakeImplProxy proxy; | 4465 FakeImplProxy proxy; |
4466 FakeLayerTreeHostImpl host_impl(&proxy); | 4466 FakeLayerTreeHostImpl host_impl(&proxy); |
4467 scoped_ptr<LayerImpl> root = | 4467 scoped_ptr<LayerImpl> root = |
4468 LayerImpl::Create(host_impl.active_tree(), 12345); | 4468 LayerImpl::Create(host_impl.active_tree(), 12345); |
4469 | 4469 |
4470 gfx::Transform uninvertible_transform; | 4470 gfx::Transform uninvertible_transform; |
4471 uninvertible_transform.matrix().setDouble(0, 0, 0.0); | 4471 uninvertible_transform.matrix().set(0, 0, 0.0); |
4472 uninvertible_transform.matrix().setDouble(1, 1, 0.0); | 4472 uninvertible_transform.matrix().set(1, 1, 0.0); |
4473 uninvertible_transform.matrix().setDouble(2, 2, 0.0); | 4473 uninvertible_transform.matrix().set(2, 2, 0.0); |
4474 uninvertible_transform.matrix().setDouble(3, 3, 0.0); | 4474 uninvertible_transform.matrix().set(3, 3, 0.0); |
4475 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 4475 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
4476 | 4476 |
4477 gfx::Transform identity_matrix; | 4477 gfx::Transform identity_matrix; |
4478 gfx::PointF anchor; | 4478 gfx::PointF anchor; |
4479 gfx::PointF position; | 4479 gfx::PointF position; |
4480 gfx::Size bounds(100, 100); | 4480 gfx::Size bounds(100, 100); |
4481 SetLayerPropertiesForTesting(root.get(), | 4481 SetLayerPropertiesForTesting(root.get(), |
4482 uninvertible_transform, | 4482 uninvertible_transform, |
4483 identity_matrix, | 4483 identity_matrix, |
4484 anchor, | 4484 anchor, |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5047 | 5047 |
5048 // (11, 50) is inside the layer and within the clipped area. | 5048 // (11, 50) is inside the layer and within the clipped area. |
5049 test_point = gfx::Point(11, 50); | 5049 test_point = gfx::Point(11, 50); |
5050 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5050 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
5051 test_point, render_surface_layer_list); | 5051 test_point, render_surface_layer_list); |
5052 ASSERT_TRUE(result_layer); | 5052 ASSERT_TRUE(result_layer); |
5053 EXPECT_EQ(2468, result_layer->id()); | 5053 EXPECT_EQ(2468, result_layer->id()); |
5054 | 5054 |
5055 // Around the middle, just to the right and up, would have hit the layer | 5055 // Around the middle, just to the right and up, would have hit the layer |
5056 // except that that area should be clipped away by the parent. | 5056 // except that that area should be clipped away by the parent. |
5057 test_point = gfx::Point(51, 51); | 5057 test_point = gfx::Point(51, 49); |
5058 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5058 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
5059 test_point, render_surface_layer_list); | 5059 test_point, render_surface_layer_list); |
5060 EXPECT_FALSE(result_layer); | 5060 EXPECT_FALSE(result_layer); |
5061 | 5061 |
5062 // Around the middle, just to the left and down, should successfully hit the | 5062 // Around the middle, just to the left and down, should successfully hit the |
5063 // layer. | 5063 // layer. |
5064 test_point = gfx::Point(49, 51); | 5064 test_point = gfx::Point(49, 51); |
5065 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 5065 result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
5066 test_point, render_surface_layer_list); | 5066 test_point, render_surface_layer_list); |
5067 ASSERT_TRUE(result_layer); | 5067 ASSERT_TRUE(result_layer); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5560 } | 5560 } |
5561 | 5561 |
5562 TEST_F(LayerTreeHostCommonTest, | 5562 TEST_F(LayerTreeHostCommonTest, |
5563 HitCheckingTouchHandlerRegionsForUninvertibleTransform) { | 5563 HitCheckingTouchHandlerRegionsForUninvertibleTransform) { |
5564 FakeImplProxy proxy; | 5564 FakeImplProxy proxy; |
5565 FakeLayerTreeHostImpl host_impl(&proxy); | 5565 FakeLayerTreeHostImpl host_impl(&proxy); |
5566 scoped_ptr<LayerImpl> root = | 5566 scoped_ptr<LayerImpl> root = |
5567 LayerImpl::Create(host_impl.active_tree(), 12345); | 5567 LayerImpl::Create(host_impl.active_tree(), 12345); |
5568 | 5568 |
5569 gfx::Transform uninvertible_transform; | 5569 gfx::Transform uninvertible_transform; |
5570 uninvertible_transform.matrix().setDouble(0, 0, 0.0); | 5570 uninvertible_transform.matrix().set(0, 0, 0.0); |
5571 uninvertible_transform.matrix().setDouble(1, 1, 0.0); | 5571 uninvertible_transform.matrix().set(1, 1, 0.0); |
5572 uninvertible_transform.matrix().setDouble(2, 2, 0.0); | 5572 uninvertible_transform.matrix().set(2, 2, 0.0); |
5573 uninvertible_transform.matrix().setDouble(3, 3, 0.0); | 5573 uninvertible_transform.matrix().set(3, 3, 0.0); |
5574 ASSERT_FALSE(uninvertible_transform.IsInvertible()); | 5574 ASSERT_FALSE(uninvertible_transform.IsInvertible()); |
5575 | 5575 |
5576 gfx::Transform identity_matrix; | 5576 gfx::Transform identity_matrix; |
5577 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 5577 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); |
5578 gfx::PointF anchor; | 5578 gfx::PointF anchor; |
5579 gfx::PointF position; | 5579 gfx::PointF position; |
5580 gfx::Size bounds(100, 100); | 5580 gfx::Size bounds(100, 100); |
5581 SetLayerPropertiesForTesting(root.get(), | 5581 SetLayerPropertiesForTesting(root.get(), |
5582 uninvertible_transform, | 5582 uninvertible_transform, |
5583 identity_matrix, | 5583 identity_matrix, |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6463 child_no_scale->draw_transform()); | 6463 child_no_scale->draw_transform()); |
6464 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_no_scale_transform, | 6464 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_no_scale_transform, |
6465 child_no_scale->screen_space_transform()); | 6465 child_no_scale->screen_space_transform()); |
6466 } | 6466 } |
6467 | 6467 |
6468 TEST_F(LayerTreeHostCommonTest, ContentsScale) { | 6468 TEST_F(LayerTreeHostCommonTest, ContentsScale) { |
6469 MockContentLayerClient delegate; | 6469 MockContentLayerClient delegate; |
6470 gfx::Transform identity_matrix; | 6470 gfx::Transform identity_matrix; |
6471 | 6471 |
6472 gfx::Transform parent_scale_matrix; | 6472 gfx::Transform parent_scale_matrix; |
6473 double initial_parent_scale = 1.75; | 6473 SkMScalar initial_parent_scale = 1.75; |
6474 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 6474 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
6475 | 6475 |
6476 gfx::Transform child_scale_matrix; | 6476 gfx::Transform child_scale_matrix; |
6477 double initial_child_scale = 1.25; | 6477 SkMScalar initial_child_scale = 1.25; |
6478 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 6478 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
6479 | 6479 |
6480 scoped_refptr<Layer> root = Layer::Create(); | 6480 scoped_refptr<Layer> root = Layer::Create(); |
6481 root->SetBounds(gfx::Size(100, 100)); | 6481 root->SetBounds(gfx::Size(100, 100)); |
6482 | 6482 |
6483 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); | 6483 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); |
6484 SetLayerPropertiesForTesting(parent.get(), | 6484 SetLayerPropertiesForTesting(parent.get(), |
6485 parent_scale_matrix, | 6485 parent_scale_matrix, |
6486 identity_matrix, | 6486 identity_matrix, |
6487 gfx::PointF(), | 6487 gfx::PointF(), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6548 child_scale); | 6548 child_scale); |
6549 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 6549 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
6550 initial_parent_scale * initial_child_scale, | 6550 initial_parent_scale * initial_child_scale, |
6551 child_empty); | 6551 child_empty); |
6552 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); | 6552 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); |
6553 | 6553 |
6554 // The parent is scaled up and shouldn't need to scale during draw. The | 6554 // The parent is scaled up and shouldn't need to scale during draw. The |
6555 // child that can scale its contents should also not need to scale during | 6555 // child that can scale its contents should also not need to scale during |
6556 // draw. This shouldn't change if the child has empty bounds. The other | 6556 // draw. This shouldn't change if the child has empty bounds. The other |
6557 // children should. | 6557 // children should. |
6558 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(0, 0)); | 6558 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(0, 0)); |
6559 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(1, 1)); | 6559 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(1, 1)); |
6560 EXPECT_FLOAT_EQ(1.0, | 6560 EXPECT_FLOAT_EQ(1.0, child_scale->draw_transform().matrix().get(0, 0)); |
6561 child_scale->draw_transform().matrix().getDouble(0, 0)); | 6561 EXPECT_FLOAT_EQ(1.0, child_scale->draw_transform().matrix().get(1, 1)); |
6562 EXPECT_FLOAT_EQ(1.0, | 6562 EXPECT_FLOAT_EQ(1.0, child_empty->draw_transform().matrix().get(0, 0)); |
6563 child_scale->draw_transform().matrix().getDouble(1, 1)); | 6563 EXPECT_FLOAT_EQ(1.0, child_empty->draw_transform().matrix().get(1, 1)); |
6564 EXPECT_FLOAT_EQ(1.0, | |
6565 child_empty->draw_transform().matrix().getDouble(0, 0)); | |
6566 EXPECT_FLOAT_EQ(1.0, | |
6567 child_empty->draw_transform().matrix().getDouble(1, 1)); | |
6568 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * | 6564 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * |
6569 initial_parent_scale * initial_child_scale, | 6565 initial_parent_scale * initial_child_scale, |
6570 child_no_scale->draw_transform().matrix().getDouble(0, 0)); | 6566 child_no_scale->draw_transform().matrix().get(0, 0)); |
6571 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * | 6567 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * |
6572 initial_parent_scale * initial_child_scale, | 6568 initial_parent_scale * initial_child_scale, |
6573 child_no_scale->draw_transform().matrix().getDouble(1, 1)); | 6569 child_no_scale->draw_transform().matrix().get(1, 1)); |
6574 } | 6570 } |
6575 | 6571 |
6576 // If the device_scale_factor or page_scale_factor changes, then it should be | 6572 // If the device_scale_factor or page_scale_factor changes, then it should be |
6577 // updated using the initial transform as the raster scale. | 6573 // updated using the initial transform as the raster scale. |
6578 device_scale_factor = 2.25f; | 6574 device_scale_factor = 2.25f; |
6579 page_scale_factor = 1.25f; | 6575 page_scale_factor = 1.25f; |
6580 | 6576 |
6581 { | 6577 { |
6582 RenderSurfaceLayerList render_surface_layer_list; | 6578 RenderSurfaceLayerList render_surface_layer_list; |
6583 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6579 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6584 root.get(), root->bounds(), &render_surface_layer_list); | 6580 root.get(), root->bounds(), &render_surface_layer_list); |
6585 inputs.device_scale_factor = device_scale_factor; | 6581 inputs.device_scale_factor = device_scale_factor; |
6586 inputs.page_scale_factor = page_scale_factor; | 6582 inputs.page_scale_factor = page_scale_factor; |
6587 inputs.page_scale_application_layer = root.get(); | 6583 inputs.page_scale_application_layer = root.get(); |
6588 inputs.can_adjust_raster_scales = true; | 6584 inputs.can_adjust_raster_scales = true; |
6589 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6585 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6590 | 6586 |
6591 EXPECT_CONTENTS_SCALE_EQ( | 6587 EXPECT_CONTENTS_SCALE_EQ( |
6592 device_scale_factor * page_scale_factor * initial_parent_scale, parent); | 6588 device_scale_factor * page_scale_factor * initial_parent_scale, parent); |
6593 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 6589 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
6594 initial_parent_scale * initial_child_scale, | 6590 initial_parent_scale * initial_child_scale, |
6595 child_scale); | 6591 child_scale); |
6596 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 6592 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
6597 initial_parent_scale * initial_child_scale, | 6593 initial_parent_scale * initial_child_scale, |
6598 child_empty); | 6594 child_empty); |
6599 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); | 6595 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); |
6600 } | 6596 } |
6601 | 6597 |
6602 // If the transform changes, we expect the raster scale to be reset to 1.0. | 6598 // If the transform changes, we expect the raster scale to be reset to 1.0. |
6603 double second_child_scale = 1.75; | 6599 SkMScalar second_child_scale = 1.75; |
6604 child_scale_matrix.Scale(second_child_scale / initial_child_scale, | 6600 child_scale_matrix.Scale(second_child_scale / initial_child_scale, |
6605 second_child_scale / initial_child_scale); | 6601 second_child_scale / initial_child_scale); |
6606 child_scale->SetTransform(child_scale_matrix); | 6602 child_scale->SetTransform(child_scale_matrix); |
6607 child_empty->SetTransform(child_scale_matrix); | 6603 child_empty->SetTransform(child_scale_matrix); |
6608 | 6604 |
6609 { | 6605 { |
6610 RenderSurfaceLayerList render_surface_layer_list; | 6606 RenderSurfaceLayerList render_surface_layer_list; |
6611 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6607 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6612 root.get(), root->bounds(), &render_surface_layer_list); | 6608 root.get(), root->bounds(), &render_surface_layer_list); |
6613 inputs.device_scale_factor = device_scale_factor; | 6609 inputs.device_scale_factor = device_scale_factor; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6651 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); | 6647 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); |
6652 } | 6648 } |
6653 } | 6649 } |
6654 | 6650 |
6655 TEST_F(LayerTreeHostCommonTest, | 6651 TEST_F(LayerTreeHostCommonTest, |
6656 ContentsScale_LayerTransformsDontAffectContentsScale) { | 6652 ContentsScale_LayerTransformsDontAffectContentsScale) { |
6657 MockContentLayerClient delegate; | 6653 MockContentLayerClient delegate; |
6658 gfx::Transform identity_matrix; | 6654 gfx::Transform identity_matrix; |
6659 | 6655 |
6660 gfx::Transform parent_scale_matrix; | 6656 gfx::Transform parent_scale_matrix; |
6661 double initial_parent_scale = 1.75; | 6657 SkMScalar initial_parent_scale = 1.75; |
enne (OOO)
2013/09/07 00:01:45
The best part of this patch is that there's no sty
danakj
2013/09/09 17:57:45
`On 2013/09/07 00:01:45, enne wrote:
enne (OOO)
2013/09/10 22:32:32
I wasn't totally serious here. I think the plan s
| |
6662 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 6658 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
6663 | 6659 |
6664 gfx::Transform child_scale_matrix; | 6660 gfx::Transform child_scale_matrix; |
6665 double initial_child_scale = 1.25; | 6661 SkMScalar initial_child_scale = 1.25; |
6666 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 6662 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
6667 | 6663 |
6668 scoped_refptr<Layer> root = Layer::Create(); | 6664 scoped_refptr<Layer> root = Layer::Create(); |
6669 root->SetBounds(gfx::Size(100, 100)); | 6665 root->SetBounds(gfx::Size(100, 100)); |
6670 | 6666 |
6671 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); | 6667 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); |
6672 SetLayerPropertiesForTesting(parent.get(), | 6668 SetLayerPropertiesForTesting(parent.get(), |
6673 parent_scale_matrix, | 6669 parent_scale_matrix, |
6674 identity_matrix, | 6670 identity_matrix, |
6675 gfx::PointF(), | 6671 gfx::PointF(), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6731 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, parent); | 6727 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, parent); |
6732 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 6728 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
6733 child_scale); | 6729 child_scale); |
6734 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 6730 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
6735 child_empty); | 6731 child_empty); |
6736 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); | 6732 EXPECT_CONTENTS_SCALE_EQ(1, child_no_scale); |
6737 | 6733 |
6738 // Since the transform scale does not affect contents scale, it should affect | 6734 // Since the transform scale does not affect contents scale, it should affect |
6739 // the draw transform instead. | 6735 // the draw transform instead. |
6740 EXPECT_FLOAT_EQ(initial_parent_scale, | 6736 EXPECT_FLOAT_EQ(initial_parent_scale, |
6741 parent->draw_transform().matrix().getDouble(0, 0)); | 6737 parent->draw_transform().matrix().get(0, 0)); |
6742 EXPECT_FLOAT_EQ(initial_parent_scale, | 6738 EXPECT_FLOAT_EQ(initial_parent_scale, |
6743 parent->draw_transform().matrix().getDouble(1, 1)); | 6739 parent->draw_transform().matrix().get(1, 1)); |
6744 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, | 6740 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, |
6745 child_scale->draw_transform().matrix().getDouble(0, 0)); | 6741 child_scale->draw_transform().matrix().get(0, 0)); |
6746 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, | 6742 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, |
6747 child_scale->draw_transform().matrix().getDouble(1, 1)); | 6743 child_scale->draw_transform().matrix().get(1, 1)); |
6748 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, | 6744 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, |
6749 child_empty->draw_transform().matrix().getDouble(0, 0)); | 6745 child_empty->draw_transform().matrix().get(0, 0)); |
6750 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, | 6746 EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale, |
6751 child_empty->draw_transform().matrix().getDouble(1, 1)); | 6747 child_empty->draw_transform().matrix().get(1, 1)); |
6752 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * | 6748 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * |
6753 initial_parent_scale * initial_child_scale, | 6749 initial_parent_scale * initial_child_scale, |
6754 child_no_scale->draw_transform().matrix().getDouble(0, 0)); | 6750 child_no_scale->draw_transform().matrix().get(0, 0)); |
6755 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * | 6751 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * |
6756 initial_parent_scale * initial_child_scale, | 6752 initial_parent_scale * initial_child_scale, |
6757 child_no_scale->draw_transform().matrix().getDouble(1, 1)); | 6753 child_no_scale->draw_transform().matrix().get(1, 1)); |
6758 } | 6754 } |
6759 | 6755 |
6760 TEST_F(LayerTreeHostCommonTest, SmallContentsScale) { | 6756 TEST_F(LayerTreeHostCommonTest, SmallContentsScale) { |
6761 MockContentLayerClient delegate; | 6757 MockContentLayerClient delegate; |
6762 gfx::Transform identity_matrix; | 6758 gfx::Transform identity_matrix; |
6763 | 6759 |
6764 gfx::Transform parent_scale_matrix; | 6760 gfx::Transform parent_scale_matrix; |
6765 double initial_parent_scale = 1.75; | 6761 SkMScalar initial_parent_scale = 1.75; |
6766 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 6762 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
6767 | 6763 |
6768 gfx::Transform child_scale_matrix; | 6764 gfx::Transform child_scale_matrix; |
6769 double initial_child_scale = 0.25; | 6765 SkMScalar initial_child_scale = 0.25; |
6770 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 6766 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
6771 | 6767 |
6772 scoped_refptr<Layer> root = Layer::Create(); | 6768 scoped_refptr<Layer> root = Layer::Create(); |
6773 root->SetBounds(gfx::Size(100, 100)); | 6769 root->SetBounds(gfx::Size(100, 100)); |
6774 | 6770 |
6775 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); | 6771 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); |
6776 SetLayerPropertiesForTesting(parent.get(), | 6772 SetLayerPropertiesForTesting(parent.get(), |
6777 parent_scale_matrix, | 6773 parent_scale_matrix, |
6778 identity_matrix, | 6774 identity_matrix, |
6779 gfx::PointF(), | 6775 gfx::PointF(), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6816 parent); | 6812 parent); |
6817 // The child's scale is < 1, so we should not save and use that scale | 6813 // The child's scale is < 1, so we should not save and use that scale |
6818 // factor. | 6814 // factor. |
6819 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * 1, | 6815 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * 1, |
6820 child_scale); | 6816 child_scale); |
6821 } | 6817 } |
6822 | 6818 |
6823 // When chilld's total scale becomes >= 1, we should save and use that scale | 6819 // When chilld's total scale becomes >= 1, we should save and use that scale |
6824 // factor. | 6820 // factor. |
6825 child_scale_matrix.MakeIdentity(); | 6821 child_scale_matrix.MakeIdentity(); |
6826 double final_child_scale = 0.75; | 6822 SkMScalar final_child_scale = 0.75; |
6827 child_scale_matrix.Scale(final_child_scale, final_child_scale); | 6823 child_scale_matrix.Scale(final_child_scale, final_child_scale); |
6828 child_scale->SetTransform(child_scale_matrix); | 6824 child_scale->SetTransform(child_scale_matrix); |
6829 | 6825 |
6830 { | 6826 { |
6831 RenderSurfaceLayerList render_surface_layer_list; | 6827 RenderSurfaceLayerList render_surface_layer_list; |
6832 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6828 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6833 root.get(), root->bounds(), &render_surface_layer_list); | 6829 root.get(), root->bounds(), &render_surface_layer_list); |
6834 inputs.device_scale_factor = device_scale_factor; | 6830 inputs.device_scale_factor = device_scale_factor; |
6835 inputs.page_scale_factor = page_scale_factor; | 6831 inputs.page_scale_factor = page_scale_factor; |
6836 inputs.page_scale_application_layer = root.get(); | 6832 inputs.page_scale_application_layer = root.get(); |
6837 inputs.can_adjust_raster_scales = true; | 6833 inputs.can_adjust_raster_scales = true; |
6838 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6834 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6839 | 6835 |
6840 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 6836 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
6841 initial_parent_scale, | 6837 initial_parent_scale, |
6842 parent); | 6838 parent); |
6843 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 6839 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
6844 initial_parent_scale * final_child_scale, | 6840 initial_parent_scale * final_child_scale, |
6845 child_scale); | 6841 child_scale); |
6846 } | 6842 } |
6847 } | 6843 } |
6848 | 6844 |
6849 TEST_F(LayerTreeHostCommonTest, ContentsScaleForSurfaces) { | 6845 TEST_F(LayerTreeHostCommonTest, ContentsScaleForSurfaces) { |
6850 MockContentLayerClient delegate; | 6846 MockContentLayerClient delegate; |
6851 gfx::Transform identity_matrix; | 6847 gfx::Transform identity_matrix; |
6852 | 6848 |
6853 gfx::Transform parent_scale_matrix; | 6849 gfx::Transform parent_scale_matrix; |
6854 double initial_parent_scale = 2.0; | 6850 SkMScalar initial_parent_scale = 2.0; |
6855 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 6851 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
6856 | 6852 |
6857 gfx::Transform child_scale_matrix; | 6853 gfx::Transform child_scale_matrix; |
6858 double initial_child_scale = 3.0; | 6854 SkMScalar initial_child_scale = 3.0; |
6859 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 6855 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
6860 | 6856 |
6861 scoped_refptr<Layer> root = Layer::Create(); | 6857 scoped_refptr<Layer> root = Layer::Create(); |
6862 root->SetBounds(gfx::Size(100, 100)); | 6858 root->SetBounds(gfx::Size(100, 100)); |
6863 | 6859 |
6864 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); | 6860 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); |
6865 SetLayerPropertiesForTesting(parent.get(), | 6861 SetLayerPropertiesForTesting(parent.get(), |
6866 parent_scale_matrix, | 6862 parent_scale_matrix, |
6867 identity_matrix, | 6863 identity_matrix, |
6868 gfx::PointF(), | 6864 gfx::PointF(), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6939 surface_scale->AddChild(surface_scale_child_scale); | 6935 surface_scale->AddChild(surface_scale_child_scale); |
6940 surface_scale->AddChild(surface_scale_child_no_scale); | 6936 surface_scale->AddChild(surface_scale_child_no_scale); |
6941 | 6937 |
6942 surface_no_scale->SetForceRenderSurface(true); | 6938 surface_no_scale->SetForceRenderSurface(true); |
6943 surface_no_scale->AddChild(surface_no_scale_child_scale); | 6939 surface_no_scale->AddChild(surface_no_scale_child_scale); |
6944 surface_no_scale->AddChild(surface_no_scale_child_no_scale); | 6940 surface_no_scale->AddChild(surface_no_scale_child_no_scale); |
6945 | 6941 |
6946 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 6942 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
6947 host->SetRootLayer(root); | 6943 host->SetRootLayer(root); |
6948 | 6944 |
6949 double device_scale_factor = 5; | 6945 SkMScalar device_scale_factor = 5; |
6950 double page_scale_factor = 7; | 6946 SkMScalar page_scale_factor = 7; |
6951 | 6947 |
6952 RenderSurfaceLayerList render_surface_layer_list; | 6948 RenderSurfaceLayerList render_surface_layer_list; |
6953 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 6949 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
6954 root.get(), root->bounds(), &render_surface_layer_list); | 6950 root.get(), root->bounds(), &render_surface_layer_list); |
6955 inputs.device_scale_factor = device_scale_factor; | 6951 inputs.device_scale_factor = device_scale_factor; |
6956 inputs.page_scale_factor = page_scale_factor; | 6952 inputs.page_scale_factor = page_scale_factor; |
6957 inputs.page_scale_application_layer = root.get(); | 6953 inputs.page_scale_application_layer = root.get(); |
6958 inputs.can_adjust_raster_scales = true; | 6954 inputs.can_adjust_raster_scales = true; |
6959 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 6955 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
6960 | 6956 |
6961 EXPECT_CONTENTS_SCALE_EQ( | 6957 EXPECT_CONTENTS_SCALE_EQ( |
6962 device_scale_factor * page_scale_factor * initial_parent_scale, parent); | 6958 device_scale_factor * page_scale_factor * initial_parent_scale, parent); |
6963 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * | 6959 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor * |
6964 initial_parent_scale * initial_child_scale, | 6960 initial_parent_scale * initial_child_scale, |
6965 surface_scale); | 6961 surface_scale); |
6966 EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale); | 6962 EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale); |
6967 EXPECT_CONTENTS_SCALE_EQ( | 6963 EXPECT_CONTENTS_SCALE_EQ( |
6968 device_scale_factor * page_scale_factor * initial_parent_scale * | 6964 device_scale_factor * page_scale_factor * initial_parent_scale * |
6969 initial_child_scale * initial_child_scale, | 6965 initial_child_scale * initial_child_scale, |
6970 surface_scale_child_scale); | 6966 surface_scale_child_scale); |
6971 EXPECT_CONTENTS_SCALE_EQ(1, surface_scale_child_no_scale); | 6967 EXPECT_CONTENTS_SCALE_EQ(1, surface_scale_child_no_scale); |
6972 EXPECT_CONTENTS_SCALE_EQ( | 6968 EXPECT_CONTENTS_SCALE_EQ( |
6973 device_scale_factor * page_scale_factor * initial_parent_scale * | 6969 device_scale_factor * page_scale_factor * initial_parent_scale * |
6974 initial_child_scale * initial_child_scale, | 6970 initial_child_scale * initial_child_scale, |
6975 surface_no_scale_child_scale); | 6971 surface_no_scale_child_scale); |
6976 EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale_child_no_scale); | 6972 EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale_child_no_scale); |
6977 | 6973 |
6978 // The parent is scaled up and shouldn't need to scale during draw. | 6974 // The parent is scaled up and shouldn't need to scale during draw. |
6979 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(0, 0)); | 6975 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(0, 0)); |
6980 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(1, 1)); | 6976 EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(1, 1)); |
6981 | 6977 |
6982 // RenderSurfaces should always be 1:1 with their target. | 6978 // RenderSurfaces should always be 1:1 with their target. |
6983 EXPECT_FLOAT_EQ( | 6979 EXPECT_FLOAT_EQ( |
6984 1.0, | 6980 1.0, |
6985 surface_scale->render_surface()->draw_transform().matrix().getDouble(0, | 6981 surface_scale->render_surface()->draw_transform().matrix().get(0, 0)); |
6986 0)); | |
6987 EXPECT_FLOAT_EQ( | 6982 EXPECT_FLOAT_EQ( |
6988 1.0, | 6983 1.0, |
6989 surface_scale->render_surface()->draw_transform().matrix().getDouble(1, | 6984 surface_scale->render_surface()->draw_transform().matrix().get(1, 1)); |
6990 1)); | |
6991 | 6985 |
6992 // The surface_scale can apply contents scale so the layer shouldn't need to | 6986 // The surface_scale can apply contents scale so the layer shouldn't need to |
6993 // scale during draw. | 6987 // scale during draw. |
6994 EXPECT_FLOAT_EQ(1.0, | 6988 EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(0, 0)); |
6995 surface_scale->draw_transform().matrix().getDouble(0, 0)); | 6989 EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(1, 1)); |
6996 EXPECT_FLOAT_EQ(1.0, | |
6997 surface_scale->draw_transform().matrix().getDouble(1, 1)); | |
6998 | 6990 |
6999 // The surface_scale_child_scale can apply contents scale so it shouldn't need | 6991 // The surface_scale_child_scale can apply contents scale so it shouldn't need |
7000 // to scale during draw. | 6992 // to scale during draw. |
7001 EXPECT_FLOAT_EQ( | 6993 EXPECT_FLOAT_EQ( |
7002 1.0, | 6994 1.0, surface_scale_child_scale->draw_transform().matrix().get(0, 0)); |
7003 surface_scale_child_scale->draw_transform().matrix().getDouble(0, 0)); | |
7004 EXPECT_FLOAT_EQ( | 6995 EXPECT_FLOAT_EQ( |
7005 1.0, | 6996 1.0, surface_scale_child_scale->draw_transform().matrix().get(1, 1)); |
7006 surface_scale_child_scale->draw_transform().matrix().getDouble(1, 1)); | |
7007 | 6997 |
7008 // The surface_scale_child_no_scale can not apply contents scale, so it needs | 6998 // The surface_scale_child_no_scale can not apply contents scale, so it needs |
7009 // to be scaled during draw. | 6999 // to be scaled during draw. |
7010 EXPECT_FLOAT_EQ( | 7000 EXPECT_FLOAT_EQ( |
7011 device_scale_factor * page_scale_factor * initial_parent_scale * | 7001 device_scale_factor * page_scale_factor * initial_parent_scale * |
7012 initial_child_scale * initial_child_scale, | 7002 initial_child_scale * initial_child_scale, |
7013 surface_scale_child_no_scale->draw_transform().matrix().getDouble(0, 0)); | 7003 surface_scale_child_no_scale->draw_transform().matrix().get(0, 0)); |
7014 EXPECT_FLOAT_EQ( | 7004 EXPECT_FLOAT_EQ( |
7015 device_scale_factor * page_scale_factor * initial_parent_scale * | 7005 device_scale_factor * page_scale_factor * initial_parent_scale * |
7016 initial_child_scale * initial_child_scale, | 7006 initial_child_scale * initial_child_scale, |
7017 surface_scale_child_no_scale->draw_transform().matrix().getDouble(1, 1)); | 7007 surface_scale_child_no_scale->draw_transform().matrix().get(1, 1)); |
7018 | 7008 |
7019 // RenderSurfaces should always be 1:1 with their target. | 7009 // RenderSurfaces should always be 1:1 with their target. |
7020 EXPECT_FLOAT_EQ( | 7010 EXPECT_FLOAT_EQ( |
7021 1.0, | 7011 1.0, |
7022 surface_no_scale->render_surface()->draw_transform().matrix().getDouble( | 7012 surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0)); |
7023 0, 0)); | |
7024 EXPECT_FLOAT_EQ( | 7013 EXPECT_FLOAT_EQ( |
7025 1.0, | 7014 1.0, |
7026 surface_no_scale->render_surface()->draw_transform().matrix().getDouble( | 7015 surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1)); |
7027 1, 1)); | |
7028 | 7016 |
7029 // The surface_no_scale layer can not apply contents scale, so it needs to be | 7017 // The surface_no_scale layer can not apply contents scale, so it needs to be |
7030 // scaled during draw. | 7018 // scaled during draw. |
7031 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * | 7019 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * |
7032 initial_parent_scale * initial_child_scale, | 7020 initial_parent_scale * initial_child_scale, |
7033 surface_no_scale->draw_transform().matrix().getDouble(0, 0)); | 7021 surface_no_scale->draw_transform().matrix().get(0, 0)); |
7034 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * | 7022 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor * |
7035 initial_parent_scale * initial_child_scale, | 7023 initial_parent_scale * initial_child_scale, |
7036 surface_no_scale->draw_transform().matrix().getDouble(1, 1)); | 7024 surface_no_scale->draw_transform().matrix().get(1, 1)); |
7037 | 7025 |
7038 // The surface_scale_child_scale can apply contents scale so it shouldn't need | 7026 // The surface_scale_child_scale can apply contents scale so it shouldn't need |
7039 // to scale during draw. | 7027 // to scale during draw. |
7040 EXPECT_FLOAT_EQ( | 7028 EXPECT_FLOAT_EQ( |
7041 1.0, | 7029 1.0, surface_no_scale_child_scale->draw_transform().matrix().get(0, 0)); |
7042 surface_no_scale_child_scale->draw_transform().matrix().getDouble(0, 0)); | |
7043 EXPECT_FLOAT_EQ( | 7030 EXPECT_FLOAT_EQ( |
7044 1.0, | 7031 1.0, surface_no_scale_child_scale->draw_transform().matrix().get(1, 1)); |
7045 surface_no_scale_child_scale->draw_transform().matrix().getDouble(1, 1)); | |
7046 | 7032 |
7047 // The surface_scale_child_no_scale can not apply contents scale, so it needs | 7033 // The surface_scale_child_no_scale can not apply contents scale, so it needs |
7048 // to be scaled during draw. | 7034 // to be scaled during draw. |
7049 EXPECT_FLOAT_EQ( | 7035 EXPECT_FLOAT_EQ( |
7050 device_scale_factor * page_scale_factor * initial_parent_scale * | 7036 device_scale_factor * page_scale_factor * initial_parent_scale * |
7051 initial_child_scale * initial_child_scale, | 7037 initial_child_scale * initial_child_scale, |
7052 surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(0, | 7038 surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0)); |
7053 0)); | |
7054 EXPECT_FLOAT_EQ( | 7039 EXPECT_FLOAT_EQ( |
7055 device_scale_factor * page_scale_factor * initial_parent_scale * | 7040 device_scale_factor * page_scale_factor * initial_parent_scale * |
7056 initial_child_scale * initial_child_scale, | 7041 initial_child_scale * initial_child_scale, |
7057 surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(1, | 7042 surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1)); |
7058 1)); | |
7059 } | 7043 } |
7060 | 7044 |
7061 TEST_F(LayerTreeHostCommonTest, | 7045 TEST_F(LayerTreeHostCommonTest, |
7062 ContentsScaleForSurfaces_LayerTransformsDontAffectContentsScale) { | 7046 ContentsScaleForSurfaces_LayerTransformsDontAffectContentsScale) { |
7063 MockContentLayerClient delegate; | 7047 MockContentLayerClient delegate; |
7064 gfx::Transform identity_matrix; | 7048 gfx::Transform identity_matrix; |
7065 | 7049 |
7066 gfx::Transform parent_scale_matrix; | 7050 gfx::Transform parent_scale_matrix; |
7067 double initial_parent_scale = 2.0; | 7051 SkMScalar initial_parent_scale = 2.0; |
7068 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 7052 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
7069 | 7053 |
7070 gfx::Transform child_scale_matrix; | 7054 gfx::Transform child_scale_matrix; |
7071 double initial_child_scale = 3.0; | 7055 SkMScalar initial_child_scale = 3.0; |
7072 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 7056 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
7073 | 7057 |
7074 scoped_refptr<Layer> root = Layer::Create(); | 7058 scoped_refptr<Layer> root = Layer::Create(); |
7075 root->SetBounds(gfx::Size(100, 100)); | 7059 root->SetBounds(gfx::Size(100, 100)); |
7076 | 7060 |
7077 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); | 7061 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); |
7078 SetLayerPropertiesForTesting(parent.get(), | 7062 SetLayerPropertiesForTesting(parent.get(), |
7079 parent_scale_matrix, | 7063 parent_scale_matrix, |
7080 identity_matrix, | 7064 identity_matrix, |
7081 gfx::PointF(), | 7065 gfx::PointF(), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7154 | 7138 |
7155 surface_no_scale->SetForceRenderSurface(true); | 7139 surface_no_scale->SetForceRenderSurface(true); |
7156 surface_no_scale->AddChild(surface_no_scale_child_scale); | 7140 surface_no_scale->AddChild(surface_no_scale_child_scale); |
7157 surface_no_scale->AddChild(surface_no_scale_child_no_scale); | 7141 surface_no_scale->AddChild(surface_no_scale_child_no_scale); |
7158 | 7142 |
7159 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 7143 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
7160 host->SetRootLayer(root); | 7144 host->SetRootLayer(root); |
7161 | 7145 |
7162 RenderSurfaceLayerList render_surface_layer_list; | 7146 RenderSurfaceLayerList render_surface_layer_list; |
7163 | 7147 |
7164 double device_scale_factor = 5.0; | 7148 SkMScalar device_scale_factor = 5.0; |
7165 double page_scale_factor = 7.0; | 7149 SkMScalar page_scale_factor = 7.0; |
7166 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 7150 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
7167 root.get(), root->bounds(), &render_surface_layer_list); | 7151 root.get(), root->bounds(), &render_surface_layer_list); |
7168 inputs.device_scale_factor = device_scale_factor; | 7152 inputs.device_scale_factor = device_scale_factor; |
7169 inputs.page_scale_factor = page_scale_factor; | 7153 inputs.page_scale_factor = page_scale_factor; |
7170 inputs.page_scale_application_layer = root.get(); | 7154 inputs.page_scale_application_layer = root.get(); |
7171 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7155 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7172 | 7156 |
7173 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 7157 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
7174 parent); | 7158 parent); |
7175 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 7159 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
7176 surface_scale); | 7160 surface_scale); |
7177 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale); | 7161 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale); |
7178 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 7162 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
7179 surface_scale_child_scale); | 7163 surface_scale_child_scale); |
7180 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_scale_child_no_scale); | 7164 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_scale_child_no_scale); |
7181 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, | 7165 EXPECT_CONTENTS_SCALE_EQ(device_scale_factor * page_scale_factor, |
7182 surface_no_scale_child_scale); | 7166 surface_no_scale_child_scale); |
7183 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale_child_no_scale); | 7167 EXPECT_CONTENTS_SCALE_EQ(1.f, surface_no_scale_child_no_scale); |
7184 | 7168 |
7185 // The parent is scaled up during draw, since its contents are not scaled by | 7169 // The parent is scaled up during draw, since its contents are not scaled by |
7186 // the transform hierarchy. | 7170 // the transform hierarchy. |
7187 EXPECT_FLOAT_EQ(initial_parent_scale, | 7171 EXPECT_FLOAT_EQ(initial_parent_scale, |
7188 parent->draw_transform().matrix().getDouble(0, 0)); | 7172 parent->draw_transform().matrix().get(0, 0)); |
7189 EXPECT_FLOAT_EQ(initial_parent_scale, | 7173 EXPECT_FLOAT_EQ(initial_parent_scale, |
7190 parent->draw_transform().matrix().getDouble(1, 1)); | 7174 parent->draw_transform().matrix().get(1, 1)); |
7191 | 7175 |
7192 // The child surface is scaled up during draw since its subtree is not scaled | 7176 // The child surface is scaled up during draw since its subtree is not scaled |
7193 // by the transform hierarchy. | 7177 // by the transform hierarchy. |
7194 EXPECT_FLOAT_EQ( | 7178 EXPECT_FLOAT_EQ( |
7195 initial_parent_scale * initial_child_scale, | 7179 initial_parent_scale * initial_child_scale, |
7196 surface_scale->render_surface()->draw_transform().matrix().getDouble(0, | 7180 surface_scale->render_surface()->draw_transform().matrix().get(0, 0)); |
7197 0)); | |
7198 EXPECT_FLOAT_EQ( | 7181 EXPECT_FLOAT_EQ( |
7199 initial_parent_scale * initial_child_scale, | 7182 initial_parent_scale * initial_child_scale, |
7200 surface_scale->render_surface()->draw_transform().matrix().getDouble(1, | 7183 surface_scale->render_surface()->draw_transform().matrix().get(1, 1)); |
7201 1)); | |
7202 | 7184 |
7203 // The surface_scale's RenderSurface is scaled during draw, so the layer does | 7185 // The surface_scale's RenderSurface is scaled during draw, so the layer does |
7204 // not need to be scaled when drawing into its surface. | 7186 // not need to be scaled when drawing into its surface. |
7205 EXPECT_FLOAT_EQ(1.0, | 7187 EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(0, 0)); |
7206 surface_scale->draw_transform().matrix().getDouble(0, 0)); | 7188 EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(1, 1)); |
7207 EXPECT_FLOAT_EQ(1.0, | |
7208 surface_scale->draw_transform().matrix().getDouble(1, 1)); | |
7209 | 7189 |
7210 // The surface_scale_child_scale is scaled when drawing into its surface, | 7190 // The surface_scale_child_scale is scaled when drawing into its surface, |
7211 // since its content bounds are not scaled by the transform hierarchy. | 7191 // since its content bounds are not scaled by the transform hierarchy. |
7212 EXPECT_FLOAT_EQ( | 7192 EXPECT_FLOAT_EQ( |
7213 initial_child_scale, | 7193 initial_child_scale, |
7214 surface_scale_child_scale->draw_transform().matrix().getDouble(0, 0)); | 7194 surface_scale_child_scale->draw_transform().matrix().get(0, 0)); |
7215 EXPECT_FLOAT_EQ( | 7195 EXPECT_FLOAT_EQ( |
7216 initial_child_scale, | 7196 initial_child_scale, |
7217 surface_scale_child_scale->draw_transform().matrix().getDouble(1, 1)); | 7197 surface_scale_child_scale->draw_transform().matrix().get(1, 1)); |
7218 | 7198 |
7219 // The surface_scale_child_no_scale has a fixed contents scale of 1, so it | 7199 // The surface_scale_child_no_scale has a fixed contents scale of 1, so it |
7220 // needs to be scaled by the device and page scale factors, along with the | 7200 // needs to be scaled by the device and page scale factors, along with the |
7221 // transform hierarchy. | 7201 // transform hierarchy. |
7222 EXPECT_FLOAT_EQ( | 7202 EXPECT_FLOAT_EQ( |
7223 device_scale_factor * page_scale_factor * initial_child_scale, | 7203 device_scale_factor * page_scale_factor * initial_child_scale, |
7224 surface_scale_child_no_scale->draw_transform().matrix().getDouble(0, 0)); | 7204 surface_scale_child_no_scale->draw_transform().matrix().get(0, 0)); |
7225 EXPECT_FLOAT_EQ( | 7205 EXPECT_FLOAT_EQ( |
7226 device_scale_factor * page_scale_factor * initial_child_scale, | 7206 device_scale_factor * page_scale_factor * initial_child_scale, |
7227 surface_scale_child_no_scale->draw_transform().matrix().getDouble(1, 1)); | 7207 surface_scale_child_no_scale->draw_transform().matrix().get(1, 1)); |
7228 | 7208 |
7229 // The child surface is scaled up during draw since its subtree is not scaled | 7209 // The child surface is scaled up during draw since its subtree is not scaled |
7230 // by the transform hierarchy. | 7210 // by the transform hierarchy. |
7231 EXPECT_FLOAT_EQ( | 7211 EXPECT_FLOAT_EQ( |
7232 initial_parent_scale * initial_child_scale, | 7212 initial_parent_scale * initial_child_scale, |
7233 surface_no_scale->render_surface()->draw_transform().matrix().getDouble( | 7213 surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0)); |
7234 0, 0)); | |
7235 EXPECT_FLOAT_EQ( | 7214 EXPECT_FLOAT_EQ( |
7236 initial_parent_scale * initial_child_scale, | 7215 initial_parent_scale * initial_child_scale, |
7237 surface_no_scale->render_surface()->draw_transform().matrix().getDouble( | 7216 surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1)); |
7238 1, 1)); | |
7239 | 7217 |
7240 // The surface_no_scale layer has a fixed contents scale of 1, so it needs to | 7218 // The surface_no_scale layer has a fixed contents scale of 1, so it needs to |
7241 // be scaled by the device and page scale factors. Its surface is already | 7219 // be scaled by the device and page scale factors. Its surface is already |
7242 // scaled by the transform hierarchy so those don't need to scale the layer's | 7220 // scaled by the transform hierarchy so those don't need to scale the layer's |
7243 // drawing. | 7221 // drawing. |
7244 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor, | 7222 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor, |
7245 surface_no_scale->draw_transform().matrix().getDouble(0, 0)); | 7223 surface_no_scale->draw_transform().matrix().get(0, 0)); |
7246 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor, | 7224 EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor, |
7247 surface_no_scale->draw_transform().matrix().getDouble(1, 1)); | 7225 surface_no_scale->draw_transform().matrix().get(1, 1)); |
7248 | 7226 |
7249 // The surface_no_scale_child_scale has its contents scaled by the page and | 7227 // The surface_no_scale_child_scale has its contents scaled by the page and |
7250 // device scale factors, but needs to be scaled by the transform hierarchy | 7228 // device scale factors, but needs to be scaled by the transform hierarchy |
7251 // when drawing. | 7229 // when drawing. |
7252 EXPECT_FLOAT_EQ( | 7230 EXPECT_FLOAT_EQ( |
7253 initial_child_scale, | 7231 initial_child_scale, |
7254 surface_no_scale_child_scale->draw_transform().matrix().getDouble(0, 0)); | 7232 surface_no_scale_child_scale->draw_transform().matrix().get(0, 0)); |
7255 EXPECT_FLOAT_EQ( | 7233 EXPECT_FLOAT_EQ( |
7256 initial_child_scale, | 7234 initial_child_scale, |
7257 surface_no_scale_child_scale->draw_transform().matrix().getDouble(1, 1)); | 7235 surface_no_scale_child_scale->draw_transform().matrix().get(1, 1)); |
7258 | 7236 |
7259 // The surface_no_scale_child_no_scale has a fixed contents scale of 1, so it | 7237 // The surface_no_scale_child_no_scale has a fixed contents scale of 1, so it |
7260 // needs to be scaled by the device and page scale factors. It also needs to | 7238 // needs to be scaled by the device and page scale factors. It also needs to |
7261 // be scaled by any transform heirarchy below its target surface. | 7239 // be scaled by any transform heirarchy below its target surface. |
7262 EXPECT_FLOAT_EQ( | 7240 EXPECT_FLOAT_EQ( |
7263 device_scale_factor * page_scale_factor * initial_child_scale, | 7241 device_scale_factor * page_scale_factor * initial_child_scale, |
7264 surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(0, | 7242 surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0)); |
7265 0)); | |
7266 EXPECT_FLOAT_EQ( | 7243 EXPECT_FLOAT_EQ( |
7267 device_scale_factor * page_scale_factor * initial_child_scale, | 7244 device_scale_factor * page_scale_factor * initial_child_scale, |
7268 surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(1, | 7245 surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1)); |
7269 1)); | |
7270 } | 7246 } |
7271 | 7247 |
7272 TEST_F(LayerTreeHostCommonTest, ContentsScaleForAnimatingLayer) { | 7248 TEST_F(LayerTreeHostCommonTest, ContentsScaleForAnimatingLayer) { |
7273 MockContentLayerClient delegate; | 7249 MockContentLayerClient delegate; |
7274 gfx::Transform identity_matrix; | 7250 gfx::Transform identity_matrix; |
7275 | 7251 |
7276 gfx::Transform parent_scale_matrix; | 7252 gfx::Transform parent_scale_matrix; |
7277 double initial_parent_scale = 1.75; | 7253 SkMScalar initial_parent_scale = 1.75; |
7278 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); | 7254 parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale); |
7279 | 7255 |
7280 gfx::Transform child_scale_matrix; | 7256 gfx::Transform child_scale_matrix; |
7281 double initial_child_scale = 1.25; | 7257 SkMScalar initial_child_scale = 1.25; |
7282 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 7258 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
7283 | 7259 |
7284 scoped_refptr<Layer> root = Layer::Create(); | 7260 scoped_refptr<Layer> root = Layer::Create(); |
7285 root->SetBounds(gfx::Size(100, 100)); | 7261 root->SetBounds(gfx::Size(100, 100)); |
7286 | 7262 |
7287 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); | 7263 scoped_refptr<ContentLayer> parent = CreateDrawableContentLayer(&delegate); |
7288 SetLayerPropertiesForTesting(parent.get(), | 7264 SetLayerPropertiesForTesting(parent.get(), |
7289 parent_scale_matrix, | 7265 parent_scale_matrix, |
7290 identity_matrix, | 7266 identity_matrix, |
7291 gfx::PointF(), | 7267 gfx::PointF(), |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7453 child->render_surface()->draw_transform()); | 7429 child->render_surface()->draw_transform()); |
7454 | 7430 |
7455 gfx::Transform expected_surface_screen_space_transform; | 7431 gfx::Transform expected_surface_screen_space_transform; |
7456 expected_surface_screen_space_transform.Translate(device_scale_factor * 2.f, | 7432 expected_surface_screen_space_transform.Translate(device_scale_factor * 2.f, |
7457 device_scale_factor * 2.f); | 7433 device_scale_factor * 2.f); |
7458 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7434 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7459 expected_surface_screen_space_transform, | 7435 expected_surface_screen_space_transform, |
7460 child->render_surface()->screen_space_transform()); | 7436 child->render_surface()->screen_space_transform()); |
7461 | 7437 |
7462 gfx::Transform expected_replica_draw_transform; | 7438 gfx::Transform expected_replica_draw_transform; |
7463 expected_replica_draw_transform.matrix().setDouble(1, 1, -1.0); | 7439 expected_replica_draw_transform.matrix().set(1, 1, -1.0); |
7464 expected_replica_draw_transform.matrix().setDouble(0, 3, 6.0); | 7440 expected_replica_draw_transform.matrix().set(0, 3, 6.0); |
7465 expected_replica_draw_transform.matrix().setDouble(1, 3, 6.0); | 7441 expected_replica_draw_transform.matrix().set(1, 3, 6.0); |
7466 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7442 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7467 expected_replica_draw_transform, | 7443 expected_replica_draw_transform, |
7468 child->render_surface()->replica_draw_transform()); | 7444 child->render_surface()->replica_draw_transform()); |
7469 | 7445 |
7470 gfx::Transform expected_replica_screen_space_transform; | 7446 gfx::Transform expected_replica_screen_space_transform; |
7471 expected_replica_screen_space_transform.matrix().setDouble(1, 1, -1.0); | 7447 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); |
7472 expected_replica_screen_space_transform.matrix().setDouble(0, 3, 6.0); | 7448 expected_replica_screen_space_transform.matrix().set(0, 3, 6.0); |
7473 expected_replica_screen_space_transform.matrix().setDouble(1, 3, 6.0); | 7449 expected_replica_screen_space_transform.matrix().set(1, 3, 6.0); |
7474 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7450 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7475 expected_replica_screen_space_transform, | 7451 expected_replica_screen_space_transform, |
7476 child->render_surface()->replica_screen_space_transform()); | 7452 child->render_surface()->replica_screen_space_transform()); |
7477 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7453 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7478 expected_replica_screen_space_transform, | 7454 expected_replica_screen_space_transform, |
7479 child->render_surface()->replica_screen_space_transform()); | 7455 child->render_surface()->replica_screen_space_transform()); |
7480 } | 7456 } |
7481 | 7457 |
7482 TEST_F(LayerTreeHostCommonTest, | 7458 TEST_F(LayerTreeHostCommonTest, |
7483 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { | 7459 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7563 duplicate_child_non_owner->content_bounds()); | 7539 duplicate_child_non_owner->content_bounds()); |
7564 | 7540 |
7565 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_transform, | 7541 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_transform, |
7566 child->render_surface()->draw_transform()); | 7542 child->render_surface()->draw_transform()); |
7567 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_transform, | 7543 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_transform, |
7568 child->render_surface()->draw_transform()); | 7544 child->render_surface()->draw_transform()); |
7569 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7545 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7570 identity_transform, child->render_surface()->screen_space_transform()); | 7546 identity_transform, child->render_surface()->screen_space_transform()); |
7571 | 7547 |
7572 gfx::Transform expected_replica_draw_transform; | 7548 gfx::Transform expected_replica_draw_transform; |
7573 expected_replica_draw_transform.matrix().setDouble(1, 1, -1.0); | 7549 expected_replica_draw_transform.matrix().set(1, 1, -1.0); |
7574 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7550 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7575 expected_replica_draw_transform, | 7551 expected_replica_draw_transform, |
7576 child->render_surface()->replica_draw_transform()); | 7552 child->render_surface()->replica_draw_transform()); |
7577 | 7553 |
7578 gfx::Transform expected_replica_screen_space_transform; | 7554 gfx::Transform expected_replica_screen_space_transform; |
7579 expected_replica_screen_space_transform.matrix().setDouble(1, 1, -1.0); | 7555 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); |
7580 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7556 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7581 expected_replica_screen_space_transform, | 7557 expected_replica_screen_space_transform, |
7582 child->render_surface()->replica_screen_space_transform()); | 7558 child->render_surface()->replica_screen_space_transform()); |
7583 } | 7559 } |
7584 | 7560 |
7585 TEST_F(LayerTreeHostCommonTest, SubtreeSearch) { | 7561 TEST_F(LayerTreeHostCommonTest, SubtreeSearch) { |
7586 scoped_refptr<Layer> root = Layer::Create(); | 7562 scoped_refptr<Layer> root = Layer::Create(); |
7587 scoped_refptr<Layer> child = Layer::Create(); | 7563 scoped_refptr<Layer> child = Layer::Create(); |
7588 scoped_refptr<Layer> grand_child = Layer::Create(); | 7564 scoped_refptr<Layer> grand_child = Layer::Create(); |
7589 scoped_refptr<Layer> mask_layer = Layer::Create(); | 7565 scoped_refptr<Layer> mask_layer = Layer::Create(); |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8967 ExecuteCalculateDrawProperties(root.get()); | 8943 ExecuteCalculateDrawProperties(root.get()); |
8968 | 8944 |
8969 EXPECT_EQ(1u, render_surface_layer_list()->size()); | 8945 EXPECT_EQ(1u, render_surface_layer_list()->size()); |
8970 EXPECT_EQ(0u, | 8946 EXPECT_EQ(0u, |
8971 render_surface_layer_list()->at(0) | 8947 render_surface_layer_list()->at(0) |
8972 ->render_surface()->layer_list().size()); | 8948 ->render_surface()->layer_list().size()); |
8973 } | 8949 } |
8974 | 8950 |
8975 } // namespace | 8951 } // namespace |
8976 } // namespace cc | 8952 } // namespace cc |
OLD | NEW |