1 // 2 // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // Buffer.h: Defines the gl::Buffer class, representing storage of vertex and/or 8 // index data. Implements GL buffer objects and related functionality. 9 // [OpenGL ES 2.0.24] section 2.9 page 21. 10 11 #ifndef LIBGLESV2_BUFFER_H_ 12 #define LIBGLESV2_BUFFER_H_ 13 14 #include "libGLESv2/Error.h" 15 16 #include "common/angleutils.h" 17 #include "common/RefCountObject.h" 18 #include "libGLESv2/renderer/IndexRangeCache.h" 19 20 namespace rx 21 { 22 class Renderer; 23 class BufferImpl; 24 }; 25 26 namespace gl 27 { 28 29 class Buffer : public RefCountObject 30 { 31 public: 32 Buffer(rx::BufferImpl *impl, GLuint id); 33 34 virtual ~Buffer(); 35 36 Error bufferData(const void *data, GLsizeiptr size, GLenum usage); 37 Error bufferSubData(const void *data, GLsizeiptr size, GLintptr offset); 38 Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); 39 Error mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access); 40 Error unmap(); 41 42 GLenum getUsage() const { return mUsage; } 43 GLint getAccessFlags() const { return mAccessFlags; } 44 GLboolean isMapped() const { return mMapped; } 45 GLvoid *getMapPointer() const { return mMapPointer; } 46 GLint64 getMapOffset() const { return mMapOffset; } 47 GLint64 getMapLength() const { return mMapLength; } 48 GLint64 getSize() const { return mSize; } 49 50 rx::BufferImpl *getImplementation() const { return mBuffer; } 51 52 void markTransformFeedbackUsage(); 53 54 rx::IndexRangeCache *getIndexRangeCache() { return &mIndexRangeCache; } 55 const rx::IndexRangeCache *getIndexRangeCache() const { return &mIndexRangeCache; } 56 57 private: 58 DISALLOW_COPY_AND_ASSIGN(Buffer); 59 60 rx::BufferImpl *mBuffer; 61 62 GLenum mUsage; 63 GLint64 mSize; 64 GLint mAccessFlags; 65 GLboolean mMapped; 66 GLvoid *mMapPointer; 67 GLint64 mMapOffset; 68 GLint64 mMapLength; 69 70 rx::IndexRangeCache mIndexRangeCache; 71 }; 72 73 } 74 75 #endif // LIBGLESV2_BUFFER_H_ 76