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