Source/WebCore/ChangeLog

 12015-03-15 Roger Fong <roger_fong@apple.com>
 2
 3 [WebGL2] Vertex Array Objects.
 4 https://bugs.webkit.org/show_bug.cgi?id=126944.
 5 <rdar://problem/15002455>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Tested by a modified version of the 1.0.3 conformance test:
 10 conformance/extensions/oes-vertex-array-object.html
 11 This test will be landed along with other modified extension conformance tests
 12 once approval from Khronos is received.
 13
 14 * html/canvas/OESVertexArrayObject.cpp: Associate extension calls only with WebGLRenderingContext.
 15 (WebCore::OESVertexArrayObject::deleteVertexArrayOES):
 16 (WebCore::OESVertexArrayObject::bindVertexArrayOES):
 17 * html/canvas/WebGLRenderingContext.cpp:
 18 (WebCore::WebGLRenderingContext::initializeVertexArrayObjects):
 19 (WebCore::WebGLRenderingContext::getParameter):
 20 * html/canvas/WebGL2RenderingContext.cpp: Implement vertex array object calls as part WebGL2 context.
 21 (WebCore::WebGL2RenderingContext::createVertexArray):
 22 (WebCore::WebGL2RenderingContext::deleteVertexArray):
 23 (WebCore::WebGL2RenderingContext::isVertexArray):
 24 (WebCore::WebGL2RenderingContext::bindVertexArray):
 25 (WebCore::WebGL2RenderingContext::initializeVertexArrayObjects):
 26 (WebCore::WebGL2RenderingContext::getParameter):
 27
 28 Duplicate extension object vertex array object extension methods in GraphicsContext3D.
 29 Implementation may change after we upgrade to newer GL headers and profile.
 30 * platform/graphics/GraphicsContext3D.h:
 31 * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
 32 (WebCore::GraphicsContext3D::createVertexArray):
 33 (WebCore::GraphicsContext3D::deleteVertexArray):
 34 (WebCore::GraphicsContext3D::isVertexArray):
 35 (WebCore::GraphicsContext3D::bindVertexArray):
 36
 37 Have WebGLVertexArrayObjectOES and WebGLVertexArrayObject inherit from WebGLRenderingContextBase.
 38 * CMakeLists.txt:
 39 * WebCore.xcodeproj/project.pbxproj:
 40 * html/canvas/WebGLVertexArrayObject.cpp:
 41 (WebCore::WebGLVertexArrayObject::create):
 42 (WebCore::WebGLVertexArrayObject::WebGLVertexArrayObject): Use GraphicsContext3D implementation of createVertexArray.
 43 (WebCore::WebGLVertexArrayObject::deleteObjectImpl):
 44 * html/canvas/WebGLVertexArrayObject.h:
 45 * html/canvas/WebGLVertexArrayObjectBase.cpp: Added.
 46 (WebCore::WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase):
 47 (WebCore::WebGLVertexArrayObjectBase::setElementArrayBuffer):
 48 (WebCore::WebGLVertexArrayObjectBase::setVertexAttribState):
 49 (WebCore::WebGLVertexArrayObjectBase::unbindBuffer):
 50 (WebCore::WebGLVertexArrayObjectBase::setVertexAttribDivisor):
 51 * html/canvas/WebGLVertexArrayObjectBase.h: Added.
 52 (WebCore::WebGLVertexArrayObjectBase::~WebGLVertexArrayObjectBase):
 53 (WebCore::WebGLVertexArrayObjectBase::VertexAttribState::VertexAttribState):
 54 (WebCore::WebGLVertexArrayObjectBase::VertexAttribState::isBound):
 55 (WebCore::WebGLVertexArrayObjectBase::VertexAttribState::validateBinding):
 56 (WebCore::WebGLVertexArrayObjectBase::isDefaultObject):
 57 (WebCore::WebGLVertexArrayObjectBase::hasEverBeenBound):
 58 (WebCore::WebGLVertexArrayObjectBase::setHasEverBeenBound):
 59 (WebCore::WebGLVertexArrayObjectBase::getElementArrayBuffer):
 60 (WebCore::WebGLVertexArrayObjectBase::getVertexAttribState):
 61 * html/canvas/WebGLVertexArrayObjectOES.cpp:
 62 (WebCore::WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES):
 63 (WebCore::WebGLVertexArrayObjectOES::deleteObjectImpl):
 64 (WebCore::WebGLVertexArrayObjectOES::setElementArrayBuffer): Deleted.
 65 (WebCore::WebGLVertexArrayObjectOES::setVertexAttribState): Deleted.
 66 (WebCore::WebGLVertexArrayObjectOES::unbindBuffer): Deleted.
 67 (WebCore::WebGLVertexArrayObjectOES::setVertexAttribDivisor): Deleted.
 68 * html/canvas/WebGLVertexArrayObjectOES.h:
 69
 70 * html/canvas/WebGLRenderingContextBase.cpp: Use WebGLVertexArrayObjectBase class.
 71 (WebCore::WebGLRenderingContextBase::initializeNewContext):
 72 (WebCore::WebGLRenderingContextBase::disableVertexAttribArray):
 73 (WebCore::WebGLRenderingContextBase::validateVertexAttributes):
 74 (WebCore::WebGLRenderingContextBase::enableVertexAttribArray):
 75 (WebCore::WebGLRenderingContextBase::getVertexAttrib):
 76 (WebCore::WebGLRenderingContextBase::initVertexAttrib0):
 77 (WebCore::WebGLRenderingContextBase::simulateVertexAttrib0):
 78 (WebCore::WebGLRenderingContextBase::restoreStatesAfterVertexAttrib0Simulation):
 79 * html/canvas/WebGLRenderingContextBase.h:
 80 (WebCore::WebGLRenderingContextBase::setBoundVertexArrayObject):
 81
 82 Handle construction of WebGLGetInfo using WebGLVertexArrayObject.
 83 * bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
 84 (WebCore::toJS):
 85 * html/canvas/WebGLGetInfo.cpp:
 86 (WebCore::WebGLGetInfo::WebGLGetInfo):
 87 (WebCore::WebGLGetInfo::getWebGLVertexArrayObjectOES):
 88 (WebCore::WebGLGetInfo::getWebGLVertexArrayObject):
 89 * html/canvas/WebGLGetInfo.h:
 90
