blob: 61b5020404d2531dedb955ded8b20c37f1034914 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@google.comac10a2d2010-12-22 21:39:39 +000010#ifndef GrGLVertexBuffer_DEFINED
11#define GrGLVertexBuffer_DEFINED
12
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000013#include "GrVertexBuffer.h"
tomhudson@google.com6bf38b52012-02-14 15:11:59 +000014#include "gl/GrGLInterface.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015
16class GrGpuGL;
17
18class GrGLVertexBuffer : public GrVertexBuffer {
reed@google.comac10a2d2010-12-22 21:39:39 +000019
20public:
bsalomon@google.com880b8fc2013-02-19 20:17:28 +000021 GrGLVertexBuffer(GrGpuGL* gpu,
22 bool isWrapped,
23 GrGLuint id,
24 size_t sizeInBytes,
25 bool dynamic);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000026 virtual ~GrGLVertexBuffer() { this->release(); }
bsalomon@google.com880b8fc2013-02-19 20:17:28 +000027
28 GrGLuint bufferID() const { return fBufferID; }
29 size_t baseOffset() const { return 0; }
30
31 void bind() const;
32
reed@google.comac10a2d2010-12-22 21:39:39 +000033 // overrides of GrVertexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000034 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000035 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000036 virtual void unlock();
37 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000038 virtual bool updateData(const void* src, size_t srcSizeInBytes);
reed@google.comac10a2d2010-12-22 21:39:39 +000039
bsalomon@google.com8fe72472011-03-30 21:26:44 +000040protected:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000041 // overrides of GrResource
robertphillips@google.comd3645542012-09-05 18:37:39 +000042 virtual void onAbandon() SK_OVERRIDE;
43 virtual void onRelease() SK_OVERRIDE;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000044
reed@google.comac10a2d2010-12-22 21:39:39 +000045private:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000046
twiz@google.com0f31ca72011-03-18 17:38:11 +000047 GrGLuint fBufferID;
reed@google.comac10a2d2010-12-22 21:39:39 +000048 void* fLockPtr;
49
reed@google.comac10a2d2010-12-22 21:39:39 +000050 typedef GrVertexBuffer INHERITED;
51};
52
53#endif