Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2012 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef GrBufferObj_DEFINED |
michael@0 | 10 | #define GrBufferObj_DEFINED |
michael@0 | 11 | |
michael@0 | 12 | #include "GrFakeRefObj.h" |
michael@0 | 13 | #include "../GrGLDefines.h" |
michael@0 | 14 | |
michael@0 | 15 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 16 | class GrBufferObj : public GrFakeRefObj { |
michael@0 | 17 | GR_DEFINE_CREATOR(GrBufferObj); |
michael@0 | 18 | |
michael@0 | 19 | public: |
michael@0 | 20 | GrBufferObj() |
michael@0 | 21 | : GrFakeRefObj() |
michael@0 | 22 | , fDataPtr(NULL) |
michael@0 | 23 | , fMapped(false) |
michael@0 | 24 | , fBound(false) |
michael@0 | 25 | , fSize(0) |
michael@0 | 26 | , fUsage(GR_GL_STATIC_DRAW) { |
michael@0 | 27 | } |
michael@0 | 28 | virtual ~GrBufferObj() { |
michael@0 | 29 | delete[] fDataPtr; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | void access() { |
michael@0 | 33 | // cannot access the buffer if it is currently mapped |
michael@0 | 34 | GrAlwaysAssert(!fMapped); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | void setMapped() { fMapped = true; } |
michael@0 | 38 | void resetMapped() { fMapped = false; } |
michael@0 | 39 | bool getMapped() const { return fMapped; } |
michael@0 | 40 | |
michael@0 | 41 | void setBound() { fBound = true; } |
michael@0 | 42 | void resetBound() { fBound = false; } |
michael@0 | 43 | bool getBound() const { return fBound; } |
michael@0 | 44 | |
michael@0 | 45 | void allocate(GrGLsizeiptr size, const GrGLchar *dataPtr); |
michael@0 | 46 | GrGLsizeiptr getSize() const { return fSize; } |
michael@0 | 47 | GrGLchar *getDataPtr() { return fDataPtr; } |
michael@0 | 48 | |
michael@0 | 49 | void setUsage(GrGLint usage) { fUsage = usage; } |
michael@0 | 50 | GrGLint getUsage() const { return fUsage; } |
michael@0 | 51 | |
michael@0 | 52 | virtual void deleteAction() SK_OVERRIDE; |
michael@0 | 53 | |
michael@0 | 54 | protected: |
michael@0 | 55 | private: |
michael@0 | 56 | |
michael@0 | 57 | GrGLchar* fDataPtr; |
michael@0 | 58 | bool fMapped; // is the buffer object mapped via "glMapBuffer"? |
michael@0 | 59 | bool fBound; // is the buffer object bound via "glBindBuffer"? |
michael@0 | 60 | GrGLsizeiptr fSize; // size in bytes |
michael@0 | 61 | GrGLint fUsage; // one of: GL_STREAM_DRAW, |
michael@0 | 62 | // GL_STATIC_DRAW, |
michael@0 | 63 | // GL_DYNAMIC_DRAW |
michael@0 | 64 | |
michael@0 | 65 | typedef GrFakeRefObj INHERITED; |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | #endif // GrBufferObj_DEFINED |