Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 gfx::Size device_viewport_size = | 43 gfx::Size device_viewport_size = |
| 44 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 44 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 45 root_layer->bounds().height() * device_scale_factor); | 45 root_layer->bounds().height() * device_scale_factor); |
| 46 | 46 |
| 47 // We are probably not testing what is intended if the root_layer bounds are | 47 // We are probably not testing what is intended if the root_layer bounds are |
| 48 // empty. | 48 // empty. |
| 49 DCHECK(!root_layer->bounds().IsEmpty()); | 49 DCHECK(!root_layer->bounds().IsEmpty()); |
| 50 LayerTreeHostCommon::CalculateDrawProperties( | 50 LayerTreeHostCommon::CalculateDrawProperties( |
| 51 root_layer, | 51 root_layer, |
| 52 device_viewport_size, | 52 device_viewport_size, |
| 53 gfx::Transform(), | |
| 53 device_scale_factor, | 54 device_scale_factor, |
| 54 page_scale_factor, | 55 page_scale_factor, |
| 55 page_scale_application_layer, | 56 page_scale_application_layer, |
| 56 dummy_max_texture_size, | 57 dummy_max_texture_size, |
| 57 can_use_lcd_text, | 58 can_use_lcd_text, |
| 58 false, | 59 false, |
| 59 &dummy_render_surface_layer_list); | 60 &dummy_render_surface_layer_list); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { | 63 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 expected_grand_child_transform.MakeIdentity(); | 1024 expected_grand_child_transform.MakeIdentity(); |
| 1024 // Apply size delta from the child(container) layer. | 1025 // Apply size delta from the child(container) layer. |
| 1025 expected_grand_child_transform.Translate(20.0, 20.0); | 1026 expected_grand_child_transform.Translate(20.0, 20.0); |
| 1026 | 1027 |
| 1027 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 1028 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 1028 child->draw_transform()); | 1029 child->draw_transform()); |
| 1029 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 1030 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 1030 grand_child->draw_transform()); | 1031 grand_child->draw_transform()); |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 TEST_F(LayerPositionConstraintTest, | |
| 1034 ScrollCompensationForFixedPositionLayerThatHasNoContainer) { | |
|
enne (OOO)
2013/06/04 17:26:03
What do you mean by "we don't ever plan to structu
aelias_OOO_until_Jul13
2013/06/04 17:54:20
A fixed-pos layer will always have a clip layer ab
danakj
2013/06/04 18:02:50
Until the UI compositor does it? Should that be a
aelias_OOO_until_Jul13
2013/06/04 22:18:27
Anyway, since all we care about is some kind of co
| |
| 1035 // This test checks scroll compensation when a fixed-position layer does not | |
| 1036 // find any ancestor that is a "containerForFixedPositionLayers". In this | |
| 1037 // situation, the layer should be fixed to the viewport -- not the root_layer, | |
| 1038 // which may have transforms of its own. | |
| 1039 LayerImpl* child = root_->children()[0]; | |
| 1040 LayerImpl* grand_child = child->children()[0]; | |
| 1041 | |
| 1042 gfx::Transform rotation_by_z; | |
| 1043 rotation_by_z.RotateAboutZAxis(90.0); | |
| 1044 | |
| 1045 root_->SetTransform(rotation_by_z); | |
| 1046 grand_child->SetPositionConstraint(fixed_to_top_left_); | |
| 1047 | |
| 1048 // Case 1: root scroll delta of 0, 0 | |
| 1049 root_->SetScrollDelta(gfx::Vector2d(0, 0)); | |
| 1050 ExecuteCalculateDrawProperties(root_.get()); | |
| 1051 | |
| 1052 gfx::Transform identity_matrix; | |
| 1053 | |
| 1054 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | |
| 1055 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | |
| 1056 grand_child->draw_transform()); | |
| 1057 | |
| 1058 // Case 2: root scroll delta of 10, 10 | |
| 1059 root_->SetScrollDelta(gfx::Vector2d(10, 20)); | |
| 1060 ExecuteCalculateDrawProperties(root_.get()); | |
| 1061 | |
| 1062 // The child is affected by scroll delta, but it is already implcitly | |
| 1063 // accounted for by the child's target surface (i.e. the root render surface). | |
| 1064 // The grand_child is not affected by the scroll delta, so its draw transform | |
| 1065 // needs to explicitly inverse-compensate for the scroll that's embedded in | |
| 1066 // the target surface. | |
| 1067 gfx::Transform expected_grand_child_transform; | |
| 1068 expected_grand_child_transform.PreconcatTransform(Inverse(rotation_by_z)); | |
| 1069 // explicit cancelling out the scroll delta that gets embedded in the fixed | |
| 1070 // position layer's surface. | |
| 1071 expected_grand_child_transform.Translate(10.0, 20.0); | |
| 1072 expected_grand_child_transform.PreconcatTransform(rotation_by_z); | |
| 1073 | |
| 1074 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | |
| 1075 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | |
| 1076 grand_child->draw_transform()); | |
| 1077 | |
| 1078 | |
| 1079 // Case 3: fixed-container size delta of 20, 20 | |
| 1080 root_->SetFixedContainerSizeDelta(gfx::Vector2d(20, 20)); | |
| 1081 ExecuteCalculateDrawProperties(root_.get()); | |
| 1082 | |
| 1083 // Top-left fixed-position layer should not be affected by container size. | |
| 1084 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | |
| 1085 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | |
| 1086 grand_child->draw_transform()); | |
| 1087 | |
| 1088 // Case 4: Bottom-right fixed-position layer. | |
| 1089 grand_child->SetPositionConstraint(fixed_to_bottom_right_); | |
| 1090 ExecuteCalculateDrawProperties(root_.get()); | |
| 1091 | |
| 1092 // Root layer is not the fixed-container anyway. | |
| 1093 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | |
| 1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | |
| 1095 grand_child->draw_transform()); | |
| 1096 } | |
| 1097 | |
| 1098 } // namespace | 1034 } // namespace |
| 1099 } // namespace cc | 1035 } // namespace cc |
| OLD | NEW |