2011-04-12 Adrienne Walker <enne@google.com>
authorenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Apr 2011 00:50:36 +0000 (00:50 +0000)
committerenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Apr 2011 00:50:36 +0000 (00:50 +0000)
        Reviewed by James Robinson.

        [chromium] TilingData mishandles very small texture sizes
        https://bugs.webkit.org/show_bug.cgi?id=58364

        Use zero tiles when the texture size is too small for tiling.

        * platform/graphics/gpu/TilingData.cpp:
        (WebCore::TilingData::TilingData):
        (WebCore::TilingData::setMaxTextureSize):
2011-04-12  Adrienne Walker  <enne@google.com>

        Reviewed by James Robinson.

        [chromium] TilingData mishandles very small texture sizes
        https://bugs.webkit.org/show_bug.cgi?id=58364

        Update test to properly handle texture sizes of 0-3.

        * tests/TilingDataTest.cpp:
        (WebCore::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83674 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gpu/TilingData.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/TilingDataTest.cpp

index 0a572d2..12c4181 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-12  Adrienne Walker  <enne@google.com>
+
+        Reviewed by James Robinson.
+
+        [chromium] TilingData mishandles very small texture sizes
+        https://bugs.webkit.org/show_bug.cgi?id=58364
+
+        Use zero tiles when the texture size is too small for tiling.
+
+        * platform/graphics/gpu/TilingData.cpp:
+        (WebCore::TilingData::TilingData):
+        (WebCore::TilingData::setMaxTextureSize):
+
 2011-04-12  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Unreviewed, rolling out r83634 and r83659.
index 1370543..a1fc297 100644 (file)
@@ -44,6 +44,9 @@ namespace WebCore {
 
 static int computeNumTiles(int maxTextureSize, int totalSize, int borderTexels)
 {
+    if (maxTextureSize - 2 * borderTexels <= 0)
+        return 0;
+
     int numTiles = max(1, 1 + (totalSize - 1 - 2 * borderTexels) / (maxTextureSize - 2 * borderTexels));
     return totalSize > 0 ? numTiles : 0;
 }
index 91fc1c6..68d7a2f 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-12  Adrienne Walker  <enne@google.com>
+
+        Reviewed by James Robinson.
+
+        [chromium] TilingData mishandles very small texture sizes
+        https://bugs.webkit.org/show_bug.cgi?id=58364
+
+        Update test to properly handle texture sizes of 0-3.
+
+        * tests/TilingDataTest.cpp:
+        (WebCore::TEST):
+
 2011-04-12  Jian Li  <jianli@chromium.org>
 
         Unreviewed, rolling out r83649.
index a41f7fe..f12b1ce 100755 (executable)
@@ -49,6 +49,20 @@ TEST(TilingDataTest, numTiles_NoTiling)
 
 TEST(TilingDataTest, numTiles_TilingNoBorders)
 {
+    EXPECT_EQ(0, TilingData(0,  0,  0, false).numTiles());
+    EXPECT_EQ(0, TilingData(0,  4,  0, false).numTiles());
+    EXPECT_EQ(0, TilingData(0,  0,  4, false).numTiles());
+    EXPECT_EQ(0, TilingData(4,  4,  0, false).numTiles());
+    EXPECT_EQ(0, TilingData(4,  0,  4, false).numTiles());
+    EXPECT_EQ(0, TilingData(-8, 1,  1, false).numTiles());
+    EXPECT_EQ(0, TilingData(-1, 1,  1, false).numTiles());
+    EXPECT_EQ(0, TilingData(0,  1,  1, false).numTiles());
+
+    EXPECT_EQ(1, TilingData(1,  1,  1, false).numTiles());
+    EXPECT_EQ(2, TilingData(1,  1,  2, false).numTiles());
+    EXPECT_EQ(1, TilingData(2,  2,  2, false).numTiles());
+    EXPECT_EQ(1, TilingData(3,  3,  3, false).numTiles());
+
     EXPECT_EQ(1, TilingData(4,  1,  4, false).numTiles());
     EXPECT_EQ(1, TilingData(4,  2,  4, false).numTiles());
     EXPECT_EQ(1, TilingData(4,  3,  4, false).numTiles());
@@ -82,6 +96,19 @@ TEST(TilingDataTest, numTiles_TilingNoBorders)
 
 TEST(TilingDataTest, numTiles_TilingWithBorders)
 {
+    EXPECT_EQ(0, TilingData(0,  0,  0, true).numTiles());
+    EXPECT_EQ(0, TilingData(0,  4,  0, true).numTiles());
+    EXPECT_EQ(0, TilingData(0,  0,  4, true).numTiles());
+    EXPECT_EQ(0, TilingData(4,  4,  0, true).numTiles());
+    EXPECT_EQ(0, TilingData(4,  0,  4, true).numTiles());
+    EXPECT_EQ(0, TilingData(-8, 1,  1, true).numTiles());
+    EXPECT_EQ(0, TilingData(-1, 1,  1, true).numTiles());
+    EXPECT_EQ(0, TilingData(0,  1,  1, true).numTiles());
+
+    EXPECT_EQ(0, TilingData(1,  1,  1, true).numTiles());
+    EXPECT_EQ(0, TilingData(1,  1,  2, true).numTiles());
+    EXPECT_EQ(0, TilingData(2,  2,  2, true).numTiles());
+
     EXPECT_EQ(1, TilingData(3,  1,  3, true).numTiles());
     EXPECT_EQ(1, TilingData(3,  2,  3, true).numTiles());
     EXPECT_EQ(1, TilingData(3,  3,  3, true).numTiles());
@@ -361,7 +388,7 @@ TEST(TilingDataTest, setTotalSize)
     EXPECT_EQ(2, data.tileSizeY(2));
 }
 
-TEST(TilingDataTest, setMaxTextureSize)
+TEST(TilingDataTest, setMaxTextureSizeNoBorders)
 {
     TilingData data(8, 16, 32, false);
     EXPECT_EQ(2, data.numTilesX());
@@ -383,4 +410,26 @@ TEST(TilingDataTest, setMaxTextureSize)
     EXPECT_EQ(7, data.numTilesY());
 }
 
+TEST(TilingDataTest, setMaxTextureSizeBorders)
+{
+    TilingData data(8, 16, 32, true);
+    EXPECT_EQ(3, data.numTilesX());
+    EXPECT_EQ(5, data.numTilesY());
+
+    data.setMaxTextureSize(32);
+    EXPECT_EQ(32, data.maxTextureSize());
+    EXPECT_EQ(1, data.numTilesX());
+    EXPECT_EQ(1, data.numTilesY());
+
+    data.setMaxTextureSize(2);
+    EXPECT_EQ(2, data.maxTextureSize());
+    EXPECT_EQ(0, data.numTilesX());
+    EXPECT_EQ(0, data.numTilesY());
+
+    data.setMaxTextureSize(5);
+    EXPECT_EQ(5, data.maxTextureSize());
+    EXPECT_EQ(5, data.numTilesX());
+    EXPECT_EQ(10, data.numTilesY());
+}
+
 } // namespace