/src/mozilla-central/dom/canvas/WebGLVertexArray.cpp
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 | | #include "WebGLVertexArray.h" |
7 | | |
8 | | #include "GLContext.h" |
9 | | #include "mozilla/dom/WebGLRenderingContextBinding.h" |
10 | | #include "WebGLBuffer.h" |
11 | | #include "WebGLContext.h" |
12 | | #include "WebGLVertexArrayGL.h" |
13 | | #include "WebGLVertexArrayFake.h" |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | JSObject* |
18 | | WebGLVertexArray::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) |
19 | 0 | { |
20 | 0 | return dom::WebGLVertexArrayObject_Binding::Wrap(cx, this, givenProto); |
21 | 0 | } |
22 | | |
23 | | WebGLVertexArray::WebGLVertexArray(WebGLContext* webgl) |
24 | | : WebGLRefCountedObject(webgl) |
25 | | , mGLName(0) |
26 | 0 | { |
27 | 0 | mAttribs.SetLength(mContext->mGLMaxVertexAttribs); |
28 | 0 | mContext->mVertexArrays.insertBack(this); |
29 | 0 | } |
30 | | |
31 | | WebGLVertexArray::~WebGLVertexArray() |
32 | 0 | { |
33 | 0 | MOZ_ASSERT(IsDeleted()); |
34 | 0 | } |
35 | | |
36 | | void |
37 | | WebGLVertexArray::AddBufferBindCounts(int8_t addVal) const |
38 | 0 | { |
39 | 0 | const GLenum target = 0; // Anything non-TF is fine. |
40 | 0 | WebGLBuffer::AddBindCount(target, mElementArrayBuffer.get(), addVal); |
41 | 0 | for (const auto& attrib : mAttribs) { |
42 | 0 | WebGLBuffer::AddBindCount(target, attrib.mBuf.get(), addVal); |
43 | 0 | } |
44 | 0 | } |
45 | | |
46 | | WebGLVertexArray* |
47 | | WebGLVertexArray::Create(WebGLContext* webgl) |
48 | 0 | { |
49 | 0 | WebGLVertexArray* array; |
50 | 0 | if (webgl->gl->IsSupported(gl::GLFeature::vertex_array_object)) { |
51 | 0 | array = new WebGLVertexArrayGL(webgl); |
52 | 0 | } else { |
53 | 0 | array = new WebGLVertexArrayFake(webgl); |
54 | 0 | } |
55 | 0 | return array; |
56 | 0 | } |
57 | | |
58 | | void |
59 | | WebGLVertexArray::Delete() |
60 | 0 | { |
61 | 0 | DeleteImpl(); |
62 | 0 |
|
63 | 0 | LinkedListElement<WebGLVertexArray>::removeFrom(mContext->mVertexArrays); |
64 | 0 | mElementArrayBuffer = nullptr; |
65 | 0 | mAttribs.Clear(); |
66 | 0 | } |
67 | | |
68 | | bool |
69 | | WebGLVertexArray::IsVertexArray() const |
70 | 0 | { |
71 | 0 | return IsVertexArrayImpl(); |
72 | 0 | } |
73 | | |
74 | | NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebGLVertexArray, |
75 | | mAttribs, |
76 | | mElementArrayBuffer) |
77 | | |
78 | | NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLVertexArray, AddRef) |
79 | | NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLVertexArray, Release) |
80 | | |
81 | | } // namespace mozilla |