sl@0: // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: */ sl@0: sl@0: sl@0: #ifndef EGLTESTCOMMONUTILS_H sl@0: #define EGLTESTCOMMONUTILS_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: /******************************************************************************/ sl@0: /*** ***/ sl@0: /*** Global constants and definitions for EGL Tests ***/ sl@0: /*** ***/ sl@0: /******************************************************************************/ sl@0: sl@0: const TUidPixelFormat KDefaultSourceFormat = EUidPixelFormatARGB_8888_PRE; sl@0: const VGImageFormat KDefaultSurfaceFormat = VG_sARGB_8888_PRE; sl@0: sl@0: const TInt KMaxEglConfigs = 1024; sl@0: const TInt KTestNoMatchingConfig = -1714; sl@0: sl@0: enum TExtensionsGroups sl@0: { sl@0: EIsUndefined, sl@0: EIsRSgImage, sl@0: EIsEGL, sl@0: EIsVG, sl@0: EIsGLES sl@0: }; sl@0: sl@0: /** sl@0: Provides an index into KConfigAttribs sl@0: */ sl@0: enum TEglTestConfig sl@0: { sl@0: EPixmapAttribsColor64K, sl@0: EPixmapAttribsColor16MU, sl@0: EPixmapAttribsColor16MAP, sl@0: EWindowAttribsColor64K, sl@0: EWindowAttribsColor16MA, sl@0: EWindowAttribsColor16MAP, sl@0: EPBufferAttribsColor64K, sl@0: EPBufferAttribsColor16MU, sl@0: EPBufferAttribsColor16MA, sl@0: EPBufferAttribsColor16MAP, sl@0: EPBufferAttribsColorGles64K, sl@0: EWindowAttribsColor16MA_Preserved, sl@0: EEglTestConfigMax // Must be the last item in the list. sl@0: }; sl@0: sl@0: // Symbian config attributes for pixmaps / pbuffers / windows sl@0: static const EGLint KConfigAttribs[EEglTestConfigMax][15] = sl@0: { sl@0: { sl@0: //EColor64K - Pixmap sl@0: EGL_BUFFER_SIZE, 16, sl@0: EGL_RED_SIZE, 5, sl@0: EGL_GREEN_SIZE, 6, sl@0: EGL_BLUE_SIZE, 5, sl@0: EGL_ALPHA_SIZE, 0, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: //EColor16MU - Pixmap sl@0: EGL_BUFFER_SIZE, 24, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 0, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: //EColor16MAP - Pixmap sl@0: EGL_BUFFER_SIZE, 32, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 8, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: //EWindowAttribsColor64K - Window sl@0: EGL_BUFFER_SIZE, 16, sl@0: EGL_RED_SIZE, 5, sl@0: EGL_GREEN_SIZE, 6, sl@0: EGL_BLUE_SIZE, 5, sl@0: EGL_ALPHA_SIZE, 0, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_WINDOW_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: //EWindowAttribsColor16MA - Window sl@0: EGL_BUFFER_SIZE, 32, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 8, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_WINDOW_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: //EWindowAttribsColor16MAP - Window sl@0: EGL_BUFFER_SIZE, 32, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 8, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: // EPBufferAttribsColor64K - PBuffer sl@0: EGL_BUFFER_SIZE, 16, sl@0: EGL_RED_SIZE, 5, sl@0: EGL_GREEN_SIZE, 6, sl@0: EGL_BLUE_SIZE, 5, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: // EPBufferAttribsColor16MU - PBuffer sl@0: EGL_BUFFER_SIZE, 24, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 0, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: // EPBufferAttribsColor16MA - PBuffer sl@0: EGL_BUFFER_SIZE, 32, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 8, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: // EPBufferAttribsColor16MAP - PBuffer sl@0: EGL_BUFFER_SIZE, 32, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 8, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: // EPBufferAttribsColorGles64K - PBuffer sl@0: EGL_BUFFER_SIZE, 16, sl@0: EGL_RED_SIZE, 5, sl@0: EGL_GREEN_SIZE, 6, sl@0: EGL_BLUE_SIZE, 5, sl@0: EGL_ALPHA_SIZE, 0, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENGL_ES_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, sl@0: EGL_NONE sl@0: }, sl@0: { sl@0: //EWindowAttribsColor16MA Preserved - Window sl@0: EGL_BUFFER_SIZE, 32, sl@0: EGL_RED_SIZE, 8, sl@0: EGL_GREEN_SIZE, 8, sl@0: EGL_BLUE_SIZE, 8, sl@0: EGL_ALPHA_SIZE, 8, sl@0: EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT, sl@0: EGL_NONE sl@0: }, sl@0: }; sl@0: sl@0: enum TEglConfigMatchType sl@0: { sl@0: /** Dummy, used for "uninitialized/unknowns/error" situations */ sl@0: eMatchUnknown, sl@0: /** Matches whatever - don't actually compare anything. */ sl@0: eMatchAlways, sl@0: /** Matches equal values - config must match requested value. */ sl@0: eMatchEqual, sl@0: /** Matches greater or equal - config must be equal or greater than requested value. */ sl@0: eMatchAtLeast, sl@0: /** Match bitmask - config bits must have the requested bits. */ sl@0: eMatchBitMask sl@0: }; sl@0: sl@0: const TInt KNumConfigMatchRules = 2; sl@0: sl@0: struct TConfigMatchRuleItem sl@0: { sl@0: EGLint iAttrib; sl@0: TEglConfigMatchType iMatchType; sl@0: }; sl@0: sl@0: /** sl@0: Defines rules for how to match a requested config with the configs returned by eglChooseConfig. sl@0: */ sl@0: static const TConfigMatchRuleItem KConfigMatchRules[KNumConfigMatchRules][15] = sl@0: { sl@0: { sl@0: // EConfigMatchStandard sl@0: { EGL_BUFFER_SIZE, eMatchAtLeast }, sl@0: { EGL_RED_SIZE, eMatchEqual }, sl@0: { EGL_GREEN_SIZE, eMatchEqual }, sl@0: { EGL_BLUE_SIZE, eMatchEqual }, sl@0: { EGL_ALPHA_SIZE, eMatchEqual }, sl@0: { EGL_RENDERABLE_TYPE, eMatchBitMask }, sl@0: { EGL_SURFACE_TYPE, eMatchBitMask }, sl@0: { EGL_NONE, eMatchUnknown } sl@0: }, sl@0: { sl@0: // EConfigMatchIgnoreAlpha sl@0: { EGL_BUFFER_SIZE, eMatchAtLeast }, sl@0: { EGL_RED_SIZE, eMatchEqual }, sl@0: { EGL_GREEN_SIZE, eMatchEqual }, sl@0: { EGL_BLUE_SIZE, eMatchEqual }, sl@0: { EGL_ALPHA_SIZE, eMatchAlways }, sl@0: { EGL_RENDERABLE_TYPE, eMatchBitMask }, sl@0: { EGL_SURFACE_TYPE, eMatchBitMask }, sl@0: { EGL_NONE, eMatchUnknown } sl@0: } sl@0: }; sl@0: sl@0: /** sl@0: Provides an index into KConfigMatchRules sl@0: */ sl@0: enum TEglConfigMatchRule sl@0: { sl@0: EConfigMatchStandard, sl@0: EConfigMatchIgnoreAlpha, sl@0: }; sl@0: sl@0: // Attributes that can be passed into eglCreatePixmapSurface() sl@0: const EGLint KPixmapAttribsNone[] = { EGL_NONE }; sl@0: const EGLint KPixmapAttribsVgAlphaFormatPre[] = sl@0: { sl@0: EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE, sl@0: EGL_NONE sl@0: }; sl@0: sl@0: const EGLint KPixmapAttribsVgAlphaFormatNonPre[] = sl@0: { sl@0: EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE, sl@0: EGL_NONE sl@0: }; sl@0: sl@0: // Attributes that can be passed into eglCreateImageKHR() sl@0: const EGLint KEglImageAttribsNone[] = { EGL_NONE }; sl@0: const EGLint KEglImageAttribsPreservedTrue[] = sl@0: { sl@0: EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, sl@0: EGL_NONE sl@0: }; sl@0: const EGLint KEglImageAttribsPreservedFalse[] = sl@0: { sl@0: EGL_IMAGE_PRESERVED_KHR, EGL_FALSE, sl@0: EGL_NONE sl@0: }; sl@0: sl@0: // Attributes that can be passed into eglCreateSyncKHR() sl@0: const EGLint KEglSyncAttribsNone[] = {EGL_NONE}; sl@0: sl@0: /** sl@0: Performs a TEFUNIT style ASSERT, but also outputs the last EGL error code. sl@0: Use this macro to check that EGL function calls have succeeded. sl@0: */ sl@0: #define ASSERT_EGL_TRUE(aFunction) \ sl@0: if(!(aFunction)) \ sl@0: { \ sl@0: EGLint eglError = eglGetError(); \ sl@0: ERR_PRINTF2(_L("EGL Error: 0x%x"), eglError); \ sl@0: User::Leave(KErrTEFUnitFail); \ sl@0: } sl@0: sl@0: /** sl@0: Performs a TEFUNIT style ASSERT, but also outputs the last EGL error code. sl@0: Use this macro to check that the expected EGL error has occurred. sl@0: */ sl@0: #define ASSERT_EGL_ERROR(aExpectedError) \ sl@0: { \ sl@0: EGLint eglError = eglGetError(); \ sl@0: if (eglError != aExpectedError) \ sl@0: { \ sl@0: ERR_PRINTF3(_L("Actual EGL Error: 0x%x, but Expected EGL Error: 0x%x"), eglError, aExpectedError); \ sl@0: User::Leave(KErrTEFUnitFail); \ sl@0: } \ sl@0: } sl@0: sl@0: /** sl@0: Performs a TEFUNIT style TEST. Use this macro to check that sl@0: EGL function calls have succeeded and the expected EGL error has occurred. sl@0: */ sl@0: #define TEST_EGL_ERROR(aFunction, aExpectedError) \ sl@0: TEST(aFunction); \ sl@0: TEST(eglGetError() == aExpectedError); sl@0: sl@0: /** sl@0: Performs a TEFUNIT style ASSERT, but also outputs the last VG error code. sl@0: Use this macro to check that VG function calls have succeeded. sl@0: */ sl@0: #define ASSERT_VG_TRUE(aFunction) \ sl@0: if(!(aFunction)) \ sl@0: { \ sl@0: VGErrorCode vgError = vgGetError(); \ sl@0: ERR_PRINTF2(_L("VG Error: 0x%x"), vgError); \ sl@0: User::Leave(KErrTEFUnitFail); \ sl@0: } sl@0: sl@0: /** sl@0: Performs a TEFUNIT style ASSERT, but also outputs the last VG error code. sl@0: Use this macro to check that the expected VG error has occurred. sl@0: */ sl@0: #define ASSERT_VG_ERROR(aExpectedError) \ sl@0: { \ sl@0: VGErrorCode vgError = vgGetError(); \ sl@0: if (vgError != aExpectedError) \ sl@0: { \ sl@0: ERR_PRINTF3(_L("Actual VG Error: 0x%x, but Expected VG Error: 0x%x"), vgError, aExpectedError); \ sl@0: User::Leave(KErrTEFUnitFail); \ sl@0: } \ sl@0: } sl@0: sl@0: sl@0: // The following macros allow verbose logging to be switched on and off programmatically. sl@0: #define VERBOSE_INFO_PRINTF1(p1) if (iVerboseLogging) { INFO_PRINTF1(p1); } sl@0: #define VERBOSE_INFO_PRINTF2(p1, p2) if (iVerboseLogging) { INFO_PRINTF2(p1, p2); } sl@0: #define VERBOSE_INFO_PRINTF3(p1, p2, p3) if (iVerboseLogging) { INFO_PRINTF3(p1, p2, p3); } sl@0: sl@0: #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE sl@0: _LIT8(KEglRSgImage,"EGL_NOK_pixmap_type_rsgimage"); sl@0: #else sl@0: _LIT8(KEglRSgImage,"EGL_SYMBIAN_PIXMAP_TYPE_RSGIMAGE"); sl@0: #endif sl@0: _LIT8(KEglKhrImageBase,"EGL_KHR_image_base"); sl@0: _LIT8(KEglKhrImagePixmap,"EGL_KHR_image_pixmap"); sl@0: _LIT8(KVgKhrEglImage,"VG_KHR_EGL_image"); sl@0: _LIT8(KEglKhrReusableSync,"EGL_KHR_reusable_sync"); sl@0: _LIT8(KEglNokPrivateSignalSync,"EGL_NOK__private__signal_sync"); sl@0: _LIT8(KEglNokiaSwapBuffers,"EGL_NOKIA_swap_buffers"); sl@0: _LIT8(KEglNokiaImageEndpoint,"EGL_NOK_image_endpoint"); sl@0: _LIT8(KEglNokiaSurfaceScaling,"EGL_NOK_surface_scaling"); sl@0: #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE sl@0: _LIT8(KEglSymbianImagePreserved,"EGL_SYMBIAN_image_preserved"); sl@0: #endif sl@0: sl@0: sl@0: enum TExtensionsId sl@0: { sl@0: KEGLUndefined, sl@0: KEGL_RSgimage = 0x01, sl@0: KEGL_KHR_image_base = 0x02, sl@0: KEGL_KHR_image_pixmap = 0x04, sl@0: KVG_KHR_EGL_image = 0x08, sl@0: KEGL_KHR_reusable_sync = 0x10, sl@0: KEGL_NOK__private__signal_sync = 0x20, sl@0: KEGL_NOKIA_swap_buffers = 0x40, sl@0: KEGL_SYMBIAN_image_preserved = 0x80, sl@0: KEGL_NOK_image_endpoint = 0x100, sl@0: KEGL_NOK_surface_scaling = 0x200 sl@0: }; sl@0: sl@0: const TUid KUidEglTestServer={0x10281B40}; sl@0: const TUid KUidEglTestServerNga={0x10285DC0}; sl@0: sl@0: #endif // EGLTESTCOMMONUTILS_H