Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11364044: cc: Replace WebCore::FloatQuad with gfx::QuadF. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reeebase. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_sorter_unittest.cc ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « cc/layer_sorter_unittest.cc ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698