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*, size_t size, GrBufferType intendedType, GrAccessPattern, |
20 const void* data = nullptr); | 20 const void* data = nullptr); |
21 | 21 |
22 ~GrGLBuffer() { | 22 ~GrGLBuffer() { |
23 // 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. |
24 SkASSERT(0 == fBufferID); | 24 SkASSERT(0 == fBufferID); |
25 } | 25 } |
26 | 26 |
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 /** | |
31 * Returns the actual size of the underlying GL buffer object. In certain ca ses we may make this | |
32 * smaller than the size reported by GrBuffer. | |
33 */ | |
34 size_t glSizeInBytes() const { return fGLSizeInBytes; } | |
35 | |
36 void setHasAttachedToTexture() { fHasAttachedToTexture = true; } | |
bsalomon
2016/04/11 16:51:38
Maybe (set)isAttachedToTexture? More clear that is
Chris Dalton
2016/04/11 19:48:19
Actually the intention of this bool is to know if
bsalomon
2016/04/11 20:37:11
Got it. I'm ok with it as is.
| |
37 bool hasAttachedToTexture() const { return fHasAttachedToTexture; } | |
38 | |
30 protected: | 39 protected: |
31 GrGLBuffer(GrGLGpu*, size_t size, GrBufferType intendedType, GrAccessPattern , bool cpuBacked, | 40 GrGLBuffer(GrGLGpu*, size_t size, GrBufferType intendedType, GrAccessPattern , bool cpuBacked, |
32 const void* data); | 41 const void* data); |
33 | 42 |
34 void onAbandon() override; | 43 void onAbandon() override; |
35 void onRelease() override; | 44 void onRelease() override; |
36 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 45 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
37 const SkString& dumpName) const override; | 46 const SkString& dumpName) const override; |
38 | 47 |
39 private: | 48 private: |
40 GrGLGpu* glGpu() const; | 49 GrGLGpu* glGpu() const; |
41 const GrGLCaps& glCaps() const; | 50 const GrGLCaps& glCaps() const; |
42 | 51 |
43 void onMap() override; | 52 void onMap() override; |
44 void onUnmap() override; | 53 void onUnmap() override; |
45 bool onUpdateData(const void* src, size_t srcSizeInBytes) override; | 54 bool onUpdateData(const void* src, size_t srcSizeInBytes) override; |
46 | 55 |
47 #ifdef SK_DEBUG | 56 #ifdef SK_DEBUG |
48 void validate() const; | 57 void validate() const; |
49 #endif | 58 #endif |
50 | 59 |
51 void* fCPUData; | 60 void* fCPUData; |
52 GrBufferType fIntendedType; | 61 GrBufferType fIntendedType; |
53 GrGLuint fBufferID; | 62 GrGLuint fBufferID; |
54 size_t fSizeInBytes; | 63 size_t fSizeInBytes; |
55 GrGLenum fUsage; | 64 GrGLenum fUsage; |
56 size_t fGLSizeInBytes; // In certain cases we make the size of t he GL buffer object | 65 size_t fGLSizeInBytes; |
57 // smaller or larger than the size in fDe sc. | 66 bool fHasAttachedToTexture; |
58 | 67 |
59 typedef GrBuffer INHERITED; | 68 typedef GrBuffer INHERITED; |
60 }; | 69 }; |
61 | 70 |
62 #endif | 71 #endif |
OLD | NEW |