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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 12407002: Align physical pixels of scrolled layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Align scrollable layer Created 7 years, 9 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
« cc/layer_tree_host_common.cc ('K') | « cc/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 kScrollLayerPosition(-kScrollOffset.x(), -kScrollOffset.y( ));
266 const float kPageScale = 0.888;
267 const float kDeviceScale = 1.666;
268
269 FakeImplProxy proxy;
270 FakeLayerTreeHostImpl hostImpl(&proxy);
271
272 gfx::Transform identityMatrix;
273 scoped_ptr<LayerImpl> sublayerScopedPtr(LayerImpl::create(hostImpl.activeTre e(), 1));
274 LayerImpl* sublayer = sublayerScopedPtr.get();
275 sublayer->setContentsScale(kPageScale * kDeviceScale, kPageScale * kDeviceSc ale);
276 setLayerPropertiesForTesting(sublayer, identityMatrix, identityMatrix, gfx:: Point(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false);
277
278 scoped_ptr<LayerImpl> scrollLayer(LayerImpl::create(hostImpl.activeTree(), 2 ));
279 setLayerPropertiesForTesting(scrollLayer.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), false);
280 scrollLayer->setScrollable(true);
281 scrollLayer->setScrollOffset(kScrollOffset);
282 scrollLayer->setScrollDelta(kScrollDelta);
283 scrollLayer->setPosition(kScrollLayerPosition);
284 gfx::Transform implTransform;
285 implTransform.Scale(kPageScale, kPageScale);
286 scrollLayer->setImplTransform(implTransform);
287 scrollLayer->addChild(sublayerScopedPtr.Pass());
288
289 scoped_ptr<LayerImpl> root(LayerImpl::create(hostImpl.activeTree(), 3));
290 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false);
291 root->addChild(scrollLayer.Pass());
292
293 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale);
294 gfx::Transform expectedTransform = identityMatrix;
295 gfx::PointF subLayerScreenPosition = kScrollLayerPosition - kScrollDelta;
296 subLayerScreenPosition.Scale(kPageScale * kDeviceScale);
297 expectedTransform.Translate(round(subLayerScreenPosition.x()), round(subLaye rScreenPosition.y()));
298 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->drawTransform() );
299 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->screenSpaceTran sform());
300 }
301
261 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) 302 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
262 { 303 {
263 gfx::Transform identityMatrix; 304 gfx::Transform identityMatrix;
264 scoped_refptr<Layer> root = Layer::create(); 305 scoped_refptr<Layer> root = Layer::create();
265 scoped_refptr<Layer> parent = Layer::create(); 306 scoped_refptr<Layer> parent = Layer::create();
266 scoped_refptr<Layer> child = Layer::create(); 307 scoped_refptr<Layer> child = Layer::create();
267 scoped_refptr<Layer> grandChild = Layer::create(); 308 scoped_refptr<Layer> grandChild = Layer::create();
268 root->addChild(parent); 309 root->addChild(parent);
269 parent->addChild(child); 310 parent->addChild(child);
270 child->addChild(grandChild); 311 child->addChild(grandChild);
(...skipping 4819 matching lines...) Expand 10 before | Expand all | Expand 10 after
5090 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); 5131 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
5091 } 5132 }
5092 5133
5093 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5134 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5094 LCDTextTest, 5135 LCDTextTest,
5095 testing::Combine(testing::Bool(), 5136 testing::Combine(testing::Bool(),
5096 testing::Bool())); 5137 testing::Bool()));
5097 5138
5098 } // namespace 5139 } // namespace
5099 } // namespace cc 5140 } // namespace cc
OLDNEW
« cc/layer_tree_host_common.cc ('K') | « cc/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698