2011-02-18 Ben Vanik <benvanik@google.com>
authorkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Feb 2011 18:42:59 +0000 (18:42 +0000)
committerkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Feb 2011 18:42:59 +0000 (18:42 +0000)
        Reviewed by Kenneth Russell.

        Bug 53940: Implement the OES_vertex_array_object WebGL extension
        https://bugs.webkit.org/show_bug.cgi?id=53940

        Stubbed out methods for the new OES_vertex_array_object methods.

        * src/Extensions3DChromium.cpp:
        (WebCore::Extensions3DChromium::createVertexArrayOES):
        (WebCore::Extensions3DChromium::deleteVertexArrayOES):
        (WebCore::Extensions3DChromium::isVertexArrayOES):
        (WebCore::Extensions3DChromium::bindVertexArrayOES):
2011-02-18  Ben Vanik  <benvanik@google.com>

        Reviewed by Kenneth Russell.

        Bug 53940: Implement the OES_vertex_array_object WebGL extension
        https://bugs.webkit.org/show_bug.cgi?id=53940

        Initial implementation of the OES_vertex_array_object extension adding the OESVertexArrayObject
        extension container and WebGLVertexArrayObjectOES VAO object. The extension is plumbed through
        the Extensions3D interface and implemented in the Extensions3DOpenGL (WebKit/OSX) version when
        it is available.
        Two big changes touching code outside of the extension files:
        * Moved the typedefs at the top of GraphicsContext3D.h to GraphicsTypes3D.h (modeled after
          GraphicsTypes.h). They are not namespaced as they weren't before.
        * To make the code cleaner/clearer all vertex attribute state has been moved to the
          WebGLVertexArrayObjectOES type (struct VertexAttribState) except for values which are still
          on the WebGLRenderingContext. A default VAO is now used to store the existing attribute
          states for when no other VAO is used. Code in WebGLRenderingContext dealing with buffers and
          vertex attributes now defers to or stores values in the bound array object.

        Tested against the WebGL conformance suite and the new
        oes-vertex-array-object test:
        https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/oes-vertex-array-object.html

        * CMakeLists.txt:
        * CodeGenerators.pri:
        * DerivedSources.make:
        * GNUmakefile.am:
        * WebCore.gyp: Modified property svn:ignore.
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSWebGLRenderingContextCustom.cpp:
        (WebCore::toJS):
        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
        (WebCore::toV8Object):
        * html/canvas/OESVertexArrayObject.cpp: Added.
        (WebCore::OESVertexArrayObject::OESVertexArrayObject):
        (WebCore::OESVertexArrayObject::~OESVertexArrayObject):
        (WebCore::OESVertexArrayObject::getName):
        (WebCore::OESVertexArrayObject::create):
        (WebCore::OESVertexArrayObject::createVertexArrayOES):
        (WebCore::OESVertexArrayObject::deleteVertexArrayOES):
        (WebCore::OESVertexArrayObject::isVertexArrayOES):
        (WebCore::OESVertexArrayObject::bindVertexArrayOES):
        * html/canvas/OESVertexArrayObject.h: Added.
        * html/canvas/OESVertexArrayObject.idl: Added.
        * html/canvas/WebGLExtension.h:
        * html/canvas/WebGLGetInfo.cpp:
        (WebCore::WebGLGetInfo::WebGLGetInfo):
        (WebCore::WebGLGetInfo::getWebGLVertexArrayObjectOES):
        * html/canvas/WebGLGetInfo.h:
        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::initializeNewContext):
        (WebCore::WebGLRenderingContext::bindBuffer):
        (WebCore::WebGLRenderingContext::deleteBuffer):
        (WebCore::WebGLRenderingContext::disableVertexAttribArray):
        (WebCore::WebGLRenderingContext::validateElementArraySize):
        (WebCore::WebGLRenderingContext::validateIndexArrayConservative):
        (WebCore::WebGLRenderingContext::validateIndexArrayPrecise):
        (WebCore::WebGLRenderingContext::validateRenderingState):
        (WebCore::WebGLRenderingContext::drawElements):
        (WebCore::WebGLRenderingContext::enableVertexAttribArray):
        (WebCore::WebGLRenderingContext::getExtension):
        (WebCore::WebGLRenderingContext::getParameter):
        (WebCore::WebGLRenderingContext::getSupportedExtensions):
        (WebCore::WebGLRenderingContext::getVertexAttrib):
        (WebCore::WebGLRenderingContext::vertexAttribPointer):
        (WebCore::WebGLRenderingContext::validateBufferDataParameters):
        (WebCore::WebGLRenderingContext::vertexAttribfImpl):
        (WebCore::WebGLRenderingContext::vertexAttribfvImpl):
        (WebCore::WebGLRenderingContext::initVertexAttrib0):
        (WebCore::WebGLRenderingContext::simulateVertexAttrib0):
        (WebCore::WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation):
        (WebCore::WebGLRenderingContext::getNumberOfExtensions):
        (WebCore::WebGLRenderingContext::getExtensionNumber):
        * html/canvas/WebGLRenderingContext.h:
        (WebCore::WebGLRenderingContext::getMaxVertexAttribs):
        (WebCore::WebGLRenderingContext::setBoundVertexArrayObject):
        (WebCore::WebGLRenderingContext::VertexAttribValue::VertexAttribValue):
        * html/canvas/WebGLVertexArrayObjectOES.cpp: Added.
        (WebCore::WebGLVertexArrayObjectOES::create):
        (WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES):
        (WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
        * html/canvas/WebGLVertexArrayObjectOES.h: Added.
        (WebCore::WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES):
        (WebCore::WebGLVertexArrayObjectOES::VertexAttribState::VertexAttribState):
        (WebCore::WebGLVertexArrayObjectOES::isDefaultObject):
        (WebCore::WebGLVertexArrayObjectOES::hasEverBeenBound):
        (WebCore::WebGLVertexArrayObjectOES::setHasEverBeenBound):
        (WebCore::WebGLVertexArrayObjectOES::getElementArrayBuffer):
        (WebCore::WebGLVertexArrayObjectOES::setElementArrayBuffer):
        (WebCore::WebGLVertexArrayObjectOES::getVertexAttribState):
        (WebCore::WebGLVertexArrayObjectOES::isVertexArray):
        * html/canvas/WebGLVertexArrayObjectOES.idl: Added.
        * platform/graphics/Extensions3D.h:
        * platform/graphics/GraphicsContext3D.h:
        * platform/graphics/GraphicsTypes3D.h: Added.
        * platform/graphics/chromium/Extensions3DChromium.h:
        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
        (WebCore::Extensions3DOpenGL::supports):
        (WebCore::Extensions3DOpenGL::createVertexArrayOES):
        (WebCore::Extensions3DOpenGL::deleteVertexArrayOES):
        (WebCore::Extensions3DOpenGL::isVertexArrayOES):
        (WebCore::Extensions3DOpenGL::bindVertexArrayOES):
        * platform/graphics/opengl/Extensions3DOpenGL.h:
        * platform/graphics/qt/Extensions3DQt.cpp:
        (WebCore::Extensions3DQt::createVertexArrayOES):
        (WebCore::Extensions3DQt::deleteVertexArrayOES):
        (WebCore::Extensions3DQt::isVertexArrayOES):
        (WebCore::Extensions3DQt::bindVertexArrayOES):
        * platform/graphics/qt/Extensions3DQt.h:

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

31 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/CodeGenerators.pri
Source/WebCore/DerivedSources.make
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
Source/WebCore/html/canvas/OESVertexArrayObject.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/OESVertexArrayObject.h [new file with mode: 0644]
Source/WebCore/html/canvas/OESVertexArrayObject.idl [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLExtension.h
Source/WebCore/html/canvas/WebGLGetInfo.cpp
Source/WebCore/html/canvas/WebGLGetInfo.h
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.h
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.idl [new file with mode: 0644]
Source/WebCore/platform/graphics/Extensions3D.h
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/GraphicsTypes3D.h [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp
Source/WebCore/platform/graphics/qt/Extensions3DQt.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/Extensions3DChromium.cpp

index 5a36a08..5f0121d 100644 (file)
@@ -294,6 +294,7 @@ SET(WebCore_IDL_FILES
     html/canvas/Int8Array.idl
     html/canvas/OESStandardDerivatives.idl
     html/canvas/OESTextureFloat.idl
+    html/canvas/OESVertexArrayObject.idl
     html/canvas/Uint16Array.idl
     html/canvas/Uint32Array.idl
     html/canvas/Uint8Array.idl
@@ -307,6 +308,7 @@ SET(WebCore_IDL_FILES
     html/canvas/WebGLShader.idl
     html/canvas/WebGLTexture.idl
     html/canvas/WebGLUniformLocation.idl
+    html/canvas/WebGLVertexArrayObjectOES.idl
     html/canvas/WebKitLoseContext.idl
 
     inspector/InjectedScriptHost.idl
index 2cd4f29..065f730 100644 (file)
@@ -1,3 +1,116 @@
+2011-02-18  Ben Vanik  <benvanik@google.com>
+
+        Reviewed by Kenneth Russell.
+
+        Bug 53940: Implement the OES_vertex_array_object WebGL extension
+        https://bugs.webkit.org/show_bug.cgi?id=53940
+
+        Initial implementation of the OES_vertex_array_object extension adding the OESVertexArrayObject
+        extension container and WebGLVertexArrayObjectOES VAO object. The extension is plumbed through
+        the Extensions3D interface and implemented in the Extensions3DOpenGL (WebKit/OSX) version when
+        it is available.
+        Two big changes touching code outside of the extension files:
+        * Moved the typedefs at the top of GraphicsContext3D.h to GraphicsTypes3D.h (modeled after
+          GraphicsTypes.h). They are not namespaced as they weren't before.
+        * To make the code cleaner/clearer all vertex attribute state has been moved to the
+          WebGLVertexArrayObjectOES type (struct VertexAttribState) except for values which are still
+          on the WebGLRenderingContext. A default VAO is now used to store the existing attribute
+          states for when no other VAO is used. Code in WebGLRenderingContext dealing with buffers and
+          vertex attributes now defers to or stores values in the bound array object.
+
+        Tested against the WebGL conformance suite and the new
+        oes-vertex-array-object test:
+        https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/oes-vertex-array-object.html
+
+        * CMakeLists.txt:
+        * CodeGenerators.pri:
+        * DerivedSources.make:
+        * GNUmakefile.am:
+        * WebCore.gyp: Modified property svn:ignore.
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSWebGLRenderingContextCustom.cpp:
+        (WebCore::toJS):
+        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+        (WebCore::toV8Object):
+        * html/canvas/OESVertexArrayObject.cpp: Added.
+        (WebCore::OESVertexArrayObject::OESVertexArrayObject):
+        (WebCore::OESVertexArrayObject::~OESVertexArrayObject):
+        (WebCore::OESVertexArrayObject::getName):
+        (WebCore::OESVertexArrayObject::create):
+        (WebCore::OESVertexArrayObject::createVertexArrayOES):
+        (WebCore::OESVertexArrayObject::deleteVertexArrayOES):
+        (WebCore::OESVertexArrayObject::isVertexArrayOES):
+        (WebCore::OESVertexArrayObject::bindVertexArrayOES):
+        * html/canvas/OESVertexArrayObject.h: Added.
+        * html/canvas/OESVertexArrayObject.idl: Added.
+        * html/canvas/WebGLExtension.h:
+        * html/canvas/WebGLGetInfo.cpp:
+        (WebCore::WebGLGetInfo::WebGLGetInfo):
+        (WebCore::WebGLGetInfo::getWebGLVertexArrayObjectOES):
+        * html/canvas/WebGLGetInfo.h:
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::initializeNewContext):
+        (WebCore::WebGLRenderingContext::bindBuffer):
+        (WebCore::WebGLRenderingContext::deleteBuffer):
+        (WebCore::WebGLRenderingContext::disableVertexAttribArray):
+        (WebCore::WebGLRenderingContext::validateElementArraySize):
+        (WebCore::WebGLRenderingContext::validateIndexArrayConservative):
+        (WebCore::WebGLRenderingContext::validateIndexArrayPrecise):
+        (WebCore::WebGLRenderingContext::validateRenderingState):
+        (WebCore::WebGLRenderingContext::drawElements):
+        (WebCore::WebGLRenderingContext::enableVertexAttribArray):
+        (WebCore::WebGLRenderingContext::getExtension):
+        (WebCore::WebGLRenderingContext::getParameter):
+        (WebCore::WebGLRenderingContext::getSupportedExtensions):
+        (WebCore::WebGLRenderingContext::getVertexAttrib):
+        (WebCore::WebGLRenderingContext::vertexAttribPointer):
+        (WebCore::WebGLRenderingContext::validateBufferDataParameters):
+        (WebCore::WebGLRenderingContext::vertexAttribfImpl):
+        (WebCore::WebGLRenderingContext::vertexAttribfvImpl):
+        (WebCore::WebGLRenderingContext::initVertexAttrib0):
+        (WebCore::WebGLRenderingContext::simulateVertexAttrib0):
+        (WebCore::WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation):
+        (WebCore::WebGLRenderingContext::getNumberOfExtensions):
+        (WebCore::WebGLRenderingContext::getExtensionNumber):
+        * html/canvas/WebGLRenderingContext.h:
+        (WebCore::WebGLRenderingContext::getMaxVertexAttribs):
+        (WebCore::WebGLRenderingContext::setBoundVertexArrayObject):
+        (WebCore::WebGLRenderingContext::VertexAttribValue::VertexAttribValue):
+        * html/canvas/WebGLVertexArrayObjectOES.cpp: Added.
+        (WebCore::WebGLVertexArrayObjectOES::create):
+        (WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES):
+        (WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
+        * html/canvas/WebGLVertexArrayObjectOES.h: Added.
+        (WebCore::WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES):
+        (WebCore::WebGLVertexArrayObjectOES::VertexAttribState::VertexAttribState):
+        (WebCore::WebGLVertexArrayObjectOES::isDefaultObject):
+        (WebCore::WebGLVertexArrayObjectOES::hasEverBeenBound):
+        (WebCore::WebGLVertexArrayObjectOES::setHasEverBeenBound):
+        (WebCore::WebGLVertexArrayObjectOES::getElementArrayBuffer):
+        (WebCore::WebGLVertexArrayObjectOES::setElementArrayBuffer):
+        (WebCore::WebGLVertexArrayObjectOES::getVertexAttribState):
+        (WebCore::WebGLVertexArrayObjectOES::isVertexArray):
+        * html/canvas/WebGLVertexArrayObjectOES.idl: Added.
+        * platform/graphics/Extensions3D.h:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/GraphicsTypes3D.h: Added.
+        * platform/graphics/chromium/Extensions3DChromium.h:
+        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
+        (WebCore::Extensions3DOpenGL::supports):
+        (WebCore::Extensions3DOpenGL::createVertexArrayOES):
+        (WebCore::Extensions3DOpenGL::deleteVertexArrayOES):
+        (WebCore::Extensions3DOpenGL::isVertexArrayOES):
+        (WebCore::Extensions3DOpenGL::bindVertexArrayOES):
+        * platform/graphics/opengl/Extensions3DOpenGL.h:
+        * platform/graphics/qt/Extensions3DQt.cpp:
+        (WebCore::Extensions3DQt::createVertexArrayOES):
+        (WebCore::Extensions3DQt::deleteVertexArrayOES):
+        (WebCore::Extensions3DQt::isVertexArrayOES):
+        (WebCore::Extensions3DQt::bindVertexArrayOES):
+        * platform/graphics/qt/Extensions3DQt.h:
+
 2011-02-17  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Pavel Feldman.
index f30693f..d20f661 100644 (file)
@@ -198,6 +198,7 @@ IDL_BINDINGS += \
     html/canvas/CanvasRenderingContext2D.idl \
     html/canvas/OESStandardDerivatives.idl \
     html/canvas/OESTextureFloat.idl \
+    html/canvas/OESVertexArrayObject.idl \
     html/canvas/WebGLActiveInfo.idl \
     html/canvas/WebGLBuffer.idl \
     html/canvas/WebGLContextAttributes.idl \
@@ -209,6 +210,7 @@ IDL_BINDINGS += \
     html/canvas/Int16Array.idl \
     html/canvas/WebGLTexture.idl \
     html/canvas/WebGLUniformLocation.idl \
+    html/canvas/WebGLVertexArrayObjectOES.idl \
     html/canvas/WebKitLoseContext.idl \
     html/canvas/Uint8Array.idl \
     html/canvas/Uint32Array.idl \
index fe55b28..815d241 100644 (file)
@@ -312,6 +312,8 @@ DOM_CLASSES = \
     NotificationCenter \
     OESStandardDerivatives \
     OESTextureFloat \
+     OESVertexArrayObject \
+     WebGLVertexArrayObjectOES \
     OverflowEvent \
     PageTransitionEvent \
     Performance \
index 3d2e772..25e7f85 100644 (file)
@@ -486,6 +486,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSOESStandardDerivatives.h \
        DerivedSources/WebCore/JSOESTextureFloat.cpp \
        DerivedSources/WebCore/JSOESTextureFloat.h \
+       DerivedSources/WebCore/JSOESVertexArrayObject.cpp \
+       DerivedSources/WebCore/JSOESVertexArrayObject.h \
        DerivedSources/WebCore/JSOverflowEvent.cpp \
        DerivedSources/WebCore/JSOverflowEvent.h \
        DerivedSources/WebCore/JSPageTransitionEvent.cpp \
@@ -592,6 +594,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSWebGLTexture.h \
        DerivedSources/WebCore/JSWebGLUniformLocation.cpp \
        DerivedSources/WebCore/JSWebGLUniformLocation.h \
+       DerivedSources/WebCore/JSWebGLVertexArrayObjectOES.cpp \
+       DerivedSources/WebCore/JSWebGLVertexArrayObjectOES.h \
        DerivedSources/WebCore/JSWebKitAnimationEvent.cpp \
        DerivedSources/WebCore/JSWebKitAnimationEvent.h \
        DerivedSources/WebCore/JSWebKitCSSKeyframeRule.cpp \
@@ -1587,13 +1591,7 @@ webcore_sources += \
        Source/WebCore/html/canvas/Int8Array.cpp \
        Source/WebCore/html/canvas/Int8Array.h \
        Source/WebCore/html/canvas/IntegralTypedArrayBase.h \
-       Source/WebCore/html/canvas/OESStandardDerivatives.cpp \
-       Source/WebCore/html/canvas/OESStandardDerivatives.h \
-       Source/WebCore/html/canvas/OESTextureFloat.cpp \
-       Source/WebCore/html/canvas/OESTextureFloat.h \
        Source/WebCore/html/canvas/TypedArrayBase.h \
-       Source/WebCore/html/canvas/WebKitLoseContext.cpp \
-       Source/WebCore/html/canvas/WebKitLoseContext.h \
        Source/WebCore/html/canvas/Uint16Array.cpp \
        Source/WebCore/html/canvas/Uint16Array.h \
        Source/WebCore/html/canvas/Uint32Array.cpp \
@@ -2439,6 +2437,7 @@ webcore_sources += \
        Source/WebCore/platform/graphics/GraphicsLayer.h \
        Source/WebCore/platform/graphics/GraphicsTypes.cpp \
        Source/WebCore/platform/graphics/GraphicsTypes.h \
+       Source/WebCore/platform/graphics/GraphicsTypes3D.h \
        Source/WebCore/platform/graphics/Icon.h \
        Source/WebCore/platform/graphics/ImageBuffer.cpp \
        Source/WebCore/platform/graphics/ImageBuffer.h \
@@ -4823,7 +4822,19 @@ webcore_sources += \
        Source/WebCore/html/canvas/WebGLTexture.cpp \
        Source/WebCore/html/canvas/WebGLTexture.h \
        Source/WebCore/html/canvas/WebGLUniformLocation.cpp \
-       Source/WebCore/html/canvas/WebGLUniformLocation.h
+       Source/WebCore/html/canvas/WebGLUniformLocation.h \
+       Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp \
+       Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h \
+       Source/WebCore/html/canvas/OESStandardDerivatives.cpp \
+       Source/WebCore/html/canvas/OESStandardDerivatives.h \
+       Source/WebCore/html/canvas/OESTextureFloat.cpp \
+       Source/WebCore/html/canvas/OESTextureFloat.h \
+       Source/WebCore/html/canvas/OESVertexArrayObject.cpp \
+       Source/WebCore/html/canvas/OESVertexArrayObject.h \
+       Source/WebCore/html/canvas/OESVertexArray.cpp \
+       Source/WebCore/html/canvas/OESVertexArray.h \
+       Source/WebCore/html/canvas/WebKitLoseContext.cpp \
+       Source/WebCore/html/canvas/WebKitLoseContext.h
 endif  # END ENABLE_WEBGL
 
 DerivedSources/WebCore/CSSPropertyNames.cpp: DerivedSources/WebCore/CSSPropertyNames.h
index c0a7bd4..b5bb4ab 100644 (file)
             'html/canvas/Int8Array.idl',
             'html/canvas/OESStandardDerivatives.idl',
             'html/canvas/OESTextureFloat.idl',
+            'html/canvas/OESVertexArrayObject.idl',
             'html/canvas/Uint16Array.idl',
             'html/canvas/Uint32Array.idl',
             'html/canvas/Uint8Array.idl',
             'html/canvas/WebGLShader.idl',
             'html/canvas/WebGLTexture.idl',
             'html/canvas/WebGLUniformLocation.idl',
+            'html/canvas/WebGLVertexArrayObjectOES.idl',
             'html/canvas/WebKitLoseContext.idl',
             'inspector/InjectedScriptHost.idl',
             'inspector/InspectorFrontendHost.idl',
             'html/canvas/OESStandardDerivatives.h',
             'html/canvas/OESTextureFloat.cpp',
             'html/canvas/OESTextureFloat.h',
+            'html/canvas/OESVertexArrayObject.cpp',
+            'html/canvas/OESVertexArrayObject.h',
             'html/canvas/TypedArrayBase.h',
             'html/canvas/Uint16Array.cpp',
             'html/canvas/Uint16Array.h',
             'html/canvas/WebGLTexture.h',
             'html/canvas/WebGLUniformLocation.cpp',
             'html/canvas/WebGLUniformLocation.h',
+            'html/canvas/WebGLVertexArrayObjectOES.cpp',
+            'html/canvas/WebGLVertexArrayObjectOES.h',
             'html/canvas/WebKitLoseContext.cpp',
             'html/canvas/WebKitLoseContext.h',
             'html/parser/CSSPreloadScanner.cpp',
             'platform/graphics/GraphicsLayerClient.h',
             'platform/graphics/GraphicsTypes.cpp',
             'platform/graphics/GraphicsTypes.h',
+            'platform/graphics/GraphicsTypes3D.h',
             'platform/graphics/Icon.h',
             'platform/graphics/Image.cpp',
             'platform/graphics/Image.h',
index 3b8d4aa..bd0ed8f 100644 (file)
@@ -2033,6 +2033,7 @@ HEADERS += \
     platform/graphics/GraphicsLayer.h \
     platform/graphics/GraphicsLayerClient.h \
     platform/graphics/GraphicsTypes.h \
+    platform/graphics/GraphicsTypes3D.h \
     platform/graphics/Image.h \
     platform/graphics/ImageSource.h \
     platform/graphics/IntPoint.h \
@@ -3690,6 +3691,8 @@ contains(DEFINES, ENABLE_WEBGL=1) {
         html/canvas/WebGLShader.h \
         html/canvas/OESStandardDerivatives.h \
         html/canvas/OESTextureFloat.h \
+        html/canvas/OESVertexArrayObject.h \
+        html/canvas/OESVertexArray.h \
         html/canvas/WebGLTexture.h \
         html/canvas/WebGLUniformLocation.h \
         html/canvas/WebKitLoseContext.h \
@@ -3717,6 +3720,8 @@ contains(DEFINES, ENABLE_WEBGL=1) {
         html/canvas/WebGLShader.cpp \
         html/canvas/OESStandardDerivatives.cpp \
         html/canvas/OESTextureFloat.cpp \
+        html/canvas/OESVertexArrayObject.cpp \
+        html/canvas/OESVertexArray.cpp \
         html/canvas/WebGLTexture.cpp \
         html/canvas/WebGLUniformLocation.cpp \
         html/canvas/WebKitLoseContext.cpp \
index 0cc5bf9..bcc5d90 100644 (file)
                76FC2B0B12370DA0006A991A /* DOMTokenList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76FC2B0812370DA0006A991A /* DOMTokenList.cpp */; };
                76FC2B0C12370DA0006A991A /* DOMTokenList.h in Headers */ = {isa = PBXBuildFile; fileRef = 76FC2B0912370DA0006A991A /* DOMTokenList.h */; };
                76FF17E311235673001D61B5 /* PluginViewNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76FF17E211235673001D61B5 /* PluginViewNone.cpp */; };
+               77A17A7112F28182004E02F6 /* OESVertexArrayObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 77A17A6E12F28182004E02F6 /* OESVertexArrayObject.cpp */; };
+               77A17A7212F28182004E02F6 /* OESVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 77A17A6F12F28182004E02F6 /* OESVertexArrayObject.h */; };
+               77A17A7712F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */; };
+               77A17A7812F28642004E02F6 /* WebGLVertexArrayObjectOES.h in Headers */ = {isa = PBXBuildFile; fileRef = 77A17A7512F28642004E02F6 /* WebGLVertexArrayObjectOES.h */; };
+               77A17A7B12F2890B004E02F6 /* GraphicsTypes3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 77A17A7A12F2890B004E02F6 /* GraphicsTypes3D.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               77A17AA612F28B2A004E02F6 /* JSOESVertexArrayObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 77A17AA212F28B2A004E02F6 /* JSOESVertexArrayObject.cpp */; };
+               77A17AA712F28B2A004E02F6 /* JSOESVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 77A17AA312F28B2A004E02F6 /* JSOESVertexArrayObject.h */; };
+               77EF62F312F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 77EF62F112F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.cpp */; };
+               77EF62F412F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.h in Headers */ = {isa = PBXBuildFile; fileRef = 77EF62F212F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.h */; };
                79AC9218109945C80021266E /* JSCompositionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79AC9216109945C80021266E /* JSCompositionEvent.cpp */; };
                79AC9219109945C80021266E /* JSCompositionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 79AC9217109945C80021266E /* JSCompositionEvent.h */; };
                79F2F5A11091939A000D87CB /* CompositionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79F2F59E1091939A000D87CB /* CompositionEvent.cpp */; };
                76FC2B0912370DA0006A991A /* DOMTokenList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMTokenList.h; sourceTree = "<group>"; };
                76FC2B0A12370DA0006A991A /* DOMTokenList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMTokenList.idl; sourceTree = "<group>"; };
                76FF17E211235673001D61B5 /* PluginViewNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginViewNone.cpp; sourceTree = "<group>"; };
+               77A17A6E12F28182004E02F6 /* OESVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OESVertexArrayObject.cpp; path = canvas/OESVertexArrayObject.cpp; sourceTree = "<group>"; };
+               77A17A6F12F28182004E02F6 /* OESVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESVertexArrayObject.h; path = canvas/OESVertexArrayObject.h; sourceTree = "<group>"; };
+               77A17A7012F28182004E02F6 /* OESVertexArrayObject.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OESVertexArrayObject.idl; path = canvas/OESVertexArrayObject.idl; sourceTree = "<group>"; };
+               77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLVertexArrayObjectOES.cpp; path = canvas/WebGLVertexArrayObjectOES.cpp; sourceTree = "<group>"; };
+               77A17A7512F28642004E02F6 /* WebGLVertexArrayObjectOES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLVertexArrayObjectOES.h; path = canvas/WebGLVertexArrayObjectOES.h; sourceTree = "<group>"; };
+               77A17A7612F28642004E02F6 /* WebGLVertexArrayObjectOES.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLVertexArrayObjectOES.idl; path = canvas/WebGLVertexArrayObjectOES.idl; sourceTree = "<group>"; };
+               77A17A7A12F2890B004E02F6 /* GraphicsTypes3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsTypes3D.h; sourceTree = "<group>"; };
+               77A17AA212F28B2A004E02F6 /* JSOESVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESVertexArrayObject.cpp; sourceTree = "<group>"; };
+               77A17AA312F28B2A004E02F6 /* JSOESVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESVertexArrayObject.h; sourceTree = "<group>"; };
+               77EF62F112F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLVertexArrayObjectOES.cpp; sourceTree = "<group>"; };
+               77EF62F212F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObjectOES.h; sourceTree = "<group>"; };
                79AC9216109945C80021266E /* JSCompositionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCompositionEvent.cpp; sourceTree = "<group>"; };
                79AC9217109945C80021266E /* JSCompositionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCompositionEvent.h; sourceTree = "<group>"; };
                79F2F59E1091939A000D87CB /* CompositionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompositionEvent.cpp; sourceTree = "<group>"; };
                                6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */,
                                6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */,
                                6EBF0E4712A8926100DB1709 /* OESTextureFloat.idl */,
