diff options
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 8 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 93d9bf1..695f539 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -52,6 +52,10 @@ const int kMinHeightForGpuRasteredTile = 256; // of using the same tile size. const int kTileRoundUp = 64; +// For performance reasons and to support compressed tile textures, tile +// width and height should be an even multiple of 4 in size. +const int kTileMinimalAlignment = 4; + } // namespace namespace cc { @@ -781,6 +785,10 @@ gfx::Size PictureLayerImpl::CalculateTileSize( tile_height = std::min(tile_height, default_tile_height); } + // Ensure that tile width and height are properly aligned. + tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); + tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); + // Under no circumstance should we be larger than the max texture size. tile_width = std::min(tile_width, max_texture_size); tile_height = std::min(tile_height, max_texture_size); diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 0f73ef1..04bac67 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -4890,8 +4890,10 @@ TEST_F(TileSizeTest, TileSizes) { layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); result = layer->CalculateTileSize(gfx::Size(10000, 10000)); - EXPECT_EQ(result.width(), 2000 + 2 * PictureLayerTiling::kBorderTexels); - EXPECT_EQ(result.height(), 500 + 2); + EXPECT_EQ(result.width(), + MathUtil::UncheckedRoundUp( + 2000 + 2 * PictureLayerTiling::kBorderTexels, 4)); + EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned. // Clamp and round-up, when smaller than viewport. // Tile-height doubles to 50% when width shrinks to <= 50%. @@ -4899,7 +4901,7 @@ TEST_F(TileSizeTest, TileSizes) { layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); result = layer->CalculateTileSize(gfx::Size(447, 10000)); EXPECT_EQ(result.width(), 448); - EXPECT_EQ(result.height(), 500 + 2); + EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aliged. // Largest layer is 50% of viewport width (rounded up), and // 50% of viewport in height. @@ -4908,7 +4910,7 @@ TEST_F(TileSizeTest, TileSizes) { EXPECT_EQ(result.height(), 448); result = layer->CalculateTileSize(gfx::Size(500, 499)); EXPECT_EQ(result.width(), 512); - EXPECT_EQ(result.height(), 500 + 2); + EXPECT_EQ(result.height(), 504); // 500 + 2, 4-byte aligned. } TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { |