Commit 1ef533e9 authored by Daniel Libby's avatar Daniel Libby Committed by Commit Bot

Remove restrictions for directly compositing images to save tile memory

With cc-based directly composited images, we previously made a decision
to not directly composite images if raster scale and aspect ratio
resulted in filling in tiles that end up truncated when scaled back up
in the display compositor, based on the shared quad state transform.

However, because we don't apply directly composited images in cases
where we used to, we can end up using more tile memory. The example
page from bug 1111621 has over a hundred 1572 x 861 size image layers,
but the image is only 16x16. If we don't directly composite, we run into
the upper limits of allowed tile memory, and tiles start disappearing
(are dropped) on re-draw.

Unfortunately, as raster scale can only be expressed as a single
scaler value, there no way to have tile size match the intrinsic image
size when the aspect ratio of the layer and image are different (the
previous approach was able to do this by encoding x and y scales in the
layer transform - however, our detection of directly composited images
happens later in the pipeline at a time where we cannot alter the
structure of the transform property tree).

This change removes the restriction (and the associated DCHECK
validating it) when the raster scale is less than 0.1, in favor of
applying directly composited images to save memory, over the minor
changes in rendering that may result. The difference in rendering is
that the last row/column of scaled pixels will only be partially filled,
and those pixels will be stretched and clipped at the layer bounds.

Bug: 1111621

Change-Id: I15b83a9f33df72f40ece087ade3e82a513aa596e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355831Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Daniel Libby <dlibby@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#799861}
parent e5fda31c
......@@ -272,7 +272,7 @@ void PictureLayerImpl::AppendQuads(viz::RenderPass* render_pass,
// Validate that the tile and bounds size are always within one pixel.
PictureLayerTiling* high_res =
tilings_->FindTilingWithResolution(HIGH_RESOLUTION);
if (high_res) {
if (raster_contents_scale_ >= 1.f && high_res) {
const float epsilon = 1.f;
gfx::SizeF scaled_tiling_size(high_res->tiling_size());
scaled_tiling_size.Scale(1 / raster_contents_scale_);
......@@ -1091,6 +1091,11 @@ void PictureLayerImpl::SetDirectlyCompositedImageSize(
}
bool PictureLayerImpl::ShouldDirectlyCompositeImage(float raster_scale) const {
// Even if there are minor rendering differences, we want to apply directly
// compositing images in cases where doing so is going to save memory.
if (raster_scale < 0.1f)
return true;
// If the results of scaling the bounds by the expected raster scale
// would end up with a content rect whose width/height are more than one
// pixel different from the layer bounds, don't directly composite the image
......
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