⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181571 in webkit


Ignore:
Timestamp:
Mar 16, 2015, 12:03:26 PM (11 years ago)
Author:
roger_fong@apple.com
Message:

[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:
Location:
trunk/Source/WebCore
Files:
2 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r181468 r181571  
    17201720    html/canvas/WebGLUniformLocation.cpp
    17211721    html/canvas/WebGLVertexArrayObject.cpp
     1722    html/canvas/WebGLVertexArrayObjectBase.cpp
    17221723    html/canvas/WebGLVertexArrayObjectOES.cpp
    17231724
     
    28252826        html/canvas/WebGLUniformLocation.cpp
    28262827        html/canvas/WebGLVertexArrayObject.cpp
     2828        html/canvas/WebGLVertexArrayObjectBase.cpp
    28272829        html/canvas/WebGLVertexArrayObjectOES.cpp
    28282830    )
  • trunk/Source/WebCore/ChangeLog

    r181568 r181571  
     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 Dean Jackson.
     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-16  Brent Fulgham  <bfulgham@apple.com>
    292
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r181468 r181571  
    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">
     
    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" />
     
    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" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r181468 r181571  
    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>
     
    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>
     
    1516615169    </ClInclude>
    1516715170    <ClInclude Include="..\html\canvas\WebGLVertexArrayObject.h">
     15171      <Filter>html\canvas</Filter>
     15172    </ClInclude>
     15173    <ClInclude Include="..\html\canvas\WebGLVertexArrayObjectBase.h”>
    1516815174      <Filter>html\canvas</Filter>
    1516915175    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r181468 r181571  
    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 */; };
     
    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>"; };
     
    1604016043                                6F995A1D1A7078B100A735F4 /* WebGLVertexArrayObject.cpp */,
    1604116044                                6F995A1E1A7078B100A735F4 /* WebGLVertexArrayObject.h */,
     16045                                6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */,
     16046                                6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */,
    1604216047                                6F995A0D1A7070E600A735F4 /* WebGLVertexArrayObject.idl */,
    1604316048                                77A17A7412F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp */,
     
    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 */,
  • trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp

    r178674 r181571  
    6969#include "JSWebGLTexture.h"
    7070#include "JSWebGLUniformLocation.h"
     71#include "JSWebGLVertexArrayObject.h"
    7172#include "JSWebGLVertexArrayObjectOES.h"
    7273#include "JSWebKitCSSMatrix.h"
     
    9394#include "WebGLProgram.h"
    9495#include "WebGLRenderingContextBase.h"
     96#include "WebGLVertexArrayObject.h"
    9597#include "WebGLVertexArrayObjectOES.h"
    9698#include <runtime/Error.h>
     
    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());
  • trunk/Source/WebCore/html/canvas/OESVertexArrayObject.cpp

    r178674 r181571  
    3131
    3232#include "Extensions3D.h"
     33#include "WebGLRenderingContext.h"
    3334
    3435namespace WebCore {
     
    5354        return 0;
    5455   
    55     RefPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VaoTypeUser);
     56    RefPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VAOTypeUser);
    5657    m_context->addContextObject(o.get());
    5758    return o.release();
     
    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());
     
    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}
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

    r181468 r181571  
    6161    : WebGLRenderingContextBase(passedCanvas, attributes)
    6262{
    63     initializeShaderExtensions();
    6463}
    6564
     
    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
     
    769778PassRefPtr<WebGLVertexArrayObject> WebGL2RenderingContext::createVertexArray()
    770779{
    771     return nullptr;
    772 }
    773 
    774 void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* vertexArray)
    775 {
    776     UNUSED_PARAM(vertexArray);
    777 }
    778 
    779 GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* vertexArray)
    780 {
    781     UNUSED_PARAM(vertexArray);
    782     return false;
    783 }
    784 
    785 void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* vertexArray)
    786 {
    787     UNUSED_PARAM(vertexArray);
     780    if (isContextLost())
     781        return 0;
     782   
     783    RefPtr<WebGLVertexArrayObject> o = WebGLVertexArrayObject::create(this, WebGLVertexArrayObject::VAOTypeUser);
     784    addContextObject(o.get());
     785    return o.release();
     786}
     787
     788void WebGL2RenderingContext::deleteVertexArray(WebGLVertexArrayObject* arrayObject)
     789{
     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());
     800}
     801
     802GC3Dboolean WebGL2RenderingContext::isVertexArray(WebGLVertexArrayObject* arrayObject)
     803{
     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());
     811}
     812
     813void WebGL2RenderingContext::bindVertexArray(WebGLVertexArrayObject* arrayObject)
     814{
     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
     
    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:
     
    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();
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h

    r180285 r181571  
    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;
  • trunk/Source/WebCore/html/canvas/WebGLGetInfo.cpp

    r179530 r181571  
    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>
     
    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{
     
    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}
  • trunk/Source/WebCore/html/canvas/WebGLGetInfo.h

    r179530 r181571  
    3333#include "WebGLRenderbuffer.h"
    3434#include "WebGLTexture.h"
     35#include "WebGLVertexArrayObject.h"
    3536#include "WebGLVertexArrayObjectOES.h"
    3637#include <runtime/Float32Array.h>
     
    7172        kTypeWebGLUnsignedIntArray,
    7273        kTypeWebGLVertexArrayObjectOES,
     74        kTypeWebGLVertexArrayObject,
    7375    };
    7476
     
    9496    explicit WebGLGetInfo(PassRefPtr<Uint32Array> value);
    9597    explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES> value);
     98    explicit WebGLGetInfo(PassRefPtr<WebGLVertexArrayObject> value);
    9699
    97100    ~WebGLGetInfo();
     
    118121    PassRefPtr<Uint32Array> getWebGLUnsignedIntArray() const;
    119122    PassRefPtr<WebGLVertexArrayObjectOES> getWebGLVertexArrayObjectOES() const;
     123    PassRefPtr<WebGLVertexArrayObject> getWebGLVertexArrayObject() const;
    120124
    121125private:
     
    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
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r181468 r181571  
    5757#include "WebGLDrawBuffers.h"
    5858#include "WebGLLoseContext.h"
     59#include "WebGLVertexArrayObjectOES.h"
    5960
    6061namespace WebCore {
     
    6869    GraphicsContext3D::Attributes attributes) : WebGLRenderingContextBase(passedCanvas, context, attributes)
    6970{
    70 }
    71 
     71    initializeVertexArrayObjects();
     72}
     73
     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)
     
    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        }
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r180285 r181571  
    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;
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r181468 r181571  
    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);
     
    539535    if (!isGLES2NPOTStrict())
    540536        createFallbackBlackTextures1x1();
    541     if (!isGLES2Compliant())
    542         initVertexAttrib0();
    543537
    544538    IntSize canvasSize = clampedCanvasSize();
     
    16011595    }
    16021596
    1603     WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
     1597    WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
    16041598    state.enabled = false;
    16051599
     
    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;
     
    18921886    }
    18931887
    1894     WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
     1888    WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index);
    18951889    state.enabled = true;
    18961890
     
    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)
     
    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();
     
    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)
     
    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()));
     
    47564750    setupFlags();
    47574751    initializeNewContext();
     4752    initializeVertexArrayObjects();
    47584753    canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, ""));
    47594754}
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r181468 r181571  
    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
     
    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)
  • trunk/Source/WebCore/html/canvas/WebGLVertexArrayObject.cpp

    r178963 r181571  
    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
     
    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
  • trunk/Source/WebCore/html/canvas/WebGLVertexArrayObject.h

    r178963 r181571  
    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>
     
    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 
     44private:
     45    WebGLVertexArrayObject(WebGLRenderingContextBase*, VAOType);
     46    bool isTransformFeedback() const { return true; }
    4547    virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override;
    46 
    47 private:
    48     virtual bool isTransformFeedback() const override { return true; }
    4948};
    5049
  • trunk/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp

    r178674 r181571  
    3535namespace WebCore {
    3636
    37 PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContextBase* ctx, VaoType type)
     37PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContextBase* ctx, VAOType type)
    3838{
    3939    return adoptRef(new WebGLVertexArrayObjectOES(ctx, type));
    4040}
    4141
    42 WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VaoType type)
    43     : WebGLContextObject(ctx)
    44     , m_type(type)
    45     , m_hasEverBeenBound(false)
    46     , m_boundElementArrayBuffer(0)
     42WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VAOType type)
     43    : WebGLVertexArrayObjectBase(ctx, type)
    4744{
    48     m_vertexAttribState.resize(ctx->getMaxVertexAttribs());
    49    
    5045    Extensions3D* extensions = context()->graphicsContext3D()->getExtensions();
    5146    switch (m_type) {
    52     case VaoTypeDefault:
     47    case VAOTypeDefault:
    5348        break;
    5449    default:
     
    6762    Extensions3D* extensions = context3d->getExtensions();
    6863    switch (m_type) {
    69     case VaoTypeDefault:
     64    case VAOTypeDefault:
    7065        break;
    7166    default:
     
    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
  • trunk/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h

    r178674 r181571  
    2929#include "WebGLBuffer.h"
    3030#include "WebGLContextObject.h"
     31#include "WebGLVertexArrayObjectBase.h"
    3132
    3233#include <wtf/PassRefPtr.h>
     
    3435namespace WebCore {
    3536
    36 class WebGLVertexArrayObjectOES final : public WebGLContextObject {
     37class WebGLVertexArrayObjectOES final : public WebGLVertexArrayObjectBase {
    3738public:
    38     enum VaoType {
    39         VaoTypeDefault,
    40         VaoTypeUser,
    41     };
    42    
     39    static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBase*, VAOType);
    4340    virtual ~WebGLVertexArrayObjectOES();
    44 
    45     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 
    9141private:
    92     WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType);
    93 
     42    WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VAOType);
    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
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r181468 r181571  
    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,
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r181468 r181571  
    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{
Note: See TracChangeset for help on using the changeset viewer.