+                               77A17A6E12F28182004E02F6 /* OESVertexArrayObject.cpp */,
+                               77A17A6F12F28182004E02F6 /* OESVertexArrayObject.h */,
+                               77A17A7012F28182004E02F6 /* OESVertexArrayObject.idl */,
                                6E96BB1B11986EE1007D94CD /* TypedArrayBase.h */,
                                49EECDDC10503C2300099FAB /* Uint16Array.cpp */,
                                49EECDDD10503C2400099FAB /* Uint16Array.h */,
                                0C3F1F5710C8871200D72CE1 /* WebGLUniformLocation.cpp */,
                                0C3F1F5810C8871200D72CE1 /* WebGLUniformLocation.h */,
                                0C3F1F5910C8871200D72CE1 /* WebGLUniformLocation.idl */,
+                               77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */,
+                               77A17A7512F28642004E02F6 /* WebGLVertexArrayObjectOES.h */,
+                               77A17A7612F28642004E02F6 /* WebGLVertexArrayObjectOES.idl */,
                                93F1D5B712D532C400832BEC /* WebKitLoseContext.cpp */,
                                93F1D5B812D532C400832BEC /* WebKitLoseContext.h */,
                                93F1D5B912D532C400832BEC /* WebKitLoseContext.idl */,
                                9001787F12E0370700648462 /* JSOESStandardDerivatives.h */,
                                6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */,
                                6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */,
