blob: 183cabaa65853c8c708b0e7f9993b9eef880959f [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
twiz@google.com0f31ca72011-03-18 17:38:11 +00002 Copyright 2011 Google Inc.
reed@google.comac10a2d2010-12-22 21:39:39 +00003
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
24class GrGpuGL;
25
26class GrGLVertexBuffer : public GrVertexBuffer {
reed@google.comac10a2d2010-12-22 21:39:39 +000027
28public:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000029 virtual ~GrGLVertexBuffer() { this->release(); }
reed@google.comac10a2d2010-12-22 21:39:39 +000030 // overrides of GrVertexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000031 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000032 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000033 virtual void unlock();
34 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000035 virtual bool updateData(const void* src, size_t srcSizeInBytes);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000036 virtual bool updateSubData(const void* src,
37 size_t srcSizeInBytes,
bsalomon@google.com1c13c962011-02-14 16:51:21 +000038 size_t offset);
twiz@google.com0f31ca72011-03-18 17:38:11 +000039 GrGLuint bufferID() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000040
bsalomon@google.com8fe72472011-03-30 21:26:44 +000041protected:
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.comac10a2d2010-12-22 21:39:39 +000051private:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000052 void bind() const;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000053
twiz@google.com0f31ca72011-03-18 17:38:11 +000054 GrGLuint fBufferID;
reed@google.comac10a2d2010-12-22 21:39:39 +000055 void* fLockPtr;
56
57 friend class GrGpuGL;
58
59 typedef GrVertexBuffer INHERITED;
60};
61
62#endif