[WebGL2] Vertex Array Objects.
authorroger_fong@apple.com <roger_fong@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Mar 2015 19:03:26 +0000 (19:03 +0000)
committerroger_fong@apple.com <roger_fong@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Mar 2015 19:03:26 +0000 (19:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126944.
<rdar://problem/15002455>
Reviewed by Dean Jackson.
Tested by a modified version of the 1.0.3 conformance test:
conformance/extensions/oes-vertex-array-object.html
This test will be landed along with other modified extension conformance tests
once approval from Khronos is received.
* html/canvas/OESVertexArrayObject.cpp: Associate extension calls only with WebGLRenderingContext.
(WebCore::OESVertexArrayObject::deleteVertexArrayOES):
(WebCore::OESVertexArrayObject::bindVertexArrayOES):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::initializeVertexArrayObjects):
(WebCore::WebGLRenderingContext::getParameter):
* html/canvas/WebGL2RenderingContext.cpp: Implement vertex array object calls as part WebGL2 context.
(WebCore::WebGL2RenderingContext::createVertexArray):
(WebCore::WebGL2RenderingContext::deleteVertexArray):
(WebCore::WebGL2RenderingContext::isVertexArray):
(WebCore::WebGL2RenderingContext::bindVertexArray):
(WebCore::WebGL2RenderingContext::initializeVertexArrayObjects):
(WebCore::WebGL2RenderingContext::getParameter):
Duplicate extension object vertex array object extension methods in GraphicsContext3D.
Implementation may change after we upgrade to newer GL headers and profile.
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::createVertexArray):
(WebCore::GraphicsContext3D::deleteVertexArray):
(WebCore::GraphicsContext3D::isVertexArray):
(WebCore::GraphicsContext3D::bindVertexArray):
Have WebGLVertexArrayObjectOES and WebGLVertexArrayObject inherit from WebGLRenderingContextBase.
* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* html/canvas/WebGLVertexArrayObject.cpp:
(WebCore::WebGLVertexArrayObject::create):
(WebCore::WebGLVertexArrayObject::WebGLVertexArrayObject): Use GraphicsContext3D implementation of createVertexArray.
(WebCore::WebGLVertexArrayObject::deleteObjectImpl):
* html/canvas/WebGLVertexArrayObject.h:
* html/canvas/WebGLVertexArrayObjectBase.cpp: Added.
(WebCore::WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase):
(WebCore::WebGLVertexArrayObjectBase::setElementArrayBuffer):
(WebCore::WebGLVertexArrayObjectBase::setVertexAttribState):
(WebCore::WebGLVertexArrayObjectBase::unbindBuffer):
(WebCore::WebGLVertexArrayObjectBase::setVertexAttribDivisor):
* html/canvas/WebGLVertexArrayObjectBase.h: Added.
(WebCore::WebGLVertexArrayObjectBase::~WebGLVertexArrayObjectBase):
(WebCore::WebGLVertexArrayObjectBase::VertexAttribState::VertexAttribState):
(WebCore::WebGLVertexArrayObjectBase::VertexAttribState::isBound):
(WebCore::WebGLVertexArrayObjectBase::VertexAttribState::validateBinding):
(WebCore::WebGLVertexArrayObjectBase::isDefaultObject):
(WebCore::WebGLVertexArrayObjectBase::hasEverBeenBound):
(WebCore::WebGLVertexArrayObjectBase::setHasEverBeenBound):
(WebCore::WebGLVertexArrayObjectBase::getElementArrayBuffer):
(WebCore::WebGLVertexArrayObjectBase::getVertexAttribState):
* html/canvas/WebGLVertexArrayObjectOES.cpp:
(WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES):
(WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
(WebCore::WebGLVertexArrayObjectOES::setElementArrayBuffer): Deleted.
(WebCore::WebGLVertexArrayObjectOES::setVertexAttribState): Deleted.
(WebCore::WebGLVertexArrayObjectOES::unbindBuffer): Deleted.
(WebCore::WebGLVertexArrayObjectOES::setVertexAttribDivisor): Deleted.
* html/canvas/WebGLVertexArrayObjectOES.h:
* html/canvas/WebGLRenderingContextBase.cpp: Use WebGLVertexArrayObjectBase class.
(WebCore::WebGLRenderingContextBase::initializeNewContext):
(WebCore::WebGLRenderingContextBase::disableVertexAttribArray):
(WebCore::WebGLRenderingContextBase::validateVertexAttributes):
(WebCore::WebGLRenderingContextBase::enableVertexAttribArray):
(WebCore::WebGLRenderingContextBase::getVertexAttrib):
(WebCore::WebGLRenderingContextBase::initVertexAttrib0):
(WebCore::WebGLRenderingContextBase::simulateVertexAttrib0):
(WebCore::WebGLRenderingContextBase::restoreStatesAfterVertexAttrib0Simulation):
* html/canvas/WebGLRenderingContextBase.h:
(WebCore::WebGLRenderingContextBase::setBoundVertexArrayObject):
Handle construction of WebGLGetInfo using WebGLVertexArrayObject.
* bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
(WebCore::toJS):
* html/canvas/WebGLGetInfo.cpp:
(WebCore::WebGLGetInfo::WebGLGetInfo):
(WebCore::WebGLGetInfo::getWebGLVertexArrayObjectOES):
(WebCore::WebGLGetInfo::getWebGLVertexArrayObject):
* html/canvas/WebGLGetInfo.h:

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

23 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp
Source/WebCore/html/canvas/OESVertexArrayObject.cpp
Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Source/WebCore/html/canvas/WebGL2RenderingContext.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/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/html/canvas/WebGLVertexArrayObject.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObject.h
Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.h [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp
Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

index d8c6020..15bf9a3 100644 (file)
@@ -1719,6 +1719,7 @@ set(WebCore_SOURCES
     html/canvas/WebGLTransformFeedback.cpp
     html/canvas/WebGLUniformLocation.cpp
     html/canvas/WebGLVertexArrayObject.cpp
+    html/canvas/WebGLVertexArrayObjectBase.cpp
     html/canvas/WebGLVertexArrayObjectOES.cpp
 
     html/forms/FileIconLoader.cpp
@@ -2824,6 +2825,7 @@ if (ENABLE_WEBGL)
         html/canvas/WebGLTransformFeedback.cpp
         html/canvas/WebGLUniformLocation.cpp
         html/canvas/WebGLVertexArrayObject.cpp
+        html/canvas/WebGLVertexArrayObjectBase.cpp
         html/canvas/WebGLVertexArrayObjectOES.cpp
     )
     list(APPEND WebCore_IDL_FILES
index 8b4ac9a..dcf252e 100644 (file)
@@ -1,3 +1,93 @@
+2015-03-15  Roger Fong  <roger_fong@apple.com>
+
+        [WebGL2] Vertex Array Objects.
+        https://bugs.webkit.org/show_bug.cgi?id=126944.
+        <rdar://problem/15002455>
+
+        Reviewed by Dean Jackson.
+
+        Tested by a modified version of the 1.0.3 conformance test:
+        conformance/extensions/oes-vertex-array-object.html
+        This test will be landed along with other modified extension conformance tests
+        once approval from Khronos is received.
+
+        * html/canvas/OESVertexArrayObject.cpp: Associate extension calls only with WebGLRenderingContext.
+        (WebCore::OESVertexArrayObject::deleteVertexArrayOES):
+        (WebCore::OESVertexArrayObject::bindVertexArrayOES):
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::initializeVertexArrayObjects):
+        (WebCore::WebGLRenderingContext::getParameter):
+        * html/canvas/WebGL2RenderingContext.cpp: Implement vertex array object calls as part WebGL2 context.
+        (WebCore::WebGL2RenderingContext::createVertexArray):
+        (WebCore::WebGL2RenderingContext::deleteVertexArray):
+        (WebCore::WebGL2RenderingContext::isVertexArray):
+        (WebCore::WebGL2RenderingContext::bindVertexArray):
+        (WebCore::WebGL2RenderingContext::initializeVertexArrayObjects):
+        (WebCore::WebGL2RenderingContext::getParameter):
+
+        Duplicate extension object vertex array object extension methods in GraphicsContext3D.
+        Implementation may change after we upgrade to newer GL headers and profile.
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::createVertexArray):
+        (WebCore::GraphicsContext3D::deleteVertexArray):
+        (WebCore::GraphicsContext3D::isVertexArray):
+        (WebCore::GraphicsContext3D::bindVertexArray):
+
+        Have WebGLVertexArrayObjectOES and WebGLVertexArrayObject inherit from WebGLRenderingContextBase.
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/canvas/WebGLVertexArrayObject.cpp:
+        (WebCore::WebGLVertexArrayObject::create):
+        (WebCore::WebGLVertexArrayObject::WebGLVertexArrayObject): Use GraphicsContext3D implementation of createVertexArray.
+        (WebCore::WebGLVertexArrayObject::deleteObjectImpl):
+        * html/canvas/WebGLVertexArrayObject.h:
+        * html/canvas/WebGLVertexArrayObjectBase.cpp: Added.
+        (WebCore::WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase):
+        (WebCore::WebGLVertexArrayObjectBase::setElementArrayBuffer):
+        (WebCore::WebGLVertexArrayObjectBase::setVertexAttribState):
+        (WebCore::WebGLVertexArrayObjectBase::unbindBuffer):
+        (WebCore::WebGLVertexArrayObjectBase::setVertexAttribDivisor):
+        * html/canvas/WebGLVertexArrayObjectBase.h: Added.
+        (WebCore::WebGLVertexArrayObjectBase::~WebGLVertexArrayObjectBase):
+        (WebCore::WebGLVertexArrayObjectBase::VertexAttribState::VertexAttribState):
+        (WebCore::WebGLVertexArrayObjectBase::VertexAttribState::isBound):
+        (WebCore::WebGLVertexArrayObjectBase::VertexAttribState::validateBinding):
+        (WebCore::WebGLVertexArrayObjectBase::isDefaultObject):
+        (WebCore::WebGLVertexArrayObjectBase::hasEverBeenBound):
+        (WebCore::WebGLVertexArrayObjectBase::setHasEverBeenBound):
+        (WebCore::WebGLVertexArrayObjectBase::getElementArrayBuffer):
+        (WebCore::WebGLVertexArrayObjectBase::getVertexAttribState):
+        * html/canvas/WebGLVertexArrayObjectOES.cpp:
+        (WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES):
+        (WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
+        (WebCore::WebGLVertexArrayObjectOES::setElementArrayBuffer): Deleted.
+        (WebCore::WebGLVertexArrayObjectOES::setVertexAttribState): Deleted.
+        (WebCore::WebGLVertexArrayObjectOES::unbindBuffer): Deleted.
+        (WebCore::WebGLVertexArrayObjectOES::setVertexAttribDivisor): Deleted.
+        * html/canvas/WebGLVertexArrayObjectOES.h:
+
+        * html/canvas/WebGLRenderingContextBase.cpp: Use WebGLVertexArrayObjectBase class.
+        (WebCore::WebGLRenderingContextBase::initializeNewContext):
+        (WebCore::WebGLRenderingContextBase::disableVertexAttribArray):
+        (WebCore::WebGLRenderingContextBase::validateVertexAttributes):
+        (WebCore::WebGLRenderingContextBase::enableVertexAttribArray):
+        (WebCore::WebGLRenderingContextBase::getVertexAttrib):
+        (WebCore::WebGLRenderingContextBase::initVertexAttrib0):
+        (WebCore::WebGLRenderingContextBase::simulateVertexAttrib0):
+        (WebCore::WebGLRenderingContextBase::restoreStatesAfterVertexAttrib0Simulation):
+        * html/canvas/WebGLRenderingContextBase.h:
+        (WebCore::WebGLRenderingContextBase::setBoundVertexArrayObject):
+
+        Handle construction of WebGLGetInfo using WebGLVertexArrayObject.
+        * bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
+        (WebCore::toJS):
+        * html/canvas/WebGLGetInfo.cpp:
+        (WebCore::WebGLGetInfo::WebGLGetInfo):
+        (WebCore::WebGLGetInfo::getWebGLVertexArrayObjectOES):
+        (WebCore::WebGLGetInfo::getWebGLVertexArrayObject):
+        * html/canvas/WebGLGetInfo.h:
+
 2015-03-16  Brent Fulgham  <bfulgham@apple.com>
 
         Potentially uninitialized Inspector values
index 51a48fd..33bd1c3 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="DebugSuffix|Win32">
     <ClCompile Include="..\html\canvas\WebGLTransformFeedback.cpp" />
     <ClCompile Include="..\html\canvas\WebGLUniformLocation.cpp" />
     <ClCompile Include="..\html\canvas\WebGLVertexArrayObject.cpp" />
+    <ClCompile Include="..\html\canvas\WebGLVertexArrayObjectBase.cpp" />
     <ClCompile Include="..\html\canvas\WebGLVertexArrayObjectOES.cpp" />
     <ClCompile Include="..\html\track\AudioTrack.cpp" />
     <ClCompile Include="..\html\track\AudioTrackList.cpp" />
     <ClInclude Include="..\html\canvas\WebGLTransformFeedback.h" />
     <ClInclude Include="..\html\canvas\WebGLUniformLocation.h" />
     <ClInclude Include="..\html\canvas\WebGLVertexArrayObject.h" />
+    <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectBase.h” />
     <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectOES.h" />
     <ClInclude Include="..\html\track\AudioTrack.h" />
     <ClInclude Include="..\html\track\AudioTrackList.h" />
index a846b22..76d844f 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="DerivedSources">
     <ClCompile Include="..\html\canvas\WebGLTransformFeedback.cpp">
       <Filter>html\canvas</Filter>
     </ClCompile>
+    <ClCompile Include="..\html\canvas\WebGLVertexArrayObjectBase.cpp">
+      <Filter>html\canvas</Filter>
+    </ClCompile>
     <ClCompile Include="..\html\canvas\WebGLVertexArrayObject.cpp">
       <Filter>html\canvas</Filter>
     </ClCompile>
     <ClInclude Include="..\html\canvas\WebGLVertexArrayObject.h">
       <Filter>html\canvas</Filter>
     </ClInclude>
+    <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectBase.h”>
+      <Filter>html\canvas</Filter>
+    </ClInclude>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSWebGLQuery.h">
       <Filter>DerivedSources</Filter>
     </ClInclude>
index 300201a..8625316 100644 (file)
                6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED8C378183BFF8C009E53BD /* BoxShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */; };
                6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
+               6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */; };
                6F995A151A70756200A735F4 /* WebGLSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F995A131A70756200A735F4 /* WebGLSync.cpp */; };
                6F995A161A70756200A735F4 /* WebGLSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A141A70756200A735F4 /* WebGLSync.h */; };
                6F995A1F1A7078B100A735F4 /* WebGLQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F995A171A7078B100A735F4 /* WebGLQuery.cpp */; };
                6ED8C378183BFF8C009E53BD /* BoxShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoxShape.h; sourceTree = "<group>"; };
                6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
                6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
+               6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebGLVertexArrayObjectBase.h; path = canvas/WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
+               6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLVertexArrayObjectBase.cpp; path = canvas/WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
                6F995A091A7070E600A735F4 /* WebGLQuery.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLQuery.idl; path = canvas/WebGLQuery.idl; sourceTree = "<group>"; };
                6F995A0A1A7070E600A735F4 /* WebGLSampler.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLSampler.idl; path = canvas/WebGLSampler.idl; sourceTree = "<group>"; };
                6F995A0B1A7070E600A735F4 /* WebGLSync.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLSync.idl; path = canvas/WebGLSync.idl; sourceTree = "<group>"; };
                                0C3F1F5910C8871200D72CE1 /* WebGLUniformLocation.idl */,
                                6F995A1D1A7078B100A735F4 /* WebGLVertexArrayObject.cpp */,
                                6F995A1E1A7078B100A735F4 /* WebGLVertexArrayObject.h */,
