Implement new WEBGL compressed texture extensions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 19:13:56 +0000 (19:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 19:13:56 +0000 (19:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77066

Source/WebCore:

This removes the old experimental compressed
texture extension and implements the first new
one.

A test is in the WebGL conformance tests in
extensions/webgl-compressed-texture-s3tc.html
and will be copied here in a future patch.

Patch by Gregg Tavares <gman@google.com> on 2012-02-08
Reviewed by Kenneth Russell.

No new tests. Test coming in future patch.

* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::toJS):
* bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
(WebCore::toV8Object):
* html/canvas/WebGLCompressedTextureS3TC.cpp: Added.
(WebCore):
(WebCore::WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC):
(WebCore::WebGLCompressedTextureS3TC::~WebGLCompressedTextureS3TC):
(WebCore::WebGLCompressedTextureS3TC::getName):
(WebCore::WebGLCompressedTextureS3TC::create):
(WebCore::WebGLCompressedTextureS3TC::supported):
* html/canvas/WebGLCompressedTextureS3TC.h: Copied from Source/WebCore/html/canvas/WebGLExtension.h.
(WebCore):
(WebGLCompressedTextureS3TC):
* html/canvas/WebGLCompressedTextureS3TC.idl: Renamed from Source/WebCore/html/canvas/WebGLCompressedTextures.idl.
* html/canvas/WebGLCompressedTextures.cpp: Removed.
* html/canvas/WebGLCompressedTextures.h: Removed.
* html/canvas/WebGLExtension.h:
* html/canvas/WebGLGetInfo.cpp:
(WebCore::WebGLGetInfo::WebGLGetInfo):
(WebCore):
(WebCore::WebGLGetInfo::getWebGLUnsignedIntArray):
* html/canvas/WebGLGetInfo.h:
* html/canvas/WebGLObject.cpp:
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::addCompressedTextureFormat):
(WebCore::WebGLRenderingContext::compressedTexImage2D):
(WebCore::WebGLRenderingContext::compressedTexSubImage2D):
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getParameter):
(WebCore::WebGLRenderingContext::getSupportedExtensions):
(WebCore::WebGLRenderingContext::validateCompressedTexFormat):
(WebCore::WebGLRenderingContext::validateCompressedTexFuncData):
(WebCore::WebGLRenderingContext::validateCompressedTexDimensions):
(WebCore::WebGLRenderingContext::validateCompressedTexSubDimensions):
* html/canvas/WebGLRenderingContext.h:
(WebCore):
(WebGLRenderingContext):
* html/canvas/WebGLRenderingContext.idl:

LayoutTests:

Patch by Gregg Tavares <gman@chromium.org> on 2012-02-08
Reviewed by Kenneth Russell.

* fast/canvas/webgl/constants.html:
* fast/canvas/webgl/gl-get-calls-expected.txt:
* fast/canvas/webgl/gl-get-calls.html:

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

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/constants.html
LayoutTests/fast/canvas/webgl/gl-get-calls-expected.txt
LayoutTests/fast/canvas/webgl/gl-get-calls.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/DerivedSources.pri
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.h [moved from Source/WebCore/html/canvas/WebGLCompressedTextures.h with 51% similarity]
Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.idl [moved from Source/WebCore/html/canvas/WebGLCompressedTextures.idl with 67% similarity]
Source/WebCore/html/canvas/WebGLCompressedTextures.cpp [deleted file]
Source/WebCore/html/canvas/WebGLExtension.h
Source/WebCore/html/canvas/WebGLGetInfo.cpp
Source/WebCore/html/canvas/WebGLGetInfo.h
Source/WebCore/html/canvas/WebGLObject.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.h
Source/WebCore/html/canvas/WebGLRenderingContext.idl

index 98ae36a..8ac621b 100644 (file)
@@ -1,3 +1,14 @@
+2012-02-08  Gregg Tavares  <gman@chromium.org>
+
+        Implement new WEBGL compressed texture extensions
+        https://bugs.webkit.org/show_bug.cgi?id=77066
+
+        Reviewed by Kenneth Russell.
+
+        * fast/canvas/webgl/constants.html:
+        * fast/canvas/webgl/gl-get-calls-expected.txt:
+        * fast/canvas/webgl/gl-get-calls.html:
+
 2012-02-08  Csaba Osztrogonác  <ossy@webkit.org>
 
         [Qt] svg/zoom/page/zoom-coords-viewattr-01-b.svg fails
index e92a31e..f36c5bf 100644 (file)
@@ -194,7 +194,6 @@ SAMPLE_COVERAGE_INVERT         : 0x80AB,
     /*      TEXTURE_WRAP_S */
     /*      TEXTURE_WRAP_T */
     
-NUM_COMPRESSED_TEXTURE_FORMATS : 0x86A2,
 COMPRESSED_TEXTURE_FORMATS     : 0x86A3,
     
     /* HintMode */
index 9aee459..af0a2a3 100644 (file)
@@ -75,7 +75,7 @@ PASS context.getParameter(context.VIEWPORT) is [0, 0, 2, 2]
 PASS context.getParameter(context.MAX_FRAGMENT_UNIFORM_VECTORS) >= 16 is true
 PASS context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 128 is true
 PASS context.getParameter(context.MAX_VARYING_VECTORS) >= 8 is true
-PASS context.getParameter(context.NUM_COMPRESSED_TEXTURE_FORMATS) is 0
+PASS context.getParameter(context.COMPRESSED_TEXTURE_FORMATS) is []
 
 PASS successfullyParsed is true
 
index 2dee381..a1bbf58 100644 (file)
@@ -107,7 +107,7 @@ else {
     shouldBeTrue('context.getParameter(context.MAX_FRAGMENT_UNIFORM_VECTORS) >= 16');
     shouldBeTrue('context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 128');
     shouldBeTrue('context.getParameter(context.MAX_VARYING_VECTORS) >= 8');
-    shouldBe('context.getParameter(context.NUM_COMPRESSED_TEXTURE_FORMATS)', '0');
+    shouldBe('context.getParameter(context.COMPRESSED_TEXTURE_FORMATS)', '[]');
 }
 
 debug("");
index dd04cf6..110f87b 100644 (file)
@@ -2181,7 +2181,7 @@ IF (ENABLE_WEBGL)
         ${THIRDPARTY_DIR}/ANGLE/src/compiler/ValidateLimitations.cpp
         ${THIRDPARTY_DIR}/ANGLE/src/compiler/VariableInfo.cpp
         html/canvas/WebGLBuffer.cpp
-        html/canvas/WebGLCompressedTextures.cpp
+        html/canvas/WebGLCompressedTextureS3TC.cpp
         html/canvas/WebGLContextAttributes.cpp
         html/canvas/WebGLContextEvent.cpp
         html/canvas/WebGLContextGroup.cpp
@@ -2214,7 +2214,7 @@ IF (ENABLE_WEBGL)
         html/canvas/OESVertexArrayObject.idl
         html/canvas/WebGLActiveInfo.idl
         html/canvas/WebGLBuffer.idl
