| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGLBufferImpl_DEFINED | 8 #ifndef GrGLBufferImpl_DEFINED |
| 9 #define GrGLBufferImpl_DEFINED | 9 #define GrGLBufferImpl_DEFINED |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 struct Desc { | 22 struct Desc { |
| 23 bool fIsWrapped; | 23 bool fIsWrapped; |
| 24 GrGLuint fID; // set to 0 to indicate buffer is CPU-backed
and not a VBO. | 24 GrGLuint fID; // set to 0 to indicate buffer is CPU-backed
and not a VBO. |
| 25 size_t fSizeInBytes; | 25 size_t fSizeInBytes; |
| 26 bool fDynamic; | 26 bool fDynamic; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 GrGLBufferImpl(GrGpuGL*, const Desc&, GrGLenum bufferType); | 29 GrGLBufferImpl(GrGpuGL*, const Desc&, GrGLenum bufferType); |
| 30 ~GrGLBufferImpl() { | 30 ~GrGLBufferImpl() { |
| 31 // either release or abandon should have been called by the owner of thi
s object. | 31 // either release or abandon should have been called by the owner of thi
s object. |
| 32 GrAssert(0 == fDesc.fID); | 32 SkASSERT(0 == fDesc.fID); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void abandon(); | 35 void abandon(); |
| 36 void release(GrGpuGL* gpu); | 36 void release(GrGpuGL* gpu); |
| 37 | 37 |
| 38 GrGLuint bufferID() const { return fDesc.fID; } | 38 GrGLuint bufferID() const { return fDesc.fID; } |
| 39 size_t baseOffset() const { return reinterpret_cast<size_t>(fCPUData); } | 39 size_t baseOffset() const { return reinterpret_cast<size_t>(fCPUData); } |
| 40 | 40 |
| 41 void bind(GrGpuGL* gpu) const; | 41 void bind(GrGpuGL* gpu) const; |
| 42 | 42 |
| 43 void* lock(GrGpuGL* gpu); | 43 void* lock(GrGpuGL* gpu); |
| 44 void* lockPtr() const { return fLockPtr; } | 44 void* lockPtr() const { return fLockPtr; } |
| 45 void unlock(GrGpuGL* gpu); | 45 void unlock(GrGpuGL* gpu); |
| 46 bool isLocked() const; | 46 bool isLocked() const; |
| 47 bool updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInBytes); | 47 bool updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInBytes); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 void validate() const; | 50 void validate() const; |
| 51 | 51 |
| 52 Desc fDesc; | 52 Desc fDesc; |
| 53 GrGLenum fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER | 53 GrGLenum fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER |
| 54 void* fCPUData; | 54 void* fCPUData; |
| 55 void* fLockPtr; | 55 void* fLockPtr; |
| 56 | 56 |
| 57 typedef GrNoncopyable INHERITED; | 57 typedef GrNoncopyable INHERITED; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 #endif | 60 #endif |
| OLD | NEW |