+                               77A17AA212F28B2A004E02F6 /* JSOESVertexArrayObject.cpp */,
+                               77A17AA312F28B2A004E02F6 /* JSOESVertexArrayObject.h */,
                                BCEF45F30E687B5C001C1287 /* JSTextMetrics.cpp */,
                                BCEF45F40E687B5C001C1287 /* JSTextMetrics.h */,
                                E44614120CD6826900FADA75 /* JSTimeRanges.cpp */,
                                49C7B9921042D2D30009D447 /* JSWebGLTexture.h */,
                                0C45342510CDBBFA00869157 /* JSWebGLUniformLocation.cpp */,
                                0C45342610CDBBFA00869157 /* JSWebGLUniformLocation.h */,
+                               77EF62F112F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.cpp */,
+                               77EF62F212F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.h */,
                                93F1D5BE12D5335600832BEC /* JSWebKitLoseContext.cpp */,
                                93F1D5BF12D5335600832BEC /* JSWebKitLoseContext.h */,
                        );
                                0F580B0B0F12A2690051D689 /* GraphicsLayerClient.h */,
                                B2A015940AF6CD53006BCE0E /* GraphicsTypes.cpp */,
                                B2A015950AF6CD53006BCE0E /* GraphicsTypes.h */,
+                               77A17A7A12F2890B004E02F6 /* GraphicsTypes3D.h */,
                                B27535400B053814002CE64F /* Icon.h */,
                                B27535410B053814002CE64F /* Image.cpp */,
                                B27535420B053814002CE64F /* Image.h */,
                                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
                                9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,
                                977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */,
