blob: 32a808606362fefa0ef55a9d48729dc91ab530cf [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
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrGLIndexBuffer_DEFINED
9#define GrGLIndexBuffer_DEFINED
10
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000011#include "GrIndexBuffer.h"
bsalomon@google.come49ad452013-02-20 19:33:20 +000012#include "GrGLBufferImpl.h"
tomhudson@google.com6bf38b52012-02-14 15:11:59 +000013#include "gl/GrGLInterface.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000014
15class GrGpuGL;
16
17class GrGLIndexBuffer : public GrIndexBuffer {
bsalomon@google.com8fe72472011-03-30 21:26:44 +000018
reed@google.comac10a2d2010-12-22 21:39:39 +000019public:
bsalomon@google.come49ad452013-02-20 19:33:20 +000020 typedef GrGLBufferImpl::Desc Desc;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000021
bsalomon@google.come49ad452013-02-20 19:33:20 +000022 GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000023 virtual ~GrGLIndexBuffer() { this->release(); }
reed@google.comac10a2d2010-12-22 21:39:39 +000024
bsalomon@google.come49ad452013-02-20 19:33:20 +000025 GrGLuint bufferID() const { return fImpl.bufferID(); }
26 size_t baseOffset() const { return fImpl.baseOffset(); }
bsalomon@google.com880b8fc2013-02-19 20:17:28 +000027
bsalomon@google.come49ad452013-02-20 19:33:20 +000028 void bind() const {
29 if (this->isValid()) {
30 fImpl.bind(this->getGpuGL());
31 }
32 }
reed@google.comac10a2d2010-12-22 21:39:39 +000033
34 // overrides of GrIndexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000035 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000036 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000037 virtual void unlock();
38 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000039 virtual bool updateData(const void* src, size_t srcSizeInBytes);
bsalomon@google.com96e96df2011-10-10 14:49:29 +000040
bsalomon@google.com8fe72472011-03-30 21:26:44 +000041protected:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000042 // overrides of GrResource
robertphillips@google.comd3645542012-09-05 18:37:39 +000043 virtual void onAbandon() SK_OVERRIDE;
44 virtual void onRelease() SK_OVERRIDE;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000045
reed@google.comac10a2d2010-12-22 21:39:39 +000046private:
bsalomon@google.come49ad452013-02-20 19:33:20 +000047 GrGpuGL* getGpuGL() const {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000048 SkASSERT(this->isValid());
bsalomon@google.come49ad452013-02-20 19:33:20 +000049 return (GrGpuGL*)(this->getGpu());
50 }
bsalomon@google.com8fe72472011-03-30 21:26:44 +000051
bsalomon@google.come49ad452013-02-20 19:33:20 +000052 GrGLBufferImpl fImpl;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000053
reed@google.comac10a2d2010-12-22 21:39:39 +000054 typedef GrIndexBuffer INHERITED;
55};
56
57#endif