reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrGLVertexBuffer_DEFINED |
| 9 | #define GrGLVertexBuffer_DEFINED |
| 10 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 11 | #include "GrVertexBuffer.h" |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 12 | #include "GrGLBufferImpl.h" |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 13 | #include "gl/GrGLInterface.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 14 | |
| 15 | class GrGpuGL; |
| 16 | |
| 17 | class GrGLVertexBuffer : public GrVertexBuffer { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 18 | |
| 19 | public: |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 20 | typedef GrGLBufferImpl::Desc Desc; |
| 21 | |
| 22 | GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 23 | virtual ~GrGLVertexBuffer() { this->release(); } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 24 | |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 25 | GrGLuint bufferID() const { return fImpl.bufferID(); } |
| 26 | size_t baseOffset() const { return fImpl.baseOffset(); } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 27 | |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 28 | void bind() const { |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 29 | if (!this->wasDestroyed()) { |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 30 | fImpl.bind(this->getGpuGL()); |
| 31 | } |
| 32 | } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 33 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 34 | protected: |
robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 35 | virtual void onAbandon() SK_OVERRIDE; |
| 36 | virtual void onRelease() SK_OVERRIDE; |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 37 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | private: |
commit-bot@chromium.org | e529a61 | 2014-05-08 18:13:23 +0000 | [diff] [blame^] | 39 | 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.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 43 | GrGpuGL* getGpuGL() const { |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 44 | SkASSERT(!this->wasDestroyed()); |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 45 | return (GrGpuGL*)(this->getGpu()); |
| 46 | } |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 47 | |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 48 | GrGLBufferImpl fImpl; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 49 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 50 | typedef GrVertexBuffer INHERITED; |
| 51 | }; |
| 52 | |
| 53 | #endif |