Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/canvas/WebGLVertexArrayFake.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 "WebGLVertexArrayFake.h"
7
8
#include "GLContext.h"
9
#include "WebGLContext.h"
10
11
namespace mozilla {
12
13
WebGLVertexArrayFake::WebGLVertexArrayFake(WebGLContext* webgl)
14
    : WebGLVertexArray(webgl)
15
    , mIsVAO(false)
16
0
{ }
17
18
void
19
WebGLVertexArrayFake::BindVertexArrayImpl()
20
0
{
21
0
    // Go through and re-bind all buffers and setup all
22
0
    // vertex attribute pointers
23
0
    gl::GLContext* gl = mContext->gl;
24
0
25
0
    WebGLRefPtr<WebGLVertexArray> prevVertexArray = mContext->mBoundVertexArray;
26
0
27
0
    mContext->mBoundVertexArray = this;
28
0
29
0
    WebGLRefPtr<WebGLBuffer> prevBuffer = mContext->mBoundArrayBuffer;
30
0
    mContext->BindBuffer(LOCAL_GL_ELEMENT_ARRAY_BUFFER, mElementArrayBuffer);
31
0
32
0
    size_t i = 0;
33
0
    for (const auto& vd : mAttribs) {
34
0
        mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, vd.mBuf);
35
0
        vd.DoVertexAttribPointer(gl, i);
36
0
37
0
        if (vd.mEnabled) {
38
0
            gl->fEnableVertexAttribArray(i);
39
0
        } else {
40
0
            gl->fDisableVertexAttribArray(i);
41
0
        }
42
0
        ++i;
43
0
    }
44
0
45
0
    size_t len = prevVertexArray->mAttribs.Length();
46
0
    for (; i < len; ++i) {
47
0
        const auto& vd = prevVertexArray->mAttribs[i];
48
0
49
0
        if (vd.mEnabled) {
50
0
            gl->fDisableVertexAttribArray(i);
51
0
        }
52
0
    }
53
0
54
0
    mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, prevBuffer);
55
0
    mIsVAO = true;
56
0
}
57
58
void
59
WebGLVertexArrayFake::DeleteImpl()
60
0
{
61
0
    mIsVAO = false;
62
0
}
63
64
bool
65
WebGLVertexArrayFake::IsVertexArrayImpl() const
66
0
{
67
0
    return mIsVAO;
68
0
}
69
70
} // namespace mozilla