0

[cc-slimming] No need to expand live_tiles_rect to tile bounds.

TEST=cc_unittests

Bug: 338977414
Change-Id: I66a8dea0e333d06814dac5a9d9d5c3cf04d3d21f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5789072
Reviewed-by: Victor Miura <vmiura@chromium.org>
Auto-Submit: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1341992}
This commit is contained in:
Zhenyao Mo
2024-08-14 22:25:44 +00:00
committed by Chromium LUCI CQ
parent e875d5628a
commit 16b6948e5a
4 changed files with 1 additions and 97 deletions

@@ -162,25 +162,6 @@ IndexRect TilingData::TileAroundIndexRect(const gfx::Rect& center_rect) const {
return IndexRect(around_left, around_right, around_top, around_bottom);
}
gfx::Rect TilingData::ExpandRectIgnoringBordersToTileBounds(
const gfx::Rect& rect) const {
if (rect.IsEmpty() || has_empty_bounds()) {
return gfx::Rect();
}
if (rect.x() > tiling_rect_.right() || rect.y() > tiling_rect_.bottom()) {
return gfx::Rect();
}
int index_x = TileXIndexFromSrcCoord(rect.x());
int index_y = TileYIndexFromSrcCoord(rect.y());
int index_right = TileXIndexFromSrcCoord(rect.right() - 1);
int index_bottom = TileYIndexFromSrcCoord(rect.bottom() - 1);
gfx::Rect rect_top_left(TileBounds(index_x, index_y));
gfx::Rect rect_bottom_right(TileBounds(index_right, index_bottom));
return gfx::UnionRects(rect_top_left, rect_bottom_right);
}
gfx::Rect TilingData::ExpandRectToTileBounds(const gfx::Rect& rect) const {
if (rect.IsEmpty() || has_empty_bounds()) {
return gfx::Rect();

@@ -61,7 +61,6 @@ class CC_BASE_EXPORT TilingData {
// Return the tile indices around the given rect.
IndexRect TileAroundIndexRect(const gfx::Rect& center_rect) const;
gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const;
gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const;
gfx::Rect TileBounds(int i, int j) const;

@@ -961,80 +961,6 @@ TEST_P(TilingDataTest, SetMaxTextureSizeBorders) {
EXPECT_EQ(10, data.num_tiles_y());
}
TEST_P(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsEmpty) {
TilingData empty_total_size(gfx::Size(0, 0), OffsetRect(8, 8), 1);
EXPECT_EQ(gfx::Rect(), empty_total_size.ExpandRectIgnoringBordersToTileBounds(
OffsetRect(0, 0)));
EXPECT_EQ(gfx::Rect(), empty_total_size.ExpandRectIgnoringBordersToTileBounds(
OffsetRect(100, 100, 100, 100)));
EXPECT_EQ(gfx::Rect(), empty_total_size.ExpandRectIgnoringBordersToTileBounds(
OffsetRect(100, 100)));
TilingData empty_max_texture_size(gfx::Size(8, 8), OffsetRect(0, 0), 1);
EXPECT_EQ(gfx::Rect(),
empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
OffsetRect(0, 0)));
EXPECT_EQ(gfx::Rect(),
empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
OffsetRect(100, 100, 100, 100)));
EXPECT_EQ(gfx::Rect(),
empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
OffsetRect(100, 100)));
}
TEST_P(TilingDataTest, ExpandRectIgnoringBordersToTileBounds) {
TilingData data(gfx::Size(4, 4), OffsetRect(16, 32), 1);
// Small rect at tiling rect origin rounds up to tile 0, 0.
gfx::Rect at_origin_src = OffsetRect(1, 1);
gfx::Rect at_origin_result(data.TileBounds(0, 0));
EXPECT_NE(at_origin_src, at_origin_result);
EXPECT_EQ(at_origin_result,
data.ExpandRectIgnoringBordersToTileBounds(at_origin_src));
// Arbitrary internal rect.
gfx::Rect rect_src = OffsetRect(6, 6, 1, 3);
// Tile 2, 2 => OffsetRect(4, 4, 4, 4)
// Tile 2, 3 => OffsetRect(4, 6, 4, 4)
gfx::Rect rect_result(
gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(2, 3)));
EXPECT_NE(rect_src, rect_result);
EXPECT_EQ(rect_result, data.ExpandRectIgnoringBordersToTileBounds(rect_src));
// On tile bounds does not round up to next tile (ignores the border).
gfx::Rect border_rect_src(
gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
gfx::Rect border_rect_result(
gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
EXPECT_EQ(border_rect_result,
data.ExpandRectIgnoringBordersToTileBounds(border_rect_src));
// Equal to tiling rect.
EXPECT_EQ(data.tiling_rect(),
data.ExpandRectIgnoringBordersToTileBounds(data.tiling_rect()));
// Containing, but larger than tiling rect.
EXPECT_EQ(data.tiling_rect(),
data.ExpandRectIgnoringBordersToTileBounds(OffsetRect(100, 100)));
// Non-intersecting with tiling rect.
gfx::Rect non_intersect = OffsetRect(200, 200, 100, 100);
EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect()));
EXPECT_EQ(gfx::Rect(),
data.ExpandRectIgnoringBordersToTileBounds(non_intersect));
TilingData data2(gfx::Size(8, 8), OffsetRect(32, 64), 1);
// Inside other tile border texels doesn't include other tiles.
gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
inner_rect_src.Inset(
gfx::Insets::VH(data.border_texels(), data2.border_texels()));
gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
gfx::Rect expanded =
data2.ExpandRectIgnoringBordersToTileBounds(inner_rect_src);
EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
}
TEST_P(TilingDataTest, ExpandRectToTileBounds) {
TilingData data(gfx::Size(4, 4), OffsetRect(16, 32), 1);

@@ -444,13 +444,11 @@ void PictureLayerTiling::ComputeTilePriorityRects(
gfx::Rect output_rects[4];
for (size_t i = 0; i < std::size(input_rects); ++i)
output_rects[i] = EnclosingContentsRectFromLayerRect(*input_rects[i]);
// Make sure the eventually rect is aligned to tile bounds.
output_rects[3] =
tiling_data_.ExpandRectIgnoringBordersToTileBounds(output_rects[3]);
SetTilePriorityRects(content_to_screen_scale, output_rects[0],
output_rects[1], output_rects[2], output_rects[3],
occlusion_in_layer_space);
output_rects[3].Intersect(tiling_rect());
SetLiveTilesRect(output_rects[3]);
}