1912015-03-15 Simon Fraser <simon.fraser@apple.com>
292
393 And another fix. Thanks to Hunseop Jeong for the fix.
181520

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
17191719 html/canvas/WebGLTransformFeedback.cpp
17201720 html/canvas/WebGLUniformLocation.cpp
17211721 html/canvas/WebGLVertexArrayObject.cpp
 1722 html/canvas/WebGLVertexArrayObjectBase.cpp
17221723 html/canvas/WebGLVertexArrayObjectOES.cpp
17231724
17241725 html/forms/FileIconLoader.cpp

@@if (ENABLE_WEBGL)
28242825 html/canvas/WebGLTransformFeedback.cpp
28252826 html/canvas/WebGLUniformLocation.cpp
28262827 html/canvas/WebGLVertexArrayObject.cpp
 2828 html/canvas/WebGLVertexArrayObjectBase.cpp
28272829 html/canvas/WebGLVertexArrayObjectOES.cpp
28282830 )
28292831 list(APPEND WebCore_IDL_FILES
181505

Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

1 <?xml version="1.0" encoding="utf-8"?>
 1<?xml version="1.0" encoding="utf-8"?>
22<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33 <ItemGroup Label="ProjectConfigurations">
44 <ProjectConfiguration Include="DebugSuffix|Win32">

66816681 <ClCompile Include="..\html\canvas\WebGLTransformFeedback.cpp" />
66826682 <ClCompile Include="..\html\canvas\WebGLUniformLocation.cpp" />
66836683 <ClCompile Include="..\html\canvas\WebGLVertexArrayObject.cpp" />
 6684 <ClCompile Include="..\html\canvas\WebGLVertexArrayObjectBase.cpp" />
66846685 <ClCompile Include="..\html\canvas\WebGLVertexArrayObjectOES.cpp" />
66856686 <ClCompile Include="..\html\track\AudioTrack.cpp" />
66866687 <ClCompile Include="..\html\track\AudioTrackList.cpp" />

1904119042 <ClInclude Include="..\html\canvas\WebGLTransformFeedback.h" />
1904219043 <ClInclude Include="..\html\canvas\WebGLUniformLocation.h" />
1904319044 <ClInclude Include="..\html\canvas\WebGLVertexArrayObject.h" />
 19045 <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectBase.h” />
1904419046 <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectOES.h" />
1904519047 <ClInclude Include="..\html\track\AudioTrack.h" />
1904619048 <ClInclude Include="..\html\track\AudioTrackList.h" />
181505

Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

1 <?xml version="1.0" encoding="utf-8"?>
 1<?xml version="1.0" encoding="utf-8"?>
22<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33 <ItemGroup>
44 <Filter Include="DerivedSources">

72017201 <ClCompile Include="..\html\canvas\WebGLTransformFeedback.cpp">
72027202 <Filter>html\canvas</Filter>
72037203 </ClCompile>
 7204 <ClCompile Include="..\html\canvas\WebGLVertexArrayObjectBase.cpp">
 7205 <Filter>html\canvas</Filter>
 7206 </ClCompile>
72047207 <ClCompile Include="..\html\canvas\WebGLVertexArrayObject.cpp">
72057208 <Filter>html\canvas</Filter>
72067209 </ClCompile>

1516715170 <ClInclude Include="..\html\canvas\WebGLVertexArrayObject.h">
1516815171 <Filter>html\canvas</Filter>
1516915172 </ClInclude>
 15173 <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectBase.h”>
 15174 <Filter>html\canvas</Filter>
 15175 </ClInclude>
1517015176 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSWebGLQuery.h">
1517115177 <Filter>DerivedSources</Filter>
1517215178 </ClInclude>
181505

Source/WebCore/WebCore.xcodeproj/project.pbxproj

23252325 6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED8C378183BFF8C009E53BD /* BoxShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
23262326 6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */; };
23272327 6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
 2328 6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */; };
23282329 6F995A151A70756200A735F4 /* WebGLSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F995A131A70756200A735F4 /* WebGLSync.cpp */; };
23292330 6F995A161A70756200A735F4 /* WebGLSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A141A70756200A735F4 /* WebGLSync.h */; };
23302331 6F995A1F1A7078B100A735F4 /* WebGLQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F995A171A7078B100A735F4 /* WebGLQuery.cpp */; };

95239524 6ED8C378183BFF8C009E53BD /* BoxShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoxShape.h; sourceTree = "<group>"; };
95249525 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
95259526 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
 9527 6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebGLVertexArrayObjectBase.h; path = canvas/WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
 9528 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLVertexArrayObjectBase.cpp; path = canvas/WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
95269529 6F995A091A7070E600A735F4 /* WebGLQuery.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLQuery.idl; path = canvas/WebGLQuery.idl; sourceTree = "<group>"; };
95279530 6F995A0A1A7070E600A735F4 /* WebGLSampler.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLSampler.idl; path = canvas/WebGLSampler.idl; sourceTree = "<group>"; };
95289531 6F995A0B1A7070E600A735F4 /* WebGLSync.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLSync.idl; path = canvas/WebGLSync.idl; sourceTree = "<group>"; };

1603916042 0C3F1F5910C8871200D72CE1 /* WebGLUniformLocation.idl */,
1604016043 6F995A1D1A7078B100A735F4 /* WebGLVertexArrayObject.cpp */,
1604116044 6F995A1E1A7078B100A735F4 /* WebGLVertexArrayObject.h */,
 16045 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */,
 16046 6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */,
