| OLD | NEW |
| 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/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
| 8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
| 9 #include "cc/heads_up_display_layer_impl.h" | 9 #include "cc/heads_up_display_layer_impl.h" |
| 10 #include "cc/layer.h" | 10 #include "cc/layer.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Case 7: Verify that position pre-multiplies the layer transform. | 251 // Case 7: Verify that position pre-multiplies the layer transform. |
| 252 // The current implementation of calculateDrawProperties does this i
mplicitly, but it is | 252 // The current implementation of calculateDrawProperties does this i
mplicitly, but it is |
| 253 // still worth testing to detect accidental regressions. | 253 // still worth testing to detect accidental regressions. |
| 254 expectedResult = positionTransform * translationToAnchor * layerTransform *
inverse(translationToAnchor); | 254 expectedResult = positionTransform * translationToAnchor * layerTransform *
inverse(translationToAnchor); |
| 255 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 255 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 256 executeCalculateDrawProperties(root.get()); | 256 executeCalculateDrawProperties(root.get()); |
| 257 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 257 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
| 258 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 258 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST(LayerTreeHostCommonTest, verifyTransformsAboutScrollOffset) |
| 262 { |
| 263 const gfx::Vector2d kScrollOffset(50, 100); |
| 264 const gfx::Vector2dF kScrollDelta(2.34, 5.67); |
| 265 const gfx::PointF kLayerPosition(-(kScrollOffset.x() + kScrollDelta.x()), -(
kScrollOffset.y() + kScrollDelta.y())); |
| 266 |
| 267 FakeImplProxy proxy; |
| 268 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 269 |
| 270 gfx::Transform identityMatrix; |
| 271 scoped_ptr<LayerImpl> layerScopedPtr(LayerImpl::create(hostImpl.activeTree()
, 1)); |
| 272 LayerImpl* layer = layerScopedPtr.get(); |
| 273 layer->setDrawsContent(true); |
| 274 setLayerPropertiesForTesting(layer, identityMatrix, identityMatrix, gfx::Poi
nt(0, 0), kLayerPosition, gfx::Size(500, 500), false); |
| 275 |
| 276 scoped_ptr<LayerImpl> root(LayerImpl::create(hostImpl.activeTree(), 2)); |
| 277 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), false); |
| 278 root->setScrollable(true); |
| 279 root->setScrollOffset(kScrollOffset); |
| 280 root->setScrollDelta(kScrollDelta); |
| 281 root->addChild(layerScopedPtr.Pass()); |
| 282 |
| 283 executeCalculateDrawProperties(root.get(), 1, 1.5); |
| 284 gfx::Transform expectedTransform = identityMatrix; |
| 285 expectedTransform.Translate(round(kLayerPosition.x()), round(kLayerPosition.
y())); |
| 286 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, layer->drawTransform()); |
| 287 } |
| 288 |
| 261 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) | 289 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) |
| 262 { | 290 { |
| 263 gfx::Transform identityMatrix; | 291 gfx::Transform identityMatrix; |
| 264 scoped_refptr<Layer> root = Layer::create(); | 292 scoped_refptr<Layer> root = Layer::create(); |
| 265 scoped_refptr<Layer> parent = Layer::create(); | 293 scoped_refptr<Layer> parent = Layer::create(); |
| 266 scoped_refptr<Layer> child = Layer::create(); | 294 scoped_refptr<Layer> child = Layer::create(); |
| 267 scoped_refptr<Layer> grandChild = Layer::create(); | 295 scoped_refptr<Layer> grandChild = Layer::create(); |
| 268 root->addChild(parent); | 296 root->addChild(parent); |
| 269 parent->addChild(child); | 297 parent->addChild(child); |
| 270 child->addChild(grandChild); | 298 child->addChild(grandChild); |
| (...skipping 4819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5090 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5118 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); |
| 5091 } | 5119 } |
| 5092 | 5120 |
| 5093 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5121 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 5094 LCDTextTest, | 5122 LCDTextTest, |
| 5095 testing::Combine(testing::Bool(), | 5123 testing::Combine(testing::Bool(), |
| 5096 testing::Bool())); | 5124 testing::Bool())); |
| 5097 | 5125 |
| 5098 } // namespace | 5126 } // namespace |
| 5099 } // namespace cc | 5127 } // namespace cc |
| OLD | NEW |