WebGLVertexArrayObject.cpp [plain text]
#include "config.h"
#include "WebGLVertexArrayObject.h"
#if ENABLE(WEBGL2)
#include "WebGL2RenderingContext.h"
#include "WebGLContextGroup.h"
#include <wtf/Lock.h>
#include <wtf/Locker.h>
namespace WebCore {
Ref<WebGLVertexArrayObject> WebGLVertexArrayObject::create(WebGLRenderingContextBase& context, Type type)
{
return adoptRef(*new WebGLVertexArrayObject(context, type));
}
WebGLVertexArrayObject::~WebGLVertexArrayObject()
{
if (!context())
return;
runDestructor();
}
WebGLVertexArrayObject::WebGLVertexArrayObject(WebGLRenderingContextBase& context, Type type)
: WebGLVertexArrayObjectBase(context, type)
{
#if USE(OPENGL_ES)
if (m_type != Type::User)
return;
#endif
setObject(this->context()->graphicsContextGL()->createVertexArray());
}
void WebGLVertexArrayObject::deleteObjectImpl(const AbstractLocker& locker, GraphicsContextGL* context3d, PlatformGLObject object)
{
switch (m_type) {
case Type::Default:
break;
case Type::User:
context3d->deleteVertexArray(object);
break;
}
if (m_boundElementArrayBuffer)
m_boundElementArrayBuffer->onDetached(locker, context3d);
for (auto& state : m_vertexAttribState) {
if (state.bufferBinding)
state.bufferBinding->onDetached(locker, context3d);
}
}
}
#endif // ENABLE(WEBGL)