michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrGLIndexBuffer_DEFINED michael@0: #define GrGLIndexBuffer_DEFINED michael@0: michael@0: #include "GrIndexBuffer.h" michael@0: #include "GrGLBufferImpl.h" michael@0: #include "gl/GrGLInterface.h" michael@0: michael@0: class GrGpuGL; michael@0: michael@0: class GrGLIndexBuffer : public GrIndexBuffer { michael@0: michael@0: public: michael@0: typedef GrGLBufferImpl::Desc Desc; michael@0: michael@0: GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc); michael@0: virtual ~GrGLIndexBuffer() { this->release(); } michael@0: michael@0: GrGLuint bufferID() const { return fImpl.bufferID(); } michael@0: size_t baseOffset() const { return fImpl.baseOffset(); } michael@0: michael@0: void bind() const { michael@0: if (this->isValid()) { michael@0: fImpl.bind(this->getGpuGL()); michael@0: } michael@0: } michael@0: michael@0: // overrides of GrIndexBuffer michael@0: virtual void* lock(); michael@0: virtual void* lockPtr() const; michael@0: virtual void unlock(); michael@0: virtual bool isLocked() const; michael@0: virtual bool updateData(const void* src, size_t srcSizeInBytes); michael@0: michael@0: protected: michael@0: // overrides of GrResource michael@0: virtual void onAbandon() SK_OVERRIDE; michael@0: virtual void onRelease() SK_OVERRIDE; michael@0: michael@0: private: michael@0: GrGpuGL* getGpuGL() const { michael@0: SkASSERT(this->isValid()); michael@0: return (GrGpuGL*)(this->getGpu()); michael@0: } michael@0: michael@0: GrGLBufferImpl fImpl; michael@0: michael@0: typedef GrIndexBuffer INHERITED; michael@0: }; michael@0: michael@0: #endif