-        html/canvas/WebGLCompressedTextures.idl
+        html/canvas/WebGLCompressedTextureS3TC.idl
         html/canvas/WebGLContextAttributes.idl
         html/canvas/WebGLContextEvent.idl
         html/canvas/WebGLDebugRendererInfo.idl
index 738faba..df32d41 100644 (file)
@@ -1,3 +1,67 @@
+2012-02-08  Gregg Tavares  <gman@google.com>
+
+        Implement new WEBGL compressed texture extensions
+        https://bugs.webkit.org/show_bug.cgi?id=77066
+
+        This removes the old experimental compressed
+        texture extension and implements the first new
+        one.
+
+        A test is in the WebGL conformance tests in
+        extensions/webgl-compressed-texture-s3tc.html
+        and will be copied here in a future patch.
+
+        Reviewed by Kenneth Russell.
+
+        No new tests. Test coming in future patch.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSWebGLRenderingContextCustom.cpp:
+        (WebCore::toJS):
+        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+        (WebCore::toV8Object):
+        * html/canvas/WebGLCompressedTextureS3TC.cpp: Added.
+        (WebCore):
+        (WebCore::WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC):
+        (WebCore::WebGLCompressedTextureS3TC::~WebGLCompressedTextureS3TC):
+        (WebCore::WebGLCompressedTextureS3TC::getName):
+        (WebCore::WebGLCompressedTextureS3TC::create):
+        (WebCore::WebGLCompressedTextureS3TC::supported):
+        * html/canvas/WebGLCompressedTextureS3TC.h: Copied from Source/WebCore/html/canvas/WebGLExtension.h.
+        (WebCore):
+        (WebGLCompressedTextureS3TC):
+        * html/canvas/WebGLCompressedTextureS3TC.idl: Renamed from Source/WebCore/html/canvas/WebGLCompressedTextures.idl.
+        * html/canvas/WebGLCompressedTextures.cpp: Removed.
+        * html/canvas/WebGLCompressedTextures.h: Removed.
+        * html/canvas/WebGLExtension.h:
+        * html/canvas/WebGLGetInfo.cpp:
+        (WebCore::WebGLGetInfo::WebGLGetInfo):
+        (WebCore):
+        (WebCore::WebGLGetInfo::getWebGLUnsignedIntArray):
+        * html/canvas/WebGLGetInfo.h:
+        * html/canvas/WebGLObject.cpp:
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContext::addCompressedTextureFormat):
+        (WebCore::WebGLRenderingContext::compressedTexImage2D):
+        (WebCore::WebGLRenderingContext::compressedTexSubImage2D):
+        (WebCore::WebGLRenderingContext::getExtension):
+        (WebCore::WebGLRenderingContext::getParameter):
+        (WebCore::WebGLRenderingContext::getSupportedExtensions):
+        (WebCore::WebGLRenderingContext::validateCompressedTexFormat):
+        (WebCore::WebGLRenderingContext::validateCompressedTexFuncData):
+        (WebCore::WebGLRenderingContext::validateCompressedTexDimensions):
+        (WebCore::WebGLRenderingContext::validateCompressedTexSubDimensions):
+        * html/canvas/WebGLRenderingContext.h:
+        (WebCore):
+        (WebGLRenderingContext):
+        * html/canvas/WebGLRenderingContext.idl:
+
 2012-02-08  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: heap snapshot: implement Distance column in Object's retaining tree.
index d63d823..70fc744 100644 (file)
@@ -286,7 +286,7 @@ BINDING_IDLS = \
     $(WebCore)/html/canvas/Uint8ClampedArray.idl \
     $(WebCore)/html/canvas/WebGLActiveInfo.idl \
     $(WebCore)/html/canvas/WebGLBuffer.idl \
-    $(WebCore)/html/canvas/WebGLCompressedTextures.idl \
+    $(WebCore)/html/canvas/WebGLCompressedTextureS3TC.idl \
     $(WebCore)/html/canvas/WebGLContextAttributes.idl \
     $(WebCore)/html/canvas/WebGLContextEvent.idl \
     $(WebCore)/html/canvas/WebGLFramebuffer.idl \
index 4da2380..610cff1 100644 (file)
@@ -222,6 +222,7 @@ IDL_BINDINGS += \
     $$PWD/html/canvas/OESVertexArrayObject.idl \
     $$PWD/html/canvas/WebGLActiveInfo.idl \
     $$PWD/html/canvas/WebGLBuffer.idl \
+    $$PWD/html/canvas/WebGLCompressedTextureS3TC.idl \
     $$PWD/html/canvas/WebGLContextAttributes.idl \
     $$PWD/html/canvas/WebGLContextEvent.idl \
     $$PWD/html/canvas/WebGLDebugRendererInfo.idl \
index 29a0097..ad9e2f6 100644 (file)
@@ -543,6 +543,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSWebGLActiveInfo.h \
        DerivedSources/WebCore/JSWebGLBuffer.cpp \
        DerivedSources/WebCore/JSWebGLBuffer.h \
+       DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.cpp \
+       DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.h \
        DerivedSources/WebCore/JSWebGLContextAttributes.cpp \
        DerivedSources/WebCore/JSWebGLContextAttributes.h \
        DerivedSources/WebCore/JSWebGLContextEvent.cpp \
@@ -847,6 +849,7 @@ dom_binding_idls += \
        $(WebCore)/html/canvas/Uint8ClampedArray.idl \
        $(WebCore)/html/canvas/WebGLActiveInfo.idl \
        $(WebCore)/html/canvas/WebGLBuffer.idl \
+       $(WebCore)/html/canvas/WebGLCompressedTextureS3TC.idl \
        $(WebCore)/html/canvas/WebGLContextAttributes.idl \
        $(WebCore)/html/canvas/WebGLContextEvent.idl \
        $(WebCore)/html/canvas/WebGLFramebuffer.idl \
@@ -5614,8 +5617,8 @@ webcore_sources += \
        Source/WebCore/html/canvas/WebGLActiveInfo.h \
        Source/WebCore/html/canvas/WebGLBuffer.cpp \
        Source/WebCore/html/canvas/WebGLBuffer.h \
-       Source/WebCore/html/canvas/WebGLCompressedTextures.cpp \
-       Source/WebCore/html/canvas/WebGLCompressedTextures.h \
+       Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp \
+       Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.h \
        Source/WebCore/html/canvas/WebGLContextAttributes.cpp \
        Source/WebCore/html/canvas/WebGLContextAttributes.h \
        Source/WebCore/html/canvas/WebGLContextEvent.cpp \
index 023a41e..af1eb58 100644 (file)
@@ -3693,7 +3693,7 @@ contains(DEFINES, ENABLE_WEBGL=1) {
         html/canvas/WebGLObject.h \
         html/canvas/WebGLActiveInfo.h \
         html/canvas/WebGLBuffer.h \
-        html/canvas/WebGLCompressedTextures.h \
+        html/canvas/WebGLCompressedTextureS3TC.h \
         html/canvas/WebGLContextAttributes.h \
         html/canvas/WebGLContextEvent.h \
         html/canvas/WebGLContextGroup.h \
@@ -3733,7 +3733,7 @@ contains(DEFINES, ENABLE_WEBGL=1) {
         html/canvas/CanvasContextAttributes.cpp \
         html/canvas/WebGLObject.cpp \
         html/canvas/WebGLBuffer.cpp \
-        html/canvas/WebGLCompressedTextures.cpp \
+        html/canvas/WebGLCompressedTextureS3TC.cpp \
         html/canvas/WebGLContextAttributes.cpp \
         html/canvas/WebGLContextEvent.cpp \
         html/canvas/WebGLContextGroup.cpp \
index 38fafda..3ab9331 100644 (file)
             'html/canvas/Uint8ClampedArray.idl',
             'html/canvas/WebGLActiveInfo.idl',
             'html/canvas/WebGLBuffer.idl',
-            'html/canvas/WebGLCompressedTextures.idl',
+            'html/canvas/WebGLCompressedTextureS3TC.idl',
             'html/canvas/WebGLContextAttributes.idl',
             'html/canvas/WebGLContextEvent.idl',
             'html/canvas/WebGLDebugRendererInfo.idl',
             'html/canvas/WebGLActiveInfo.h',
             'html/canvas/WebGLBuffer.cpp',
             'html/canvas/WebGLBuffer.h',
-            'html/canvas/WebGLCompressedTextures.cpp',
-            'html/canvas/WebGLCompressedTextures.h',
+            'html/canvas/WebGLCompressedTextureS3TC.cpp',
+            'html/canvas/WebGLCompressedTextureS3TC.h',
             'html/canvas/WebGLContextAttributes.cpp',
             'html/canvas/WebGLContextAttributes.h',
             'html/canvas/WebGLContextEvent.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLActiveInfo.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLBuffer.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLBuffer.h',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.cpp',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLContextAttributes.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLContextAttributes.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLFramebuffer.cpp',
index 9ce401b..96544e5 100644 (file)
                65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
                6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */; };
                6E21C6C21126339900A7BE02 /* GraphicsContext3DCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */; };
-               6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextures.cpp */; };
-               6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextures.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextures.h */; };
-               6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextures.cpp */; };
-               6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextures.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextures.h */; };
+               6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */; };
+               6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */; };
+               6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp */; };
+               6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */; };
                6E47E66010B7944B00B186C8 /* WebGLGetInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */; };
                6E47E66110B7944B00B186C8 /* WebGLGetInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */; };
                6E4ABCD4138EA0B70071D291 /* JSHTMLUnknownElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E4ABCD2138EA0B70071D291 /* JSHTMLUnknownElement.cpp */; };
                65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
                6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DCG.cpp; sourceTree = "<group>"; };
-               6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextures.cpp; sourceTree = "<group>"; };
-               6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLCompressedTextures.h; sourceTree = "<group>"; };
-               6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLCompressedTextures.cpp; path = canvas/WebGLCompressedTextures.cpp; sourceTree = "<group>"; };
-               6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLCompressedTextures.h; path = canvas/WebGLCompressedTextures.h; sourceTree = "<group>"; };
-               6E3FAE9014733FEA00E42306 /* WebGLCompressedTextures.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLCompressedTextures.idl; path = canvas/WebGLCompressedTextures.idl; sourceTree = "<group>"; };
+               6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; };
+               6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLCompressedTextureS3TC.h; sourceTree = "<group>"; };
+               6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLCompressedTextureS3TC.cpp; path = canvas/WebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; };
+               6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLCompressedTextureS3TC.h; path = canvas/WebGLCompressedTextureS3TC.h; sourceTree = "<group>"; };
+               6E3FAE9014733FEA00E42306 /* WebGLCompressedTextureS3TC.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLCompressedTextureS3TC.idl; path = canvas/WebGLCompressedTextureS3TC.idl; sourceTree = "<group>"; };
                6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLGetInfo.cpp; path = canvas/WebGLGetInfo.cpp; sourceTree = "<group>"; };
                6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLGetInfo.h; path = canvas/WebGLGetInfo.h; sourceTree = "<group>"; };
                6E4ABCD2138EA0B70071D291 /* JSHTMLUnknownElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLUnknownElement.cpp; sourceTree = "<group>"; };
                                49C7B9A81042D32E0009D447 /* WebGLBuffer.cpp */,
                                49C7B9A91042D32E0009D447 /* WebGLBuffer.h */,
                                49C7B9AA1042D32E0009D447 /* WebGLBuffer.idl */,
-                               6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextures.cpp */,
-                               6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextures.h */,
-                               6E3FAE9014733FEA00E42306 /* WebGLCompressedTextures.idl */,
+                               6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp */,
+                               6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */,
+                               6E3FAE9014733FEA00E42306 /* WebGLCompressedTextureS3TC.idl */,
                                6E4E91A910F7FB3100A2779C /* WebGLContextAttributes.cpp */,
                                6E4E91AA10F7FB3100A2779C /* WebGLContextAttributes.h */,
                                6E4E91AB10F7FB3100A2779C /* WebGLContextAttributes.idl */,
                                A7D20F61107F406900A80392 /* JSWebGLActiveInfo.h */,
                                49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */,
                                49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */,
-                               6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextures.cpp */,
-                               6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextures.h */,
+                               6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */,
+                               6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */,
                                6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */,
                                6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */,
                                BC2CBF7A140F1D58003879BE /* JSWebGLContextEvent.cpp */,
                                FD82D7F813D4C8BD004E4372 /* JSWaveShaperNode.h in Headers */,
                                A7D20F63107F406900A80392 /* JSWebGLActiveInfo.h in Headers */,
                                49C7B9941042D2D30009D447 /* JSWebGLBuffer.h in Headers */,
-                               6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextures.h in Headers */,
+                               6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextureS3TC.h in Headers */,
                                6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */,
                                BC2CBF4E140F1ABD003879BE /* JSWebGLContextEvent.h in Headers */,
                                49C7B9981042D2D30009D447 /* JSWebGLFramebuffer.h in Headers */,
                                BC6DADEF0A195FDF00E5CD14 /* WebFontCache.h in Headers */,
                                A7D20F6D107F438B00A80392 /* WebGLActiveInfo.h in Headers */,
                                49C7B9C91042D32F0009D447 /* WebGLBuffer.h in Headers */,
-                               6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextures.h in Headers */,
+                               6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */,
                                6E4E91AF10F7FB3100A2779C /* WebGLContextAttributes.h in Headers */,
                                93F6F1EE127F70B10055CB06 /* WebGLContextEvent.h in Headers */,
                                01D3CF8314BD0A3000FE9970 /* WebGLContextGroup.h in Headers */,
                                FD8E9BDF13D4CD2B0050DC72 /* JSWaveShaperNodeCustom.cpp in Sources */,
                                A7D20F62107F406900A80392 /* JSWebGLActiveInfo.cpp in Sources */,
                                49C7B9931042D2D30009D447 /* JSWebGLBuffer.cpp in Sources */,
