Commit 493db032 authored by Daniel Libby's avatar Daniel Libby Committed by Commit Bot

Relax DCHECK in PictureLayerTiling constructor

This allows small raster scales like we see for some directly
composited images to not trip over this particular DCHECK. Since these
raster scales are all chosen by inverting the minimum dimension of the
layer bounds, these minimum values round trip, and the resulting tiles
won't be empty as they are doing a EnclosingContentsRectFromLayerRect
to compute the tiling (and tile) size.

Bug: 1124342
Change-Id: Ifb364e7d569d66903a04f9e4c80d56fc3ef8b9da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398985Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Daniel Libby <dlibby@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#806712}
parent 22482ccf
......@@ -50,12 +50,21 @@ PictureLayerTiling::PictureLayerTiling(
DCHECK_GE(raster_transform.translation().y(), 0.f);
DCHECK_LT(raster_transform.translation().y(), 1.f);
DCHECK(!gfx::ScaleToFlooredSize(raster_source_->GetSize(),
raster_transform.scale())
.IsEmpty())
#if DCHECK_IS_ON()
gfx::SizeF scaled_source_size(gfx::ScaleSize(
gfx::SizeF(raster_source_->GetSize()), raster_transform.scale()));
gfx::Size floored_size = gfx::ToFlooredSize(scaled_source_size);
bool is_width_empty =
!floored_size.width() &&
!MathUtil::IsWithinEpsilon(scaled_source_size.width(), 1.f);
bool is_height_empty =
!floored_size.height() &&
!MathUtil::IsWithinEpsilon(scaled_source_size.height(), 1.f);
DCHECK(!is_width_empty && !is_height_empty)
<< "Tiling created with scale too small as contents become empty."
<< " Layer bounds: " << raster_source_->GetSize().ToString()
<< " Raster transform: " << raster_transform_.ToString();
#endif
gfx::Rect content_bounds_rect =
EnclosingContentsRectFromLayerRect(gfx::Rect(raster_source_->GetSize()));
......
......@@ -1316,5 +1316,18 @@ TEST_F(PictureLayerTilingIteratorTest, EdgeCaseLargeIntBounds2) {
}
}
TEST_F(PictureLayerTilingIteratorTest, SmallRasterTransforms) {
gfx::Size tile_size(1, 1);
gfx::Size layer_bounds(4357, 4357);
float scale = 1.f / layer_bounds.width();
Initialize(tile_size, scale, layer_bounds);
EXPECT_EQ(tiling_->tiling_size(), tile_size);
layer_bounds = {378, 378};
scale = 1.f / layer_bounds.width();
Initialize(tile_size, scale, layer_bounds);
EXPECT_EQ(tiling_->tiling_size(), tile_size);
}
} // namespace
} // namespace cc
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