blob: e4e77c9e8c64da51c6d41831244bfe973aa1fc56 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrGLIndexBuffer_DEFINED
12#define GrGLIndexBuffer_DEFINED
13
14#include "GrIndexBuffer.h"
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000015#include "GrGLInterface.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000016
17class GrGpuGL;
18
19class GrGLIndexBuffer : public GrIndexBuffer {
bsalomon@google.com8fe72472011-03-30 21:26:44 +000020
reed@google.comac10a2d2010-12-22 21:39:39 +000021public:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000022
23 virtual ~GrGLIndexBuffer() { this->release(); }
reed@google.comac10a2d2010-12-22 21:39:39 +000024
twiz@google.com0f31ca72011-03-18 17:38:11 +000025 GrGLuint bufferID() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000026
27 // overrides of GrIndexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000028 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000029 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000030 virtual void unlock();
31 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000032 virtual bool updateData(const void* src, size_t srcSizeInBytes);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000033 virtual bool updateSubData(const void* src,
34 size_t srcSizeInBytes,
bsalomon@google.com1c13c962011-02-14 16:51:21 +000035 size_t offset);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000036protected:
37 GrGLIndexBuffer(GrGpuGL* gpu,
38 GrGLuint id,
39 size_t sizeInBytes,
40 bool dynamic);
41
42 // overrides of GrResource
43 virtual void onAbandon();
44 virtual void onRelease();
45
reed@google.comac10a2d2010-12-22 21:39:39 +000046private:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000047 void bind() const;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000048
twiz@google.com0f31ca72011-03-18 17:38:11 +000049 GrGLuint fBufferID;
reed@google.comac10a2d2010-12-22 21:39:39 +000050 void* fLockPtr;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000051
reed@google.comac10a2d2010-12-22 21:39:39 +000052 friend class GrGpuGL;
53
54 typedef GrIndexBuffer INHERITED;
55};
56
57#endif