michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "WebGLContext.h" michael@0: #include "WebGLBuffer.h" michael@0: #include "WebGLVertexArray.h" michael@0: #include "WebGLExtensions.h" michael@0: #include "mozilla/dom/WebGLRenderingContextBinding.h" michael@0: #include "GLContext.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: WebGLExtensionVertexArray::WebGLExtensionVertexArray(WebGLContext* context) michael@0: : WebGLExtensionBase(context) michael@0: { michael@0: MOZ_ASSERT(IsSupported(context), "should not construct WebGLExtensionVertexArray :" michael@0: "OES_vertex_array_object unsuported."); michael@0: } michael@0: michael@0: WebGLExtensionVertexArray::~WebGLExtensionVertexArray() michael@0: { michael@0: } michael@0: michael@0: already_AddRefed WebGLExtensionVertexArray::CreateVertexArrayOES() michael@0: { michael@0: if (mIsLost) { michael@0: mContext->ErrorInvalidOperation("createVertexArrayOES: Extension is lost. Returning NULL."); michael@0: return nullptr; michael@0: } michael@0: michael@0: return mContext->CreateVertexArray(); michael@0: } michael@0: michael@0: void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array) michael@0: { michael@0: if (mIsLost) michael@0: return mContext->ErrorInvalidOperation("deleteVertexArrayOES: Extension is lost."); michael@0: michael@0: mContext->DeleteVertexArray(array); michael@0: } michael@0: michael@0: bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array) michael@0: { michael@0: if (mIsLost) { michael@0: mContext->ErrorInvalidOperation("isVertexArrayOES: Extension is lost. Returning false."); michael@0: return false; michael@0: } michael@0: michael@0: return mContext->IsVertexArray(array); michael@0: } michael@0: michael@0: void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array) michael@0: { michael@0: if (mIsLost) michael@0: return mContext->ErrorInvalidOperation("bindVertexArrayOES: Extension is lost."); michael@0: michael@0: mContext->BindVertexArray(array); michael@0: } michael@0: michael@0: bool WebGLExtensionVertexArray::IsSupported(const WebGLContext* context) michael@0: { michael@0: gl::GLContext* gl = context->GL(); michael@0: michael@0: return gl->IsSupported(gl::GLFeature::vertex_array_object); michael@0: } michael@0: michael@0: IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionVertexArray)