gfx/skia/trunk/src/gpu/gl/GrGLBufferImpl.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  * Copyright 2013 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  */
     8 #ifndef GrGLBufferImpl_DEFINED
     9 #define GrGLBufferImpl_DEFINED
    11 #include "SkTypes.h"
    12 #include "gl/GrGLFunctions.h"
    14 class GrGpuGL;
    16 /**
    17  * This class serves as the implementation of GrGL*Buffer classes. It was written to avoid code
    18  * duplication in those classes.
    19  */
    20 class GrGLBufferImpl : public SkNoncopyable {
    21 public:
    22     struct Desc {
    23         bool        fIsWrapped;
    24         GrGLuint    fID;            // set to 0 to indicate buffer is CPU-backed and not a VBO.
    25         size_t      fSizeInBytes;
    26         bool        fDynamic;
    27     };
    29     GrGLBufferImpl(GrGpuGL*, const Desc&, GrGLenum bufferType);
    30     ~GrGLBufferImpl() {
    31         // either release or abandon should have been called by the owner of this object.
    32         SkASSERT(0 == fDesc.fID);
    33     }
    35     void abandon();
    36     void release(GrGpuGL* gpu);
    38     GrGLuint bufferID() const { return fDesc.fID; }
    39     size_t baseOffset() const { return reinterpret_cast<size_t>(fCPUData); }
    41     void bind(GrGpuGL* gpu) const;
    43     void* lock(GrGpuGL* gpu);
    44     void* lockPtr() const { return fLockPtr; }
    45     void unlock(GrGpuGL* gpu);
    46     bool isLocked() const;
    47     bool updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInBytes);
    49 private:
    50     void validate() const;
    52     Desc         fDesc;
    53     GrGLenum     fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER
    54     void*        fCPUData;
    55     void*        fLockPtr;
    57     typedef SkNoncopyable INHERITED;
    58 };
    60 #endif

mercurial