| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 GrGLBuffer_DEFINED | 8 #ifndef GrGLBuffer_DEFINED |
| 9 #define GrGLBuffer_DEFINED | 9 #define GrGLBuffer_DEFINED |
| 10 | 10 |
| 11 #include "GrBuffer.h" | 11 #include "GrBuffer.h" |
| 12 #include "gl/GrGLTypes.h" | 12 #include "gl/GrGLTypes.h" |
| 13 | 13 |
| 14 class GrGLGpu; | 14 class GrGLGpu; |
| 15 class GrGLCaps; | 15 class GrGLCaps; |
| 16 | 16 |
| 17 class GrGLBuffer : public GrBuffer { | 17 class GrGLBuffer : public GrBuffer { |
| 18 public: | 18 public: |
| 19 static GrGLBuffer* Create(GrGLGpu*, size_t size, GrBufferType intendedType,
GrAccessPattern, | 19 static GrGLBuffer* Create(GrGLGpu*, GrBufferType, size_t size, GrAccessPatte
rn); |
| 20 const void* data = nullptr); | |
| 21 | 20 |
| 22 ~GrGLBuffer() { | 21 ~GrGLBuffer() { |
| 23 // either release or abandon should have been called by the owner of thi
s object. | 22 // either release or abandon should have been called by the owner of thi
s object. |
| 24 SkASSERT(0 == fBufferID); | 23 SkASSERT(0 == fBufferID); |
| 25 } | 24 } |
| 26 | 25 |
| 26 GrGLenum target() const { return fTarget; } |
| 27 GrGLuint bufferID() const { return fBufferID; } | 27 GrGLuint bufferID() const { return fBufferID; } |
| 28 size_t baseOffset() const { return reinterpret_cast<size_t>(fCPUData); } | 28 size_t baseOffset() const { return reinterpret_cast<size_t>(fCPUData); } |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 GrGLBuffer(GrGLGpu*, size_t size, GrBufferType intendedType, GrAccessPattern
, bool cpuBacked, | 31 GrGLBuffer(GrGLGpu*, GrBufferType, size_t size, GrAccessPattern, bool cpuBac
ked); |
| 32 const void* data); | |
| 33 | 32 |
| 34 void onAbandon() override; | 33 void onAbandon() override; |
| 35 void onRelease() override; | 34 void onRelease() override; |
| 36 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 35 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 37 const SkString& dumpName) const override; | 36 const SkString& dumpName) const override; |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 GrGLGpu* glGpu() const; | 39 GrGLGpu* glGpu() const; |
| 41 const GrGLCaps& glCaps() const; | 40 const GrGLCaps& glCaps() const; |
| 42 | 41 |
| 43 void onMap() override; | 42 void onMap() override; |
| 44 void onUnmap() override; | 43 void onUnmap() override; |
| 45 bool onUpdateData(const void* src, size_t srcSizeInBytes) override; | 44 bool onUpdateData(const void* src, size_t srcSizeInBytes) override; |
| 46 | 45 |
| 47 #ifdef SK_DEBUG | 46 #ifdef SK_DEBUG |
| 48 void validate() const; | 47 void validate() const; |
| 49 #endif | 48 #endif |
| 50 | 49 |
| 51 void* fCPUData; | 50 void* fCPUData; |
| 52 GrBufferType fIntendedType; | 51 GrGLenum fTarget; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER, e.g. |
| 53 GrGLuint fBufferID; | 52 GrGLuint fBufferID; |
| 54 size_t fSizeInBytes; | 53 size_t fSizeInBytes; |
| 55 GrGLenum fUsage; | 54 GrGLenum fUsage; |
| 56 size_t fGLSizeInBytes; // In certain cases we make the size of t
he GL buffer object | 55 size_t fGLSizeInBytes; // In certain cases we make the size of the
GL buffer object |
| 57 // smaller or larger than the size in fDe
sc. | 56 // smaller or larger than the size in fDesc
. |
| 58 | 57 |
| 59 typedef GrBuffer INHERITED; | 58 typedef GrBuffer INHERITED; |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 #endif | 61 #endif |
| OLD | NEW |