+                               6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */,
+                               6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */,
                                6F995A0D1A7070E600A735F4 /* WebGLVertexArrayObject.idl */,
                                77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */,
                                77A17A7512F28642004E02F6 /* WebGLVertexArrayObjectOES.h */,
                                A8185F3F09765766005826D9 /* DocumentFragment.cpp in Sources */,
                                93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
                                1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */,
+                               6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */,
                                861C2EA413FB4FDD00062ABB /* DocumentLoadTiming.cpp in Sources */,
                                A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */,
                                CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
index 527d953..5d5aa27 100644 (file)
@@ -68,6 +68,7 @@
 #include "JSWebGLShader.h"
 #include "JSWebGLTexture.h"
 #include "JSWebGLUniformLocation.h"
+#include "JSWebGLVertexArrayObject.h"
 #include "JSWebGLVertexArrayObjectOES.h"
 #include "JSWebKitCSSMatrix.h"
 #include "NotImplemented.h"
@@ -92,6 +93,7 @@
 #include "WebGLLoseContext.h"
 #include "WebGLProgram.h"
 #include "WebGLRenderingContextBase.h"
+#include "WebGLVertexArrayObject.h"
 #include "WebGLVertexArrayObjectOES.h"
 #include <runtime/Error.h>
 #include <runtime/JSTypedArrays.h>
