content/canvas/src/WebGLVertexArray.cpp

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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