+                               77A17A7212F28182004E02F6 /* OESVertexArrayObject.h in Headers */,
+                               77A17A7812F28642004E02F6 /* WebGLVertexArrayObjectOES.h in Headers */,
+                               77A17A7B12F2890B004E02F6 /* GraphicsTypes3D.h in Headers */,
+                               77A17AA712F28B2A004E02F6 /* JSOESVertexArrayObject.h in Headers */,
+                               77EF62F412F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.h in Headers */,
                                975CA28B130365F800E99AD9 /* Crypto.h in Headers */,
                                975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */,
                                26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */,
                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
                                9343CB8112F25E510033C5EE /* TextCodecUTF8.cpp in Sources */,
                                977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
+                               77A17A7112F28182004E02F6 /* OESVertexArrayObject.cpp in Sources */,
+                               77A17A7712F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp in Sources */,
+                               77A17AA612F28B2A004E02F6 /* JSOESVertexArrayObject.cpp in Sources */,
+                               77EF62F312F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.cpp in Sources */,
                                0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */,
                                975CA28A130365F800E99AD9 /* Crypto.cpp in Sources */,
                                975CA2A11303679D00E99AD9 /* JSCrypto.cpp in Sources */,
index eb4f6e2..0f52301 100644 (file)
@@ -39,6 +39,8 @@
 #include "JSImageData.h"
 #include "JSOESStandardDerivatives.h"
 #include "JSOESTextureFloat.h"
+#include "JSOESVertexArrayObject.h"
+#include "JSWebGLVertexArrayObjectOES.h"
 #include "JSWebGLBuffer.h"
 #include "JSFloat32Array.h"
 #include "JSWebGLFramebuffer.h"
@@ -53,6 +55,8 @@
 #include "NotImplemented.h"
 #include "OESStandardDerivatives.h"
 #include "OESTextureFloat.h"
+#include "OESVertexArrayObject.h"
+#include "WebGLVertexArrayObjectOES.h"
 #include "WebGLBuffer.h"
 #include "Float32Array.h"
 #include "WebGLExtension.h"
@@ -115,6 +119,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::kTypeWebGLVertexArrayObjectOES:
+        return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
     default:
         notImplemented();
         return jsUndefined();
@@ -179,6 +185,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten
         return toJS(exec, globalObject, static_cast<OESStandardDerivatives*>(extension));
     case WebGLExtension::OESTextureFloatName:
         return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension));
+    case WebGLExtension::OESVertexArrayObjectName:
+        return toJS(exec, globalObject, static_cast<OESVertexArrayObject*>(extension));
     }
     ASSERT_NOT_REACHED();
     return jsNull();
index 5a3f873..af81a41 100644 (file)
@@ -50,6 +50,7 @@
 #include "V8Int8Array.h"
 #include "V8OESStandardDerivatives.h"
 #include "V8OESTextureFloat.h"
+#include "V8OESVertexArrayObject.h"
 #include "V8Proxy.h"
 #include "V8Uint16Array.h"
 #include "V8Uint32Array.h"
@@ -61,6 +62,7 @@
 #include "V8WebGLShader.h"
 #include "V8WebGLTexture.h"
 #include "V8WebGLUniformLocation.h"
+#include "V8WebGLVertexArrayObjectOES.h"
 #include "WebGLRenderingContext.h"
 #include <wtf/FastMalloc.h>
 
@@ -146,6 +148,8 @@ static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info)
         return toV8(info.getWebGLTexture());
     case WebGLGetInfo::kTypeWebGLUnsignedByteArray:
         return toV8(info.getWebGLUnsignedByteArray());
+    case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
+        return toV8(info.getWebGLVertexArrayObjectOES());
     default:
         notImplemented();
         return v8::Undefined();
@@ -167,6 +171,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8
     case WebGLExtension::OESTextureFloatName:
         extensionObject = toV8(static_cast<OESTextureFloat*>(extension));
         break;
+    case WebGLExtension::OESVertexArrayObjectName:
+        extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension));
+        break;
     }
     ASSERT(!extensionObject.IsEmpty());
     V8DOMWrapper::setHiddenReference(contextObject, extensionObject);
diff --git a/Source/WebCore/html/canvas/OESVertexArrayObject.cpp b/Source/WebCore/html/canvas/OESVertexArrayObject.cpp
new file mode 100644 (file)
index 0000000..5fb71c8
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "OESVertexArrayObject.h"
+
+#include "Extensions3D.h"
+#include "WebGLRenderingContext.h"
+#include "WebGLVertexArrayObjectOES.h"
+
+namespace WebCore {
+
+OESVertexArrayObject::OESVertexArrayObject(WebGLRenderingContext* context)
+    : WebGLExtension()
+    , m_context(context)
+{
+}
+
+OESVertexArrayObject::~OESVertexArrayObject()
+{
+}
+
+WebGLExtension::ExtensionName OESVertexArrayObject::getName() const
+{
+    return OESVertexArrayObjectName;
+}
+
+PassRefPtr<OESVertexArrayObject> OESVertexArrayObject::create(WebGLRenderingContext* context)
+{
+    return adoptRef(new OESVertexArrayObject(context));
+}
+
+PassRefPtr<WebGLVertexArrayObjectOES> OESVertexArrayObject::createVertexArrayOES()
+{
+    if (m_context->isContextLost())
+        return 0;
+    
+    RefPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VaoTypeUser);
+    m_context->addObject(o.get());
+    return o.release();
+}
+
+void OESVertexArrayObject::deleteVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
+{
+    if (!arrayObject || m_context->isContextLost())
+        return;
+    
+    arrayObject->deleteObject();
+}
+
+GC3Dboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
+{
+    if (!arrayObject || m_context->isContextLost())
+        return 0;
+    
+    if (!arrayObject->hasEverBeenBound())
+        return 0;
+    
+    Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
+    return extensions->isVertexArrayOES(arrayObject->object());
+}
+
+void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject, ExceptionCode& ec)
+{
+    UNUSED_PARAM(ec);
+    if (m_context->isContextLost())
+        return;
+    
+    if (arrayObject && arrayObject->context() != m_context) {
+        m_context->graphicsContext3D()->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+        return;
+    }
+    
+    Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
+    if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
+        extensions->bindVertexArrayOES(arrayObject->object());
+        
+        arrayObject->setHasEverBeenBound();
+        m_context->setBoundVertexArrayObject(arrayObject);
+    } else {
+        extensions->bindVertexArrayOES(0);
+        
+        m_context->setBoundVertexArrayObject(0);
+    }
+    
+    m_context->cleanupAfterGraphicsCall(false);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/html/canvas/OESVertexArrayObject.h b/Source/WebCore/html/canvas/OESVertexArrayObject.h
new file mode 100644 (file)
index 0000000..d9792da
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+#ifndef OESVertexArrayObject_h
+#define OESVertexArrayObject_h
+
+#include "ExceptionCode.h"
+#include "GraphicsTypes3D.h"
+#include "WebGLExtension.h"
+#include "WebGLVertexArrayObjectOES.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/UnusedParam.h>
+
+namespace WebCore {
+
+class WebGLRenderingContext;
+class WebGLVertexArrayObjectOES;
+
+class OESVertexArrayObject : public WebGLExtension {
+public:
+    static PassRefPtr<OESVertexArrayObject> create(WebGLRenderingContext*);
+
+    virtual ~OESVertexArrayObject();
+    virtual ExtensionName getName() const;
+    
+    PassRefPtr<WebGLVertexArrayObjectOES> createVertexArrayOES();
+    void deleteVertexArrayOES(WebGLVertexArrayObjectOES*);
+    GC3Dboolean isVertexArrayOES(WebGLVertexArrayObjectOES*);
+    void bindVertexArrayOES(WebGLVertexArrayObjectOES*, ExceptionCode&);
+
+private:
+    OESVertexArrayObject(WebGLRenderingContext*);
+    
+    WebGLRenderingContext* m_context;
+};
+
+} // namespace WebCore
+
+#endif // OESVertexArrayObject_h
diff --git a/Source/WebCore/html/canvas/OESVertexArrayObject.idl b/Source/WebCore/html/canvas/OESVertexArrayObject.idl
new file mode 100644 (file)
index 0000000..911ebbc
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+module html {
+    interface [Conditional=WEBGL, OmitConstructor, DontCheckEnums] OESVertexArrayObject {
+        const unsigned int VERTEX_ARRAY_BINDING_OES = 0x85B5;
+        
+        [StrictTypeChecking] WebGLVertexArrayObjectOES createVertexArrayOES();
+        [StrictTypeChecking] void         deleteVertexArrayOES(in WebGLVertexArrayObjectOES arrayObject);
+        [StrictTypeChecking] boolean      isVertexArrayOES(in WebGLVertexArrayObjectOES arrayObject);
+        [StrictTypeChecking] void         bindVertexArrayOES(in WebGLVertexArrayObjectOES arrayObject) raises(DOMException);
+    };
+}
index d135c18..9a6753f 100644 (file)
@@ -37,6 +37,7 @@ public:
         WebKitLoseContextName,
         OESTextureFloatName,
         OESStandardDerivativesName,
+        OESVertexArrayObjectName,
     };
 
     virtual ~WebGLExtension();
