blob: db413ac9909c25acdf3a2be853e16e0b3f4fbb7f [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 GrGLVertexBuffer_DEFINED
9#define GrGLVertexBuffer_DEFINED
10
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000011#include "GrVertexBuffer.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 GrGLVertexBuffer : public GrVertexBuffer {
reed@google.comac10a2d2010-12-22 21:39:39 +000018
19public:
bsalomon@google.come49ad452013-02-20 19:33:20 +000020 typedef GrGLBufferImpl::Desc Desc;
21
22 GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000023 virtual ~GrGLVertexBuffer() { this->release(); }
bsalomon@google.com880b8fc2013-02-19 20:17:28 +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 {
commit-bot@chromium.org089a7802014-05-02 21:38:22 +000029 if (!this->wasDestroyed()) {
bsalomon@google.come49ad452013-02-20 19:33:20 +000030 fImpl.bind(this->getGpuGL());
31 }
32 }
bsalomon@google.com880b8fc2013-02-19 20:17:28 +000033
bsalomon@google.com8fe72472011-03-30 21:26:44 +000034protected:
robertphillips@google.comd3645542012-09-05 18:37:39 +000035 virtual void onAbandon() SK_OVERRIDE;
36 virtual void onRelease() SK_OVERRIDE;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000037
reed@google.comac10a2d2010-12-22 21:39:39 +000038private:
commit-bot@chromium.orge529a612014-05-08 18:13:23 +000039 virtual void* onMap() SK_OVERRIDE;
40 virtual void onUnmap() SK_OVERRIDE;
41 virtual bool onUpdateData(const void* src, size_t srcSizeInBytes) SK_OVERRIDE;
42
bsalomon@google.come49ad452013-02-20 19:33:20 +000043 GrGpuGL* getGpuGL() const {
commit-bot@chromium.org089a7802014-05-02 21:38:22 +000044 SkASSERT(!this->wasDestroyed());
bsalomon@google.come49ad452013-02-20 19:33:20 +000045 return (GrGpuGL*)(this->getGpu());
46 }
bsalomon@google.com8fe72472011-03-30 21:26:44 +000047
bsalomon@google.come49ad452013-02-20 19:33:20 +000048 GrGLBufferImpl fImpl;
reed@google.comac10a2d2010-12-22 21:39:39 +000049
reed@google.comac10a2d2010-12-22 21:39:39 +000050 typedef GrVertexBuffer INHERITED;
51};
52
53#endif