Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3548)

Unified Diff: cc/base/tiling_data_unittest.cc

Issue 2445363002: cc: Add functions for getting absolute tile indices.
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/base/tiling_data.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/tiling_data_unittest.cc
diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc
index 71935a6c533006e7a67cf1a9e7b56a7df1246d98..bf6f5367eca012ce441bcdb9428bd2ecbe0c053a 100644
--- a/cc/base/tiling_data_unittest.cc
+++ b/cc/base/tiling_data_unittest.cc
@@ -45,6 +45,22 @@ int YIndex(const gfx::Size& max_texture_size,
return tiling.TileYIndexFromSrcCoord(y_coord);
}
+int AbsoluteXIndex(const gfx::Size& max_texture_size,
+ const gfx::Size& tiling_size,
+ bool has_border_texels,
+ int x_coord) {
+ TilingData tiling(max_texture_size, tiling_size, has_border_texels);
+ return tiling.TileAbsoluteXIndexFromSrcCoord(x_coord);
+}
+
+int AbsoluteYIndex(const gfx::Size& max_texture_size,
+ const gfx::Size& tiling_size,
+ bool has_border_texels,
+ int y_coord) {
+ TilingData tiling(max_texture_size, tiling_size, has_border_texels);
+ return tiling.TileAbsoluteYIndexFromSrcCoord(y_coord);
+}
+
int MinBorderXIndex(const gfx::Size& max_texture_size,
const gfx::Size& tiling_size,
bool has_border_texels,
@@ -274,6 +290,88 @@ TEST(TilingDataTest, TileXIndexFromSrcCoord) {
EXPECT_EQ(1, XIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 3));
}
+TEST(TilingDataTest, TileAbsoluteXIndexFromSrcCoord) {
+ EXPECT_EQ(-2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -4));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -3));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -2));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
+ EXPECT_EQ(2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
+ EXPECT_EQ(2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
+ EXPECT_EQ(2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
+ EXPECT_EQ(3, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
+ EXPECT_EQ(3, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
+ EXPECT_EQ(3, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
+ EXPECT_EQ(4, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 12));
+
+ EXPECT_EQ(-4, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -4));
+ EXPECT_EQ(-3, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -3));
+ EXPECT_EQ(-2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -2));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
+ EXPECT_EQ(2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
+ EXPECT_EQ(3, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
+ EXPECT_EQ(4, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
+ EXPECT_EQ(5, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
+ EXPECT_EQ(6, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
+ EXPECT_EQ(7, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
+ EXPECT_EQ(7, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
+ EXPECT_EQ(8, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
+ EXPECT_EQ(9, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
+ EXPECT_EQ(10, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 12));
+
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 1));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 2));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 3));
+
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, -2));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 2));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 3));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 4));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), false, 5));
+
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 2));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 3));
+
+ EXPECT_EQ(-2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, -2));
+ EXPECT_EQ(-1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, -1));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 0));
+ EXPECT_EQ(0, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 1));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 2));
+ EXPECT_EQ(1, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 3));
+ EXPECT_EQ(2, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 4));
+ EXPECT_EQ(3, AbsoluteXIndex(gfx::Size(3, 3), gfx::Size(4, 3), true, 5));
+}
+
TEST(TilingDataTest, FirstBorderTileXIndexFromSrcCoord) {
EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
EXPECT_EQ(0, MinBorderXIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
@@ -430,6 +528,88 @@ TEST(TilingDataTest, TileYIndexFromSrcCoord) {
EXPECT_EQ(1, YIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 3));
}
+TEST(TilingDataTest, TileAbsoluteYIndexFromSrcCoord) {
+ EXPECT_EQ(-2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -4));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -3));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -2));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 2));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 3));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 4));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 5));
+ EXPECT_EQ(2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 6));
+ EXPECT_EQ(2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 7));
+ EXPECT_EQ(2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 8));
+ EXPECT_EQ(3, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 9));
+ EXPECT_EQ(3, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 10));
+ EXPECT_EQ(3, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 11));
+ EXPECT_EQ(4, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 12));
+
+ EXPECT_EQ(-4, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -4));
+ EXPECT_EQ(-3, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -3));
+ EXPECT_EQ(-2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -2));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 1));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 2));
+ EXPECT_EQ(2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 3));
+ EXPECT_EQ(3, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 4));
+ EXPECT_EQ(4, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 5));
+ EXPECT_EQ(5, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 6));
+ EXPECT_EQ(6, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 7));
+ EXPECT_EQ(7, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 8));
+ EXPECT_EQ(7, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 9));
+ EXPECT_EQ(8, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 10));
+ EXPECT_EQ(9, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 11));
+ EXPECT_EQ(10, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(10, 10), true, 12));
+
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 0));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(1, 1), gfx::Size(1, 1), false, 1));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 1));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), false, 2));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 2));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), false, 3));
+
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, -2));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 2));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 3));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 4));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), false, 5));
+
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(1, 1), gfx::Size(1, 1), true, 1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(2, 2), gfx::Size(2, 2), true, 2));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 2));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 3), true, 3));
+
+ EXPECT_EQ(-2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, -2));
+ EXPECT_EQ(-1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, -1));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 0));
+ EXPECT_EQ(0, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 1));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 2));
+ EXPECT_EQ(1, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 3));
+ EXPECT_EQ(2, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 4));
+ EXPECT_EQ(3, AbsoluteYIndex(gfx::Size(3, 3), gfx::Size(3, 4), true, 5));
+}
+
TEST(TilingDataTest, FirstBorderTileYIndexFromSrcCoord) {
EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 0));
EXPECT_EQ(0, MinBorderYIndex(gfx::Size(3, 3), gfx::Size(10, 10), false, 1));
« no previous file with comments | « cc/base/tiling_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698