1/* 2 * Copyright 2011 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#include "GrGLVertexBuffer.h" 9#include "GrGLGpu.h" 10 11GrGLVertexBuffer::GrGLVertexBuffer(GrGLGpu* gpu, const Desc& desc) 12 : INHERITED(gpu, desc.fSizeInBytes, desc.fDynamic, 0 == desc.fID) 13 , fImpl(gpu, desc, GR_GL_ARRAY_BUFFER) { 14 this->registerWithCache(); 15} 16 17void GrGLVertexBuffer::onRelease() { 18 if (!this->wasDestroyed()) { 19 fImpl.release(this->getGpuGL()); 20 } 21 22 INHERITED::onRelease(); 23} 24 25void GrGLVertexBuffer::onAbandon() { 26 fImpl.abandon(); 27 INHERITED::onAbandon(); 28} 29 30void* GrGLVertexBuffer::onMap() { 31 if (!this->wasDestroyed()) { 32 return fImpl.map(this->getGpuGL()); 33 } else { 34 return NULL; 35 } 36} 37 38void GrGLVertexBuffer::onUnmap() { 39 if (!this->wasDestroyed()) { 40 fImpl.unmap(this->getGpuGL()); 41 } 42} 43 44bool GrGLVertexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) { 45 if (!this->wasDestroyed()) { 46 return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes); 47 } else { 48 return false; 49 } 50} 51