blob: e28200135c27d56db61189fe08d7f935f0de1893 [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 GrGLIndexBuffer_DEFINED
11#define GrGLIndexBuffer_DEFINED
12
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000013#include "GrIndexBuffer.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 GrGLIndexBuffer : public GrIndexBuffer {
bsalomon@google.com8fe72472011-03-30 21:26:44 +000019
reed@google.comac10a2d2010-12-22 21:39:39 +000020public:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000021
22 virtual ~GrGLIndexBuffer() { this->release(); }
reed@google.comac10a2d2010-12-22 21:39:39 +000023
twiz@google.com0f31ca72011-03-18 17:38:11 +000024 GrGLuint bufferID() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000025
26 // overrides of GrIndexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000027 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000028 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000029 virtual void unlock();
30 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000031 virtual bool updateData(const void* src, size_t srcSizeInBytes);
bsalomon@google.com96e96df2011-10-10 14:49:29 +000032
bsalomon@google.com8fe72472011-03-30 21:26:44 +000033protected:
34 GrGLIndexBuffer(GrGpuGL* gpu,
35 GrGLuint id,
36 size_t sizeInBytes,
37 bool dynamic);
38
39 // overrides of GrResource
robertphillips@google.comd3645542012-09-05 18:37:39 +000040 virtual void onAbandon() SK_OVERRIDE;
41 virtual void onRelease() SK_OVERRIDE;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000042
reed@google.comac10a2d2010-12-22 21:39:39 +000043private:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000044 void bind() const;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000045
twiz@google.com0f31ca72011-03-18 17:38:11 +000046 GrGLuint fBufferID;
reed@google.comac10a2d2010-12-22 21:39:39 +000047 void* fLockPtr;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000048
reed@google.comac10a2d2010-12-22 21:39:39 +000049 friend class GrGpuGL;
50
51 typedef GrIndexBuffer INHERITED;
52};
53
54#endif