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 { |
| 29 | if (this->isValid()) { |
| 30 | fImpl.bind(this->getGpuGL()); |
| 31 | } |
| 32 | } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 33 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 34 | // overrides of GrVertexBuffer |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 35 | virtual void* lock(); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 36 | virtual void* lockPtr() const; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 37 | virtual void unlock(); |
| 38 | virtual bool isLocked() const; |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 39 | virtual bool updateData(const void* src, size_t srcSizeInBytes); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 40 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 41 | protected: |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 42 | // overrides of GrResource |
robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 43 | virtual void onAbandon() SK_OVERRIDE; |
| 44 | virtual void onRelease() SK_OVERRIDE; |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 45 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | private: |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 47 | GrGpuGL* getGpuGL() const { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 48 | SkASSERT(this->isValid()); |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 49 | return (GrGpuGL*)(this->getGpu()); |
| 50 | } |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 51 | |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 52 | GrGLBufferImpl fImpl; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 53 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 54 | typedef GrVertexBuffer INHERITED; |
| 55 | }; |
| 56 | |
| 57 | #endif |