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

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

Issue 1159983010: Record root layer's position in its TransformNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 6 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 | « no previous file | cc/trees/property_tree_builder.cc » ('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 "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 2669
2670 // Only the corner of the layer is not visible on the surface because of being 2670 // Only the corner of the layer is not visible on the surface because of being
2671 // clipped. But, the net result of rounding visible region to an axis-aligned 2671 // clipped. But, the net result of rounding visible region to an axis-aligned
2672 // rect is that the entire layer should still be considered visible. 2672 // rect is that the entire layer should still be considered visible.
2673 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20); 2673 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20);
2674 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2674 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2675 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2675 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2676 EXPECT_EQ(expected, actual); 2676 EXPECT_EQ(expected, actual);
2677 } 2677 }
2678 2678
2679 TEST_F(LayerTreeHostCommonTest,
2680 VisibleRectsForPositionedRootLayerClippedByViewport) {
2681 scoped_refptr<Layer> root =
2682 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2683 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2684 host->SetRootLayer(root);
2685
2686 gfx::Transform identity_matrix;
2687 // Root layer is positioned at (60, 70). The default device viewport size
2688 // is (0, 0, 100x100) in target space. So the root layer's visible rect
2689 // will be clipped by the viewport to be (0, 0, 40x30) in layer's space.
2690 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
2691 gfx::PointF(60, 70), gfx::Size(100, 100), true,
2692 false);
2693 ExecuteCalculateDrawProperties(root.get());
2694
2695 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2696 root->render_surface()->DrawableContentRect());
2697 // In target space, not clipped.
2698 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect());
2699 // In layer space, clipped.
2700 EXPECT_EQ(gfx::Rect(0, 0, 40, 30), root->visible_content_rect());
2701 }
2702
2679 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { 2703 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
2680 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 2704 scoped_refptr<Layer> root = Layer::Create(layer_settings());
2681 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2705 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2682 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 2706 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2683 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2707 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2684 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 2708 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2685 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2709 scoped_refptr<LayerWithForcedDrawsContent> child3 =
2686 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); 2710 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings()));
2687 root->AddChild(child1); 2711 root->AddChild(child1);
2688 root->AddChild(child2); 2712 root->AddChild(child2);
(...skipping 6996 matching lines...) Expand 10 before | Expand all | Expand 10 after
9685 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); 9709 EXPECT_FALSE(root->layer_or_descendant_is_drawn());
9686 EXPECT_FALSE(root->visited()); 9710 EXPECT_FALSE(root->visited());
9687 EXPECT_FALSE(root->sorted_for_recursion()); 9711 EXPECT_FALSE(root->sorted_for_recursion());
9688 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); 9712 EXPECT_FALSE(child->layer_or_descendant_is_drawn());
9689 EXPECT_FALSE(child->visited()); 9713 EXPECT_FALSE(child->visited());
9690 EXPECT_FALSE(child->sorted_for_recursion()); 9714 EXPECT_FALSE(child->sorted_for_recursion());
9691 } 9715 }
9692 9716
9693 } // namespace 9717 } // namespace
9694 } // namespace cc 9718 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698