webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
angletypes.h
Go to the documentation of this file.
1 //
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.
5 //
6 
7 // angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
8 
9 #ifndef LIBANGLE_ANGLETYPES_H_
10 #define LIBANGLE_ANGLETYPES_H_
11 
12 #include "libANGLE/Constants.h"
14 
15 #include <stdint.h>
16 
17 #include <bitset>
18 #include <unordered_map>
19 
20 namespace gl
21 {
22 class Buffer;
23 class State;
24 class Program;
25 struct VertexAttribute;
26 struct VertexAttribCurrentValueData;
27 
29 {
38 };
39 
41 
43 {
46 };
47 
48 struct Rectangle
49 {
50  Rectangle() : x(0), y(0), width(0), height(0) {}
51  Rectangle(int x_in, int y_in, int width_in, int height_in)
52  : x(x_in), y(y_in), width(width_in), height(height_in)
53  {
54  }
55 
56  int x0() const { return x; }
57  int y0() const { return y; }
58  int x1() const { return x + width; }
59  int y1() const { return y + height; }
60 
61  int x;
62  int y;
63  int width;
64  int height;
65 };
66 
67 bool operator==(const Rectangle &a, const Rectangle &b);
68 bool operator!=(const Rectangle &a, const Rectangle &b);
69 
70 bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection);
71 
72 struct Offset
73 {
74  int x;
75  int y;
76  int z;
77 
78  Offset() : x(0), y(0), z(0) { }
79  Offset(int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in) { }
80 };
81 
82 struct Extents
83 {
84  int width;
85  int height;
86  int depth;
87 
88  Extents() : width(0), height(0), depth(0) { }
89  Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
90 
91  Extents(const Extents &other) = default;
92  Extents &operator=(const Extents &other) = default;
93 
94  bool empty() const { return (width * height * depth) == 0; }
95 };
96 
97 bool operator==(const Extents &lhs, const Extents &rhs);
98 bool operator!=(const Extents &lhs, const Extents &rhs);
99 
100 struct Box
101 {
102  int x;
103  int y;
104  int z;
105  int width;
106  int height;
107  int depth;
108 
109  Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
110  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) { }
111  Box(const Offset &offset, const Extents &size) : x(offset.x), y(offset.y), z(offset.z), width(size.width), height(size.height), depth(size.depth) { }
112  bool operator==(const Box &other) const;
113  bool operator!=(const Box &other) const;
114 };
115 
116 
118 {
119  bool cullFace;
122 
126 
129 
131 };
132 
134 {
135  bool blend;
142 
147 
149 
150  bool dither;
151 };
152 
154 {
155  bool depthTest;
157  bool depthMask;
158 
172 };
173 
174 // State from Table 6.10 (state per sampler object)
176 {
177  SamplerState();
178  static SamplerState CreateDefaultForTarget(GLenum target);
179 
182 
186 
187  // From EXT_texture_filter_anisotropic
189 
192 
195 };
196 
197 bool operator==(const SamplerState &a, const SamplerState &b);
198 bool operator!=(const SamplerState &a, const SamplerState &b);
199 
201 {
203  GLint alignment = 4;
204  GLint rowLength = 0;
205  GLint skipRows = 0;
206  GLint skipPixels = 0;
207  GLint imageHeight = 0;
208  GLint skipImages = 0;
209 };
210 
212 {
214 
215  PixelUnpackState(GLint alignmentIn, GLint rowLengthIn)
216  {
217  alignment = alignmentIn;
218  rowLength = rowLengthIn;
219  }
220 };
221 
223 {
225 
226  PixelPackState(GLint alignmentIn, bool reverseRowOrderIn)
227  : reverseRowOrder(reverseRowOrderIn)
228  {
229  alignment = alignmentIn;
230  }
231 
232  bool reverseRowOrder = false;
233 };
234 
235 // Used in Program and VertexArray.
236 typedef std::bitset<MAX_VERTEX_ATTRIBS> AttributesMask;
237 
238 // Use in Program
239 typedef std::bitset<IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS> UniformBlockBindingMask;
240 
241 // A map of GL objects indexed by object ID. The specific map implementation may change.
242 // Client code should treat it as a std::map.
243 template <class ResourceT>
244 using ResourceMap = std::unordered_map<GLuint, ResourceT *>;
245 }
246 
247 namespace rx
248 {
250 {
252  VENDOR_ID_AMD = 0x1002,
253  VENDOR_ID_INTEL = 0x8086,
255  // This is Qualcomm PCI Vendor ID.
256  // Android doesn't have a PCI bus, but all we need is a unique id.
258 };
259 
260 // A macro that determines whether an object has a given runtime type.
261 #if defined(__clang__)
262 #if __has_feature(cxx_rtti)
263 #define ANGLE_HAS_DYNAMIC_CAST 1
264 #endif
265 #elif !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI))
266 #define ANGLE_HAS_DYNAMIC_CAST 1
267 #endif
268 
269 #ifdef ANGLE_HAS_DYNAMIC_CAST
270 #define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type >(obj) != nullptr)
271 #undef ANGLE_HAS_DYNAMIC_CAST
272 #else
273 #define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (obj != nullptr)
274 #endif
275 
276 // Downcast a base implementation object (EG TextureImpl to TextureD3D)
277 template <typename DestT, typename SrcT>
278 inline DestT *GetAs(SrcT *src)
279 {
280  ASSERT(ANGLE_HAS_DYNAMIC_TYPE(DestT*, src));
281  return static_cast<DestT*>(src);
282 }
283 
284 template <typename DestT, typename SrcT>
285 inline const DestT *GetAs(const SrcT *src)
286 {
287  ASSERT(ANGLE_HAS_DYNAMIC_TYPE(const DestT*, src));
288  return static_cast<const DestT*>(src);
289 }
290 
291 #undef ANGLE_HAS_DYNAMIC_TYPE
292 
293 // Downcast a GL object to an Impl (EG gl::Texture to rx::TextureD3D)
294 template <typename DestT, typename SrcT>
295 inline DestT *GetImplAs(SrcT *src)
296 {
297  return GetAs<DestT>(src->getImplementation());
298 }
299 
300 }
301 
302 #include "angletypes.inl"
303 
304 namespace angle
305 {
306 // Zero-based for better array indexing
308 {
315 };
316 
318 {
319  switch (enumValue)
320  {
321  case GL_READ_FRAMEBUFFER:
322  return FramebufferBindingRead;
323  case GL_DRAW_FRAMEBUFFER:
324  return FramebufferBindingDraw;
325  case GL_FRAMEBUFFER:
326  return FramebufferBindingBoth;
327  default:
328  UNREACHABLE();
330  }
331 }
332 
334 {
335  switch (binding)
336  {
338  return GL_READ_FRAMEBUFFER;
340  return GL_DRAW_FRAMEBUFFER;
342  return GL_FRAMEBUFFER;
343  default:
344  UNREACHABLE();
345  return GL_NONE;
346  }
347 }
348 }
349 
350 #endif // LIBANGLE_ANGLETYPES_H_
FramebufferBinding
Definition: angletypes.h:307
int GLint
Definition: gl2.h:76
BindingPointer< Buffer > pixelBuffer
Definition: angletypes.h:202
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
GLenum destBlendRGB
Definition: angletypes.h:137
GLsizei GLsizei GLchar * source
Definition: gl2.h:451
bool pointDrawMode
Definition: angletypes.h:127
GLfloat polygonOffsetFactor
Definition: angletypes.h:124
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:950
GLenum compareMode
Definition: angletypes.h:193
GLenum depthFunc
Definition: angletypes.h:156
float maxAnisotropy
Definition: angletypes.h:188
GLenum cullMode
Definition: angletypes.h:120
GLenum stencilFunc
Definition: angletypes.h:160
Definition: RefCountObject.h:52
bool stencilTest
Definition: angletypes.h:159
bool operator==(const Extents &lhs, const Extents &rhs)
Definition: angletypes.cpp:134
Definition: angletypes.h:153
int height
Definition: angletypes.h:106
Definition: angletypes.h:257
GLenum stencilPassDepthPass
Definition: angletypes.h:164
Definition: angletypes.h:32
GLuint stencilMask
Definition: angletypes.h:161
Definition: angletypes.h:252
unsigned int uint32_t
Definition: ptypes.h:105
Definition: angletypes.h:312
PixelPackState(GLint alignmentIn, bool reverseRowOrderIn)
Definition: angletypes.h:226
FramebufferBinding EnumToFramebufferBinding(GLenum enumValue)
Definition: angletypes.h:317
Rectangle(int x_in, int y_in, int width_in, int height_in)
Definition: angletypes.h:51
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:950
Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in)
Definition: angletypes.h:110
EGLContext EGLenum target
Definition: eglext.h:192
GLenum stencilBackPassDepthFail
Definition: angletypes.h:169
VendorID
Definition: angletypes.h:249
GLenum stencilFail
Definition: angletypes.h:162
Definition: angletypes.h:253
unsigned int GLenum
Definition: gl2.h:69
GLenum sourceBlendAlpha
Definition: angletypes.h:138
Definition: angletypes.h:222
GLenum wrapR
Definition: angletypes.h:185
bool colorMaskGreen
Definition: angletypes.h:144
Definition: angletypes.h:33
bool cullFace
Definition: angletypes.h:119
bool dither
Definition: angletypes.h:150
Definition: angletypes.h:44
Definition: angletypes.h:35
GLenum stencilBackFail
Definition: angletypes.h:168
GLenum blendEquationRGB
Definition: angletypes.h:140
Definition: angletypes.h:82
int z
Definition: angletypes.h:104
Rectangle()
Definition: angletypes.h:50
Offset(int x_in, int y_in, int z_in)
Definition: angletypes.h:79
Definition: angletypes.h:37
int y
Definition: angletypes.h:103
GLuint stencilWritemask
Definition: angletypes.h:165
std::unordered_map< GLuint, ResourceT * > ResourceMap
Definition: angletypes.h:244
bool colorMaskAlpha
Definition: angletypes.h:146
#define UNREACHABLE
Definition: utils.h:36
GLenum destBlendAlpha
Definition: angletypes.h:139
#define GL_FRAMEBUFFER
Definition: gl2.h:348
Definition: angletypes.h:45
SamplerType
Definition: angletypes.h:42
Definition: angletypes.h:254
Definition: angletypes.h:36
GLfloat maxLod
Definition: angletypes.h:191
std::bitset< IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS > UniformBlockBindingMask
Definition: angletypes.h:239
bool rasterizerDiscard
Definition: angletypes.h:130
khronos_float_t GLfloat
Definition: gl2.h:72
bool blend
Definition: angletypes.h:135
ClipRect intersection(const ClipRect &a, const ClipRect &b)
Definition: ClipRect.h:99
Definition: angletypes.h:314
EGLStreamKHR EGLint EGLint offset
Definition: eglext.h:984
Box(const Offset &offset, const Extents &size)
Definition: angletypes.h:111
bool colorMaskRed
Definition: angletypes.h:143
Definition: angletypes.h:311
GLenum wrapT
Definition: angletypes.h:184
Definition: mathutil.h:804
#define GL_NONE
Definition: gl2.h:371
int y
Definition: angletypes.h:62
BufferT< uint8_t > Buffer
Definition: buffer.h:370
DestT * GetImplAs(SrcT *src)
Definition: angletypes.h:295
EGLSurface EGLint x
Definition: eglext.h:950
Offset()
Definition: angletypes.h:78
int y
Definition: angletypes.h:75
Definition: Platform.h:33
GLenum stencilPassDepthFail
Definition: angletypes.h:163
GLenum stencilBackFunc
Definition: angletypes.h:166
Box()
Definition: angletypes.h:109
#define GL_DRAW_FRAMEBUFFER
Definition: gl3.h:836
int x
Definition: angletypes.h:102
GLfloat polygonOffsetUnits
Definition: angletypes.h:125
GLenum sourceBlendRGB
Definition: angletypes.h:136
GLenum FramebufferBindingToEnum(FramebufferBinding binding)
Definition: angletypes.h:333
Definition: angletypes.h:200
int y1() const
Definition: angletypes.h:59
unsigned int GLuint
Definition: gl2.h:70
int x
Definition: angletypes.h:74
bool polygonOffsetFill
Definition: angletypes.h:123
Definition: DebuggerParseData.cpp:130
Definition: angletypes.h:31
GLfloat minLod
Definition: angletypes.h:190
Extents()
Definition: angletypes.h:88
bool empty() const
Definition: angletypes.h:94
int y0() const
Definition: angletypes.h:57
EGLSurface EGLint EGLint y
Definition: eglext.h:950
GLuint stencilBackWritemask
Definition: angletypes.h:171
GLenum minFilter
Definition: angletypes.h:180
GLboolean GLboolean GLboolean GLboolean a
Definition: gl2ext.h:306
Definition: angletypes.h:251
GLenum magFilter
Definition: angletypes.h:181
int height
Definition: angletypes.h:85
int height
Definition: angletypes.h:64
GLenum wrapS
Definition: angletypes.h:183
Definition: angletypes.h:309
int width
Definition: angletypes.h:84
int width
Definition: angletypes.h:63
Definition: angletypes.h:211
GLenum src
Definition: gl2ext.h:304
GLuint stencilBackMask
Definition: angletypes.h:167
Definition: angletypes.h:310
int z
Definition: angletypes.h:76
int x0() const
Definition: angletypes.h:56
GLenum stencilBackPassDepthPass
Definition: angletypes.h:170
bool multiSample
Definition: angletypes.h:128
bool depthTest
Definition: angletypes.h:155
const DestT * GetAs(const SrcT *src)
Definition: angletypes.h:285
GLenum compareFunc
Definition: angletypes.h:194
PixelUnpackState(GLint alignmentIn, GLint rowLengthIn)
Definition: angletypes.h:215
Definition: angletypes.h:30
#define GL_READ_FRAMEBUFFER
Definition: gl3.h:835
Definition: angletypes.h:175
GLboolean GLboolean GLboolean b
Definition: gl2ext.h:306
PixelUnpackState()
Definition: angletypes.h:213
Definition: xmlparse.c:144
bool operator!=(const Extents &lhs, const Extents &rhs)
Definition: angletypes.cpp:139
bool sampleAlphaToCoverage
Definition: angletypes.h:148
std::bitset< MAX_VERTEX_ATTRIBS > AttributesMask
Definition: angletypes.h:236
Definition: angletypes.h:100
GLenum frontFace
Definition: angletypes.h:121
State
Definition: event_timer_posix.h:25
Definition: angletypes.h:72
Definition: angletypes.h:133
int depth
Definition: angletypes.h:86
Definition: angletypes.h:34
int depth
Definition: angletypes.h:107
GLenum blendEquationAlpha
Definition: angletypes.h:141
#define ASSERT(assertion)
Definition: Assertions.h:283
PrimitiveType
Definition: angletypes.h:28
bool colorMaskBlue
Definition: angletypes.h:145
Definition: angletypes.h:117
bool depthMask
Definition: angletypes.h:157
bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection)
Definition: angletypes.cpp:87
Extents(int width_, int height_, int depth_)
Definition: angletypes.h:89
int x
Definition: angletypes.h:61
Definition: entry_points_gles_2_0.h:15
PixelPackState()
Definition: angletypes.h:224
Definition: angletypes.h:313
PrimitiveType GetPrimitiveType(GLenum drawMode)
Definition: angletypes.cpp:18
int width
Definition: angletypes.h:105
Definition: angletypes.h:48
int x1() const
Definition: angletypes.h:58
#define ANGLE_HAS_DYNAMIC_TYPE(type, obj)
Definition: angletypes.h:270