• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 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 GrGLVertexBuffer_DEFINED
9 #define GrGLVertexBuffer_DEFINED
10 
11 #include "GrVertexBuffer.h"
12 #include "GrGLBufferImpl.h"
13 #include "gl/GrGLInterface.h"
14 
15 class GrGpuGL;
16 
17 class GrGLVertexBuffer : public GrVertexBuffer {
18 
19 public:
20     typedef GrGLBufferImpl::Desc Desc;
21 
22     GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc);
~GrGLVertexBuffer()23     virtual ~GrGLVertexBuffer() { this->release(); }
24 
bufferID()25     GrGLuint bufferID() const { return fImpl.bufferID(); }
baseOffset()26     size_t baseOffset() const { return fImpl.baseOffset(); }
27 
bind()28     void bind() const {
29         if (this->isValid()) {
30             fImpl.bind(this->getGpuGL());
31         }
32     }
33 
34     // overrides of GrVertexBuffer
35     virtual void* lock();
36     virtual void* lockPtr() const;
37     virtual void unlock();
38     virtual bool isLocked() const;
39     virtual bool updateData(const void* src, size_t srcSizeInBytes);
40 
41 protected:
42     // overrides of GrResource
43     virtual void onAbandon() SK_OVERRIDE;
44     virtual void onRelease() SK_OVERRIDE;
45 
46 private:
getGpuGL()47     GrGpuGL* getGpuGL() const {
48         SkASSERT(this->isValid());
49         return (GrGpuGL*)(this->getGpu());
50     }
51 
52     GrGLBufferImpl fImpl;
53 
54     typedef GrVertexBuffer INHERITED;
55 };
56 
57 #endif
58