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 WEBGL_VERTEX_ARRAY_H_
7 #define WEBGL_VERTEX_ARRAY_H_
9 #include "mozilla/LinkedList.h"
10 #include "nsWrapperCache.h"
11 #include "WebGLBindableName.h"
12 #include "WebGLBuffer.h"
13 #include "WebGLObjectModel.h"
14 #include "WebGLStrongTypes.h"
15 #include "WebGLVertexAttribData.h"
19 class WebGLVertexArrayFake
;
21 class WebGLVertexArray
22 : public nsWrapperCache
23 , public WebGLBindable
<VAOBinding
>
24 , public WebGLRefCountedObject
<WebGLVertexArray
>
25 , public LinkedListElement
<WebGLVertexArray
>
26 , public WebGLContextBoundObject
29 static WebGLVertexArray
* Create(WebGLContext
* webgl
);
31 void BindVertexArray() {
32 // Bind to dummy value to signal that this vertex array has ever been
34 BindTo(LOCAL_GL_VERTEX_ARRAY_BINDING
);
35 BindVertexArrayImpl();
38 virtual void GenVertexArray() = 0;
39 virtual void BindVertexArrayImpl() = 0;
40 virtual void DeleteImpl() = 0;
42 void EnsureAttrib(GLuint index
);
43 bool HasAttrib(GLuint index
) const {
44 return index
< mAttribs
.Length();
46 bool IsAttribArrayEnabled(GLuint index
) const {
47 return HasAttrib(index
) && mAttribs
[index
].enabled
;
50 // Implement parent classes:
53 WebGLContext
* GetParentObject() const {
57 virtual JSObject
* WrapObject(JSContext
* cx
) MOZ_OVERRIDE
;
59 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray
)
60 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray
)
62 GLuint
GLName() const { return mGLName
; }
65 explicit WebGLVertexArray(WebGLContext
* webgl
);
67 virtual ~WebGLVertexArray() {
68 MOZ_ASSERT(IsDeleted());
72 nsTArray
<WebGLVertexAttribData
> mAttribs
;
73 WebGLRefPtr
<WebGLBuffer
> mElementArrayBuffer
;
75 friend class WebGLContext
;
76 friend class WebGLVertexArrayFake
;
77 friend class WebGL2Context
;
80 } // namespace mozilla
82 #endif // WEBGL_VERTEX_ARRAY_H_