blob: c3e2287260d995bb58aa4249d70f402ad4892a21 [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.com96e96df2011-10-10 14:49:29 +000033
bsalomon@google.com8fe72472011-03-30 21:26:44 +000034protected:
35 GrGLIndexBuffer(GrGpuGL* gpu,
36 GrGLuint id,
37 size_t sizeInBytes,
38 bool dynamic);
39
40 // overrides of GrResource
41 virtual void onAbandon();
42 virtual void onRelease();
43
reed@google.comac10a2d2010-12-22 21:39:39 +000044private:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000045 void bind() const;
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;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000049
reed@google.comac10a2d2010-12-22 21:39:39 +000050 friend class GrGpuGL;
51
52 typedef GrIndexBuffer INHERITED;
53};
54
55#endif