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

Side by Side Diff: cc/trees/layer_tree_impl_unittest.cc

Issue 2889093003: Refactor SetViewportLayerIds to use a struct instead of 6 values (Closed)
Patch Set: Fix small mistake made in a test Created 3 years, 7 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
« no previous file with comments | « cc/trees/layer_tree_impl.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 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 "cc/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/layers/heads_up_display_layer_impl.h" 9 #include "cc/layers/heads_up_display_layer_impl.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 } 1432 }
1433 1433
1434 float device_scale_factor = 3.f; 1434 float device_scale_factor = 3.f;
1435 float page_scale_factor = 5.f; 1435 float page_scale_factor = 5.f;
1436 float max_page_scale_factor = 10.f; 1436 float max_page_scale_factor = 10.f;
1437 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( 1437 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
1438 root->bounds(), device_scale_factor * page_scale_factor); 1438 root->bounds(), device_scale_factor * page_scale_factor);
1439 host_impl().SetViewportSize(scaled_bounds_for_root); 1439 host_impl().SetViewportSize(scaled_bounds_for_root);
1440 1440
1441 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); 1441 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
1442 host_impl().active_tree()->SetViewportLayersFromIds( 1442 LayerTreeImpl::ViewportLayerIds viewport_ids;
1443 Layer::INVALID_ID, 1, Layer::INVALID_ID, Layer::INVALID_ID, 1, 1443 viewport_ids.page_scale = 1;
1444 Layer::INVALID_ID); 1444 viewport_ids.inner_viewport_scroll = 1;
1445 host_impl().active_tree()->SetViewportLayersFromIds(viewport_ids);
1445 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 1446 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
1446 host_impl().active_tree()->PushPageScaleFromMainThread( 1447 host_impl().active_tree()->PushPageScaleFromMainThread(
1447 page_scale_factor, page_scale_factor, max_page_scale_factor); 1448 page_scale_factor, page_scale_factor, max_page_scale_factor);
1448 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1449 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1449 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1450 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1450 1451
1451 // Sanity check the scenario we just created. 1452 // Sanity check the scenario we just created.
1452 // The visible content rect for test_layer is actually 100x100, even though 1453 // The visible content rect for test_layer is actually 100x100, even though
1453 // its layout size is 50x50, positioned at 25x25. 1454 // its layout size is 50x50, positioned at 25x25.
1454 LayerImpl* test_layer = root->test_properties()->children[0]; 1455 LayerImpl* test_layer = root->test_properties()->children[0];
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 } 1661 }
1661 1662
1662 float device_scale_factor = 3.f; 1663 float device_scale_factor = 3.f;
1663 float page_scale_factor = 1.f; 1664 float page_scale_factor = 1.f;
1664 float max_page_scale_factor = 1.f; 1665 float max_page_scale_factor = 1.f;
1665 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( 1666 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
1666 root->bounds(), device_scale_factor * page_scale_factor); 1667 root->bounds(), device_scale_factor * page_scale_factor);
1667 host_impl().SetViewportSize(scaled_bounds_for_root); 1668 host_impl().SetViewportSize(scaled_bounds_for_root);
1668 1669
1669 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); 1670 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
1670 host_impl().active_tree()->SetViewportLayersFromIds( 1671 LayerTreeImpl::ViewportLayerIds viewport_ids;
1671 Layer::INVALID_ID, 1, Layer::INVALID_ID, Layer::INVALID_ID, 1, 1672 viewport_ids.page_scale = 1;
1672 Layer::INVALID_ID); 1673 viewport_ids.inner_viewport_scroll = 1;
1674 host_impl().active_tree()->SetViewportLayersFromIds(viewport_ids);
1673 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 1675 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
1674 host_impl().active_tree()->PushPageScaleFromMainThread( 1676 host_impl().active_tree()->PushPageScaleFromMainThread(
1675 page_scale_factor, page_scale_factor, max_page_scale_factor); 1677 page_scale_factor, page_scale_factor, max_page_scale_factor);
1676 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1678 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1677 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1679 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1678 1680
1679 // Sanity check the scenario we just created. 1681 // Sanity check the scenario we just created.
1680 ASSERT_EQ(2u, GetRenderSurfaceList().size()); 1682 ASSERT_EQ(2u, GetRenderSurfaceList().size());
1681 1683
1682 // Hit checking for a point outside the layer should return a null pointer. 1684 // Hit checking for a point outside the layer should return a null pointer.
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 } 2055 }
2054 2056
2055 host_impl().active_tree()->BuildPropertyTreesForTesting(); 2057 host_impl().active_tree()->BuildPropertyTreesForTesting();
2056 2058
2057 float device_scale_factor = 3.f; 2059 float device_scale_factor = 3.f;
2058 float page_scale_factor = 5.f; 2060 float page_scale_factor = 5.f;
2059 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( 2061 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
2060 root->bounds(), device_scale_factor * page_scale_factor); 2062 root->bounds(), device_scale_factor * page_scale_factor);
2061 host_impl().SetViewportSize(scaled_bounds_for_root); 2063 host_impl().SetViewportSize(scaled_bounds_for_root);
2062 2064
2063 host_impl().active_tree()->SetViewportLayersFromIds( 2065 LayerTreeImpl::ViewportLayerIds viewport_ids;
2064 Layer::INVALID_ID, root->id(), Layer::INVALID_ID, Layer::INVALID_ID, 2066 viewport_ids.page_scale = root->id();
2065 Layer::INVALID_ID, Layer::INVALID_ID); 2067 host_impl().active_tree()->SetViewportLayersFromIds(viewport_ids);
2066 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor); 2068 host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
2067 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 2069 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
2068 2070
2069 host_impl().active_tree()->PushPageScaleFromMainThread( 2071 host_impl().active_tree()->PushPageScaleFromMainThread(
2070 page_scale_factor, page_scale_factor, page_scale_factor); 2072 page_scale_factor, page_scale_factor, page_scale_factor);
2071 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 2073 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
2072 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 2074 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
2073 2075
2074 // Sanity check the scenario we just created. 2076 // Sanity check the scenario we just created.
2075 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 2077 ASSERT_EQ(1u, GetRenderSurfaceList().size());
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 auto weak_promise = promise->AsWeakPtr(); 2355 auto weak_promise = promise->AsWeakPtr();
2354 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); 2356 host_impl().active_tree()->QueueSwapPromise(std::move(promise));
2355 host_impl().active_tree()->BreakSwapPromises( 2357 host_impl().active_tree()->BreakSwapPromises(
2356 SwapPromise::DidNotSwapReason::SWAP_FAILS); 2358 SwapPromise::DidNotSwapReason::SWAP_FAILS);
2357 EXPECT_FALSE(weak_promise); 2359 EXPECT_FALSE(weak_promise);
2358 } 2360 }
2359 } 2361 }
2360 2362
2361 } // namespace 2363 } // namespace
2362 } // namespace cc 2364 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698