Update contrib.
1 // Copyright (c) 2007-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #ifndef EGLTESTCOMMONUTILS_H
23 #define EGLTESTCOMMONUTILS_H
26 #include <pixelformats.h>
27 #include <EGL/eglext.h>
28 #include <VG/openvg.h>
31 /******************************************************************************/
33 /*** Global constants and definitions for EGL Tests ***/
35 /******************************************************************************/
37 const TUidPixelFormat KDefaultSourceFormat = EUidPixelFormatARGB_8888_PRE;
38 const VGImageFormat KDefaultSurfaceFormat = VG_sARGB_8888_PRE;
40 const TInt KMaxEglConfigs = 1024;
41 const TInt KTestNoMatchingConfig = -1714;
43 enum TExtensionsGroups
53 Provides an index into KConfigAttribs
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.
72 // Symbian config attributes for pixmaps / pbuffers / windows
73 static const EGLint KConfigAttribs[EEglTestConfigMax][15] =
82 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
83 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
93 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
94 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
98 //EColor16MAP - Pixmap
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,
109 //EWindowAttribsColor64K - Window
115 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
116 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
120 //EWindowAttribsColor16MA - Window
126 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
127 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
131 //EWindowAttribsColor16MAP - Window
137 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
138 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
142 // EPBufferAttribsColor64K - PBuffer
147 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
148 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
152 // EPBufferAttribsColor16MU - PBuffer
158 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
159 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
163 // EPBufferAttribsColor16MA - PBuffer
169 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
170 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
174 // EPBufferAttribsColor16MAP - PBuffer
180 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
181 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
185 // EPBufferAttribsColorGles64K - PBuffer
191 EGL_RENDERABLE_TYPE,EGL_OPENGL_ES_BIT,
192 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
196 //EWindowAttribsColor16MA Preserved - Window
202 EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
203 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT,
208 enum TEglConfigMatchType
210 /** Dummy, used for "uninitialized/unknowns/error" situations */
212 /** Matches whatever - don't actually compare anything. */
214 /** Matches equal values - config must match requested value. */
216 /** Matches greater or equal - config must be equal or greater than requested value. */
218 /** Match bitmask - config bits must have the requested bits. */
222 const TInt KNumConfigMatchRules = 2;
224 struct TConfigMatchRuleItem
227 TEglConfigMatchType iMatchType;
231 Defines rules for how to match a requested config with the configs returned by eglChooseConfig.
233 static const TConfigMatchRuleItem KConfigMatchRules[KNumConfigMatchRules][15] =
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 }
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 }
260 Provides an index into KConfigMatchRules
262 enum TEglConfigMatchRule
264 EConfigMatchStandard,
265 EConfigMatchIgnoreAlpha,
268 // Attributes that can be passed into eglCreatePixmapSurface()
269 const EGLint KPixmapAttribsNone[] = { EGL_NONE };
270 const EGLint KPixmapAttribsVgAlphaFormatPre[] =
272 EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE,
276 const EGLint KPixmapAttribsVgAlphaFormatNonPre[] =
278 EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE,
282 // Attributes that can be passed into eglCreateImageKHR()
283 const EGLint KEglImageAttribsNone[] = { EGL_NONE };
284 const EGLint KEglImageAttribsPreservedTrue[] =
286 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
289 const EGLint KEglImageAttribsPreservedFalse[] =
291 EGL_IMAGE_PRESERVED_KHR, EGL_FALSE,
295 // Attributes that can be passed into eglCreateSyncKHR()
296 const EGLint KEglSyncAttribsNone[] = {EGL_NONE};
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.
302 #define ASSERT_EGL_TRUE(aFunction) \
305 EGLint eglError = eglGetError(); \
306 ERR_PRINTF2(_L("EGL Error: 0x%x"), eglError); \
307 User::Leave(KErrTEFUnitFail); \
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.
314 #define ASSERT_EGL_ERROR(aExpectedError) \
316 EGLint eglError = eglGetError(); \
317 if (eglError != aExpectedError) \
319 ERR_PRINTF3(_L("Actual EGL Error: 0x%x, but Expected EGL Error: 0x%x"), eglError, aExpectedError); \
320 User::Leave(KErrTEFUnitFail); \
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.
328 #define TEST_EGL_ERROR(aFunction, aExpectedError) \
330 TEST(eglGetError() == aExpectedError);
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.
336 #define ASSERT_VG_TRUE(aFunction) \
339 VGErrorCode vgError = vgGetError(); \
340 ERR_PRINTF2(_L("VG Error: 0x%x"), vgError); \
341 User::Leave(KErrTEFUnitFail); \
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.
348 #define ASSERT_VG_ERROR(aExpectedError) \
350 VGErrorCode vgError = vgGetError(); \
351 if (vgError != aExpectedError) \
353 ERR_PRINTF3(_L("Actual VG Error: 0x%x, but Expected VG Error: 0x%x"), vgError, aExpectedError); \
354 User::Leave(KErrTEFUnitFail); \
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); }
364 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
365 _LIT8(KEglRSgImage,"EGL_NOK_pixmap_type_rsgimage");
367 _LIT8(KEglRSgImage,"EGL_SYMBIAN_PIXMAP_TYPE_RSGIMAGE");
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 _LIT8(KEglNokiaImageEndpoint,"EGL_NOK_image_endpoint");
376 _LIT8(KEglNokiaSurfaceScaling,"EGL_NOK_surface_scaling");
377 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
378 _LIT8(KEglSymbianImagePreserved,"EGL_SYMBIAN_image_preserved");
385 KEGL_RSgimage = 0x01,
386 KEGL_KHR_image_base = 0x02,
387 KEGL_KHR_image_pixmap = 0x04,
388 KVG_KHR_EGL_image = 0x08,
389 KEGL_KHR_reusable_sync = 0x10,
390 KEGL_NOK__private__signal_sync = 0x20,
391 KEGL_NOKIA_swap_buffers = 0x40,
392 KEGL_SYMBIAN_image_preserved = 0x80,
393 KEGL_NOK_image_endpoint = 0x100,
394 KEGL_NOK_surface_scaling = 0x200
397 const TUid KUidEglTestServer={0x10281B40};
398 const TUid KUidEglTestServerNga={0x10285DC0};
400 #endif // EGLTESTCOMMONUTILS_H