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

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 81453002: Reland: CC: Adjust tiling creation triggers during pinch-zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CC_soon_bin_optimization_REDUCE_ZOOM_OUT_MEMORY_V2
Patch Set: Rebase. Created 7 years 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/layers/picture_layer_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 &result_scale_y, 662 &result_scale_y,
663 &result_bounds); 663 &result_bounds);
664 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); 664 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
665 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 665 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
666 EXPECT_FLOAT_EQ(high_res_scale, 666 EXPECT_FLOAT_EQ(high_res_scale,
667 pending_layer_->HighResTiling()->contents_scale()); 667 pending_layer_->HighResTiling()->contents_scale());
668 EXPECT_FLOAT_EQ(low_res_scale, 668 EXPECT_FLOAT_EQ(low_res_scale,
669 pending_layer_->LowResTiling()->contents_scale()); 669 pending_layer_->LowResTiling()->contents_scale());
670 } 670 }
671 671
672 TEST_F(PictureLayerImplTest, ZoomOutCrash) {
673 gfx::Size tile_size(400, 400);
674 gfx::Size layer_bounds(1300, 1900);
675
676 // Set up the high and low res tilings before pinch zoom.
677 scoped_refptr<FakePicturePileImpl> pending_pile =
678 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
679 scoped_refptr<FakePicturePileImpl> active_pile =
680 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
681
682 SetupTrees(pending_pile, active_pile);
683 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
684 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, false);
685 host_impl_.PinchGestureBegin();
686 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
687 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
688 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1);
689 }
690
691 TEST_F(PictureLayerImplTest, PinchGestureTilings) {
692 gfx::Size tile_size(400, 400);
693 gfx::Size layer_bounds(1300, 1900);
694
695 scoped_refptr<FakePicturePileImpl> pending_pile =
696 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
697 scoped_refptr<FakePicturePileImpl> active_pile =
698 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
699
700 // Set up the high and low res tilings before pinch zoom.
701 SetupTrees(pending_pile, active_pile);
702 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
703 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
704 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
705 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
706 EXPECT_FLOAT_EQ(
707 1.0f,
708 active_layer_->tilings()->tiling_at(0)->contents_scale());
709 EXPECT_FLOAT_EQ(
710 1.0f * low_res_factor,
711 active_layer_->tilings()->tiling_at(1)->contents_scale());
712
713 // Start a pinch gesture.
714 host_impl_.PinchGestureBegin();
715
716 // Zoom out by a small amount. We should create a tiling at half
717 // the scale (1/kMaxScaleRatioDuringPinch).
718 SetContentsScaleOnBothLayers(0.90f, 1.0f, 0.9f, false);
719 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
720 EXPECT_FLOAT_EQ(
721 1.0f,
722 active_layer_->tilings()->tiling_at(0)->contents_scale());
723 EXPECT_FLOAT_EQ(
724 0.5f,
725 active_layer_->tilings()->tiling_at(1)->contents_scale());
726 EXPECT_FLOAT_EQ(
727 1.0f * low_res_factor,
728 active_layer_->tilings()->tiling_at(2)->contents_scale());
729
730 // Zoom out further, close to our low-res scale factor. We should
731 // use that tiling as high-res, and not create a new tiling.
732 SetContentsScaleOnBothLayers(low_res_factor, 1.0f, low_res_factor, false);
733 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
734
735 // Zoom in a lot now. Since we increase by increments of
736 // kMaxScaleRatioDuringPinch, this will first use 0.5, then 1.0
737 // and then finally create a new tiling at 2.0.
738 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false);
739 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
740 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false);
741 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
742 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false);
743 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings());
744 EXPECT_FLOAT_EQ(
745 2.0f,
746 active_layer_->tilings()->tiling_at(0)->contents_scale());
747 }
748
672 TEST_F(PictureLayerImplTest, CleanUpTilings) { 749 TEST_F(PictureLayerImplTest, CleanUpTilings) {
673 gfx::Size tile_size(400, 400); 750 gfx::Size tile_size(400, 400);
674 gfx::Size layer_bounds(1300, 1900); 751 gfx::Size layer_bounds(1300, 1900);
675 752
676 scoped_refptr<FakePicturePileImpl> pending_pile = 753 scoped_refptr<FakePicturePileImpl> pending_pile =
677 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 754 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
678 scoped_refptr<FakePicturePileImpl> active_pile = 755 scoped_refptr<FakePicturePileImpl> active_pile =
679 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 756 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
680 757
681 float result_scale_x, result_scale_y; 758 float result_scale_x, result_scale_y;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 TestContextProvider::Create(), NULL)); 1340 TestContextProvider::Create(), NULL));
1264 1341
1265 // These will crash PictureLayerImpl if this is not true. 1342 // These will crash PictureLayerImpl if this is not true.
1266 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); 1343 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties());
1267 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); 1344 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties());
1268 host_impl_.active_tree()->UpdateDrawProperties(); 1345 host_impl_.active_tree()->UpdateDrawProperties();
1269 } 1346 }
1270 1347
1271 } // namespace 1348 } // namespace
1272 } // namespace cc 1349 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698