1604216047 6F995A0D1A7070E600A735F4 /* WebGLVertexArrayObject.idl */,
1604316048 77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */,
1604416049 77A17A7512F28642004E02F6 /* WebGLVertexArrayObjectOES.h */,

2773327738 A8185F3F09765766005826D9 /* DocumentFragment.cpp in Sources */,
2773427739 93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
2773527740 1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */,
 27741 6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */,
2773627742 861C2EA413FB4FDD00062ABB /* DocumentLoadTiming.cpp in Sources */,
2773727743 A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */,
2773827744 CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
181505

Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp

6868#include "JSWebGLShader.h"
6969#include "JSWebGLTexture.h"
7070#include "JSWebGLUniformLocation.h"
 71#include "JSWebGLVertexArrayObject.h"
7172#include "JSWebGLVertexArrayObjectOES.h"
7273#include "JSWebKitCSSMatrix.h"
7374#include "NotImplemented.h"

9293#include "WebGLLoseContext.h"
9394#include "WebGLProgram.h"
9495#include "WebGLRenderingContextBase.h"
 96#include "WebGLVertexArrayObject.h"
9597#include "WebGLVertexArrayObjectOES.h"
9698#include <runtime/Error.h>
9799#include <runtime/JSTypedArrays.h>

@@static JSValue toJS(ExecState* exec, JSD
150152 return toJS(exec, globalObject, info.getWebGLUnsignedByteArray());
151153 case WebGLGetInfo::kTypeWebGLUnsignedIntArray:
152154 return toJS(exec, globalObject, info.getWebGLUnsignedIntArray());
 155 case WebGLGetInfo::kTypeWebGLVertexArrayObject:
 156 return toJS(exec, globalObject, info.getWebGLVertexArrayObject());
153157 case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES:
154158 return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES());
155159 default:
181505

Source/WebCore/html/canvas/OESVertexArrayObject.cpp

3030#include "OESVertexArrayObject.h"
3131
3232#include "Extensions3D.h"
 33#include "WebGLRenderingContext.h"
3334
3435namespace WebCore {
3536

@@void OESVertexArrayObject::deleteVertexA
6263 if (!arrayObject || m_context->isContextLost())
6364 return;
6465
65  if (!arrayObject->isDefaultObject() && arrayObject == m_context->m_boundVertexArrayObject)
66  m_context->setBoundVertexArrayObject(0);
 66 if (!arrayObject->isDefaultObject() && arrayObject == static_cast<WebGLRenderingContext*>(m_context)->m_boundVertexArrayObject)
 67 static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(0);
6768
6869 arrayObject->deleteObject(m_context->graphicsContext3D());
6970}

@@void OESVertexArrayObject::bindVertexArr
9697 extensions->bindVertexArrayOES(arrayObject->object());
9798
9899 arrayObject->setHasEverBeenBound();
99  m_context->setBoundVertexArrayObject(arrayObject);
 100 static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(arrayObject);
100101 } else {
101102 extensions->bindVertexArrayOES(0);
102  m_context->setBoundVertexArrayObject(0);
 103 static_cast<WebGLRenderingContext*>(m_context)->setBoundVertexArrayObject(0);
103104 }
104105}
105106
181505

Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

@@namespace WebCore {
6060WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, GraphicsContext3D::Attributes attributes)
6161 : WebGLRenderingContextBase(passedCanvas, attributes)
6262{
63  initializeShaderExtensions();
6463}
6564
6665WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
6766 GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, context, attributes)
6867{
6968 initializeShaderExtensions();
 69 initializeVertexArrayObjects();
 70}
 71
 72void WebGL2RenderingContext::initializeVertexArrayObjects()
 73{
 74 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVertexArrayObject::VaoTypeDefault);
 75 addContextObject(m_defaultVertexArrayObject.get());
 76 m_boundVertexArrayObject = m_defaultVertexArrayObject;
 77 if (!isGLES2Compliant())
 78 initVertexAttrib0();
7079}
7180
7281void WebGL2RenderingContext::initializeShaderExtensions()

@@void WebGL2RenderingContext::uniformBloc
768777
769778PassRefPtr<WebGLVertexArrayObject> WebGL2RenderingContext::createVertexArray()
770779{
771  return nullptr;
 780 if (isContextLost())
 781 return 0;
 782
 783 RefPtr<WebGLVertexArrayObject> o = WebGLVertexArrayObject::create(this, WebGLVertexArrayObject::VaoTypeUser);
 784 addContextObject(o.get());
 785 return o.release();
772786}
773787
774 void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* vertexArray)
 788void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* arrayObject)
775789{
776  UNUSED_PARAM(vertexArray);
 790 if (!arrayObject || isContextLost())
 791 return;
 792
 793 if (arrayObject->isDeleted())
 794 return;
 795
 796 if (!arrayObject->isDefaultObject() && arrayObject == m_boundVertexArrayObject)
 797 setBoundVertexArrayObject(0);
 798
 799 arrayObject->deleteObject(graphicsContext3D());
777800}
778801
779 GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* vertexArray)
 802GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* arrayObject)
780803{
781  UNUSED_PARAM(vertexArray);
782  return false;
 804 if (!arrayObject || isContextLost())
 805 return 0;
 806
 807 if (!arrayObject->hasEverBeenBound() || !arrayObject->validate(0, this))
 808 return 0;
 809
 810 return m_context->isVertexArray(arrayObject->object());
783811}
784812
785 void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* vertexArray)
 813void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* arrayObject)