-                               6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextures.cpp in Sources */,
+                               6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp in Sources */,
                                6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */,
                                BC2CBF7B140F1D58003879BE /* JSWebGLContextEvent.cpp in Sources */,
                                49C7B9971042D2D30009D447 /* JSWebGLFramebuffer.cpp in Sources */,
                                93F19B0708245E59001E9ABC /* WebCoreView.m in Sources */,
                                BC6DADFA0A19602B00E5CD14 /* WebFontCache.mm in Sources */,
                                49C7B9C81042D32F0009D447 /* WebGLBuffer.cpp in Sources */,
-                               6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextures.cpp in Sources */,
+                               6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp in Sources */,
                                6E4E91AE10F7FB3100A2779C /* WebGLContextAttributes.cpp in Sources */,
                                93F6F1ED127F70B10055CB06 /* WebGLContextEvent.cpp in Sources */,
                                01D3CF8214BD0A3000FE9970 /* WebGLContextGroup.cpp in Sources */,
index b4f5662..0bfa63a 100644 (file)
 #include "JSOESStandardDerivatives.h"
 #include "JSOESTextureFloat.h"
 #include "JSOESVertexArrayObject.h"
+#include "JSUint32Array.h"
 #include "JSUint8Array.h"
 #include "JSWebGLBuffer.h"
+#include "JSWebGLCompressedTextureS3TC.h"
 #include "JSWebGLFramebuffer.h"
 #include "JSWebGLLoseContext.h"
 #include "JSWebGLProgram.h"
@@ -56,7 +58,7 @@
 #include "OESTextureFloat.h"
 #include "OESVertexArrayObject.h"
 #include "WebGLBuffer.h"
-#include "WebGLCompressedTextures.h"
+#include "WebGLCompressedTextureS3TC.h"
 #include "WebGLDebugRendererInfo.h"
 #include "WebGLDebugShaders.h"
 #include "WebGLExtension.h"
@@ -71,6 +73,7 @@
 #include <wtf/FastMalloc.h>
 #include <wtf/Float32Array.h>
 #include <wtf/Int32Array.h>
+#include <wtf/Uint32Array.h>
 
 #if ENABLE(VIDEO)
 #include "HTMLVideoElement.h"
@@ -121,6 +124,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebG
         return toJS(exec, globalObject, info.getWebGLTexture());
     case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
         return toJS(exec, globalObject, info.getWebGLUnsignedByteArray());
+    case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
+        return toJS(exec, globalObject, info.getWebGLUnsignedIntArray());
     case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
         return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
     default:
@@ -193,8 +198,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten
         return toJS(exec, globalObject, static_cast<WebGLDebugRendererInfo*>(extension));
     case WebGLExtension::WebGLDebugShadersName:
         return toJS(exec, globalObject, static_cast<WebGLDebugShaders*>(extension));
-    case WebGLExtension::WebKitWebGLCompressedTexturesName:
-        return toJS(exec, globalObject, static_cast<WebGLCompressedTextures*>(extension));
+    case WebGLExtension::WebKitWebGLCompressedTextureS3TCName:
+        return toJS(exec, globalObject, static_cast<WebGLCompressedTextureS3TC*>(extension));
     }
     ASSERT_NOT_REACHED();
     return jsNull();
index de14d43..c078688 100644 (file)
@@ -55,7 +55,7 @@
 #include "V8Uint32Array.h"
 #include "V8Uint8Array.h"
 #include "V8WebGLBuffer.h"
-#include "V8WebGLCompressedTextures.h"
+#include "V8WebGLCompressedTextureS3TC.h"
 #include "V8WebGLDebugRendererInfo.h"
 #include "V8WebGLDebugShaders.h"
 #include "V8WebGLFramebuffer.h"
@@ -154,6 +154,8 @@ static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info)
         return toV8(info.getWebGLTexture());
     case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
         return toV8(info.getWebGLUnsignedByteArray());
+    case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
+        return toV8(info.getWebGLUnsignedIntArray());
     case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
         return toV8(info.getWebGLVertexArrayObjectOES());
     default:
@@ -193,9 +195,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8
         extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension));
         referenceName = "webGLDebugShadersName";
         break;
-    case WebGLExtension::WebKitWebGLCompressedTexturesName:
-        extensionObject = toV8(static_cast<WebGLCompressedTextures*>(extension));
-        referenceName = "webKitWebGLCompressedTexturesName";
+    case WebGLExtension::WebKitWebGLCompressedTextureS3TCName:
+        extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extension));
+        referenceName = "webKitWebGLCompressedTextureS3TCName";
         break;
     }
     ASSERT(!extensionObject.IsEmpty());
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp b/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp
new file mode 100644 (file)
index 0000000..02357ef
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEBGL)
+
+#include "WebGLCompressedTextureS3TC.h"
+
+#include "Extensions3D.h"
+#include "WebGLRenderingContext.h"
+
+#include <wtf/Int32Array.h>
+#include <wtf/OwnArrayPtr.h>
+
+namespace WebCore {
+
+WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC(WebGLRenderingContext* context)
+    : WebGLExtension(context)
+{
+    context->addCompressedTextureFormat(Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT);
+    context->addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT);
+    context->addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT);
+    context->addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT);
+}
+
+WebGLCompressedTextureS3TC::~WebGLCompressedTextureS3TC()
+{
+}
+
+WebGLExtension::ExtensionName WebGLCompressedTextureS3TC::getName() const
+{
+    return WebKitWebGLCompressedTextureS3TCName;
+}
+
+PassOwnPtr<WebGLCompressedTextureS3TC> WebGLCompressedTextureS3TC::create(WebGLRenderingContext* context)
+{
+    return adoptPtr(new WebGLCompressedTextureS3TC(context));
+}
+
+bool WebGLCompressedTextureS3TC::supported(WebGLRenderingContext* context)
+{
+    Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
+    return extensions->supports("GL_EXT_texture_compression_s3tc")
+        || (extensions->supports("GL_EXT_texture_compression_dxt1")
+            && extensions->supports("GL_CHROMIUM_texture_compression_dxt3")
+            && extensions->supports("GL_CHROMIUM_texture_compression_dxt5"));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebGLCompressedTextures_h
-#define WebGLCompressedTextures_h
+#ifndef WebGLCompressedTextureS3TC_h
+#define WebGLCompressedTextureS3TC_h
 
 #include "ExceptionCode.h"
 #include "WebGLExtension.h"
-#include <wtf/ArrayBufferView.h>
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
 class WebGLTexture;
 
-class WebGLCompressedTextures : public WebGLExtension {
+class WebGLCompressedTextureS3TC : public WebGLExtension {
 public:
-    static PassOwnPtr<WebGLCompressedTextures> create(WebGLRenderingContext*);
+    static PassOwnPtr<WebGLCompressedTextureS3TC> create(WebGLRenderingContext*);
 
     static bool supported(WebGLRenderingContext*);
 
-    virtual ~WebGLCompressedTextures();
+    virtual ~WebGLCompressedTextureS3TC();
     virtual ExtensionName getName() const;
 
-    void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
-                              GC3Dsizei height, GC3Dint border, ArrayBufferView* data);
-    void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
-                                 GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data);
-
-    WebGLGetInfo getCompressedTextureFormats();
-
 private:
-    WebGLCompressedTextures(WebGLRenderingContext*);
-
-    bool validateCompressedTexFuncData(const char* functionName,
-                                       GC3Dsizei width, GC3Dsizei height,
-                                       GC3Denum format, ArrayBufferView* pixels);
-
-    bool validateCompressedTexFormat(GC3Denum format);
-
-    bool validateCompressedTexSubDimensions(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
-                                            GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture*);
-
-    bool m_supportsDxt1;
-    bool m_supportsDxt5;
-    bool m_supportsEtc1;
-    bool m_supportsPvrtc;
-
-    Vector<int> m_formats;
+    WebGLCompressedTextureS3TC(WebGLRenderingContext*);
 };
 
 } // namespace WebCore
 
