| 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 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #include "gl/GrGLTypes.h" | 12 #include "gl/GrGLTypes.h" |
| 13 | 13 |
| 14 class GrGLGpu; | 14 class GrGLGpu; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * This class serves as the implementation of GrGL*Buffer classes. It was writte
n to avoid code | 17 * This class serves as the implementation of GrGL*Buffer classes. It was writte
n to avoid code |
| 18 * duplication in those classes. | 18 * duplication in those classes. |
| 19 */ | 19 */ |
| 20 class GrGLBufferImpl : SkNoncopyable { | 20 class GrGLBufferImpl : SkNoncopyable { |
| 21 public: | 21 public: |
| 22 enum Usage { |
| 23 kStaticDraw_Usage = 0, |
| 24 kDynamicDraw_Usage, |
| 25 kStreamDraw_Usage, |
| 26 kStreamRead_Usage, |
| 27 |
| 28 kLast_Usage = kStreamRead_Usage |
| 29 }; |
| 30 static const int kUsageCount = kLast_Usage + 1; |
| 31 |
| 22 struct Desc { | 32 struct Desc { |
| 23 GrGLuint fID; // set to 0 to indicate buffer is CPU-backed
and not a VBO. | 33 GrGLuint fID; // set to 0 to indicate buffer is CPU-backed
and not a VBO. |
| 24 size_t fSizeInBytes; | 34 size_t fSizeInBytes; |
| 25 bool fDynamic; | 35 Usage fUsage; |
| 26 }; | 36 }; |
| 27 | 37 |
| 28 GrGLBufferImpl(GrGLGpu*, const Desc&, GrGLenum bufferType); | 38 GrGLBufferImpl(GrGLGpu*, const Desc&, GrGLenum bufferType); |
| 29 ~GrGLBufferImpl() { | 39 ~GrGLBufferImpl() { |
| 30 // either release or abandon should have been called by the owner of thi
s object. | 40 // either release or abandon should have been called by the owner of thi
s object. |
| 31 SkASSERT(0 == fDesc.fID); | 41 SkASSERT(0 == fDesc.fID); |
| 32 } | 42 } |
| 33 | 43 |
| 34 void abandon(); | 44 void abandon(); |
| 35 void release(GrGLGpu* gpu); | 45 void release(GrGLGpu* gpu); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 GrGLenum fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER | 59 GrGLenum fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER |
| 50 void* fCPUData; | 60 void* fCPUData; |
| 51 void* fMapPtr; | 61 void* fMapPtr; |
| 52 size_t fGLSizeInBytes; // In certain cases we make the size of the
GL buffer object | 62 size_t fGLSizeInBytes; // In certain cases we make the size of the
GL buffer object |
| 53 // smaller or larger than the size in fDesc
. | 63 // smaller or larger than the size in fDesc
. |
| 54 | 64 |
| 55 typedef SkNoncopyable INHERITED; | 65 typedef SkNoncopyable INHERITED; |
| 56 }; | 66 }; |
| 57 | 67 |
| 58 #endif | 68 #endif |
| OLD | NEW |