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