1 // 2 // Copyright 2015 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 // BufferGL.h: Defines the class interface for BufferGL. 8 9 #ifndef LIBANGLE_RENDERER_GL_BUFFERGL_H_ 10 #define LIBANGLE_RENDERER_GL_BUFFERGL_H_ 11 12 #include "common/MemoryBuffer.h" 13 #include "libANGLE/renderer/BufferImpl.h" 14 15 #include <optional> 16 17 namespace rx 18 { 19 20 class FunctionsGL; 21 class StateManagerGL; 22 23 class BufferGL : public BufferImpl 24 { 25 public: 26 BufferGL(const gl::BufferState &state, GLuint buffer); 27 ~BufferGL() override; 28 29 void destroy(const gl::Context *context) override; 30 31 angle::Result setData(const gl::Context *context, 32 gl::BufferBinding target, 33 const void *data, 34 size_t size, 35 gl::BufferUsage usage) override; 36 angle::Result setSubData(const gl::Context *context, 37 gl::BufferBinding target, 38 const void *data, 39 size_t size, 40 size_t offset) override; 41 angle::Result copySubData(const gl::Context *context, 42 BufferImpl *source, 43 GLintptr sourceOffset, 44 GLintptr destOffset, 45 GLsizeiptr size) override; 46 angle::Result map(const gl::Context *context, GLenum access, void **mapPtr) override; 47 angle::Result mapRange(const gl::Context *context, 48 size_t offset, 49 size_t length, 50 GLbitfield access, 51 void **mapPtr) override; 52 angle::Result unmap(const gl::Context *context, GLboolean *result) override; 53 54 angle::Result getIndexRange(const gl::Context *context, 55 gl::DrawElementsType type, 56 size_t offset, 57 size_t count, 58 bool primitiveRestartEnabled, 59 gl::IndexRange *outRange) override; 60 61 size_t getBufferSize() const; 62 GLuint getBufferID() const; 63 64 private: 65 bool mIsMapped; 66 size_t mMapOffset; 67 size_t mMapSize; 68 69 std::optional<angle::MemoryBuffer> mShadowCopy; 70 71 size_t mBufferSize; 72 73 GLuint mBufferID; 74 }; 75 76 } // namespace rx 77 78 #endif // LIBANGLE_RENDERER_GL_BUFFERGL_H_ 79