786814{
787  UNUSED_PARAM(vertexArray);
 815 if (isContextLost())
 816 return;
 817
 818 if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, this) || !m_contextObjects.contains(arrayObject))) {
 819 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
 820 return;
 821 }
 822 if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
 823 m_context->bindVertexArray(arrayObject->object());
 824
 825 arrayObject->setHasEverBeenBound();
 826 setBoundVertexArrayObject(arrayObject);
 827 } else {
 828 m_context->bindVertexArray(m_defaultVertexArrayObject->object());
 829 setBoundVertexArrayObject(m_defaultVertexArrayObject);
 830 }
788831}
789832
790833WebGLExtension* WebGL2RenderingContext::getExtension(const String& name)

@@WebGLGetInfo WebGL2RenderingContext::get
21542197 return getBooleanParameter(pname);
21552198 case GraphicsContext3D::UNIFORM_BUFFER_OFFSET_ALIGNMENT:
21562199 return getIntParameter(pname);
 2200 case GraphicsContext3D::VERTEX_ARRAY_BINDING: {
 2201 if (!m_boundVertexArrayObject->isDefaultObject())
 2202 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject>(static_cast<WebGLVertexArrayObject*>(m_boundVertexArrayObject.get())));
 2203 return WebGLGetInfo();
 2204 }
 2205 break;
21572206 case GraphicsContext3D::COPY_READ_BUFFER:
21582207 case GraphicsContext3D::COPY_WRITE_BUFFER:
21592208 case GraphicsContext3D::DRAW_BUFFER0:

@@WebGLGetInfo WebGL2RenderingContext::get
21812230 case GraphicsContext3D::READ_FRAMEBUFFER_BINDING:
21822231 case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER_BINDING:
21832232 case GraphicsContext3D::UNIFORM_BUFFER_BINDING:
2184  case GraphicsContext3D::VERTEX_ARRAY_BINDING:
21852233 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "parameter name not yet supported");
21862234 return WebGLGetInfo();
21872235 default:
181505

Source/WebCore/html/canvas/WebGL2RenderingContext.h

@@public:
189189#endif
190190
191191protected:
 192 virtual void initializeVertexArrayObjects() override;
192193 virtual bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) override;
193194 virtual bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned& numElements, GC3Dsizei primitiveCount) override;
194195 virtual bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
181505

Source/WebCore/html/canvas/WebGLGetInfo.cpp

3030
3131#include "WebGLGetInfo.h"
3232
33 #include "WebGLBuffer.h"
34 #include "WebGLFramebuffer.h"
35 #include "WebGLProgram.h"
36 #include "WebGLRenderbuffer.h"
37 #include "WebGLTexture.h"
38 #include "WebGLVertexArrayObjectOES.h"
3933#include <runtime/Float32Array.h>
4034#include <runtime/Int32Array.h>
4135#include <runtime/Uint32Array.h>

@@WebGLGetInfo::WebGLGetInfo(PassRefPtr<We
236230 , m_int(0)
237231 , m_unsignedInt(0)
238232 , m_int64(0)
 233 , m_webglVertexArrayObjectOES(value)
 234{
 235}
 236
 237WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject> value)
 238 : m_type(kTypeWebGLVertexArrayObject)
 239 , m_bool(false)
 240 , m_float(0)
 241 , m_int(0)
 242 , m_unsignedInt(0)
 243 , m_int64(0)
239244 , m_webglVertexArrayObject(value)
240245{
241246}

@@PassRefPtr<Uint32Array> WebGLGetInfo::ge
348353PassRefPtr<WebGLVertexArrayObjectOES> WebGLGetInfo::getWebGLVertexArrayObjectOES() const
349354{
350355 ASSERT(getType() == kTypeWebGLVertexArrayObjectOES);
 356 return m_webglVertexArrayObjectOES;
 357}
 358
 359PassRefPtr<WebGLVertexArrayObject> WebGLGetInfo::getWebGLVertexArrayObject() const
 360{
 361 ASSERT(getType() == kTypeWebGLVertexArrayObject);
351362 return m_webglVertexArrayObject;
352363}
353364
181505

Source/WebCore/html/canvas/WebGLGetInfo.h

3232#include "WebGLProgram.h"
3333#include "WebGLRenderbuffer.h"
3434#include "WebGLTexture.h"
 35#include "WebGLVertexArrayObject.h"
3536#include "WebGLVertexArrayObjectOES.h"
3637#include <runtime/Float32Array.h>
3738#include <runtime/Int32Array.h>

@@public:
7071 kTypeWebGLUnsignedByteArray,
7172 kTypeWebGLUnsignedIntArray,
7273 kTypeWebGLVertexArrayObjectOES,
 74 kTypeWebGLVertexArrayObject,
7375 };
7476
7577 explicit WebGLGetInfo(bool value);

@@public:
9395 explicit WebGLGetInfo(PassRefPtr<Uint8Array> value);
9496 explicit WebGLGetInfo(PassRefPtr<Uint32Array> value);
9597 explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value);
 98 explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject> value);
9699
97100 ~WebGLGetInfo();
98101

@@public:
117120 PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
118121 PassRefPtr<Uint32Array> getWebGLUnsignedIntArray() const;
119122 PassRefPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const;
 123 PassRefPtr<WebGLVertexArrayObject> getWebGLVertexArrayObject() const;
120124
121125private:
122126 Type m_type;

@@private:
138142 RefPtr<WebGLTexture> m_webglTexture;
139143 RefPtr<Uint8Array> m_webglUnsignedByteArray;
140144 RefPtr<Uint32Array> m_webglUnsignedIntArray;
141  RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObject;
 145 RefPtr<WebGLVertexArrayObjectOES> m_webglVertexArrayObjectOES;
 146 RefPtr<WebGLVertexArrayObject> m_webglVertexArrayObject;
142147};
143148
144149} // namespace WebCore
181505

Source/WebCore/html/canvas/WebGLRenderingContext.cpp

5656#include "WebGLDepthTexture.h"
5757#include "WebGLDrawBuffers.h"
5858#include "WebGLLoseContext.h"
 59#include "WebGLVertexArrayObjectOES.h"
