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 GrGpuGL; 16 17 class GrGLIndexBuffer : public GrIndexBuffer { 18 19 public: 20 typedef GrGLBufferImpl::Desc Desc; 21 22 GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc); 23 virtual ~GrGLIndexBuffer() { this->release(); } 24 25 GrGLuint bufferID() const { return fImpl.bufferID(); } 26 size_t baseOffset() const { return fImpl.baseOffset(); } 27 28 void bind() const { 29 if (!this->wasDestroyed()) { 30 fImpl.bind(this->getGpuGL()); 31 } 32 } 33 34 protected: 35 virtual void onAbandon() SK_OVERRIDE; 36 virtual void onRelease() SK_OVERRIDE; 37 38 private: 39 virtual void* onMap() SK_OVERRIDE; 40 virtual void onUnmap() SK_OVERRIDE; 41 virtual bool onUpdateData(const void* src, size_t srcSizeInBytes) SK_OVERRIDE; 42 43 GrGpuGL* getGpuGL() const { 44 SkASSERT(!this->wasDestroyed()); 45 return (GrGpuGL*)(this->getGpu()); 46 } 47 48 GrGLBufferImpl fImpl; 49 50 typedef GrIndexBuffer INHERITED; 51 }; 52 53 #endif 54