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