Line data Source code
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 WEBGL_VERTEX_ARRAY_H_
7 : #define WEBGL_VERTEX_ARRAY_H_
8 :
9 : #include "nsTArray.h"
10 : #include "mozilla/LinkedList.h"
11 : #include "nsWrapperCache.h"
12 :
13 : #include "WebGLObjectModel.h"
14 : #include "WebGLStrongTypes.h"
15 : #include "WebGLVertexAttribData.h"
16 :
17 : namespace mozilla {
18 :
19 : class WebGLVertexArrayFake;
20 :
21 : class WebGLVertexArray
22 : : public nsWrapperCache
23 : , public WebGLRefCountedObject<WebGLVertexArray>
24 : , public LinkedListElement<WebGLVertexArray>
25 : {
26 : public:
27 : static WebGLVertexArray* Create(WebGLContext* webgl);
28 :
29 0 : void BindVertexArray() {
30 : // Bind to dummy value to signal that this vertex array has ever been
31 : // bound.
32 0 : BindVertexArrayImpl();
33 0 : };
34 :
35 : // Implement parent classes:
36 : void Delete();
37 : bool IsVertexArray() const;
38 :
39 0 : WebGLContext* GetParentObject() const {
40 0 : return mContext;
41 : }
42 :
43 : virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
44 :
45 0 : NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray)
46 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray)
47 :
48 0 : GLuint GLName() const { return mGLName; }
49 :
50 : void AddBufferBindCounts(int8_t addVal) const;
51 :
52 : protected:
53 : explicit WebGLVertexArray(WebGLContext* webgl);
54 : virtual ~WebGLVertexArray();
55 :
56 : virtual void GenVertexArray() = 0;
57 : virtual void BindVertexArrayImpl() = 0;
58 : virtual void DeleteImpl() = 0;
59 : virtual bool IsVertexArrayImpl() const = 0;
60 :
61 : GLuint mGLName;
62 : nsTArray<WebGLVertexAttribData> mAttribs;
63 : WebGLRefPtr<WebGLBuffer> mElementArrayBuffer;
64 :
65 : friend class ScopedDrawHelper;
66 : friend class WebGLContext;
67 : friend class WebGLVertexArrayFake;
68 : friend class WebGL2Context;
69 : };
70 :
71 : } // namespace mozilla
72 :
73 : #endif // WEBGL_VERTEX_ARRAY_H_
|