5960
6061namespace WebCore {
6162

@@WebGLRenderingContext::WebGLRenderingCon
6768WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
6869 GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, context, attributes)
6970{
 71 initializeVertexArrayObjects();
7072}
7173
 74void WebGLRenderingContext::initializeVertexArrayObjects()
 75{
 76 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVertexArrayObjectOES::VaoTypeDefault);
 77 addContextObject(m_defaultVertexArrayObject.get());
 78 m_boundVertexArrayObject = m_defaultVertexArrayObject;
 79 if (!isGLES2Compliant())
 80 initVertexAttrib0();
 81}
7282
7383WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
7484{

@@WebGLGetInfo WebGLRenderingContext::getP
10671077 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
10681078 if (m_oesVertexArrayObject) {
10691079 if (!m_boundVertexArrayObject->isDefaultObject())
1070  return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boundVertexArrayObject));
 1080 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(static_cast<WebGLVertexArrayObjectOES*>(m_boundVertexArrayObject.get())));
10711081 return WebGLGetInfo();
10721082 }
10731083 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, OES_vertex_array_object not enabled");
181505

Source/WebCore/html/canvas/WebGLRenderingContext.h

@@public:
6161#endif
6262
6363protected:
 64 virtual void initializeVertexArrayObjects() override;
6465 virtual bool validateIndexArrayConservative(GC3Denum type, unsigned& numElementsRequired) override;
6566 virtual bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned& numElements, GC3Dsizei primitiveCount) override;
6667 virtual bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
181505

Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

@@void WebGLRenderingContextBase::initiali
529529 m_backDrawBuffer = GraphicsContext3D::BACK;
530530 m_drawBuffersWebGLRequirementsChecked = false;
531531 m_drawBuffersSupported = false;
532 
533  m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVertexArrayObjectOES::VaoTypeDefault);
534  addContextObject(m_defaultVertexArrayObject.get());
535  m_boundVertexArrayObject = m_defaultVertexArrayObject;
536532
537533 m_vertexAttribValue.resize(m_maxVertexAttribs);
538534
539535 if (!isGLES2NPOTStrict())
540536 createFallbackBlackTextures1x1();
541  if (!isGLES2Compliant())
542  initVertexAttrib0();
543537
544538 IntSize canvasSize = clampedCanvasSize();
545539 m_context->reshape(canvasSize.width(), canvasSize.height());

@@void WebGLRenderingContextBase::disableV
16001594 return;
16011595 }
16021596
1603  WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
 1597 WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
16041598 state.enabled = false;
16051599
16061600 if (index > 0 || isGLES2Compliant())

@@bool WebGLRenderingContextBase::validate
17221716 for (int i = 0; i < numActiveAttribLocations; ++i) {
17231717 int loc = m_currentProgram->getActiveAttribLocation(i);
17241718 if (loc >= 0 && loc < static_cast<int>(m_maxVertexAttribs)) {
1725  const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(loc);
 1719 const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(loc);
17261720 if (state.enabled) {
17271721 sawEnabledAttrib = true;
17281722 // Avoid off-by-one errors in numElements computation.

@@void WebGLRenderingContextBase::enableVe
18911885 return;
18921886 }
18931887
1894  WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
 1888 WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
18951889 state.enabled = true;
18961890
18971891 m_context->enableVertexAttribArray(index);

@@WebGLGetInfo WebGLRenderingContextBase::
25192513 return WebGLGetInfo();
25202514 }
25212515
2522  const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
 2516 const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
25232517
25242518 if (m_angleInstancedArrays && pname == GraphicsContext3D::VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)
25252519 return WebGLGetInfo(state.divisor);

@@void WebGLRenderingContextBase::vertexAt
46004594
46014595void WebGLRenderingContextBase::initVertexAttrib0()
46024596{
4603  WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
 4597 WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
46044598
46054599 m_vertexAttrib0Buffer = createBuffer();
46064600 m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_vertexAttrib0Buffer->object());

@@void WebGLRenderingContextBase::initVert
46204614
46214615bool WebGLRenderingContextBase::simulateVertexAttrib0(GC3Dsizei numVertex)
46224616{
4623  const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
 4617 const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
46244618 const VertexAttribValue& attribValue = m_vertexAttribValue[0];
46254619 if (!m_currentProgram)
46264620 return false;

@@bool WebGLRenderingContextBase::simulate
46654659
46664660void WebGLRenderingContextBase::restoreStatesAfterVertexAttrib0Simulation()
46674661{
4668  const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
 4662 const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
46694663 if (state.bufferBinding != m_vertexAttrib0Buffer) {
46704664 m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, objectOrZero(state.bufferBinding.get()));
46714665 m_context->vertexAttribPointer(0, state.size, state.type, state.normalized, state.originalStride, state.offset);

@@void WebGLRenderingContextBase::maybeRes
47554749 m_contextLost = false;
47564750 setupFlags();
47574751 initializeNewContext();
 4752 initializeVertexArrayObjects();
47584753 canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, ""));
47594754}
47604755
181505

Source/WebCore/html/canvas/WebGLRenderingContextBase.h

@@protected:
373373 friend class WebGLCompressedTextureS3TC;
374374 friend class WebGLRenderingContextErrorMessageCallback;
375375 friend class WebGLVertexArrayObjectOES;
 376 friend class WebGLVertexArrayObject;
 377 friend class WebGLVertexArrayObjectBase;
376378
377379 virtual void initializeNewContext();
 380 virtual void initializeVertexArrayObjects() = 0;
378381 void setupFlags();
379382
380383 // ActiveDOMObject

@@protected:
447450
448451 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER
449452 RefPtr<WebGLBuffer> m_boundArrayBuffer;
450 
451  RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
452  RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
453  void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayObject)
 453
 454 RefPtr<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
 455 RefPtr<WebGLVertexArrayObjectBase> m_boundVertexArrayObject;
 456 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectBase> arrayObject)
