1 /* 2 Copyright 2011 Google Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 18 #ifndef GrGLIndexBuffer_DEFINED 19 #define GrGLIndexBuffer_DEFINED 20 21 #include "GrIndexBuffer.h" 22 #include "GrGLInterface.h" 23 24 class GrGpuGL; 25 26 class GrGLIndexBuffer : public GrIndexBuffer { 27 28 public: 29 30 virtual ~GrGLIndexBuffer() { this->release(); } 31 32 GrGLuint bufferID() const; 33 34 // overrides of GrIndexBuffer 35 virtual void* lock(); 36 virtual void* lockPtr() const; 37 virtual void unlock(); 38 virtual bool isLocked() const; 39 virtual bool updateData(const void* src, size_t srcSizeInBytes); 40 virtual bool updateSubData(const void* src, 41 size_t srcSizeInBytes, 42 size_t offset); 43 protected: 44 GrGLIndexBuffer(GrGpuGL* gpu, 45 GrGLuint id, 46 size_t sizeInBytes, 47 bool dynamic); 48 49 // overrides of GrResource 50 virtual void onAbandon(); 51 virtual void onRelease(); 52 53 private: 54 void bind() const; 55 56 GrGLuint fBufferID; 57 void* fLockPtr; 58 59 friend class GrGpuGL; 60 61 typedef GrIndexBuffer INHERITED; 62 }; 63 64 #endif 65