3 * Copyright 2012 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #ifndef GrBufferObj_DEFINED
10 #define GrBufferObj_DEFINED
12 #include "GrFakeRefObj.h"
13 #include "../GrGLDefines.h"
15 ////////////////////////////////////////////////////////////////////////////////
16 class GrBufferObj : public GrFakeRefObj {
17 GR_DEFINE_CREATOR(GrBufferObj);
26 , fUsage(GR_GL_STATIC_DRAW) {
28 virtual ~GrBufferObj() {
33 // cannot access the buffer if it is currently mapped
34 GrAlwaysAssert(!fMapped);
37 void setMapped(GrGLintptr offset, GrGLsizeiptr length) {
39 fMappedOffset = offset;
40 fMappedLength = length;
42 void resetMapped() { fMapped = false; }
43 bool getMapped() const { return fMapped; }
44 GrGLintptr getMappedOffset() const { return fMappedOffset; }
45 GrGLsizeiptr getMappedLength() const { return fMappedLength; }
47 void setBound() { fBound = true; }
48 void resetBound() { fBound = false; }
49 bool getBound() const { return fBound; }
51 void allocate(GrGLsizeiptr size, const GrGLchar *dataPtr);
52 GrGLsizeiptr getSize() const { return fSize; }
53 GrGLchar *getDataPtr() { return fDataPtr; }
55 void setUsage(GrGLint usage) { fUsage = usage; }
56 GrGLint getUsage() const { return fUsage; }
58 void deleteAction() SK_OVERRIDE;
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
67 bool fBound; // is the buffer object bound via "glBindBuffer"?
68 GrGLsizeiptr fSize; // size in bytes
69 GrGLint fUsage; // one of: GL_STREAM_DRAW,
73 typedef GrFakeRefObj INHERITED;
76 #endif // GrBufferObj_DEFINED