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