454457 {
455458 if (arrayObject)
456459 m_boundVertexArrayObject = arrayObject;
181505

Source/WebCore/html/canvas/WebGLVertexArrayObject.cpp

2828#if ENABLE(WEBGL)
2929#include "WebGLVertexArrayObject.h"
3030
 31#include "WebGL2RenderingContext.h"
3132#include "WebGLContextGroup.h"
32 #include "WebGLRenderingContextBase.h"
3333
3434namespace WebCore {
3535
36 PassRefPtr<WebGLVertexArrayObject> WebGLVertexArrayObject::create(WebGLRenderingContextBase* ctx)
 36PassRefPtr<WebGLVertexArrayObject> WebGLVertexArrayObject::create(WebGLRenderingContextBase* ctx, VaoType type)
3737{
38  return adoptRef(new WebGLVertexArrayObject(ctx));
 38 return adoptRef(new WebGLVertexArrayObject(ctx, type));
3939}
4040
4141WebGLVertexArrayObject::~WebGLVertexArrayObject()

@@WebGLVertexArrayObject::~WebGLVertexArra
4343 deleteObject(0);
4444}
4545
46 WebGLVertexArrayObject::WebGLVertexArrayObject(WebGLRenderingContextBase* ctx)
47  : WebGLSharedObject(ctx)
 46WebGLVertexArrayObject::WebGLVertexArrayObject(WebGLRenderingContextBase* ctx, VaoType type)
 47 : WebGLVertexArrayObjectBase(ctx, type)
4848{
49  // FIXME: Call createVertexArray from GraphicsContext3D.
 49 switch (m_type) {
 50 case VaoTypeDefault:
 51 break;
 52 default:
 53 setObject(context()->graphicsContext3D()->createVertexArray());
 54 break;
 55 }
5056}
5157
5258void WebGLVertexArrayObject::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
5359{
54  UNUSED_PARAM(context3d);
55  UNUSED_PARAM(object);
56  // FIXME: Call deleteVertexArray from GraphicsContext3D.
 60 switch (m_type) {
 61 case VaoTypeDefault:
 62 break;
 63 default:
 64 context3d->deleteVertexArray(object);
 65 break;
 66 }
 67
 68 if (m_boundElementArrayBuffer)
 69 m_boundElementArrayBuffer->onDetached(context3d);
 70
 71 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
 72 VertexAttribState& state = m_vertexAttribState[i];
 73 if (state.bufferBinding)
 74 state.bufferBinding->onDetached(context3d);
 75 }
5776}
5877
5978}
181505

Source/WebCore/html/canvas/WebGLVertexArrayObject.h

2626#ifndef WebGLVertexArrayObject_h
2727#define WebGLVertexArrayObject_h
2828
29 #include "WebGLSharedObject.h"
 29#include "WebGLBuffer.h"
 30#include "WebGLContextObject.h"
 31#include "WebGLVertexArrayObjectBase.h"
