reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 2 | Copyright 2011 Google Inc. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | #ifndef GrGLVertexBuffer_DEFINED |
| 19 | #define GrGLVertexBuffer_DEFINED |
| 20 | |
| 21 | #include "GrVertexBuffer.h" |
| 22 | #include "GrGLConfig.h" |
| 23 | |
| 24 | class GrGpuGL; |
| 25 | |
| 26 | class GrGLVertexBuffer : public GrVertexBuffer { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 27 | |
| 28 | public: |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame^] | 29 | virtual ~GrGLVertexBuffer() { this->release(); } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 30 | // overrides of GrVertexBuffer |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 31 | virtual void* lock(); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 32 | virtual void* lockPtr() const; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 33 | virtual void unlock(); |
| 34 | virtual bool isLocked() const; |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 35 | virtual bool updateData(const void* src, size_t srcSizeInBytes); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame^] | 36 | virtual bool updateSubData(const void* src, |
| 37 | size_t srcSizeInBytes, |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 38 | size_t offset); |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 39 | GrGLuint bufferID() const; |
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: |
| 42 | GrGLVertexBuffer(GrGpuGL* gpu, |
| 43 | GrGLuint id, |
| 44 | size_t sizeInBytes, |
| 45 | bool dynamic); |
| 46 | |
| 47 | // overrides of GrResource |
| 48 | virtual void onAbandon(); |
| 49 | virtual void onRelease(); |
| 50 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 51 | private: |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 52 | void bind() const; |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame^] | 53 | |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 54 | GrGLuint fBufferID; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 55 | void* fLockPtr; |
| 56 | |
| 57 | friend class GrGpuGL; |
| 58 | |
| 59 | typedef GrVertexBuffer INHERITED; |
| 60 | }; |
| 61 | |
| 62 | #endif |