blob: 3565059f269192a9aa0baec20cc1c1d7b555ec1e [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 GrGLIndexBuffer_DEFINED
19#define GrGLIndexBuffer_DEFINED
20
21#include "GrIndexBuffer.h"
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000022#include "GrGLInterface.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000023
24class GrGpuGL;
25
26class GrGLIndexBuffer : public GrIndexBuffer {
bsalomon@google.com8fe72472011-03-30 21:26:44 +000027
reed@google.comac10a2d2010-12-22 21:39:39 +000028public:
bsalomon@google.com8fe72472011-03-30 21:26:44 +000029
30 virtual ~GrGLIndexBuffer() { this->release(); }
reed@google.comac10a2d2010-12-22 21:39:39 +000031
twiz@google.com0f31ca72011-03-18 17:38:11 +000032 GrGLuint bufferID() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000033
34 // overrides of GrIndexBuffer
reed@google.comac10a2d2010-12-22 21:39:39 +000035 virtual void* lock();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000036 virtual void* lockPtr() const;
reed@google.comac10a2d2010-12-22 21:39:39 +000037 virtual void unlock();
38 virtual bool isLocked() const;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000039 virtual bool updateData(const void* src, size_t srcSizeInBytes);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000040 virtual bool updateSubData(const void* src,
41 size_t srcSizeInBytes,
bsalomon@google.com1c13c962011-02-14 16:51:21 +000042 size_t offset);
bsalomon@google.com8fe72472011-03-30 21:26:44 +000043protected:
44 GrGLIndexBuffer(GrGpuGL* gpu,
45 GrGLuint id,
46 size_t sizeInBytes,
47 bool dynamic);
48
49 // overrides of GrResource
50 virtual void onAbandon();
51 virtual void onRelease();
52
reed@google.comac10a2d2010-12-22 21:39:39 +000053private:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000054 void bind() const;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000055
twiz@google.com0f31ca72011-03-18 17:38:11 +000056 GrGLuint fBufferID;
reed@google.comac10a2d2010-12-22 21:39:39 +000057 void* fLockPtr;
bsalomon@google.com8fe72472011-03-30 21:26:44 +000058
reed@google.comac10a2d2010-12-22 21:39:39 +000059 friend class GrGpuGL;
60
61 typedef GrIndexBuffer INHERITED;
62};
63
64#endif