index d0c8c65..17be974 100644 (file)
@@ -38,6 +38,7 @@
 #include "WebGLProgram.h"
 #include "WebGLRenderbuffer.h"
 #include "WebGLTexture.h"
+#include "WebGLVertexArrayObjectOES.h"
 
 namespace WebCore {
 
@@ -134,6 +135,12 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<Uint8Array> value)
 {
 }
 
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value)
+    : m_type(kTypeWebGLVertexArrayObjectOES)
+    , m_webglVertexArrayObject(value)
+{
+}
+
 WebGLGetInfo::~WebGLGetInfo()
 {
 }
@@ -227,6 +234,12 @@ PassRefPtr<Uint8Array> WebGLGetInfo::getWebGLUnsignedByteArray() const
     return m_webglUnsignedByteArray;
 }
 
+PassRefPtr<WebGLVertexArrayObjectOES> WebGLGetInfo::getWebGLVertexArrayObjectOES() const
+{
+    ASSERT(getType() == kTypeWebGLVertexArrayObjectOES);
+    return m_webglVertexArrayObject;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)
index 91f9233..bc2aacc 100644 (file)
@@ -36,6 +36,7 @@
 #include "WebGLProgram.h"
 #include "WebGLRenderbuffer.h"
 #include "WebGLTexture.h"
+#include "WebGLVertexArrayObjectOES.h"
 
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
@@ -65,7 +66,8 @@ public:
         kTypeWebGLProgram,
         kTypeWebGLRenderbuffer,
         kTypeWebGLTexture,
-        kTypeWebGLUnsignedByteArray
+        kTypeWebGLUnsignedByteArray,
+        kTypeWebGLVertexArrayObjectOES,
     };
 
     WebGLGetInfo(bool value);
@@ -86,6 +88,7 @@ public:
     WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value);
     WebGLGetInfo(PassRefPtr<WebGLTexture> value);
     WebGLGetInfo(PassRefPtr<Uint8Array> value);
+    WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value);
 
     virtual ~WebGLGetInfo();
 
@@ -107,6 +110,7 @@ public:
     PassRefPtr<WebGLRenderbuffer> getWebGLRenderbuffer() const;
     PassRefPtr<WebGLTexture> getWebGLTexture() const;
     PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
+    PassRefPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const;
 
 private:
     Type m_type;
@@ -126,6 +130,7 @@ private:
     RefPtr<WebGLRenderbuffer> m_webglRenderbuffer;
     RefPtr<WebGLTexture> m_webglTexture;
     RefPtr<Uint8Array> m_webglUnsignedByteArray;
+    RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObject;
 };
 
 } // namespace WebCore
index 4ed9ab0..cc7a23b 100644 (file)
@@ -46,6 +46,7 @@
 #include "NotImplemented.h"
 #include "OESStandardDerivatives.h"
 #include "OESTextureFloat.h"
+#include "OESVertexArrayObject.h"
 #include "RenderBox.h"
 #include "RenderLayer.h"
 #include "Settings.h"
@@ -402,7 +403,6 @@ void WebGLRenderingContext::initializeNewContext()
     m_unpackPremultiplyAlpha = false;
     m_unpackColorspaceConversion = GraphicsContext3D::BROWSER_DEFAULT_WEBGL;
     m_boundArrayBuffer = 0;
-    m_boundElementArrayBuffer = 0;
     m_currentProgram = 0;
     m_framebufferBinding = 0;
     m_renderbufferBinding = 0;
@@ -412,7 +412,6 @@ void WebGLRenderingContext::initializeNewContext()
     m_stencilFuncRefBack = 0;
     m_stencilFuncMask = 0xFFFFFFFF;
     m_stencilFuncMaskBack = 0xFFFFFFFF;
-    m_vertexAttribState.clear();
 
     GC3Dint numCombinedTextureImageUnits = 0;
     m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits);
@@ -422,13 +421,19 @@ void WebGLRenderingContext::initializeNewContext()
     GC3Dint numVertexAttribs = 0;
     m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &numVertexAttribs);
     m_maxVertexAttribs = numVertexAttribs;
-
+    
     m_maxTextureSize = 0;
     m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_maxTextureSize);
     m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxTextureSize);
     m_maxCubeMapTextureSize = 0;
     m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSize);
     m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextureSize, m_maxCubeMapTextureSize);
+    
+    m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVertexArrayObjectOES::VaoTypeDefault);
+    addObject(m_defaultVertexArrayObject.get());
+    m_boundVertexArrayObject = m_defaultVertexArrayObject;
+    
+    m_vertexAttribValue.resize(m_maxVertexAttribs);
 
     if (!isGLES2NPOTStrict())
         createFallbackBlackTextures1x1();
@@ -602,7 +607,7 @@ void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer, Exc
     if (target == GraphicsContext3D::ARRAY_BUFFER)
         m_boundArrayBuffer = buffer;
     else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER)
-        m_boundElementArrayBuffer = buffer;
+        m_boundVertexArrayObject->setElementArrayBuffer(buffer);
     else {
         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
         return;
@@ -1118,10 +1123,11 @@ void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer)
         return;
     if (m_boundArrayBuffer == buffer)
         m_boundArrayBuffer = 0;
