diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-14 03:07:28 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-14 03:07:28 +0000 |
commit | 60f06b1af0223cd7d8bafeb2dd9a54093992a39c (patch) | |
tree | 596ea0ece6b3589687309d62ac42261a7587215a /cc/base | |
parent | 643e58b5c1b0c869c6f51548d4ec9f7cabe83149 (diff) | |
download | chromium_src-60f06b1af0223cd7d8bafeb2dd9a54093992a39c.zip chromium_src-60f06b1af0223cd7d8bafeb2dd9a54093992a39c.tar.gz chromium_src-60f06b1af0223cd7d8bafeb2dd9a54093992a39c.tar.bz2 |
cc: Use ExpandRectIgnoringBordersToTileBoundsWithBordersEmpty.
When expanding the live tiles rect, we want to include border pixels
for all tiles that intersect the live tiles rect. It used to do this
by also including any tiles whose border pixels intersect the live
tiles rect, but that's excessive.
This adds ExpandRectIgnoringBordersToTileBoundsWithBordersEmpty and
uses it to expand the live tiles rect, the unit test
PictureLayerTilingIteratorTest.ResizeOverBorderPixelsDeletesTiles
covers this usage of the method.
The ExpandRectToTileBoundsWithBorders is no longer used, so remove it.
R=enne
BUG=386998
Review URL: https://codereview.chromium.org/385123006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base')
-rw-r--r-- | cc/base/tiling_data.cc | 10 | ||||
-rw-r--r-- | cc/base/tiling_data.h | 3 | ||||
-rw-r--r-- | cc/base/tiling_data_unittest.cc | 73 |
3 files changed, 50 insertions, 36 deletions
diff --git a/cc/base/tiling_data.cc b/cc/base/tiling_data.cc index 185bbed..6921a8b 100644 --- a/cc/base/tiling_data.cc +++ b/cc/base/tiling_data.cc @@ -138,14 +138,14 @@ int TilingData::LastBorderTileYIndexFromSrcCoord(int src_position) const { return std::min(std::max(y, 0), num_tiles_y_ - 1); } -gfx::Rect TilingData::ExpandRectToTileBoundsWithBorders( +gfx::Rect TilingData::ExpandRectIgnoringBordersToTileBoundsWithBorders( const gfx::Rect& rect) const { if (!rect.Intersects(tiling_rect_) || has_empty_bounds()) return gfx::Rect(); - int index_x = FirstBorderTileXIndexFromSrcCoord(rect.x()); - int index_y = FirstBorderTileYIndexFromSrcCoord(rect.y()); - int index_right = LastBorderTileXIndexFromSrcCoord(rect.right() - 1); - int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); + 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(TileBoundsWithBorder(index_x, index_y)); gfx::Rect rect_bottom_right(TileBoundsWithBorder(index_right, index_bottom)); diff --git a/cc/base/tiling_data.h b/cc/base/tiling_data.h index 8550e5f..94bee34 100644 --- a/cc/base/tiling_data.h +++ b/cc/base/tiling_data.h @@ -52,7 +52,8 @@ class CC_EXPORT TilingData { int LastBorderTileXIndexFromSrcCoord(int src_position) const; int LastBorderTileYIndexFromSrcCoord(int src_position) const; - gfx::Rect ExpandRectToTileBoundsWithBorders(const gfx::Rect& rect) const; + gfx::Rect ExpandRectIgnoringBordersToTileBoundsWithBorders( + const gfx::Rect& rect) const; gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; gfx::Rect TileBounds(int i, int j) const; diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc index 84d9e79..0bf601a 100644 --- a/cc/base/tiling_data_unittest.cc +++ b/cc/base/tiling_data_unittest.cc @@ -2133,34 +2133,40 @@ TEST_P(TilingDataTest, SetMaxTextureSizeBorders) { EXPECT_EQ(10, data.num_tiles_y()); } -TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBordersEmpty) { +TEST_P(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsWithBordersEmpty) { gfx::Point origin = GetParam(); TilingData empty_total_size( gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(8, 8)), true); EXPECT_RECT_EQ( gfx::Rect(), - empty_total_size.ExpandRectToTileBoundsWithBorders(gfx::Rect())); - EXPECT_RECT_EQ(gfx::Rect(), - empty_total_size.ExpandRectToTileBoundsWithBorders( - gfx::Rect(100, 100, 100, 100))); - EXPECT_RECT_EQ(gfx::Rect(), - empty_total_size.ExpandRectToTileBoundsWithBorders( - gfx::Rect(0, 0, 100, 100))); + empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders( + gfx::Rect())); + EXPECT_RECT_EQ( + gfx::Rect(), + empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders( + gfx::Rect(100, 100, 100, 100))); + EXPECT_RECT_EQ( + gfx::Rect(), + empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders( + gfx::Rect(0, 0, 100, 100))); TilingData empty_max_texture_size( gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(0, 0)), true); EXPECT_RECT_EQ( gfx::Rect(), - empty_max_texture_size.ExpandRectToTileBoundsWithBorders(gfx::Rect())); - EXPECT_RECT_EQ(gfx::Rect(), - empty_max_texture_size.ExpandRectToTileBoundsWithBorders( - gfx::Rect(100, 100, 100, 100))); - EXPECT_RECT_EQ(gfx::Rect(), - empty_max_texture_size.ExpandRectToTileBoundsWithBorders( - gfx::Rect(0, 0, 100, 100))); + empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders( + gfx::Rect())); + EXPECT_RECT_EQ( + gfx::Rect(), + empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders( + gfx::Rect(100, 100, 100, 100))); + EXPECT_RECT_EQ( + gfx::Rect(), + empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders( + gfx::Rect(0, 0, 100, 100))); } -TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) { +TEST_P(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsWithBorders) { gfx::Point origin = GetParam(); TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true); @@ -2168,40 +2174,46 @@ TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) { gfx::Rect at_origin_src(origin, gfx::Size(1, 1)); gfx::Rect at_origin_result(data.TileBoundsWithBorder(0, 0)); EXPECT_NE(at_origin_src, at_origin_result); - EXPECT_RECT_EQ(at_origin_result, - data.ExpandRectToTileBoundsWithBorders(at_origin_src)); + EXPECT_RECT_EQ( + at_origin_result, + data.ExpandRectIgnoringBordersToTileBoundsWithBorders(at_origin_src)); // Arbitrary internal rect. gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3); // Tile 2, 2 => gfx::Rect(4, 4, 4, 4) - // Tile 3, 4 => gfx::Rect(6, 8, 4, 4) + // Tile 2, 3 => gfx::Rect(4, 6, 4, 4) gfx::Rect rect_result(gfx::UnionRects(data.TileBoundsWithBorder(2, 2), - data.TileBoundsWithBorder(3, 4))); + data.TileBoundsWithBorder(2, 3))); EXPECT_NE(rect_src, rect_result); - EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBoundsWithBorders(rect_src)); + EXPECT_RECT_EQ( + rect_result, + data.ExpandRectIgnoringBordersToTileBoundsWithBorders(rect_src)); - // On tile bounds rounds up to next tile (since border overlaps). + // 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.TileBoundsWithBorder(0, 1), data.TileBoundsWithBorder(4, 5))); - EXPECT_RECT_EQ(border_rect_result, - data.ExpandRectToTileBoundsWithBorders(border_rect_src)); + data.TileBoundsWithBorder(1, 2), data.TileBoundsWithBorder(3, 4))); + EXPECT_RECT_EQ( + border_rect_result, + data.ExpandRectIgnoringBordersToTileBoundsWithBorders(border_rect_src)); // Equal to tiling rect. EXPECT_RECT_EQ(data.tiling_rect(), - data.ExpandRectToTileBoundsWithBorders(data.tiling_rect())); + data.ExpandRectIgnoringBordersToTileBoundsWithBorders( + data.tiling_rect())); // Containing, but larger than tiling rect. EXPECT_RECT_EQ(data.tiling_rect(), - data.ExpandRectToTileBoundsWithBorders( + data.ExpandRectIgnoringBordersToTileBoundsWithBorders( gfx::Rect(origin, gfx::Size(100, 100)))); // Non-intersecting with tiling rect. gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100); EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect())); - EXPECT_RECT_EQ(gfx::Rect(), - data.ExpandRectToTileBoundsWithBorders(non_intersect)); + EXPECT_RECT_EQ( + gfx::Rect(), + data.ExpandRectIgnoringBordersToTileBoundsWithBorders(non_intersect)); TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true); @@ -2209,7 +2221,8 @@ TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) { gfx::Rect inner_rect_src(data2.TileBounds(1, 1)); inner_rect_src.Inset(data2.border_texels(), data.border_texels()); gfx::Rect inner_rect_result(data2.TileBoundsWithBorder(1, 1)); - gfx::Rect expanded = data2.ExpandRectToTileBoundsWithBorders(inner_rect_src); + gfx::Rect expanded = + data2.ExpandRectIgnoringBordersToTileBoundsWithBorders(inner_rect_src); EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString()); } |