1 //
2 // Copyright 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 // BufferImpl.h: Defines the abstract rx::BufferImpl class.
8 
9 #ifndef LIBANGLE_RENDERER_BUFFERIMPL_H_
10 #define LIBANGLE_RENDERER_BUFFERIMPL_H_
11 
12 #include "common/angleutils.h"
13 #include "common/mathutil.h"
14 #include "libANGLE/Error.h"
15 #include "libANGLE/PackedGLEnums.h"
16 
17 #include <stdint.h>
18 
19 namespace gl
20 {
21 class BufferState;
22 class Context;
23 }
24 
25 namespace rx
26 {
27 class BufferImpl : angle::NonCopyable
28 {
29   public:
BufferImpl(const gl::BufferState & state)30     BufferImpl(const gl::BufferState &state) : mState(state) {}
~BufferImpl()31     virtual ~BufferImpl() {}
destroy(const gl::Context * context)32     virtual void destroy(const gl::Context *context) {}
33 
34     virtual gl::Error setData(const gl::Context *context,
35                               gl::BufferBinding target,
36                               const void *data,
37                               size_t size,
38                               gl::BufferUsage usage)                                = 0;
39     virtual gl::Error setSubData(const gl::Context *context,
40                                  gl::BufferBinding target,
41                                  const void *data,
42                                  size_t size,
43                                  size_t offset)                                     = 0;
44     virtual gl::Error copySubData(const gl::Context *context,
45                                   BufferImpl *source,
46                                   GLintptr sourceOffset,
47                                   GLintptr destOffset,
48                                   GLsizeiptr size) = 0;
49     virtual gl::Error map(const gl::Context *context, GLenum access, void **mapPtr) = 0;
50     virtual gl::Error mapRange(const gl::Context *context,
51                                size_t offset,
52                                size_t length,
53                                GLbitfield access,
54                                void **mapPtr) = 0;
55     virtual gl::Error unmap(const gl::Context *context, GLboolean *result) = 0;
56 
57     virtual gl::Error getIndexRange(const gl::Context *context,
58                                     GLenum type,
59                                     size_t offset,
60                                     size_t count,
61                                     bool primitiveRestartEnabled,
62                                     gl::IndexRange *outRange) = 0;
63 
64   protected:
65     const gl::BufferState &mState;
66 };
67 }
68 
69 #endif  // LIBANGLE_RENDERER_BUFFERIMPL_H_
70