|
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/. */ |
|
5 |
|
6 #ifndef WEBGLVERTEXARRAY_H_ |
|
7 #define WEBGLVERTEXARRAY_H_ |
|
8 |
|
9 #include "WebGLObjectModel.h" |
|
10 #include "WebGLBuffer.h" |
|
11 #include "WebGLVertexAttribData.h" |
|
12 |
|
13 #include "nsWrapperCache.h" |
|
14 |
|
15 #include "mozilla/LinkedList.h" |
|
16 |
|
17 namespace mozilla { |
|
18 |
|
19 class WebGLVertexArray MOZ_FINAL |
|
20 : public nsWrapperCache |
|
21 , public WebGLRefCountedObject<WebGLVertexArray> |
|
22 , public LinkedListElement<WebGLVertexArray> |
|
23 , public WebGLContextBoundObject |
|
24 { |
|
25 // ----------------------------------------------------------------------------- |
|
26 // PUBLIC |
|
27 public: |
|
28 |
|
29 // ------------------------------------------------------------------------- |
|
30 // CONSTRUCTOR & DESTRUCTOR |
|
31 |
|
32 WebGLVertexArray(WebGLContext *context); |
|
33 |
|
34 ~WebGLVertexArray() { |
|
35 DeleteOnce(); |
|
36 }; |
|
37 |
|
38 |
|
39 // ------------------------------------------------------------------------- |
|
40 // IMPLMENET PARENT CLASSES |
|
41 |
|
42 void Delete(); |
|
43 |
|
44 WebGLContext* GetParentObject() const { |
|
45 return Context(); |
|
46 } |
|
47 |
|
48 virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; |
|
49 |
|
50 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray) |
|
51 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray) |
|
52 |
|
53 |
|
54 // ------------------------------------------------------------------------- |
|
55 // MEMBER FUNCTIONS |
|
56 |
|
57 bool HasEverBeenBound() { return mHasEverBeenBound; } |
|
58 void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } |
|
59 GLuint GLName() const { return mGLName; } |
|
60 |
|
61 bool EnsureAttrib(GLuint index, const char *info); |
|
62 bool HasAttrib(GLuint index) { |
|
63 return index < mAttribs.Length(); |
|
64 } |
|
65 bool IsAttribArrayEnabled(GLuint index) { |
|
66 return HasAttrib(index) && mAttribs[index].enabled; |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // PRIVATE |
|
72 private: |
|
73 |
|
74 // ------------------------------------------------------------------------- |
|
75 // MEMBERS |
|
76 |
|
77 GLuint mGLName; |
|
78 bool mHasEverBeenBound; |
|
79 nsTArray<WebGLVertexAttribData> mAttribs; |
|
80 WebGLRefPtr<WebGLBuffer> mBoundElementArrayBuffer; |
|
81 |
|
82 |
|
83 // ------------------------------------------------------------------------- |
|
84 // FRIENDSHIPS |
|
85 |
|
86 friend class WebGLContext; |
|
87 }; |
|
88 |
|
89 } // namespace mozilla |
|
90 |
|
91 #endif |