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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2721743003: Remove unused utility methods. (Closed)
Patch Set: names Created 3 years, 9 months 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
« no previous file with comments | « cc/base/math_util.cc ('k') | no next file » | 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 "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 2959
2960 gfx::Rect expected_visible_layer_rect = gfx::Rect(0, 1, 10, 1); 2960 gfx::Rect expected_visible_layer_rect = gfx::Rect(0, 1, 10, 1);
2961 gfx::Rect expected_drawable_content_rect = target_surface_rect; 2961 gfx::Rect expected_drawable_content_rect = target_surface_rect;
2962 LayerImpl* drawing_layer = TestVisibleRectAndDrawableContentRect( 2962 LayerImpl* drawing_layer = TestVisibleRectAndDrawableContentRect(
2963 target_surface_rect, layer_to_surface_transform, layer_content_rect); 2963 target_surface_rect, layer_to_surface_transform, layer_content_rect);
2964 EXPECT_EQ(expected_visible_layer_rect, drawing_layer->visible_layer_rect()); 2964 EXPECT_EQ(expected_visible_layer_rect, drawing_layer->visible_layer_rect());
2965 EXPECT_EQ(expected_drawable_content_rect, 2965 EXPECT_EQ(expected_drawable_content_rect,
2966 drawing_layer->drawable_content_rect()); 2966 drawing_layer->drawable_content_rect());
2967 } 2967 }
2968 2968
2969 static bool ProjectionClips(const gfx::Transform& map_transform,
2970 const gfx::RectF& mapped_rect) {
2971 gfx::Transform inverse(Inverse(map_transform));
2972 bool clipped = false;
2973 if (!clipped)
2974 MathUtil::ProjectPoint(inverse, mapped_rect.top_right(), &clipped);
2975 if (!clipped)
2976 MathUtil::ProjectPoint(inverse, mapped_rect.origin(), &clipped);
2977 if (!clipped)
2978 MathUtil::ProjectPoint(inverse, mapped_rect.bottom_right(), &clipped);
2979 if (!clipped)
2980 MathUtil::ProjectPoint(inverse, mapped_rect.bottom_left(), &clipped);
2981 return clipped;
2982 }
2983
2969 TEST_F(LayerTreeHostCommonDrawRectsTest, DrawRectsForPerspectiveUnprojection) { 2984 TEST_F(LayerTreeHostCommonDrawRectsTest, DrawRectsForPerspectiveUnprojection) {
2970 // To determine visible rect in layer space, there needs to be an 2985 // To determine visible rect in layer space, there needs to be an
2971 // un-projection from surface space to layer space. When the original 2986 // un-projection from surface space to layer space. When the original
2972 // transform was a perspective projection that was clipped, it returns a rect 2987 // transform was a perspective projection that was clipped, it returns a rect
2973 // that encloses the clipped bounds. Un-projecting this new rect may require 2988 // that encloses the clipped bounds. Un-projecting this new rect may require
2974 // clipping again. 2989 // clipping again.
2975 2990
2976 // This sequence of transforms causes one corner of the layer to protrude 2991 // This sequence of transforms causes one corner of the layer to protrude
2977 // across the w = 0 plane, and should be clipped. 2992 // across the w = 0 plane, and should be clipped.
2978 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 150, 150); 2993 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 150, 150);
2979 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 20, 20); 2994 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 20, 20);
2980 gfx::Transform layer_to_surface_transform; 2995 gfx::Transform layer_to_surface_transform;
2981 layer_to_surface_transform.MakeIdentity(); 2996 layer_to_surface_transform.MakeIdentity();
2982 layer_to_surface_transform.Translate(10, 10); 2997 layer_to_surface_transform.Translate(10, 10);
2983 layer_to_surface_transform.ApplyPerspectiveDepth(1.0); 2998 layer_to_surface_transform.ApplyPerspectiveDepth(1.0);
2984 layer_to_surface_transform.Translate3d(0.0, 0.0, -5.0); 2999 layer_to_surface_transform.Translate3d(0.0, 0.0, -5.0);
2985 layer_to_surface_transform.RotateAboutYAxis(45.0); 3000 layer_to_surface_transform.RotateAboutYAxis(45.0);
2986 layer_to_surface_transform.RotateAboutXAxis(80.0); 3001 layer_to_surface_transform.RotateAboutXAxis(80.0);
2987 layer_to_surface_transform.Translate(-10, -10); 3002 layer_to_surface_transform.Translate(-10, -10);
2988 3003
2989 // Sanity check that un-projection does indeed cause w < 0, otherwise this 3004 // Sanity check that un-projection does indeed cause w < 0, otherwise this
2990 // code is not testing the intended scenario. 3005 // code is not testing the intended scenario.
2991 bool clipped;
2992 gfx::RectF clipped_rect = MathUtil::MapClippedRect( 3006 gfx::RectF clipped_rect = MathUtil::MapClippedRect(
2993 layer_to_surface_transform, gfx::RectF(layer_content_rect)); 3007 layer_to_surface_transform, gfx::RectF(layer_content_rect));
2994 MathUtil::ProjectQuad( 3008 ASSERT_TRUE(ProjectionClips(layer_to_surface_transform, clipped_rect));
2995 Inverse(layer_to_surface_transform), gfx::QuadF(clipped_rect), &clipped);
2996 ASSERT_TRUE(clipped);
2997 3009
2998 // Only the corner of the layer is not visible on the surface because of being 3010 // Only the corner of the layer is not visible on the surface because of being
2999 // clipped. But, the net result of rounding visible region to an axis-aligned 3011 // clipped. But, the net result of rounding visible region to an axis-aligned
3000 // rect is that the entire layer should still be considered visible. 3012 // rect is that the entire layer should still be considered visible.
3001 gfx::Rect expected_visible_layer_rect = layer_content_rect; 3013 gfx::Rect expected_visible_layer_rect = layer_content_rect;
3002 gfx::Rect expected_drawable_content_rect = target_surface_rect; 3014 gfx::Rect expected_drawable_content_rect = target_surface_rect;
3003 LayerImpl* drawing_layer = TestVisibleRectAndDrawableContentRect( 3015 LayerImpl* drawing_layer = TestVisibleRectAndDrawableContentRect(
3004 target_surface_rect, layer_to_surface_transform, layer_content_rect); 3016 target_surface_rect, layer_to_surface_transform, layer_content_rect);
3005 EXPECT_EQ(expected_visible_layer_rect, drawing_layer->visible_layer_rect()); 3017 EXPECT_EQ(expected_visible_layer_rect, drawing_layer->visible_layer_rect());
3006 EXPECT_EQ(expected_drawable_content_rect, 3018 EXPECT_EQ(expected_drawable_content_rect,
(...skipping 7759 matching lines...) Expand 10 before | Expand all | Expand 10 after
10766 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10778 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10767 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10779 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10768 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10780 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10769 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10781 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10770 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10782 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10771 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10783 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10772 } 10784 }
10773 10785
10774 } // namespace 10786 } // namespace
10775 } // namespace cc 10787 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698