OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef GrBufferObj_DEFINED | 9 #ifndef GrBufferObj_DEFINED |
10 #define GrBufferObj_DEFINED | 10 #define GrBufferObj_DEFINED |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 virtual ~GrBufferObj() { | 28 virtual ~GrBufferObj() { |
29 delete[] fDataPtr; | 29 delete[] fDataPtr; |
30 } | 30 } |
31 | 31 |
32 void access() { | 32 void access() { |
33 // cannot access the buffer if it is currently mapped | 33 // cannot access the buffer if it is currently mapped |
34 GrAlwaysAssert(!fMapped); | 34 GrAlwaysAssert(!fMapped); |
35 } | 35 } |
36 | 36 |
37 void setMapped() { fMapped = true; } | 37 void setMapped(GrGLintptr offset, GrGLsizeiptr length) { |
| 38 fMapped = true; |
| 39 fMappedOffset = offset; |
| 40 fMappedLength = length; |
| 41 } |
38 void resetMapped() { fMapped = false; } | 42 void resetMapped() { fMapped = false; } |
39 bool getMapped() const { return fMapped; } | 43 bool getMapped() const { return fMapped; } |
| 44 GrGLsizei getMappedOffset() const { return fMappedOffset; } |
| 45 GrGLsizei getMappedLength() const { return fMappedLength; } |
40 | 46 |
41 void setBound() { fBound = true; } | 47 void setBound() { fBound = true; } |
42 void resetBound() { fBound = false; } | 48 void resetBound() { fBound = false; } |
43 bool getBound() const { return fBound; } | 49 bool getBound() const { return fBound; } |
44 | 50 |
45 void allocate(GrGLsizeiptr size, const GrGLchar *dataPtr); | 51 void allocate(GrGLsizeiptr size, const GrGLchar *dataPtr); |
46 GrGLsizeiptr getSize() const { return fSize; } | 52 GrGLsizeiptr getSize() const { return fSize; } |
47 GrGLchar *getDataPtr() { return fDataPtr; } | 53 GrGLchar *getDataPtr() { return fDataPtr; } |
48 | 54 |
49 void setUsage(GrGLint usage) { fUsage = usage; } | 55 void setUsage(GrGLint usage) { fUsage = usage; } |
50 GrGLint getUsage() const { return fUsage; } | 56 GrGLint getUsage() const { return fUsage; } |
51 | 57 |
52 virtual void deleteAction() SK_OVERRIDE; | 58 virtual void deleteAction() SK_OVERRIDE; |
53 | 59 |
54 protected: | 60 protected: |
55 private: | 61 private: |
56 | 62 |
57 GrGLchar* fDataPtr; | 63 GrGLchar* fDataPtr; |
58 bool fMapped; // is the buffer object mapped via "glMapBuffer"
? | 64 bool fMapped; // is the buffer object mapped via "glMapBuffer[
Range]"? |
| 65 GrGLintptr fMappedOffset; // the offset of the buffer range that is mapped |
| 66 GrGLsizeiptr fMappedLength; // the size of the buffer range that is mapped |
59 bool fBound; // is the buffer object bound via "glBindBuffer"
? | 67 bool fBound; // is the buffer object bound via "glBindBuffer"
? |
60 GrGLsizeiptr fSize; // size in bytes | 68 GrGLsizeiptr fSize; // size in bytes |
61 GrGLint fUsage; // one of: GL_STREAM_DRAW, | 69 GrGLint fUsage; // one of: GL_STREAM_DRAW, |
62 // GL_STATIC_DRAW, | 70 // GL_STATIC_DRAW, |
63 // GL_DYNAMIC_DRAW | 71 // GL_DYNAMIC_DRAW |
64 | 72 |
65 typedef GrFakeRefObj INHERITED; | 73 typedef GrFakeRefObj INHERITED; |
66 }; | 74 }; |
67 | 75 |
68 #endif // GrBufferObj_DEFINED | 76 #endif // GrBufferObj_DEFINED |
OLD | NEW |