| 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 <vector> | 5 #include <vector> |
| 6 #include "cc/blink/web_layer_impl_fixed_bounds.h" | 6 #include "cc/blink/web_layer_impl_fixed_bounds.h" |
| 7 #include "cc/layers/picture_image_layer.h" | 7 #include "cc/layers/picture_image_layer.h" |
| 8 #include "cc/test/fake_layer_tree_host.h" | 8 #include "cc/test/fake_layer_tree_host.h" |
| 9 #include "cc/test/geometry_test_utils.h" | 9 #include "cc/test/geometry_test_utils.h" |
| 10 #include "cc/trees/layer_tree_host_common.h" | 10 #include "cc/trees/layer_tree_host_common.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 EXPECT_EQ(fixed_bounds, layer->layer()->bounds()); | 46 EXPECT_EQ(fixed_bounds, layer->layer()->bounds()); |
| 47 EXPECT_TRUE(layer->transform().isIdentity()); | 47 EXPECT_TRUE(layer->transform().isIdentity()); |
| 48 | 48 |
| 49 // An arbitrary point to check the scale and transforms. | 49 // An arbitrary point to check the scale and transforms. |
| 50 gfx::Point3F original_point(10, 20, 1); | 50 gfx::Point3F original_point(10, 20, 1); |
| 51 gfx::Point3F scaled_point( | 51 gfx::Point3F scaled_point( |
| 52 original_point.x() * bounds.width / fixed_bounds.width(), | 52 original_point.x() * bounds.width / fixed_bounds.width(), |
| 53 original_point.y() * bounds.height / fixed_bounds.height(), | 53 original_point.y() * bounds.height / fixed_bounds.height(), |
| 54 original_point.z()); | 54 original_point.z()); |
| 55 // Test if the bounds scale is correctly applied in transform. | 55 // Test if the bounds scale is correctly applied in transform. |
| 56 EXPECT_POINT3F_EQ( | 56 EXPECT_EQ(scaled_point, |
| 57 scaled_point, | 57 TransformPoint(layer->layer()->transform(), original_point)); |
| 58 TransformPoint(layer->layer()->transform(), original_point)); | |
| 59 } | 58 } |
| 60 | 59 |
| 61 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) { | 60 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) { |
| 62 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); | 61 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); |
| 63 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250)); | 62 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250)); |
| 64 // Change fixed_bounds. | 63 // Change fixed_bounds. |
| 65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100)); | 64 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100)); |
| 66 // Change bounds. | 65 // Change bounds. |
| 67 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100)); | 66 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100)); |
| 68 } | 67 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 169 |
| 171 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), transform); | 170 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), transform); |
| 172 | 171 |
| 173 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to | 172 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to |
| 174 // WebLayerImpl. | 173 // WebLayerImpl. |
| 175 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), transform); | 174 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), transform); |
| 176 } | 175 } |
| 177 | 176 |
| 178 } // namespace | 177 } // namespace |
| 179 } // namespace cc_blink | 178 } // namespace cc_blink |
| OLD | NEW |