Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / renderer / d3d / VertexDataManager.h
1 //
2 // Copyright (c) 2002-2012 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 // VertexDataManager.h: Defines the VertexDataManager, a class that
8 // runs the Buffer translation process.
9
10 #ifndef LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
11 #define LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_
12
13 #include "libGLESv2/Constants.h"
14 #include "libGLESv2/VertexAttribute.h"
15 #include "common/angleutils.h"
16
17 namespace gl
18 {
19 class ProgramBinary;
20 class State;
21 struct VertexAttribute;
22 struct VertexAttribCurrentValueData;
23 }
24
25 namespace rx
26 {
27 class BufferD3D;
28 class StreamingVertexBufferInterface;
29 class VertexBuffer;
30 class Renderer;
31
32 struct TranslatedAttribute
33 {
34     TranslatedAttribute() : active(false), attribute(NULL), currentValueType(GL_NONE),
35                             offset(0), stride(0), vertexBuffer(NULL), storage(NULL),
36                             serial(0), divisor(0) {};
37     bool active;
38
39     const gl::VertexAttribute *attribute;
40     GLenum currentValueType;
41     unsigned int offset;
42     unsigned int stride;   // 0 means not to advance the read pointer at all
43
44     VertexBuffer *vertexBuffer;
45     BufferD3D *storage;
46     unsigned int serial;
47     unsigned int divisor;
48 };
49
50 class VertexDataManager
51 {
52   public:
53     VertexDataManager(rx::Renderer *renderer);
54     virtual ~VertexDataManager();
55
56     gl::Error prepareVertexData(const gl::State &state, GLint start, GLsizei count,
57                                 TranslatedAttribute *outAttribs, GLsizei instances);
58
59   private:
60     DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
61
62     gl::Error reserveSpaceForAttrib(const gl::VertexAttribute &attrib,
63                                     const gl::VertexAttribCurrentValueData &currentValue,
64                                     GLsizei count,
65                                     GLsizei instances) const;
66
67     void invalidateMatchingStaticData(const gl::VertexAttribute &attrib,
68                                       const gl::VertexAttribCurrentValueData &currentValue) const;
69
70     gl::Error storeAttribute(const gl::VertexAttribute &attrib,
71                              const gl::VertexAttribCurrentValueData &currentValue,
72                              TranslatedAttribute *translated,
73                              GLint start,
74                              GLsizei count,
75                              GLsizei instances);
76
77     gl::Error storeCurrentValue(const gl::VertexAttribute &attrib,
78                                 const gl::VertexAttribCurrentValueData &currentValue,
79                                 TranslatedAttribute *translated,
80                                 gl::VertexAttribCurrentValueData *cachedValue,
81                                 size_t *cachedOffset,
82                                 StreamingVertexBufferInterface *buffer);
83
84     rx::Renderer *const mRenderer;
85
86     StreamingVertexBufferInterface *mStreamingBuffer;
87
88     gl::VertexAttribCurrentValueData mCurrentValue[gl::MAX_VERTEX_ATTRIBS];
89
90     StreamingVertexBufferInterface *mCurrentValueBuffer[gl::MAX_VERTEX_ATTRIBS];
91     std::size_t mCurrentValueOffsets[gl::MAX_VERTEX_ATTRIBS];
92 };
93
94 }
95
96 #endif   // LIBGLESV2_RENDERER_VERTEXDATAMANAGER_H_