michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "GrGLIndexBuffer.h" michael@0: #include "GrGpuGL.h" michael@0: michael@0: GrGLIndexBuffer::GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc) michael@0: : INHERITED(gpu, desc.fIsWrapped, desc.fSizeInBytes, desc.fDynamic, 0 == desc.fID) michael@0: , fImpl(gpu, desc, GR_GL_ELEMENT_ARRAY_BUFFER) { michael@0: } michael@0: michael@0: void GrGLIndexBuffer::onRelease() { michael@0: if (this->isValid()) { michael@0: fImpl.release(this->getGpuGL()); michael@0: } michael@0: michael@0: INHERITED::onRelease(); michael@0: } michael@0: michael@0: void GrGLIndexBuffer::onAbandon() { michael@0: fImpl.abandon(); michael@0: INHERITED::onAbandon(); michael@0: } michael@0: michael@0: void* GrGLIndexBuffer::lock() { michael@0: if (this->isValid()) { michael@0: return fImpl.lock(this->getGpuGL()); michael@0: } else { michael@0: return NULL; michael@0: } michael@0: } michael@0: michael@0: void* GrGLIndexBuffer::lockPtr() const { michael@0: return fImpl.lockPtr(); michael@0: } michael@0: michael@0: void GrGLIndexBuffer::unlock() { michael@0: if (this->isValid()) { michael@0: fImpl.unlock(this->getGpuGL()); michael@0: } michael@0: } michael@0: michael@0: bool GrGLIndexBuffer::isLocked() const { michael@0: return fImpl.isLocked(); michael@0: } michael@0: michael@0: bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) { michael@0: if (this->isValid()) { michael@0: return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes); michael@0: } else { michael@0: return false; michael@0: } michael@0: }