[iOS WebGL] Fixed WEBGL_compressed_texture_pvrtc.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jun 2014 23:14:36 +0000 (23:14 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jun 2014 23:14:36 +0000 (23:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133561

Based on Blink r153971 by bajones@chromium.org.

Reviewed by Dean Jackson.

No new tests, but this should fix webgl-compressed-texture-pvrtc.html.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateCompressedTexDimensions):
(WebCore::WebGLRenderingContext::validateCompressedTexSubDimensions):
Added checks for pvrtc.

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

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContext.cpp

index f97f3e7..ccaa55f 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-18  Alex Christensen  <achristensen@webkit.org>
+
+        [iOS WebGL] Fixed WEBGL_compressed_texture_pvrtc.
+        https://bugs.webkit.org/show_bug.cgi?id=133561
+        
+        Based on Blink r153971 by bajones@chromium.org.
+
+        Reviewed by Dean Jackson.
+
+        No new tests, but this should fix webgl-compressed-texture-pvrtc.html.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::validateCompressedTexDimensions):
+        (WebCore::WebGLRenderingContext::validateCompressedTexSubDimensions):
+        Added checks for pvrtc.
+
 2014-06-18  Anders Carlsson  <andersca@apple.com>
 
         Work around a Windows compiler crash.
index 0ab2afd..4f90e20 100644 (file)
@@ -5446,6 +5446,17 @@ bool WebGLRenderingContext::validateCompressedTexDimensions(const char* function
         }
         return true;
     }
+    case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
+    case Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
+    case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
+    case Extensions3D::COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
+            return false;
+        // Height and width must be powers of 2.
+        if ((width & (width - 1)) || (height & (height - 1))) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height invalid for level");
+            return false;
+        }
+        return true;
     default:
         return false;
     }
@@ -5477,6 +5488,21 @@ bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* funct
         }
         return validateCompressedTexDimensions(functionName, target, level, width, height, format);
     }
+    case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
+    case Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
+    case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
+    case Extensions3D::COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: {
+        if (xoffset || yoffset) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "xoffset and yoffset must be zero");
+            return false;
+        }
+        if (width != tex->getWidth(target, level)
+            || height != tex->getHeight(target, level)) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "dimensions must match existing level");
+            return false;
+        }
+        return validateCompressedTexDimensions(functionName, target, level, width, height, format);
+    }
     default:
         return false;
     }