Commit 37974aa8 authored by hendrikw's avatar hendrikw Committed by Commit bot

cc: Changed ComputeExpansionDelta to never return a delta less than zero.

The eventually rect was returning as smaller than the visible rect, which
caused tiles to be dropped.  Returning a delta larger or equal to zero
fixes it.

BUG=407776

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

Cr-Commit-Position: refs/heads/master@{#294091}
parent bbfe6ce4
...@@ -823,9 +823,11 @@ int ComputeExpansionDelta(int num_x_edges, int num_y_edges, ...@@ -823,9 +823,11 @@ int ComputeExpansionDelta(int num_x_edges, int num_y_edges,
int64 c = static_cast<int64>(width) * height - target_area; int64 c = static_cast<int64>(width) * height - target_area;
// Compute the delta for our edges using the quadratic equation. // Compute the delta for our edges using the quadratic equation.
return a == 0 ? -c / b : int delta =
(-b + static_cast<int>( (a == 0) ? -c / b : (-b + static_cast<int>(std::sqrt(
std::sqrt(static_cast<int64>(b) * b - 4.0 * a * c))) / (2 * a); static_cast<int64>(b) * b - 4.0 * a * c))) /
(2 * a);
return std::max(0, delta);
} }
} // namespace } // namespace
......
...@@ -869,7 +869,11 @@ TEST(PictureLayerTilingTest, ExpandRectSmaller) { ...@@ -869,7 +869,11 @@ TEST(PictureLayerTilingTest, ExpandRectSmaller) {
EXPECT_EQ(out.bottom() - in.bottom(), in.y() - out.y()); EXPECT_EQ(out.bottom() - in.bottom(), in.y() - out.y());
EXPECT_EQ(out.right() - in.right(), in.x() - out.x()); EXPECT_EQ(out.right() - in.right(), in.x() - out.x());
EXPECT_EQ(out.width() - in.width(), out.height() - in.height()); EXPECT_EQ(out.width() - in.width(), out.height() - in.height());
EXPECT_NEAR(100 * 100, out.width() * out.height(), 50);
// |in| represents the visible rect, and |out| represents the eventually rect.
// If the eventually rect doesn't contain the visible rect, we will start
// losing tiles.
EXPECT_TRUE(out.Contains(in));
EXPECT_TRUE(bounds.Contains(out)); EXPECT_TRUE(bounds.Contains(out));
} }
...@@ -1449,41 +1453,6 @@ TEST_F(PictureLayerTilingIteratorTest, ...@@ -1449,41 +1453,6 @@ TEST_F(PictureLayerTilingIteratorTest,
base::Bind(&TilesIntersectingRectExist, visible_rect, true)); base::Bind(&TilesIntersectingRectExist, visible_rect, true));
} }
static void CountExistingTiles(int *count,
Tile* tile,
const gfx::Rect& geometry_rect) {
if (tile != NULL)
++(*count);
}
TEST_F(PictureLayerTilingIteratorTest,
TilesExistLargeViewportAndLayerWithLargeVisibleArea) {
gfx::Size layer_bounds(10000, 10000);
Initialize(gfx::Size(100, 100), 1.f, layer_bounds);
VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds));
VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false));
client_.set_tree(ACTIVE_TREE);
set_max_tiles_for_interest_area(1);
tiling_->UpdateTilePriorities(
ACTIVE_TREE,
gfx::Rect(layer_bounds), // visible content rect
1.f, // current contents scale
1.0, // current frame time
NULL, // occlusion tracker
NULL, // render target
gfx::Transform()); // draw transform
int num_tiles = 0;
VerifyTiles(1.f,
gfx::Rect(layer_bounds),
base::Bind(&CountExistingTiles, &num_tiles));
// If we're making a rect the size of one tile, it can only overlap up to 4
// tiles depending on its position.
EXPECT_LE(num_tiles, 4);
VerifyTiles(1.f, gfx::Rect(), base::Bind(&TileExists, false));
}
TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) {
gfx::Size layer_bounds(1099, 801); gfx::Size layer_bounds(1099, 801);
gfx::Size tile_size(100, 100); gfx::Size tile_size(100, 100);
......
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