blob: 3ff746e29787b021cf74563616d7fb8b908d9570 [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
bsalomon861e1032014-12-16 07:33:49 -080015class GrGLGpu;
reed@google.comac10a2d2010-12-22 21:39:39 +000016
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
bsalomon861e1032014-12-16 07:33:49 -080022 GrGLIndexBuffer(GrGLGpu* gpu, const Desc& desc);
reed@google.comac10a2d2010-12-22 21:39:39 +000023
bsalomon@google.come49ad452013-02-20 19:33:20 +000024 GrGLuint bufferID() const { return fImpl.bufferID(); }
25 size_t baseOffset() const { return fImpl.baseOffset(); }
bsalomon@google.com880b8fc2013-02-19 20:17:28 +000026
bsalomon@google.come49ad452013-02-20 19:33:20 +000027 void bind() const {
commit-bot@chromium.org089a7802014-05-02 21:38:22 +000028 if (!this->wasDestroyed()) {
bsalomon@google.come49ad452013-02-20 19:33:20 +000029 fImpl.bind(this->getGpuGL());
30 }
31 }
reed@google.comac10a2d2010-12-22 21:39:39 +000032
bsalomon@google.com8fe72472011-03-30 21:26:44 +000033protected:
mtklein72c9faa2015-01-09 10:06:39 -080034 void onAbandon() SK_OVERRIDE;
35 void onRelease() SK_OVERRIDE;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000036
reed@google.comac10a2d2010-12-22 21:39:39 +000037private:
mtklein72c9faa2015-01-09 10:06:39 -080038 void* onMap() SK_OVERRIDE;
39 void onUnmap() SK_OVERRIDE;
40 bool onUpdateData(const void* src, size_t srcSizeInBytes) SK_OVERRIDE;
commit-bot@chromium.orge529a612014-05-08 18:13:23 +000041
bsalomon861e1032014-12-16 07:33:49 -080042 GrGLGpu* getGpuGL() const {
commit-bot@chromium.org089a7802014-05-02 21:38:22 +000043 SkASSERT(!this->wasDestroyed());
bsalomon861e1032014-12-16 07:33:49 -080044 return (GrGLGpu*)(this->getGpu());
bsalomon@google.come49ad452013-02-20 19:33:20 +000045 }
bsalomon@google.com8fe72472011-03-30 21:26:44 +000046
bsalomon@google.come49ad452013-02-20 19:33:20 +000047 GrGLBufferImpl fImpl;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000048
reed@google.comac10a2d2010-12-22 21:39:39 +000049 typedef GrIndexBuffer INHERITED;
50};
51
52#endif