DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "WebGLVertexArrayFake.h"

#include "WebGLContext.h"
#include "GLContext.h"

namespace mozilla {

void
WebGLVertexArrayFake::BindVertexArrayImpl()
{
    // Go through and re-bind all buffers and setup all
    // vertex attribute pointers
    gl::GLContext* gl = mContext->gl;

    WebGLRefPtr<WebGLVertexArray> prevVertexArray = mContext->mBoundVertexArray;

    mContext->mBoundVertexArray = this;

    WebGLRefPtr<WebGLBuffer> prevBuffer = mContext->mBoundArrayBuffer;
    mContext->BindBuffer(LOCAL_GL_ELEMENT_ARRAY_BUFFER, mElementArrayBuffer);

    for (size_t i = 0; i < mAttribs.Length(); ++i) {
        const WebGLVertexAttribData& vd = mAttribs[i];

        mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, vd.buf);

        gl->fVertexAttribPointer(i, vd.size, vd.type, vd.normalized,
                                 vd.stride, reinterpret_cast<void*>(vd.byteOffset));

        if (vd.enabled) {
            gl->fEnableVertexAttribArray(i);
        } else {
            gl->fDisableVertexAttribArray(i);
        }
    }

    for (size_t i = mAttribs.Length(); i < prevVertexArray->mAttribs.Length(); ++i) {
        const WebGLVertexAttribData& vd = prevVertexArray->mAttribs[i];

        if (vd.enabled) {
            gl->fDisableVertexAttribArray(i);
        }
    }

    mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, prevBuffer);
}

} // namespace mozilla