-    if (m_boundElementArrayBuffer == buffer)
-        m_boundElementArrayBuffer = 0;
+    RefPtr<WebGLBuffer> elementArrayBuffer = m_boundVertexArrayObject->getElementArrayBuffer();
+    if (elementArrayBuffer == buffer)
+        m_boundVertexArrayObject->setElementArrayBuffer(0);
     if (!isGLES2Compliant()) {
-        VertexAttribState& state = m_vertexAttribState[0];
+        WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
         if (buffer == state.bufferBinding) {
             state.bufferBinding = m_vertexAttrib0Buffer;
             state.bytesPerElement = 0;
@@ -1242,8 +1248,8 @@ void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index, ExceptionCo
         return;
     }
 
-    if (index < m_vertexAttribState.size())
-        m_vertexAttribState[index].enabled = false;
+    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
+    state.enabled = false;
 
     if (index > 0 || isGLES2Compliant()) {
         m_context->disableVertexAttribArray(index);
@@ -1253,7 +1259,9 @@ void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index, ExceptionCo
 
 bool WebGLRenderingContext::validateElementArraySize(GC3Dsizei count, GC3Denum type, GC3Dintptr offset)
 {
-    if (!m_boundElementArrayBuffer)
+    RefPtr<WebGLBuffer> elementArrayBuffer = m_boundVertexArrayObject->getElementArrayBuffer();
+    
+    if (!elementArrayBuffer)
         return false;
 
     if (offset < 0)
@@ -1267,11 +1275,11 @@ bool WebGLRenderingContext::validateElementArraySize(GC3Dsizei count, GC3Denum t
         // Make uoffset an element offset.
         offset /= 2;
 
-        GC3Dsizeiptr n = m_boundElementArrayBuffer->byteLength() / 2;
+        GC3Dsizeiptr n = elementArrayBuffer->byteLength() / 2;
         if (offset > n || count > n - offset)
             return false;
     } else if (type == GraphicsContext3D::UNSIGNED_BYTE) {
-        GC3Dsizeiptr n = m_boundElementArrayBuffer->byteLength();
+        GC3Dsizeiptr n = elementArrayBuffer->byteLength();
         if (offset > n || count > n - offset)
             return false;
     }
@@ -1285,18 +1293,20 @@ bool WebGLRenderingContext::validateIndexArrayConservative(GC3Denum type, int& n
     // array buffers have enough elements to satisfy that maximum
     // index, skips the expensive per-draw-call iteration in
     // validateIndexArrayPrecise.
+    
+    RefPtr<WebGLBuffer> elementArrayBuffer = m_boundVertexArrayObject->getElementArrayBuffer();
 
-    if (!m_boundElementArrayBuffer)
+    if (!elementArrayBuffer)
         return false;
 
-    GC3Dsizeiptr numElements = m_boundElementArrayBuffer->byteLength();
+    GC3Dsizeiptr numElements = elementArrayBuffer->byteLength();
     // The case count==0 is already dealt with in drawElements before validateIndexArrayConservative.
     if (!numElements)
         return false;
-    const ArrayBuffer* buffer = m_boundElementArrayBuffer->elementArrayBuffer();
+    const ArrayBuffer* buffer = elementArrayBuffer->elementArrayBuffer();
     ASSERT(buffer);
 
-    int maxIndex = m_boundElementArrayBuffer->getCachedMaxIndex(type);
+    int maxIndex = elementArrayBuffer->getCachedMaxIndex(type);
     if (maxIndex < 0) {
         // Compute the maximum index in the entire buffer for the given type of index.
         switch (type) {
@@ -1316,7 +1326,7 @@ bool WebGLRenderingContext::validateIndexArrayConservative(GC3Denum type, int& n
         default:
             return false;
         }
-        m_boundElementArrayBuffer->setCachedMaxIndex(type, maxIndex);
+        elementArrayBuffer->setCachedMaxIndex(type, maxIndex);
     }
 
     if (maxIndex >= 0) {
@@ -1333,8 +1343,10 @@ bool WebGLRenderingContext::validateIndexArrayPrecise(GC3Dsizei count, GC3Denum
 {
     ASSERT(count >= 0 && offset >= 0);
     int lastIndex = -1;
+    
+    RefPtr<WebGLBuffer> elementArrayBuffer = m_boundVertexArrayObject->getElementArrayBuffer();
 
-    if (!m_boundElementArrayBuffer)
+    if (!elementArrayBuffer)
         return false;
 
     if (!count) {
@@ -1342,7 +1354,7 @@ bool WebGLRenderingContext::validateIndexArrayPrecise(GC3Dsizei count, GC3Denum
         return true;
     }
 
-    if (!m_boundElementArrayBuffer->elementArrayBuffer())
+    if (!elementArrayBuffer->elementArrayBuffer())
         return false;
 
     unsigned long uoffset = offset;
@@ -1351,14 +1363,14 @@ bool WebGLRenderingContext::validateIndexArrayPrecise(GC3Dsizei count, GC3Denum
     if (type == GraphicsContext3D::UNSIGNED_SHORT) {
         // Make uoffset an element offset.
         uoffset /= sizeof(GC3Dushort);
-        const GC3Dushort* p = static_cast<const GC3Dushort*>(m_boundElementArrayBuffer->elementArrayBuffer()->data()) + uoffset;
+        const GC3Dushort* p = static_cast<const GC3Dushort*>(elementArrayBuffer->elementArrayBuffer()->data()) + uoffset;
         while (n-- > 0) {
             if (*p > lastIndex)
                 lastIndex = *p;
             ++p;
         }
     } else if (type == GraphicsContext3D::UNSIGNED_BYTE) {
-        const GC3Dubyte* p = static_cast<const GC3Dubyte*>(m_boundElementArrayBuffer->elementArrayBuffer()->data()) + uoffset;
+        const GC3Dubyte* p = static_cast<const GC3Dubyte*>(elementArrayBuffer->elementArrayBuffer()->data()) + uoffset;
         while (n-- > 0) {
             if (*p > lastIndex)
                 lastIndex = *p;
@@ -1376,12 +1388,11 @@ bool WebGLRenderingContext::validateRenderingState(int numElementsRequired)
     if (!m_currentProgram)
         return false;
 
-    int numAttribStates = static_cast<int>(m_vertexAttribState.size());
-
     // Look in each enabled vertex attrib and check if they've been bound to a buffer.
-    for (int i = 0; i < numAttribStates; ++i) {
-        if (m_vertexAttribState[i].enabled
-            && (!m_vertexAttribState[i].bufferBinding || !m_vertexAttribState[i].bufferBinding->object()))
+    for (unsigned i = 0; i < m_maxVertexAttribs; ++i) {
+        const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(i);
+        if (state.enabled
+            && (!state.bufferBinding || !state.bufferBinding->object()))
             return false;
     }
 
@@ -1393,8 +1404,8 @@ bool WebGLRenderingContext::validateRenderingState(int numElementsRequired)
     int numActiveAttribLocations = m_currentProgram->numActiveAttribLocations();
     for (int i = 0; i < numActiveAttribLocations; ++i) {
         int loc = m_currentProgram->getActiveAttribLocation(i);
-        if (loc >=0 && loc < numAttribStates) {
-            const VertexAttribState& state = m_vertexAttribState[loc];
+        if (loc >= 0 && loc < static_cast<int>(m_maxVertexAttribs)) {
+            const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(loc);
             if (state.enabled) {
                 // Avoid off-by-one errors in numElements computation.
                 // For the last element, we will only touch the data for the
@@ -1508,7 +1519,7 @@ void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denu
     if (!count)
         return;
 
-    if (!m_boundElementArrayBuffer) {
+    if (!m_boundVertexArrayObject->getElementArrayBuffer()) {
         m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
         return;
     }
@@ -1574,10 +1585,8 @@ void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index, ExceptionCod
         return;
     }
 
-    if (index >= m_vertexAttribState.size())
-        m_vertexAttribState.resize(index + 1);
-
-    m_vertexAttribState[index].enabled = true;
+    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
+    state.enabled = true;
 
     m_context->enableVertexAttribArray(index);
     cleanupAfterGraphicsCall(false);
@@ -1851,6 +1860,14 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
         }
         return m_oesTextureFloat.get();
     }
+    if (equalIgnoringCase(name, "OES_vertex_array_object")
+        && m_context->getExtensions()->supports("GL_OES_vertex_array_object")) {
+        if (!m_oesVertexArrayObject) {
+            m_context->getExtensions()->ensureEnabled("GL_OES_vertex_array_object");
+            m_oesVertexArrayObject = OESVertexArrayObject::create(this);
+        }
+        return m_oesVertexArrayObject.get();
+    }
     if (equalIgnoringCase(name, "WEBKIT_lose_context")) {
         if (!m_webkitLoseContext)
             m_webkitLoseContext = WebKitLoseContext::create(this);
@@ -1971,7 +1988,7 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&
     case GraphicsContext3D::DITHER:
         return getBooleanParameter(pname);
     case GraphicsContext3D::ELEMENT_ARRAY_BUFFER_BINDING:
-        return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundElementArrayBuffer));
+        return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundVertexArrayObject->getElementArrayBuffer()));
     case GraphicsContext3D::FRAMEBUFFER_BINDING:
         return WebGLGetInfo(PassRefPtr<WebGLFramebuffer>(m_framebufferBinding));
     case GraphicsContext3D::FRONT_FACE:
@@ -2097,6 +2114,14 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&
             return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
         return WebGLGetInfo();
+    case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
+        if (m_oesVertexArrayObject) {
+            if (!m_boundVertexArrayObject->isDefaultObject())
+                return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boundVertexArrayObject));
+            return WebGLGetInfo();
+        }
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+        return WebGLGetInfo();
     default:
         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
         return WebGLGetInfo();
@@ -2258,6 +2283,8 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions()
         result.append("OES_texture_float");
     if (m_context->getExtensions()->supports("GL_OES_standard_derivatives"))
         result.append("OES_standard_derivatives");
+    if (m_context->getExtensions()->supports("GL_OES_vertex_array_object"))
+        result.append("OES_vertex_array_object");
     result.append("WEBKIT_lose_context");
     return result;
 }
@@ -2453,40 +2480,26 @@ WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna
         m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
         return WebGLGetInfo();
     }
+    const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
     switch (pname) {
     case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
-        if ((!isGLES2Compliant() && !index && m_vertexAttribState[0].bufferBinding == m_vertexAttrib0Buffer)
-            || index >= m_vertexAttribState.size()
-            || !m_vertexAttribState[index].bufferBinding
-            || !m_vertexAttribState[index].bufferBinding->object())
+        if ((!isGLES2Compliant() && !index && m_boundVertexArrayObject->getVertexAttribState(0).bufferBinding == m_vertexAttrib0Buffer)
+            || !state.bufferBinding
+            || !state.bufferBinding->object())
             return WebGLGetInfo();
-        return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_vertexAttribState[index].bufferBinding));
+        return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding));
     case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_ENABLED:
-        if (index >= m_vertexAttribState.size())
-            return WebGLGetInfo(false);
-        return WebGLGetInfo(m_vertexAttribState[index].enabled);
+        return WebGLGetInfo(state.enabled);
     case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_NORMALIZED:
-        if (index >= m_vertexAttribState.size())
-            return WebGLGetInfo(false);
-        return WebGLGetInfo(m_vertexAttribState[index].normalized);
+        return WebGLGetInfo(state.normalized);
     case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_SIZE:
-        if (index >= m_vertexAttribState.size())
-            return WebGLGetInfo(static_cast<int>(4));
-        return WebGLGetInfo(m_vertexAttribState[index].size);
+        return WebGLGetInfo(state.size);
     case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_STRIDE:
-        if (index >= m_vertexAttribState.size())
-            return WebGLGetInfo(static_cast<int>(0));
-        return WebGLGetInfo(m_vertexAttribState[index].originalStride);
+        return WebGLGetInfo(state.originalStride);
     case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_TYPE:
-        if (index >= m_vertexAttribState.size())
-            return WebGLGetInfo(static_cast<unsigned int>(GraphicsContext3D::FLOAT));
-        return WebGLGetInfo(m_vertexAttribState[index].type);
+        return WebGLGetInfo(state.type);
     case GraphicsContext3D::CURRENT_VERTEX_ATTRIB:
-        if (index >= m_vertexAttribState.size()) {
-            float value[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
-            return WebGLGetInfo(Float32Array::create(value, 4));
-        }
-        return WebGLGetInfo(Float32Array::create(m_vertexAttribState[index].value, 4));
+        return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].value, 4));
     default:
         m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
         return WebGLGetInfo();
@@ -3724,19 +3737,17 @@ void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC
     }
     GC3Dsizei bytesPerElement = size * typeSize;
 
-    if (index >= m_vertexAttribState.size())
-        m_vertexAttribState.resize(index + 1);
-
     GC3Dsizei validatedStride = stride ? stride : bytesPerElement;
 
-    m_vertexAttribState[index].bufferBinding = m_boundArrayBuffer;
-    m_vertexAttribState[index].bytesPerElement = bytesPerElement;
-    m_vertexAttribState[index].size = size;
-    m_vertexAttribState[index].type = type;
-    m_vertexAttribState[index].normalized = normalized;
-    m_vertexAttribState[index].stride = validatedStride;
-    m_vertexAttribState[index].originalStride = stride;
-    m_vertexAttribState[index].offset = offset;
+    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
+    state.bufferBinding = m_boundArrayBuffer;
+    state.bytesPerElement = bytesPerElement;
+    state.size = size;
+    state.type = type;
+    state.normalized = normalized;
+    state.stride = validatedStride;
+    state.originalStride = stride;
+    state.offset = offset;
     m_context->vertexAttribPointer(index, size, type, normalized, stride, offset);
     cleanupAfterGraphicsCall(false);
 }
@@ -4473,7 +4484,7 @@ WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(GC3Denum target
     WebGLBuffer* buffer = 0;
     switch (target) {
     case GraphicsContext3D::ELEMENT_ARRAY_BUFFER:
-        buffer = m_boundElementArrayBuffer.get();
+        buffer = m_boundVertexArrayObject->getElementArrayBuffer().get();
         break;
     case GraphicsContext3D::ARRAY_BUFFER:
         buffer = m_boundArrayBuffer.get();
@@ -4522,12 +4533,11 @@ void WebGLRenderingContext::vertexAttribfImpl(GC3Duint index, GC3Dsizei expected
         }
         cleanupAfterGraphicsCall(false);
     }
-    if (index >= m_vertexAttribState.size())
-        m_vertexAttribState.resize(index + 1);
-    m_vertexAttribState[index].value[0] = v0;
-    m_vertexAttribState[index].value[1] = v1;
-    m_vertexAttribState[index].value[2] = v2;
-    m_vertexAttribState[index].value[3] = v3;
+    VertexAttribValue& attribValue = m_vertexAttribValue[index];
+    attribValue.value[0] = v0;
+    attribValue.value[1] = v1;
+    attribValue.value[2] = v2;
+    attribValue.value[3] = v3;
 }
 
 void WebGLRenderingContext::vertexAttribfvImpl(GC3Duint index, Float32Array* v, GC3Dsizei expectedSize)
@@ -4575,21 +4585,21 @@ void WebGLRenderingContext::vertexAttribfvImpl(GC3Duint index, GC3Dfloat* v, GC3
         }
         cleanupAfterGraphicsCall(false);
     }
-    if (index >= m_vertexAttribState.size())
-        m_vertexAttribState.resize(index + 1);
-    m_vertexAttribState[index].initValue();
+    VertexAttribValue& attribValue = m_vertexAttribValue[index];
+    attribValue.initValue();
     for (int ii = 0; ii < expectedSize; ++ii)
