michael@0: /* -*- Mode: C++; tab-width: 4; 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: #ifndef WEBGLVERTEXARRAY_H_ michael@0: #define WEBGLVERTEXARRAY_H_ michael@0: michael@0: #include "WebGLObjectModel.h" michael@0: #include "WebGLBuffer.h" michael@0: #include "WebGLVertexAttribData.h" michael@0: michael@0: #include "nsWrapperCache.h" michael@0: michael@0: #include "mozilla/LinkedList.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class WebGLVertexArray MOZ_FINAL michael@0: : public nsWrapperCache michael@0: , public WebGLRefCountedObject michael@0: , public LinkedListElement michael@0: , public WebGLContextBoundObject michael@0: { michael@0: // ----------------------------------------------------------------------------- michael@0: // PUBLIC michael@0: public: michael@0: michael@0: // ------------------------------------------------------------------------- michael@0: // CONSTRUCTOR & DESTRUCTOR michael@0: michael@0: WebGLVertexArray(WebGLContext *context); michael@0: michael@0: ~WebGLVertexArray() { michael@0: DeleteOnce(); michael@0: }; michael@0: michael@0: michael@0: // ------------------------------------------------------------------------- michael@0: // IMPLMENET PARENT CLASSES michael@0: michael@0: void Delete(); michael@0: michael@0: WebGLContext* GetParentObject() const { michael@0: return Context(); michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; michael@0: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray) michael@0: michael@0: michael@0: // ------------------------------------------------------------------------- michael@0: // MEMBER FUNCTIONS michael@0: michael@0: bool HasEverBeenBound() { return mHasEverBeenBound; } michael@0: void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } michael@0: GLuint GLName() const { return mGLName; } michael@0: michael@0: bool EnsureAttrib(GLuint index, const char *info); michael@0: bool HasAttrib(GLuint index) { michael@0: return index < mAttribs.Length(); michael@0: } michael@0: bool IsAttribArrayEnabled(GLuint index) { michael@0: return HasAttrib(index) && mAttribs[index].enabled; michael@0: } michael@0: michael@0: michael@0: // ----------------------------------------------------------------------------- michael@0: // PRIVATE michael@0: private: michael@0: michael@0: // ------------------------------------------------------------------------- michael@0: // MEMBERS michael@0: michael@0: GLuint mGLName; michael@0: bool mHasEverBeenBound; michael@0: nsTArray mAttribs; michael@0: WebGLRefPtr mBoundElementArrayBuffer; michael@0: michael@0: michael@0: // ------------------------------------------------------------------------- michael@0: // FRIENDSHIPS michael@0: michael@0: friend class WebGLContext; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif