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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11377068: ui: Make gfx::Size::Scale() mutate the class. Add gfx::ScaleSize() similar to Rect/Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebaseTOGO Created 8 years, 1 month 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_impl_unittest.cc ('k') | cc/page_scale_animation.cc » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_tree_host.h" 7 #include "cc/layer_tree_host.h"
8 8
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/content_layer.h" 10 #include "cc/content_layer.h"
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 1332
1333 // Both layers should be drawing into the root render surface. 1333 // Both layers should be drawing into the root render surface.
1334 ASSERT_EQ(1u, renderSurfaceLayerList.size()); 1334 ASSERT_EQ(1u, renderSurfaceLayerList.size());
1335 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac e()); 1335 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac e());
1336 ASSERT_EQ(2u, root->renderSurface()->layerList().size()); 1336 ASSERT_EQ(2u, root->renderSurface()->layerList().size());
1337 1337
1338 // The root render surface is the size of the viewport. 1338 // The root render surface is the size of the viewport.
1339 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRe ct()); 1339 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRe ct());
1340 1340
1341 // The content bounds of the child should be scaled. 1341 // The content bounds of the child should be scaled.
1342 gfx::Size childBoundsScaled = child->bounds(); 1342 gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bo unds(), 1.5));
1343 childBoundsScaled = gfx::ToRoundedSize(childBoundsScaled.Scale(1.5));
1344 EXPECT_EQ(childBoundsScaled, child->contentBounds()); 1343 EXPECT_EQ(childBoundsScaled, child->contentBounds());
1345 1344
1346 WebTransformationMatrix scaleTransform; 1345 WebTransformationMatrix scaleTransform;
1347 scaleTransform.scale(impl->deviceScaleFactor()); 1346 scaleTransform.scale(impl->deviceScaleFactor());
1348 1347
1349 // The root layer is scaled by 2x. 1348 // The root layer is scaled by 2x.
1350 WebTransformationMatrix rootScreenSpaceTransform = scaleTransform; 1349 WebTransformationMatrix rootScreenSpaceTransform = scaleTransform;
1351 WebTransformationMatrix rootDrawTransform = scaleTransform; 1350 WebTransformationMatrix rootDrawTransform = scaleTransform;
1352 1351
1353 EXPECT_EQ(rootDrawTransform, root->drawTransform()); 1352 EXPECT_EQ(rootDrawTransform, root->drawTransform());
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 , m_initialScroll(10, 20) 2179 , m_initialScroll(10, 20)
2181 , m_secondScroll(40, 5) 2180 , m_secondScroll(40, 5)
2182 , m_scrollAmount(2, -1) 2181 , m_scrollAmount(2, -1)
2183 , m_rootScrolls(0) 2182 , m_rootScrolls(0)
2184 { 2183 {
2185 } 2184 }
2186 2185
2187 virtual void beginTest() OVERRIDE 2186 virtual void beginTest() OVERRIDE
2188 { 2187 {
2189 gfx::Size viewportSize(10, 10); 2188 gfx::Size viewportSize(10, 10);
2190 gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_de viceScaleFactor)); 2189 gfx::Size deviceViewportSize = gfx::ToCeiledSize(gfx::ScaleSize(viewport Size, m_deviceScaleFactor));
2191 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize); 2190 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize);
2192 2191
2193 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); 2192 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
2194 2193
2195 m_rootScrollLayer = ContentLayer::create(&m_fakeDelegate); 2194 m_rootScrollLayer = ContentLayer::create(&m_fakeDelegate);
2196 m_rootScrollLayer->setBounds(gfx::Size(110, 110)); 2195 m_rootScrollLayer->setBounds(gfx::Size(110, 110));
2197 2196
2198 m_rootScrollLayer->setPosition(gfx::PointF(0, 0)); 2197 m_rootScrollLayer->setPosition(gfx::PointF(0, 0));
2199 m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0)); 2198 m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0));
2200 2199
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 , m_initialScroll(10, 20) 2339 , m_initialScroll(10, 20)
2341 , m_secondScroll(40, 5) 2340 , m_secondScroll(40, 5)
2342 , m_scrollAmount(2, -1) 2341 , m_scrollAmount(2, -1)
2343 , m_rootScrolls(0) 2342 , m_rootScrolls(0)
2344 { 2343 {
2345 } 2344 }
2346 2345
2347 virtual void beginTest() OVERRIDE 2346 virtual void beginTest() OVERRIDE
2348 { 2347 {
2349 gfx::Size viewportSize(10, 10); 2348 gfx::Size viewportSize(10, 10);
2350 gfx::Size deviceViewportSize = gfx::ToCeiledSize(viewportSize.Scale(m_de viceScaleFactor)); 2349 gfx::Size deviceViewportSize = gfx::ToCeiledSize(gfx::ScaleSize(viewport Size, m_deviceScaleFactor));
2351 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize); 2350 m_layerTreeHost->setViewportSize(viewportSize, deviceViewportSize);
2352 2351
2353 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor); 2352 m_layerTreeHost->setDeviceScaleFactor(m_deviceScaleFactor);
2354 2353
2355 m_rootScrollLayer = ContentLayer::create(&m_fakeDelegate); 2354 m_rootScrollLayer = ContentLayer::create(&m_fakeDelegate);
2356 m_rootScrollLayer->setBounds(gfx::Size(110, 110)); 2355 m_rootScrollLayer->setBounds(gfx::Size(110, 110));
2357 2356
2358 m_rootScrollLayer->setPosition(gfx::PointF(0, 0)); 2357 m_rootScrollLayer->setPosition(gfx::PointF(0, 0));
2359 m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0)); 2358 m_rootScrollLayer->setAnchorPoint(gfx::PointF(0, 0));
2360 2359
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 int m_numCommitsDeferred; 3217 int m_numCommitsDeferred;
3219 int m_numCompleteCommits; 3218 int m_numCompleteCommits;
3220 }; 3219 };
3221 3220
3222 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) 3221 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread)
3223 { 3222 {
3224 runTest(true); 3223 runTest(true);
3225 } 3224 }
3226 3225
3227 } // anonymous namespace 3226 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl_unittest.cc ('k') | cc/page_scale_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698