gfx/skia/trunk/src/gpu/gl/debug/GrBufferObj.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     2 /*
     3  * Copyright 2012 Google Inc.
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
     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);
    19 public:
    20     GrBufferObj()
    21         : GrFakeRefObj()
    22         , fDataPtr(NULL)
    23         , fMapped(false)
    24         , fBound(false)
    25         , fSize(0)
    26         , fUsage(GR_GL_STATIC_DRAW) {
    27     }
    28     virtual ~GrBufferObj() {
    29         delete[] fDataPtr;
    30     }
    32     void access() {
    33         // cannot access the buffer if it is currently mapped
    34         GrAlwaysAssert(!fMapped);
    35     }
    37     void setMapped()             { fMapped = true; }
    38     void resetMapped()           { fMapped = false; }
    39     bool getMapped() const       { return fMapped; }
    41     void setBound()              { fBound = true; }
    42     void resetBound()            { fBound = false; }
    43     bool getBound() const        { return fBound; }
    45     void allocate(GrGLsizeiptr size, const GrGLchar *dataPtr);
    46     GrGLsizeiptr getSize() const { return fSize; }
    47     GrGLchar *getDataPtr()       { return fDataPtr; }
    49     void setUsage(GrGLint usage) { fUsage = usage; }
    50     GrGLint getUsage() const     { return fUsage; }
    52     virtual void deleteAction() SK_OVERRIDE;
    54 protected:
    55 private:
    57     GrGLchar*    fDataPtr;
    58     bool         fMapped;       // is the buffer object mapped via "glMapBuffer"?
    59     bool         fBound;        // is the buffer object bound via "glBindBuffer"?
    60     GrGLsizeiptr fSize;         // size in bytes
    61     GrGLint      fUsage;        // one of: GL_STREAM_DRAW,
    62                                 //         GL_STATIC_DRAW,
    63                                 //         GL_DYNAMIC_DRAW
    65     typedef GrFakeRefObj INHERITED;
    66 };
    68 #endif // GrBufferObj_DEFINED

mercurial