summaryrefslogtreecommitdiffstats
path: root/cc/tiles
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2015-05-19 13:44:27 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-19 20:44:20 +0000
commit7923e436272f671334bc4d75edad97c67bc02212 (patch)
tree6104316c9c1281278537f03ea49cd1f6cc3988f8 /cc/tiles
parent586df8dbac3349c087cae5197f0709ce26989bee (diff)
downloadchromium_src-7923e436272f671334bc4d75edad97c67bc02212.zip
chromium_src-7923e436272f671334bc4d75edad97c67bc02212.tar.gz
chromium_src-7923e436272f671334bc4d75edad97c67bc02212.tar.bz2
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}
Diffstat (limited to 'cc/tiles')
-rw-r--r--cc/tiles/picture_layer_tiling.cc7
-rw-r--r--cc/tiles/picture_layer_tiling_unittest.cc24
2 files changed, 31 insertions, 0 deletions
diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc
index 8db2352..3ae1ad9 100644
--- a/cc/tiles/picture_layer_tiling.cc
+++ b/cc/tiles/picture_layer_tiling.cc
@@ -552,6 +552,13 @@ gfx::Rect PictureLayerTiling::ComputeSkewport(
// union in case intersecting would have left the empty rect.
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;
}
diff --git a/cc/tiles/picture_layer_tiling_unittest.cc b/cc/tiles/picture_layer_tiling_unittest.cc
index 3539b6d..31caf46 100644
--- a/cc/tiles/picture_layer_tiling_unittest.cc
+++ b/cc/tiles/picture_layer_tiling_unittest.cc
@@ -629,6 +629,30 @@ TEST(PictureLayerTilingTest, SkewportLimits) {
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) {
FakePictureLayerTilingClient client;