OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2012 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 GrBufferObj_DEFINED | |
9 #define GrBufferObj_DEFINED | |
10 | |
11 #include "GrFakeRefObj.h" | |
12 #include "../GrGLDefines.h" | |
13 | |
14 //////////////////////////////////////////////////////////////////////////////// | |
15 class GrBufferObj : public GrFakeRefObj { | |
16 GR_DEFINE_CREATOR(GrBufferObj); | |
17 | |
18 public: | |
19 GrBufferObj() | |
20 : GrFakeRefObj() | |
21 , fDataPtr(nullptr) | |
22 , fMapped(false) | |
23 , fBound(false) | |
24 , fSize(0) | |
25 , fUsage(GR_GL_STATIC_DRAW) { | |
26 } | |
27 virtual ~GrBufferObj() { | |
28 delete[] fDataPtr; | |
29 } | |
30 | |
31 void access() { | |
32 // cannot access the buffer if it is currently mapped | |
33 GrAlwaysAssert(!fMapped); | |
34 } | |
35 | |
36 void setMapped(GrGLintptr offset, GrGLsizeiptr length) { | |
37 fMapped = true; | |
38 fMappedOffset = offset; | |
39 fMappedLength = length; | |
40 } | |
41 void resetMapped() { fMapped = false; } | |
42 bool getMapped() const { return fMapped; } | |
43 GrGLintptr getMappedOffset() const { return fMappedOffset; } | |
44 GrGLsizeiptr getMappedLength() const { return fMappedLength; } | |
45 | |
46 void setBound() { fBound = true; } | |
47 void resetBound() { fBound = false; } | |
48 bool getBound() const { return fBound; } | |
49 | |
50 void allocate(GrGLsizeiptr size, const GrGLchar *dataPtr); | |
51 GrGLsizeiptr getSize() const { return fSize; } | |
52 GrGLchar *getDataPtr() { return fDataPtr; } | |
53 | |
54 void setUsage(GrGLint usage) { fUsage = usage; } | |
55 GrGLint getUsage() const { return fUsage; } | |
56 | |
57 void deleteAction() override; | |
58 | |
59 protected: | |
60 private: | |
61 | |
62 GrGLchar* fDataPtr; | |
63 bool fMapped; // is the buffer object mapped via "glMapBuffer[
Range]"? | |
64 GrGLintptr fMappedOffset; // the offset of the buffer range that is mapped | |
65 GrGLsizeiptr fMappedLength; // the size of the buffer range that is mapped | |
66 bool fBound; // is the buffer object bound via "glBindBuffer"
? | |
67 GrGLsizeiptr fSize; // size in bytes | |
68 GrGLint fUsage; // one of: GL_STREAM_DRAW, | |
69 // GL_STATIC_DRAW, | |
70 // GL_DYNAMIC_DRAW | |
71 | |
72 typedef GrFakeRefObj INHERITED; | |
73 }; | |
74 | |
75 #endif // GrBufferObj_DEFINED | |
OLD | NEW |