Home | History | Annotate | Download | only in gl
      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 "GrGpuGL.h"
     10 
     11 GrGLVertexBuffer::GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc)
     12     : INHERITED(gpu, desc.fIsWrapped, desc.fSizeInBytes, desc.fDynamic, 0 == desc.fID)
     13     , fImpl(gpu, desc, GR_GL_ARRAY_BUFFER) {
     14 }
     15 
     16 void GrGLVertexBuffer::onRelease() {
     17     if (!this->wasDestroyed()) {
     18         fImpl.release(this->getGpuGL());
     19     }
     20 
     21     INHERITED::onRelease();
     22 }
     23 
     24 void GrGLVertexBuffer::onAbandon() {
     25     fImpl.abandon();
     26     INHERITED::onAbandon();
     27 }
     28 
     29 void* GrGLVertexBuffer::onMap() {
     30     if (!this->wasDestroyed()) {
     31         return fImpl.map(this->getGpuGL());
     32     } else {
     33         return NULL;
     34     }
     35 }
     36 
     37 void GrGLVertexBuffer::onUnmap() {
     38     if (!this->wasDestroyed()) {
     39         fImpl.unmap(this->getGpuGL());
     40     }
     41 }
     42 
     43 bool GrGLVertexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) {
     44     if (!this->wasDestroyed()) {
     45         return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes);
     46     } else {
     47         return false;
     48     }
     49 }
     50