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

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

Issue 2647343012: cc: Ensure that layer bounds * content scale doesn't overflow (Closed)
Patch Set: Typo Created 3 years, 10 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/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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 ResetTilingsAndRasterScales(); 703 ResetTilingsAndRasterScales();
704 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); 704 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings());
705 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); 705 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false);
706 EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale()); 706 EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale());
707 host_impl()->PinchGestureBegin(); 707 host_impl()->PinchGestureBegin();
708 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); 708 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false);
709 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); 709 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false);
710 EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1); 710 EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1);
711 } 711 }
712 712
713 TEST_F(PictureLayerImplTest, ScaledBoundsOverflowInt) {
714 // Limit visible size.
715 gfx::Size viewport_size(1, 1);
716 host_impl()->SetViewportSize(viewport_size);
717
718 gfx::Size layer_bounds(600000, 60);
719
720 // Set up the high and low res tilings before pinch zoom.
721 SetupDefaultTrees(layer_bounds);
722 ResetTilingsAndRasterScales();
723 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings());
724 float scale = 8000.f;
725
726 // Verify this will overflow an int.
727 EXPECT_GT(static_cast<float>(layer_bounds.width()) * scale,
728 static_cast<float>(std::numeric_limits<int>::max()));
729
730 SetContentsScaleOnBothLayers(scale, 1.0f, scale, 1.0f, 0.f, false);
731 float adjusted_scale = active_layer()->HighResTiling()->contents_scale();
732 EXPECT_LT(adjusted_scale, scale);
733
734 // PopulateSharedQuadState CHECKs for overflows.
735 // See http://crbug.com/679035
736 active_layer()->draw_properties().visible_layer_rect =
737 gfx::Rect(layer_bounds);
738 SharedQuadState state;
739 active_layer()->PopulateScaledSharedQuadState(&state, adjusted_scale,
740 adjusted_scale);
741 }
742
713 TEST_F(PictureLayerImplTest, PinchGestureTilings) { 743 TEST_F(PictureLayerImplTest, PinchGestureTilings) {
714 gfx::Size layer_bounds(1300, 1900); 744 gfx::Size layer_bounds(1300, 1900);
715 745
716 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; 746 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor;
717 // Set up the high and low res tilings before pinch zoom. 747 // Set up the high and low res tilings before pinch zoom.
718 SetupDefaultTrees(layer_bounds); 748 SetupDefaultTrees(layer_bounds);
719 ResetTilingsAndRasterScales(); 749 ResetTilingsAndRasterScales();
720 750
721 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); 751 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false);
722 EXPECT_EQ(active_layer()->num_tilings(), 2u); 752 EXPECT_EQ(active_layer()->num_tilings(), 2u);
(...skipping 4200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4923 EXPECT_FLOAT_EQ(expected_contents_scale, 4953 EXPECT_FLOAT_EQ(expected_contents_scale,
4924 pending_layer_ptr->picture_layer_tiling_set() 4954 pending_layer_ptr->picture_layer_tiling_set()
4925 ->FindTilingWithResolution(HIGH_RESOLUTION) 4955 ->FindTilingWithResolution(HIGH_RESOLUTION)
4926 ->contents_scale()) 4956 ->contents_scale())
4927 << "ideal_contents_scale: " << ideal_contents_scale; 4957 << "ideal_contents_scale: " << ideal_contents_scale;
4928 } 4958 }
4929 } 4959 }
4930 4960
4931 } // namespace 4961 } // namespace
4932 } // namespace cc 4962 } // 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