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 #ifndef GrGLIndexBuffer_DEFINED
      9 #define GrGLIndexBuffer_DEFINED
     10 
     11 #include "GrIndexBuffer.h"
     12 #include "GrGLBufferImpl.h"
     13 #include "gl/GrGLInterface.h"
     14 
     15 class GrGLGpu;
     16 
     17 class GrGLIndexBuffer : public GrIndexBuffer {
     18 
     19 public:
     20     typedef GrGLBufferImpl::Desc Desc;
     21 
     22     GrGLIndexBuffer(GrGLGpu* gpu, const Desc& desc);
     23 
     24     GrGLuint bufferID() const { return fImpl.bufferID(); }
     25     size_t baseOffset() const { return fImpl.baseOffset(); }
     26 
     27     void bind() const {
     28         if (!this->wasDestroyed()) {
     29             fImpl.bind(this->getGpuGL());
     30         }
     31     }
     32 
     33 protected:
     34     void onAbandon() override;
     35     void onRelease() override;
     36 
     37 private:
     38     void* onMap() override;
     39     void onUnmap() override;
     40     bool onUpdateData(const void* src, size_t srcSizeInBytes) override;
     41 
     42     GrGLGpu* getGpuGL() const {
     43         SkASSERT(!this->wasDestroyed());
     44         return (GrGLGpu*)(this->getGpu());
     45     }
     46 
     47     GrGLBufferImpl fImpl;
     48 
     49     typedef GrIndexBuffer INHERITED;
     50 };
     51 
     52 #endif
     53