michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "VBOArena.h" michael@0: #include "GLContext.h" michael@0: michael@0: using namespace mozilla::gl; michael@0: michael@0: GLuint VBOArena::Allocate(GLContext *aGLContext) michael@0: { michael@0: if (!mAvailableVBOs.size()) { michael@0: GLuint vbo; michael@0: aGLContext->fGenBuffers(1, &vbo); michael@0: mAllocatedVBOs.push_back(vbo); michael@0: return vbo; michael@0: } michael@0: GLuint vbo = mAvailableVBOs.back(); michael@0: mAvailableVBOs.pop_back(); michael@0: return vbo; michael@0: } michael@0: michael@0: void VBOArena::Reset() michael@0: { michael@0: mAvailableVBOs = mAllocatedVBOs; michael@0: } michael@0: michael@0: void VBOArena::Flush(GLContext *aGLContext) michael@0: { michael@0: if (mAvailableVBOs.size()) { michael@0: #ifdef DEBUG michael@0: printf_stderr("VBOArena::Flush for %u VBOs\n", mAvailableVBOs.size()); michael@0: #endif michael@0: aGLContext->fDeleteBuffers(mAvailableVBOs.size(), &mAvailableVBOs[0]); michael@0: } michael@0: }