2 // Copyright (c) 2012-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.
7 // angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
9 #ifndef LIBGLESV2_ANGLETYPES_H_
10 #define LIBGLESV2_ANGLETYPES_H_
12 #include "libGLESv2/constants.h"
13 #include "common/RefCountObject.h"
19 struct VertexAttribute;
20 struct VertexAttribCurrentValueData;
36 Color() : red(0), green(0), blue(0), alpha(0) { }
37 Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { }
40 typedef Color<float> ColorF;
41 typedef Color<int> ColorI;
42 typedef Color<unsigned int> ColorUI;
51 Rectangle() : x(0), y(0), width(0), height(0) { }
52 Rectangle(int x_in, int y_in, int width_in, int height_in) : x(x_in), y(y_in), width(width_in), height(height_in) { }
55 bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection);
66 Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
67 Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { }
76 Extents() : width(0), height(0), depth(0) { }
77 Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
80 struct RasterizerState
86 bool polygonOffsetFill;
87 GLfloat polygonOffsetFactor;
88 GLfloat polygonOffsetUnits;
93 bool rasterizerDiscard;
99 GLenum sourceBlendRGB;
101 GLenum sourceBlendAlpha;
102 GLenum destBlendAlpha;
103 GLenum blendEquationRGB;
104 GLenum blendEquationAlpha;
111 bool sampleAlphaToCoverage;
116 struct DepthStencilState
126 GLenum stencilPassDepthFail;
127 GLenum stencilPassDepthPass;
128 GLuint stencilWritemask;
129 GLenum stencilBackFunc;
130 GLuint stencilBackMask;
131 GLenum stencilBackFail;
132 GLenum stencilBackPassDepthFail;
133 GLenum stencilBackPassDepthPass;
134 GLuint stencilBackWritemask;
161 bool swizzleRequired() const;
164 struct ClearParameters
166 bool clearColor[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
167 ColorF colorFClearValue;
168 ColorI colorIClearValue;
169 ColorUI colorUIClearValue;
170 GLenum colorClearType;
177 float depthClearValue;
180 GLint stencilClearValue;
181 GLuint stencilWriteMask;
187 struct PixelUnpackState
189 BindingPointer<Buffer> pixelBuffer;
196 explicit PixelUnpackState(GLint alignmentIn)
197 : alignment(alignmentIn)
201 struct PixelPackState
203 BindingPointer<Buffer> pixelBuffer;
205 bool reverseRowOrder;
209 reverseRowOrder(false)
212 explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn)
213 : alignment(alignmentIn),
214 reverseRowOrder(reverseRowOrderIn)
221 GLboolean mNormalized;
226 VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger);
227 explicit VertexFormat(const VertexAttribute &attribute);
228 VertexFormat(const VertexAttribute &attribute, GLenum currentValueType);
230 static void GetInputLayout(VertexFormat *inputLayout,
231 ProgramBinary *programBinary,
232 const VertexAttribute *attributes,
233 const gl::VertexAttribCurrentValueData *currentValues);
235 bool operator==(const VertexFormat &other) const;
236 bool operator!=(const VertexFormat &other) const;
237 bool operator<(const VertexFormat& other) const;
245 enum VertexConversionType
247 VERTEX_CONVERT_NONE = 0,
248 VERTEX_CONVERT_CPU = 1,
249 VERTEX_CONVERT_GPU = 2,
250 VERTEX_CONVERT_BOTH = 3
253 enum D3DWorkaroundType
255 ANGLE_D3D_WORKAROUND_NONE,
256 ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
257 ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
262 #endif // LIBGLESV2_ANGLETYPES_H_