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

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

Issue 323193002: cc: Don't cleanup the pending twin's low res tiling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: scale-collision: . Created 6 years, 6 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/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling_set.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 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); 2910 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2911 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 2911 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
2912 2912
2913 // If we remove it from our used tilings set, it is outside the range to keep 2913 // If we remove it from our used tilings set, it is outside the range to keep
2914 // so it is deleted. 2914 // so it is deleted.
2915 used_tilings.clear(); 2915 used_tilings.clear();
2916 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); 2916 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2917 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); 2917 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
2918 } 2918 }
2919 2919
2920 TEST_F(PictureLayerImplTest, ScaleCollision) {
2921 gfx::Size tile_size(400, 400);
2922 gfx::Size layer_bounds(1300, 1900);
2923
2924 scoped_refptr<FakePicturePileImpl> pending_pile =
2925 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2926 scoped_refptr<FakePicturePileImpl> active_pile =
2927 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2928
2929 float result_scale_x, result_scale_y;
2930 gfx::Size result_bounds;
2931 std::vector<PictureLayerTiling*> used_tilings;
2932
2933 SetupTrees(pending_pile, active_pile);
2934
2935 float pending_contents_scale = 1.f;
2936 float active_contents_scale = 2.f;
2937 float device_scale_factor = 1.f;
2938 float page_scale_factor = 1.f;
2939 float maximum_animation_contents_scale = 1.f;
2940 bool animating_transform = false;
2941
2942 EXPECT_TRUE(host_impl_.settings().create_low_res_tiling);
2943 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
2944 EXPECT_LT(low_res_factor, 1.f);
2945
2946 pending_layer_->CalculateContentsScale(pending_contents_scale,
2947 device_scale_factor,
2948 page_scale_factor,
2949 maximum_animation_contents_scale,
2950 animating_transform,
2951 &result_scale_x,
2952 &result_scale_y,
2953 &result_bounds);
2954 active_layer_->CalculateContentsScale(active_contents_scale,
2955 device_scale_factor,
2956 page_scale_factor,
2957 maximum_animation_contents_scale,
2958 animating_transform,
2959 &result_scale_x,
2960 &result_scale_y,
2961 &result_bounds);
2962
2963 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings());
2964 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings());
2965
2966 EXPECT_EQ(active_contents_scale,
2967 pending_layer_->tilings()->tiling_at(0)->contents_scale());
2968 EXPECT_EQ(pending_contents_scale,
2969 pending_layer_->tilings()->tiling_at(1)->contents_scale());
2970 EXPECT_EQ(active_contents_scale * low_res_factor,
2971 pending_layer_->tilings()->tiling_at(2)->contents_scale());
2972 EXPECT_EQ(pending_contents_scale * low_res_factor,
2973 pending_layer_->tilings()->tiling_at(3)->contents_scale());
2974
2975 EXPECT_EQ(active_contents_scale,
2976 active_layer_->tilings()->tiling_at(0)->contents_scale());
2977 EXPECT_EQ(pending_contents_scale,
2978 active_layer_->tilings()->tiling_at(1)->contents_scale());
2979 EXPECT_EQ(active_contents_scale * low_res_factor,
2980 active_layer_->tilings()->tiling_at(2)->contents_scale());
2981 EXPECT_EQ(pending_contents_scale * low_res_factor,
2982 active_layer_->tilings()->tiling_at(3)->contents_scale());
2983
2984 // The unused low res tiling from the pending tree must be kept or we may add
2985 // it again on the active tree and collide with the pending tree.
2986 used_tilings.push_back(active_layer_->tilings()->tiling_at(1));
2987 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
2988 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings());
2989
2990 EXPECT_EQ(active_contents_scale,
2991 active_layer_->tilings()->tiling_at(0)->contents_scale());
2992 EXPECT_EQ(pending_contents_scale,
2993 active_layer_->tilings()->tiling_at(1)->contents_scale());
2994 EXPECT_EQ(active_contents_scale * low_res_factor,
2995 active_layer_->tilings()->tiling_at(2)->contents_scale());
2996 EXPECT_EQ(pending_contents_scale * low_res_factor,
2997 active_layer_->tilings()->tiling_at(3)->contents_scale());
2998 }
2999
2920 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { 3000 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) {
2921 gfx::Size tile_size(400, 400); 3001 gfx::Size tile_size(400, 400);
2922 gfx::Size layer_bounds(1300, 1900); 3002 gfx::Size layer_bounds(1300, 1900);
2923 3003
2924 scoped_refptr<FakePicturePileImpl> pending_pile = 3004 scoped_refptr<FakePicturePileImpl> pending_pile =
2925 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3005 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2926 scoped_refptr<FakePicturePileImpl> active_pile = 3006 scoped_refptr<FakePicturePileImpl> active_pile =
2927 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3007 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2928 3008
2929 float result_scale_x, result_scale_y; 3009 float result_scale_x, result_scale_y;
(...skipping 25 matching lines...) Expand all
2955 1.f, // maximum animation scale 3035 1.f, // maximum animation scale
2956 false, 3036 false,
2957 &result_scale_x, 3037 &result_scale_x,
2958 &result_scale_y, 3038 &result_scale_y,
2959 &result_bounds); 3039 &result_bounds);
2960 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 3040 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2961 } 3041 }
2962 3042
2963 } // namespace 3043 } // namespace
2964 } // namespace cc 3044 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698