-        m_vertexAttribState[index].value[ii] = v[ii];
+        attribValue.value[ii] = v[ii];
 }
 
 void WebGLRenderingContext::initVertexAttrib0()
 {
-    m_vertexAttribState.resize(1);
+    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
+    
     m_vertexAttrib0Buffer = createBuffer();
     m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_vertexAttrib0Buffer->object());
     m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, 0, GraphicsContext3D::DYNAMIC_DRAW);
     m_context->vertexAttribPointer(0, 4, GraphicsContext3D::FLOAT, false, 0, 0);
-    m_vertexAttribState[0].bufferBinding = m_vertexAttrib0Buffer;
+    state.bufferBinding = m_vertexAttrib0Buffer;
     m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
     m_context->enableVertexAttribArray(0);
     m_vertexAttrib0BufferSize = 0;
@@ -4603,7 +4613,8 @@ void WebGLRenderingContext::initVertexAttrib0()
 
 bool WebGLRenderingContext::simulateVertexAttrib0(GC3Dsizei numVertex)
 {
-    const VertexAttribState& state = m_vertexAttribState[0];
+    const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
+    const VertexAttribValue& attribValue = m_vertexAttribValue[0];
     if (!m_currentProgram)
         return false;
     bool usingVertexAttrib0 = m_currentProgram->isUsingVertexAttrib0();
@@ -4623,21 +4634,21 @@ bool WebGLRenderingContext::simulateVertexAttrib0(GC3Dsizei numVertex)
     }
     if (usingVertexAttrib0
         && (m_forceAttrib0BufferRefill
-            || state.value[0] != m_vertexAttrib0BufferValue[0]
-            || state.value[1] != m_vertexAttrib0BufferValue[1]
-            || state.value[2] != m_vertexAttrib0BufferValue[2]
-            || state.value[3] != m_vertexAttrib0BufferValue[3])) {
+            || attribValue.value[0] != m_vertexAttrib0BufferValue[0]
+            || attribValue.value[1] != m_vertexAttrib0BufferValue[1]
+            || attribValue.value[2] != m_vertexAttrib0BufferValue[2]
+            || attribValue.value[3] != m_vertexAttrib0BufferValue[3])) {
         OwnArrayPtr<GC3Dfloat> bufferData = adoptArrayPtr(new GC3Dfloat[(numVertex + 1) * 4]);
         for (GC3Dsizei ii = 0; ii < numVertex + 1; ++ii) {
-            bufferData[ii * 4] = state.value[0];
-            bufferData[ii * 4 + 1] = state.value[1];
-            bufferData[ii * 4 + 2] = state.value[2];
-            bufferData[ii * 4 + 3] = state.value[3];
+            bufferData[ii * 4] = attribValue.value[0];
+            bufferData[ii * 4 + 1] = attribValue.value[1];
+            bufferData[ii * 4 + 2] = attribValue.value[2];
+            bufferData[ii * 4 + 3] = attribValue.value[3];
         }
-        m_vertexAttrib0BufferValue[0] = state.value[0];
-        m_vertexAttrib0BufferValue[1] = state.value[1];
-        m_vertexAttrib0BufferValue[2] = state.value[2];
-        m_vertexAttrib0BufferValue[3] = state.value[3];
+        m_vertexAttrib0BufferValue[0] = attribValue.value[0];
+        m_vertexAttrib0BufferValue[1] = attribValue.value[1];
+        m_vertexAttrib0BufferValue[2] = attribValue.value[2];
+        m_vertexAttrib0BufferValue[3] = attribValue.value[3];
         m_forceAttrib0BufferRefill = false;
         m_context->bufferSubData(GraphicsContext3D::ARRAY_BUFFER, 0, bufferDataSize, bufferData.get());
     }
@@ -4647,7 +4658,7 @@ bool WebGLRenderingContext::simulateVertexAttrib0(GC3Dsizei numVertex)
 
 void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation()
 {
-    const VertexAttribState& state = m_vertexAttribState[0];
+    const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
     if (state.bufferBinding != m_vertexAttrib0Buffer) {
         m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, objectOrZero(state.bufferBinding.get()));
         m_context->vertexAttribPointer(0, state.size, state.type, state.normalized, state.originalStride, state.offset);
@@ -4657,11 +4668,16 @@ void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation()
 
 int WebGLRenderingContext::getNumberOfExtensions()
 {
-    return (m_oesStandardDerivatives ? 1 : 0) + (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0);
+    return (m_oesVertexArrayObject ? 1 : 0) + (m_oesStandardDerivatives ? 1 : 0) + (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0);
 }
 
 WebGLExtension* WebGLRenderingContext::getExtensionNumber(int i)
 {
+    if (m_oesVertexArrayObject) {
+        if (!i)
+            return m_oesVertexArrayObject.get();
+        --i;
+    }
     if (m_oesStandardDerivatives) {
         if (!i)
             return m_oesStandardDerivatives.get();
index dd71620..13145c8 100644 (file)
@@ -59,6 +59,8 @@ class ImageData;
 class IntSize;
 class OESStandardDerivatives;
 class OESTextureFloat;
+class OESVertexArrayObject;
+class WebGLVertexArrayObjectOES;
 
 class WebGLRenderingContext : public CanvasRenderingContext {
 public:
@@ -286,6 +288,8 @@ public:
     virtual void paintRenderingResultsToCanvas();
 
     void removeObject(WebGLObject*);
+    
+    unsigned getMaxVertexAttribs() const { return m_maxVertexAttribs; }
 
     // Helpers for JSC bindings.
     int getNumberOfExtensions();
@@ -293,6 +297,7 @@ public:
 
   private:
     friend class WebGLObject;
+    friend class OESVertexArrayObject;
 
     WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes);
     void initializeNewContext();
@@ -362,24 +367,24 @@ public:
 
     // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER
     RefPtr<WebGLBuffer> m_boundArrayBuffer;
-    RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
-
-    // Cached values for vertex attrib range checks
-    class VertexAttribState {
+    
+    RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
+    RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
+    void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayObject)
+    {
+        if (arrayObject)
+            m_boundVertexArrayObject = arrayObject;
+        else
+            m_boundVertexArrayObject = m_defaultVertexArrayObject;
+    }
+    
+    class VertexAttribValue {
     public:
-        VertexAttribState()
-            : enabled(false)
-            , bytesPerElement(0)
-            , size(4)
-            , type(GraphicsContext3D::FLOAT)
-            , normalized(false)
-            , stride(16)
-            , originalStride(0)
-            , offset(0)
+        VertexAttribValue()
         {
             initValue();
         }
-
+        
         void initValue()
         {
             value[0] = 0.0f;
@@ -387,20 +392,10 @@ public:
             value[2] = 0.0f;
             value[3] = 1.0f;
         }
-
-        bool enabled;
-        RefPtr<WebGLBuffer> bufferBinding;
-        GC3Dsizei bytesPerElement;
-        GC3Dint size;
-        GC3Denum type;
-        bool normalized;
-        GC3Dsizei stride;
-        GC3Dsizei originalStride;
-        GC3Dintptr offset;
+        
         GC3Dfloat value[4];
     };
-
-    Vector<VertexAttribState> m_vertexAttribState;
+    Vector<VertexAttribValue> m_vertexAttribValue;
     unsigned m_maxVertexAttribs;
     RefPtr<WebGLBuffer> m_vertexAttrib0Buffer;
     long m_vertexAttrib0BufferSize;
@@ -462,6 +457,7 @@ public:
     // Enabled extension objects.
     RefPtr<OESTextureFloat> m_oesTextureFloat;
     RefPtr<OESStandardDerivatives> m_oesStandardDerivatives;
+    RefPtr<OESVertexArrayObject> m_oesVertexArrayObject;
     RefPtr<WebKitLoseContext> m_webkitLoseContext;
 
     // Helpers for getParameter and others
diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp
new file mode 100644 (file)
index 0000000..d14c96c
--- /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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "WebGLVertexArrayObjectOES.h"
+
+#include "Extensions3D.h"
+#include "WebGLRenderingContext.h"
+
+namespace WebCore {
+
+PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContext* ctx, VaoType type)
+{
+    return adoptRef(new WebGLVertexArrayObjectOES(ctx, type));
+}
+
+WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContext* ctx, VaoType type)
+    : WebGLObject(ctx)
+    , m_type(type)
+    , m_hasEverBeenBound(false)
+    , m_boundElementArrayBuffer(0)
+{
+    m_vertexAttribState.resize(ctx->getMaxVertexAttribs());
+    
+    Extensions3D* extensions = context()->graphicsContext3D()->getExtensions();
+    switch (m_type) {
+    case VaoTypeDefault:
+        break;
+    default:
+        setObject(extensions->createVertexArrayOES());
+        break;
+    }
+}
+
+void WebGLVertexArrayObjectOES::deleteObjectImpl(Platform3DObject object)
+{
+    Extensions3D* extensions = context()->graphicsContext3D()->getExtensions();
+    switch (m_type) {
+    case VaoTypeDefault:
+        break;
+    default:
+        extensions->deleteVertexArrayOES(object);
+        break;
+    }
+}
+
+}
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h
new file mode 100644 (file)
index 0000000..f49a780
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+#ifndef WebGLVertexArrayObjectOES_h
+#define WebGLVertexArrayObjectOES_h
+
+#include "WebGLBuffer.h"
+#include "WebGLObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class WebGLVertexArrayObjectOES : public WebGLObject {
+public:
+    enum VaoType {
+        VaoTypeDefault,
+        VaoTypeUser,
+    };
+    
+    virtual ~WebGLVertexArrayObjectOES() { deleteObject(); }
+
+    static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContext*, VaoType);
+    
+    // Cached values for vertex attrib range checks
+    struct VertexAttribState {
+        VertexAttribState()
+            : enabled(false)
+            , bytesPerElement(0)
+            , size(4)
+            , type(GraphicsContext3D::FLOAT)
+            , normalized(false)
+            , stride(16)
+            , originalStride(0)
+            , offset(0)
+        {
+        }
+        
+        bool enabled;
+        RefPtr<WebGLBuffer> bufferBinding;
+        GC3Dsizei bytesPerElement;
+        GC3Dint size;
+        GC3Denum type;
+        bool normalized;
+        GC3Dsizei stride;
+        GC3Dsizei originalStride;
+        GC3Dintptr offset;
+    };
+    
+    bool isDefaultObject() const { return m_type == VaoTypeDefault; }
+    
+    bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
+    void setHasEverBeenBound() { m_hasEverBeenBound = true; }
+    
+    PassRefPtr<WebGLBuffer> getElementArrayBuffer() const { return m_boundElementArrayBuffer; }
+    void setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer) { m_boundElementArrayBuffer = buffer; }
+    
+    VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
+
+private:
+    WebGLVertexArrayObjectOES(WebGLRenderingContext*, VaoType);
+
+    virtual void deleteObjectImpl(Platform3DObject);
+
+    virtual bool isVertexArray() const { return true; }
+    
+    VaoType m_type;
+    bool m_hasEverBeenBound;
+    RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
+    Vector<VertexAttribState> m_vertexAttribState;
+};
+
+} // namespace WebCore
+
+#endif // WebGLVertexArrayObjectOES_h
diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.idl b/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.idl
new file mode 100644 (file)
index 0000000..8582b36
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+module html {
+    interface [Conditional=WEBGL] WebGLVertexArrayObjectOES {
+    };
+}
index 6d6efe5..5d5a5b7 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef Extensions3D_h
 #define Extensions3D_h
 
