|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef EGLTESTCOMMONUTILS_H |
|
23 #define EGLTESTCOMMONUTILS_H |
|
24 |
|
25 #include <w32std.h> |
|
26 #include <pixelformats.h> |
|
27 #include <EGL/eglext.h> |
|
28 #include <VG/openvg.h> |
|
29 |
|
30 |
|
31 /******************************************************************************/ |
|
32 /*** ***/ |
|
33 /*** Global constants and definitions for EGL Tests ***/ |
|
34 /*** ***/ |
|
35 /******************************************************************************/ |
|
36 |
|
37 const TUidPixelFormat KDefaultSourceFormat = EUidPixelFormatARGB_8888_PRE; |
|
38 const VGImageFormat KDefaultSurfaceFormat = VG_sARGB_8888_PRE; |
|
39 |
|
40 const TInt KMaxEglConfigs = 1024; |
|
41 const TInt KTestNoMatchingConfig = -1714; |
|
42 |
|
43 enum TExtensionsGroups |
|
44 { |
|
45 EIsUndefined, |
|
46 EIsRSgImage, |
|
47 EIsEGL, |
|
48 EIsVG, |
|
49 EIsGLES |
|
50 }; |
|
51 |
|
52 /** |
|
53 Provides an index into KConfigAttribs |
|
54 */ |
|
55 enum TEglTestConfig |
|
56 { |
|
57 EPixmapAttribsColor64K, |
|
58 EPixmapAttribsColor16MU, |
|
59 EPixmapAttribsColor16MAP, |
|
60 EWindowAttribsColor64K, |
|
61 EWindowAttribsColor16MA, |
|
62 EWindowAttribsColor16MAP, |
|
63 EPBufferAttribsColor64K, |
|
64 EPBufferAttribsColor16MU, |
|
65 EPBufferAttribsColor16MA, |
|
66 EPBufferAttribsColor16MAP, |
|
67 EPBufferAttribsColorGles64K, |
|
68 EWindowAttribsColor16MA_Preserved, |
|
69 EEglTestConfigMax // Must be the last item in the list. |
|
70 }; |
|
71 |
|
72 // Symbian config attributes for pixmaps / pbuffers / windows |
|
73 static const EGLint KConfigAttribs[EEglTestConfigMax][15] = |
|
74 { |
|
75 { |
|
76 //EColor64K - Pixmap |
|
77 EGL_BUFFER_SIZE, 16, |
|
78 EGL_RED_SIZE, 5, |
|
79 EGL_GREEN_SIZE, 6, |
|
80 EGL_BLUE_SIZE, 5, |
|
81 EGL_ALPHA_SIZE, 0, |
|
82 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
83 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, |
|
84 EGL_NONE |
|
85 }, |
|
86 { |
|
87 //EColor16MU - Pixmap |
|
88 EGL_BUFFER_SIZE, 24, |
|
89 EGL_RED_SIZE, 8, |
|
90 EGL_GREEN_SIZE, 8, |
|
91 EGL_BLUE_SIZE, 8, |
|
92 EGL_ALPHA_SIZE, 0, |
|
93 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
94 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, |
|
95 EGL_NONE |
|
96 }, |
|
97 { |
|
98 //EColor16MAP - Pixmap |
|
99 EGL_BUFFER_SIZE, 32, |
|
100 EGL_RED_SIZE, 8, |
|
101 EGL_GREEN_SIZE, 8, |
|
102 EGL_BLUE_SIZE, 8, |
|
103 EGL_ALPHA_SIZE, 8, |
|
104 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
105 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, |
|
106 EGL_NONE |
|
107 }, |
|
108 { |
|
109 //EWindowAttribsColor64K - Window |
|
110 EGL_BUFFER_SIZE, 16, |
|
111 EGL_RED_SIZE, 5, |
|
112 EGL_GREEN_SIZE, 6, |
|
113 EGL_BLUE_SIZE, 5, |
|
114 EGL_ALPHA_SIZE, 0, |
|
115 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
116 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
|
117 EGL_NONE |
|
118 }, |
|
119 { |
|
120 //EWindowAttribsColor16MA - Window |
|
121 EGL_BUFFER_SIZE, 32, |
|
122 EGL_RED_SIZE, 8, |
|
123 EGL_GREEN_SIZE, 8, |
|
124 EGL_BLUE_SIZE, 8, |
|
125 EGL_ALPHA_SIZE, 8, |
|
126 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
127 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
|
128 EGL_NONE |
|
129 }, |
|
130 { |
|
131 //EWindowAttribsColor16MAP - Window |
|
132 EGL_BUFFER_SIZE, 32, |
|
133 EGL_RED_SIZE, 8, |
|
134 EGL_GREEN_SIZE, 8, |
|
135 EGL_BLUE_SIZE, 8, |
|
136 EGL_ALPHA_SIZE, 8, |
|
137 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
138 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, |
|
139 EGL_NONE |
|
140 }, |
|
141 { |
|
142 // EPBufferAttribsColor64K - PBuffer |
|
143 EGL_BUFFER_SIZE, 16, |
|
144 EGL_RED_SIZE, 5, |
|
145 EGL_GREEN_SIZE, 6, |
|
146 EGL_BLUE_SIZE, 5, |
|
147 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
148 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
|
149 EGL_NONE |
|
150 }, |
|
151 { |
|
152 // EPBufferAttribsColor16MU - PBuffer |
|
153 EGL_BUFFER_SIZE, 24, |
|
154 EGL_RED_SIZE, 8, |
|
155 EGL_GREEN_SIZE, 8, |
|
156 EGL_BLUE_SIZE, 8, |
|
157 EGL_ALPHA_SIZE, 0, |
|
158 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
159 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
|
160 EGL_NONE |
|
161 }, |
|
162 { |
|
163 // EPBufferAttribsColor16MA - PBuffer |
|
164 EGL_BUFFER_SIZE, 32, |
|
165 EGL_RED_SIZE, 8, |
|
166 EGL_GREEN_SIZE, 8, |
|
167 EGL_BLUE_SIZE, 8, |
|
168 EGL_ALPHA_SIZE, 8, |
|
169 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
170 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
|
171 EGL_NONE |
|
172 }, |
|
173 { |
|
174 // EPBufferAttribsColor16MAP - PBuffer |
|
175 EGL_BUFFER_SIZE, 32, |
|
176 EGL_RED_SIZE, 8, |
|
177 EGL_GREEN_SIZE, 8, |
|
178 EGL_BLUE_SIZE, 8, |
|
179 EGL_ALPHA_SIZE, 8, |
|
180 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
181 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, |
|
182 EGL_NONE |
|
183 }, |
|
184 { |
|
185 // EPBufferAttribsColorGles64K - PBuffer |
|
186 EGL_BUFFER_SIZE, 16, |
|
187 EGL_RED_SIZE, 5, |
|
188 EGL_GREEN_SIZE, 6, |
|
189 EGL_BLUE_SIZE, 5, |
|
190 EGL_ALPHA_SIZE, 0, |
|
191 EGL_RENDERABLE_TYPE,EGL_OPENGL_ES_BIT, |
|
192 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
|
193 EGL_NONE |
|
194 }, |
|
195 { |
|
196 //EWindowAttribsColor16MA Preserved - Window |
|
197 EGL_BUFFER_SIZE, 32, |
|
198 EGL_RED_SIZE, 8, |
|
199 EGL_GREEN_SIZE, 8, |
|
200 EGL_BLUE_SIZE, 8, |
|
201 EGL_ALPHA_SIZE, 8, |
|
202 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, |
|
203 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT, |
|
204 EGL_NONE |
|
205 }, |
|
206 }; |
|
207 |
|
208 enum TEglConfigMatchType |
|
209 { |
|
210 /** Dummy, used for "uninitialized/unknowns/error" situations */ |
|
211 eMatchUnknown, |
|
212 /** Matches whatever - don't actually compare anything. */ |
|
213 eMatchAlways, |
|
214 /** Matches equal values - config must match requested value. */ |
|
215 eMatchEqual, |
|
216 /** Matches greater or equal - config must be equal or greater than requested value. */ |
|
217 eMatchAtLeast, |
|
218 /** Match bitmask - config bits must have the requested bits. */ |
|
219 eMatchBitMask |
|
220 }; |
|
221 |
|
222 const TInt KNumConfigMatchRules = 2; |
|
223 |
|
224 struct TConfigMatchRuleItem |
|
225 { |
|
226 EGLint iAttrib; |
|
227 TEglConfigMatchType iMatchType; |
|
228 }; |
|
229 |
|
230 /** |
|
231 Defines rules for how to match a requested config with the configs returned by eglChooseConfig. |
|
232 */ |
|
233 static const TConfigMatchRuleItem KConfigMatchRules[KNumConfigMatchRules][15] = |
|
234 { |
|
235 { |
|
236 // EConfigMatchStandard |
|
237 { EGL_BUFFER_SIZE, eMatchAtLeast }, |
|
238 { EGL_RED_SIZE, eMatchEqual }, |
|
239 { EGL_GREEN_SIZE, eMatchEqual }, |
|
240 { EGL_BLUE_SIZE, eMatchEqual }, |
|
241 { EGL_ALPHA_SIZE, eMatchEqual }, |
|
242 { EGL_RENDERABLE_TYPE, eMatchBitMask }, |
|
243 { EGL_SURFACE_TYPE, eMatchBitMask }, |
|
244 { EGL_NONE, eMatchUnknown } |
|
245 }, |
|
246 { |
|
247 // EConfigMatchIgnoreAlpha |
|
248 { EGL_BUFFER_SIZE, eMatchAtLeast }, |
|
249 { EGL_RED_SIZE, eMatchEqual }, |
|
250 { EGL_GREEN_SIZE, eMatchEqual }, |
|
251 { EGL_BLUE_SIZE, eMatchEqual }, |
|
252 { EGL_ALPHA_SIZE, eMatchAlways }, |
|
253 { EGL_RENDERABLE_TYPE, eMatchBitMask }, |
|
254 { EGL_SURFACE_TYPE, eMatchBitMask }, |
|
255 { EGL_NONE, eMatchUnknown } |
|
256 } |
|
257 }; |
|
258 |
|
259 /** |
|
260 Provides an index into KConfigMatchRules |
|
261 */ |
|
262 enum TEglConfigMatchRule |
|
263 { |
|
264 EConfigMatchStandard, |
|
265 EConfigMatchIgnoreAlpha, |
|
266 }; |
|
267 |
|
268 // Attributes that can be passed into eglCreatePixmapSurface() |
|
269 const EGLint KPixmapAttribsNone[] = { EGL_NONE }; |
|
270 const EGLint KPixmapAttribsVgAlphaFormatPre[] = |
|
271 { |
|
272 EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE, |
|
273 EGL_NONE |
|
274 }; |
|
275 |
|
276 const EGLint KPixmapAttribsVgAlphaFormatNonPre[] = |
|
277 { |
|
278 EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE, |
|
279 EGL_NONE |
|
280 }; |
|
281 |
|
282 // Attributes that can be passed into eglCreateImageKHR() |
|
283 const EGLint KEglImageAttribsNone[] = { EGL_NONE }; |
|
284 const EGLint KEglImageAttribsPreservedTrue[] = |
|
285 { |
|
286 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, |
|
287 EGL_NONE |
|
288 }; |
|
289 const EGLint KEglImageAttribsPreservedFalse[] = |
|
290 { |
|
291 EGL_IMAGE_PRESERVED_KHR, EGL_FALSE, |
|
292 EGL_NONE |
|
293 }; |
|
294 |
|
295 // Attributes that can be passed into eglCreateSyncKHR() |
|
296 const EGLint KEglSyncAttribsNone[] = {EGL_NONE}; |
|
297 |
|
298 /** |
|
299 Performs a TEFUNIT style ASSERT, but also outputs the last EGL error code. |
|
300 Use this macro to check that EGL function calls have succeeded. |
|
301 */ |
|
302 #define ASSERT_EGL_TRUE(aFunction) \ |
|
303 if(!(aFunction)) \ |
|
304 { \ |
|
305 EGLint eglError = eglGetError(); \ |
|
306 ERR_PRINTF2(_L("EGL Error: 0x%x"), eglError); \ |
|
307 User::Leave(KErrTEFUnitFail); \ |
|
308 } |
|
309 |
|
310 /** |
|
311 Performs a TEFUNIT style ASSERT, but also outputs the last EGL error code. |
|
312 Use this macro to check that the expected EGL error has occurred. |
|
313 */ |
|
314 #define ASSERT_EGL_ERROR(aExpectedError) \ |
|
315 { \ |
|
316 EGLint eglError = eglGetError(); \ |
|
317 if (eglError != aExpectedError) \ |
|
318 { \ |
|
319 ERR_PRINTF3(_L("Actual EGL Error: 0x%x, but Expected EGL Error: 0x%x"), eglError, aExpectedError); \ |
|
320 User::Leave(KErrTEFUnitFail); \ |
|
321 } \ |
|
322 } |
|
323 |
|
324 /** |
|
325 Performs a TEFUNIT style TEST. Use this macro to check that |
|
326 EGL function calls have succeeded and the expected EGL error has occurred. |
|
327 */ |
|
328 #define TEST_EGL_ERROR(aFunction, aExpectedError) \ |
|
329 TEST(aFunction); \ |
|
330 TEST(eglGetError() == aExpectedError); |
|
331 |
|
332 /** |
|
333 Performs a TEFUNIT style ASSERT, but also outputs the last VG error code. |
|
334 Use this macro to check that VG function calls have succeeded. |
|
335 */ |
|
336 #define ASSERT_VG_TRUE(aFunction) \ |
|
337 if(!(aFunction)) \ |
|
338 { \ |
|
339 VGErrorCode vgError = vgGetError(); \ |
|
340 ERR_PRINTF2(_L("VG Error: 0x%x"), vgError); \ |
|
341 User::Leave(KErrTEFUnitFail); \ |
|
342 } |
|
343 |
|
344 /** |
|
345 Performs a TEFUNIT style ASSERT, but also outputs the last VG error code. |
|
346 Use this macro to check that the expected VG error has occurred. |
|
347 */ |
|
348 #define ASSERT_VG_ERROR(aExpectedError) \ |
|
349 { \ |
|
350 VGErrorCode vgError = vgGetError(); \ |
|
351 if (vgError != aExpectedError) \ |
|
352 { \ |
|
353 ERR_PRINTF3(_L("Actual VG Error: 0x%x, but Expected VG Error: 0x%x"), vgError, aExpectedError); \ |
|
354 User::Leave(KErrTEFUnitFail); \ |
|
355 } \ |
|
356 } |
|
357 |
|
358 |
|
359 // The following macros allow verbose logging to be switched on and off programmatically. |
|
360 #define VERBOSE_INFO_PRINTF1(p1) if (iVerboseLogging) { INFO_PRINTF1(p1); } |
|
361 #define VERBOSE_INFO_PRINTF2(p1, p2) if (iVerboseLogging) { INFO_PRINTF2(p1, p2); } |
|
362 #define VERBOSE_INFO_PRINTF3(p1, p2, p3) if (iVerboseLogging) { INFO_PRINTF3(p1, p2, p3); } |
|
363 |
|
364 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
365 _LIT8(KEglRSgImage,"EGL_NOK_pixmap_type_rsgimage"); |
|
366 #else |
|
367 _LIT8(KEglRSgImage,"EGL_SYMBIAN_PIXMAP_TYPE_RSGIMAGE"); |
|
368 #endif |
|
369 _LIT8(KEglKhrImageBase,"EGL_KHR_image_base"); |
|
370 _LIT8(KEglKhrImagePixmap,"EGL_KHR_image_pixmap"); |
|
371 _LIT8(KVgKhrEglImage,"VG_KHR_EGL_image"); |
|
372 _LIT8(KEglKhrReusableSync,"EGL_KHR_reusable_sync"); |
|
373 _LIT8(KEglNokPrivateSignalSync,"EGL_NOK__private__signal_sync"); |
|
374 _LIT8(KEglNokiaSwapBuffers,"EGL_NOKIA_swap_buffers"); |
|
375 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
376 _LIT8(KEglSymbianImagePreserved,"EGL_SYMBIAN_image_preserved"); |
|
377 #endif |
|
378 |
|
379 |
|
380 enum TExtensionsId |
|
381 { |
|
382 KEGLUndefined, |
|
383 KEGL_RSgimage = 0x01, |
|
384 KEGL_KHR_image_base = 0x02, |
|
385 KEGL_KHR_image_pixmap = 0x04, |
|
386 KVG_KHR_EGL_image = 0x08, |
|
387 KEGL_KHR_reusable_sync = 0x10, |
|
388 KEGL_NOK__private__signal_sync = 0x20, |
|
389 KEGL_NOKIA_swap_buffers = 0x40, |
|
390 KEGL_SYMBIAN_image_preserved = 0x80 |
|
391 }; |
|
392 |
|
393 const TUid KUidEglTestServer={0x10281B40}; |
|
394 const TUid KUidEglTestServerNga={0x10285DC0}; |
|
395 |
|
396 #endif // EGLTESTCOMMONUTILS_H |