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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 4872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4883 EXPECT_EQ(result.height(), 200); | 4883 EXPECT_EQ(result.height(), 200); |
4884 | 4884 |
4885 // Gpu-rasterization uses 25% viewport-height tiles. | 4885 // Gpu-rasterization uses 25% viewport-height tiles. |
4886 // The +2's below are for border texels. | 4886 // The +2's below are for border texels. |
4887 host_impl_.SetHasGpuRasterizationTrigger(true); | 4887 host_impl_.SetHasGpuRasterizationTrigger(true); |
4888 EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON); | 4888 EXPECT_EQ(host_impl_.gpu_rasterization_status(), GpuRasterizationStatus::ON); |
4889 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); | 4889 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); |
4890 | 4890 |
4891 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); | 4891 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); |
4892 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4892 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
4893 EXPECT_EQ(result.width(), 2000 + 2 * PictureLayerTiling::kBorderTexels); | 4893 EXPECT_EQ(result.width(), |
4894 EXPECT_EQ(result.height(), 500 + 2); | 4894 MathUtil::UncheckedRoundUp( |
| 4895 2000 + 2 * PictureLayerTiling::kBorderTexels, 4)); |
| 4896 EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned. |
4895 | 4897 |
4896 // Clamp and round-up, when smaller than viewport. | 4898 // Clamp and round-up, when smaller than viewport. |
4897 // Tile-height doubles to 50% when width shrinks to <= 50%. | 4899 // Tile-height doubles to 50% when width shrinks to <= 50%. |
4898 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); | 4900 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); |
4899 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); | 4901 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); |
4900 result = layer->CalculateTileSize(gfx::Size(447, 10000)); | 4902 result = layer->CalculateTileSize(gfx::Size(447, 10000)); |
4901 EXPECT_EQ(result.width(), 448); | 4903 EXPECT_EQ(result.width(), 448); |
4902 EXPECT_EQ(result.height(), 500 + 2); | 4904 EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aliged. |
4903 | 4905 |
4904 // Largest layer is 50% of viewport width (rounded up), and | 4906 // Largest layer is 50% of viewport width (rounded up), and |
4905 // 50% of viewport in height. | 4907 // 50% of viewport in height. |
4906 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4908 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4907 EXPECT_EQ(result.width(), 448); | 4909 EXPECT_EQ(result.width(), 448); |
4908 EXPECT_EQ(result.height(), 448); | 4910 EXPECT_EQ(result.height(), 448); |
4909 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4911 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4910 EXPECT_EQ(result.width(), 512); | 4912 EXPECT_EQ(result.width(), 512); |
4911 EXPECT_EQ(result.height(), 500 + 2); | 4913 EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned. |
4912 } | 4914 } |
4913 | 4915 |
4914 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { | 4916 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { |
4915 gfx::Size layer_bounds(1300, 1900); | 4917 gfx::Size layer_bounds(1300, 1900); |
4916 | 4918 |
4917 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 4919 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
4918 SetupDefaultTrees(layer_bounds); | 4920 SetupDefaultTrees(layer_bounds); |
4919 ResetTilingsAndRasterScales(); | 4921 ResetTilingsAndRasterScales(); |
4920 | 4922 |
4921 float page_scale = 2.f; | 4923 float page_scale = 2.f; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4990 // New low res tiling. | 4992 // New low res tiling. |
4991 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 4993 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
4992 | 4994 |
4993 // This tiling will be high res now, it won't contain low res content since it | 4995 // This tiling will be high res now, it won't contain low res content since it |
4994 // was all destroyed. | 4996 // was all destroyed. |
4995 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 4997 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
4996 } | 4998 } |
4997 | 4999 |
4998 } // namespace | 5000 } // namespace |
4999 } // namespace cc | 5001 } // namespace cc |
OLD | NEW |