/src/mozilla-central/dom/canvas/WebGLContextVertexArray.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 "WebGLContext.h" |
7 | | |
8 | | #include "GLContext.h" |
9 | | #include "WebGLBuffer.h" |
10 | | #include "WebGLVertexArray.h" |
11 | | #include "WebGLVertexAttribData.h" |
12 | | |
13 | | namespace mozilla { |
14 | | |
15 | | void |
16 | | WebGLContext::BindVertexArray(WebGLVertexArray* array) |
17 | 0 | { |
18 | 0 | const FuncScope funcScope(*this, "bindVertexArray"); |
19 | 0 | if (IsContextLost()) |
20 | 0 | return; |
21 | 0 | |
22 | 0 | if (array && !ValidateObject("array", *array)) |
23 | 0 | return; |
24 | 0 | |
25 | 0 | if (mBoundVertexArray) { |
26 | 0 | mBoundVertexArray->AddBufferBindCounts(-1); |
27 | 0 | } |
28 | 0 |
|
29 | 0 | if (array == nullptr) { |
30 | 0 | array = mDefaultVertexArray; |
31 | 0 | } |
32 | 0 |
|
33 | 0 | array->BindVertexArray(); |
34 | 0 |
|
35 | 0 | MOZ_ASSERT(mBoundVertexArray == array); |
36 | 0 | if (mBoundVertexArray) { |
37 | 0 | mBoundVertexArray->AddBufferBindCounts(+1); |
38 | 0 | } |
39 | 0 | } |
40 | | |
41 | | already_AddRefed<WebGLVertexArray> |
42 | | WebGLContext::CreateVertexArray() |
43 | 0 | { |
44 | 0 | const FuncScope funcScope(*this, "createVertexArray"); |
45 | 0 | if (IsContextLost()) |
46 | 0 | return nullptr; |
47 | 0 | |
48 | 0 | RefPtr<WebGLVertexArray> globj = CreateVertexArrayImpl(); |
49 | 0 |
|
50 | 0 | globj->GenVertexArray(); |
51 | 0 |
|
52 | 0 | return globj.forget(); |
53 | 0 | } |
54 | | |
55 | | WebGLVertexArray* |
56 | | WebGLContext::CreateVertexArrayImpl() |
57 | 0 | { |
58 | 0 | return WebGLVertexArray::Create(this); |
59 | 0 | } |
60 | | |
61 | | void |
62 | | WebGLContext::DeleteVertexArray(WebGLVertexArray* array) |
63 | 0 | { |
64 | 0 | const FuncScope funcScope(*this, "deleteVertexArray"); |
65 | 0 | if (!ValidateDeleteObject(array)) |
66 | 0 | return; |
67 | 0 | |
68 | 0 | if (mBoundVertexArray == array) |
69 | 0 | BindVertexArray(static_cast<WebGLVertexArray*>(nullptr)); |
70 | 0 |
|
71 | 0 | array->RequestDelete(); |
72 | 0 | } |
73 | | |
74 | | } // namespace mozilla |