+#include "GraphicsTypes3D.h"
+
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -53,6 +55,7 @@ public:
     //   GL_OES_texture_float
     //   GL_OES_standard_derivatives
     //   GL_OES_rgb8_rgba8
+    //   GL_OES_vertex_array_object
 
     // Takes full name of extension; for example,
     // "GL_EXT_texture_format_BGRA8888".
@@ -92,6 +95,9 @@ public:
         // GL_OES_rgb8_rgba8 names
         RGB8_OES = 0x8051,
         RGBA8_OES = 0x8058,
+        
+        // GL_OES_vertex_array_object names
+        VERTEX_ARRAY_BINDING_OES = 0x85B5,
     };
 
     // GL_ARB_robustness
@@ -101,7 +107,13 @@ public:
     virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) = 0;
     
     // GL_ANGLE_framebuffer_multisample
-    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;    
+    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) = 0;
+    
+    // GL_OES_vertex_array_object
+    virtual Platform3DObject createVertexArrayOES() = 0;
+    virtual void deleteVertexArrayOES(Platform3DObject) = 0;
+    virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
+    virtual void bindVertexArrayOES(Platform3DObject) = 0;
 };
 
 } // namespace WebCore
index d6c1cec..a9db650 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "IntSize.h"
 #include "GraphicsLayer.h"
+#include "GraphicsTypes3D.h"
 #include "PlatformString.h"
 
 #include <wtf/HashMap.h>
 #undef VERSION
 #endif
 
-// GC3D types match the corresponding GL types as defined in OpenGL ES 2.0
-// header file gl2.h from khronos.org.
-typedef unsigned int GC3Denum;
-typedef unsigned char GC3Dboolean;
-typedef unsigned int GC3Dbitfield;
-typedef signed char GC3Dbyte;
-typedef unsigned char GC3Dubyte;
-typedef short GC3Dshort;
-typedef unsigned short GC3Dushort;
-typedef int GC3Dint;
-typedef int GC3Dsizei;
-typedef unsigned int GC3Duint;
-typedef float GC3Dfloat;
-typedef float GC3Dclampf;
-typedef signed long int GC3Dintptr;
-typedef signed long int GC3Dsizeiptr;
-
-typedef GC3Duint Platform3DObject;
-
 #if PLATFORM(MAC)
 #include "ANGLEWebKitBridge.h"
 #include <OpenGL/OpenGL.h>
diff --git a/Source/WebCore/platform/graphics/GraphicsTypes3D.h b/Source/WebCore/platform/graphics/GraphicsTypes3D.h
new file mode 100644 (file)
index 0000000..ad73336
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+#ifndef GraphicsTypes3D_h
+#define GraphicsTypes3D_h
+
+#include <wtf/Forward.h>
+
+// GC3D types match the corresponding GL types as defined in OpenGL ES 2.0
+// header file gl2.h from khronos.org.
+typedef unsigned int GC3Denum;
+typedef unsigned char GC3Dboolean;
+typedef unsigned int GC3Dbitfield;
+typedef signed char GC3Dbyte;
+typedef unsigned char GC3Dubyte;
+typedef short GC3Dshort;
+typedef unsigned short GC3Dushort;
+typedef int GC3Dint;
+typedef int GC3Dsizei;
+typedef unsigned int GC3Duint;
+typedef float GC3Dfloat;
+typedef float GC3Dclampf;
+typedef signed long int GC3Dintptr;
+typedef signed long int GC3Dsizeiptr;
+
+typedef GC3Duint Platform3DObject;
+
+#endif
index 92fb7b3..3b0fdbf 100644 (file)
@@ -46,6 +46,10 @@ public:
     virtual int getGraphicsResetStatusARB();
     virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
     virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);
+    virtual Platform3DObject createVertexArrayOES();
+    virtual void deleteVertexArrayOES(Platform3DObject);
+    virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
+    virtual void bindVertexArrayOES(Platform3DObject);
 
     enum {
         // GL_CHROMIUM_map_sub (enums inherited from GL_ARB_vertex_buffer_object)
index df45147..d761eb9 100644 (file)
@@ -87,6 +87,10 @@ bool Extensions3DOpenGL::supports(const String& name)
     // GL_OES_texture_half_float as available.
     if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float")
         return m_availableExtensions.contains("GL_ARB_texture_float");
+    
+    // GL_OES_vertex_array_object
+    if (name == "GL_OES_vertex_array_object")
+        return m_availableExtensions.contains("GL_APPLE_vertex_array_object");
 
     // Desktop GL always supports the standard derivative functions
     if (name == "GL_OES_standard_derivatives")
@@ -127,6 +131,53 @@ void Extensions3DOpenGL::renderbufferStorageMultisample(unsigned long target, un
     ::glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height);
 }
 
+Platform3DObject Extensions3DOpenGL::createVertexArrayOES()
+{
+    m_context->makeContextCurrent();
+#if GL_APPLE_vertex_array_object
+    GLuint array = 0;
+    glGenVertexArraysAPPLE(1, &array);
+    return array;
+#else
+    return 0;
+#endif
+}
+
+void Extensions3DOpenGL::deleteVertexArrayOES(Platform3DObject array)
+{
+    if (!array)
+        return;
+    
+    m_context->makeContextCurrent();
+#if GL_APPLE_vertex_array_object
+    glDeleteVertexArraysAPPLE(1, &array);
+#else
+#endif
+}
+
+GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
+{
+    if (!array)
+        return GL_FALSE;
+    
+    m_context->makeContextCurrent();
+#if GL_APPLE_vertex_array_object
+    return glIsVertexArrayAPPLE(array);
+#else
+    return GL_FALSE;
+#endif
+}
+
+void Extensions3DOpenGL::bindVertexArrayOES(Platform3DObject array)
+{
+    m_context->makeContextCurrent();
+#if GL_APPLE_vertex_array_object
+    glBindVertexArrayAPPLE(array);
+#else
+    ASSERT_UNUSED(array, supports(array));
+#endif
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)
index 1941a42..9188507 100644 (file)
@@ -43,7 +43,12 @@ public:
     virtual void ensureEnabled(const String&);
     virtual int getGraphicsResetStatusARB();
     virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
-    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);    
+    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);
+    
+    virtual Platform3DObject createVertexArrayOES();
+    virtual void deleteVertexArrayOES(Platform3DObject);
+    virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
+    virtual void bindVertexArrayOES(Platform3DObject);
 
 private:
     // This class only needs to be instantiated by GraphicsContext3D implementations.
index ee57593..dcea72f 100644 (file)
@@ -64,6 +64,24 @@ void Extensions3DQt::renderbufferStorageMultisample(unsigned long target, unsign
 {
 }
 
+Platform3DObject Extensions3DQt::createVertexArrayOES()
+{
+    return 0;
+}
+
+void Extensions3DQt::deleteVertexArrayOES(Platform3DObject)
+{
+}
+
+GC3Dboolean Extensions3DQt::isVertexArrayOES(Platform3DObject)
+{
+    return GL_FALSE;
+}
+
+void Extensions3DQt::bindVertexArrayOES(Platform3DObject)
+{
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)
index 419b99c..c67fbed 100644 (file)
@@ -39,7 +39,11 @@ public:
     virtual void ensureEnabled(const String&);
     virtual int getGraphicsResetStatusARB();
     virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
-    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);    
+    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);
+    virtual Platform3DObject createVertexArrayOES();
+    virtual void deleteVertexArrayOES(Platform3DObject);
+    virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
+    virtual void bindVertexArrayOES(Platform3DObject);
 
 private:
     // This class only needs to be instantiated by GraphicsContext3D implementations.
index 17761ea..0ce9ed2 100644 (file)
@@ -1,3 +1,18 @@
+2011-02-18  Ben Vanik  <benvanik@google.com>
+
+        Reviewed by Kenneth Russell.
+
+        Bug 53940: Implement the OES_vertex_array_object WebGL extension
+        https://bugs.webkit.org/show_bug.cgi?id=53940
+
+        Stubbed out methods for the new OES_vertex_array_object methods.
+
+        * src/Extensions3DChromium.cpp:
+        (WebCore::Extensions3DChromium::createVertexArrayOES):
+        (WebCore::Extensions3DChromium::deleteVertexArrayOES):
+        (WebCore::Extensions3DChromium::isVertexArrayOES):
+        (WebCore::Extensions3DChromium::bindVertexArrayOES):
+
 2011-02-17  Yuzo Fujishima  <yuzo@google.com>
 
         Reviewed by Shinichiro Hamaji.
index 52c2e12..30101c7 100644 (file)
@@ -97,6 +97,24 @@ void Extensions3DChromium::copyTextureToParentTextureCHROMIUM(unsigned texture,
     m_internal->copyTextureToParentTextureCHROMIUM(texture, parentTexture);
 }
 
+Platform3DObject Extensions3DChromium::createVertexArrayOES()
+{
+    return 0;
+}
+
+void Extensions3DChromium::deleteVertexArrayOES(Platform3DObject)
+{
+}
+
+GC3Dboolean Extensions3DChromium::isVertexArrayOES(Platform3DObject)
+{
+    return 0;
+}
+
+void Extensions3DChromium::bindVertexArrayOES(Platform3DObject)
+{
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)