Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/property_tree.h" | 5 #include "cc/trees/property_tree.h" |
| 6 | 6 |
| 7 #include "cc/test/geometry_test_utils.h" | 7 #include "cc/test/geometry_test_utils.h" |
| 8 #include "cc/trees/draw_property_utils.h" | 8 #include "cc/trees/draw_property_utils.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_dest_sublayer_scale, | 309 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_dest_sublayer_scale, |
| 310 transform); | 310 transform); |
| 311 | 311 |
| 312 success = tree.ComputeTransformWithSourceSublayerScale( | 312 success = tree.ComputeTransformWithSourceSublayerScale( |
| 313 grand_child_id, grand_parent_id, &transform); | 313 grand_child_id, grand_parent_id, &transform); |
| 314 EXPECT_TRUE(success); | 314 EXPECT_TRUE(success); |
| 315 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_source_sublayer_scale, | 315 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_source_sublayer_scale, |
| 316 transform); | 316 transform); |
| 317 } | 317 } |
| 318 | 318 |
| 319 TEST (PropertyTreeTest, FlattenOperationPropertyTest) { | |
|
ajuma
2015/04/16 17:34:37
Maybe call this something like FlatteningWhenDesti
| |
| 320 // This test verifies the property : | |
| 321 // If A is a 2d transform, then | |
| 322 // flatten(B*A) = flatten(B)*A | |
|
ajuma
2015/04/16 17:34:37
Nit: This is the property the implementation relie
jaydasika
2015/04/16 17:44:22
The property is used by the test. But, I agree, th
| |
| 323 TransformTree tree; | |
| 324 | |
| 325 int parent = tree.Insert(TransformNode(), 0); | |
| 326 tree.Node(parent)->data.content_target_id = parent; | |
| 327 tree.Node(parent)->data.target_id = parent; | |
| 328 tree.Node(parent)->data.local.Translate(2, 2); | |
| 329 | |
| 330 gfx::Transform rotation_about_x; | |
| 331 rotation_about_x.RotateAboutXAxis(15); | |
| 332 | |
| 333 int child = tree.Insert(TransformNode(), parent); | |
| 334 tree.Node(child)->data.content_target_id = child; | |
| 335 tree.Node(child)->data.target_id = child; | |
| 336 tree.Node(child)->data.local = rotation_about_x; | |
| 337 | |
| 338 | |
| 339 int grand_child = tree.Insert(TransformNode(), child); | |
| 340 tree.Node(grand_child)->data.content_target_id = grand_child; | |
| 341 tree.Node(grand_child)->data.target_id = grand_child; | |
| 342 tree.Node(grand_child)->data.flattens_inherited_transform = true; | |
| 343 | |
| 344 ComputeTransforms(&tree); | |
| 345 | |
| 346 gfx::Transform flattened_rotation_about_x = rotation_about_x; | |
| 347 flattened_rotation_about_x.FlattenTo2d(); | |
| 348 | |
| 349 gfx::Transform grand_child_to_parent; | |
| 350 bool success = | |
| 351 tree.ComputeTransform(grand_child, parent, &grand_child_to_parent); | |
| 352 EXPECT_TRUE(success); | |
| 353 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_x, | |
| 354 grand_child_to_parent); | |
| 355 } | |
| 356 | |
| 319 } // namespace cc | 357 } // namespace cc |
| OLD | NEW |