Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2697)

Unified Diff: cc/layers/picture_layer_impl.cc

Issue 2099903002: Make tile size a function of the device scale factor. Base URL: https://chromium.googlesource.com/chromium/src.git@layouttests-display
Patch Set: tilesize: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layers/picture_layer_impl.cc
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 56fcfecbfe559b8a5827426e681d925be025c026..d17dfb4b180291ac7317e92bf78395728522e134 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -51,6 +51,11 @@ const int kMinHeightForGpuRasteredTile = 256;
// of using the same tile size.
const int kTileRoundUp = 64;
+// When sizing tiles relative to the viewport, we keep them as a multiple of
+// this.
+// TODO(crbug.com/622885) But why not just use kTileMinimalAlignment.
enne (OOO) 2016/06/28 18:39:01 I suspect it's for the same reason as kTileRoundUp
+const int kTileViewportAlignment = 32;
+
// 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;
@@ -715,15 +720,15 @@ gfx::Size PictureLayerImpl::CalculateTileSize(
return content_bounds;
}
- int default_tile_width = 0;
- int default_tile_height = 0;
+ int tile_width = 0;
+ int tile_height = 0;
if (layer_tree_impl()->use_gpu_rasterization()) {
enne (OOO) 2016/06/28 18:39:01 This function is a little long and hard to read.
// For GPU rasterization, we pick an ideal tile size using the viewport
// so we don't need any settings. The current approach uses 4 tiles
// to cover the viewport vertically.
int viewport_width = gpu_raster_max_texture_size_.width();
int viewport_height = gpu_raster_max_texture_size_.height();
- default_tile_width = viewport_width;
+ tile_width = viewport_width;
// Also, increase the height proportionally as the width decreases, and
// pad by our border texels to make the tiles exactly match the viewport.
@@ -732,50 +737,85 @@ gfx::Size PictureLayerImpl::CalculateTileSize(
divisor = 2;
if (content_bounds.width() <= viewport_width / 4)
divisor = 1;
- default_tile_height =
+ tile_height =
MathUtil::UncheckedRoundUp(viewport_height, divisor) / divisor;
// Grow default sizes to account for overlapping border texels.
- default_tile_width += 2 * PictureLayerTiling::kBorderTexels;
- default_tile_height += 2 * PictureLayerTiling::kBorderTexels;
+ tile_width += 2 * PictureLayerTiling::kBorderTexels;
+ tile_height += 2 * PictureLayerTiling::kBorderTexels;
- default_tile_height =
- std::max(default_tile_height, kMinHeightForGpuRasteredTile);
+ tile_height = std::max(tile_height, kMinHeightForGpuRasteredTile);
} else {
- // For CPU rasterization we use tile-size settings.
+ // For CPU rasterization we use stuff.
enne (OOO) 2016/06/28 18:39:01 stuff, eh?
+ int tile_size;
vmpstr 2016/06/29 01:40:23 Initialize to 0, so that DCHECK on 787 fails if we
const LayerTreeSettings& settings = layer_tree_impl()->settings();
- int max_untiled_content_width = settings.max_untiled_layer_size.width();
- int max_untiled_content_height = settings.max_untiled_layer_size.height();
- default_tile_width = settings.default_tile_size.width();
- default_tile_height = settings.default_tile_size.height();
-
- // If the content width is small, increase tile size vertically.
- // If the content height is small, increase tile size horizontally.
- // If both are less than the untiled-size, use a single tile.
- if (content_bounds.width() < default_tile_width)
- default_tile_height = max_untiled_content_height;
- if (content_bounds.height() < default_tile_height)
- default_tile_width = max_untiled_content_width;
- if (content_bounds.width() < max_untiled_content_width &&
- content_bounds.height() < max_untiled_content_height) {
- default_tile_height = max_untiled_content_height;
- default_tile_width = max_untiled_content_width;
+ // TODO(crbug.com/622885): Supply the physical device size along with the
+ // device scale factor to layer tree host. Use that instead of the viewport.
+ // Then we should have use_viewport_for_tile_size always be true, and use it
+ // for ganesh also (maybe with different |num_tiles| for it).
+ if (settings.use_viewport_for_tile_size) {
+ int min_tile_size = 256;
+ int max_tile_size = 512;
+
+ gfx::Size stable_size = layer_tree_impl()->GetStableScreenSize();
+ int display_width = stable_size.width();
+ int display_height = stable_size.height();
+
+ // Pick tile sizes for portrait mode on small screens. On bigger screens
+ // we'll use the max tile sizes anyhow.
+ if (display_width > display_height)
+ std::swap(display_width, display_height);
+ int num_tiles = 3;
vmpstr 2016/06/29 01:40:23 can you const int kNumTiles this?
+
+ // Tiles overlap by a border, so make the display seem that many pixels
+ // larger.
+ display_width += (num_tiles - 1) * PictureLayerTiling::kBorderTexels;
+
+ // These are the ideal tile size to put |num_tiles| across the screen at a
+ // time, rounded up to a multiple of kTileViewportAlignment, so the last
+ // tile will end up usually entending past the right edge of the screen a
+ // bit.
+ tile_size = MathUtil::UncheckedRoundUp(
+ (display_width + num_tiles - 1) / num_tiles, kTileViewportAlignment);
+ tile_size = std::max(tile_size, min_tile_size);
+ tile_size = std::min(tile_size, max_tile_size);
+ } else {
+ tile_size = 256;
+ if (layer_tree_impl()->device_scale_factor() >= 2.f)
+ tile_size = 512;
+ }
+ DCHECK_GT(tile_size, 0);
+
+ tile_width = tile_height = tile_size;
+
+ if (content_bounds.width() < kMaxUntiledContentSize &&
+ content_bounds.height() < kMaxUntiledContentSize) {
+ // Small layers should not be tiled.
+ tile_width = tile_height = kMaxUntiledContentSize;
+ } else if (content_bounds.width() < tile_width) {
+ // If the content width is small, increase tile size vertically.
+ tile_height *= 2;
vmpstr 2016/06/29 01:40:23 Kind of overly safe, but can this break kMaxUntile
+ } else if (content_bounds.height() < tile_height) {
+ // If the content height is small, increase tile size horizontally.
+ tile_width *= 2;
}
}
-
- int tile_width = default_tile_width;
- int tile_height = default_tile_height;
-
- // Clamp the tile width/height to the content width/height to save space.
- if (content_bounds.width() < default_tile_width) {
- tile_width = std::min(tile_width, content_bounds.width());
- tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp);
- tile_width = std::min(tile_width, default_tile_width);
+ DCHECK_GT(tile_width, 0);
+ DCHECK_GT(tile_height, 0);
+
+ // Shrink the tile width/height to be closer content width/height to save
enne (OOO) 2016/06/28 18:39:01 closer...to?
+ // space, if there's a smaller multiple of kTileRoundUp.
+ if (content_bounds.width() < tile_width) {
+ int before_tile_width = tile_width;
+ tile_width =
+ MathUtil::UncheckedRoundUp(content_bounds.width(), kTileRoundUp);
+ tile_width = std::min(tile_width, before_tile_width);
}
- if (content_bounds.height() < default_tile_height) {
- tile_height = std::min(tile_height, content_bounds.height());
- tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp);
- tile_height = std::min(tile_height, default_tile_height);
+ if (content_bounds.height() < tile_height) {
+ int before_tile_height = tile_height;
+ tile_height =
+ MathUtil::UncheckedRoundUp(content_bounds.height(), kTileRoundUp);
+ tile_height = std::min(tile_height, before_tile_height);
}
// Ensure that tile width and height are properly aligned.

Powered by Google App Engine
This is Rietveld 408576698