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

Side by Side Diff: cc/layers/layer_position_constraint_unittest.cc

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/layer_position_constraint.h" 5 #include "cc/layers/layer_position_constraint.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/layers/layer_impl.h" 9 #include "cc/layers/layer_impl.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
11 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
12 #include "cc/test/geometry_test_utils.h" 12 #include "cc/test/geometry_test_utils.h"
13 #include "cc/test/test_shared_bitmap_manager.h" 13 #include "cc/test/test_shared_bitmap_manager.h"
14 #include "cc/trees/layer_tree_host_common.h" 14 #include "cc/trees/layer_tree_host_common.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace cc { 17 namespace cc {
18 namespace { 18 namespace {
19 19
20 void SetLayerPropertiesForTesting(LayerImpl* layer, 20 void SetLayerPropertiesForTesting(LayerImpl* layer,
21 const gfx::Transform& transform, 21 const gfx::Transform& transform,
22 const gfx::PointF& anchor, 22 const gfx::Point3F& transform_origin,
23 const gfx::PointF& position, 23 const gfx::PointF& position,
24 const gfx::Size& bounds, 24 const gfx::Size& bounds,
25 bool flatten_transform, 25 bool flatten_transform,
26 bool is_3d_sorted) { 26 bool is_3d_sorted) {
27 layer->SetTransform(transform); 27 layer->SetTransform(transform);
28 layer->SetAnchorPoint(anchor); 28 layer->SetTransformOrigin(transform_origin);
29 layer->SetPosition(position); 29 layer->SetPosition(position);
30 layer->SetBounds(bounds); 30 layer->SetBounds(bounds);
31 layer->SetShouldFlattenTransform(flatten_transform); 31 layer->SetShouldFlattenTransform(flatten_transform);
32 layer->SetIs3dSorted(is_3d_sorted); 32 layer->SetIs3dSorted(is_3d_sorted);
33 layer->SetContentBounds(bounds); 33 layer->SetContentBounds(bounds);
34 } 34 }
35 35
36 void ExecuteCalculateDrawProperties(LayerImpl* root_layer, 36 void ExecuteCalculateDrawProperties(LayerImpl* root_layer,
37 float device_scale_factor, 37 float device_scale_factor,
38 float page_scale_factor, 38 float page_scale_factor,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 scoped_ptr<LayerImpl> scroll_layer = 80 scoped_ptr<LayerImpl> scroll_layer =
81 LayerImpl::Create(host_impl_.active_tree(), 1); 81 LayerImpl::Create(host_impl_.active_tree(), 1);
82 scoped_ptr<LayerImpl> child = 82 scoped_ptr<LayerImpl> child =
83 LayerImpl::Create(host_impl_.active_tree(), 2); 83 LayerImpl::Create(host_impl_.active_tree(), 2);
84 scoped_ptr<LayerImpl> grand_child = 84 scoped_ptr<LayerImpl> grand_child =
85 LayerImpl::Create(host_impl_.active_tree(), 3); 85 LayerImpl::Create(host_impl_.active_tree(), 3);
86 scoped_ptr<LayerImpl> great_grand_child = 86 scoped_ptr<LayerImpl> great_grand_child =
87 LayerImpl::Create(host_impl_.active_tree(), 4); 87 LayerImpl::Create(host_impl_.active_tree(), 4);
88 88
89 gfx::Transform IdentityMatrix; 89 gfx::Transform IdentityMatrix;
90 gfx::PointF anchor; 90 gfx::Point3F transform_origin;
91 gfx::PointF position; 91 gfx::PointF position;
92 gfx::Size bounds(200, 200); 92 gfx::Size bounds(200, 200);
93 gfx::Size clip_bounds(100, 100); 93 gfx::Size clip_bounds(100, 100);
94 SetLayerPropertiesForTesting(scroll_layer.get(), 94 SetLayerPropertiesForTesting(scroll_layer.get(),
95 IdentityMatrix, 95 IdentityMatrix,
96 anchor, 96 transform_origin,
97 position, 97 position,
98 bounds, 98 bounds,
99 true, 99 true,
100 false); 100 false);
101 SetLayerPropertiesForTesting(child.get(), 101 SetLayerPropertiesForTesting(child.get(),
102 IdentityMatrix, 102 IdentityMatrix,
103 anchor, 103 transform_origin,
104 position, 104 position,
105 bounds, 105 bounds,
106 true, 106 true,
107 false); 107 false);
108 SetLayerPropertiesForTesting(grand_child.get(), 108 SetLayerPropertiesForTesting(grand_child.get(),
109 IdentityMatrix, 109 IdentityMatrix,
110 anchor, 110 transform_origin,
111 position, 111 position,
112 bounds, 112 bounds,
113 true, 113 true,
114 false); 114 false);
115 SetLayerPropertiesForTesting(great_grand_child.get(), 115 SetLayerPropertiesForTesting(great_grand_child.get(),
116 IdentityMatrix, 116 IdentityMatrix,
117 anchor, 117 transform_origin,
118 position, 118 position,
119 bounds, 119 bounds,
120 true, 120 true,
121 false); 121 false);
122 122
123 root->SetBounds(clip_bounds); 123 root->SetBounds(clip_bounds);
124 scroll_layer->SetScrollClipLayer(root->id()); 124 scroll_layer->SetScrollClipLayer(root->id());
125 child->SetScrollClipLayer(root->id()); 125 child->SetScrollClipLayer(root->id());
126 grand_child->SetScrollClipLayer(root->id()); 126 grand_child->SetScrollClipLayer(root->id());
127 127
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 LayerImpl* grand_child = child->children()[0]; 734 LayerImpl* grand_child = child->children()[0];
735 LayerImpl* great_grand_child = grand_child->children()[0]; 735 LayerImpl* great_grand_child = grand_child->children()[0];
736 736
737 // Add one more layer to the test tree for this scenario. 737 // Add one more layer to the test tree for this scenario.
738 { 738 {
739 gfx::Transform identity; 739 gfx::Transform identity;
740 scoped_ptr<LayerImpl> fixed_position_child = 740 scoped_ptr<LayerImpl> fixed_position_child =
741 LayerImpl::Create(host_impl_.active_tree(), 5); 741 LayerImpl::Create(host_impl_.active_tree(), 5);
742 SetLayerPropertiesForTesting(fixed_position_child.get(), 742 SetLayerPropertiesForTesting(fixed_position_child.get(),
743 identity, 743 identity,
744 gfx::PointF(), 744 gfx::Point3F(),
745 gfx::PointF(), 745 gfx::PointF(),
746 gfx::Size(100, 100), 746 gfx::Size(100, 100),
747 true, 747 true,
748 false); 748 false);
749 great_grand_child->AddChild(fixed_position_child.Pass()); 749 great_grand_child->AddChild(fixed_position_child.Pass());
750 } 750 }
751 LayerImpl* fixed_position_child = great_grand_child->children()[0]; 751 LayerImpl* fixed_position_child = great_grand_child->children()[0];
752 752
753 // Actually set up the scenario here. 753 // Actually set up the scenario here.
754 child->SetIsContainerForFixedPositionLayers(true); 754 child->SetIsContainerForFixedPositionLayers(true);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 fixed_to_container1->draw_transform()); 1163 fixed_to_container1->draw_transform());
1164 1164
1165 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, 1165 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform,
1166 container2->draw_transform()); 1166 container2->draw_transform());
1167 1167
1168 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, 1168 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform,
1169 fixed_to_container2->draw_transform()); 1169 fixed_to_container2->draw_transform());
1170 } 1170 }
1171 } // namespace 1171 } // namespace
1172 } // namespace cc 1172 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698