-#endif // WebGLCompressedTextures_h
+#endif // WebGLCompressedTextureS3TC_h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,18 +29,11 @@ module html {
         JSGenerateIsReachable=ImplContext,
         OmitConstructor,
         DoNotCheckConstants
-    ] WebGLCompressedTextures {
+    ] WebGLCompressedTextureS3TC {
         /* Compressed Texture Formats */
         const unsigned int COMPRESSED_RGB_S3TC_DXT1_EXT        = 0x83F0;
         const unsigned int COMPRESSED_RGBA_S3TC_DXT1_EXT       = 0x83F1;
+        const unsigned int COMPRESSED_RGBA_S3TC_DXT3_EXT       = 0x83F2;
         const unsigned int COMPRESSED_RGBA_S3TC_DXT5_EXT       = 0x83F3;
-        const unsigned int ETC1_RGB8_OES                       = 0x8D64;
-        const unsigned int COMPRESSED_RGB_PVRTC_4BPPV1_IMG     = 0x8C00;
-        const unsigned int COMPRESSED_RGBA_PVRTC_4BPPV1_IMG    = 0x8C02;
-
-        [StrictTypeChecking] void compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat,
-                                                       in long width, in long height, in long border, in ArrayBufferView data);
-        [StrictTypeChecking] void compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
-                                                          in long width, in long height, in unsigned long format, in ArrayBufferView data);
     };
 }
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextures.cpp b/Source/WebCore/html/canvas/WebGLCompressedTextures.cpp
deleted file mode 100644 (file)
index 151980c..0000000
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(WEBGL)
-
-#include "WebGLCompressedTextures.h"
-
-#include "Extensions3D.h"
-#include "WebGLRenderingContext.h"
-
-#include <wtf/Int32Array.h>
-#include <wtf/OwnArrayPtr.h>
-
-namespace WebCore {
-
-WebGLCompressedTextures::WebGLCompressedTextures(WebGLRenderingContext* context)
-    : WebGLExtension(context)
-    , m_supportsDxt1(false)
-    , m_supportsDxt5(false)
-    , m_supportsEtc1(false)
-    , m_supportsPvrtc(false)
-{
-    Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
-    if (extensions->supports("GL_EXT_texture_compression_dxt1")) {
-        extensions->ensureEnabled("GL_EXT_texture_compression_dxt1");
-        m_supportsDxt1 = true;
-    }
-    if (extensions->supports("GL_EXT_texture_compression_s3tc")) {
-        extensions->ensureEnabled("GL_EXT_texture_compression_s3tc");
-        m_supportsDxt1 = true;
-        m_supportsDxt5 = true;
-    }
-    if (extensions->supports("GL_CHROMIUM_texture_compression_dxt5")) {
-        extensions->ensureEnabled("GL_CHROMIUM_texture_compression_dxt5");
-        m_supportsDxt5 = true;
-    }
-    if (extensions->supports("GL_OES_compressed_ETC1_RGB8_texture")) {
-        extensions->ensureEnabled("GL_OES_compressed_ETC1_RGB8_texture");
-        m_supportsEtc1 = true;
-    }
-    if (extensions->supports("GL_IMG_texture_compression_pvrtc")) {
-        extensions->ensureEnabled("GL_IMG_texture_compression_pvrtc");
-        m_supportsPvrtc = true;
-    }
-
-    if (m_supportsDxt1) {
-        m_formats.append(Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT);
-        m_formats.append(Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT);
-    }
-
-    if (m_supportsDxt5)
-        m_formats.append(Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT);
-
-    if (m_supportsEtc1)
-        m_formats.append(Extensions3D::ETC1_RGB8_OES);
-
-    if (m_supportsPvrtc) {
-        m_formats.append(Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG);
-        m_formats.append(Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG);
-    }
-}
-
-WebGLCompressedTextures::~WebGLCompressedTextures()
-{
-}
-
-WebGLExtension::ExtensionName WebGLCompressedTextures::getName() const
-{
-    return WebKitWebGLCompressedTexturesName;
-}
-
-PassOwnPtr<WebGLCompressedTextures> WebGLCompressedTextures::create(WebGLRenderingContext* context)
-{
-    return adoptPtr(new WebGLCompressedTextures(context));
-}
-
-bool WebGLCompressedTextures::supported(WebGLRenderingContext* context)
-{
-    Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
-    return extensions->supports("GL_EXT_texture_compression_dxt1")
-        || extensions->supports("GL_EXT_texture_compression_s3tc")
-        || extensions->supports("GL_CHROMIUM_texture_compression_dxt5")
-        || extensions->supports("GL_OES_compressed_ETC1_RGB8_texture")
-        || extensions->supports("GL_IMG_texture_compression_pvrtc");
-}
-
-bool WebGLCompressedTextures::validateCompressedTexFormat(GC3Denum format)
-{
-    switch (format) {
-    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
-    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
-        return m_supportsDxt1;
-    case Extensions3D::ETC1_RGB8_OES:
-        return m_supportsEtc1;
-    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
-        return m_supportsDxt5;
-    case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
-    case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
-        return m_supportsPvrtc;
-    }
-    return false;
-}
-
-bool WebGLCompressedTextures::validateCompressedTexFuncData(const char* functionName,
-                                                            GC3Dsizei width, GC3Dsizei height,
-                                                            GC3Denum format, ArrayBufferView* pixels)
-{
-    if (!pixels) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pixels");
-        return false;
-    }
-    if (width < 0 || height < 0) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0");
-        return false;
-    }
-
-    unsigned int bytesRequired = 0;
-
-    switch (format) {
-    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
-    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
-    case Extensions3D::ETC1_RGB8_OES:
-        {
-            const int kBlockWidth = 4;
-            const int kBlockHeight = 4;
-            const int kBlockSize = 8;
-            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
-            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
-            int numBlocks = numBlocksAcross * numBlocksDown;
-            bytesRequired = numBlocks * kBlockSize;
-        }
-        break;
-    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
-        {
-            const int kBlockWidth = 4;
-            const int kBlockHeight = 4;
-            const int kBlockSize = 16;
-            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
-            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
-            int numBlocks = numBlocksAcross * numBlocksDown;
-            bytesRequired = numBlocks * kBlockSize;
-        }
-        break;
-    case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
-    case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
-        {
-            bytesRequired = (std::max(width, 8) * std::max(height, 8) + 7) / 8;
-        }
-        break;
-    default:
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format");
-        return false;
-    }
-
-    if (pixels->byteLength() != bytesRequired) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "length of ArrayBufferView is not correct for dimensions");
-        return false;
-    }
-
-    return true;
-}
-
-bool WebGLCompressedTextures::validateCompressedTexSubDimensions(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
-                                                                             GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex)
-{
-    switch (format) {
-    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
-    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
-    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
-    case Extensions3D::ETC1_RGB8_OES:
-        {
-            const int kBlockWidth = 4;
-            const int kBlockHeight = 4;
-            if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight))
-                return false;
-            if (!xoffset) {
-                if (width != tex->getWidth(target, level))
-                    return false;
-            } else {
-                if (width % kBlockWidth)
-                    return false;
-            }
-            if (!yoffset) {
-                if (height != tex->getHeight(target, level))
-                    return false;
-            } else {
-                if (height % kBlockHeight)
-                    return false;
-            }
-            return true;
-        }
-    case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
-    case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
-        {
-            if (xoffset || yoffset
-                || width != tex->getWidth(target, level) || height != tex->getHeight(target, level)) {
-                return false;
-            }
-            return true;
-        }
-    }
-    return false;
-}
-
-void WebGLCompressedTextures::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
-                                                               GC3Dsizei height, GC3Dint border, ArrayBufferView* data)
-{
-    if (m_context->isContextLost())
-        return;
-    if (!validateCompressedTexFormat(internalformat)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
-        return;
-    }
-    if (border) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "border not 0");
-        return;
-    }
-    if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, internalformat, data))
-        return;
-    WebGLTexture* tex = m_context->validateTextureBinding("compressedTexImage2D", target, true);
-    if (!tex)
-        return;
-    if (!m_context->isGLES2NPOTStrict()) {
-        if (level && WebGLTexture::isNPOT(width, height)) {
-            m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "level > 0 not power of 2");
-            return;
-        }
-    }
-    m_context->graphicsContext3D()->compressedTexImage2D(target, level, internalformat, width, height,
-                                                         border, data->byteLength(), data->baseAddress());
-    tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
-    m_context->cleanupAfterGraphicsCall(false);
-}
-
-void WebGLCompressedTextures::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
-                                                                  GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data)
-{
-    if (m_context->isContextLost())
-        return;
-    if (!validateCompressedTexFormat(format)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format");
-        return;
-    }
-    if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data))
-        return;
-
-    WebGLTexture* tex = m_context->validateTextureBinding("compressedTexSubImage2D", target, true);
-    if (!tex)
-        return;
-
-    if (format != tex->getInternalFormat(target, level)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexSubImage2D", "format does not match texture format");
-        return;
-    }
-
-    if (!validateCompressedTexSubDimensions(target, level, xoffset, yoffset, width, height, format, tex)) {
-        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSubImage2D", "dimensions invalid for format");
-        return;
-    }
-
-    m_context->graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset,
-                                                            width, height, format, data->byteLength(), data->baseAddress());
-    m_context->cleanupAfterGraphicsCall(false);
-}
-
-WebGLGetInfo WebGLCompressedTextures::getCompressedTextureFormats()
-{
-    return WebGLGetInfo(Int32Array::create(&m_formats[0], m_formats.size()));
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGL)
index 4ff9690..ff482fa 100644 (file)
@@ -40,7 +40,7 @@ public:
         OESVertexArrayObjectName,
         WebGLDebugRendererInfoName,
         WebGLDebugShadersName,
