content/canvas/src/WebGLVertexArray.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "WebGLContext.h"
     7 #include "WebGLBuffer.h"
     8 #include "WebGLVertexArray.h"
     9 #include "mozilla/dom/WebGLRenderingContextBinding.h"
    10 #include "GLContext.h"
    12 using namespace mozilla;
    14 JSObject*
    15 WebGLVertexArray::WrapObject(JSContext *cx) {
    16     return dom::WebGLVertexArrayBinding::Wrap(cx, this);
    17 }
    19 WebGLVertexArray::WebGLVertexArray(WebGLContext* context)
    20     : WebGLContextBoundObject(context)
    21     , mGLName(0)
    22     , mHasEverBeenBound(false)
    23 {
    24     SetIsDOMBinding();
    25 }
    27 void WebGLVertexArray::Delete() {
    28     if (mGLName != 0) {
    29         mBoundElementArrayBuffer = nullptr;
    31         mContext->MakeContextCurrent();
    32         mContext->gl->fDeleteVertexArrays(1, &mGLName);
    33         LinkedListElement<WebGLVertexArray>::removeFrom(mContext->mVertexArrays);
    34     }
    36     mBoundElementArrayBuffer = nullptr;
    37     mAttribs.Clear();
    38 }
    40 bool WebGLVertexArray::EnsureAttrib(GLuint index, const char *info)
    41 {
    42     if (index >= GLuint(mContext->mGLMaxVertexAttribs)) {
    43         if (index == GLuint(-1)) {
    44             mContext->ErrorInvalidValue("%s: index -1 is invalid. That probably comes from a getAttribLocation() call, "
    45                                         "where this return value -1 means that the passed name didn't correspond to an active attribute in "
    46                                         "the specified program.", info);
    47         } else {
    48             mContext->ErrorInvalidValue("%s: index %d is out of range", info, index);
    49         }
    50         return false;
    51     }
    52     else if (index >= mAttribs.Length()) {
    53         mAttribs.SetLength(index + 1);
    54     }
    56     return true;
    57 }
    59 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(WebGLVertexArray,
    60   mAttribs,
    61   mBoundElementArrayBuffer)
    63 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLVertexArray, AddRef)
    64 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLVertexArray, Release)

mercurial