content/canvas/src/WebGLExtensionVertexArray.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/src/WebGLExtensionVertexArray.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "WebGLContext.h"
    1.10 +#include "WebGLBuffer.h"
    1.11 +#include "WebGLVertexArray.h"
    1.12 +#include "WebGLExtensions.h"
    1.13 +#include "mozilla/dom/WebGLRenderingContextBinding.h"
    1.14 +#include "GLContext.h"
    1.15 +
    1.16 +using namespace mozilla;
    1.17 +
    1.18 +WebGLExtensionVertexArray::WebGLExtensionVertexArray(WebGLContext* context)
    1.19 +  : WebGLExtensionBase(context)
    1.20 +{
    1.21 +    MOZ_ASSERT(IsSupported(context), "should not construct WebGLExtensionVertexArray :"
    1.22 +                                     "OES_vertex_array_object unsuported.");
    1.23 +}
    1.24 +
    1.25 +WebGLExtensionVertexArray::~WebGLExtensionVertexArray()
    1.26 +{
    1.27 +}
    1.28 +
    1.29 +already_AddRefed<WebGLVertexArray> WebGLExtensionVertexArray::CreateVertexArrayOES()
    1.30 +{
    1.31 +    if (mIsLost) {
    1.32 +        mContext->ErrorInvalidOperation("createVertexArrayOES: Extension is lost. Returning NULL.");
    1.33 +        return nullptr;
    1.34 +    }
    1.35 +
    1.36 +    return mContext->CreateVertexArray();
    1.37 +}
    1.38 +
    1.39 +void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
    1.40 +{
    1.41 +    if (mIsLost)
    1.42 +        return mContext->ErrorInvalidOperation("deleteVertexArrayOES: Extension is lost.");
    1.43 +
    1.44 +    mContext->DeleteVertexArray(array);
    1.45 +}
    1.46 +
    1.47 +bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
    1.48 +{
    1.49 +    if (mIsLost) {
    1.50 +        mContext->ErrorInvalidOperation("isVertexArrayOES: Extension is lost. Returning false.");
    1.51 +        return false;
    1.52 +    }
    1.53 +
    1.54 +    return mContext->IsVertexArray(array);
    1.55 +}
    1.56 +
    1.57 +void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array)
    1.58 +{
    1.59 +    if (mIsLost)
    1.60 +        return mContext->ErrorInvalidOperation("bindVertexArrayOES: Extension is lost.");
    1.61 +
    1.62 +    mContext->BindVertexArray(array);
    1.63 +}
    1.64 +
    1.65 +bool WebGLExtensionVertexArray::IsSupported(const WebGLContext* context)
    1.66 +{
    1.67 +    gl::GLContext* gl = context->GL();
    1.68 +
    1.69 +    return gl->IsSupported(gl::GLFeature::vertex_array_object);
    1.70 +}
    1.71 +
    1.72 +IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionVertexArray)

mercurial