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