@@ -150,6 +152,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebG
         return toJS(exec, globalObject, info.getWebGLUnsignedByteArray());
     case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
         return toJS(exec, globalObject, info.getWebGLUnsignedIntArray());
+    case WebGLGetInfo::kTypeWebGLVertexArrayObject:
+        return toJS(exec, globalObject, info.getWebGLVertexArrayObject());
     case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
         return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
     default:
index f90def8..16aa8d7 100644 (file)
@@ -30,6 +30,7 @@
 #include "OESVertexArrayObject.h"
 
 #include "Extensions3D.h"
+#include "WebGLRenderingContext.h"
 
 namespace WebCore {
 
@@ -52,7 +53,7 @@ PassRefPtr<WebGLVertexArrayObjectOES> OESVertexArrayObject::createVertexArrayOES
     if (m_context->isContextLost())
         return 0;
     
-    RefPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VaoTypeUser);
+    RefPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VAOTypeUser);
     m_context->addContextObject(o.get());
     return o.release();
 }
@@ -62,8 +63,8 @@ void OESVertexArrayObject::deleteVertexArrayOES(WebGLVertexArrayObjectOES* array
     if (!arrayObject || m_context->isContextLost())
         return;
     
-    if (!arrayObject->isDefaultObject() && arrayObject == m_context->m_boundVertexArrayObject)
-        m_context->setBoundVertexArrayObject(0);
+    if (!arrayObject->isDefaultObject() && arrayObject == static_cast<WebGLRenderingContext*>(m_context)->m_boundVertexArrayObject)
+        static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(0);
 
     arrayObject->deleteObject(m_context->graphicsContext3D());
 }
