1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Utilities
3 * ------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief EGL String Utilities.
22 *//*--------------------------------------------------------------------*/
23
24 #include "egluStrUtil.hpp"
25 #include "egluHeaderWrapper.hpp"
26
27 #include <EGL/eglext.h>
28
29 #if !defined(EGL_OPENGL_ES3_BIT_KHR)
30 # define EGL_OPENGL_ES3_BIT_KHR 0x0040
31 #endif
32
33 namespace eglu
34 {
35
operator <<(std::ostream & str,const ConfigAttribValueFmt & attribFmt)36 std::ostream& operator<< (std::ostream& str, const ConfigAttribValueFmt& attribFmt)
37 {
38 switch (attribFmt.attribute)
39 {
40 case EGL_COLOR_BUFFER_TYPE:
41 return str << getColorBufferTypeStr(attribFmt.value);
42
43 case EGL_CONFIG_CAVEAT:
44 return str << getConfigCaveatStr(attribFmt.value);
45
46 case EGL_CONFORMANT:
47 case EGL_RENDERABLE_TYPE:
48 return str << getAPIBitsStr(attribFmt.value);
49
50 case EGL_SURFACE_TYPE:
51 return str << getSurfaceBitsStr(attribFmt.value);
52
53 case EGL_MATCH_NATIVE_PIXMAP:
54 if (attribFmt.value == EGL_NONE)
55 return str << "EGL_NONE";
56 else
57 return str << tcu::toHex(attribFmt.value);
58
59 case EGL_TRANSPARENT_TYPE:
60 return str << getTransparentTypeStr(attribFmt.value);
61
62 case EGL_BIND_TO_TEXTURE_RGB:
63 case EGL_BIND_TO_TEXTURE_RGBA:
64 case EGL_NATIVE_RENDERABLE:
65 return str << getBoolDontCareStr(attribFmt.value);
66
67 case EGL_ALPHA_MASK_SIZE:
68 case EGL_ALPHA_SIZE:
69 case EGL_BLUE_SIZE:
70 case EGL_BUFFER_SIZE:
71 case EGL_CONFIG_ID:
72 case EGL_DEPTH_SIZE:
73 case EGL_GREEN_SIZE:
74 case EGL_LEVEL:
75 case EGL_LUMINANCE_SIZE:
76 case EGL_MAX_SWAP_INTERVAL:
77 case EGL_MIN_SWAP_INTERVAL:
78 case EGL_RED_SIZE:
79 case EGL_SAMPLE_BUFFERS:
80 case EGL_SAMPLES:
81 case EGL_STENCIL_SIZE:
82 case EGL_TRANSPARENT_RED_VALUE:
83 case EGL_TRANSPARENT_GREEN_VALUE:
84 case EGL_TRANSPARENT_BLUE_VALUE:
85 return str << (int)attribFmt.value;
86
87 default:
88 return str << tcu::toHex(attribFmt.value);
89 }
90 }
91
operator <<(std::ostream & str,const ContextAttribValueFmt & attribFmt)92 std::ostream& operator<< (std::ostream& str, const ContextAttribValueFmt& attribFmt)
93 {
94 switch (attribFmt.attribute)
95 {
96 case EGL_CONFIG_ID:
97 case EGL_CONTEXT_CLIENT_VERSION:
98 return str << (int)attribFmt.value;
99
100 case EGL_CONTEXT_CLIENT_TYPE:
101 return str << getAPIStr(attribFmt.value);
102
103 case EGL_RENDER_BUFFER:
104 return str << getRenderBufferStr(attribFmt.value);
105
106 default:
107 return str << tcu::toHex(attribFmt.value);
108 }
109 }
110
operator <<(std::ostream & str,const SurfaceAttribValueFmt & attribFmt)111 std::ostream& operator<< (std::ostream& str, const SurfaceAttribValueFmt& attribFmt)
112 {
113 switch (attribFmt.attribute)
114 {
115 case EGL_CONFIG_ID:
116 case EGL_WIDTH:
117 case EGL_HEIGHT:
118 case EGL_HORIZONTAL_RESOLUTION:
119 case EGL_VERTICAL_RESOLUTION:
120 case EGL_PIXEL_ASPECT_RATIO:
121 return str << (int)attribFmt.value;
122
123 case EGL_LARGEST_PBUFFER:
124 case EGL_MIPMAP_TEXTURE:
125 return str << getBoolDontCareStr(attribFmt.value);
126
127 case EGL_MULTISAMPLE_RESOLVE:
128 return str << getMultisampleResolveStr(attribFmt.value);
129
130 case EGL_RENDER_BUFFER:
131 return str << getRenderBufferStr(attribFmt.value);
132
133 case EGL_SWAP_BEHAVIOR:
134 return str << getSwapBehaviorStr(attribFmt.value);
135
136 case EGL_TEXTURE_FORMAT:
137 return str << getTextureFormatStr(attribFmt.value);
138
139 case EGL_TEXTURE_TARGET:
140 return str << getTextureTargetStr(attribFmt.value);
141
142 case EGL_VG_ALPHA_FORMAT:
143 return str << getVGAlphaFormatStr(attribFmt.value);
144
145 case EGL_VG_COLORSPACE:
146 return str << getVGColorspaceStr(attribFmt.value);
147
148 default:
149 return str << tcu::toHex(attribFmt.value);
150 }
151 }
152
operator <<(std::ostream & str,const ConfigAttribListFmt & fmt)153 std::ostream& operator<< (std::ostream& str, const ConfigAttribListFmt& fmt)
154 {
155 int pos = 0;
156
157 str << "{ ";
158
159 for (;;)
160 {
161 int attrib = fmt.attribs[pos];
162
163 if (pos != 0)
164 str << ", ";
165
166 if (attrib == EGL_NONE)
167 {
168 // Terminate.
169 str << "EGL_NONE";
170 break;
171 }
172
173 const char* attribName = getConfigAttribName(attrib);
174
175 if (attribName)
176 {
177 // Valid attribute, print value.
178 str << attribName << ", " << getConfigAttribValueStr(attrib, fmt.attribs[pos+1]);
179 pos += 2;
180 }
181 else
182 {
183 // Invalid attribute. Terminate parsing.
184 str << tcu::toHex(attrib) << ", ???";
185 break;
186 }
187 }
188
189 str << " }";
190 return str;
191 }
192
operator <<(std::ostream & str,const SurfaceAttribListFmt & fmt)193 std::ostream& operator<< (std::ostream& str, const SurfaceAttribListFmt& fmt)
194 {
195 int pos = 0;
196
197 str << "{ ";
198
199 for (;;)
200 {
201 int attrib = fmt.attribs[pos];
202
203 if (pos != 0)
204 str << ", ";
205
206 if (attrib == EGL_NONE)
207 {
208 // Terminate.
209 str << "EGL_NONE";
210 break;
211 }
212
213 const char* attribName = getSurfaceAttribName(attrib);
214
215 if (attribName)
216 {
217 // Valid attribute, print value.
218 str << attribName << ", " << getSurfaceAttribValueStr(attrib, fmt.attribs[pos+1]);
219 pos += 2;
220 }
221 else
222 {
223 // Invalid attribute. Terminate parsing.
224 str << tcu::toHex(attrib) << ", ???";
225 break;
226 }
227 }
228
229 str << " }";
230 return str;
231 }
232
operator <<(std::ostream & str,const ContextAttribListFmt & fmt)233 std::ostream& operator<< (std::ostream& str, const ContextAttribListFmt& fmt)
234 {
235 int pos = 0;
236
237 str << "{ ";
238
239 for (;;)
240 {
241 int attrib = fmt.attribs[pos];
242
243 if (pos != 0)
244 str << ", ";
245
246 if (attrib == EGL_NONE)
247 {
248 // Terminate.
249 str << "EGL_NONE";
250 break;
251 }
252
253 const char* attribName = getContextAttribName(attrib);
254
255 if (attribName)
256 {
257 // Valid attribute, print value.
258 str << attribName << ", " << getContextAttribValueStr(attrib, fmt.attribs[pos+1]);
259 pos += 2;
260 }
261 else
262 {
263 // Invalid attribute. Terminate parsing.
264 str << tcu::toHex(attrib) << ", ???";
265 break;
266 }
267 }
268
269 str << " }";
270 return str;
271 }
272
273 #include "egluStrUtil.inl"
274
275 } // eglu
276