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

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: Fix win break again 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
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/math_util.h » ('j') | 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.34f, 5.67f);
265 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(), -kScrollOffset.y( ));
266 const float kPageScale = 0.888f;
267 const float kDeviceScale = 1.666f;
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> scrollLayerScopedPtr(LayerImpl::create(hostImpl.active Tree(), 2));
279 LayerImpl* scrollLayer = scrollLayerScopedPtr.get();
280 setLayerPropertiesForTesting(scrollLayer, identityMatrix, identityMatrix, gf x::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false);
281 scrollLayer->setScrollable(true);
282 scrollLayer->setScrollOffset(kScrollOffset);
283 scrollLayer->setScrollDelta(kScrollDelta);
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(scrollLayerScopedPtr.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(MathUtil::Round(subLayerScreenPosition.x()), Mat hUtil::Round(subLayerScreenPosition.y()));
298 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->drawTransform() );
299 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->screenSpaceTran sform());
300
301 gfx::Transform arbitraryTranslate;
302 const float kTranslateX = 10.6f;
303 const float kTranslateY = 20.6f;
304 arbitraryTranslate.Translate(kTranslateX, kTranslateY);
305 setLayerPropertiesForTesting(scrollLayer, arbitraryTranslate, identityMatrix , gfx::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false);
306 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale);
307 expectedTransform.MakeIdentity();
308 expectedTransform.Translate(MathUtil::Round(kTranslateX * kPageScale * kDevi ceScale + subLayerScreenPosition.x()),
309 MathUtil::Round(kTranslateY * kPageScale * kDevi ceScale + subLayerScreenPosition.y()));
310 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->drawTransform() );
311 }
312
261 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) 313 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
262 { 314 {
263 gfx::Transform identityMatrix; 315 gfx::Transform identityMatrix;
264 scoped_refptr<Layer> root = Layer::create(); 316 scoped_refptr<Layer> root = Layer::create();
265 scoped_refptr<Layer> parent = Layer::create(); 317 scoped_refptr<Layer> parent = Layer::create();
266 scoped_refptr<Layer> child = Layer::create(); 318 scoped_refptr<Layer> child = Layer::create();
267 scoped_refptr<Layer> grandChild = Layer::create(); 319 scoped_refptr<Layer> grandChild = Layer::create();
268 root->addChild(parent); 320 root->addChild(parent);
269 parent->addChild(child); 321 parent->addChild(child);
270 child->addChild(grandChild); 322 child->addChild(grandChild);
(...skipping 4819 matching lines...) Expand 10 before | Expand all | Expand 10 after
5090 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText());
5091 } 5143 }
5092 5144
5093 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5094 LCDTextTest, 5146 LCDTextTest,
5095 testing::Combine(testing::Bool(), 5147 testing::Combine(testing::Bool(),
5096 testing::Bool())); 5148 testing::Bool()));
5097 5149
5098 } // namespace 5150 } // namespace
5099 } // namespace cc 5151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/math_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698