Bumping manifests a=b2g-bump
[gecko.git] / dom / canvas / WebGLVertexArray.h
blobbc43858c4b5f92226b816560852ce0e0e52c4e1c
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"
17 namespace mozilla {
19 class WebGLVertexArrayFake;
21 class WebGLVertexArray
22 : public nsWrapperCache
23 , public WebGLBindable<VAOBinding>
24 , public WebGLRefCountedObject<WebGLVertexArray>
25 , public LinkedListElement<WebGLVertexArray>
26 , public WebGLContextBoundObject
28 public:
29 static WebGLVertexArray* Create(WebGLContext* webgl);
31 void BindVertexArray() {
32 // Bind to dummy value to signal that this vertex array has ever been
33 // bound.
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:
51 void Delete();
53 WebGLContext* GetParentObject() const {
54 return Context();
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; }
64 protected:
65 explicit WebGLVertexArray(WebGLContext* webgl);
67 virtual ~WebGLVertexArray() {
68 MOZ_ASSERT(IsDeleted());
71 GLuint mGLName;
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_