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