Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / canvas / WebGLVertexArrayFake.cpp
blobc83e7e076657e5434383ef4b938e46fab0d6c4eb
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/. */
6 #include "WebGLVertexArrayFake.h"
8 #include "WebGLContext.h"
9 #include "GLContext.h"
11 namespace mozilla {
13 void
14 WebGLVertexArrayFake::BindVertexArrayImpl()
16 // Go through and re-bind all buffers and setup all
17 // vertex attribute pointers
18 gl::GLContext* gl = mContext->gl;
20 WebGLRefPtr<WebGLVertexArray> prevVertexArray = mContext->mBoundVertexArray;
22 mContext->mBoundVertexArray = this;
24 WebGLRefPtr<WebGLBuffer> prevBuffer = mContext->mBoundArrayBuffer;
25 mContext->BindBuffer(LOCAL_GL_ELEMENT_ARRAY_BUFFER, mElementArrayBuffer);
27 for (size_t i = 0; i < mAttribs.Length(); ++i) {
28 const WebGLVertexAttribData& vd = mAttribs[i];
30 mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, vd.buf);
32 gl->fVertexAttribPointer(i, vd.size, vd.type, vd.normalized,
33 vd.stride, reinterpret_cast<void*>(vd.byteOffset));
35 if (vd.enabled) {
36 gl->fEnableVertexAttribArray(i);
37 } else {
38 gl->fDisableVertexAttribArray(i);
42 for (size_t i = mAttribs.Length(); i < prevVertexArray->mAttribs.Length(); ++i) {
43 const WebGLVertexAttribData& vd = prevVertexArray->mAttribs[i];
45 if (vd.enabled) {
46 gl->fDisableVertexAttribArray(i);
50 mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, prevBuffer);
53 } // namespace mozilla