OLD | NEW |
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 4966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4977 EXPECT_EQ(result.height(), 200); | 4977 EXPECT_EQ(result.height(), 200); |
4978 | 4978 |
4979 // Gpu-rasterization uses 25% viewport-height tiles. | 4979 // Gpu-rasterization uses 25% viewport-height tiles. |
4980 // The +2's below are for border texels. | 4980 // The +2's below are for border texels. |
4981 host_impl_.SetHasGpuRasterizationTrigger(true); | 4981 host_impl_.SetHasGpuRasterizationTrigger(true); |
4982 EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON); | 4982 EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON); |
4983 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); | 4983 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); |
4984 | 4984 |
4985 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); | 4985 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); |
4986 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4986 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
4987 EXPECT_EQ(result.width(), | 4987 EXPECT_EQ(result.width(), 2000 + 2 * PictureLayerTiling::kBorderTexels); |
4988 MathUtil::UncheckedRoundUp( | 4988 EXPECT_EQ(result.height(), 500 + 2); |
4989 2000 + 2 * PictureLayerTiling::kBorderTexels, 4)); | |
4990 EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned. | |
4991 | 4989 |
4992 // Clamp and round-up, when smaller than viewport. | 4990 // Clamp and round-up, when smaller than viewport. |
4993 // Tile-height doubles to 50% when width shrinks to <= 50%. | 4991 // Tile-height doubles to 50% when width shrinks to <= 50%. |
4994 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); | 4992 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); |
4995 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); | 4993 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); |
4996 result = layer->CalculateTileSize(gfx::Size(447, 10000)); | 4994 result = layer->CalculateTileSize(gfx::Size(447, 10000)); |
4997 EXPECT_EQ(result.width(), 448); | 4995 EXPECT_EQ(result.width(), 448); |
4998 EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aliged. | 4996 EXPECT_EQ(result.height(), 500 + 2); |
4999 | 4997 |
5000 // Largest layer is 50% of viewport width (rounded up), and | 4998 // Largest layer is 50% of viewport width (rounded up), and |
5001 // 50% of viewport in height. | 4999 // 50% of viewport in height. |
5002 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 5000 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
5003 EXPECT_EQ(result.width(), 448); | 5001 EXPECT_EQ(result.width(), 448); |
5004 EXPECT_EQ(result.height(), 448); | 5002 EXPECT_EQ(result.height(), 448); |
5005 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 5003 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
5006 EXPECT_EQ(result.width(), 512); | 5004 EXPECT_EQ(result.width(), 512); |
5007 EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned. | 5005 EXPECT_EQ(result.height(), 500 + 2); |
5008 } | 5006 } |
5009 | 5007 |
5010 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { | 5008 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { |
5011 gfx::Size layer_bounds(1300, 1900); | 5009 gfx::Size layer_bounds(1300, 1900); |
5012 | 5010 |
5013 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 5011 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
5014 SetupDefaultTrees(layer_bounds); | 5012 SetupDefaultTrees(layer_bounds); |
5015 ResetTilingsAndRasterScales(); | 5013 ResetTilingsAndRasterScales(); |
5016 | 5014 |
5017 float page_scale = 2.f; | 5015 float page_scale = 2.f; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5086 // New low res tiling. | 5084 // New low res tiling. |
5087 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 5085 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
5088 | 5086 |
5089 // This tiling will be high res now, it won't contain low res content since it | 5087 // This tiling will be high res now, it won't contain low res content since it |
5090 // was all destroyed. | 5088 // was all destroyed. |
5091 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 5089 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
5092 } | 5090 } |
5093 | 5091 |
5094 } // namespace | 5092 } // namespace |
5095 } // namespace cc | 5093 } // namespace cc |
OLD | NEW |