-        WebKitWebGLCompressedTexturesName, // WEBKIT_ prefix until extension is official
+        WebKitWebGLCompressedTextureS3TCName, // WEBKIT_ prefix until extension is official
     };
 
     void ref() { m_context->ref(); }
index 87bec79..f7166c4 100644 (file)
@@ -38,6 +38,7 @@
 #include "WebGLVertexArrayObjectOES.h"
 #include <wtf/Float32Array.h>
 #include <wtf/Int32Array.h>
+#include <wtf/Uint32Array.h>
 #include <wtf/Uint8Array.h>
 
 namespace WebCore {
@@ -191,6 +192,16 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<Uint8Array> value)
 {
 }
 
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<Uint32Array> value)
+    : m_type(kTypeWebGLUnsignedIntArray)
+    , m_bool(false)
+    , m_float(0)
+    , m_int(0)
+    , m_unsignedInt(0)
+    , m_webglUnsignedIntArray(value)
+{
+}
+
 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value)
     : m_type(kTypeWebGLVertexArrayObjectOES)
     , m_bool(false)
@@ -294,6 +305,12 @@ PassRefPtr<Uint8Array> WebGLGetInfo::getWebGLUnsignedByteArray() const
     return m_webglUnsignedByteArray;
 }
 
+PassRefPtr<Uint32Array> WebGLGetInfo::getWebGLUnsignedIntArray() const
+{
+    ASSERT(getType() == kTypeWebGLUnsignedIntArray);
+    return m_webglUnsignedIntArray;
+}
+
 PassRefPtr<WebGLVertexArrayObjectOES> WebGLGetInfo::getWebGLVertexArrayObjectOES() const
 {
     ASSERT(getType() == kTypeWebGLVertexArrayObjectOES);
index f747a09..d1f73a6 100644 (file)
@@ -39,6 +39,7 @@
 #include <wtf/Int32Array.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/Uint32Array.h>
 #include <wtf/Uint8Array.h>
 
 namespace WebCore {
@@ -67,6 +68,7 @@ public:
         kTypeWebGLRenderbuffer,
         kTypeWebGLTexture,
         kTypeWebGLUnsignedByteArray,
+        kTypeWebGLUnsignedIntArray,
         kTypeWebGLVertexArrayObjectOES,
     };
 
@@ -88,6 +90,7 @@ public:
     explicit WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value);
     explicit WebGLGetInfo(PassRefPtr<WebGLTexture> value);
     explicit WebGLGetInfo(PassRefPtr<Uint8Array> value);
+    explicit WebGLGetInfo(PassRefPtr<Uint32Array> value);
     explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value);
 
     virtual ~WebGLGetInfo();
@@ -110,6 +113,7 @@ public:
     PassRefPtr<WebGLRenderbuffer> getWebGLRenderbuffer() const;
     PassRefPtr<WebGLTexture> getWebGLTexture() const;
     PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
+    PassRefPtr<Uint32Array> getWebGLUnsignedIntArray() const;
     PassRefPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const;
 
 private:
@@ -130,6 +134,7 @@ private:
     RefPtr<WebGLRenderbuffer> m_webglRenderbuffer;
     RefPtr<WebGLTexture> m_webglTexture;
     RefPtr<Uint8Array> m_webglUnsignedByteArray;
+    RefPtr<Uint32Array> m_webglUnsignedIntArray;
     RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObject;
 };
 
index 192852c..6d7b9d8 100644 (file)
@@ -32,7 +32,7 @@
 #include "OESStandardDerivatives.h"
 #include "OESTextureFloat.h"
 #include "OESVertexArrayObject.h"
-#include "WebGLCompressedTextures.h"
+#include "WebGLCompressedTextureS3TC.h"
 #include "WebGLContextGroup.h"
 #include "WebGLDebugRendererInfo.h"
 #include "WebGLDebugShaders.h"
index 618b92d..6f15136 100644 (file)
@@ -54,7 +54,7 @@
 #include "Settings.h"
 #include "WebGLActiveInfo.h"
 #include "WebGLBuffer.h"
-#include "WebGLCompressedTextures.h"
+#include "WebGLCompressedTextureS3TC.h"
 #include "WebGLContextAttributes.h"
 #include "WebGLContextEvent.h"
 #include "WebGLContextGroup.h"
@@ -72,6 +72,7 @@
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/PassOwnArrayPtr.h>
 #include <wtf/Uint16Array.h>
+#include <wtf/Uint32Array.h>
 #include <wtf/text/StringBuilder.h>
 
 #if PLATFORM(QT)
@@ -541,6 +542,12 @@ bool WebGLRenderingContext::allowPrivilegedExtensions() const
     return false;
 }
 
+void WebGLRenderingContext::addCompressedTextureFormat(GC3Denum format)
+{
+    if (!m_compressedTextureFormats.contains(format))
+        m_compressedTextureFormats.append(format);
+}
+
 WebGLRenderingContext::~WebGLRenderingContext()
 {
     // Remove all references to WebGLObjects so if they are the last reference
@@ -1212,24 +1219,71 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
     cleanupAfterGraphicsCall(false);
 }
 
-void WebGLRenderingContext::compressedTexImage2D(GC3Denum /*target*/, GC3Dint /*level*/, GC3Denum /*internalformat*/, GC3Dsizei /*width*/,
-                                                 GC3Dsizei /*height*/, GC3Dint /*border*/, ArrayBufferView* /*data*/)
+void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
+                                                 GC3Dsizei height, GC3Dint border, ArrayBufferView* data)
 {
     if (isContextLost())
         return;
+    if (!validateTexFuncLevel("compressedTexImage2D", target, level))
+        return;
+
+    if (!validateCompressedTexFormat(internalformat)) {
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
+        return;
+    }
+    if (border) {
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "border not 0");
+        return;
+    }
+    if (!validateCompressedTexDimensions("compressedTexImage2D", level, width, height, internalformat))
+        return;
+    if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, internalformat, data))
+        return;
 
-    // FIXME: implement this.
-    synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
+    WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, true);
+    if (!tex)
+        return;
+    if (!isGLES2NPOTStrict()) {
+        if (level && WebGLTexture::isNPOT(width, height)) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "level > 0 not power of 2");
+            return;
+        }
+    }
+    graphicsContext3D()->compressedTexImage2D(target, level, internalformat, width, height,
+                                              border, data->byteLength(), data->baseAddress());
+    tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
+    cleanupAfterGraphicsCall(false);
 }
 
-void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum /*target*/, GC3Dint /*level*/, GC3Dint /*xoffset*/, GC3Dint /*yoffset*/,
-                                                    GC3Dsizei /*width*/, GC3Dsizei /*height*/, GC3Denum /*format*/, ArrayBufferView* /*data*/)
+void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
+                                                    GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data)
 {
     if (isContextLost())
         return;
+    if (!validateTexFuncLevel("compressedTexSubImage2D", target, level))
+        return;
+    if (!validateCompressedTexFormat(format)) {
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format");
+        return;
+    }
+    if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data))
+        return;
+
+    WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target, true);
+    if (!tex)
+        return;
 
-    // FIXME: implement this.
-    synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format");
+    if (format != tex->getInternalFormat(target, level)) {
+        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSubImage2D", "format does not match texture format");
+        return;
+    }
+
+    if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, level, xoffset, yoffset, width, height, format, tex))
+        return;
+
+    graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset,
+                                                 width, height, format, data->byteLength(), data->baseAddress());
+    cleanupAfterGraphicsCall(false);
 }
 
 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
@@ -2190,11 +2244,11 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
             m_webglLoseContext = WebGLLoseContext::create(this);
         return m_webglLoseContext.get();
     }
-    if (equalIgnoringCase(name, "WEBKIT_WEBGL_compressed_textures")) {
+    if (equalIgnoringCase(name, "WEBKIT_WEBGL_compressed_texture_s3tc")) {
         // Use WEBKIT_ prefix until extension is official.
-        if (!m_webglCompressedTextures)
-            m_webglCompressedTextures = WebGLCompressedTextures::create(this);
-        return m_webglCompressedTextures.get();
+        if (!m_webglCompressedTextureS3TC)
+            m_webglCompressedTextureS3TC = WebGLCompressedTextureS3TC::create(this);
+        return m_webglCompressedTextureS3TC.get();
     }
 
     if (allowPrivilegedExtensions()) {
@@ -2307,10 +2361,7 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&
     case GraphicsContext3D::COLOR_WRITEMASK:
         return getBooleanArrayParameter(pname);
     case GraphicsContext3D::COMPRESSED_TEXTURE_FORMATS:
-        if (m_webglCompressedTextures)
-            return m_webglCompressedTextures->getCompressedTextureFormats();
-        // Defined as null in the spec
-        return WebGLGetInfo();
+        return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data(), m_compressedTextureFormats.size()));
     case GraphicsContext3D::CULL_FACE:
         return getBooleanParameter(pname);
     case GraphicsContext3D::CULL_FACE_MODE:
@@ -2365,9 +2416,6 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&
         return getIntParameter(pname);
     case GraphicsContext3D::MAX_VIEWPORT_DIMS:
         return getWebGLIntArrayParameter(pname);
-    case GraphicsContext3D::NUM_COMPRESSED_TEXTURE_FORMATS:
-        // WebGL 1.0 specifies that there are no compressed texture formats.
-        return WebGLGetInfo(static_cast<int>(0));
     case GraphicsContext3D::NUM_SHADER_BINARY_FORMATS:
         // FIXME: should we always return 0 for this?
         return getIntParameter(pname);
@@ -2640,8 +2688,8 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions()
     if (m_context->getExtensions()->supports("GL_OES_vertex_array_object"))
         result.append("OES_vertex_array_object");
     result.append("WEBKIT_WEBGL_lose_context");
-    if (WebGLCompressedTextures::supported(this))
-        result.append("WEBKIT_WEBGL_compressed_textures");
+    if (WebGLCompressedTextureS3TC::supported(this))
+        result.append("WEBKIT_WEBGL_compressed_texture_s3tc");
 
     if (allowPrivilegedExtensions()) {
         if (m_context->getExtensions()->supports("GL_ANGLE_translated_shader_source"))
@@ -4685,6 +4733,117 @@ bool WebGLRenderingContext::validateTexFuncData(const char* functionName,
     return true;
 }
 
+bool WebGLRenderingContext::validateCompressedTexFormat(GC3Denum format)
+{
+    return m_compressedTextureFormats.contains(format);
+}
+
+bool WebGLRenderingContext::validateCompressedTexFuncData(const char* functionName,
+                                                          GC3Dsizei width, GC3Dsizei height,
+                                                          GC3Denum format, ArrayBufferView* pixels)
+{
+    if (!pixels) {
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pixels");
+        return false;
+    }
+    if (width < 0 || height < 0) {
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0");
+        return false;
+    }
+
+    unsigned int bytesRequired = 0;
+
+    switch (format) {
+    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
+        {
+            const int kBlockWidth = 4;
+            const int kBlockHeight = 4;
+            const int kBlockSize = 8;
+            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
+            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
+            int numBlocks = numBlocksAcross * numBlocksDown;
+            bytesRequired = numBlocks * kBlockSize;
+        }
+        break;
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
+        {
+            const int kBlockWidth = 4;
+            const int kBlockHeight = 4;
+            const int kBlockSize = 16;
+            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
+            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
+            int numBlocks = numBlocksAcross * numBlocksDown;
+            bytesRequired = numBlocks * kBlockSize;
+        }
+        break;
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format");
+        return false;
+    }
+
+    if (pixels->byteLength() != bytesRequired) {
+        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "length of ArrayBufferView is not correct for dimensions");
+        return false;
+    }
+
+    return true;
+}
+
+bool WebGLRenderingContext::validateCompressedTexDimensions(const char* functionName, GC3Dint level, GC3Dsizei width, GC3Dsizei height, GC3Denum format)
+{
+    switch (format) {
+    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: {
+        const int kBlockWidth = 4;
+        const int kBlockHeight = 4;
+        bool widthValid = (level && width == 1) || (level && width == 2) || !(width % kBlockWidth);
+        bool heightValid = (level && height == 1) || (level && height == 2) || !(height % kBlockHeight);
+        if (!widthValid || !heightValid) {
+          synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "width or height invalid for level");
+          return false;
+        }
+        return true;
+    }
+    default:
+        return false;
+    }
+}
+
+bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* functionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
+                                                               GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex)
+{
+    if (xoffset < 0 || yoffset < 0) {
+      synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "xoffset or yoffset < 0");
+      return false;
+    }
+
+    switch (format) {
+    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
+    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: {
+        const int kBlockWidth = 4;
+        const int kBlockHeight = 4;
+        if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "xoffset or yoffset not multiple of 4");
+            return false;
+        }
+        if (width - xoffset > tex->getWidth(target, level)
+            || height - yoffset > tex->getHeight(target, level)) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "dimensions out of range");
+            return false;
+        }
+        return validateCompressedTexDimensions(functionName, level, width, height, format);
+    }
+    default:
+        return false;
+    }
+}
+
 bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode)
 {
     switch (mode) {
index b81c2b0..0449ead 100644 (file)
@@ -52,7 +52,7 @@ class WebGLActiveInfo;
 class WebGLBuffer;
 class WebGLContextGroup;
 class WebGLContextObject;
-class WebGLCompressedTextures;
+class WebGLCompressedTextureS3TC;
 class WebGLContextAttributes;
 class WebGLDebugRendererInfo;
 class WebGLDebugShaders;
@@ -321,7 +321,7 @@ public:
     friend class WebGLObject;
     friend class OESVertexArrayObject;
     friend class WebGLDebugShaders;
-    friend class WebGLCompressedTextures;
+    friend class WebGLCompressedTextureS3TC;
     friend class WebGLRenderingContextErrorMessageCallback;
 
     WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes);
@@ -367,6 +367,9 @@ public:
 
     bool validateWebGLObject(const char*, WebGLObject*);
 
+    // Adds a compressed texture format.
+    void addCompressedTextureFormat(GC3Denum);
+
 #if ENABLE(VIDEO)
     PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, ExceptionCode&);
 #endif
@@ -443,6 +446,8 @@ public:
     RefPtr<WebGLTexture> m_blackTexture2D;
     RefPtr<WebGLTexture> m_blackTextureCubeMap;
 
+    Vector<GC3Denum> m_compressedTextureFormats;
+
     // Fixed-size cache of reusable image buffers for video texImage2D calls.
     class LRUImageBufferCache {
     public:
@@ -500,7 +505,7 @@ public:
     OwnPtr<WebGLLoseContext> m_webglLoseContext;
     OwnPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
     OwnPtr<WebGLDebugShaders> m_webglDebugShaders;
-    OwnPtr<WebGLCompressedTextures> m_webglCompressedTextures;
+    OwnPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
 
     // Helpers for getParameter and others
     WebGLGetInfo getBooleanParameter(GC3Denum);
@@ -588,6 +593,24 @@ public:
                              GC3Denum format, GC3Denum type,
                              ArrayBufferView* pixels);
 
+    // Helper function to validate compressed texture data is correct size
+    // for the given format and dimensions.
+    bool validateCompressedTexFuncData(const char* functionName,
+                                       GC3Dsizei width, GC3Dsizei height,
+                                       GC3Denum format, ArrayBufferView* pixels);
+
+    // Helper function for validating compressed texture formats.
+    bool validateCompressedTexFormat(GC3Denum format);
+
+    // Helper function to validate compressed texture dimensions are valid for
+    // the given format.
+    bool validateCompressedTexDimensions(const char* functionName, GC3Dint level, GC3Dsizei width, GC3Dsizei height, GC3Denum format);
+
+    // Helper function to validate compressed texture dimensions are valid for
+    // the given format.
+    bool validateCompressedTexSubDimensions(const char* functionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
+                                            GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture*);
+
     // Helper function to validate mode for draw{Arrays/Elements}.
     bool validateDrawMode(const char* functionName, GC3Denum);
 
index 4d992c1..6db811d 100644 (file)
@@ -206,7 +206,6 @@ module html {
         /*      TEXTURE_WRAP_S */
         /*      TEXTURE_WRAP_T */
 
-        const unsigned int NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
         const unsigned int COMPRESSED_TEXTURE_FORMATS     = 0x86A3;
 
         /* HintMode */