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/base/thread.h" | 9 #include "cc/base/thread.h" |
10 #include "cc/layers/content_layer.h" | 10 #include "cc/layers/content_layer.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 void executeCalculateDrawProperties(Layer* rootLayer, float deviceScaleFactor =
1, float pageScaleFactor = 1, bool canUseLCDText = false) | 54 void executeCalculateDrawProperties(Layer* rootLayer, float deviceScaleFactor =
1, float pageScaleFactor = 1, bool canUseLCDText = false) |
55 { | 55 { |
56 gfx::Transform identityMatrix; | 56 gfx::Transform identityMatrix; |
57 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; | 57 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; |
58 int dummyMaxTextureSize = 512; | 58 int dummyMaxTextureSize = 512; |
59 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 59 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
60 | 60 |
61 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 61 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
62 DCHECK(!rootLayer->bounds().IsEmpty()); | 62 DCHECK(!rootLayer->bounds().IsEmpty()); |
63 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList); | 63 LayerTreeHostCommon::CalculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, &dummyRe
nderSurfaceLayerList); |
64 } | 64 } |
65 | 65 |
66 void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFacto
r = 1, float pageScaleFactor = 1, bool canUseLCDText = false) | 66 void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFacto
r = 1, float pageScaleFactor = 1, bool canUseLCDText = false) |
67 { | 67 { |
68 gfx::Transform identityMatrix; | 68 gfx::Transform identityMatrix; |
69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; | 69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; |
70 int dummyMaxTextureSize = 512; | 70 int dummyMaxTextureSize = 512; |
71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
72 | 72 |
73 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 73 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
74 DCHECK(!rootLayer->bounds().IsEmpty()); | 74 DCHECK(!rootLayer->bounds().IsEmpty()); |
75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList, false); | 75 LayerTreeHostCommon::CalculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, &dummyRe
nderSurfaceLayerList, false); |
76 } | 76 } |
77 | 77 |
78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp
l) | 78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp
l) |
79 { | 79 { |
80 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl->active_tree(), 1); | 80 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl->active_tree(), 1); |
81 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl->active_tree(), 2); | 81 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl->active_tree(), 2); |
82 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl->active_tree()
, 3); | 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl->active_tree()
, 3); |
83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::Create(hostImpl->active_t
ree(), 4); | 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::Create(hostImpl->active_t
ree(), 4); |
84 | 84 |
85 gfx::Transform IdentityMatrix; | 85 gfx::Transform IdentityMatrix; |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 883 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
884 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); | 884 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); |
885 | 885 |
886 parent->AddChild(renderSurface1); | 886 parent->AddChild(renderSurface1); |
887 parent->SetMasksToBounds(true); | 887 parent->SetMasksToBounds(true); |
888 renderSurface1->AddChild(child); | 888 renderSurface1->AddChild(child); |
889 renderSurface1->SetForceRenderSurface(true); | 889 renderSurface1->SetForceRenderSurface(true); |
890 | 890 |
891 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 891 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
892 int dummyMaxTextureSize = 512; | 892 int dummyMaxTextureSize = 512; |
893 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 893 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
894 | 894 |
895 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate | 895 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate |
896 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible | 896 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible |
897 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). | 897 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). |
898 ASSERT_TRUE(parent->render_surface()); | 898 ASSERT_TRUE(parent->render_surface()); |
899 ASSERT_FALSE(renderSurface1->render_surface()); | 899 ASSERT_FALSE(renderSurface1->render_surface()); |
900 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 900 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
901 } | 901 } |
902 | 902 |
903 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 903 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
904 { | 904 { |
905 scoped_refptr<Layer> parent = Layer::Create(); | 905 scoped_refptr<Layer> parent = Layer::Create(); |
906 scoped_refptr<Layer> renderSurface1 = Layer::Create(); | 906 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
907 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 907 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
908 | 908 |
909 const gfx::Transform identityMatrix; | 909 const gfx::Transform identityMatrix; |
910 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 910 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
911 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 911 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
912 | 912 |
913 parent->AddChild(renderSurface1); | 913 parent->AddChild(renderSurface1); |
914 renderSurface1->AddChild(child); | 914 renderSurface1->AddChild(child); |
915 renderSurface1->SetForceRenderSurface(true); | 915 renderSurface1->SetForceRenderSurface(true); |
916 renderSurface1->SetOpacity(0); | 916 renderSurface1->SetOpacity(0); |
917 | 917 |
918 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 918 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
919 int dummyMaxTextureSize = 512; | 919 int dummyMaxTextureSize = 512; |
920 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 920 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
921 | 921 |
922 // Since the layer is transparent, renderSurface1->render_surface() should n
ot have gotten added anywhere. | 922 // Since the layer is transparent, renderSurface1->render_surface() should n
ot have gotten added anywhere. |
923 // Also, the drawable content rect should not have been extended by the chil
dren. | 923 // Also, the drawable content rect should not have been extended by the chil
dren. |
924 ASSERT_TRUE(parent->render_surface()); | 924 ASSERT_TRUE(parent->render_surface()); |
925 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); | 925 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); |
926 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 926 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
927 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 927 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
928 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); | 928 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); |
929 } | 929 } |
930 | 930 |
(...skipping 11 matching lines...) Expand all Loading... |
942 | 942 |
943 parent->AddChild(renderSurface1); | 943 parent->AddChild(renderSurface1); |
944 renderSurface1->AddChild(child); | 944 renderSurface1->AddChild(child); |
945 | 945 |
946 // Sanity check before the actual test | 946 // Sanity check before the actual test |
947 EXPECT_FALSE(parent->render_surface()); | 947 EXPECT_FALSE(parent->render_surface()); |
948 EXPECT_FALSE(renderSurface1->render_surface()); | 948 EXPECT_FALSE(renderSurface1->render_surface()); |
949 | 949 |
950 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 950 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
951 int dummyMaxTextureSize = 512; | 951 int dummyMaxTextureSize = 512; |
952 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 952 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
953 | 953 |
954 // The root layer always creates a renderSurface | 954 // The root layer always creates a renderSurface |
955 EXPECT_TRUE(parent->render_surface()); | 955 EXPECT_TRUE(parent->render_surface()); |
956 EXPECT_TRUE(renderSurface1->render_surface()); | 956 EXPECT_TRUE(renderSurface1->render_surface()); |
957 EXPECT_EQ(2U, renderSurfaceLayerList.size()); | 957 EXPECT_EQ(2U, renderSurfaceLayerList.size()); |
958 | 958 |
959 renderSurfaceLayerList.clear(); | 959 renderSurfaceLayerList.clear(); |
960 renderSurface1->SetForceRenderSurface(false); | 960 renderSurface1->SetForceRenderSurface(false); |
961 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 961 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
962 EXPECT_TRUE(parent->render_surface()); | 962 EXPECT_TRUE(parent->render_surface()); |
963 EXPECT_FALSE(renderSurface1->render_surface()); | 963 EXPECT_FALSE(renderSurface1->render_surface()); |
964 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 964 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
965 } | 965 } |
966 | 966 |
967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
irectContainer) | 967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
irectContainer) |
968 { | 968 { |
969 // This test checks for correct scroll compensation when the fixed-position
container | 969 // This test checks for correct scroll compensation when the fixed-position
container |
970 // is the direct parent of the fixed-position layer. | 970 // is the direct parent of the fixed-position layer. |
971 FakeImplProxy proxy; | 971 FakeImplProxy proxy; |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1566 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
1567 | 1567 |
1568 child->SetMasksToBounds(true); | 1568 child->SetMasksToBounds(true); |
1569 child->SetOpacity(0.4f); | 1569 child->SetOpacity(0.4f); |
1570 child->SetForceRenderSurface(true); | 1570 child->SetForceRenderSurface(true); |
1571 grandChild->SetOpacity(0.5); | 1571 grandChild->SetOpacity(0.5); |
1572 greatGrandChild->SetOpacity(0.4f); | 1572 greatGrandChild->SetOpacity(0.4f); |
1573 | 1573 |
1574 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1574 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1575 int dummyMaxTextureSize = 512; | 1575 int dummyMaxTextureSize = 512; |
1576 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1576 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1577 | 1577 |
1578 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1578 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
1579 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1579 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1580 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1580 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1581 } | 1581 } |
1582 | 1582 |
1583 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) | 1583 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) |
1584 { | 1584 { |
1585 // When a renderSurface has a clipRect, it is used to clip the contentRect | 1585 // When a renderSurface has a clipRect, it is used to clip the contentRect |
1586 // of the surface. When the renderSurface is animating its transforms, then | 1586 // of the surface. When the renderSurface is animating its transforms, then |
(...skipping 26 matching lines...) Expand all Loading... |
1613 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1613 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
1614 | 1614 |
1615 parent->SetMasksToBounds(true); | 1615 parent->SetMasksToBounds(true); |
1616 child->SetOpacity(0.4f); | 1616 child->SetOpacity(0.4f); |
1617 child->SetForceRenderSurface(true); | 1617 child->SetForceRenderSurface(true); |
1618 grandChild->SetOpacity(0.4f); | 1618 grandChild->SetOpacity(0.4f); |
1619 grandChild->SetForceRenderSurface(true); | 1619 grandChild->SetForceRenderSurface(true); |
1620 | 1620 |
1621 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1621 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1622 int dummyMaxTextureSize = 512; | 1622 int dummyMaxTextureSize = 512; |
1623 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1623 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1624 | 1624 |
1625 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1625 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
1626 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1626 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1627 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1627 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1628 | 1628 |
1629 // Now put an animating transform on child. | 1629 // Now put an animating transform on child. |
1630 addAnimatedTransformToController(*child->layer_animation_controller(), 10, 3
0, 0); | 1630 addAnimatedTransformToController(*child->layer_animation_controller(), 10, 3
0, 0); |
1631 | 1631 |
1632 parent->ClearRenderSurface(); | 1632 parent->ClearRenderSurface(); |
1633 child->ClearRenderSurface(); | 1633 child->ClearRenderSurface(); |
1634 grandChild->ClearRenderSurface(); | 1634 grandChild->ClearRenderSurface(); |
1635 renderSurfaceLayerList.clear(); | 1635 renderSurfaceLayerList.clear(); |
1636 | 1636 |
1637 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1637 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1638 | 1638 |
1639 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. | 1639 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. |
1640 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1640 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
1641 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1641 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1642 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1642 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1643 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); | 1643 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); |
1644 } | 1644 } |
1645 | 1645 |
1646 TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) | 1646 TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) |
1647 { | 1647 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1679 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1680 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1680 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1681 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1681 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1682 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1682 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1683 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1683 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1684 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1684 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1685 | 1685 |
1686 // Case 1: nothing is clipped except the root renderSurface. | 1686 // Case 1: nothing is clipped except the root renderSurface. |
1687 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1687 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1688 int dummyMaxTextureSize = 512; | 1688 int dummyMaxTextureSize = 512; |
1689 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1689 LayerTreeHostCommon::CalculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1690 | 1690 |
1691 ASSERT_TRUE(root->render_surface()); | 1691 ASSERT_TRUE(root->render_surface()); |
1692 ASSERT_TRUE(child2->render_surface()); | 1692 ASSERT_TRUE(child2->render_surface()); |
1693 | 1693 |
1694 EXPECT_FALSE(root->is_clipped()); | 1694 EXPECT_FALSE(root->is_clipped()); |
1695 EXPECT_TRUE(root->render_surface()->is_clipped()); | 1695 EXPECT_TRUE(root->render_surface()->is_clipped()); |
1696 EXPECT_FALSE(parent->is_clipped()); | 1696 EXPECT_FALSE(parent->is_clipped()); |
1697 EXPECT_FALSE(child1->is_clipped()); | 1697 EXPECT_FALSE(child1->is_clipped()); |
1698 EXPECT_FALSE(child2->is_clipped()); | 1698 EXPECT_FALSE(child2->is_clipped()); |
1699 EXPECT_FALSE(child2->render_surface()->is_clipped()); | 1699 EXPECT_FALSE(child2->render_surface()->is_clipped()); |
1700 EXPECT_FALSE(grandChild->is_clipped()); | 1700 EXPECT_FALSE(grandChild->is_clipped()); |
1701 EXPECT_FALSE(leafNode1->is_clipped()); | 1701 EXPECT_FALSE(leafNode1->is_clipped()); |
1702 EXPECT_FALSE(leafNode2->is_clipped()); | 1702 EXPECT_FALSE(leafNode2->is_clipped()); |
1703 | 1703 |
1704 // Case 2: parent masksToBounds, so the parent, child1, and child2's | 1704 // Case 2: parent masksToBounds, so the parent, child1, and child2's |
1705 // surface are clipped. But layers that contribute to child2's surface are | 1705 // surface are clipped. But layers that contribute to child2's surface are |
1706 // not clipped explicitly because child2's surface already accounts for | 1706 // not clipped explicitly because child2's surface already accounts for |
1707 // that clip. | 1707 // that clip. |
1708 renderSurfaceLayerList.clear(); | 1708 renderSurfaceLayerList.clear(); |
1709 parent->SetMasksToBounds(true); | 1709 parent->SetMasksToBounds(true); |
1710 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1710 LayerTreeHostCommon::CalculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1711 | 1711 |
1712 ASSERT_TRUE(root->render_surface()); | 1712 ASSERT_TRUE(root->render_surface()); |
1713 ASSERT_TRUE(child2->render_surface()); | 1713 ASSERT_TRUE(child2->render_surface()); |
1714 | 1714 |
1715 EXPECT_FALSE(root->is_clipped()); | 1715 EXPECT_FALSE(root->is_clipped()); |
1716 EXPECT_TRUE(root->render_surface()->is_clipped()); | 1716 EXPECT_TRUE(root->render_surface()->is_clipped()); |
1717 EXPECT_TRUE(parent->is_clipped()); | 1717 EXPECT_TRUE(parent->is_clipped()); |
1718 EXPECT_TRUE(child1->is_clipped()); | 1718 EXPECT_TRUE(child1->is_clipped()); |
1719 EXPECT_FALSE(child2->is_clipped()); | 1719 EXPECT_FALSE(child2->is_clipped()); |
1720 EXPECT_TRUE(child2->render_surface()->is_clipped()); | 1720 EXPECT_TRUE(child2->render_surface()->is_clipped()); |
1721 EXPECT_TRUE(grandChild->is_clipped()); | 1721 EXPECT_TRUE(grandChild->is_clipped()); |
1722 EXPECT_TRUE(leafNode1->is_clipped()); | 1722 EXPECT_TRUE(leafNode1->is_clipped()); |
1723 EXPECT_FALSE(leafNode2->is_clipped()); | 1723 EXPECT_FALSE(leafNode2->is_clipped()); |
1724 | 1724 |
1725 // Case 3: child2 masksToBounds. The layer and subtree are clipped, and | 1725 // Case 3: child2 masksToBounds. The layer and subtree are clipped, and |
1726 // child2's renderSurface is not clipped. | 1726 // child2's renderSurface is not clipped. |
1727 renderSurfaceLayerList.clear(); | 1727 renderSurfaceLayerList.clear(); |
1728 parent->SetMasksToBounds(false); | 1728 parent->SetMasksToBounds(false); |
1729 child2->SetMasksToBounds(true); | 1729 child2->SetMasksToBounds(true); |
1730 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1730 LayerTreeHostCommon::CalculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1731 | 1731 |
1732 ASSERT_TRUE(root->render_surface()); | 1732 ASSERT_TRUE(root->render_surface()); |
1733 ASSERT_TRUE(child2->render_surface()); | 1733 ASSERT_TRUE(child2->render_surface()); |
1734 | 1734 |
1735 EXPECT_FALSE(root->is_clipped()); | 1735 EXPECT_FALSE(root->is_clipped()); |
1736 EXPECT_TRUE(root->render_surface()->is_clipped()); | 1736 EXPECT_TRUE(root->render_surface()->is_clipped()); |
1737 EXPECT_FALSE(parent->is_clipped()); | 1737 EXPECT_FALSE(parent->is_clipped()); |
1738 EXPECT_FALSE(child1->is_clipped()); | 1738 EXPECT_FALSE(child1->is_clipped()); |
1739 EXPECT_TRUE(child2->is_clipped()); | 1739 EXPECT_TRUE(child2->is_clipped()); |
1740 EXPECT_FALSE(child2->render_surface()->is_clipped()); | 1740 EXPECT_FALSE(child2->render_surface()->is_clipped()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 | 1779 |
1780 // Force everyone to be a render surface. | 1780 // Force everyone to be a render surface. |
1781 child->SetOpacity(0.4f); | 1781 child->SetOpacity(0.4f); |
1782 grandChild1->SetOpacity(0.5); | 1782 grandChild1->SetOpacity(0.5); |
1783 grandChild2->SetOpacity(0.5); | 1783 grandChild2->SetOpacity(0.5); |
1784 grandChild3->SetOpacity(0.5); | 1784 grandChild3->SetOpacity(0.5); |
1785 grandChild4->SetOpacity(0.5); | 1785 grandChild4->SetOpacity(0.5); |
1786 | 1786 |
1787 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1787 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1788 int dummyMaxTextureSize = 512; | 1788 int dummyMaxTextureSize = 512; |
1789 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1789 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1790 | 1790 |
1791 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1->
drawable_content_rect()); | 1791 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1->
drawable_content_rect()); |
1792 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawable_content_rect()); | 1792 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawable_content_rect()); |
1793 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawable_content_rect()); | 1793 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawable_content_rect()); |
1794 EXPECT_TRUE(grandChild4->drawable_content_rect().IsEmpty()); | 1794 EXPECT_TRUE(grandChild4->drawable_content_rect().IsEmpty()); |
1795 } | 1795 } |
1796 | 1796 |
1797 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1797 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
1798 { | 1798 { |
1799 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. | 1799 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 grandChild1->SetForceRenderSurface(true); | 1849 grandChild1->SetForceRenderSurface(true); |
1850 grandChild2->SetOpacity(0.5); | 1850 grandChild2->SetOpacity(0.5); |
1851 grandChild2->SetForceRenderSurface(true); | 1851 grandChild2->SetForceRenderSurface(true); |
1852 grandChild3->SetOpacity(0.5); | 1852 grandChild3->SetOpacity(0.5); |
1853 grandChild3->SetForceRenderSurface(true); | 1853 grandChild3->SetForceRenderSurface(true); |
1854 grandChild4->SetOpacity(0.5); | 1854 grandChild4->SetOpacity(0.5); |
1855 grandChild4->SetForceRenderSurface(true); | 1855 grandChild4->SetForceRenderSurface(true); |
1856 | 1856 |
1857 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1857 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1858 int dummyMaxTextureSize = 512; | 1858 int dummyMaxTextureSize = 512; |
1859 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1859 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
1860 | 1860 |
1861 ASSERT_TRUE(grandChild1->render_surface()); | 1861 ASSERT_TRUE(grandChild1->render_surface()); |
1862 ASSERT_TRUE(grandChild2->render_surface()); | 1862 ASSERT_TRUE(grandChild2->render_surface()); |
1863 ASSERT_TRUE(grandChild3->render_surface()); | 1863 ASSERT_TRUE(grandChild3->render_surface()); |
1864 EXPECT_FALSE(grandChild4->render_surface()); // Because grandChild4 is entir
ely clipped, it is expected to not have a renderSurface. | 1864 EXPECT_FALSE(grandChild4->render_surface()); // Because grandChild4 is entir
ely clipped, it is expected to not have a renderSurface. |
1865 | 1865 |
1866 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. | 1866 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. |
1867 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1->
render_surface()->clip_rect()); | 1867 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1->
render_surface()->clip_rect()); |
1868 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2->
render_surface()->clip_rect()); | 1868 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2->
render_surface()->clip_rect()); |
1869 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3->
render_surface()->clip_rect()); | 1869 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3->
render_surface()->clip_rect()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) | 2013 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) |
2014 { | 2014 { |
2015 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. | 2015 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. |
2016 | 2016 |
2017 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2017 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
2018 gfx::Transform layerToSurfaceTransform; | 2018 gfx::Transform layerToSurfaceTransform; |
2019 | 2019 |
2020 // Case 1: Layer is contained within the surface. | 2020 // Case 1: Layer is contained within the surface. |
2021 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)
); | 2021 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)
); |
2022 gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); | 2022 gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); |
2023 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2023 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2024 EXPECT_RECT_EQ(expected, actual); | 2024 EXPECT_RECT_EQ(expected, actual); |
2025 | 2025 |
2026 // Case 2: Layer is outside the surface rect. | 2026 // Case 2: Layer is outside the surface rect. |
2027 layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); | 2027 layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); |
2028 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2028 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2029 EXPECT_TRUE(actual.IsEmpty()); | 2029 EXPECT_TRUE(actual.IsEmpty()); |
2030 | 2030 |
2031 // Case 3: Layer is partially overlapping the surface rect. | 2031 // Case 3: Layer is partially overlapping the surface rect. |
2032 layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); | 2032 layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); |
2033 expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); | 2033 expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); |
2034 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2034 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2035 EXPECT_RECT_EQ(expected, actual); | 2035 EXPECT_RECT_EQ(expected, actual); |
2036 } | 2036 } |
2037 | 2037 |
2038 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) | 2038 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) |
2039 { | 2039 { |
2040 // Test the calculateVisibleRect() function works correctly for scaling tran
sforms. | 2040 // Test the calculateVisibleRect() function works correctly for scaling tran
sforms. |
2041 | 2041 |
2042 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2042 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
2043 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 2043 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
2044 gfx::Transform layerToSurfaceTransform; | 2044 gfx::Transform layerToSurfaceTransform; |
2045 | 2045 |
2046 // Case 1: Layer is contained within the surface. | 2046 // Case 1: Layer is contained within the surface. |
2047 layerToSurfaceTransform.MakeIdentity(); | 2047 layerToSurfaceTransform.MakeIdentity(); |
2048 layerToSurfaceTransform.Translate(10, 10); | 2048 layerToSurfaceTransform.Translate(10, 10); |
2049 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 2049 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
2050 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2050 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2051 EXPECT_RECT_EQ(expected, actual); | 2051 EXPECT_RECT_EQ(expected, actual); |
2052 | 2052 |
2053 // Case 2: Layer is outside the surface rect. | 2053 // Case 2: Layer is outside the surface rect. |
2054 layerToSurfaceTransform.MakeIdentity(); | 2054 layerToSurfaceTransform.MakeIdentity(); |
2055 layerToSurfaceTransform.Translate(120, 120); | 2055 layerToSurfaceTransform.Translate(120, 120); |
2056 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2056 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2057 EXPECT_TRUE(actual.IsEmpty()); | 2057 EXPECT_TRUE(actual.IsEmpty()); |
2058 | 2058 |
2059 // Case 3: Layer is partially overlapping the surface rect. | 2059 // Case 3: Layer is partially overlapping the surface rect. |
2060 layerToSurfaceTransform.MakeIdentity(); | 2060 layerToSurfaceTransform.MakeIdentity(); |
2061 layerToSurfaceTransform.Translate(80, 80); | 2061 layerToSurfaceTransform.Translate(80, 80); |
2062 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); | 2062 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); |
2063 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2063 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2064 EXPECT_RECT_EQ(expected, actual); | 2064 EXPECT_RECT_EQ(expected, actual); |
2065 } | 2065 } |
2066 | 2066 |
2067 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) | 2067 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) |
2068 { | 2068 { |
2069 // Test the calculateVisibleRect() function works correctly for rotations ab
out z-axis (i.e. 2D rotations). | 2069 // Test the calculateVisibleRect() function works correctly for rotations ab
out z-axis (i.e. 2D rotations). |
2070 // Remember that calculateVisibleRect() should return the visible rect in th
e layer's space. | 2070 // Remember that calculateVisibleRect() should return the visible rect in th
e layer's space. |
2071 | 2071 |
2072 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2072 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
2073 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 2073 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
2074 gfx::Transform layerToSurfaceTransform; | 2074 gfx::Transform layerToSurfaceTransform; |
2075 | 2075 |
2076 // Case 1: Layer is contained within the surface. | 2076 // Case 1: Layer is contained within the surface. |
2077 layerToSurfaceTransform.MakeIdentity(); | 2077 layerToSurfaceTransform.MakeIdentity(); |
2078 layerToSurfaceTransform.Translate(50, 50); | 2078 layerToSurfaceTransform.Translate(50, 50); |
2079 layerToSurfaceTransform.Rotate(45); | 2079 layerToSurfaceTransform.Rotate(45); |
2080 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 2080 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
2081 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2081 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2082 EXPECT_RECT_EQ(expected, actual); | 2082 EXPECT_RECT_EQ(expected, actual); |
2083 | 2083 |
2084 // Case 2: Layer is outside the surface rect. | 2084 // Case 2: Layer is outside the surface rect. |
2085 layerToSurfaceTransform.MakeIdentity(); | 2085 layerToSurfaceTransform.MakeIdentity(); |
2086 layerToSurfaceTransform.Translate(-50, 0); | 2086 layerToSurfaceTransform.Translate(-50, 0); |
2087 layerToSurfaceTransform.Rotate(45); | 2087 layerToSurfaceTransform.Rotate(45); |
2088 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2088 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2089 EXPECT_TRUE(actual.IsEmpty()); | 2089 EXPECT_TRUE(actual.IsEmpty()); |
2090 | 2090 |
2091 // Case 3: The layer is rotated about its top-left corner. In surface space,
the layer | 2091 // Case 3: The layer is rotated about its top-left corner. In surface space,
the layer |
2092 // is oriented diagonally, with the left half outside of the renderS
urface. In | 2092 // is oriented diagonally, with the left half outside of the renderS
urface. In |
2093 // this case, the visible rect should still be the entire layer (rem
ember the | 2093 // this case, the visible rect should still be the entire layer (rem
ember the |
2094 // visible rect is computed in layer space); both the top-left and | 2094 // visible rect is computed in layer space); both the top-left and |
2095 // bottom-right corners of the layer are still visible. | 2095 // bottom-right corners of the layer are still visible. |
2096 layerToSurfaceTransform.MakeIdentity(); | 2096 layerToSurfaceTransform.MakeIdentity(); |
2097 layerToSurfaceTransform.Rotate(45); | 2097 layerToSurfaceTransform.Rotate(45); |
2098 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 2098 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
2099 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2099 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2100 EXPECT_RECT_EQ(expected, actual); | 2100 EXPECT_RECT_EQ(expected, actual); |
2101 | 2101 |
2102 // Case 4: The layer is rotated about its top-left corner, and translated up
wards. In | 2102 // Case 4: The layer is rotated about its top-left corner, and translated up
wards. In |
2103 // surface space, the layer is oriented diagonally, with only the to
p corner | 2103 // surface space, the layer is oriented diagonally, with only the to
p corner |
2104 // of the surface overlapping the layer. In layer space, the render
surface | 2104 // of the surface overlapping the layer. In layer space, the render
surface |
2105 // overlaps the right side of the layer. The visible rect should be
the | 2105 // overlaps the right side of the layer. The visible rect should be
the |
2106 // layer's right half. | 2106 // layer's right half. |
2107 layerToSurfaceTransform.MakeIdentity(); | 2107 layerToSurfaceTransform.MakeIdentity(); |
2108 layerToSurfaceTransform.Translate(0, -sqrt(2.0) * 15); | 2108 layerToSurfaceTransform.Translate(0, -sqrt(2.0) * 15); |
2109 layerToSurfaceTransform.Rotate(45); | 2109 layerToSurfaceTransform.Rotate(45); |
2110 expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of
layer bounds. | 2110 expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of
layer bounds. |
2111 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2111 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2112 EXPECT_RECT_EQ(expected, actual); | 2112 EXPECT_RECT_EQ(expected, actual); |
2113 } | 2113 } |
2114 | 2114 |
2115 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) | 2115 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) |
2116 { | 2116 { |
2117 // Test that the calculateVisibleRect() function works correctly for 3d tran
sforms. | 2117 // Test that the calculateVisibleRect() function works correctly for 3d tran
sforms. |
2118 | 2118 |
2119 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2119 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
2120 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); | 2120 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); |
2121 gfx::Transform layerToSurfaceTransform; | 2121 gfx::Transform layerToSurfaceTransform; |
2122 | 2122 |
2123 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, should be fully contained in the renderSurface. | 2123 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, should be fully contained in the renderSurface. |
2124 layerToSurfaceTransform.MakeIdentity(); | 2124 layerToSurfaceTransform.MakeIdentity(); |
2125 layerToSurfaceTransform.RotateAboutYAxis(45); | 2125 layerToSurfaceTransform.RotateAboutYAxis(45); |
2126 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); | 2126 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); |
2127 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2127 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2128 EXPECT_RECT_EQ(expected, actual); | 2128 EXPECT_RECT_EQ(expected, actual); |
2129 | 2129 |
2130 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, but | 2130 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, but |
2131 // shifted to the side so only the right-half the layer would be vis
ible on | 2131 // shifted to the side so only the right-half the layer would be vis
ible on |
2132 // the surface. | 2132 // the surface. |
2133 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r
otated layer width; divided by sqrt(2) is the rotated width. | 2133 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r
otated layer width; divided by sqrt(2) is the rotated width. |
2134 layerToSurfaceTransform.MakeIdentity(); | 2134 layerToSurfaceTransform.MakeIdentity(); |
2135 layerToSurfaceTransform.Translate(-halfWidthOfRotatedLayer, 0); | 2135 layerToSurfaceTransform.Translate(-halfWidthOfRotatedLayer, 0); |
2136 layerToSurfaceTransform.RotateAboutYAxis(45); // rotates about the left edge
of the layer | 2136 layerToSurfaceTransform.RotateAboutYAxis(45); // rotates about the left edge
of the layer |
2137 expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half o
f the layer. | 2137 expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half o
f the layer. |
2138 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2138 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2139 EXPECT_RECT_EQ(expected, actual); | 2139 EXPECT_RECT_EQ(expected, actual); |
2140 } | 2140 } |
2141 | 2141 |
2142 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) | 2142 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) |
2143 { | 2143 { |
2144 // Test the calculateVisibleRect() function works correctly when the layer h
as a | 2144 // Test the calculateVisibleRect() function works correctly when the layer h
as a |
2145 // perspective projection onto the target surface. | 2145 // perspective projection onto the target surface. |
2146 | 2146 |
2147 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2147 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
2148 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200,
200)); | 2148 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200,
200)); |
2149 gfx::Transform layerToSurfaceTransform; | 2149 gfx::Transform layerToSurfaceTransform; |
2150 | 2150 |
2151 // Case 1: Even though the layer is twice as large as the surface, due to pe
rspective | 2151 // Case 1: Even though the layer is twice as large as the surface, due to pe
rspective |
2152 // foreshortening, the layer will fit fully in the surface when its
translated | 2152 // foreshortening, the layer will fit fully in the surface when its
translated |
2153 // more than the perspective amount. | 2153 // more than the perspective amount. |
2154 layerToSurfaceTransform.MakeIdentity(); | 2154 layerToSurfaceTransform.MakeIdentity(); |
2155 | 2155 |
2156 // The following sequence of transforms applies the perspective about the ce
nter of the surface. | 2156 // The following sequence of transforms applies the perspective about the ce
nter of the surface. |
2157 layerToSurfaceTransform.Translate(50, 50); | 2157 layerToSurfaceTransform.Translate(50, 50); |
2158 layerToSurfaceTransform.ApplyPerspectiveDepth(9); | 2158 layerToSurfaceTransform.ApplyPerspectiveDepth(9); |
2159 layerToSurfaceTransform.Translate(-50, -50); | 2159 layerToSurfaceTransform.Translate(-50, -50); |
2160 | 2160 |
2161 // This translate places the layer in front of the surface's projection plan
e. | 2161 // This translate places the layer in front of the surface's projection plan
e. |
2162 layerToSurfaceTransform.Translate3d(0, 0, -27); | 2162 layerToSurfaceTransform.Translate3d(0, 0, -27); |
2163 | 2163 |
2164 gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); | 2164 gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); |
2165 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2165 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2166 EXPECT_RECT_EQ(expected, actual); | 2166 EXPECT_RECT_EQ(expected, actual); |
2167 | 2167 |
2168 // Case 2: same projection as before, except that the layer is also translat
ed to the | 2168 // Case 2: same projection as before, except that the layer is also translat
ed to the |
2169 // side, so that only the right half of the layer should be visible. | 2169 // side, so that only the right half of the layer should be visible. |
2170 // | 2170 // |
2171 // Explanation of expected result: | 2171 // Explanation of expected result: |
2172 // The perspective ratio is (z distance between layer and camera origin) / (
z distance between projection plane and camera origin) == ((-27 - 9) / 9) | 2172 // The perspective ratio is (z distance between layer and camera origin) / (
z distance between projection plane and camera origin) == ((-27 - 9) / 9) |
2173 // Then, by similar triangles, if we want to move a layer by translating -50
units in projected surface units (so that only half of it is | 2173 // Then, by similar triangles, if we want to move a layer by translating -50
units in projected surface units (so that only half of it is |
2174 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t
he layer's units. | 2174 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t
he layer's units. |
2175 // | 2175 // |
2176 layerToSurfaceTransform.Translate3d(-200, 0, 0); | 2176 layerToSurfaceTransform.Translate3d(-200, 0, 0); |
2177 expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right
half of the layer's bounding rect. | 2177 expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right
half of the layer's bounding rect. |
2178 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 2178 actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
2179 EXPECT_RECT_EQ(expected, actual); | 2179 EXPECT_RECT_EQ(expected, actual); |
2180 } | 2180 } |
2181 | 2181 |
2182 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi
ndSurface) | 2182 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi
ndSurface) |
2183 { | 2183 { |
2184 // There is currently no explicit concept of an orthographic projection plan
e in our | 2184 // There is currently no explicit concept of an orthographic projection plan
e in our |
2185 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te
chnically | 2185 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te
chnically |
2186 // behind the surface in an orthographic world should not be clipped when th
ey are | 2186 // behind the surface in an orthographic world should not be clipped when th
ey are |
2187 // flattened to the surface. | 2187 // flattened to the surface. |
2188 | 2188 |
2189 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2189 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
2190 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); | 2190 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); |
2191 gfx::Transform layerToSurfaceTransform; | 2191 gfx::Transform layerToSurfaceTransform; |
2192 | 2192 |
2193 // This sequence of transforms effectively rotates the layer about the y-axi
s at the | 2193 // This sequence of transforms effectively rotates the layer about the y-axi
s at the |
2194 // center of the layer. | 2194 // center of the layer. |
2195 layerToSurfaceTransform.MakeIdentity(); | 2195 layerToSurfaceTransform.MakeIdentity(); |
2196 layerToSurfaceTransform.Translate(50, 0); | 2196 layerToSurfaceTransform.Translate(50, 0); |
2197 layerToSurfaceTransform.RotateAboutYAxis(45); | 2197 layerToSurfaceTransform.RotateAboutYAxis(45); |
2198 layerToSurfaceTransform.Translate(-50, 0); | 2198 layerToSurfaceTransform.Translate(-50, 0); |
2199 | 2199 |
2200 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); | 2200 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); |
2201 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2201 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2202 EXPECT_RECT_EQ(expected, actual); | 2202 EXPECT_RECT_EQ(expected, actual); |
2203 } | 2203 } |
2204 | 2204 |
2205 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) | 2205 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) |
2206 { | 2206 { |
2207 // Test the calculateVisibleRect() function works correctly when projecting
a surface | 2207 // Test the calculateVisibleRect() function works correctly when projecting
a surface |
2208 // onto a layer, but the layer is partially behind the camera (not just behi
nd the | 2208 // onto a layer, but the layer is partially behind the camera (not just behi
nd the |
2209 // projection plane). In this case, the cartesian coordinates may seem to be
valid, | 2209 // projection plane). In this case, the cartesian coordinates may seem to be
valid, |
2210 // but actually they are not. The visibleRect needs to be properly clipped b
y the | 2210 // but actually they are not. The visibleRect needs to be properly clipped b
y the |
2211 // w = 0 plane in homogeneous coordinates before converting to cartesian coo
rdinates. | 2211 // w = 0 plane in homogeneous coordinates before converting to cartesian coo
rdinates. |
(...skipping 12 matching lines...) Expand all Loading... |
2224 layerToSurfaceTransform.RotateAboutYAxis(45); | 2224 layerToSurfaceTransform.RotateAboutYAxis(45); |
2225 | 2225 |
2226 // Sanity check that this transform does indeed cause w < 0 when applying th
e | 2226 // Sanity check that this transform does indeed cause w < 0 when applying th
e |
2227 // transform, otherwise this code is not testing the intended scenario. | 2227 // transform, otherwise this code is not testing the intended scenario. |
2228 bool clipped = false; | 2228 bool clipped = false; |
2229 MathUtil::MapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten
tRect)), &clipped); | 2229 MathUtil::MapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten
tRect)), &clipped); |
2230 ASSERT_TRUE(clipped); | 2230 ASSERT_TRUE(clipped); |
2231 | 2231 |
2232 int expectedXPosition = 0; | 2232 int expectedXPosition = 0; |
2233 int expectedWidth = 10; | 2233 int expectedWidth = 10; |
2234 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2234 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2235 EXPECT_EQ(expectedXPosition, actual.x()); | 2235 EXPECT_EQ(expectedXPosition, actual.x()); |
2236 EXPECT_EQ(expectedWidth, actual.width()); | 2236 EXPECT_EQ(expectedWidth, actual.width()); |
2237 } | 2237 } |
2238 | 2238 |
2239 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) | 2239 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) |
2240 { | 2240 { |
2241 // To determine visibleRect in layer space, there needs to be an un-projecti
on from | 2241 // To determine visibleRect in layer space, there needs to be an un-projecti
on from |
2242 // surface space to layer space. When the original transform was a perspecti
ve | 2242 // surface space to layer space. When the original transform was a perspecti
ve |
2243 // projection that was clipped, it returns a rect that encloses the clipped
bounds. | 2243 // projection that was clipped, it returns a rect that encloses the clipped
bounds. |
2244 // Un-projecting this new rect may require clipping again. | 2244 // Un-projecting this new rect may require clipping again. |
(...skipping 12 matching lines...) Expand all Loading... |
2257 // testing the intended scenario. | 2257 // testing the intended scenario. |
2258 bool clipped = false; | 2258 bool clipped = false; |
2259 gfx::RectF clippedRect = MathUtil::MapClippedRect(layerToSurfaceTransform, l
ayerContentRect); | 2259 gfx::RectF clippedRect = MathUtil::MapClippedRect(layerToSurfaceTransform, l
ayerContentRect); |
2260 MathUtil::ProjectQuad(Inverse(layerToSurfaceTransform), gfx::QuadF(clippedRe
ct), &clipped); | 2260 MathUtil::ProjectQuad(Inverse(layerToSurfaceTransform), gfx::QuadF(clippedRe
ct), &clipped); |
2261 ASSERT_TRUE(clipped); | 2261 ASSERT_TRUE(clipped); |
2262 | 2262 |
2263 // Only the corner of the layer is not visible on the surface because of bei
ng | 2263 // Only the corner of the layer is not visible on the surface because of bei
ng |
2264 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is | 2264 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is |
2265 // that the entire layer should still be considered visible. | 2265 // that the entire layer should still be considered visible. |
2266 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); | 2266 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); |
2267 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2267 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2268 EXPECT_RECT_EQ(expected, actual); | 2268 EXPECT_RECT_EQ(expected, actual); |
2269 } | 2269 } |
2270 | 2270 |
2271 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) | 2271 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) |
2272 { | 2272 { |
2273 scoped_refptr<Layer> root = Layer::Create(); | 2273 scoped_refptr<Layer> root = Layer::Create(); |
2274 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2274 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2275 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2275 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2276 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2276 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2277 root->AddChild(child1); | 2277 root->AddChild(child1); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2685 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2685 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2686 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2686 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2687 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2687 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2688 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); | 2688 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); |
2689 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2689 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
2690 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2690 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
2691 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2691 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
2692 | 2692 |
2693 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2693 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2694 int dummyMaxTextureSize = 512; | 2694 int dummyMaxTextureSize = 512; |
2695 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2695 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
2696 | 2696 |
2697 // Verify which renderSurfaces were created. | 2697 // Verify which renderSurfaces were created. |
2698 EXPECT_FALSE(frontFacingChild->render_surface()); | 2698 EXPECT_FALSE(frontFacingChild->render_surface()); |
2699 EXPECT_FALSE(backFacingChild->render_surface()); | 2699 EXPECT_FALSE(backFacingChild->render_surface()); |
2700 EXPECT_TRUE(frontFacingSurface->render_surface()); | 2700 EXPECT_TRUE(frontFacingSurface->render_surface()); |
2701 EXPECT_TRUE(backFacingSurface->render_surface()); | 2701 EXPECT_TRUE(backFacingSurface->render_surface()); |
2702 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->render_surface()); | 2702 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->render_surface()); |
2703 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->render_surface()); | 2703 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->render_surface()); |
2704 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->render_surface()); | 2704 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->render_surface()); |
2705 EXPECT_FALSE(backFacingChildOfBackFacingSurface->render_surface()); | 2705 EXPECT_FALSE(backFacingChildOfBackFacingSurface->render_surface()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2784 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2784 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2785 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); //
surface transform style is preserve-3d. | 2785 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); //
surface transform style is preserve-3d. |
2786 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s
urface transform style is preserve-3d. | 2786 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s
urface transform style is preserve-3d. |
2787 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); | 2787 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); |
2788 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2788 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
2789 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2789 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
2790 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2790 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
2791 | 2791 |
2792 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2792 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2793 int dummyMaxTextureSize = 512; | 2793 int dummyMaxTextureSize = 512; |
2794 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2794 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
2795 | 2795 |
2796 // Verify which renderSurfaces were created. | 2796 // Verify which renderSurfaces were created. |
2797 EXPECT_FALSE(frontFacingChild->render_surface()); | 2797 EXPECT_FALSE(frontFacingChild->render_surface()); |
2798 EXPECT_FALSE(backFacingChild->render_surface()); | 2798 EXPECT_FALSE(backFacingChild->render_surface()); |
2799 EXPECT_TRUE(frontFacingSurface->render_surface()); | 2799 EXPECT_TRUE(frontFacingSurface->render_surface()); |
2800 EXPECT_FALSE(backFacingSurface->render_surface()); | 2800 EXPECT_FALSE(backFacingSurface->render_surface()); |
2801 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->render_surface()); | 2801 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->render_surface()); |
2802 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->render_surface()); | 2802 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->render_surface()); |
2803 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->render_surface()); | 2803 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->render_surface()); |
2804 EXPECT_FALSE(backFacingChildOfBackFacingSurface->render_surface()); | 2804 EXPECT_FALSE(backFacingChildOfBackFacingSurface->render_surface()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 | 2864 |
2865 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2865 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2866 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2866 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2867 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2867 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2868 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false
); | 2868 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false
); |
2869 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2869 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2870 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2870 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2871 | 2871 |
2872 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2872 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2873 int dummyMaxTextureSize = 512; | 2873 int dummyMaxTextureSize = 512; |
2874 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2874 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
2875 | 2875 |
2876 EXPECT_FALSE(child->render_surface()); | 2876 EXPECT_FALSE(child->render_surface()); |
2877 EXPECT_TRUE(animatingSurface->render_surface()); | 2877 EXPECT_TRUE(animatingSurface->render_surface()); |
2878 EXPECT_FALSE(childOfAnimatingSurface->render_surface()); | 2878 EXPECT_FALSE(childOfAnimatingSurface->render_surface()); |
2879 EXPECT_FALSE(animatingChild->render_surface()); | 2879 EXPECT_FALSE(animatingChild->render_surface()); |
2880 EXPECT_FALSE(child2->render_surface()); | 2880 EXPECT_FALSE(child2->render_surface()); |
2881 | 2881 |
2882 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. | 2882 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. |
2883 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2883 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2884 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2884 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 backfaceMatrix.Translate(-50, -50); | 2930 backfaceMatrix.Translate(-50, -50); |
2931 | 2931 |
2932 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans
form style is preserve3d. | 2932 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans
form style is preserve3d. |
2933 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. | 2933 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. |
2934 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. | 2934 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. |
2935 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2935 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2936 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2936 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2937 | 2937 |
2938 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2938 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2939 int dummyMaxTextureSize = 512; | 2939 int dummyMaxTextureSize = 512; |
2940 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2940 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
2941 | 2941 |
2942 // Verify which renderSurfaces were created. | 2942 // Verify which renderSurfaces were created. |
2943 EXPECT_TRUE(frontFacingSurface->render_surface()); | 2943 EXPECT_TRUE(frontFacingSurface->render_surface()); |
2944 EXPECT_FALSE(backFacingSurface->render_surface()); // because it should be c
ulled | 2944 EXPECT_FALSE(backFacingSurface->render_surface()); // because it should be c
ulled |
2945 EXPECT_FALSE(child1->render_surface()); | 2945 EXPECT_FALSE(child1->render_surface()); |
2946 EXPECT_FALSE(child2->render_surface()); | 2946 EXPECT_FALSE(child2->render_surface()); |
2947 | 2947 |
2948 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2948 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
2949 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2949 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2950 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2950 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
2951 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); | 2951 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); |
2952 | 2952 |
2953 // Verify root surface's layerList. | 2953 // Verify root surface's layerList. |
2954 ASSERT_EQ(1u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); | 2954 ASSERT_EQ(1u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
2955 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->render_surfac
e()->layer_list()[0]->id()); | 2955 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->render_surfac
e()->layer_list()[0]->id()); |
2956 | 2956 |
2957 // Verify frontFacingSurface's layerList. | 2957 // Verify frontFacingSurface's layerList. |
2958 ASSERT_EQ(2u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); | 2958 ASSERT_EQ(2u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
2959 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->render_surfac
e()->layer_list()[0]->id()); | 2959 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->render_surfac
e()->layer_list()[0]->id()); |
2960 EXPECT_EQ(child1->id(), renderSurfaceLayerList[1]->render_surface()->layer_l
ist()[1]->id()); | 2960 EXPECT_EQ(child1->id(), renderSurfaceLayerList[1]->render_surface()->layer_l
ist()[1]->id()); |
2961 } | 2961 } |
2962 | 2962 |
2963 TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) | 2963 TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) |
2964 { | 2964 { |
2965 // Hit testing on an empty renderSurfaceLayerList should return a null point
er. | 2965 // Hit testing on an empty renderSurfaceLayerList should return a null point
er. |
2966 std::vector<LayerImpl*> renderSurfaceLayerList; | 2966 std::vector<LayerImpl*> renderSurfaceLayerList; |
2967 | 2967 |
2968 gfx::Point testPoint(0, 0); | 2968 gfx::Point testPoint(0, 0); |
2969 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 2969 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2970 EXPECT_FALSE(resultLayer); | 2970 EXPECT_FALSE(resultLayer); |
2971 | 2971 |
2972 testPoint = gfx::Point(10, 20); | 2972 testPoint = gfx::Point(10, 20); |
2973 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2973 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2974 EXPECT_FALSE(resultLayer); | 2974 EXPECT_FALSE(resultLayer); |
2975 } | 2975 } |
2976 | 2976 |
2977 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2977 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
2978 { | 2978 { |
2979 FakeImplProxy proxy; | 2979 FakeImplProxy proxy; |
2980 FakeLayerTreeHostImpl hostImpl(&proxy); | 2980 FakeLayerTreeHostImpl hostImpl(&proxy); |
2981 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 2981 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
2982 | 2982 |
2983 gfx::Transform identityMatrix; | 2983 gfx::Transform identityMatrix; |
2984 gfx::PointF anchor(0, 0); | 2984 gfx::PointF anchor(0, 0); |
2985 gfx::PointF position(0, 0); | 2985 gfx::PointF position(0, 0); |
2986 gfx::Size bounds(100, 100); | 2986 gfx::Size bounds(100, 100); |
2987 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2987 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2988 root->SetDrawsContent(true); | 2988 root->SetDrawsContent(true); |
2989 | 2989 |
2990 std::vector<LayerImpl*> renderSurfaceLayerList; | 2990 std::vector<LayerImpl*> renderSurfaceLayerList; |
2991 int dummyMaxTextureSize = 512; | 2991 int dummyMaxTextureSize = 512; |
2992 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 2992 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
2993 | 2993 |
2994 // Sanity check the scenario we just created. | 2994 // Sanity check the scenario we just created. |
2995 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2995 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2996 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 2996 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
2997 | 2997 |
2998 // Hit testing for a point outside the layer should return a null pointer. | 2998 // Hit testing for a point outside the layer should return a null pointer. |
2999 gfx::Point testPoint(101, 101); | 2999 gfx::Point testPoint(101, 101); |
3000 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3000 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3001 EXPECT_FALSE(resultLayer); | 3001 EXPECT_FALSE(resultLayer); |
3002 | 3002 |
3003 testPoint = gfx::Point(-1, -1); | 3003 testPoint = gfx::Point(-1, -1); |
3004 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3004 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3005 EXPECT_FALSE(resultLayer); | 3005 EXPECT_FALSE(resultLayer); |
3006 | 3006 |
3007 // Hit testing for a point inside should return the root layer. | 3007 // Hit testing for a point inside should return the root layer. |
3008 testPoint = gfx::Point(1, 1); | 3008 testPoint = gfx::Point(1, 1); |
3009 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3009 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3010 ASSERT_TRUE(resultLayer); | 3010 ASSERT_TRUE(resultLayer); |
3011 EXPECT_EQ(12345, resultLayer->id()); | 3011 EXPECT_EQ(12345, resultLayer->id()); |
3012 | 3012 |
3013 testPoint = gfx::Point(99, 99); | 3013 testPoint = gfx::Point(99, 99); |
3014 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3014 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3015 ASSERT_TRUE(resultLayer); | 3015 ASSERT_TRUE(resultLayer); |
3016 EXPECT_EQ(12345, resultLayer->id()); | 3016 EXPECT_EQ(12345, resultLayer->id()); |
3017 } | 3017 } |
3018 | 3018 |
3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) | 3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) |
3020 { | 3020 { |
3021 FakeImplProxy proxy; | 3021 FakeImplProxy proxy; |
3022 FakeLayerTreeHostImpl hostImpl(&proxy); | 3022 FakeLayerTreeHostImpl hostImpl(&proxy); |
3023 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3023 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3024 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::Create(ho
stImpl.active_tree(), 11111); | 3024 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::Create(ho
stImpl.active_tree(), 11111); |
3025 | 3025 |
3026 gfx::Transform identityMatrix; | 3026 gfx::Transform identityMatrix; |
3027 gfx::PointF anchor(0.f, 0.f); | 3027 gfx::PointF anchor(0.f, 0.f); |
3028 gfx::PointF position(0.f, 0.f); | 3028 gfx::PointF position(0.f, 0.f); |
3029 gfx::Size bounds(100, 100); | 3029 gfx::Size bounds(100, 100); |
3030 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3030 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3031 root->SetDrawsContent(true); | 3031 root->SetDrawsContent(true); |
3032 | 3032 |
3033 // Create hud and add it as a child of root. | 3033 // Create hud and add it as a child of root. |
3034 gfx::Size hudBounds(200, 200); | 3034 gfx::Size hudBounds(200, 200); |
3035 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); | 3035 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); |
3036 hud->SetDrawsContent(true); | 3036 hud->SetDrawsContent(true); |
3037 | 3037 |
3038 hostImpl.active_tree()->set_hud_layer(hud.get()); | 3038 hostImpl.active_tree()->set_hud_layer(hud.get()); |
3039 root->AddChild(hud.PassAs<LayerImpl>()); | 3039 root->AddChild(hud.PassAs<LayerImpl>()); |
3040 | 3040 |
3041 std::vector<LayerImpl*> renderSurfaceLayerList; | 3041 std::vector<LayerImpl*> renderSurfaceLayerList; |
3042 int dummyMaxTextureSize = 512; | 3042 int dummyMaxTextureSize = 512; |
3043 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, renderSurfaceLayerList, false); | 3043 LayerTreeHostCommon::CalculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3044 | 3044 |
3045 // Sanity check the scenario we just created. | 3045 // Sanity check the scenario we just created. |
3046 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3046 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3047 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 3047 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
3048 | 3048 |
3049 // Hit testing for a point inside HUD, but outside root should return null | 3049 // Hit testing for a point inside HUD, but outside root should return null |
3050 gfx::Point testPoint(101, 101); | 3050 gfx::Point testPoint(101, 101); |
3051 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3051 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3052 EXPECT_FALSE(resultLayer); | 3052 EXPECT_FALSE(resultLayer); |
3053 | 3053 |
3054 testPoint = gfx::Point(-1, -1); | 3054 testPoint = gfx::Point(-1, -1); |
3055 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3055 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3056 EXPECT_FALSE(resultLayer); | 3056 EXPECT_FALSE(resultLayer); |
3057 | 3057 |
3058 // Hit testing for a point inside should return the root layer, never the HU
D layer. | 3058 // Hit testing for a point inside should return the root layer, never the HU
D layer. |
3059 testPoint = gfx::Point(1, 1); | 3059 testPoint = gfx::Point(1, 1); |
3060 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3060 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3061 ASSERT_TRUE(resultLayer); | 3061 ASSERT_TRUE(resultLayer); |
3062 EXPECT_EQ(12345, resultLayer->id()); | 3062 EXPECT_EQ(12345, resultLayer->id()); |
3063 | 3063 |
3064 testPoint = gfx::Point(99, 99); | 3064 testPoint = gfx::Point(99, 99); |
3065 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3065 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3066 ASSERT_TRUE(resultLayer); | 3066 ASSERT_TRUE(resultLayer); |
3067 EXPECT_EQ(12345, resultLayer->id()); | 3067 EXPECT_EQ(12345, resultLayer->id()); |
3068 } | 3068 } |
3069 | 3069 |
3070 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 3070 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
3071 { | 3071 { |
3072 FakeImplProxy proxy; | 3072 FakeImplProxy proxy; |
3073 FakeLayerTreeHostImpl hostImpl(&proxy); | 3073 FakeLayerTreeHostImpl hostImpl(&proxy); |
3074 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3074 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3075 | 3075 |
3076 gfx::Transform uninvertibleTransform; | 3076 gfx::Transform uninvertibleTransform; |
3077 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3077 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
3078 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3078 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
3079 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3079 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
3080 uninvertibleTransform.matrix().setDouble(3, 3, 0); | 3080 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
3081 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); | 3081 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
3082 | 3082 |
3083 gfx::Transform identityMatrix; | 3083 gfx::Transform identityMatrix; |
3084 gfx::PointF anchor(0, 0); | 3084 gfx::PointF anchor(0, 0); |
3085 gfx::PointF position(0, 0); | 3085 gfx::PointF position(0, 0); |
3086 gfx::Size bounds(100, 100); | 3086 gfx::Size bounds(100, 100); |
3087 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 3087 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
3088 root->SetDrawsContent(true); | 3088 root->SetDrawsContent(true); |
3089 | 3089 |
3090 std::vector<LayerImpl*> renderSurfaceLayerList; | 3090 std::vector<LayerImpl*> renderSurfaceLayerList; |
3091 int dummyMaxTextureSize = 512; | 3091 int dummyMaxTextureSize = 512; |
3092 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3092 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3093 | 3093 |
3094 // Sanity check the scenario we just created. | 3094 // Sanity check the scenario we just created. |
3095 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3095 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3096 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3096 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3097 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); | 3097 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
3098 | 3098 |
3099 // Hit testing any point should not hit the layer. If the invertible matrix
is | 3099 // Hit testing any point should not hit the layer. If the invertible matrix
is |
3100 // accidentally ignored and treated like an identity, then the hit testing w
ill | 3100 // accidentally ignored and treated like an identity, then the hit testing w
ill |
3101 // incorrectly hit the layer when it shouldn't. | 3101 // incorrectly hit the layer when it shouldn't. |
3102 gfx::Point testPoint(1, 1); | 3102 gfx::Point testPoint(1, 1); |
3103 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3103 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3104 EXPECT_FALSE(resultLayer); | 3104 EXPECT_FALSE(resultLayer); |
3105 | 3105 |
3106 testPoint = gfx::Point(10, 10); | 3106 testPoint = gfx::Point(10, 10); |
3107 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3107 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3108 EXPECT_FALSE(resultLayer); | 3108 EXPECT_FALSE(resultLayer); |
3109 | 3109 |
3110 testPoint = gfx::Point(10, 30); | 3110 testPoint = gfx::Point(10, 30); |
3111 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3111 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3112 EXPECT_FALSE(resultLayer); | 3112 EXPECT_FALSE(resultLayer); |
3113 | 3113 |
3114 testPoint = gfx::Point(50, 50); | 3114 testPoint = gfx::Point(50, 50); |
3115 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3115 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3116 EXPECT_FALSE(resultLayer); | 3116 EXPECT_FALSE(resultLayer); |
3117 | 3117 |
3118 testPoint = gfx::Point(67, 48); | 3118 testPoint = gfx::Point(67, 48); |
3119 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3119 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3120 EXPECT_FALSE(resultLayer); | 3120 EXPECT_FALSE(resultLayer); |
3121 | 3121 |
3122 testPoint = gfx::Point(99, 99); | 3122 testPoint = gfx::Point(99, 99); |
3123 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3123 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3124 EXPECT_FALSE(resultLayer); | 3124 EXPECT_FALSE(resultLayer); |
3125 | 3125 |
3126 testPoint = gfx::Point(-1, -1); | 3126 testPoint = gfx::Point(-1, -1); |
3127 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3127 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3128 EXPECT_FALSE(resultLayer); | 3128 EXPECT_FALSE(resultLayer); |
3129 } | 3129 } |
3130 | 3130 |
3131 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 3131 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
3132 { | 3132 { |
3133 FakeImplProxy proxy; | 3133 FakeImplProxy proxy; |
3134 FakeLayerTreeHostImpl hostImpl(&proxy); | 3134 FakeLayerTreeHostImpl hostImpl(&proxy); |
3135 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3135 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3136 | 3136 |
3137 gfx::Transform identityMatrix; | 3137 gfx::Transform identityMatrix; |
3138 gfx::PointF anchor(0, 0); | 3138 gfx::PointF anchor(0, 0); |
3139 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3139 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
3140 gfx::Size bounds(100, 100); | 3140 gfx::Size bounds(100, 100); |
3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3142 root->SetDrawsContent(true); | 3142 root->SetDrawsContent(true); |
3143 | 3143 |
3144 std::vector<LayerImpl*> renderSurfaceLayerList; | 3144 std::vector<LayerImpl*> renderSurfaceLayerList; |
3145 int dummyMaxTextureSize = 512; | 3145 int dummyMaxTextureSize = 512; |
3146 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3146 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3147 | 3147 |
3148 // Sanity check the scenario we just created. | 3148 // Sanity check the scenario we just created. |
3149 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3149 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3150 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3150 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3151 | 3151 |
3152 // Hit testing for a point outside the layer should return a null pointer. | 3152 // Hit testing for a point outside the layer should return a null pointer. |
3153 gfx::Point testPoint(49, 49); | 3153 gfx::Point testPoint(49, 49); |
3154 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3154 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3155 EXPECT_FALSE(resultLayer); | 3155 EXPECT_FALSE(resultLayer); |
3156 | 3156 |
3157 // Even though the layer exists at (101, 101), it should not be visible ther
e since the root renderSurface would clamp it. | 3157 // Even though the layer exists at (101, 101), it should not be visible ther
e since the root renderSurface would clamp it. |
3158 testPoint = gfx::Point(101, 101); | 3158 testPoint = gfx::Point(101, 101); |
3159 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3159 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3160 EXPECT_FALSE(resultLayer); | 3160 EXPECT_FALSE(resultLayer); |
3161 | 3161 |
3162 // Hit testing for a point inside should return the root layer. | 3162 // Hit testing for a point inside should return the root layer. |
3163 testPoint = gfx::Point(51, 51); | 3163 testPoint = gfx::Point(51, 51); |
3164 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3164 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3165 ASSERT_TRUE(resultLayer); | 3165 ASSERT_TRUE(resultLayer); |
3166 EXPECT_EQ(12345, resultLayer->id()); | 3166 EXPECT_EQ(12345, resultLayer->id()); |
3167 | 3167 |
3168 testPoint = gfx::Point(99, 99); | 3168 testPoint = gfx::Point(99, 99); |
3169 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3169 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3170 ASSERT_TRUE(resultLayer); | 3170 ASSERT_TRUE(resultLayer); |
3171 EXPECT_EQ(12345, resultLayer->id()); | 3171 EXPECT_EQ(12345, resultLayer->id()); |
3172 } | 3172 } |
3173 | 3173 |
3174 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 3174 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
3175 { | 3175 { |
3176 FakeImplProxy proxy; | 3176 FakeImplProxy proxy; |
3177 FakeLayerTreeHostImpl hostImpl(&proxy); | 3177 FakeLayerTreeHostImpl hostImpl(&proxy); |
3178 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3178 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3179 | 3179 |
3180 gfx::Transform identityMatrix; | 3180 gfx::Transform identityMatrix; |
3181 gfx::Transform rotation45DegreesAboutCenter; | 3181 gfx::Transform rotation45DegreesAboutCenter; |
3182 rotation45DegreesAboutCenter.Translate(50, 50); | 3182 rotation45DegreesAboutCenter.Translate(50, 50); |
3183 rotation45DegreesAboutCenter.RotateAboutZAxis(45); | 3183 rotation45DegreesAboutCenter.RotateAboutZAxis(45); |
3184 rotation45DegreesAboutCenter.Translate(-50, -50); | 3184 rotation45DegreesAboutCenter.Translate(-50, -50); |
3185 gfx::PointF anchor(0, 0); | 3185 gfx::PointF anchor(0, 0); |
3186 gfx::PointF position(0, 0); | 3186 gfx::PointF position(0, 0); |
3187 gfx::Size bounds(100, 100); | 3187 gfx::Size bounds(100, 100); |
3188 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 3188 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
3189 root->SetDrawsContent(true); | 3189 root->SetDrawsContent(true); |
3190 | 3190 |
3191 std::vector<LayerImpl*> renderSurfaceLayerList; | 3191 std::vector<LayerImpl*> renderSurfaceLayerList; |
3192 int dummyMaxTextureSize = 512; | 3192 int dummyMaxTextureSize = 512; |
3193 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3193 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3194 | 3194 |
3195 // Sanity check the scenario we just created. | 3195 // Sanity check the scenario we just created. |
3196 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3196 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3197 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3197 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3198 | 3198 |
3199 // Hit testing for points outside the layer. | 3199 // Hit testing for points outside the layer. |
3200 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 3200 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
3201 gfx::Point testPoint(99, 99); | 3201 gfx::Point testPoint(99, 99); |
3202 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3202 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3203 EXPECT_FALSE(resultLayer); | 3203 EXPECT_FALSE(resultLayer); |
3204 | 3204 |
3205 testPoint = gfx::Point(1, 1); | 3205 testPoint = gfx::Point(1, 1); |
3206 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3206 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3207 EXPECT_FALSE(resultLayer); | 3207 EXPECT_FALSE(resultLayer); |
3208 | 3208 |
3209 // Hit testing for a point inside should return the root layer. | 3209 // Hit testing for a point inside should return the root layer. |
3210 testPoint = gfx::Point(1, 50); | 3210 testPoint = gfx::Point(1, 50); |
3211 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3211 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3212 ASSERT_TRUE(resultLayer); | 3212 ASSERT_TRUE(resultLayer); |
3213 EXPECT_EQ(12345, resultLayer->id()); | 3213 EXPECT_EQ(12345, resultLayer->id()); |
3214 | 3214 |
3215 // Hit testing the corners that would overlap the unclipped layer, but are o
utside the clipped region. | 3215 // Hit testing the corners that would overlap the unclipped layer, but are o
utside the clipped region. |
3216 testPoint = gfx::Point(50, -1); | 3216 testPoint = gfx::Point(50, -1); |
3217 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3217 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3218 ASSERT_FALSE(resultLayer); | 3218 ASSERT_FALSE(resultLayer); |
3219 | 3219 |
3220 testPoint = gfx::Point(-1, 50); | 3220 testPoint = gfx::Point(-1, 50); |
3221 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3221 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3222 ASSERT_FALSE(resultLayer); | 3222 ASSERT_FALSE(resultLayer); |
3223 } | 3223 } |
3224 | 3224 |
3225 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 3225 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
3226 { | 3226 { |
3227 FakeImplProxy proxy; | 3227 FakeImplProxy proxy; |
3228 FakeLayerTreeHostImpl hostImpl(&proxy); | 3228 FakeLayerTreeHostImpl hostImpl(&proxy); |
3229 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3229 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3230 | 3230 |
3231 gfx::Transform identityMatrix; | 3231 gfx::Transform identityMatrix; |
3232 | 3232 |
3233 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 3233 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
3234 gfx::Transform perspectiveProjectionAboutCenter; | 3234 gfx::Transform perspectiveProjectionAboutCenter; |
3235 perspectiveProjectionAboutCenter.Translate(50, 50); | 3235 perspectiveProjectionAboutCenter.Translate(50, 50); |
3236 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); | 3236 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); |
3237 perspectiveProjectionAboutCenter.Translate(-50, -50); | 3237 perspectiveProjectionAboutCenter.Translate(-50, -50); |
3238 gfx::Transform translationByZ; | 3238 gfx::Transform translationByZ; |
3239 translationByZ.Translate3d(0, 0, -1); | 3239 translationByZ.Translate3d(0, 0, -1); |
3240 | 3240 |
3241 gfx::PointF anchor(0, 0); | 3241 gfx::PointF anchor(0, 0); |
3242 gfx::PointF position(0, 0); | 3242 gfx::PointF position(0, 0); |
3243 gfx::Size bounds(100, 100); | 3243 gfx::Size bounds(100, 100); |
3244 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); | 3244 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); |
3245 root->SetDrawsContent(true); | 3245 root->SetDrawsContent(true); |
3246 | 3246 |
3247 std::vector<LayerImpl*> renderSurfaceLayerList; | 3247 std::vector<LayerImpl*> renderSurfaceLayerList; |
3248 int dummyMaxTextureSize = 512; | 3248 int dummyMaxTextureSize = 512; |
3249 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3249 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3250 | 3250 |
3251 // Sanity check the scenario we just created. | 3251 // Sanity check the scenario we just created. |
3252 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3252 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3253 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3253 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3254 | 3254 |
3255 // Hit testing for points outside the layer. | 3255 // Hit testing for points outside the layer. |
3256 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 3256 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
3257 gfx::Point testPoint(24, 24); | 3257 gfx::Point testPoint(24, 24); |
3258 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3258 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3259 EXPECT_FALSE(resultLayer); | 3259 EXPECT_FALSE(resultLayer); |
3260 | 3260 |
3261 testPoint = gfx::Point(76, 76); | 3261 testPoint = gfx::Point(76, 76); |
3262 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3262 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3263 EXPECT_FALSE(resultLayer); | 3263 EXPECT_FALSE(resultLayer); |
3264 | 3264 |
3265 // Hit testing for a point inside should return the root layer. | 3265 // Hit testing for a point inside should return the root layer. |
3266 testPoint = gfx::Point(26, 26); | 3266 testPoint = gfx::Point(26, 26); |
3267 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3267 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3268 ASSERT_TRUE(resultLayer); | 3268 ASSERT_TRUE(resultLayer); |
3269 EXPECT_EQ(12345, resultLayer->id()); | 3269 EXPECT_EQ(12345, resultLayer->id()); |
3270 | 3270 |
3271 testPoint = gfx::Point(74, 74); | 3271 testPoint = gfx::Point(74, 74); |
3272 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3272 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3273 ASSERT_TRUE(resultLayer); | 3273 ASSERT_TRUE(resultLayer); |
3274 EXPECT_EQ(12345, resultLayer->id()); | 3274 EXPECT_EQ(12345, resultLayer->id()); |
3275 } | 3275 } |
3276 | 3276 |
3277 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents) | 3277 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents) |
3278 { | 3278 { |
3279 // A layer's visibleContentRect is actually in the layer's content space. Th
e | 3279 // A layer's visibleContentRect is actually in the layer's content space. Th
e |
3280 // screenSpaceTransform converts from the layer's origin space to screen spa
ce. This | 3280 // screenSpaceTransform converts from the layer's origin space to screen spa
ce. This |
3281 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3281 // test makes sure that hit testing works correctly accounts for the content
s scale. |
3282 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3282 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
(...skipping 21 matching lines...) Expand all Loading... |
3304 // override contentBounds and contentsScale | 3304 // override contentBounds and contentsScale |
3305 testLayer->SetContentBounds(gfx::Size(100, 100)); | 3305 testLayer->SetContentBounds(gfx::Size(100, 100)); |
3306 testLayer->SetContentsScale(2, 2); | 3306 testLayer->SetContentsScale(2, 2); |
3307 | 3307 |
3308 testLayer->SetDrawsContent(true); | 3308 testLayer->SetDrawsContent(true); |
3309 root->AddChild(testLayer.Pass()); | 3309 root->AddChild(testLayer.Pass()); |
3310 } | 3310 } |
3311 | 3311 |
3312 std::vector<LayerImpl*> renderSurfaceLayerList; | 3312 std::vector<LayerImpl*> renderSurfaceLayerList; |
3313 int dummyMaxTextureSize = 512; | 3313 int dummyMaxTextureSize = 512; |
3314 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3314 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3315 | 3315 |
3316 // Sanity check the scenario we just created. | 3316 // Sanity check the scenario we just created. |
3317 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 3317 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
3318 LayerImpl* testLayer = root->children()[0]; | 3318 LayerImpl* testLayer = root->children()[0]; |
3319 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
ble_content_rect()); | 3319 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
ble_content_rect()); |
3320 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3320 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3321 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3321 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3322 | 3322 |
3323 // Hit testing for a point outside the layer should return a null pointer (t
he root layer does not draw content, so it will not be hit tested either). | 3323 // Hit testing for a point outside the layer should return a null pointer (t
he root layer does not draw content, so it will not be hit tested either). |
3324 gfx::Point testPoint(101, 101); | 3324 gfx::Point testPoint(101, 101); |
3325 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3325 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3326 EXPECT_FALSE(resultLayer); | 3326 EXPECT_FALSE(resultLayer); |
3327 | 3327 |
3328 testPoint = gfx::Point(24, 24); | 3328 testPoint = gfx::Point(24, 24); |
3329 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3329 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3330 EXPECT_FALSE(resultLayer); | 3330 EXPECT_FALSE(resultLayer); |
3331 | 3331 |
3332 testPoint = gfx::Point(76, 76); | 3332 testPoint = gfx::Point(76, 76); |
3333 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3333 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3334 EXPECT_FALSE(resultLayer); | 3334 EXPECT_FALSE(resultLayer); |
3335 | 3335 |
3336 // Hit testing for a point inside should return the test layer. | 3336 // Hit testing for a point inside should return the test layer. |
3337 testPoint = gfx::Point(26, 26); | 3337 testPoint = gfx::Point(26, 26); |
3338 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3338 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3339 ASSERT_TRUE(resultLayer); | 3339 ASSERT_TRUE(resultLayer); |
3340 EXPECT_EQ(12345, resultLayer->id()); | 3340 EXPECT_EQ(12345, resultLayer->id()); |
3341 | 3341 |
3342 testPoint = gfx::Point(74, 74); | 3342 testPoint = gfx::Point(74, 74); |
3343 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3343 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3344 ASSERT_TRUE(resultLayer); | 3344 ASSERT_TRUE(resultLayer); |
3345 EXPECT_EQ(12345, resultLayer->id()); | 3345 EXPECT_EQ(12345, resultLayer->id()); |
3346 } | 3346 } |
3347 | 3347 |
3348 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 3348 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
3349 { | 3349 { |
3350 // Test that hit-testing will only work for the visible portion of a layer,
and not | 3350 // Test that hit-testing will only work for the visible portion of a layer,
and not |
3351 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3351 // the entire layer bounds. Here we just test the simple axis-aligned case. |
3352 gfx::Transform identityMatrix; | 3352 gfx::Transform identityMatrix; |
3353 gfx::PointF anchor(0, 0); | 3353 gfx::PointF anchor(0, 0); |
(...skipping 14 matching lines...) Expand all Loading... |
3368 position = gfx::PointF(-50, -50); | 3368 position = gfx::PointF(-50, -50); |
3369 bounds = gfx::Size(300, 300); | 3369 bounds = gfx::Size(300, 300); |
3370 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3370 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3371 child->SetDrawsContent(true); | 3371 child->SetDrawsContent(true); |
3372 clippingLayer->AddChild(child.Pass()); | 3372 clippingLayer->AddChild(child.Pass()); |
3373 root->AddChild(clippingLayer.Pass()); | 3373 root->AddChild(clippingLayer.Pass()); |
3374 } | 3374 } |
3375 | 3375 |
3376 std::vector<LayerImpl*> renderSurfaceLayerList; | 3376 std::vector<LayerImpl*> renderSurfaceLayerList; |
3377 int dummyMaxTextureSize = 512; | 3377 int dummyMaxTextureSize = 512; |
3378 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3378 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3379 | 3379 |
3380 // Sanity check the scenario we just created. | 3380 // Sanity check the scenario we just created. |
3381 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3381 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3382 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3382 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3383 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); | 3383 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
3384 | 3384 |
3385 // Hit testing for a point outside the layer should return a null pointer. | 3385 // Hit testing for a point outside the layer should return a null pointer. |
3386 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 3386 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
3387 gfx::Point testPoint(24, 24); | 3387 gfx::Point testPoint(24, 24); |
3388 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3388 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3389 EXPECT_FALSE(resultLayer); | 3389 EXPECT_FALSE(resultLayer); |
3390 | 3390 |
3391 // Even though the layer exists at (101, 101), it should not be visible ther
e since the clippingLayer would clamp it. | 3391 // Even though the layer exists at (101, 101), it should not be visible ther
e since the clippingLayer would clamp it. |
3392 testPoint = gfx::Point(76, 76); | 3392 testPoint = gfx::Point(76, 76); |
3393 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3393 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3394 EXPECT_FALSE(resultLayer); | 3394 EXPECT_FALSE(resultLayer); |
3395 | 3395 |
3396 // Hit testing for a point inside should return the child layer. | 3396 // Hit testing for a point inside should return the child layer. |
3397 testPoint = gfx::Point(26, 26); | 3397 testPoint = gfx::Point(26, 26); |
3398 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3398 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3399 ASSERT_TRUE(resultLayer); | 3399 ASSERT_TRUE(resultLayer); |
3400 EXPECT_EQ(456, resultLayer->id()); | 3400 EXPECT_EQ(456, resultLayer->id()); |
3401 | 3401 |
3402 testPoint = gfx::Point(74, 74); | 3402 testPoint = gfx::Point(74, 74); |
3403 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3403 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3404 ASSERT_TRUE(resultLayer); | 3404 ASSERT_TRUE(resultLayer); |
3405 EXPECT_EQ(456, resultLayer->id()); | 3405 EXPECT_EQ(456, resultLayer->id()); |
3406 } | 3406 } |
3407 | 3407 |
3408 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) | 3408 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) |
3409 { | 3409 { |
3410 // This test checks whether hit testing correctly avoids hit testing with mu
ltiple | 3410 // This test checks whether hit testing correctly avoids hit testing with mu
ltiple |
3411 // ancestors that clip in non axis-aligned ways. To pass this test, the hit
testing | 3411 // ancestors that clip in non axis-aligned ways. To pass this test, the hit
testing |
3412 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3412 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
3413 // should not actually hit those clipped areas. | 3413 // should not actually hit those clipped areas. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3458 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
3459 rotatedLeaf->SetDrawsContent(true); | 3459 rotatedLeaf->SetDrawsContent(true); |
3460 | 3460 |
3461 grandChild->AddChild(rotatedLeaf.Pass()); | 3461 grandChild->AddChild(rotatedLeaf.Pass()); |
3462 child->AddChild(grandChild.Pass()); | 3462 child->AddChild(grandChild.Pass()); |
3463 root->AddChild(child.Pass()); | 3463 root->AddChild(child.Pass()); |
3464 } | 3464 } |
3465 | 3465 |
3466 std::vector<LayerImpl*> renderSurfaceLayerList; | 3466 std::vector<LayerImpl*> renderSurfaceLayerList; |
3467 int dummyMaxTextureSize = 512; | 3467 int dummyMaxTextureSize = 512; |
3468 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3468 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3469 | 3469 |
3470 // Sanity check the scenario we just created. | 3470 // Sanity check the scenario we just created. |
3471 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3471 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
3472 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3472 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
3473 ASSERT_EQ(1u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); | 3473 ASSERT_EQ(1u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
3474 ASSERT_EQ(789, renderSurfaceLayerList[0]->render_surface()->layer_list()[0]-
>id()); // grandChild's surface. | 3474 ASSERT_EQ(789, renderSurfaceLayerList[0]->render_surface()->layer_list()[0]-
>id()); // grandChild's surface. |
3475 ASSERT_EQ(1u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); | 3475 ASSERT_EQ(1u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
3476 ASSERT_EQ(2468, renderSurfaceLayerList[1]->render_surface()->layer_list()[0]
->id()); | 3476 ASSERT_EQ(2468, renderSurfaceLayerList[1]->render_surface()->layer_list()[0]
->id()); |
3477 | 3477 |
3478 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. | 3478 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. |
3479 gfx::Point testPoint(11, 89); | 3479 gfx::Point testPoint(11, 89); |
3480 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3480 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3481 EXPECT_FALSE(resultLayer); | 3481 EXPECT_FALSE(resultLayer); |
3482 | 3482 |
3483 // Closer inwards from the bottom left will overlap the layer. | 3483 // Closer inwards from the bottom left will overlap the layer. |
3484 testPoint = gfx::Point(25, 75); | 3484 testPoint = gfx::Point(25, 75); |
3485 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3485 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3486 ASSERT_TRUE(resultLayer); | 3486 ASSERT_TRUE(resultLayer); |
3487 EXPECT_EQ(2468, resultLayer->id()); | 3487 EXPECT_EQ(2468, resultLayer->id()); |
3488 | 3488 |
3489 // (4, 50) is inside the unclipped layer, but that corner of the layer shoul
d be | 3489 // (4, 50) is inside the unclipped layer, but that corner of the layer shoul
d be |
3490 // clipped away by the grandParent and should not get hit. If hit testing bl
indly uses | 3490 // clipped away by the grandParent and should not get hit. If hit testing bl
indly uses |
3491 // visibleContentRect without considering how parent may clip the layer, the
n hit | 3491 // visibleContentRect without considering how parent may clip the layer, the
n hit |
3492 // testing would accidentally think that the point successfully hits the lay
er. | 3492 // testing would accidentally think that the point successfully hits the lay
er. |
3493 testPoint = gfx::Point(4, 50); | 3493 testPoint = gfx::Point(4, 50); |
3494 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3494 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3495 EXPECT_FALSE(resultLayer); | 3495 EXPECT_FALSE(resultLayer); |
3496 | 3496 |
3497 // (11, 50) is inside the layer and within the clipped area. | 3497 // (11, 50) is inside the layer and within the clipped area. |
3498 testPoint = gfx::Point(11, 50); | 3498 testPoint = gfx::Point(11, 50); |
3499 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3499 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3500 ASSERT_TRUE(resultLayer); | 3500 ASSERT_TRUE(resultLayer); |
3501 EXPECT_EQ(2468, resultLayer->id()); | 3501 EXPECT_EQ(2468, resultLayer->id()); |
3502 | 3502 |
3503 // Around the middle, just to the right and up, would have hit the layer exc
ept that | 3503 // Around the middle, just to the right and up, would have hit the layer exc
ept that |
3504 // that area should be clipped away by the parent. | 3504 // that area should be clipped away by the parent. |
3505 testPoint = gfx::Point(51, 51); | 3505 testPoint = gfx::Point(51, 51); |
3506 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3506 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3507 EXPECT_FALSE(resultLayer); | 3507 EXPECT_FALSE(resultLayer); |
3508 | 3508 |
3509 // Around the middle, just to the left and down, should successfully hit the
layer. | 3509 // Around the middle, just to the left and down, should successfully hit the
layer. |
3510 testPoint = gfx::Point(49, 51); | 3510 testPoint = gfx::Point(49, 51); |
3511 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3511 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3512 ASSERT_TRUE(resultLayer); | 3512 ASSERT_TRUE(resultLayer); |
3513 EXPECT_EQ(2468, resultLayer->id()); | 3513 EXPECT_EQ(2468, resultLayer->id()); |
3514 } | 3514 } |
3515 | 3515 |
3516 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3516 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
3517 { | 3517 { |
3518 // This test checks that hit testing code does not accidentally clip to laye
r | 3518 // This test checks that hit testing code does not accidentally clip to laye
r |
3519 // bounds for a layer that actually does not clip. | 3519 // bounds for a layer that actually does not clip. |
3520 gfx::Transform identityMatrix; | 3520 gfx::Transform identityMatrix; |
3521 gfx::PointF anchor(0, 0); | 3521 gfx::PointF anchor(0, 0); |
(...skipping 18 matching lines...) Expand all Loading... |
3540 position = gfx::PointF(60, 60); // 70, 70 in screen space | 3540 position = gfx::PointF(60, 60); // 70, 70 in screen space |
3541 bounds = gfx::Size(20, 20); | 3541 bounds = gfx::Size(20, 20); |
3542 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3542 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3543 child->SetDrawsContent(true); | 3543 child->SetDrawsContent(true); |
3544 intermediateLayer->AddChild(child.Pass()); | 3544 intermediateLayer->AddChild(child.Pass()); |
3545 root->AddChild(intermediateLayer.Pass()); | 3545 root->AddChild(intermediateLayer.Pass()); |
3546 } | 3546 } |
3547 | 3547 |
3548 std::vector<LayerImpl*> renderSurfaceLayerList; | 3548 std::vector<LayerImpl*> renderSurfaceLayerList; |
3549 int dummyMaxTextureSize = 512; | 3549 int dummyMaxTextureSize = 512; |
3550 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3550 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3551 | 3551 |
3552 // Sanity check the scenario we just created. | 3552 // Sanity check the scenario we just created. |
3553 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3553 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3554 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3554 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3555 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); | 3555 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
3556 | 3556 |
3557 // Hit testing for a point outside the layer should return a null pointer. | 3557 // Hit testing for a point outside the layer should return a null pointer. |
3558 gfx::Point testPoint(69, 69); | 3558 gfx::Point testPoint(69, 69); |
3559 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3559 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3560 EXPECT_FALSE(resultLayer); | 3560 EXPECT_FALSE(resultLayer); |
3561 | 3561 |
3562 testPoint = gfx::Point(91, 91); | 3562 testPoint = gfx::Point(91, 91); |
3563 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3563 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3564 EXPECT_FALSE(resultLayer); | 3564 EXPECT_FALSE(resultLayer); |
3565 | 3565 |
3566 // Hit testing for a point inside should return the child layer. | 3566 // Hit testing for a point inside should return the child layer. |
3567 testPoint = gfx::Point(71, 71); | 3567 testPoint = gfx::Point(71, 71); |
3568 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3568 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3569 ASSERT_TRUE(resultLayer); | 3569 ASSERT_TRUE(resultLayer); |
3570 EXPECT_EQ(456, resultLayer->id()); | 3570 EXPECT_EQ(456, resultLayer->id()); |
3571 | 3571 |
3572 testPoint = gfx::Point(89, 89); | 3572 testPoint = gfx::Point(89, 89); |
3573 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3573 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3574 ASSERT_TRUE(resultLayer); | 3574 ASSERT_TRUE(resultLayer); |
3575 EXPECT_EQ(456, resultLayer->id()); | 3575 EXPECT_EQ(456, resultLayer->id()); |
3576 } | 3576 } |
3577 | 3577 |
3578 | 3578 |
3579 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3579 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
3580 { | 3580 { |
3581 FakeImplProxy proxy; | 3581 FakeImplProxy proxy; |
3582 FakeLayerTreeHostImpl hostImpl(&proxy); | 3582 FakeLayerTreeHostImpl hostImpl(&proxy); |
3583 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); | 3583 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 1); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3620 root->AddChild(child1.Pass()); | 3620 root->AddChild(child1.Pass()); |
3621 root->AddChild(child2.Pass()); | 3621 root->AddChild(child2.Pass()); |
3622 } | 3622 } |
3623 | 3623 |
3624 LayerImpl* child1 = root->children()[0]; | 3624 LayerImpl* child1 = root->children()[0]; |
3625 LayerImpl* child2 = root->children()[1]; | 3625 LayerImpl* child2 = root->children()[1]; |
3626 LayerImpl* grandChild1 = child1->children()[0]; | 3626 LayerImpl* grandChild1 = child1->children()[0]; |
3627 | 3627 |
3628 std::vector<LayerImpl*> renderSurfaceLayerList; | 3628 std::vector<LayerImpl*> renderSurfaceLayerList; |
3629 int dummyMaxTextureSize = 512; | 3629 int dummyMaxTextureSize = 512; |
3630 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3630 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3631 | 3631 |
3632 // Sanity check the scenario we just created. | 3632 // Sanity check the scenario we just created. |
3633 ASSERT_TRUE(child1); | 3633 ASSERT_TRUE(child1); |
3634 ASSERT_TRUE(child2); | 3634 ASSERT_TRUE(child2); |
3635 ASSERT_TRUE(grandChild1); | 3635 ASSERT_TRUE(grandChild1); |
3636 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3636 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3637 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); | 3637 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); |
3638 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer | 3638 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer |
3639 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1 | 3639 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1 |
3640 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grandChild1 | 3640 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grandChild1 |
3641 ASSERT_EQ(3, root->render_surface()->layer_list()[3]->id()); // child2 | 3641 ASSERT_EQ(3, root->render_surface()->layer_list()[3]->id()); // child2 |
3642 | 3642 |
3643 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. | 3643 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. |
3644 gfx::Point testPoint = gfx::Point(1, 1); | 3644 gfx::Point testPoint = gfx::Point(1, 1); |
3645 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3645 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3646 ASSERT_TRUE(resultLayer); | 3646 ASSERT_TRUE(resultLayer); |
3647 EXPECT_EQ(1, resultLayer->id()); | 3647 EXPECT_EQ(1, resultLayer->id()); |
3648 | 3648 |
3649 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. | 3649 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. |
3650 testPoint = gfx::Point(15, 15); | 3650 testPoint = gfx::Point(15, 15); |
3651 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3651 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3652 ASSERT_TRUE(resultLayer); | 3652 ASSERT_TRUE(resultLayer); |
3653 EXPECT_EQ(2, resultLayer->id()); | 3653 EXPECT_EQ(2, resultLayer->id()); |
3654 | 3654 |
3655 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 3655 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. |
3656 testPoint = gfx::Point(51, 20); | 3656 testPoint = gfx::Point(51, 20); |
3657 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3657 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3658 ASSERT_TRUE(resultLayer); | 3658 ASSERT_TRUE(resultLayer); |
3659 EXPECT_EQ(3, resultLayer->id()); | 3659 EXPECT_EQ(3, resultLayer->id()); |
3660 | 3660 |
3661 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. | 3661 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. |
3662 testPoint = gfx::Point(80, 51); | 3662 testPoint = gfx::Point(80, 51); |
3663 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3663 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3664 ASSERT_TRUE(resultLayer); | 3664 ASSERT_TRUE(resultLayer); |
3665 EXPECT_EQ(3, resultLayer->id()); | 3665 EXPECT_EQ(3, resultLayer->id()); |
3666 | 3666 |
3667 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. | 3667 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. |
3668 testPoint = gfx::Point(51, 51); | 3668 testPoint = gfx::Point(51, 51); |
3669 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3669 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3670 ASSERT_TRUE(resultLayer); | 3670 ASSERT_TRUE(resultLayer); |
3671 EXPECT_EQ(3, resultLayer->id()); | 3671 EXPECT_EQ(3, resultLayer->id()); |
3672 | 3672 |
3673 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. | 3673 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. |
3674 testPoint = gfx::Point(20, 51); | 3674 testPoint = gfx::Point(20, 51); |
3675 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3675 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3676 ASSERT_TRUE(resultLayer); | 3676 ASSERT_TRUE(resultLayer); |
3677 EXPECT_EQ(4, resultLayer->id()); | 3677 EXPECT_EQ(4, resultLayer->id()); |
3678 } | 3678 } |
3679 | 3679 |
3680 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3680 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
3681 { | 3681 { |
3682 // | 3682 // |
3683 // The geometry is set up similarly to the previous case, but | 3683 // The geometry is set up similarly to the previous case, but |
3684 // all layers are forced to be renderSurfaces now. | 3684 // all layers are forced to be renderSurfaces now. |
3685 // | 3685 // |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3728 root->AddChild(child1.Pass()); | 3728 root->AddChild(child1.Pass()); |
3729 root->AddChild(child2.Pass()); | 3729 root->AddChild(child2.Pass()); |
3730 } | 3730 } |
3731 | 3731 |
3732 LayerImpl* child1 = root->children()[0]; | 3732 LayerImpl* child1 = root->children()[0]; |
3733 LayerImpl* child2 = root->children()[1]; | 3733 LayerImpl* child2 = root->children()[1]; |
3734 LayerImpl* grandChild1 = child1->children()[0]; | 3734 LayerImpl* grandChild1 = child1->children()[0]; |
3735 | 3735 |
3736 std::vector<LayerImpl*> renderSurfaceLayerList; | 3736 std::vector<LayerImpl*> renderSurfaceLayerList; |
3737 int dummyMaxTextureSize = 512; | 3737 int dummyMaxTextureSize = 512; |
3738 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3738 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3739 | 3739 |
3740 // Sanity check the scenario we just created. | 3740 // Sanity check the scenario we just created. |
3741 ASSERT_TRUE(child1); | 3741 ASSERT_TRUE(child1); |
3742 ASSERT_TRUE(child2); | 3742 ASSERT_TRUE(child2); |
3743 ASSERT_TRUE(grandChild1); | 3743 ASSERT_TRUE(grandChild1); |
3744 ASSERT_TRUE(child1->render_surface()); | 3744 ASSERT_TRUE(child1->render_surface()); |
3745 ASSERT_TRUE(child2->render_surface()); | 3745 ASSERT_TRUE(child2->render_surface()); |
3746 ASSERT_TRUE(grandChild1->render_surface()); | 3746 ASSERT_TRUE(grandChild1->render_surface()); |
3747 ASSERT_EQ(4u, renderSurfaceLayerList.size()); | 3747 ASSERT_EQ(4u, renderSurfaceLayerList.size()); |
3748 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); // The root surf
ace has the root layer, and child1's and child2's renderSurfaces. | 3748 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); // The root surf
ace has the root layer, and child1's and child2's renderSurfaces. |
3749 ASSERT_EQ(2u, child1->render_surface()->layer_list().size()); // The child1
surface has the child1 layer and grandChild1's renderSurface. | 3749 ASSERT_EQ(2u, child1->render_surface()->layer_list().size()); // The child1
surface has the child1 layer and grandChild1's renderSurface. |
3750 ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); | 3750 ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); |
3751 ASSERT_EQ(1u, grandChild1->render_surface()->layer_list().size()); | 3751 ASSERT_EQ(1u, grandChild1->render_surface()->layer_list().size()); |
3752 ASSERT_EQ(1, renderSurfaceLayerList[0]->id()); // root layer | 3752 ASSERT_EQ(1, renderSurfaceLayerList[0]->id()); // root layer |
3753 ASSERT_EQ(2, renderSurfaceLayerList[1]->id()); // child1 | 3753 ASSERT_EQ(2, renderSurfaceLayerList[1]->id()); // child1 |
3754 ASSERT_EQ(4, renderSurfaceLayerList[2]->id()); // grandChild1 | 3754 ASSERT_EQ(4, renderSurfaceLayerList[2]->id()); // grandChild1 |
3755 ASSERT_EQ(3, renderSurfaceLayerList[3]->id()); // child2 | 3755 ASSERT_EQ(3, renderSurfaceLayerList[3]->id()); // child2 |
3756 | 3756 |
3757 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. | 3757 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. |
3758 gfx::Point testPoint = gfx::Point(1, 1); | 3758 gfx::Point testPoint = gfx::Point(1, 1); |
3759 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3759 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3760 ASSERT_TRUE(resultLayer); | 3760 ASSERT_TRUE(resultLayer); |
3761 EXPECT_EQ(1, resultLayer->id()); | 3761 EXPECT_EQ(1, resultLayer->id()); |
3762 | 3762 |
3763 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. | 3763 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. |
3764 testPoint = gfx::Point(15, 15); | 3764 testPoint = gfx::Point(15, 15); |
3765 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3765 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3766 ASSERT_TRUE(resultLayer); | 3766 ASSERT_TRUE(resultLayer); |
3767 EXPECT_EQ(2, resultLayer->id()); | 3767 EXPECT_EQ(2, resultLayer->id()); |
3768 | 3768 |
3769 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 3769 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. |
3770 testPoint = gfx::Point(51, 20); | 3770 testPoint = gfx::Point(51, 20); |
3771 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3771 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3772 ASSERT_TRUE(resultLayer); | 3772 ASSERT_TRUE(resultLayer); |
3773 EXPECT_EQ(3, resultLayer->id()); | 3773 EXPECT_EQ(3, resultLayer->id()); |
3774 | 3774 |
3775 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. | 3775 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. |
3776 testPoint = gfx::Point(80, 51); | 3776 testPoint = gfx::Point(80, 51); |
3777 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3777 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3778 ASSERT_TRUE(resultLayer); | 3778 ASSERT_TRUE(resultLayer); |
3779 EXPECT_EQ(3, resultLayer->id()); | 3779 EXPECT_EQ(3, resultLayer->id()); |
3780 | 3780 |
3781 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. | 3781 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. |
3782 testPoint = gfx::Point(51, 51); | 3782 testPoint = gfx::Point(51, 51); |
3783 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3783 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3784 ASSERT_TRUE(resultLayer); | 3784 ASSERT_TRUE(resultLayer); |
3785 EXPECT_EQ(3, resultLayer->id()); | 3785 EXPECT_EQ(3, resultLayer->id()); |
3786 | 3786 |
3787 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. | 3787 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. |
3788 testPoint = gfx::Point(20, 51); | 3788 testPoint = gfx::Point(20, 51); |
3789 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3789 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3790 ASSERT_TRUE(resultLayer); | 3790 ASSERT_TRUE(resultLayer); |
3791 EXPECT_EQ(4, resultLayer->id()); | 3791 EXPECT_EQ(4, resultLayer->id()); |
3792 } | 3792 } |
3793 | 3793 |
3794 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForEmptyLayerL
ist) | 3794 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForEmptyLayerL
ist) |
3795 { | 3795 { |
3796 // Hit checking on an empty renderSurfaceLayerList should return a null poin
ter. | 3796 // Hit checking on an empty renderSurfaceLayerList should return a null poin
ter. |
3797 std::vector<LayerImpl*> renderSurfaceLayerList; | 3797 std::vector<LayerImpl*> renderSurfaceLayerList; |
3798 | 3798 |
3799 gfx::Point testPoint(0, 0); | 3799 gfx::Point testPoint(0, 0); |
3800 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3800 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
3801 EXPECT_FALSE(resultLayer); | 3801 EXPECT_FALSE(resultLayer); |
3802 | 3802 |
3803 testPoint = gfx::Point(10, 20); | 3803 testPoint = gfx::Point(10, 20); |
3804 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3804 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3805 EXPECT_FALSE(resultLayer); | 3805 EXPECT_FALSE(resultLayer); |
3806 } | 3806 } |
3807 | 3807 |
3808 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) | 3808 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) |
3809 { | 3809 { |
3810 FakeImplProxy proxy; | 3810 FakeImplProxy proxy; |
3811 FakeLayerTreeHostImpl hostImpl(&proxy); | 3811 FakeLayerTreeHostImpl hostImpl(&proxy); |
3812 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3812 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3813 | 3813 |
3814 gfx::Transform identityMatrix; | 3814 gfx::Transform identityMatrix; |
3815 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3815 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
3816 gfx::PointF anchor(0, 0); | 3816 gfx::PointF anchor(0, 0); |
3817 gfx::PointF position(0, 0); | 3817 gfx::PointF position(0, 0); |
3818 gfx::Size bounds(100, 100); | 3818 gfx::Size bounds(100, 100); |
3819 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3819 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3820 root->SetDrawsContent(true); | 3820 root->SetDrawsContent(true); |
3821 | 3821 |
3822 std::vector<LayerImpl*> renderSurfaceLayerList; | 3822 std::vector<LayerImpl*> renderSurfaceLayerList; |
3823 int dummyMaxTextureSize = 512; | 3823 int dummyMaxTextureSize = 512; |
3824 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3824 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3825 | 3825 |
3826 // Sanity check the scenario we just created. | 3826 // Sanity check the scenario we just created. |
3827 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3827 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3828 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3828 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3829 | 3829 |
3830 // Hit checking for any point should return a null pointer for a layer witho
ut any touch event handler regions. | 3830 // Hit checking for any point should return a null pointer for a layer witho
ut any touch event handler regions. |
3831 gfx::Point testPoint(11, 11); | 3831 gfx::Point testPoint(11, 11); |
3832 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3832 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
3833 EXPECT_FALSE(resultLayer); | 3833 EXPECT_FALSE(resultLayer); |
3834 | 3834 |
3835 root->SetTouchEventHandlerRegion(touchHandlerRegion); | 3835 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
3836 // Hit checking for a point outside the layer should return a null pointer. | 3836 // Hit checking for a point outside the layer should return a null pointer. |
3837 testPoint = gfx::Point(101, 101); | 3837 testPoint = gfx::Point(101, 101); |
3838 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3838 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3839 EXPECT_FALSE(resultLayer); | 3839 EXPECT_FALSE(resultLayer); |
3840 | 3840 |
3841 testPoint = gfx::Point(-1, -1); | 3841 testPoint = gfx::Point(-1, -1); |
3842 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3842 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3843 EXPECT_FALSE(resultLayer); | 3843 EXPECT_FALSE(resultLayer); |
3844 | 3844 |
3845 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 3845 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
3846 testPoint = gfx::Point(1, 1); | 3846 testPoint = gfx::Point(1, 1); |
3847 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3847 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3848 EXPECT_FALSE(resultLayer); | 3848 EXPECT_FALSE(resultLayer); |
3849 | 3849 |
3850 testPoint = gfx::Point(99, 99); | 3850 testPoint = gfx::Point(99, 99); |
3851 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3851 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3852 EXPECT_FALSE(resultLayer); | 3852 EXPECT_FALSE(resultLayer); |
3853 | 3853 |
3854 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. | 3854 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. |
3855 testPoint = gfx::Point(11, 11); | 3855 testPoint = gfx::Point(11, 11); |
3856 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3856 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3857 ASSERT_TRUE(resultLayer); | 3857 ASSERT_TRUE(resultLayer); |
3858 EXPECT_EQ(12345, resultLayer->id()); | 3858 EXPECT_EQ(12345, resultLayer->id()); |
3859 | 3859 |
3860 testPoint = gfx::Point(59, 59); | 3860 testPoint = gfx::Point(59, 59); |
3861 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3861 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3862 ASSERT_TRUE(resultLayer); | 3862 ASSERT_TRUE(resultLayer); |
3863 EXPECT_EQ(12345, resultLayer->id()); | 3863 EXPECT_EQ(12345, resultLayer->id()); |
3864 } | 3864 } |
3865 | 3865 |
3866 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) | 3866 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) |
3867 { | 3867 { |
3868 FakeImplProxy proxy; | 3868 FakeImplProxy proxy; |
3869 FakeLayerTreeHostImpl hostImpl(&proxy); | 3869 FakeLayerTreeHostImpl hostImpl(&proxy); |
3870 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3870 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3871 | 3871 |
3872 gfx::Transform uninvertibleTransform; | 3872 gfx::Transform uninvertibleTransform; |
3873 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3873 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
3874 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3874 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
3875 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3875 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
3876 uninvertibleTransform.matrix().setDouble(3, 3, 0); | 3876 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
3877 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); | 3877 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
3878 | 3878 |
3879 gfx::Transform identityMatrix; | 3879 gfx::Transform identityMatrix; |
3880 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3880 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
3881 gfx::PointF anchor(0, 0); | 3881 gfx::PointF anchor(0, 0); |
3882 gfx::PointF position(0, 0); | 3882 gfx::PointF position(0, 0); |
3883 gfx::Size bounds(100, 100); | 3883 gfx::Size bounds(100, 100); |
3884 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 3884 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
3885 root->SetDrawsContent(true); | 3885 root->SetDrawsContent(true); |
3886 root->SetTouchEventHandlerRegion(touchHandlerRegion); | 3886 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
3887 | 3887 |
3888 std::vector<LayerImpl*> renderSurfaceLayerList; | 3888 std::vector<LayerImpl*> renderSurfaceLayerList; |
3889 int dummyMaxTextureSize = 512; | 3889 int dummyMaxTextureSize = 512; |
3890 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3890 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3891 | 3891 |
3892 // Sanity check the scenario we just created. | 3892 // Sanity check the scenario we just created. |
3893 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3893 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3894 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3894 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3895 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); | 3895 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
3896 | 3896 |
3897 // Hit checking any point should not hit the touch handler region on the lay
er. If the invertible matrix is | 3897 // Hit checking any point should not hit the touch handler region on the lay
er. If the invertible matrix is |
3898 // accidentally ignored and treated like an identity, then the hit testing w
ill | 3898 // accidentally ignored and treated like an identity, then the hit testing w
ill |
3899 // incorrectly hit the layer when it shouldn't. | 3899 // incorrectly hit the layer when it shouldn't. |
3900 gfx::Point testPoint(1, 1); | 3900 gfx::Point testPoint(1, 1); |
3901 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3901 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
3902 EXPECT_FALSE(resultLayer); | 3902 EXPECT_FALSE(resultLayer); |
3903 | 3903 |
3904 testPoint = gfx::Point(10, 10); | 3904 testPoint = gfx::Point(10, 10); |
3905 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3905 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3906 EXPECT_FALSE(resultLayer); | 3906 EXPECT_FALSE(resultLayer); |
3907 | 3907 |
3908 testPoint = gfx::Point(10, 30); | 3908 testPoint = gfx::Point(10, 30); |
3909 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3909 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3910 EXPECT_FALSE(resultLayer); | 3910 EXPECT_FALSE(resultLayer); |
3911 | 3911 |
3912 testPoint = gfx::Point(50, 50); | 3912 testPoint = gfx::Point(50, 50); |
3913 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3913 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3914 EXPECT_FALSE(resultLayer); | 3914 EXPECT_FALSE(resultLayer); |
3915 | 3915 |
3916 testPoint = gfx::Point(67, 48); | 3916 testPoint = gfx::Point(67, 48); |
3917 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3917 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3918 EXPECT_FALSE(resultLayer); | 3918 EXPECT_FALSE(resultLayer); |
3919 | 3919 |
3920 testPoint = gfx::Point(99, 99); | 3920 testPoint = gfx::Point(99, 99); |
3921 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3921 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3922 EXPECT_FALSE(resultLayer); | 3922 EXPECT_FALSE(resultLayer); |
3923 | 3923 |
3924 testPoint = gfx::Point(-1, -1); | 3924 testPoint = gfx::Point(-1, -1); |
3925 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3925 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3926 EXPECT_FALSE(resultLayer); | 3926 EXPECT_FALSE(resultLayer); |
3927 } | 3927 } |
3928 | 3928 |
3929 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) | 3929 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) |
3930 { | 3930 { |
3931 FakeImplProxy proxy; | 3931 FakeImplProxy proxy; |
3932 FakeLayerTreeHostImpl hostImpl(&proxy); | 3932 FakeLayerTreeHostImpl hostImpl(&proxy); |
3933 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); | 3933 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.active_tree(), 12345
); |
3934 | 3934 |
3935 gfx::Transform identityMatrix; | 3935 gfx::Transform identityMatrix; |
3936 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3936 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
3937 gfx::PointF anchor(0, 0); | 3937 gfx::PointF anchor(0, 0); |
3938 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3938 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
3939 gfx::Size bounds(100, 100); | 3939 gfx::Size bounds(100, 100); |
3940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3941 root->SetDrawsContent(true); | 3941 root->SetDrawsContent(true); |
3942 root->SetTouchEventHandlerRegion(touchHandlerRegion); | 3942 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
3943 | 3943 |
3944 std::vector<LayerImpl*> renderSurfaceLayerList; | 3944 std::vector<LayerImpl*> renderSurfaceLayerList; |
3945 int dummyMaxTextureSize = 512; | 3945 int dummyMaxTextureSize = 512; |
3946 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3946 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
3947 | 3947 |
3948 // Sanity check the scenario we just created. | 3948 // Sanity check the scenario we just created. |
3949 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3949 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3950 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 3950 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
3951 | 3951 |
3952 // Hit checking for a point outside the layer should return a null pointer. | 3952 // Hit checking for a point outside the layer should return a null pointer. |
3953 gfx::Point testPoint(49, 49); | 3953 gfx::Point testPoint(49, 49); |
3954 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3954 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
3955 EXPECT_FALSE(resultLayer); | 3955 EXPECT_FALSE(resultLayer); |
3956 | 3956 |
3957 // Even though the layer has a touch handler region containing (101, 101), i
t should not be visible there since the root renderSurface would clamp it. | 3957 // Even though the layer has a touch handler region containing (101, 101), i
t should not be visible there since the root renderSurface would clamp it. |
3958 testPoint = gfx::Point(101, 101); | 3958 testPoint = gfx::Point(101, 101); |
3959 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3959 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3960 EXPECT_FALSE(resultLayer); | 3960 EXPECT_FALSE(resultLayer); |
3961 | 3961 |
3962 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 3962 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
3963 testPoint = gfx::Point(51, 51); | 3963 testPoint = gfx::Point(51, 51); |
3964 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3964 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3965 EXPECT_FALSE(resultLayer); | 3965 EXPECT_FALSE(resultLayer); |
3966 | 3966 |
3967 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. | 3967 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. |
3968 testPoint = gfx::Point(61, 61); | 3968 testPoint = gfx::Point(61, 61); |
3969 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3969 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3970 ASSERT_TRUE(resultLayer); | 3970 ASSERT_TRUE(resultLayer); |
3971 EXPECT_EQ(12345, resultLayer->id()); | 3971 EXPECT_EQ(12345, resultLayer->id()); |
3972 | 3972 |
3973 testPoint = gfx::Point(99, 99); | 3973 testPoint = gfx::Point(99, 99); |
3974 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3974 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3975 ASSERT_TRUE(resultLayer); | 3975 ASSERT_TRUE(resultLayer); |
3976 EXPECT_EQ(12345, resultLayer->id()); | 3976 EXPECT_EQ(12345, resultLayer->id()); |
3977 } | 3977 } |
3978 | 3978 |
3979 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithScaledContents) | 3979 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithScaledContents) |
3980 { | 3980 { |
3981 // A layer's visibleContentRect is actually in the layer's content space. Th
e | 3981 // A layer's visibleContentRect is actually in the layer's content space. Th
e |
3982 // screenSpaceTransform converts from the layer's origin space to screen spa
ce. This | 3982 // screenSpaceTransform converts from the layer's origin space to screen spa
ce. This |
3983 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3983 // test makes sure that hit testing works correctly accounts for the content
s scale. |
3984 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3984 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
(...skipping 23 matching lines...) Expand all Loading... |
4008 testLayer->SetContentBounds(gfx::Size(100, 100)); | 4008 testLayer->SetContentBounds(gfx::Size(100, 100)); |
4009 testLayer->SetContentsScale(2, 2); | 4009 testLayer->SetContentsScale(2, 2); |
4010 | 4010 |
4011 testLayer->SetDrawsContent(true); | 4011 testLayer->SetDrawsContent(true); |
4012 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); | 4012 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); |
4013 root->AddChild(testLayer.Pass()); | 4013 root->AddChild(testLayer.Pass()); |
4014 } | 4014 } |
4015 | 4015 |
4016 std::vector<LayerImpl*> renderSurfaceLayerList; | 4016 std::vector<LayerImpl*> renderSurfaceLayerList; |
4017 int dummyMaxTextureSize = 512; | 4017 int dummyMaxTextureSize = 512; |
4018 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 4018 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
4019 | 4019 |
4020 // Sanity check the scenario we just created. | 4020 // Sanity check the scenario we just created. |
4021 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 4021 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
4022 LayerImpl* testLayer = root->children()[0]; | 4022 LayerImpl* testLayer = root->children()[0]; |
4023 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
ble_content_rect()); | 4023 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
ble_content_rect()); |
4024 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 4024 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
4025 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4025 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
4026 | 4026 |
4027 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). | 4027 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). |
4028 gfx::Point testPoint(76, 76); | 4028 gfx::Point testPoint(76, 76); |
4029 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 4029 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
4030 EXPECT_FALSE(resultLayer); | 4030 EXPECT_FALSE(resultLayer); |
4031 | 4031 |
4032 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 4032 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
4033 testPoint = gfx::Point(26, 26); | 4033 testPoint = gfx::Point(26, 26); |
4034 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4034 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4035 EXPECT_FALSE(resultLayer); | 4035 EXPECT_FALSE(resultLayer); |
4036 | 4036 |
4037 testPoint = gfx::Point(34, 34); | 4037 testPoint = gfx::Point(34, 34); |
4038 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4038 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4039 EXPECT_FALSE(resultLayer); | 4039 EXPECT_FALSE(resultLayer); |
4040 | 4040 |
4041 testPoint = gfx::Point(65, 65); | 4041 testPoint = gfx::Point(65, 65); |
4042 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4042 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4043 EXPECT_FALSE(resultLayer); | 4043 EXPECT_FALSE(resultLayer); |
4044 | 4044 |
4045 testPoint = gfx::Point(74, 74); | 4045 testPoint = gfx::Point(74, 74); |
4046 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4046 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4047 EXPECT_FALSE(resultLayer); | 4047 EXPECT_FALSE(resultLayer); |
4048 | 4048 |
4049 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. | 4049 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. |
4050 testPoint = gfx::Point(35, 35); | 4050 testPoint = gfx::Point(35, 35); |
4051 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4051 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4052 ASSERT_TRUE(resultLayer); | 4052 ASSERT_TRUE(resultLayer); |
4053 EXPECT_EQ(12345, resultLayer->id()); | 4053 EXPECT_EQ(12345, resultLayer->id()); |
4054 | 4054 |
4055 testPoint = gfx::Point(64, 64); | 4055 testPoint = gfx::Point(64, 64); |
4056 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4056 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4057 ASSERT_TRUE(resultLayer); | 4057 ASSERT_TRUE(resultLayer); |
4058 EXPECT_EQ(12345, resultLayer->id()); | 4058 EXPECT_EQ(12345, resultLayer->id()); |
4059 } | 4059 } |
4060 | 4060 |
4061 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) | 4061 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) |
4062 { | 4062 { |
4063 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should | 4063 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should |
4064 // be able to hit the touch handler region by scaling the points accordingly
. | 4064 // be able to hit the touch handler region by scaling the points accordingly
. |
4065 FakeImplProxy proxy; | 4065 FakeImplProxy proxy; |
4066 FakeLayerTreeHostImpl hostImpl(&proxy); | 4066 FakeLayerTreeHostImpl hostImpl(&proxy); |
(...skipping 17 matching lines...) Expand all Loading... |
4084 } | 4084 } |
4085 | 4085 |
4086 std::vector<LayerImpl*> renderSurfaceLayerList; | 4086 std::vector<LayerImpl*> renderSurfaceLayerList; |
4087 int dummyMaxTextureSize = 512; | 4087 int dummyMaxTextureSize = 512; |
4088 float deviceScaleFactor = 3.0f; | 4088 float deviceScaleFactor = 3.0f; |
4089 float pageScaleFactor = 5.0f; | 4089 float pageScaleFactor = 5.0f; |
4090 gfx::Transform pageScaleTransform; | 4090 gfx::Transform pageScaleTransform; |
4091 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); | 4091 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); |
4092 root->SetImplTransform(pageScaleTransform); // Applying the pageScaleFactor
through implTransform. | 4092 root->SetImplTransform(pageScaleTransform); // Applying the pageScaleFactor
through implTransform. |
4093 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound
s(), deviceScaleFactor * pageScaleFactor)); | 4093 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound
s(), deviceScaleFactor * pageScaleFactor)); |
4094 LayerTreeHostCommon::calculateDrawProperties(root.get(), scaledBoundsForRoot
, deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, fals
e); | 4094 LayerTreeHostCommon::CalculateDrawProperties(root.get(), scaledBoundsForRoot
, deviceScaleFactor, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, fal
se); |
4095 | 4095 |
4096 // Sanity check the scenario we just created. | 4096 // Sanity check the scenario we just created. |
4097 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 4097 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
4098 LayerImpl* testLayer = root->children()[0]; | 4098 LayerImpl* testLayer = root->children()[0]; |
4099 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 4099 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
4100 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4100 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
4101 | 4101 |
4102 // Check whether the child layer fits into the root after scaled. | 4102 // Check whether the child layer fits into the root after scaled. |
4103 EXPECT_RECT_EQ(gfx::Rect(testLayer->content_bounds()), testLayer->visible_co
ntent_rect());; | 4103 EXPECT_RECT_EQ(gfx::Rect(testLayer->content_bounds()), testLayer->visible_co
ntent_rect());; |
4104 | 4104 |
4105 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). | 4105 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). |
4106 gfx::PointF testPoint(76, 76); | 4106 gfx::PointF testPoint(76, 76); |
4107 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4107 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4108 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 4108 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
4109 EXPECT_FALSE(resultLayer); | 4109 EXPECT_FALSE(resultLayer); |
4110 | 4110 |
4111 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 4111 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
4112 testPoint = gfx::Point(26, 26); | 4112 testPoint = gfx::Point(26, 26); |
4113 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4113 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4114 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4114 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4115 EXPECT_FALSE(resultLayer); | 4115 EXPECT_FALSE(resultLayer); |
4116 | 4116 |
4117 testPoint = gfx::Point(34, 34); | 4117 testPoint = gfx::Point(34, 34); |
4118 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4118 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4119 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4119 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4120 EXPECT_FALSE(resultLayer); | 4120 EXPECT_FALSE(resultLayer); |
4121 | 4121 |
4122 testPoint = gfx::Point(65, 65); | 4122 testPoint = gfx::Point(65, 65); |
4123 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4123 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4124 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4124 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4125 EXPECT_FALSE(resultLayer); | 4125 EXPECT_FALSE(resultLayer); |
4126 | 4126 |
4127 testPoint = gfx::Point(74, 74); | 4127 testPoint = gfx::Point(74, 74); |
4128 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4128 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4129 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4129 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4130 EXPECT_FALSE(resultLayer); | 4130 EXPECT_FALSE(resultLayer); |
4131 | 4131 |
4132 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. | 4132 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. |
4133 testPoint = gfx::Point(35, 35); | 4133 testPoint = gfx::Point(35, 35); |
4134 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4134 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4135 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4135 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4136 ASSERT_TRUE(resultLayer); | 4136 ASSERT_TRUE(resultLayer); |
4137 EXPECT_EQ(12345, resultLayer->id()); | 4137 EXPECT_EQ(12345, resultLayer->id()); |
4138 | 4138 |
4139 testPoint = gfx::Point(64, 64); | 4139 testPoint = gfx::Point(64, 64); |
4140 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4140 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
4141 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4141 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4142 ASSERT_TRUE(resultLayer); | 4142 ASSERT_TRUE(resultLayer); |
4143 EXPECT_EQ(12345, resultLayer->id()); | 4143 EXPECT_EQ(12345, resultLayer->id()); |
4144 } | 4144 } |
4145 | 4145 |
4146 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) | 4146 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) |
4147 { | 4147 { |
4148 // Test that hit-checking will only work for the visible portion of a layer,
and not | 4148 // Test that hit-checking will only work for the visible portion of a layer,
and not |
4149 // the entire layer bounds. Here we just test the simple axis-aligned case. | 4149 // the entire layer bounds. Here we just test the simple axis-aligned case. |
4150 gfx::Transform identityMatrix; | 4150 gfx::Transform identityMatrix; |
4151 gfx::PointF anchor(0, 0); | 4151 gfx::PointF anchor(0, 0); |
(...skipping 16 matching lines...) Expand all Loading... |
4168 bounds = gfx::Size(300, 300); | 4168 bounds = gfx::Size(300, 300); |
4169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 4169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
4170 child->SetDrawsContent(true); | 4170 child->SetDrawsContent(true); |
4171 child->SetTouchEventHandlerRegion(touchHandlerRegion); | 4171 child->SetTouchEventHandlerRegion(touchHandlerRegion); |
4172 clippingLayer->AddChild(child.Pass()); | 4172 clippingLayer->AddChild(child.Pass()); |
4173 root->AddChild(clippingLayer.Pass()); | 4173 root->AddChild(clippingLayer.Pass()); |
4174 } | 4174 } |
4175 | 4175 |
4176 std::vector<LayerImpl*> renderSurfaceLayerList; | 4176 std::vector<LayerImpl*> renderSurfaceLayerList; |
4177 int dummyMaxTextureSize = 512; | 4177 int dummyMaxTextureSize = 512; |
4178 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 4178 LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); |
4179 | 4179 |
4180 // Sanity check the scenario we just created. | 4180 // Sanity check the scenario we just created. |
4181 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 4181 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
4182 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 4182 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
4183 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); | 4183 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
4184 | 4184 |
4185 // Hit checking for a point outside the layer should return a null pointer. | 4185 // Hit checking for a point outside the layer should return a null pointer. |
4186 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 4186 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
4187 gfx::Point testPoint(24, 24); | 4187 gfx::Point testPoint(24, 24); |
4188 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 4188 LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
4189 EXPECT_FALSE(resultLayer); | 4189 EXPECT_FALSE(resultLayer); |
4190 | 4190 |
4191 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 4191 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
4192 testPoint = gfx::Point(35, 35); | 4192 testPoint = gfx::Point(35, 35); |
4193 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4193 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4194 EXPECT_FALSE(resultLayer); | 4194 EXPECT_FALSE(resultLayer); |
4195 | 4195 |
4196 testPoint = gfx::Point(74, 74); | 4196 testPoint = gfx::Point(74, 74); |
4197 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4197 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4198 EXPECT_FALSE(resultLayer); | 4198 EXPECT_FALSE(resultLayer); |
4199 | 4199 |
4200 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. | 4200 // Hit checking for a point inside the touch event handler region should ret
urn the root layer. |
4201 testPoint = gfx::Point(25, 25); | 4201 testPoint = gfx::Point(25, 25); |
4202 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4202 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4203 ASSERT_TRUE(resultLayer); | 4203 ASSERT_TRUE(resultLayer); |
4204 EXPECT_EQ(456, resultLayer->id()); | 4204 EXPECT_EQ(456, resultLayer->id()); |
4205 | 4205 |
4206 testPoint = gfx::Point(34, 34); | 4206 testPoint = gfx::Point(34, 34); |
4207 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4207 resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
4208 ASSERT_TRUE(resultLayer); | 4208 ASSERT_TRUE(resultLayer); |
4209 EXPECT_EQ(456, resultLayer->id()); | 4209 EXPECT_EQ(456, resultLayer->id()); |
4210 } | 4210 } |
4211 | 4211 |
4212 class NoScaleContentLayer : public ContentLayer | 4212 class NoScaleContentLayer : public ContentLayer |
4213 { | 4213 { |
4214 public: | 4214 public: |
4215 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } | 4215 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } |
4216 | 4216 |
4217 virtual void CalculateContentsScale( | 4217 virtual void CalculateContentsScale( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4263 parent->AddChild(child); | 4263 parent->AddChild(child); |
4264 parent->AddChild(childEmpty); | 4264 parent->AddChild(childEmpty); |
4265 parent->AddChild(childNoScale); | 4265 parent->AddChild(childNoScale); |
4266 | 4266 |
4267 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4267 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4268 int dummyMaxTextureSize = 512; | 4268 int dummyMaxTextureSize = 512; |
4269 | 4269 |
4270 const double deviceScaleFactor = 2.5; | 4270 const double deviceScaleFactor = 2.5; |
4271 const double pageScaleFactor = 1; | 4271 const double pageScaleFactor = 1; |
4272 | 4272 |
4273 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4273 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4274 | 4274 |
4275 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4275 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
4276 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 4276 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
4277 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 4277 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
4278 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4278 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4279 | 4279 |
4280 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 4280 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
4281 | 4281 |
4282 // Verify parent transforms | 4282 // Verify parent transforms |
4283 gfx::Transform expectedParentTransform; | 4283 gfx::Transform expectedParentTransform; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4358 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4358 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4359 int dummyMaxTextureSize = 512; | 4359 int dummyMaxTextureSize = 512; |
4360 | 4360 |
4361 const double deviceScaleFactor = 2.5; | 4361 const double deviceScaleFactor = 2.5; |
4362 const double pageScaleFactor = 3; | 4362 const double pageScaleFactor = 3; |
4363 | 4363 |
4364 gfx::Transform pageScaleTransform; | 4364 gfx::Transform pageScaleTransform; |
4365 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); | 4365 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); |
4366 parent->SetImplTransform(pageScaleTransform); | 4366 parent->SetImplTransform(pageScaleTransform); |
4367 | 4367 |
4368 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4368 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4369 | 4369 |
4370 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4370 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
4371 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, perspectiveSur
face); | 4371 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, perspectiveSur
face); |
4372 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, scaleSurface); | 4372 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, scaleSurface); |
4373 | 4373 |
4374 EXPECT_EQ(3u, renderSurfaceLayerList.size()); | 4374 EXPECT_EQ(3u, renderSurfaceLayerList.size()); |
4375 | 4375 |
4376 gfx::Transform expectedParentDrawTransform; | 4376 gfx::Transform expectedParentDrawTransform; |
4377 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->draw_tr
ansform()); | 4377 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->draw_tr
ansform()); |
4378 | 4378 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4417 | 4417 |
4418 parent->AddChild(child); | 4418 parent->AddChild(child); |
4419 parent->AddChild(childNoScale); | 4419 parent->AddChild(childNoScale); |
4420 | 4420 |
4421 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4421 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4422 int dummyMaxTextureSize = 512; | 4422 int dummyMaxTextureSize = 512; |
4423 | 4423 |
4424 const float deviceScaleFactor = 1.7f; | 4424 const float deviceScaleFactor = 1.7f; |
4425 const float pageScaleFactor = 1; | 4425 const float pageScaleFactor = 1; |
4426 | 4426 |
4427 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4427 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4428 | 4428 |
4429 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4429 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
4430 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 4430 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
4431 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4431 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4432 | 4432 |
4433 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 4433 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
4434 | 4434 |
4435 // Verify parent transforms | 4435 // Verify parent transforms |
4436 gfx::Transform expectedParentTransform; | 4436 gfx::Transform expectedParentTransform; |
4437 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); | 4437 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4522 int dummyMaxTextureSize = 512; | 4522 int dummyMaxTextureSize = 512; |
4523 | 4523 |
4524 double deviceScaleFactor = 2.5; | 4524 double deviceScaleFactor = 2.5; |
4525 double pageScaleFactor = 1.5; | 4525 double pageScaleFactor = 1.5; |
4526 | 4526 |
4527 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4527 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4528 gfx::Transform pageScaleMatrix; | 4528 gfx::Transform pageScaleMatrix; |
4529 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4529 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
4530 parent->SetSublayerTransform(pageScaleMatrix); | 4530 parent->SetSublayerTransform(pageScaleMatrix); |
4531 | 4531 |
4532 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4532 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4533 | 4533 |
4534 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4534 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4535 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4535 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
4536 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4536 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
4537 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4537 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4538 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4538 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
4539 | 4539 |
4540 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should | 4540 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should |
4541 // also not need to scale during draw. This shouldn't change if the child ha
s empty bounds. The other children should. | 4541 // also not need to scale during draw. This shouldn't change if the child ha
s empty bounds. The other children should. |
4542 EXPECT_FLOAT_EQ(1, parent->draw_transform().matrix().getDouble(0, 0)); | 4542 EXPECT_FLOAT_EQ(1, parent->draw_transform().matrix().getDouble(0, 0)); |
(...skipping 10 matching lines...) Expand all Loading... |
4553 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated using the initial transform as the rasterScale. | 4553 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated using the initial transform as the rasterScale. |
4554 deviceScaleFactor = 2.25; | 4554 deviceScaleFactor = 2.25; |
4555 pageScaleFactor = 1.25; | 4555 pageScaleFactor = 1.25; |
4556 | 4556 |
4557 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4557 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4558 pageScaleMatrix = identityMatrix; | 4558 pageScaleMatrix = identityMatrix; |
4559 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4559 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
4560 parent->SetSublayerTransform(pageScaleMatrix); | 4560 parent->SetSublayerTransform(pageScaleMatrix); |
4561 | 4561 |
4562 renderSurfaceLayerList.clear(); | 4562 renderSurfaceLayerList.clear(); |
4563 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4563 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4564 | 4564 |
4565 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4565 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4566 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4566 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
4567 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4567 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
4568 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4568 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4569 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4569 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
4570 | 4570 |
4571 // If the transform changes, we expect the rasterScale to be reset to 1.0. | 4571 // If the transform changes, we expect the rasterScale to be reset to 1.0. |
4572 const double secondChildScale = 1.75; | 4572 const double secondChildScale = 1.75; |
4573 childScaleMatrix.Scale(secondChildScale / initialChildScale, secondChildScal
e / initialChildScale); | 4573 childScaleMatrix.Scale(secondChildScale / initialChildScale, secondChildScal
e / initialChildScale); |
4574 childScale->SetTransform(childScaleMatrix); | 4574 childScale->SetTransform(childScaleMatrix); |
4575 childEmpty->SetTransform(childScaleMatrix); | 4575 childEmpty->SetTransform(childScaleMatrix); |
4576 | 4576 |
4577 renderSurfaceLayerList.clear(); | 4577 renderSurfaceLayerList.clear(); |
4578 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4578 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4579 | 4579 |
4580 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4580 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4581 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); | 4581 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); |
4582 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 4582 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
4583 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4583 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4584 | 4584 |
4585 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated, but still using 1.0 as the rasterScale. | 4585 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated, but still using 1.0 as the rasterScale. |
4586 deviceScaleFactor = 2.75; | 4586 deviceScaleFactor = 2.75; |
4587 pageScaleFactor = 1.75; | 4587 pageScaleFactor = 1.75; |
4588 | 4588 |
4589 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4589 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4590 pageScaleMatrix = identityMatrix; | 4590 pageScaleMatrix = identityMatrix; |
4591 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4591 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
4592 parent->SetSublayerTransform(pageScaleMatrix); | 4592 parent->SetSublayerTransform(pageScaleMatrix); |
4593 | 4593 |
4594 renderSurfaceLayerList.clear(); | 4594 renderSurfaceLayerList.clear(); |
4595 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4595 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4596 | 4596 |
4597 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4597 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4598 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); | 4598 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); |
4599 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 4599 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
4600 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4600 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4601 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4601 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
4602 } | 4602 } |
4603 | 4603 |
4604 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) | 4604 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) |
4605 { | 4605 { |
(...skipping 24 matching lines...) Expand all Loading... |
4630 int dummyMaxTextureSize = 512; | 4630 int dummyMaxTextureSize = 512; |
4631 | 4631 |
4632 double deviceScaleFactor = 2.5; | 4632 double deviceScaleFactor = 2.5; |
4633 double pageScaleFactor = 0.01; | 4633 double pageScaleFactor = 0.01; |
4634 | 4634 |
4635 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4635 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4636 gfx::Transform pageScaleMatrix; | 4636 gfx::Transform pageScaleMatrix; |
4637 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4637 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
4638 parent->SetSublayerTransform(pageScaleMatrix); | 4638 parent->SetSublayerTransform(pageScaleMatrix); |
4639 | 4639 |
4640 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4640 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4641 | 4641 |
4642 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4642 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4643 // The child's scale is < 1, so we should not save and use that scale factor
. | 4643 // The child's scale is < 1, so we should not save and use that scale factor
. |
4644 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); | 4644 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); |
4645 | 4645 |
4646 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. | 4646 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. |
4647 childScaleMatrix.MakeIdentity(); | 4647 childScaleMatrix.MakeIdentity(); |
4648 const double finalChildScale = 0.75; | 4648 const double finalChildScale = 0.75; |
4649 childScaleMatrix.Scale(finalChildScale, finalChildScale); | 4649 childScaleMatrix.Scale(finalChildScale, finalChildScale); |
4650 childScale->SetTransform(childScaleMatrix); | 4650 childScale->SetTransform(childScaleMatrix); |
4651 | 4651 |
4652 renderSurfaceLayerList.clear(); | 4652 renderSurfaceLayerList.clear(); |
4653 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4653 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4654 | 4654 |
4655 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4655 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4656 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); | 4656 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); |
4657 } | 4657 } |
4658 | 4658 |
4659 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) | 4659 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
4660 { | 4660 { |
4661 MockContentLayerClient delegate; | 4661 MockContentLayerClient delegate; |
4662 gfx::Transform identityMatrix; | 4662 gfx::Transform identityMatrix; |
4663 | 4663 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4727 int dummyMaxTextureSize = 512; | 4727 int dummyMaxTextureSize = 512; |
4728 | 4728 |
4729 double deviceScaleFactor = 5; | 4729 double deviceScaleFactor = 5; |
4730 double pageScaleFactor = 7; | 4730 double pageScaleFactor = 7; |
4731 | 4731 |
4732 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4732 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4733 gfx::Transform pageScaleMatrix; | 4733 gfx::Transform pageScaleMatrix; |
4734 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4734 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
4735 parent->SetSublayerTransform(pageScaleMatrix); | 4735 parent->SetSublayerTransform(pageScaleMatrix); |
4736 | 4736 |
4737 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4737 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceL
ayerList); |
4738 | 4738 |
4739 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4739 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4740 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, surfaceScale); | 4740 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, surfaceScale); |
4741 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); | 4741 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); |
4742 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, surfaceNoAutoScale); | 4742 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, surfaceNoAutoScale); |
4743 | 4743 |
4744 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); | 4744 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); |
4745 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); | 4745 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); |
4746 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); | 4746 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); |
4747 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); | 4747 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4821 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4821 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4822 | 4822 |
4823 parent->AddChild(childScale); | 4823 parent->AddChild(childScale); |
4824 | 4824 |
4825 // Now put an animating transform on child. | 4825 // Now put an animating transform on child. |
4826 int animationId = addAnimatedTransformToController(*childScale->layer_animat
ion_controller(), 10, 30, 0); | 4826 int animationId = addAnimatedTransformToController(*childScale->layer_animat
ion_controller(), 10, 30, 0); |
4827 | 4827 |
4828 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4828 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4829 int dummyMaxTextureSize = 512; | 4829 int dummyMaxTextureSize = 512; |
4830 | 4830 |
4831 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4831 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
4832 | 4832 |
4833 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4833 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
4834 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. | 4834 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. |
4835 EXPECT_CONTENTS_SCALE_EQ(1, childScale); | 4835 EXPECT_CONTENTS_SCALE_EQ(1, childScale); |
4836 | 4836 |
4837 // Remove the animation, now it can save a raster scale. | 4837 // Remove the animation, now it can save a raster scale. |
4838 childScale->layer_animation_controller()->RemoveAnimation(animationId); | 4838 childScale->layer_animation_controller()->RemoveAnimation(animationId); |
4839 | 4839 |
4840 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4840 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
4841 | 4841 |
4842 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4842 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
4843 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. | 4843 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. |
4844 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale)
; | 4844 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale)
; |
4845 } | 4845 } |
4846 | 4846 |
4847 | 4847 |
4848 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 4848 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
4849 { | 4849 { |
4850 MockContentLayerClient delegate; | 4850 MockContentLayerClient delegate; |
(...skipping 16 matching lines...) Expand all Loading... |
4867 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); | 4867 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); |
4868 | 4868 |
4869 parent->AddChild(child); | 4869 parent->AddChild(child); |
4870 child->AddChild(duplicateChildNonOwner); | 4870 child->AddChild(duplicateChildNonOwner); |
4871 child->SetReplicaLayer(replica.get()); | 4871 child->SetReplicaLayer(replica.get()); |
4872 | 4872 |
4873 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4873 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4874 int dummyMaxTextureSize = 512; | 4874 int dummyMaxTextureSize = 512; |
4875 | 4875 |
4876 const double deviceScaleFactor = 1.5; | 4876 const double deviceScaleFactor = 1.5; |
4877 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4877 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
4878 | 4878 |
4879 // We should have two render surfaces. The root's render surface and child's | 4879 // We should have two render surfaces. The root's render surface and child's |
4880 // render surface (it needs one because it has a replica layer). | 4880 // render surface (it needs one because it has a replica layer). |
4881 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4881 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4882 | 4882 |
4883 gfx::Transform expectedParentTransform; | 4883 gfx::Transform expectedParentTransform; |
4884 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); | 4884 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); |
4885 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->draw_transf
orm()); | 4885 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->draw_transf
orm()); |
4886 | 4886 |
4887 gfx::Transform expectedDrawTransform; | 4887 gfx::Transform expectedDrawTransform; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4945 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4945 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
4946 | 4946 |
4947 parent->AddChild(child); | 4947 parent->AddChild(child); |
4948 child->AddChild(duplicateChildNonOwner); | 4948 child->AddChild(duplicateChildNonOwner); |
4949 child->SetReplicaLayer(replica.get()); | 4949 child->SetReplicaLayer(replica.get()); |
4950 | 4950 |
4951 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4951 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4952 int dummyMaxTextureSize = 512; | 4952 int dummyMaxTextureSize = 512; |
4953 | 4953 |
4954 const float deviceScaleFactor = 1.7f; | 4954 const float deviceScaleFactor = 1.7f; |
4955 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4955 LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); |
4956 | 4956 |
4957 // We should have two render surfaces. The root's render surface and child's | 4957 // We should have two render surfaces. The root's render surface and child's |
4958 // render surface (it needs one because it has a replica layer). | 4958 // render surface (it needs one because it has a replica layer). |
4959 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4959 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4960 | 4960 |
4961 gfx::Transform identityTransform; | 4961 gfx::Transform identityTransform; |
4962 | 4962 |
4963 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screen_space_tran
sform()); | 4963 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screen_space_tran
sform()); |
4964 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->draw_transform())
; | 4964 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->draw_transform())
; |
4965 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->draw_transform()); | 4965 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->draw_transform()); |
(...skipping 23 matching lines...) Expand all Loading... |
4989 scoped_refptr<Layer> grandChild = Layer::Create(); | 4989 scoped_refptr<Layer> grandChild = Layer::Create(); |
4990 scoped_refptr<Layer> maskLayer = Layer::Create(); | 4990 scoped_refptr<Layer> maskLayer = Layer::Create(); |
4991 scoped_refptr<Layer> replicaLayer = Layer::Create(); | 4991 scoped_refptr<Layer> replicaLayer = Layer::Create(); |
4992 | 4992 |
4993 grandChild->SetReplicaLayer(replicaLayer.get()); | 4993 grandChild->SetReplicaLayer(replicaLayer.get()); |
4994 child->AddChild(grandChild.get()); | 4994 child->AddChild(grandChild.get()); |
4995 child->SetMaskLayer(maskLayer.get()); | 4995 child->SetMaskLayer(maskLayer.get()); |
4996 root->AddChild(child.get()); | 4996 root->AddChild(child.get()); |
4997 | 4997 |
4998 int nonexistentId = -1; | 4998 int nonexistentId = -1; |
4999 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); | 4999 EXPECT_EQ(root, LayerTreeHostCommon::FindLayerInSubtree(root.get(), root->id
())); |
5000 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); | 5000 EXPECT_EQ(child, LayerTreeHostCommon::FindLayerInSubtree(root.get(), child->
id())); |
5001 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); | 5001 EXPECT_EQ(grandChild, LayerTreeHostCommon::FindLayerInSubtree(root.get(), gr
andChild->id())); |
5002 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); | 5002 EXPECT_EQ(maskLayer, LayerTreeHostCommon::FindLayerInSubtree(root.get(), mas
kLayer->id())); |
5003 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); | 5003 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::FindLayerInSubtree(root.get(),
replicaLayer->id())); |
5004 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); | 5004 EXPECT_EQ(0, LayerTreeHostCommon::FindLayerInSubtree(root.get(), nonexistent
Id)); |
5005 } | 5005 } |
5006 | 5006 |
5007 TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation) | 5007 TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation) |
5008 { | 5008 { |
5009 scoped_refptr<Layer> root = Layer::Create(); | 5009 scoped_refptr<Layer> root = Layer::Create(); |
5010 scoped_refptr<Layer> child = Layer::Create(); | 5010 scoped_refptr<Layer> child = Layer::Create(); |
5011 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 5011 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
5012 | 5012 |
5013 const gfx::Transform identityMatrix; | 5013 const gfx::Transform identityMatrix; |
5014 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 5014 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); | 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
5143 } | 5143 } |
5144 | 5144 |
5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
5146 LCDTextTest, | 5146 LCDTextTest, |
5147 testing::Combine(testing::Bool(), | 5147 testing::Combine(testing::Bool(), |
5148 testing::Bool())); | 5148 testing::Bool())); |
5149 | 5149 |
5150 } // namespace | 5150 } // namespace |
5151 } // namespace cc | 5151 } // namespace cc |
OLD | NEW |