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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_common.h" | 7 #include "cc/layer_tree_host_common.h" |
8 | 8 |
9 #include "cc/content_layer.h" | 9 #include "cc/content_layer.h" |
10 #include "cc/content_layer_client.h" | 10 #include "cc/content_layer_client.h" |
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 // following sequence of transforms applies the perspective and rotation abo
ut the | 1934 // following sequence of transforms applies the perspective and rotation abo
ut the |
1935 // center of the layer. | 1935 // center of the layer. |
1936 layerToSurfaceTransform.makeIdentity(); | 1936 layerToSurfaceTransform.makeIdentity(); |
1937 layerToSurfaceTransform.applyPerspective(1); | 1937 layerToSurfaceTransform.applyPerspective(1); |
1938 layerToSurfaceTransform.translate3d(-2, 0, 1); | 1938 layerToSurfaceTransform.translate3d(-2, 0, 1); |
1939 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1939 layerToSurfaceTransform.rotate3d(0, 45, 0); |
1940 | 1940 |
1941 // Sanity check that this transform does indeed cause w < 0 when applying th
e | 1941 // Sanity check that this transform does indeed cause w < 0 when applying th
e |
1942 // transform, otherwise this code is not testing the intended scenario. | 1942 // transform, otherwise this code is not testing the intended scenario. |
1943 bool clipped = false; | 1943 bool clipped = false; |
1944 MathUtil::mapQuad(layerToSurfaceTransform, FloatQuad(gfx::RectF(layerContent
Rect)), clipped); | 1944 MathUtil::mapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten
tRect)), clipped); |
1945 ASSERT_TRUE(clipped); | 1945 ASSERT_TRUE(clipped); |
1946 | 1946 |
1947 int expectedXPosition = 0; | 1947 int expectedXPosition = 0; |
1948 int expectedWidth = 10; | 1948 int expectedWidth = 10; |
1949 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1949 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
1950 EXPECT_EQ(expectedXPosition, actual.x()); | 1950 EXPECT_EQ(expectedXPosition, actual.x()); |
1951 EXPECT_EQ(expectedWidth, actual.width()); | 1951 EXPECT_EQ(expectedWidth, actual.width()); |
1952 } | 1952 } |
1953 | 1953 |
1954 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) | 1954 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) |
(...skipping 10 matching lines...) Expand all Loading... |
1965 layerToSurfaceTransform.makeIdentity(); | 1965 layerToSurfaceTransform.makeIdentity(); |
1966 layerToSurfaceTransform.applyPerspective(1); | 1966 layerToSurfaceTransform.applyPerspective(1); |
1967 layerToSurfaceTransform.translate3d(0, 0, -5); | 1967 layerToSurfaceTransform.translate3d(0, 0, -5); |
1968 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1968 layerToSurfaceTransform.rotate3d(0, 45, 0); |
1969 layerToSurfaceTransform.rotate3d(80, 0, 0); | 1969 layerToSurfaceTransform.rotate3d(80, 0, 0); |
1970 | 1970 |
1971 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not | 1971 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not |
1972 // testing the intended scenario. | 1972 // testing the intended scenario. |
1973 bool clipped = false; | 1973 bool clipped = false; |
1974 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l
ayerContentRect); | 1974 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l
ayerContentRect); |
1975 MathUtil::projectQuad(layerToSurfaceTransform.inverse(), FloatQuad(clippedRe
ct), clipped); | 1975 MathUtil::projectQuad(layerToSurfaceTransform.inverse(), gfx::QuadF(clippedR
ect), clipped); |
1976 ASSERT_TRUE(clipped); | 1976 ASSERT_TRUE(clipped); |
1977 | 1977 |
1978 // Only the corner of the layer is not visible on the surface because of bei
ng | 1978 // Only the corner of the layer is not visible on the surface because of bei
ng |
1979 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is | 1979 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is |
1980 // that the entire layer should still be considered visible. | 1980 // that the entire layer should still be considered visible. |
1981 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); | 1981 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); |
1982 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1982 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
1983 EXPECT_RECT_EQ(expected, actual); | 1983 EXPECT_RECT_EQ(expected, actual); |
1984 } | 1984 } |
1985 | 1985 |
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4039 int nonexistentId = -1; | 4039 int nonexistentId = -1; |
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); | 4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); |
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); | 4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); |
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); | 4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); |
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); | 4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); |
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); | 4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); |
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); | 4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); |
4046 } | 4046 } |
4047 | 4047 |
4048 } // namespace | 4048 } // namespace |
OLD | NEW |