@@ -96,10 +97,10 @@ void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayOb
         extensions->bindVertexArrayOES(arrayObject->object());
         
         arrayObject->setHasEverBeenBound();
-        m_context->setBoundVertexArrayObject(arrayObject);
+        static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(arrayObject);
     } else {
         extensions->bindVertexArrayOES(0);
-        m_context->setBoundVertexArrayObject(0);
+        static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(0);
     }
 }
 
index 5af257e..093a37e 100644 (file)
@@ -60,13 +60,22 @@ namespace WebCore {
 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, GraphicsContext3D::Attributes attributes)
     : WebGLRenderingContextBase(passedCanvas, attributes)
 {
-    initializeShaderExtensions();
 }
 
 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
     GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, context, attributes)
 {
     initializeShaderExtensions();
+    initializeVertexArrayObjects();
+}
+
+void WebGL2RenderingContext::initializeVertexArrayObjects()
+{
+    m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVertexArrayObject::VAOTypeDefault);
+    addContextObject(m_defaultVertexArrayObject.get());
+    m_boundVertexArrayObject = m_defaultVertexArrayObject;
+    if (!isGLES2Compliant())
+        initVertexAttrib0();
 }
 
 void WebGL2RenderingContext::initializeShaderExtensions()
@@ -768,23 +777,57 @@ void WebGL2RenderingContext::uniformBlockBinding(WebGLProgram* program, GC3Duint
 
 PassRefPtr<WebGLVertexArrayObject> WebGL2RenderingContext::createVertexArray()
 {
-    return nullptr;
+    if (isContextLost())
+        return 0;
+    
+    RefPtr<WebGLVertexArrayObject> o = WebGLVertexArrayObject::create(this, WebGLVertexArrayObject::VAOTypeUser);
+    addContextObject(o.get());
+    return o.release();
 }
 
-void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* vertexArray)
+void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* arrayObject)
 {
-    UNUSED_PARAM(vertexArray);
+    if (!arrayObject || isContextLost())
+        return;
+    
+    if (arrayObject->isDeleted())
+        return;
+    
+    if (!arrayObject->isDefaultObject() && arrayObject == m_boundVertexArrayObject)
+        setBoundVertexArrayObject(0);
+    
+    arrayObject->deleteObject(graphicsContext3D());
 }
 
-GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* vertexArray)
+GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* arrayObject)
 {
-    UNUSED_PARAM(vertexArray);
-    return false;
+    if (!arrayObject || isContextLost())
+        return 0;
+    
+    if (!arrayObject->hasEverBeenBound() || !arrayObject->validate(0, this))
+        return 0;
+    
+    return m_context->isVertexArray(arrayObject->object());
 }
 
-void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* vertexArray)
+void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* arrayObject)
 {
-    UNUSED_PARAM(vertexArray);
+    if (isContextLost())
+        return;
+    
+    if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, this) || !m_contextObjects.contains(arrayObject))) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+        return;
+    }
+    if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
+        m_context->bindVertexArray(arrayObject->object());
+        
+        arrayObject->setHasEverBeenBound();
+        setBoundVertexArrayObject(arrayObject);
+    } else {
+        m_context->bindVertexArray(m_defaultVertexArrayObject->object());
+        setBoundVertexArrayObject(m_defaultVertexArrayObject);
+    }
 }
 
 WebGLExtension* WebGL2RenderingContext::getExtension(const String& name)
@@ -2154,6 +2197,12 @@ WebGLGetInfo WebGL2RenderingContext::getParameter(GC3Denum pname, ExceptionCode&
         return getBooleanParameter(pname);
     case GraphicsContext3D::UNIFORM_BUFFER_OFFSET_ALIGNMENT:
         return getIntParameter(pname);
+    case GraphicsContext3D::VERTEX_ARRAY_BINDING: {
+        if (!m_boundVertexArrayObject->isDefaultObject())
+            return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject>(static_cast<WebGLVertexArrayObject*>(m_boundVertexArrayObject.get())));
+        return WebGLGetInfo();
+        }
+        break;
     case GraphicsContext3D::COPY_READ_BUFFER:
     case GraphicsContext3D::COPY_WRITE_BUFFER:
     case GraphicsContext3D::DRAW_BUFFER0:
@@ -2181,7 +2230,6 @@ WebGLGetInfo WebGL2RenderingContext::getParameter(GC3Denum pname, ExceptionCode&
     case GraphicsContext3D::READ_FRAMEBUFFER_BINDING:
     case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER_BINDING:
     case GraphicsContext3D::UNIFORM_BUFFER_BINDING:
-    case GraphicsContext3D::VERTEX_ARRAY_BINDING:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "parameter name not yet supported");
         return WebGLGetInfo();
     default:
index 7b38f3c..d1e427e 100644 (file)
@@ -189,6 +189,7 @@ public:
 #endif
 
 protected:
+    virtual void initializeVertexArrayObjects() override;
     virtual bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) override;
     virtual bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned& numElements, GC3Dsizei primitiveCount) override;
     virtual bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
index 261038f..7203466 100644 (file)
 
 #include "WebGLGetInfo.h"
 
