Commit 30d77173 authored by epenner's avatar epenner Committed by Commit bot

CC: Have GPU-raster tiles exactly match the viewport.

The previous logic doesn't account for divide truncation and
border texels, resulting in an additional visible tile with
only a couple of rows visible. This is hidden by the URL bar
sometimes, but it still affects full-screen, web-apps and
desktop browsers.

BUG=365877

Review URL: https://codereview.chromium.org/626113004

Cr-Commit-Position: refs/heads/master@{#299201}
parent 29f16221
...@@ -45,9 +45,9 @@ const float kCpuSkewportTargetTimeInFrames = 60.0f; ...@@ -45,9 +45,9 @@ const float kCpuSkewportTargetTimeInFrames = 60.0f;
const float kGpuSkewportTargetTimeInFrames = 0.0f; const float kGpuSkewportTargetTimeInFrames = 0.0f;
// Even for really wide viewports, at some point GPU raster should use // Even for really wide viewports, at some point GPU raster should use
// less than 4 tiles to fill the viewport. This is set to 128 as a // less than 4 tiles to fill the viewport. This is set to 256 as a
// sane minimum for now, but we might want to increase with tuning. // sane minimum for now, but we might want to tune this for low-end.
const int kMinHeightForGpuRasteredTile = 128; const int kMinHeightForGpuRasteredTile = 256;
// When making odd-sized tiles, round them up to increase the chances // When making odd-sized tiles, round them up to increase the chances
// of using the same tile size. // of using the same tile size.
...@@ -695,14 +695,17 @@ gfx::Size PictureLayerImpl::CalculateTileSize( ...@@ -695,14 +695,17 @@ gfx::Size PictureLayerImpl::CalculateTileSize(
int viewport_width = layer_tree_impl()->device_viewport_size().width(); int viewport_width = layer_tree_impl()->device_viewport_size().width();
int viewport_height = layer_tree_impl()->device_viewport_size().height(); int viewport_height = layer_tree_impl()->device_viewport_size().height();
default_tile_width = viewport_width; default_tile_width = viewport_width;
default_tile_height = viewport_height / 4; // Also, increase the height proportionally as the width decreases, and
// pad by our border texels to make the tiles exactly match the viewport.
int divisor = 4;
if (content_bounds.width() <= viewport_width / 2)
divisor = 2;
if (content_bounds.width() <= viewport_width / 4)
divisor = 1;
default_tile_height = RoundUp(viewport_height, divisor) / divisor;
default_tile_height += 2 * PictureLayerTiling::kBorderTexels;
default_tile_height = default_tile_height =
std::max(default_tile_height, kMinHeightForGpuRasteredTile); std::max(default_tile_height, kMinHeightForGpuRasteredTile);
// Increase the tile-height proportionally when the content width
// drops below half the viewport width.
if (content_bounds.width() <= viewport_width / 2)
default_tile_height *= 2;
} else { } else {
// For CPU rasterization we use tile-size settings. // For CPU rasterization we use tile-size settings.
const LayerTreeSettings& settings = layer_tree_impl()->settings(); const LayerTreeSettings& settings = layer_tree_impl()->settings();
......
...@@ -4470,8 +4470,7 @@ TEST_F(TileSizeTest, TileSizes) { ...@@ -4470,8 +4470,7 @@ TEST_F(TileSizeTest, TileSizes) {
scoped_ptr<FakePictureLayerImpl> layer = scoped_ptr<FakePictureLayerImpl> layer =
FakePictureLayerImpl::Create(pending_tree, id_); FakePictureLayerImpl::Create(pending_tree, id_);
gfx::Size viewport_size = gfx::Size(1000, 1000); host_impl_.SetViewportSize(gfx::Size(1000, 1000));
host_impl_.SetViewportSize(viewport_size);
gfx::Size result; gfx::Size result;
host_impl_.SetUseGpuRasterization(false); host_impl_.SetUseGpuRasterization(false);
...@@ -4484,29 +4483,27 @@ TEST_F(TileSizeTest, TileSizes) { ...@@ -4484,29 +4483,27 @@ TEST_F(TileSizeTest, TileSizes) {
result = layer->CalculateTileSize(gfx::Size(42, 42)); result = layer->CalculateTileSize(gfx::Size(42, 42));
EXPECT_EQ(result.width(), 64); EXPECT_EQ(result.width(), 64);
EXPECT_EQ(result.height(), 64); EXPECT_EQ(result.height(), 64);
result = layer->CalculateTileSize(gfx::Size(184, 184)); result = layer->CalculateTileSize(gfx::Size(191, 191));
EXPECT_EQ(result.width(), 192); EXPECT_EQ(result.width(), 192);
EXPECT_EQ(result.height(), 192); EXPECT_EQ(result.height(), 192);
result = layer->CalculateTileSize(gfx::Size(199, 199)); result = layer->CalculateTileSize(gfx::Size(199, 199));
EXPECT_EQ(result.width(), 200); EXPECT_EQ(result.width(), 200);
EXPECT_EQ(result.height(), 200); EXPECT_EQ(result.height(), 200);
host_impl_.SetUseGpuRasterization(true);
// Gpu-rasterization uses 25% viewport-height tiles. // Gpu-rasterization uses 25% viewport-height tiles.
// The +2's below are for border texels.
host_impl_.SetUseGpuRasterization(true);
host_impl_.SetViewportSize(gfx::Size(2000, 2000));
result = layer->CalculateTileSize(gfx::Size(10000, 10000)); result = layer->CalculateTileSize(gfx::Size(10000, 10000));
EXPECT_EQ(result.width(), 1000); EXPECT_EQ(result.width(), 2000);
EXPECT_EQ(result.height(), 250); EXPECT_EQ(result.height(), 500 + 2);
// Clamp and round-up, when smaller than viewport. // Clamp and round-up, when smaller than viewport.
result = layer->CalculateTileSize(gfx::Size(831, 10000));
EXPECT_EQ(result.width(), 832);
EXPECT_EQ(result.height(), 250);
// Tile-height doubles to 50% when width shrinks to <= 50%. // Tile-height doubles to 50% when width shrinks to <= 50%.
host_impl_.SetViewportSize(gfx::Size(1000, 1000));
result = layer->CalculateTileSize(gfx::Size(447, 10000)); result = layer->CalculateTileSize(gfx::Size(447, 10000));
EXPECT_EQ(result.width(), 448); EXPECT_EQ(result.width(), 448);
EXPECT_EQ(result.height(), 500); EXPECT_EQ(result.height(), 500 + 2);
// Largest layer is 50% of viewport width (rounded up), and // Largest layer is 50% of viewport width (rounded up), and
// 50% of viewport in height. // 50% of viewport in height.
...@@ -4515,7 +4512,7 @@ TEST_F(TileSizeTest, TileSizes) { ...@@ -4515,7 +4512,7 @@ TEST_F(TileSizeTest, TileSizes) {
EXPECT_EQ(result.height(), 448); EXPECT_EQ(result.height(), 448);
result = layer->CalculateTileSize(gfx::Size(500, 499)); result = layer->CalculateTileSize(gfx::Size(500, 499));
EXPECT_EQ(result.width(), 512); EXPECT_EQ(result.width(), 512);
EXPECT_EQ(result.height(), 500); EXPECT_EQ(result.height(), 500 + 2);
} }
} // namespace } // namespace
......
...@@ -72,7 +72,7 @@ PictureLayerTiling::PictureLayerTiling(float contents_scale, ...@@ -72,7 +72,7 @@ PictureLayerTiling::PictureLayerTiling(float contents_scale,
layer_bounds_(layer_bounds), layer_bounds_(layer_bounds),
resolution_(NON_IDEAL_RESOLUTION), resolution_(NON_IDEAL_RESOLUTION),
client_(client), client_(client),
tiling_data_(gfx::Size(), gfx::Size(), true), tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels),
last_impl_frame_time_in_seconds_(0.0), last_impl_frame_time_in_seconds_(0.0),
content_to_screen_scale_(0.f), content_to_screen_scale_(0.f),
can_require_tiles_for_activation_(false), can_require_tiles_for_activation_(false),
......
...@@ -58,6 +58,8 @@ class CC_EXPORT PictureLayerTilingClient { ...@@ -58,6 +58,8 @@ class CC_EXPORT PictureLayerTilingClient {
class CC_EXPORT PictureLayerTiling { class CC_EXPORT PictureLayerTiling {
public: public:
static const int kBorderTexels = 1;
enum EvictionCategory { enum EvictionCategory {
EVENTUALLY, EVENTUALLY,
EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION, EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment