Changeset 107107 in webkit


Ignore:
Timestamp:
Feb 8, 2012 11:13:56 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Implement new WEBGL compressed texture extensions
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 <Gregg Tavares> 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:
Location:
trunk
Files:
1 added
2 deleted
21 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107104 r107107  
     12012-02-08  Gregg Tavares  <gman@chromium.org>
     2
     3        Implement new WEBGL compressed texture extensions
     4        https://bugs.webkit.org/show_bug.cgi?id=77066
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * fast/canvas/webgl/constants.html:
     9        * fast/canvas/webgl/gl-get-calls-expected.txt:
     10        * fast/canvas/webgl/gl-get-calls.html:
     11
    1122012-02-08  Csaba Osztrogonác  <ossy@webkit.org>
    213
  • trunk/LayoutTests/fast/canvas/webgl/constants.html

    r98407 r107107  
    195195    /*      TEXTURE_WRAP_T */
    196196   
    197 NUM_COMPRESSED_TEXTURE_FORMATS : 0x86A2,
    198197COMPRESSED_TEXTURE_FORMATS     : 0x86A3,
    199198   
  • trunk/LayoutTests/fast/canvas/webgl/gl-get-calls-expected.txt

    r65279 r107107  
    7676PASS context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 128 is true
    7777PASS context.getParameter(context.MAX_VARYING_VECTORS) >= 8 is true
    78 PASS context.getParameter(context.NUM_COMPRESSED_TEXTURE_FORMATS) is 0
     78PASS context.getParameter(context.COMPRESSED_TEXTURE_FORMATS) is []
    7979
    8080PASS successfullyParsed is true
  • trunk/LayoutTests/fast/canvas/webgl/gl-get-calls.html

    r98407 r107107  
    108108    shouldBeTrue('context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 128');
    109109    shouldBeTrue('context.getParameter(context.MAX_VARYING_VECTORS) >= 8');
    110     shouldBe('context.getParameter(context.NUM_COMPRESSED_TEXTURE_FORMATS)', '0');
     110    shouldBe('context.getParameter(context.COMPRESSED_TEXTURE_FORMATS)', '[]');
    111111}
    112112
  • trunk/Source/WebCore/CMakeLists.txt

    r106953 r107107  
    21822182        ${THIRDPARTY_DIR}/ANGLE/src/compiler/VariableInfo.cpp
    21832183        html/canvas/WebGLBuffer.cpp
    2184         html/canvas/WebGLCompressedTextures.cpp
     2184        html/canvas/WebGLCompressedTextureS3TC.cpp
    21852185        html/canvas/WebGLContextAttributes.cpp
    21862186        html/canvas/WebGLContextEvent.cpp
     
    22152215        html/canvas/WebGLActiveInfo.idl
    22162216        html/canvas/WebGLBuffer.idl
    2217         html/canvas/WebGLCompressedTextures.idl
     2217        html/canvas/WebGLCompressedTextureS3TC.idl
    22182218        html/canvas/WebGLContextAttributes.idl
    22192219        html/canvas/WebGLContextEvent.idl
  • trunk/Source/WebCore/ChangeLog

    r107106 r107107  
     12012-02-08  Gregg Tavares  <gman@google.com>
     2
     3        Implement new WEBGL compressed texture extensions
     4        https://bugs.webkit.org/show_bug.cgi?id=77066
     5
     6        This removes the old experimental compressed
     7        texture extension and implements the first new
     8        one.
     9
     10        A test is in the WebGL conformance tests in
     11        extensions/webgl-compressed-texture-s3tc.html
     12        and will be copied here in a future patch.
     13
     14        Reviewed by Kenneth Russell.
     15
     16        No new tests. Test coming in future patch.
     17
     18        * CMakeLists.txt:
     19        * DerivedSources.make:
     20        * GNUmakefile.list.am:
     21        * Target.pri:
     22        * WebCore.gypi:
     23        * WebCore.xcodeproj/project.pbxproj:
     24        * bindings/js/JSWebGLRenderingContextCustom.cpp:
     25        (WebCore::toJS):
     26        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
     27        (WebCore::toV8Object):
     28        * html/canvas/WebGLCompressedTextureS3TC.cpp: Added.
     29        (WebCore):
     30        (WebCore::WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC):
     31        (WebCore::WebGLCompressedTextureS3TC::~WebGLCompressedTextureS3TC):
     32        (WebCore::WebGLCompressedTextureS3TC::getName):
     33        (WebCore::WebGLCompressedTextureS3TC::create):
     34        (WebCore::WebGLCompressedTextureS3TC::supported):
     35        * html/canvas/WebGLCompressedTextureS3TC.h: Copied from Source/WebCore/html/canvas/WebGLExtension.h.
     36        (WebCore):
     37        (WebGLCompressedTextureS3TC):
     38        * html/canvas/WebGLCompressedTextureS3TC.idl: Renamed from Source/WebCore/html/canvas/WebGLCompressedTextures.idl.
     39        * html/canvas/WebGLCompressedTextures.cpp: Removed.
     40        * html/canvas/WebGLCompressedTextures.h: Removed.
     41        * html/canvas/WebGLExtension.h:
     42        * html/canvas/WebGLGetInfo.cpp:
     43        (WebCore::WebGLGetInfo::WebGLGetInfo):
     44        (WebCore):
     45        (WebCore::WebGLGetInfo::getWebGLUnsignedIntArray):
     46        * html/canvas/WebGLGetInfo.h:
     47        * html/canvas/WebGLObject.cpp:
     48        * html/canvas/WebGLRenderingContext.cpp:
     49        (WebCore):
     50        (WebCore::WebGLRenderingContext::addCompressedTextureFormat):
     51        (WebCore::WebGLRenderingContext::compressedTexImage2D):
     52        (WebCore::WebGLRenderingContext::compressedTexSubImage2D):
     53        (WebCore::WebGLRenderingContext::getExtension):
     54        (WebCore::WebGLRenderingContext::getParameter):
     55        (WebCore::WebGLRenderingContext::getSupportedExtensions):
     56        (WebCore::WebGLRenderingContext::validateCompressedTexFormat):
     57        (WebCore::WebGLRenderingContext::validateCompressedTexFuncData):
     58        (WebCore::WebGLRenderingContext::validateCompressedTexDimensions):
     59        (WebCore::WebGLRenderingContext::validateCompressedTexSubDimensions):
     60        * html/canvas/WebGLRenderingContext.h:
     61        (WebCore):
     62        (WebGLRenderingContext):
     63        * html/canvas/WebGLRenderingContext.idl:
     64
    1652012-02-08  Ilya Tikhonovsky  <loislo@chromium.org>
    266
  • trunk/Source/WebCore/DerivedSources.make

    r107026 r107107  
    287287    $(WebCore)/html/canvas/WebGLActiveInfo.idl \
    288288    $(WebCore)/html/canvas/WebGLBuffer.idl \
    289     $(WebCore)/html/canvas/WebGLCompressedTextures.idl \
     289    $(WebCore)/html/canvas/WebGLCompressedTextureS3TC.idl \
    290290    $(WebCore)/html/canvas/WebGLContextAttributes.idl \
    291291    $(WebCore)/html/canvas/WebGLContextEvent.idl \
  • trunk/Source/WebCore/DerivedSources.pri

    r107026 r107107  
    223223    $$PWD/html/canvas/WebGLActiveInfo.idl \
    224224    $$PWD/html/canvas/WebGLBuffer.idl \
     225    $$PWD/html/canvas/WebGLCompressedTextureS3TC.idl \
    225226    $$PWD/html/canvas/WebGLContextAttributes.idl \
    226227    $$PWD/html/canvas/WebGLContextEvent.idl \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r107082 r107107  
    544544        DerivedSources/WebCore/JSWebGLBuffer.cpp \
    545545        DerivedSources/WebCore/JSWebGLBuffer.h \
     546        DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.cpp \
     547        DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.h \
    546548        DerivedSources/WebCore/JSWebGLContextAttributes.cpp \
    547549        DerivedSources/WebCore/JSWebGLContextAttributes.h \
     
    848850        $(WebCore)/html/canvas/WebGLActiveInfo.idl \
    849851        $(WebCore)/html/canvas/WebGLBuffer.idl \
     852        $(WebCore)/html/canvas/WebGLCompressedTextureS3TC.idl \
    850853        $(WebCore)/html/canvas/WebGLContextAttributes.idl \
    851854        $(WebCore)/html/canvas/WebGLContextEvent.idl \
     
    56155618        Source/WebCore/html/canvas/WebGLBuffer.cpp \
    56165619        Source/WebCore/html/canvas/WebGLBuffer.h \
    5617         Source/WebCore/html/canvas/WebGLCompressedTextures.cpp \
    5618         Source/WebCore/html/canvas/WebGLCompressedTextures.h \
     5620        Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp \
     5621        Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.h \
    56195622        Source/WebCore/html/canvas/WebGLContextAttributes.cpp \
    56205623        Source/WebCore/html/canvas/WebGLContextAttributes.h \
  • trunk/Source/WebCore/Target.pri

    r107082 r107107  
    36943694        html/canvas/WebGLActiveInfo.h \
    36953695        html/canvas/WebGLBuffer.h \
    3696         html/canvas/WebGLCompressedTextures.h \
     3696        html/canvas/WebGLCompressedTextureS3TC.h \
    36973697        html/canvas/WebGLContextAttributes.h \
    36983698        html/canvas/WebGLContextEvent.h \
     
    37343734        html/canvas/WebGLObject.cpp \
    37353735        html/canvas/WebGLBuffer.cpp \
    3736         html/canvas/WebGLCompressedTextures.cpp \
     3736        html/canvas/WebGLCompressedTextureS3TC.cpp \
    37373737        html/canvas/WebGLContextAttributes.cpp \
    37383738        html/canvas/WebGLContextEvent.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r107082 r107107  
    961961            'html/canvas/WebGLActiveInfo.idl',
    962962            'html/canvas/WebGLBuffer.idl',
    963             'html/canvas/WebGLCompressedTextures.idl',
     963            'html/canvas/WebGLCompressedTextureS3TC.idl',
    964964            'html/canvas/WebGLContextAttributes.idl',
    965965            'html/canvas/WebGLContextEvent.idl',
     
    54425442            'html/canvas/WebGLBuffer.cpp',
    54435443            'html/canvas/WebGLBuffer.h',
    5444             'html/canvas/WebGLCompressedTextures.cpp',
    5445             'html/canvas/WebGLCompressedTextures.h',
     5444            'html/canvas/WebGLCompressedTextureS3TC.cpp',
     5445            'html/canvas/WebGLCompressedTextureS3TC.h',
    54465446            'html/canvas/WebGLContextAttributes.cpp',
    54475447            'html/canvas/WebGLContextAttributes.h',
     
    78557855            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLBuffer.cpp',
    78567856            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLBuffer.h',
     7857            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.cpp',
     7858            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.h',
    78577859            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLContextAttributes.cpp',
    78587860            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLContextAttributes.h',
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r107082 r107107  
    17831783                6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */; };
    17841784                6E21C6C21126339900A7BE02 /* GraphicsContext3DCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */; };
    1785                 6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextures.cpp */; };
    1786                 6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextures.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextures.h */; };
    1787                 6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextures.cpp */; };
    1788                 6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextures.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextures.h */; };
     1785                6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */; };
     1786                6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */; };
     1787                6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp */; };
     1788                6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */; };
    17891789                6E47E66010B7944B00B186C8 /* WebGLGetInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */; };
    17901790                6E47E66110B7944B00B186C8 /* WebGLGetInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */; };
     
    86518651                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
    86528652                6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DCG.cpp; sourceTree = "<group>"; };
    8653                 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextures.cpp; sourceTree = "<group>"; };
    8654                 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLCompressedTextures.h; sourceTree = "<group>"; };
    8655                 6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLCompressedTextures.cpp; path = canvas/WebGLCompressedTextures.cpp; sourceTree = "<group>"; };
    8656                 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLCompressedTextures.h; path = canvas/WebGLCompressedTextures.h; sourceTree = "<group>"; };
    8657                 6E3FAE9014733FEA00E42306 /* WebGLCompressedTextures.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLCompressedTextures.idl; path = canvas/WebGLCompressedTextures.idl; sourceTree = "<group>"; };
     8653                6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; };
     8654                6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLCompressedTextureS3TC.h; sourceTree = "<group>"; };
     8655                6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLCompressedTextureS3TC.cpp; path = canvas/WebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; };
     8656                6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLCompressedTextureS3TC.h; path = canvas/WebGLCompressedTextureS3TC.h; sourceTree = "<group>"; };
     8657                6E3FAE9014733FEA00E42306 /* WebGLCompressedTextureS3TC.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLCompressedTextureS3TC.idl; path = canvas/WebGLCompressedTextureS3TC.idl; sourceTree = "<group>"; };
    86588658                6E47E65E10B7944B00B186C8 /* WebGLGetInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLGetInfo.cpp; path = canvas/WebGLGetInfo.cpp; sourceTree = "<group>"; };
    86598659                6E47E65F10B7944B00B186C8 /* WebGLGetInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLGetInfo.h; path = canvas/WebGLGetInfo.h; sourceTree = "<group>"; };
     
    1448214482                                49C7B9A91042D32E0009D447 /* WebGLBuffer.h */,
    1448314483                                49C7B9AA1042D32E0009D447 /* WebGLBuffer.idl */,
    14484                                 6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextures.cpp */,
    14485                                 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextures.h */,
    14486                                 6E3FAE9014733FEA00E42306 /* WebGLCompressedTextures.idl */,
     14484                                6E3FAE8C14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp */,
     14485                                6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */,
     14486                                6E3FAE9014733FEA00E42306 /* WebGLCompressedTextureS3TC.idl */,
    1448714487                                6E4E91A910F7FB3100A2779C /* WebGLContextAttributes.cpp */,
    1448814488                                6E4E91AA10F7FB3100A2779C /* WebGLContextAttributes.h */,
     
    1746517465                                49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */,
    1746617466                                49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */,
    17467                                 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextures.cpp */,
    17468                                 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextures.h */,
     17467                                6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */,
     17468                                6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */,
    1746917469                                6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */,
    1747017470                                6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */,
     
    2299222992                                A7D20F63107F406900A80392 /* JSWebGLActiveInfo.h in Headers */,
    2299322993                                49C7B9941042D2D30009D447 /* JSWebGLBuffer.h in Headers */,
    22994                                 6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextures.h in Headers */,
     22994                                6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextureS3TC.h in Headers */,
    2299522995                                6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */,
    2299622996                                BC2CBF4E140F1ABD003879BE /* JSWebGLContextEvent.h in Headers */,
     
    2401924019                                A7D20F6D107F438B00A80392 /* WebGLActiveInfo.h in Headers */,
    2402024020                                49C7B9C91042D32F0009D447 /* WebGLBuffer.h in Headers */,
    24021                                 6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextures.h in Headers */,
     24021                                6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */,
    2402224022                                6E4E91AF10F7FB3100A2779C /* WebGLContextAttributes.h in Headers */,
    2402324023                                93F6F1EE127F70B10055CB06 /* WebGLContextEvent.h in Headers */,
     
    2613626136                                A7D20F62107F406900A80392 /* JSWebGLActiveInfo.cpp in Sources */,
    2613726137                                49C7B9931042D2D30009D447 /* JSWebGLBuffer.cpp in Sources */,
    26138                                 6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextures.cpp in Sources */,
     26138                                6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp in Sources */,
    2613926139                                6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */,
    2614026140                                BC2CBF7B140F1D58003879BE /* JSWebGLContextEvent.cpp in Sources */,
     
    2696926969                                BC6DADFA0A19602B00E5CD14 /* WebFontCache.mm in Sources */,
    2697026970                                49C7B9C81042D32F0009D447 /* WebGLBuffer.cpp in Sources */,
    26971                                 6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextures.cpp in Sources */,
     26971                                6E3FAE8E14733FDB00E42306 /* WebGLCompressedTextureS3TC.cpp in Sources */,
    2697226972                                6E4E91AE10F7FB3100A2779C /* WebGLContextAttributes.cpp in Sources */,
    2697326973                                93F6F1ED127F70B10055CB06 /* WebGLContextEvent.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp

    r105698 r107107  
    4141#include "JSOESTextureFloat.h"
    4242#include "JSOESVertexArrayObject.h"
     43#include "JSUint32Array.h"
    4344#include "JSUint8Array.h"
    4445#include "JSWebGLBuffer.h"
     46#include "JSWebGLCompressedTextureS3TC.h"
    4547#include "JSWebGLFramebuffer.h"
    4648#include "JSWebGLLoseContext.h"
     
    5759#include "OESVertexArrayObject.h"
    5860#include "WebGLBuffer.h"
    59 #include "WebGLCompressedTextures.h"
     61#include "WebGLCompressedTextureS3TC.h"
    6062#include "WebGLDebugRendererInfo.h"
    6163#include "WebGLDebugShaders.h"
     
    7274#include <wtf/Float32Array.h>
    7375#include <wtf/Int32Array.h>
     76#include <wtf/Uint32Array.h>
    7477
    7578#if ENABLE(VIDEO)
     
    122125    case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
    123126        return toJS(exec, globalObject, info.getWebGLUnsignedByteArray());
     127    case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
     128        return toJS(exec, globalObject, info.getWebGLUnsignedIntArray());
    124129    case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
    125130        return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
     
    194199    case WebGLExtension::WebGLDebugShadersName:
    195200        return toJS(exec, globalObject, static_cast<WebGLDebugShaders*>(extension));
    196     case WebGLExtension::WebKitWebGLCompressedTexturesName:
    197         return toJS(exec, globalObject, static_cast<WebGLCompressedTextures*>(extension));
     201    case WebGLExtension::WebKitWebGLCompressedTextureS3TCName:
     202        return toJS(exec, globalObject, static_cast<WebGLCompressedTextureS3TC*>(extension));
    198203    }
    199204    ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp

    r102973 r107107  
    5656#include "V8Uint8Array.h"
    5757#include "V8WebGLBuffer.h"
    58 #include "V8WebGLCompressedTextures.h"
     58#include "V8WebGLCompressedTextureS3TC.h"
    5959#include "V8WebGLDebugRendererInfo.h"
    6060#include "V8WebGLDebugShaders.h"
     
    155155    case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
    156156        return toV8(info.getWebGLUnsignedByteArray());
     157    case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
     158        return toV8(info.getWebGLUnsignedIntArray());
    157159    case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
    158160        return toV8(info.getWebGLVertexArrayObjectOES());
     
    194196        referenceName = "webGLDebugShadersName";
    195197        break;
    196     case WebGLExtension::WebKitWebGLCompressedTexturesName:
    197         extensionObject = toV8(static_cast<WebGLCompressedTextures*>(extension));
    198         referenceName = "webKitWebGLCompressedTexturesName";
     198    case WebGLExtension::WebKitWebGLCompressedTextureS3TCName:
     199        extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extension));
     200        referenceName = "webKitWebGLCompressedTextureS3TCName";
    199201        break;
    200202    }
  • trunk/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.h

    r107106 r107107  
    11/*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
     2 * Copyright (C) 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef WebGLExtension_h
    27 #define WebGLExtension_h
     26#ifndef WebGLCompressedTextureS3TC_h
     27#define WebGLCompressedTextureS3TC_h
    2828
    29 #include "WebGLRenderingContext.h"
     29#include "ExceptionCode.h"
     30#include "WebGLExtension.h"
     31#include <wtf/PassOwnPtr.h>
    3032
    3133namespace WebCore {
    3234
    33 class WebGLExtension {
     35class WebGLTexture;
     36
     37class WebGLCompressedTextureS3TC : public WebGLExtension {
    3438public:
    35     // Extension names are needed to properly wrap instances in JavaScript objects.
    36     enum ExtensionName {
    37         WebKitWebGLLoseContextName, // WEBKIT_ prefix until extension is official
    38         OESTextureFloatName,
    39         OESStandardDerivativesName,
    40         OESVertexArrayObjectName,
    41         WebGLDebugRendererInfoName,
    42         WebGLDebugShadersName,
    43         WebKitWebGLCompressedTexturesName, // WEBKIT_ prefix until extension is official
    44     };
     39    static PassOwnPtr<WebGLCompressedTextureS3TC> create(WebGLRenderingContext*);
    4540
    46     void ref() { m_context->ref(); }
    47     void deref() { m_context->deref(); }
    48     WebGLRenderingContext* context() { return m_context; }
     41    static bool supported(WebGLRenderingContext*);
    4942
    50     virtual ~WebGLExtension();
    51     virtual ExtensionName getName() const = 0;
     43    virtual ~WebGLCompressedTextureS3TC();
     44    virtual ExtensionName getName() const;
    5245
    53 protected:
    54     WebGLExtension(WebGLRenderingContext*);
    55     WebGLRenderingContext* m_context;
     46private:
     47    WebGLCompressedTextureS3TC(WebGLRenderingContext*);
    5648};
    5749
    5850} // namespace WebCore
    5951
    60 #endif // WebGLExtension_h
     52#endif // WebGLCompressedTextureS3TC_h
  • trunk/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.idl

    r107106 r107107  
    11/*
    2  * Copyright (C) 2011 Google Inc. All rights reserved.
     2 * Copyright (C) 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030        OmitConstructor,
    3131        DoNotCheckConstants
    32     ] WebGLCompressedTextures {
     32    ] WebGLCompressedTextureS3TC {
    3333        /* Compressed Texture Formats */
    3434        const unsigned int COMPRESSED_RGB_S3TC_DXT1_EXT        = 0x83F0;
    3535        const unsigned int COMPRESSED_RGBA_S3TC_DXT1_EXT       = 0x83F1;
     36        const unsigned int COMPRESSED_RGBA_S3TC_DXT3_EXT       = 0x83F2;
    3637        const unsigned int COMPRESSED_RGBA_S3TC_DXT5_EXT       = 0x83F3;
    37         const unsigned int ETC1_RGB8_OES                       = 0x8D64;
    38         const unsigned int COMPRESSED_RGB_PVRTC_4BPPV1_IMG     = 0x8C00;
    39         const unsigned int COMPRESSED_RGBA_PVRTC_4BPPV1_IMG    = 0x8C02;
    40 
    41         [StrictTypeChecking] void compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat,
    42                                                        in long width, in long height, in long border, in ArrayBufferView data);
    43         [StrictTypeChecking] void compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
    44                                                           in long width, in long height, in unsigned long format, in ArrayBufferView data);
    4538    };
    4639}
  • trunk/Source/WebCore/html/canvas/WebGLExtension.h

    r102973 r107107  
    4141        WebGLDebugRendererInfoName,
    4242        WebGLDebugShadersName,
    43         WebKitWebGLCompressedTexturesName, // WEBKIT_ prefix until extension is official
     43        WebKitWebGLCompressedTextureS3TCName, // WEBKIT_ prefix until extension is official
    4444    };
    4545
  • trunk/Source/WebCore/html/canvas/WebGLGetInfo.cpp

    r105457 r107107  
    3939#include <wtf/Float32Array.h>
    4040#include <wtf/Int32Array.h>
     41#include <wtf/Uint32Array.h>
    4142#include <wtf/Uint8Array.h>
    4243
     
    192193}
    193194
     195WebGLGetInfo::WebGLGetInfo(PassRefPtr<Uint32Array> value)
     196    : m_type(kTypeWebGLUnsignedIntArray)
     197    , m_bool(false)
     198    , m_float(0)
     199    , m_int(0)
     200    , m_unsignedInt(0)
     201    , m_webglUnsignedIntArray(value)
     202{
     203}
     204
    194205WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value)
    195206    : m_type(kTypeWebGLVertexArrayObjectOES)
     
    295306}
    296307
     308PassRefPtr<Uint32Array> WebGLGetInfo::getWebGLUnsignedIntArray() const
     309{
     310    ASSERT(getType() == kTypeWebGLUnsignedIntArray);
     311    return m_webglUnsignedIntArray;
     312}
     313
    297314PassRefPtr<WebGLVertexArrayObjectOES> WebGLGetInfo::getWebGLVertexArrayObjectOES() const
    298315{
  • trunk/Source/WebCore/html/canvas/WebGLGetInfo.h

    r101295 r107107  
    4040#include <wtf/PassRefPtr.h>
    4141#include <wtf/RefPtr.h>
     42#include <wtf/Uint32Array.h>
    4243#include <wtf/Uint8Array.h>
    4344
     
    6869        kTypeWebGLTexture,
    6970        kTypeWebGLUnsignedByteArray,
     71        kTypeWebGLUnsignedIntArray,
    7072        kTypeWebGLVertexArrayObjectOES,
    7173    };
     
    8991    explicit WebGLGetInfo(PassRefPtr<WebGLTexture> value);
    9092    explicit WebGLGetInfo(PassRefPtr<Uint8Array> value);
     93    explicit WebGLGetInfo(PassRefPtr<Uint32Array> value);
    9194    explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value);
    9295
     
    111114    PassRefPtr<WebGLTexture> getWebGLTexture() const;
    112115    PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
     116    PassRefPtr<Uint32Array> getWebGLUnsignedIntArray() const;
    113117    PassRefPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const;
    114118
     
    131135    RefPtr<WebGLTexture> m_webglTexture;
    132136    RefPtr<Uint8Array> m_webglUnsignedByteArray;
     137    RefPtr<Uint32Array> m_webglUnsignedIntArray;
    133138    RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObject;
    134139};
  • trunk/Source/WebCore/html/canvas/WebGLObject.cpp

    r104959 r107107  
    3333#include "OESTextureFloat.h"
    3434#include "OESVertexArrayObject.h"
    35 #include "WebGLCompressedTextures.h"
     35#include "WebGLCompressedTextureS3TC.h"
    3636#include "WebGLContextGroup.h"
    3737#include "WebGLDebugRendererInfo.h"
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r106881 r107107  
    5555#include "WebGLActiveInfo.h"
    5656#include "WebGLBuffer.h"
    57 #include "WebGLCompressedTextures.h"
     57#include "WebGLCompressedTextureS3TC.h"
    5858#include "WebGLContextAttributes.h"
    5959#include "WebGLContextEvent.h"
     
    7373#include <wtf/PassOwnArrayPtr.h>
    7474#include <wtf/Uint16Array.h>
     75#include <wtf/Uint32Array.h>
    7576#include <wtf/text/StringBuilder.h>
    7677
     
    542543}
    543544
     545void WebGLRenderingContext::addCompressedTextureFormat(GC3Denum format)
     546{
     547    if (!m_compressedTextureFormats.contains(format))
     548        m_compressedTextureFormats.append(format);
     549}
     550
    544551WebGLRenderingContext::~WebGLRenderingContext()
    545552{
     
    12131220}
    12141221
    1215 void WebGLRenderingContext::compressedTexImage2D(GC3Denum /*target*/, GC3Dint /*level*/, GC3Denum /*internalformat*/, GC3Dsizei /*width*/,
    1216                                                  GC3Dsizei /*height*/, GC3Dint /*border*/, ArrayBufferView* /*data*/)
    1217 {
    1218     if (isContextLost())
    1219         return;
    1220 
    1221     // FIXME: implement this.
    1222     synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
    1223 }
    1224 
    1225 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum /*target*/, GC3Dint /*level*/, GC3Dint /*xoffset*/, GC3Dint /*yoffset*/,
    1226                                                     GC3Dsizei /*width*/, GC3Dsizei /*height*/, GC3Denum /*format*/, ArrayBufferView* /*data*/)
    1227 {
    1228     if (isContextLost())
    1229         return;
    1230 
    1231     // FIXME: implement this.
    1232     synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format");
     1222void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
     1223                                                 GC3Dsizei height, GC3Dint border, ArrayBufferView* data)
     1224{
     1225    if (isContextLost())
     1226        return;
     1227    if (!validateTexFuncLevel("compressedTexImage2D", target, level))
     1228        return;
     1229
     1230    if (!validateCompressedTexFormat(internalformat)) {
     1231        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D", "invalid internalformat");
     1232        return;
     1233    }
     1234    if (border) {
     1235        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "border not 0");
     1236        return;
     1237    }
     1238    if (!validateCompressedTexDimensions("compressedTexImage2D", level, width, height, internalformat))
     1239        return;
     1240    if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, internalformat, data))
     1241        return;
     1242
     1243    WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, true);
     1244    if (!tex)
     1245        return;
     1246    if (!isGLES2NPOTStrict()) {
     1247        if (level && WebGLTexture::isNPOT(width, height)) {
     1248            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2D", "level > 0 not power of 2");
     1249            return;
     1250        }
     1251    }
     1252    graphicsContext3D()->compressedTexImage2D(target, level, internalformat, width, height,
     1253                                              border, data->byteLength(), data->baseAddress());
     1254    tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
     1255    cleanupAfterGraphicsCall(false);
     1256}
     1257
     1258void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
     1259                                                    GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data)
     1260{
     1261    if (isContextLost())
     1262        return;
     1263    if (!validateTexFuncLevel("compressedTexSubImage2D", target, level))
     1264        return;
     1265    if (!validateCompressedTexFormat(format)) {
     1266        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImage2D", "invalid format");
     1267        return;
     1268    }
     1269    if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data))
     1270        return;
     1271
     1272    WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target, true);
     1273    if (!tex)
     1274        return;
     1275
     1276    if (format != tex->getInternalFormat(target, level)) {
     1277        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSubImage2D", "format does not match texture format");
     1278        return;
     1279    }
     1280
     1281    if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, level, xoffset, yoffset, width, height, format, tex))
     1282        return;
     1283
     1284    graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset,
     1285                                                 width, height, format, data->byteLength(), data->baseAddress());
     1286    cleanupAfterGraphicsCall(false);
    12331287}
    12341288
     
    21912245        return m_webglLoseContext.get();
    21922246    }
    2193     if (equalIgnoringCase(name, "WEBKIT_WEBGL_compressed_textures")) {
     2247    if (equalIgnoringCase(name, "WEBKIT_WEBGL_compressed_texture_s3tc")) {
    21942248        // Use WEBKIT_ prefix until extension is official.
    2195         if (!m_webglCompressedTextures)
    2196             m_webglCompressedTextures = WebGLCompressedTextures::create(this);
    2197         return m_webglCompressedTextures.get();
     2249        if (!m_webglCompressedTextureS3TC)
     2250            m_webglCompressedTextureS3TC = WebGLCompressedTextureS3TC::create(this);
     2251        return m_webglCompressedTextureS3TC.get();
    21982252    }
    21992253
     
    23082362        return getBooleanArrayParameter(pname);
    23092363    case GraphicsContext3D::COMPRESSED_TEXTURE_FORMATS:
    2310         if (m_webglCompressedTextures)
    2311             return m_webglCompressedTextures->getCompressedTextureFormats();
    2312         // Defined as null in the spec
    2313         return WebGLGetInfo();
     2364        return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data(), m_compressedTextureFormats.size()));
    23142365    case GraphicsContext3D::CULL_FACE:
    23152366        return getBooleanParameter(pname);
     
    23662417    case GraphicsContext3D::MAX_VIEWPORT_DIMS:
    23672418        return getWebGLIntArrayParameter(pname);
    2368     case GraphicsContext3D::NUM_COMPRESSED_TEXTURE_FORMATS:
    2369         // WebGL 1.0 specifies that there are no compressed texture formats.
    2370         return WebGLGetInfo(static_cast<int>(0));
    23712419    case GraphicsContext3D::NUM_SHADER_BINARY_FORMATS:
    23722420        // FIXME: should we always return 0 for this?
     
    26412689        result.append("OES_vertex_array_object");
    26422690    result.append("WEBKIT_WEBGL_lose_context");
    2643     if (WebGLCompressedTextures::supported(this))
    2644         result.append("WEBKIT_WEBGL_compressed_textures");
     2691    if (WebGLCompressedTextureS3TC::supported(this))
     2692        result.append("WEBKIT_WEBGL_compressed_texture_s3tc");
    26452693
    26462694    if (allowPrivilegedExtensions()) {
     
    46864734}
    46874735
     4736bool WebGLRenderingContext::validateCompressedTexFormat(GC3Denum format)
     4737{
     4738    return m_compressedTextureFormats.contains(format);
     4739}
     4740
     4741bool WebGLRenderingContext::validateCompressedTexFuncData(const char* functionName,
     4742                                                          GC3Dsizei width, GC3Dsizei height,
     4743                                                          GC3Denum format, ArrayBufferView* pixels)
     4744{
     4745    if (!pixels) {
     4746        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pixels");
     4747        return false;
     4748    }
     4749    if (width < 0 || height < 0) {
     4750        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0");
     4751        return false;
     4752    }
     4753
     4754    unsigned int bytesRequired = 0;
     4755
     4756    switch (format) {
     4757    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
     4758    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
     4759        {
     4760            const int kBlockWidth = 4;
     4761            const int kBlockHeight = 4;
     4762            const int kBlockSize = 8;
     4763            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
     4764            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
     4765            int numBlocks = numBlocksAcross * numBlocksDown;
     4766            bytesRequired = numBlocks * kBlockSize;
     4767        }
     4768        break;
     4769    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
     4770    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
     4771        {
     4772            const int kBlockWidth = 4;
     4773            const int kBlockHeight = 4;
     4774            const int kBlockSize = 16;
     4775            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
     4776            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
     4777            int numBlocks = numBlocksAcross * numBlocksDown;
     4778            bytesRequired = numBlocks * kBlockSize;
     4779        }
     4780        break;
     4781    default:
     4782        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format");
     4783        return false;
     4784    }
     4785
     4786    if (pixels->byteLength() != bytesRequired) {
     4787        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "length of ArrayBufferView is not correct for dimensions");
     4788        return false;
     4789    }
     4790
     4791    return true;
     4792}
     4793
     4794bool WebGLRenderingContext::validateCompressedTexDimensions(const char* functionName, GC3Dint level, GC3Dsizei width, GC3Dsizei height, GC3Denum format)
     4795{
     4796    switch (format) {
     4797    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
     4798    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
     4799    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
     4800    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: {
     4801        const int kBlockWidth = 4;
     4802        const int kBlockHeight = 4;
     4803        bool widthValid = (level && width == 1) || (level && width == 2) || !(width % kBlockWidth);
     4804        bool heightValid = (level && height == 1) || (level && height == 2) || !(height % kBlockHeight);
     4805        if (!widthValid || !heightValid) {
     4806          synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "width or height invalid for level");
     4807          return false;
     4808        }
     4809        return true;
     4810    }
     4811    default:
     4812        return false;
     4813    }
     4814}
     4815
     4816bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* functionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
     4817                                                               GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex)
     4818{
     4819    if (xoffset < 0 || yoffset < 0) {
     4820      synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "xoffset or yoffset < 0");
     4821      return false;
     4822    }
     4823
     4824    switch (format) {
     4825    case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
     4826    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
     4827    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
     4828    case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: {
     4829        const int kBlockWidth = 4;
     4830        const int kBlockHeight = 4;
     4831        if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
     4832            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "xoffset or yoffset not multiple of 4");
     4833            return false;
     4834        }
     4835        if (width - xoffset > tex->getWidth(target, level)
     4836            || height - yoffset > tex->getHeight(target, level)) {
     4837            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "dimensions out of range");
     4838            return false;
     4839        }
     4840        return validateCompressedTexDimensions(functionName, level, width, height, format);
     4841    }
     4842    default:
     4843        return false;
     4844    }
     4845}
     4846
    46884847bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode)
    46894848{
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r106873 r107107  
    5353class WebGLContextGroup;
    5454class WebGLContextObject;
    55 class WebGLCompressedTextures;
     55class WebGLCompressedTextureS3TC;
    5656class WebGLContextAttributes;
    5757class WebGLDebugRendererInfo;
     
    322322    friend class OESVertexArrayObject;
    323323    friend class WebGLDebugShaders;
    324     friend class WebGLCompressedTextures;
     324    friend class WebGLCompressedTextureS3TC;
    325325    friend class WebGLRenderingContextErrorMessageCallback;
    326326
     
    367367
    368368    bool validateWebGLObject(const char*, WebGLObject*);
     369
     370    // Adds a compressed texture format.
     371    void addCompressedTextureFormat(GC3Denum);
    369372
    370373#if ENABLE(VIDEO)
     
    444447    RefPtr<WebGLTexture> m_blackTextureCubeMap;
    445448
     449    Vector<GC3Denum> m_compressedTextureFormats;
     450
    446451    // Fixed-size cache of reusable image buffers for video texImage2D calls.
    447452    class LRUImageBufferCache {
     
    501506    OwnPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
    502507    OwnPtr<WebGLDebugShaders> m_webglDebugShaders;
    503     OwnPtr<WebGLCompressedTextures> m_webglCompressedTextures;
     508    OwnPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
    504509
    505510    // Helpers for getParameter and others
     
    589594                             ArrayBufferView* pixels);
    590595
     596    // Helper function to validate compressed texture data is correct size
     597    // for the given format and dimensions.
     598    bool validateCompressedTexFuncData(const char* functionName,
     599                                       GC3Dsizei width, GC3Dsizei height,
     600                                       GC3Denum format, ArrayBufferView* pixels);
     601
     602    // Helper function for validating compressed texture formats.
     603    bool validateCompressedTexFormat(GC3Denum format);
     604
     605    // Helper function to validate compressed texture dimensions are valid for
     606    // the given format.
     607    bool validateCompressedTexDimensions(const char* functionName, GC3Dint level, GC3Dsizei width, GC3Dsizei height, GC3Denum format);
     608
     609    // Helper function to validate compressed texture dimensions are valid for
     610    // the given format.
     611    bool validateCompressedTexSubDimensions(const char* functionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
     612                                            GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture*);
     613
    591614    // Helper function to validate mode for draw{Arrays/Elements}.
    592615    bool validateDrawMode(const char* functionName, GC3Denum);
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.idl

    r106892 r107107  
    207207        /*      TEXTURE_WRAP_T */
    208208
    209         const unsigned int NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
    210209        const unsigned int COMPRESSED_TEXTURE_FORMATS     = 0x86A3;
    211210
Note: See TracChangeset for help on using the changeset viewer.