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->isValid()) {
     18         fImpl.release(this->getGpuGL());
     19     }
     20 
     21     INHERITED::onRelease();
     22 }
     23 
     24 
     25 void GrGLVertexBuffer::onAbandon() {
     26     fImpl.abandon();
     27     INHERITED::onAbandon();
     28 }
     29 
     30 void* GrGLVertexBuffer::lock() {
     31     if (this->isValid()) {
     32         return fImpl.lock(this->getGpuGL());
     33     } else {
     34         return NULL;
     35     }
     36 }
     37 
     38 void* GrGLVertexBuffer::lockPtr() const {
     39     return fImpl.lockPtr();
     40 }
     41 
     42 void GrGLVertexBuffer::unlock() {
     43     if (this->isValid()) {
     44         fImpl.unlock(this->getGpuGL());
     45     }
     46 }
     47 
     48 bool GrGLVertexBuffer::isLocked() const {
     49     return fImpl.isLocked();
     50 }
     51 
     52 bool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
     53     if (this->isValid()) {
     54         return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes);
     55     } else {
     56         return false;
     57     }
     58 }
     59