Commit 7923e436 authored by vmpstr's avatar vmpstr Committed by Commit bot

cc: Ensure that skewport.Contains(visible_rect) is always true.

This patch ensures that the skewport contains the visible rect. This
is a required that could be violated by extreme visible rects that
would overflow integer math. The fix is to add an extra union.
Includes a test.

R=enne
BUG=487130

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

Cr-Commit-Position: refs/heads/master@{#330600}
parent 586df8db
...@@ -552,6 +552,13 @@ gfx::Rect PictureLayerTiling::ComputeSkewport( ...@@ -552,6 +552,13 @@ gfx::Rect PictureLayerTiling::ComputeSkewport(
// union in case intersecting would have left the empty rect. // union in case intersecting would have left the empty rect.
skewport.Intersect(max_skewport); skewport.Intersect(max_skewport);
// Due to limits in int's representation, it is possible that the two
// operations above (union and intersect) result in an empty skewport. To
// avoid any unpleasant situations like that, union the visible rect again to
// ensure that skewport.Contains(visible_rect_in_content_space) is always
// true.
skewport.Union(visible_rect_in_content_space);
return skewport; return skewport;
} }
......
...@@ -629,6 +629,30 @@ TEST(PictureLayerTilingTest, SkewportLimits) { ...@@ -629,6 +629,30 @@ TEST(PictureLayerTilingTest, SkewportLimits) {
EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100))); EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100)));
} }
TEST(PictureLayerTilingTest, ComputeSkewportExtremeCases) {
FakePictureLayerTilingClient client;
gfx::Size layer_bounds(200, 200);
client.SetTileSize(gfx::Size(100, 100));
LayerTreeSettings settings;
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds);
scoped_ptr<TestablePictureLayerTiling> tiling =
TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client,
settings);
gfx::Rect viewport1(-1918, 255860, 4010, 2356);
gfx::Rect viewport2(-7088, -91738, 14212, 8350);
gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512);
double time = 1.0;
tiling->ComputeTilePriorityRects(viewport1, 1.f, time, Occlusion());
time += 0.016;
EXPECT_TRUE(tiling->ComputeSkewport(time, viewport2).Contains(viewport2));
tiling->ComputeTilePriorityRects(viewport2, 1.f, time, Occlusion());
time += 0.016;
EXPECT_TRUE(tiling->ComputeSkewport(time, viewport3).Contains(viewport3));
}
TEST(PictureLayerTilingTest, ComputeSkewport) { TEST(PictureLayerTilingTest, ComputeSkewport) {
FakePictureLayerTilingClient client; FakePictureLayerTilingClient client;
......
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