-#include "WebGLBuffer.h"
-#include "WebGLFramebuffer.h"
-#include "WebGLProgram.h"
-#include "WebGLRenderbuffer.h"
-#include "WebGLTexture.h"
-#include "WebGLVertexArrayObjectOES.h"
 #include <runtime/Float32Array.h>
 #include <runtime/Int32Array.h>
 #include <runtime/Uint32Array.h>
@@ -236,6 +230,17 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value)
     , m_int(0)
     , m_unsignedInt(0)
     , m_int64(0)
+    , m_webglVertexArrayObjectOES(value)
+{
+}
+
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject> value)
+    : m_type(kTypeWebGLVertexArrayObject)
+    , m_bool(false)
+    , m_float(0)
+    , m_int(0)
+    , m_unsignedInt(0)
+    , m_int64(0)
     , m_webglVertexArrayObject(value)
 {
 }
@@ -348,6 +353,12 @@ PassRefPtr<Uint32Array> WebGLGetInfo::getWebGLUnsignedIntArray() const
 PassRefPtr<WebGLVertexArrayObjectOES> WebGLGetInfo::getWebGLVertexArrayObjectOES() const
 {
     ASSERT(getType() == kTypeWebGLVertexArrayObjectOES);
+    return m_webglVertexArrayObjectOES;
+}
+
+PassRefPtr<WebGLVertexArrayObject> WebGLGetInfo::getWebGLVertexArrayObject() const
+{
+    ASSERT(getType() == kTypeWebGLVertexArrayObject);
     return m_webglVertexArrayObject;
 }
 
index b6a9b82..124fd7d 100644 (file)
@@ -32,6 +32,7 @@
 #include "WebGLProgram.h"
 #include "WebGLRenderbuffer.h"
 #include "WebGLTexture.h"
+#include "WebGLVertexArrayObject.h"
 #include "WebGLVertexArrayObjectOES.h"
 #include <runtime/Float32Array.h>
 #include <runtime/Int32Array.h>
@@ -70,6 +71,7 @@ public:
         kTypeWebGLUnsignedByteArray,
         kTypeWebGLUnsignedIntArray,
         kTypeWebGLVertexArrayObjectOES,
+        kTypeWebGLVertexArrayObject,
     };
 
     explicit WebGLGetInfo(bool value);
@@ -93,6 +95,7 @@ public:
     explicit WebGLGetInfo(PassRefPtr<Uint8Array> value);
     explicit WebGLGetInfo(PassRefPtr<Uint32Array> value);
     explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value);
+    explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject> value);
 
     ~WebGLGetInfo();
 
@@ -117,6 +120,7 @@ public:
     PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
     PassRefPtr<Uint32Array> getWebGLUnsignedIntArray() const;
     PassRefPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const;
+    PassRefPtr<WebGLVertexArrayObject> getWebGLVertexArrayObject() const;
 
 private:
     Type m_type;
@@ -138,7 +142,8 @@ private:
     RefPtr<WebGLTexture> m_webglTexture;
     RefPtr<Uint8Array> m_webglUnsignedByteArray;
     RefPtr<Uint32Array> m_webglUnsignedIntArray;
-    RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObject;
+    RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObjectOES;
+    RefPtr<WebGLVertexArrayObject> m_webglVertexArrayObject;
 };
 
 } // namespace WebCore
index 9cebeb6..4e15c19 100644 (file)
@@ -56,6 +56,7 @@
 #include "WebGLDepthTexture.h"
 #include "WebGLDrawBuffers.h"
 #include "WebGLLoseContext.h"
+#include "WebGLVertexArrayObjectOES.h"
 
 namespace WebCore {
 
@@ -67,8 +68,17 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Gr
 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
     GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, context, attributes)
 {
+    initializeVertexArrayObjects();
 }
 
+void WebGLRenderingContext::initializeVertexArrayObjects()
+{
+    m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVertexArrayObjectOES::VAOTypeDefault);
+    addContextObject(m_defaultVertexArrayObject.get());
+    m_boundVertexArrayObject = m_defaultVertexArrayObject;
+    if (!isGLES2Compliant())
+        initVertexAttrib0();
+}
 
 WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
 {
@@ -1067,7 +1077,7 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&
     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(PassRefPtr<WebGLVertexArrayObjectOES>(static_cast<WebGLVertexArrayObjectOES*>(m_boundVertexArrayObject.get())));
             return WebGLGetInfo();
         }
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, OES_vertex_array_object not enabled");
index 65f2b51..51f4253 100644 (file)
@@ -61,6 +61,7 @@ public:
 #endif
 
 protected:
+    virtual void initializeVertexArrayObjects() override;
     virtual bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) override;
     virtual bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned& numElements, GC3Dsizei primitiveCount) override;
     virtual bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
index 22748f7..006078f 100644 (file)
@@ -529,17 +529,11 @@ void WebGLRenderingContextBase::initializeNewContext()
     m_backDrawBuffer = GraphicsContext3D::BACK;
     m_drawBuffersWebGLRequirementsChecked = false;
     m_drawBuffersSupported = false;
-
-    m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVertexArrayObjectOES::VaoTypeDefault);
-    addContextObject(m_defaultVertexArrayObject.get());
-    m_boundVertexArrayObject = m_defaultVertexArrayObject;
     
     m_vertexAttribValue.resize(m_maxVertexAttribs);
 
     if (!isGLES2NPOTStrict())
         createFallbackBlackTextures1x1();
-    if (!isGLES2Compliant())
-        initVertexAttrib0();
 
     IntSize canvasSize = clampedCanvasSize();
     m_context->reshape(canvasSize.width(), canvasSize.height());
@@ -1600,7 +1594,7 @@ void WebGLRenderingContextBase::disableVertexAttribArray(GC3Duint index, Excepti
         return;
     }
 
-    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
+    WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
     state.enabled = false;
 
     if (index > 0 || isGLES2Compliant())
