• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2002-2013 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 "common/angleutils.h"
15 #include "common/RefCountObject.h"
16 #include "libGLESv2/renderer/IndexRangeCache.h"
17 
18 namespace rx
19 {
20 class Renderer;
21 class BufferStorage;
22 class StaticIndexBufferInterface;
23 class StaticVertexBufferInterface;
24 };
25 
26 namespace gl
27 {
28 
29 class Buffer : public RefCountObject
30 {
31   public:
32     Buffer(rx::Renderer *renderer, GLuint id);
33 
34     virtual ~Buffer();
35 
36     void bufferData(const void *data, GLsizeiptr size, GLenum usage);
37     void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
38 
39     GLenum usage() const;
40 
41     rx::BufferStorage *getStorage() const;
42     unsigned int size() const;
43 
44     rx::StaticVertexBufferInterface *getStaticVertexBuffer();
45     rx::StaticIndexBufferInterface *getStaticIndexBuffer();
46     void invalidateStaticData();
47     void promoteStaticUsage(int dataSize);
48 
49     rx::IndexRangeCache *getIndexRangeCache();
50 
51   private:
52     DISALLOW_COPY_AND_ASSIGN(Buffer);
53 
54     rx::Renderer *mRenderer;
55     GLenum mUsage;
56 
57     rx::BufferStorage *mBufferStorage;
58 
59     rx::IndexRangeCache mIndexRangeCache;
60 
61     rx::StaticVertexBufferInterface *mStaticVertexBuffer;
62     rx::StaticIndexBufferInterface *mStaticIndexBuffer;
63     unsigned int mUnmodifiedDataUse;
64 };
65 
66 }
67 
68 #endif   // LIBGLESV2_BUFFER_H_
69