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