@@ -1722,7 +1716,7 @@ bool WebGLRenderingContextBase::validateVertexAttributes(unsigned elementCount,
     for (int i = 0; i < numActiveAttribLocations; ++i) {
         int loc = m_currentProgram->getActiveAttribLocation(i);
         if (loc >= 0 && loc < static_cast<int>(m_maxVertexAttribs)) {
-            const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(loc);
+            const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(loc);
             if (state.enabled) {
                 sawEnabledAttrib = true;
                 // Avoid off-by-one errors in numElements computation.
@@ -1891,7 +1885,7 @@ void WebGLRenderingContextBase::enableVertexAttribArray(GC3Duint index, Exceptio
         return;
     }
 
-    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
+    WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
     state.enabled = true;
 
     m_context->enableVertexAttribArray(index);
@@ -2519,7 +2513,7 @@ WebGLGetInfo WebGLRenderingContextBase::getVertexAttrib(GC3Duint index, GC3Denum
         return WebGLGetInfo();
     }
 
-    const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
+    const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
 
     if (m_angleInstancedArrays && pname == GraphicsContext3D::VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)
         return WebGLGetInfo(state.divisor);
@@ -4600,7 +4594,7 @@ void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GC3
 
 void WebGLRenderingContextBase::initVertexAttrib0()
 {
-    WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
+    WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
     
     m_vertexAttrib0Buffer = createBuffer();
     m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_vertexAttrib0Buffer->object());
@@ -4620,7 +4614,7 @@ void WebGLRenderingContextBase::initVertexAttrib0()
 
 bool WebGLRenderingContextBase::simulateVertexAttrib0(GC3Dsizei numVertex)
 {
-    const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
+    const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
     const VertexAttribValue& attribValue = m_vertexAttribValue[0];
     if (!m_currentProgram)
         return false;
@@ -4665,7 +4659,7 @@ bool WebGLRenderingContextBase::simulateVertexAttrib0(GC3Dsizei numVertex)
 
 void WebGLRenderingContextBase::restoreStatesAfterVertexAttrib0Simulation()
 {
-    const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
+    const WebGLVertexArrayObjectBase::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);
@@ -4755,6 +4749,7 @@ void WebGLRenderingContextBase::maybeRestoreContext()
     m_contextLost = false;
     setupFlags();
     initializeNewContext();
+    initializeVertexArrayObjects();
     canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, ""));
 }
 
index d0d9a9a..b4688ee 100644 (file)
@@ -373,8 +373,11 @@ protected:
     friend class WebGLCompressedTextureS3TC;
     friend class WebGLRenderingContextErrorMessageCallback;
     friend class WebGLVertexArrayObjectOES;
+    friend class WebGLVertexArrayObject;
+    friend class WebGLVertexArrayObjectBase;
 
     virtual void initializeNewContext();
+    virtual void initializeVertexArrayObjects() = 0;
     void setupFlags();
 
     // ActiveDOMObject
@@ -447,10 +450,10 @@ protected:
 
     // 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<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
-    RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
-    void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayObject)
+
+    RefPtr<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
+    RefPtr<WebGLVertexArrayObjectBase> m_boundVertexArrayObject;
+    void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectBase> arrayObject)
     {
         if (arrayObject)
             m_boundVertexArrayObject = arrayObject;
index 9bb54d1..284c709 100644 (file)
 #if ENABLE(WEBGL)
 #include "WebGLVertexArrayObject.h"
 
+#include "WebGL2RenderingContext.h"
 #include "WebGLContextGroup.h"
-#include "WebGLRenderingContextBase.h"
 
 namespace WebCore {
     
-PassRefPtr<WebGLVertexArrayObject> WebGLVertexArrayObject::create(WebGLRenderingContextBase* ctx)
+PassRefPtr<WebGLVertexArrayObject> WebGLVertexArrayObject::create(WebGLRenderingContextBase* ctx, VAOType type)
 {
-    return adoptRef(new WebGLVertexArrayObject(ctx));
+    return adoptRef(new WebGLVertexArrayObject(ctx, type));
 }
 
 WebGLVertexArrayObject::~WebGLVertexArrayObject()
@@ -43,17 +43,36 @@ WebGLVertexArrayObject::~WebGLVertexArrayObject()
     deleteObject(0);
 }
 
-WebGLVertexArrayObject::WebGLVertexArrayObject(WebGLRenderingContextBase* ctx)
-    : WebGLSharedObject(ctx)
+WebGLVertexArrayObject::WebGLVertexArrayObject(WebGLRenderingContextBase* ctx, VAOType type)
+    : WebGLVertexArrayObjectBase(ctx, type)
 {
-    // FIXME: Call createVertexArray from GraphicsContext3D.
+    switch (m_type) {
+    case VAOTypeDefault:
+        break;
+    default:
+        setObject(context()->graphicsContext3D()->createVertexArray());
+        break;
+    }
 }
 
 void WebGLVertexArrayObject::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
 {
-    UNUSED_PARAM(context3d);
-    UNUSED_PARAM(object);
-    // FIXME: Call deleteVertexArray from GraphicsContext3D.
+    switch (m_type) {
+    case VAOTypeDefault:
+        break;
+    default:
+        context3d->deleteVertexArray(object);
+        break;
+    }
+    
+    if (m_boundElementArrayBuffer)
+        m_boundElementArrayBuffer->onDetached(context3d);
+    
+    for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
+        VertexAttribState& state = m_vertexAttribState[i];
+        if (state.bufferBinding)
+            state.bufferBinding->onDetached(context3d);
+    }
 }
 
 }
index 3c88053..1f130a3 100644 (file)
 #ifndef WebGLVertexArrayObject_h
 #define WebGLVertexArrayObject_h
 
