blob: 17b0283f102b43f7cbf9770341fd13a293112e56 [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.com8fe72472011-03-30 21:26:44 +000021 virtual ~GrGLVertexBuffer() { this->release(); }
reed@google.comac10a2d2010-12-22 21:39:39 +000022 // overrides of GrVertexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000023 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000024 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000025 virtual void unlock();
26 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000027 virtual bool updateData(const void* src, size_t srcSizeInBytes);
twiz@google.com0f31ca72011-03-18 17:38:11 +000028 GrGLuint bufferID() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000029
bsalomon@google.com8fe72472011-03-30 21:26:44 +000030protected:
31 GrGLVertexBuffer(GrGpuGL* gpu,
bsalomon@google.com72830222013-01-23 20:25:22 +000032 bool isWrapped,
bsalomon@google.com8fe72472011-03-30 21:26:44 +000033 GrGLuint id,
34 size_t sizeInBytes,
35 bool dynamic);
36
37 // overrides of GrResource
robertphillips@google.comd3645542012-09-05 18:37:39 +000038 virtual void onAbandon() SK_OVERRIDE;
39 virtual void onRelease() SK_OVERRIDE;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000040
reed@google.comac10a2d2010-12-22 21:39:39 +000041private:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000042 void bind() const;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000043
twiz@google.com0f31ca72011-03-18 17:38:11 +000044 GrGLuint fBufferID;
reed@google.comac10a2d2010-12-22 21:39:39 +000045 void* fLockPtr;
46
47 friend class GrGpuGL;
48
49 typedef GrVertexBuffer INHERITED;
50};
51
52#endif