1 /* -*- Mode: C++; tab-width: 4; 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 #ifndef WEBGLVERTEXARRAY_H_
7 #define WEBGLVERTEXARRAY_H_
9 #include "WebGLObjectModel.h"
10 #include "WebGLBuffer.h"
11 #include "WebGLVertexAttribData.h"
13 #include "nsWrapperCache.h"
15 #include "mozilla/LinkedList.h"
19 class WebGLVertexArray MOZ_FINAL
20 : public nsWrapperCache
21 , public WebGLRefCountedObject
<WebGLVertexArray
>
22 , public LinkedListElement
<WebGLVertexArray
>
23 , public WebGLContextBoundObject
25 // -----------------------------------------------------------------------------
29 // -------------------------------------------------------------------------
30 // CONSTRUCTOR & DESTRUCTOR
32 WebGLVertexArray(WebGLContext
*context
);
39 // -------------------------------------------------------------------------
40 // IMPLMENET PARENT CLASSES
44 WebGLContext
* GetParentObject() const {
48 virtual JSObject
* WrapObject(JSContext
*cx
,
49 JS::Handle
<JSObject
*> scope
) MOZ_OVERRIDE
;
51 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray
)
52 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray
)
55 // -------------------------------------------------------------------------
58 bool HasEverBeenBound() { return mHasEverBeenBound
; }
59 void SetHasEverBeenBound(bool x
) { mHasEverBeenBound
= x
; }
60 GLuint
GLName() const { return mGLName
; }
62 bool EnsureAttrib(GLuint index
, const char *info
);
63 bool HasAttrib(GLuint index
) {
64 return index
< mAttribs
.Length();
66 bool IsAttribArrayEnabled(GLuint index
) {
67 return HasAttrib(index
) && mAttribs
[index
].enabled
;
71 // -----------------------------------------------------------------------------
75 // -------------------------------------------------------------------------
79 bool mHasEverBeenBound
;
80 nsTArray
<WebGLVertexAttribData
> mAttribs
;
81 WebGLRefPtr
<WebGLBuffer
> mBoundElementArrayBuffer
;
84 // -------------------------------------------------------------------------
87 friend class WebGLContext
;
90 } // namespace mozilla