-#include "WebGLSharedObject.h"
+#include "WebGLBuffer.h"
+#include "WebGLContextObject.h"
+#include "WebGLVertexArrayObjectBase.h"
 
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-class WebGLVertexArrayObject final : public WebGLSharedObject {
+class WebGL2RenderingContext;
+
+class WebGLVertexArrayObject final : public WebGLVertexArrayObjectBase {
 public:
+    static PassRefPtr<WebGLVertexArrayObject> create(WebGLRenderingContextBase*, VAOType);
     virtual ~WebGLVertexArrayObject();
-
-    static PassRefPtr<WebGLVertexArrayObject> create(WebGLRenderingContextBase*);
-
-protected:
-    WebGLVertexArrayObject(WebGLRenderingContextBase*);
-
-    virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
-
 private:
-    virtual bool isTransformFeedback() const override { return true; }
+    WebGLVertexArrayObject(WebGLRenderingContextBase*, VAOType);
+    bool isTransformFeedback() const { return true; }
+    virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.cpp b/Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.cpp
new file mode 100644 (file)
index 0000000..f6d8da6
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2015 Apple 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 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 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 "WebGLVertexArrayObjectBase.h"
+
+#include "WebGLRenderingContextBase.h"
+
+namespace WebCore {
+
+WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase* ctx, VAOType type)
+    : WebGLContextObject(ctx)
+    , m_type(type)
+    , m_hasEverBeenBound(false)
+    , m_boundElementArrayBuffer(0)
+{
+    m_vertexAttribState.resize(ctx->getMaxVertexAttribs());
+}
+
+void WebGLVertexArrayObjectBase::setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer)
+{
+    if (buffer)
+        buffer->onAttached();
+    if (m_boundElementArrayBuffer)
+        m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
+    m_boundElementArrayBuffer = buffer;
+    
+}
+
+void WebGLVertexArrayObjectBase::setVertexAttribState(GC3Duint index, GC3Dsizei bytesPerElement, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, PassRefPtr<WebGLBuffer> buffer)
+{
+    GC3Dsizei validatedStride = stride ? stride : bytesPerElement;
+    
+    VertexAttribState& state = m_vertexAttribState[index];
+    
+    if (buffer)
+        buffer->onAttached();
+    if (state.bufferBinding)
+        state.bufferBinding->onDetached(context()->graphicsContext3D());
+    
+    state.bufferBinding = buffer;
+    state.bytesPerElement = bytesPerElement;
+    state.size = size;
+    state.type = type;
+    state.normalized = normalized;
+    state.stride = validatedStride;
+    state.originalStride = stride;
+    state.offset = offset;
+}
+
+void WebGLVertexArrayObjectBase::unbindBuffer(PassRefPtr<WebGLBuffer> buffer)
+{
+    if (m_boundElementArrayBuffer == buffer) {
+        m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
+        m_boundElementArrayBuffer = 0;
+    }
+    
+    for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
+        VertexAttribState& state = m_vertexAttribState[i];
+        if (state.bufferBinding == buffer) {
+            buffer->onDetached(context()->graphicsContext3D());
+            
+            if (!i && !context()->isGLES2Compliant()) {
+                state.bufferBinding = context()->m_vertexAttrib0Buffer;
+                state.bufferBinding->onAttached();
+                state.bytesPerElement = 0;
+                state.size = 4;
+                state.type = GraphicsContext3D::FLOAT;
+                state.normalized = false;
+                state.stride = 16;
+                state.originalStride = 0;
+                state.offset = 0;
+            } else
+                state.bufferBinding = 0;
+        }
+    }
+}
+
+void WebGLVertexArrayObjectBase::setVertexAttribDivisor(GC3Duint index, GC3Duint divisor)
+{
+    VertexAttribState& state = m_vertexAttribState[index];
+    state.divisor = divisor;
+}
+    
+}
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.h b/Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.h
new file mode 100644 (file)
index 0000000..4030409
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2015 Apple 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 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 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 WebGLVertexArrayObjectBase_h
+#define WebGLVertexArrayObjectBase_h
+
+#include "WebGLBuffer.h"
+#include "WebGLContextObject.h"
+
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class WebGLVertexArrayObjectBase : public WebGLContextObject {
+public:
+    enum VAOType {
+        VAOTypeDefault,
+        VAOTypeUser,
+    };
+    
+    virtual ~WebGLVertexArrayObjectBase() { }
+
+    // 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)
+            , divisor(0)
+        {
+        }
+        
+        bool isBound() const { return bufferBinding && bufferBinding->object(); }
+        bool validateBinding() const { return !enabled || isBound(); }
+        
+        bool enabled;
+        RefPtr<WebGLBuffer> bufferBinding;
+        GC3Dsizei bytesPerElement;
+        GC3Dint size;
+        GC3Denum type;
+        bool normalized;
+        GC3Dsizei stride;
+        GC3Dsizei originalStride;
+        GC3Dintptr offset;
+        GC3Duint divisor;
+    };
+    
+    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>);
+    
+    VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
+    void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>);
+    void unbindBuffer(PassRefPtr<WebGLBuffer>);
+    
+    void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor);
+
+protected:
+    WebGLVertexArrayObjectBase(WebGLRenderingContextBase*, VAOType);
+    virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) = 0;
+    
+    VAOType m_type;
+    bool m_hasEverBeenBound;
+    RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
+    Vector<VertexAttribState> m_vertexAttribState;
+};
+    
+} // namespace WebCore
+
+#endif // WebGLVertexArrayObjectBase_h
index 797c362..7e757f2 100644 (file)
 
 namespace WebCore {
 
-PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContextBase* ctx, VaoType type)
+PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContextBase* ctx, VAOType type)
 {
     return adoptRef(new WebGLVertexArrayObjectOES(ctx, type));
 }
 
-WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VaoType type)
-    : WebGLContextObject(ctx)
-    , m_type(type)
-    , m_hasEverBeenBound(false)
-    , m_boundElementArrayBuffer(0)
+WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VAOType type)
+    : WebGLVertexArrayObjectBase(ctx, type)
 {
-    m_vertexAttribState.resize(ctx->getMaxVertexAttribs());
-    
     Extensions3D* extensions = context()->graphicsContext3D()->getExtensions();
     switch (m_type) {
-    case VaoTypeDefault:
+    case VAOTypeDefault:
         break;
     default:
         setObject(extensions->createVertexArrayOES());
@@ -66,7 +61,7 @@ void WebGLVertexArrayObjectOES::deleteObjectImpl(GraphicsContext3D* context3d, P
 {
     Extensions3D* extensions = context3d->getExtensions();
     switch (m_type) {
-    case VaoTypeDefault:
+    case VAOTypeDefault:
         break;
     default:
         extensions->deleteVertexArrayOES(object);
@@ -82,73 +77,6 @@ void WebGLVertexArrayObjectOES::deleteObjectImpl(GraphicsContext3D* context3d, P
             state.bufferBinding->onDetached(context3d);
     }
 }
-
-void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer)
-{
-    if (buffer)
-        buffer->onAttached();
-    if (m_boundElementArrayBuffer)
-        m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
-    m_boundElementArrayBuffer = buffer;
-    
-}
-
-void WebGLVertexArrayObjectOES::setVertexAttribState(
-    GC3Duint index, GC3Dsizei bytesPerElement, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, PassRefPtr<WebGLBuffer> buffer)
-{
-    GC3Dsizei validatedStride = stride ? stride : bytesPerElement;
-
-    VertexAttribState& state = m_vertexAttribState[index];
-
-    if (buffer)
-        buffer->onAttached();
-    if (state.bufferBinding)
-        state.bufferBinding->onDetached(context()->graphicsContext3D());
-
-    state.bufferBinding = buffer;
-    state.bytesPerElement = bytesPerElement;
-    state.size = size;
-    state.type = type;
-    state.normalized = normalized;
-    state.stride = validatedStride;
-    state.originalStride = stride;
-    state.offset = offset;
-}
-
-void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer)
-{
-    if (m_boundElementArrayBuffer == buffer) {
-        m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
-        m_boundElementArrayBuffer = 0;
-    }
-
-    for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
-        VertexAttribState& state = m_vertexAttribState[i];
-        if (state.bufferBinding == buffer) {
-            buffer->onDetached(context()->graphicsContext3D());
-
-            if (!i && !context()->isGLES2Compliant()) {
-                state.bufferBinding = context()->m_vertexAttrib0Buffer;
-                state.bufferBinding->onAttached();
-                state.bytesPerElement = 0;
-                state.size = 4;
-                state.type = GraphicsContext3D::FLOAT;
-                state.normalized = false;
-                state.stride = 16;
-                state.originalStride = 0;
-                state.offset = 0;
-            } else
-                state.bufferBinding = 0;
-        }
-    }
-}
-
-void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GC3Duint index, GC3Duint divisor)
-{
-    VertexAttribState& state = m_vertexAttribState[index];
-    state.divisor = divisor;
-}
-
 }
 
 #endif // ENABLE(WEBGL)
index 59b11c8..0711ea4 100644 (file)
 
 #include "WebGLBuffer.h"
 #include "WebGLContextObject.h"
+#include "WebGLVertexArrayObjectBase.h"
 
 #include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
-class WebGLVertexArrayObjectOES final : public WebGLContextObject {
+class WebGLVertexArrayObjectOES final : public WebGLVertexArrayObjectBase {
 public:
-    enum VaoType {
-        VaoTypeDefault,
-        VaoTypeUser,
-    };
-    
+    static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBase*, VAOType);
     virtual ~WebGLVertexArrayObjectOES();
-
-    static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBase*, 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)
-            , divisor(0)
-        {
-        }
-        
-        bool isBound() const { return bufferBinding && bufferBinding->object(); }
-        bool validateBinding() const { return !enabled || isBound(); }
-
-        bool enabled;
-        RefPtr<WebGLBuffer> bufferBinding;
-        GC3Dsizei bytesPerElement;
-        GC3Dint size;
-        GC3Denum type;
-        bool normalized;
-        GC3Dsizei stride;
-        GC3Dsizei originalStride;
-        GC3Dintptr offset;
-        GC3Duint divisor;
-    };
-    
-    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>);
-    
-    VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
-    void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>);
-    void unbindBuffer(PassRefPtr<WebGLBuffer>);
-
-    void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor);
-
 private:
-    WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType);
-
+    WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VAOType);
     virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
-    
-    VaoType m_type;
-    bool m_hasEverBeenBound;
-    RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
-    Vector<VertexAttribState> m_vertexAttribState;
 };
 
 } // namespace WebCore
index 5b9a468..70af40f 100644 (file)
@@ -1118,6 +1118,12 @@ public:
     void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount);
     void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
 
+    // VertexArrayOject calls
+    Platform3DObject createVertexArray();
+    void deleteVertexArray(Platform3DObject);
+    GC3Dboolean isVertexArray(Platform3DObject);
+    void bindVertexArray(Platform3DObject);
+
 #if PLATFORM(GTK) || PLATFORM(EFL) || USE(CAIRO)
     void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
                        int canvasWidth, int canvasHeight, PlatformContextCairo* context);
index 642e593..4d7588d 100644 (file)
@@ -1357,6 +1357,57 @@ void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsize
     ::glViewport(x, y, width, height);
 }
 
+Platform3DObject GraphicsContext3D::createVertexArray()
+{
+    makeContextCurrent();
+    GLuint array = 0;
+#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
+    glGenVertexArrays(1, &array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+    glGenVertexArraysAPPLE(1, &array);
+#endif
+    return array;
+}
+
+void GraphicsContext3D::deleteVertexArray(Platform3DObject array)
+{
+    if (!array)
+        return;
+    
+    makeContextCurrent();
+#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
+    glDeleteVertexArrays(1, &array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+    glDeleteVertexArraysAPPLE(1, &array);
+#endif
+}
+
+GC3Dboolean GraphicsContext3D::isVertexArray(Platform3DObject array)
+{
+    if (!array)
+        return GL_FALSE;
+    
+    makeContextCurrent();
+#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
+    return glIsVertexArray(array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+    return glIsVertexArrayAPPLE(array);
+#endif
+    return GL_FALSE;
+}
+
+void GraphicsContext3D::bindVertexArray(Platform3DObject array)
+{
+    makeContextCurrent();
+#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
+    glBindVertexArray(array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+    glBindVertexArrayAPPLE(array);
+#else
+    UNUSED_PARAM(array);
+#endif
+}
+
 void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value)
 {
     makeContextCurrent();