Backed out changeset 58dbd2146e24 (bug 944961) for bustage.
[gecko.git] / content / canvas / src / WebGLVertexArray.h
blob64c0456f8404e3b995bf811b0fbb3924fe8c7be7
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"
17 namespace mozilla {
19 class WebGLVertexArray MOZ_FINAL
20 : public nsWrapperCache
21 , public WebGLRefCountedObject<WebGLVertexArray>
22 , public LinkedListElement<WebGLVertexArray>
23 , public WebGLContextBoundObject
25 // -----------------------------------------------------------------------------
26 // PUBLIC
27 public:
29 // -------------------------------------------------------------------------
30 // CONSTRUCTOR & DESTRUCTOR
32 WebGLVertexArray(WebGLContext *context);
34 ~WebGLVertexArray() {
35 DeleteOnce();
39 // -------------------------------------------------------------------------
40 // IMPLMENET PARENT CLASSES
42 void Delete();
44 WebGLContext* GetParentObject() const {
45 return Context();
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 // -------------------------------------------------------------------------
56 // MEMBER FUNCTIONS
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 // -----------------------------------------------------------------------------
72 // PRIVATE
73 private:
75 // -------------------------------------------------------------------------
76 // MEMBERS
78 GLuint mGLName;
79 bool mHasEverBeenBound;
80 nsTArray<WebGLVertexAttribData> mAttribs;
81 WebGLRefPtr<WebGLBuffer> mBoundElementArrayBuffer;
84 // -------------------------------------------------------------------------
85 // FRIENDSHIPS
87 friend class WebGLContext;
90 } // namespace mozilla
92 #endif