3032
3133#include <wtf/PassRefPtr.h>
3234#include <wtf/RefCounted.h>
3335
3436namespace WebCore {
3537
36 class WebGLVertexArrayObject final : public WebGLSharedObject {
 38class WebGL2RenderingContext;
 39
 40class WebGLVertexArrayObject final : public WebGLVertexArrayObjectBase {
3741public:
 42 static PassRefPtr<WebGLVertexArrayObject> create(WebGLRenderingContextBase*, VaoType);
3843 virtual ~WebGLVertexArrayObject();
39 
40  static PassRefPtr<WebGLVertexArrayObject> create(WebGLRenderingContextBase*);
41 
42 protected:
43  WebGLVertexArrayObject(WebGLRenderingContextBase*);
44 
45  virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
46 
4744private:
48  virtual bool isTransformFeedback() const override { return true; }
 45 WebGLVertexArrayObject(WebGLRenderingContextBase*, VaoType);
 46 bool isTransformFeedback() const { return true; }
 47 virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
4948};
5049
5150} // namespace WebCore
181505

Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.cpp

 1/*
 2 * Copyright (C) 2015 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27
 28#if ENABLE(WEBGL)
 29#include "WebGLVertexArrayObjectBase.h"
 30
 31#include "WebGLRenderingContextBase.h"
 32
 33namespace WebCore {
 34
 35WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase* ctx, VaoType type)
 36 : WebGLContextObject(ctx)
 37 , m_type(type)
 38 , m_hasEverBeenBound(false)
 39 , m_boundElementArrayBuffer(0)
 40{
 41 m_vertexAttribState.resize(ctx->getMaxVertexAttribs());
 42}
 43
 44void WebGLVertexArrayObjectBase::setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer)
 45{
 46 if (buffer)
 47 buffer->onAttached();
 48 if (m_boundElementArrayBuffer)
 49 m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
 50 m_boundElementArrayBuffer = buffer;
 51
 52}
 53
 54void WebGLVertexArrayObjectBase::setVertexAttribState(GC3Duint index, GC3Dsizei bytesPerElement, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, PassRefPtr<WebGLBuffer> buffer)
 55{
 56 GC3Dsizei validatedStride = stride ? stride : bytesPerElement;
 57
 58 VertexAttribState& state = m_vertexAttribState[index];
 59
 60 if (buffer)
 61 buffer->onAttached();
 62 if (state.bufferBinding)
 63 state.bufferBinding->onDetached(context()->graphicsContext3D());
 64
 65 state.bufferBinding = buffer;
 66 state.bytesPerElement = bytesPerElement;
 67 state.size = size;
 68 state.type = type;
 69 state.normalized = normalized;
 70 state.stride = validatedStride;
 71 state.originalStride = stride;
 72 state.offset = offset;
 73}
 74
 75void WebGLVertexArrayObjectBase::unbindBuffer(PassRefPtr<WebGLBuffer> buffer)
 76{
 77 if (m_boundElementArrayBuffer == buffer) {
 78 m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
 79 m_boundElementArrayBuffer = 0;
 80 }
 81
 82 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
 83 VertexAttribState& state = m_vertexAttribState[i];
 84 if (state.bufferBinding == buffer) {
 85 buffer->onDetached(context()->graphicsContext3D());
 86
 87 if (!i && !context()->isGLES2Compliant()) {
 88 state.bufferBinding = context()->m_vertexAttrib0Buffer;
 89 state.bufferBinding->onAttached();
 90 state.bytesPerElement = 0;
 91 state.size = 4;
 92 state.type = GraphicsContext3D::FLOAT;
 93 state.normalized = false;
 94 state.stride = 16;
 95 state.originalStride = 0;
 96 state.offset = 0;
 97 } else
 98 state.bufferBinding = 0;
 99 }
 100 }
 101}
 102
 103void WebGLVertexArrayObjectBase::setVertexAttribDivisor(GC3Duint index, GC3Duint divisor)
 104{
 105 VertexAttribState& state = m_vertexAttribState[index];
 106 state.divisor = divisor;
 107}
 108
 109}
 110
 111#endif // ENABLE(WEBGL)
0

Source/WebCore/html/canvas/WebGLVertexArrayObjectBase.h

 1/*
 2 * Copyright (C) 2015 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebGLVertexArrayObjectBase_h
 27#define WebGLVertexArrayObjectBase_h
 28
 29#include "WebGLBuffer.h"
 30#include "WebGLContextObject.h"
 31
 32#include <wtf/PassRefPtr.h>
 33
 34namespace WebCore {
 35
 36class WebGLVertexArrayObjectBase : public WebGLContextObject {
 37public:
 38 enum VaoType {
 39 VaoTypeDefault,
 40 VaoTypeUser,
 41 };
 42
 43 virtual ~WebGLVertexArrayObjectBase() { }
 44
 45 // Cached values for vertex attrib range checks
 46 struct VertexAttribState {
 47 VertexAttribState()
 48 : enabled(false)
 49 , bytesPerElement(0)
 50 , size(4)
 51 , type(GraphicsContext3D::FLOAT)
 52 , normalized(false)
 53 , stride(16)
 54 , originalStride(0)
 55 , offset(0)
 56 , divisor(0)
 57 {
 58 }
 59
 60 bool isBound() const { return bufferBinding && bufferBinding->object(); }
 61 bool validateBinding() const { return !enabled || isBound(); }
 62
 63 bool enabled;
 64 RefPtr<WebGLBuffer> bufferBinding;
 65 GC3Dsizei bytesPerElement;
 66 GC3Dint size;
 67 GC3Denum type;
 68 bool normalized;
 69 GC3Dsizei stride;
 70 GC3Dsizei originalStride;
 71 GC3Dintptr offset;
 72 GC3Duint divisor;
 73 };
 74
 75 bool isDefaultObject() const { return m_type == VaoTypeDefault; }
 76
 77 bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
 78 void setHasEverBeenBound() { m_hasEverBeenBound = true; }
 79
 80 PassRefPtr<WebGLBuffer> getElementArrayBuffer() const { return m_boundElementArrayBuffer; }
 81 void setElementArrayBuffer(PassRefPtr<WebGLBuffer>);
 82
 83 VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
 84 void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>);
 85 void unbindBuffer(PassRefPtr<WebGLBuffer>);
 86
 87 void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor);
 88
 89protected:
 90 WebGLVertexArrayObjectBase(WebGLRenderingContextBase*, VaoType);
 91 virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) = 0;
 92
 93 VaoType m_type;
 94 bool m_hasEverBeenBound;
 95 RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
 96 Vector<VertexAttribState> m_vertexAttribState;
 97};
 98
 99} // namespace WebCore
 100
 101#endif // WebGLVertexArrayObjectBase_h
0

Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp

@@PassRefPtr<WebGLVertexArrayObjectOES> We
4040}
4141
4242WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VaoType type)
43  : WebGLContextObject(ctx)
44  , m_type(type)
45  , m_hasEverBeenBound(false)
46  , m_boundElementArrayBuffer(0)
 43 : WebGLVertexArrayObjectBase(ctx, type)
4744{
48  m_vertexAttribState.resize(ctx->getMaxVertexAttribs());
49 
5045 Extensions3D* extensions = context()->graphicsContext3D()->getExtensions();
5146 switch (m_type) {
5247 case VaoTypeDefault:

@@WebGLVertexArrayObjectOES::WebGLVertexAr
5651 break;
5752 }
5853}
59 
 54
6055WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES()
6156{
6257 deleteObject(0);

@@void WebGLVertexArrayObjectOES::deleteOb
8277 state.bufferBinding->onDetached(context3d);
8378 }
8479}
85 
86 void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer)
87 {
88  if (buffer)
89  buffer->onAttached();
90  if (m_boundElementArrayBuffer)
91  m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
92  m_boundElementArrayBuffer = buffer;
93 
94 }
95 
96 void WebGLVertexArrayObjectOES::setVertexAttribState(
97  GC3Duint index, GC3Dsizei bytesPerElement, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, PassRefPtr<WebGLBuffer> buffer)
98 {
99  GC3Dsizei validatedStride = stride ? stride : bytesPerElement;
100 
101  VertexAttribState& state = m_vertexAttribState[index];
102 
103  if (buffer)
104  buffer->onAttached();
105  if (state.bufferBinding)
106  state.bufferBinding->onDetached(context()->graphicsContext3D());
107 
108  state.bufferBinding = buffer;
109  state.bytesPerElement = bytesPerElement;
110  state.size = size;
111  state.type = type;
112  state.normalized = normalized;
113  state.stride = validatedStride;
114  state.originalStride = stride;
115  state.offset = offset;
116 }
117 
118 void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer)
119 {
120  if (m_boundElementArrayBuffer == buffer) {
121  m_boundElementArrayBuffer->onDetached(context()->graphicsContext3D());
122  m_boundElementArrayBuffer = 0;
123  }
124 
125  for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
126  VertexAttribState& state = m_vertexAttribState[i];
127  if (state.bufferBinding == buffer) {
128  buffer->onDetached(context()->graphicsContext3D());
129 
130  if (!i && !context()->isGLES2Compliant()) {
131  state.bufferBinding = context()->m_vertexAttrib0Buffer;
132  state.bufferBinding->onAttached();
133  state.bytesPerElement = 0;
134  state.size = 4;
135  state.type = GraphicsContext3D::FLOAT;
136  state.normalized = false;
137  state.stride = 16;
138  state.originalStride = 0;
139  state.offset = 0;
140  } else
141  state.bufferBinding = 0;
142  }
143  }
144 }
145 
146 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GC3Duint index, GC3Duint divisor)
147 {
148  VertexAttribState& state = m_vertexAttribState[index];
149  state.divisor = divisor;
150 }
151 
15280}
15381
15482#endif // ENABLE(WEBGL)
181505

Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h

2828
2929#include "WebGLBuffer.h"
3030#include "WebGLContextObject.h"
 31#include "WebGLVertexArrayObjectBase.h"
3132
3233#include <wtf/PassRefPtr.h>
3334
3435namespace WebCore {
3536
36 class WebGLVertexArrayObjectOES final : public WebGLContextObject {
 37class WebGLVertexArrayObjectOES final : public WebGLVertexArrayObjectBase {
3738public:
38  enum VaoType {
39  VaoTypeDefault,
40  VaoTypeUser,
41  };
42 
43  virtual ~WebGLVertexArrayObjectOES();
44 
4539 static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBase*, VaoType);
46 
47  // Cached values for vertex attrib range checks
48  struct VertexAttribState {
49  VertexAttribState()
50  : enabled(false)
51  , bytesPerElement(0)
52  , size(4)
53  , type(GraphicsContext3D::FLOAT)
54  , normalized(false)
55  , stride(16)
56  , originalStride(0)
57  , offset(0)
58  , divisor(0)
59  {
60  }
61 
62  bool isBound() const { return bufferBinding && bufferBinding->object(); }
63  bool validateBinding() const { return !enabled || isBound(); }
64 
65  bool enabled;
66  RefPtr<WebGLBuffer> bufferBinding;
67  GC3Dsizei bytesPerElement;
68  GC3Dint size;
69  GC3Denum type;
70  bool normalized;
71  GC3Dsizei stride;
72  GC3Dsizei originalStride;
73  GC3Dintptr offset;
74  GC3Duint divisor;
75  };
76 
77  bool isDefaultObject() const { return m_type == VaoTypeDefault; }
78 
79  bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
80  void setHasEverBeenBound() { m_hasEverBeenBound = true; }
81 
82  PassRefPtr<WebGLBuffer> getElementArrayBuffer() const { return m_boundElementArrayBuffer; }
83  void setElementArrayBuffer(PassRefPtr<WebGLBuffer>);
84 
85  VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
86  void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>);
87  void unbindBuffer(PassRefPtr<WebGLBuffer>);
88 
89  void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor);
90 
 40 virtual ~WebGLVertexArrayObjectOES();
9141private:
9242 WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType);
93 
9443 virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
95 
96  VaoType m_type;
97  bool m_hasEverBeenBound;
98  RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
99  Vector<VertexAttribState> m_vertexAttribState;
10044};
10145
10246} // namespace WebCore
181505

Source/WebCore/platform/graphics/GraphicsContext3D.h

@@public:
11181118 void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount);
11191119 void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
11201120
 1121 // VertexArrayOject calls
 1122 Platform3DObject createVertexArray();
 1123 void deleteVertexArray(Platform3DObject);
 1124 GC3Dboolean isVertexArray(Platform3DObject);
 1125 void bindVertexArray(Platform3DObject);
 1126
11211127#if PLATFORM(GTK) || PLATFORM(EFL) || USE(CAIRO)
11221128 void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
11231129 int canvasWidth, int canvasHeight, PlatformContextCairo* context);
181505

Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

@@void GraphicsContext3D::viewport(GC3Dint
13571357 ::glViewport(x, y, width, height);
13581358}
13591359
 1360Platform3DObject GraphicsContext3D::createVertexArray()
 1361{
 1362 makeContextCurrent();
 1363 GLuint array = 0;
 1364#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
 1365 glGenVertexArrays(1, &array);
 1366#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
 1367 glGenVertexArraysAPPLE(1, &array);
 1368#endif
 1369 return array;
 1370}
 1371
 1372void GraphicsContext3D::deleteVertexArray(Platform3DObject array)
 1373{
 1374 if (!array)
 1375 return;
 1376
 1377 makeContextCurrent();
 1378#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
 1379 glDeleteVertexArrays(1, &array);
 1380#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
 1381 glDeleteVertexArraysAPPLE(1, &array);
 1382#endif
 1383}
 1384
 1385GC3Dboolean GraphicsContext3D::isVertexArray(Platform3DObject array)
 1386{
 1387 if (!array)
 1388 return GL_FALSE;
 1389
 1390 makeContextCurrent();
 1391#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
 1392 return glIsVertexArray(array);
 1393#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
 1394 return glIsVertexArrayAPPLE(array);
 1395#endif
 1396 return GL_FALSE;
 1397}
 1398
 1399void GraphicsContext3D::bindVertexArray(Platform3DObject array)
 1400{
 1401 makeContextCurrent();
 1402#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
 1403 glBindVertexArray(array);
 1404#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
 1405 glBindVertexArrayAPPLE(array);
 1406#else
 1407 UNUSED_PARAM(array);
 1408#endif
 1409}
 1410
13601411void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value)
13611412{
13621413 makeContextCurrent();
181505