os/graphics/egl/egltest/src/egltest_createpixmapsurface.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 #include "egltest_createpixmapsurface.h"
    22 
    23 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    24 #include <sgresource/sgimage.h>
    25 #else
    26 #include <graphics/sgimage.h>
    27 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    28 #include <test/tefunit.h> // for ASSERT macros
    29 
    30 #include <test/egltestcommonconversion.h>
    31 #include <test/egltestcommoninisettings.h>
    32 #include <test/egltestcommonsgimageinfo.h>
    33 
    34 
    35 
    36 /**
    37 @SYMTestCaseID GRAPHICS-EGL-0063
    38 
    39 @SYMTestPriority 1
    40 
    41 @SYMPREQ 39
    42 
    43 @SYMREQ See SGL.GT0386.401 document
    44 
    45 @SYMTestCaseDesc
    46 This test ensures the matching algorithm between EGLConfig and RSgImages when the RSgImage format is EUidPixelFormatARGB_8888_PRE.
    47 The algorithm is tested in both eglChooseConfig and eglCreatePixmap.
    48 
    49 @SYMTestActions
    50 Create an RSgImage format with the following parameters:
    51 * format: EUidPixelFormatARGB_8888_PRE
    52 * usage: ESgUsageBitOpenVgSurface
    53 Create second RSgImage format with the following parameters:
    54 * format: EUidPixelFormatXRGB_8888
    55 * usage: ESgUsageBitOpenVgSurface
    56 
    57 Query a compatible config via eglChooseConfig.
    58 If we get one compatible config check that is accepted by eglCreatePixmapSurface.
    59 1) call eglCreatePixmap with the just queried config and as attribute:
    60 	* EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE
    61 	* as native pixmap format supply RSgImage with premultiply alpha   
    62 This call has to fail and give back a EGL_BAD_MATCH error.
    63 2) call eglCreatePixmapSurface with the just queried config and as attribute:
    64     * EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE
    65     * as native pixmap format supply RSgImage with non-premultiply alpha   
    66 This call has to fail and give back a EGL_BAD_MATCH error.
    67 3) call eglCreatePixmapSurface with the just queried config and as attribute:
    68 	* EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE
    69 This call has to succed.
    70 No memory or handle leaks.
    71 
    72 @SYMTestExpectedResults
    73 The first and second calls to eglCreatePixmapSurface have to fail and give back a EGL_BAD_MATCH error.
    74 The third call has to succed.
    75 No memory or handle leaks.
    76 */
    77 TVerdict CEglTest_CreatePixmapSurface_Alpha_bit_RSgImage::doTestStepL()
    78 	{
    79 	SetTestStepID(_L("GRAPHICS-EGL-0063"));
    80 	INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_Alpha_bit_RSgImage::doTestPartialStepL"));	
    81 
    82 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap);
    83 	if(!ret)
    84 		{
    85 		// The extension is not supported
    86 		RecordTestResultL();
    87 		CloseTMSGraphicsStep();
    88 		return TestStepResult();
    89 		}
    90 
    91 	// Create display object
    92 	GetDisplayL();
    93 	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
    94 	eglSess->InitializeL();
    95 	
    96 	eglSess->OpenSgDriverL();
    97 	TSgImageInfoOpenVgTarget imageInfo = TSgImageInfoOpenVgTarget(EUidPixelFormatARGB_8888_PRE);
    98     RSgImage sgImageWithPre;
    99     // Create a SgImage ARGB_8888_PRE
   100 	CleanupClosePushL(sgImageWithPre);
   101     ret = sgImageWithPre.Create(imageInfo, NULL, NULL);
   102     ASSERT_EQUALS(ret, KErrNone);
   103     
   104 	EGLint numConfigsWithPre = 0;		
   105 	EGLConfig configWithPre[KMaxEglConfigs];
   106 	const EGLint KAttrib_list_ImageWithPre[] = { EGL_MATCH_NATIVE_PIXMAP,	(TInt)&sgImageWithPre,
   107 												 EGL_RENDERABLE_TYPE, 		EGL_OPENVG_BIT,
   108 												 EGL_SURFACE_TYPE, 			EGL_PIXMAP_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
   109 												 EGL_NONE };
   110 
   111 	INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set"));
   112 	eglChooseConfig(iDisplay,KAttrib_list_ImageWithPre,configWithPre,KMaxEglConfigs,&numConfigsWithPre);
   113     if(!numConfigsWithPre)
   114         {
   115         ERR_PRINTF1(_L("No EGL Config with EGL_VG_ALPHA_FORMAT_PRE available for EUidPixelFormatARGB_8888_PRE"));
   116         SetTestStepResult(EFail);           
   117         }
   118 
   119 	for(TInt index = 0; index < numConfigsWithPre; index++)
   120 	    {
   121 	    INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
   122 	    ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
   123 	
   124 	    INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
   125 		eglSess->SetExpectedError(EGL_BAD_MATCH);
   126 		EGLSurface surface = eglCreatePixmapSurface(iDisplay, configWithPre[index],&sgImageWithPre, KPixmapAttribsVgAlphaFormatNonPre);
   127 		if ( !eglSess->CheckExpectedError(EGL_FALSE) )
   128 			{
   129 			ERR_PRINTF1(_L("eglCreatePixmapSurface didn't fail as expected."));
   130 			SetTestStepResult(EFail);			
   131 			if(surface != EGL_NO_SURFACE)
   132 				{
   133 				eglDestroySurface(iDisplay,surface);
   134 				eglSess->CheckExpectedError(EGL_SUCCESS);
   135 				surface = EGL_NO_SURFACE;
   136 				}
   137 			}		
   138 	
   139 		surface = eglCreatePixmapSurface(iDisplay, configWithPre[index],&sgImageWithPre, KPixmapAttribsVgAlphaFormatPre);
   140 		if ( !eglSess->CheckExpectedError(EGL_TRUE) )
   141 			{
   142 			ERR_PRINTF1(_L("eglCreatePixmapSurface failed."));
   143 			SetTestStepResult(EFail);			
   144 			}
   145 		if(surface != EGL_NO_SURFACE)
   146 			{
   147 			eglDestroySurface(iDisplay,surface);
   148 			eglSess->CheckExpectedError(EGL_SUCCESS);
   149 			surface = EGL_NO_SURFACE;
   150 			}		
   151 		}
   152 	
   153 	CleanupStack::PopAndDestroy(2,eglSess);
   154 	TerminateDisplayL();
   155 	RecordTestResultL();
   156 	CloseTMSGraphicsStep();
   157 	return TestStepResult();
   158 	}
   159 
   160 
   161 /**
   162 @SYMTestCaseID GRAPHICS-EGL-0066
   163 
   164 @SYMTestPriority 1
   165 
   166 @SYMPREQ 39
   167 
   168 @SYMREQ See SGL.GT0386.401 document
   169 
   170 @SYMTestCaseDesc
   171 Test passing a non-initialised RSgImage into eglCreatePixmapSurface()
   172 
   173 @SYMTestActions
   174 Initialise the thread to use RSgImage as the native pixmap type
   175 For each config returned from eglGetConfig() that supports OpenGLES or OpenVG rendering to pixmaps
   176 	*	Create an empty RSgImage object but do not initialize it
   177 	*	Use eglCreatePixmapSurface() to construct a surface from the RSgImage object.
   178 		o	Use a NULL attrib_list
   179 	*	Close the RSgImage object
   180 
   181 @SYMTestExpectedResults
   182 Check that eglCreatePixmapSurface() returns EGL_NO_SURFACE
   183 Check that eglGetError() returns EGL_BAD_NATIVE_PIXMAP
   184 Check for memory and handle leaks.
   185 */
   186 TVerdict CEglTest_CreatePixmapSurface_RSgImage_Negative_RSgImage_NotInitialised::doTestStepL()
   187 	{
   188 	SetTestStepID(_L("GRAPHICS-EGL-0066"));
   189 	INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_RSgImage_Negative_RSgImage_NotInitialised::doTestStepL"));
   190 
   191 	TBool ret = CheckForExtensionL(KEGL_RSgimage);
   192 	if(!ret)
   193 		{
   194 		// The extension is not supported
   195 		RecordTestResultL();
   196 		CloseTMSGraphicsStep();
   197 		return TestStepResult();
   198 		}
   199 
   200 	// Create display object
   201 	GetDisplayL();
   202 	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
   203 	eglSess->InitializeL();
   204 
   205 	EGLConfig configs[KMaxEglConfigs];
   206 	EGLint numConfigs=0;
   207 
   208 	// Query number of configs available
   209 	INFO_PRINTF1(_L("Calling eglGetConfigs to get the number of configs available..."));
   210 	ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
   211 
   212 	INFO_PRINTF1(_L("Checking number of configs..."));
   213 	ASSERT_TRUE(numConfigs >= 1);
   214 	ASSERT_TRUE(numConfigs <= KMaxEglConfigs);
   215 	INFO_PRINTF2(_L("Found %d configs"), numConfigs);
   216 		
   217 	// Get the configs
   218 	INFO_PRINTF1(_L("Calling eglGetConfigs to get configs..."));
   219 	ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, configs, KMaxEglConfigs, &numConfigs));
   220 	
   221 	for(TUint index = 0; index < numConfigs; index++)
   222 		{
   223 		INFO_PRINTF2(_L("Getting Config Attributes for index %d"), index);
   224 		
   225 		EGLint surfaceType=0;
   226 		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, configs[index], EGL_SURFACE_TYPE, &surfaceType));
   227 		if (!(surfaceType & EGL_PIXMAP_BIT))
   228 			{
   229 			// This is just an info print because we don't want to test surfaces that do not support pixmaps.
   230 			VERBOSE_INFO_PRINTF1(_L("Skipping config: Does not support pixmaps"));
   231 			continue;
   232 			}
   233 		
   234 		EGLint renderableType=0;
   235 		RSgImage sgImage; // Deliberately don't initialise it
   236 		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &renderableType));		
   237 		if (renderableType & EGL_OPENVG_BIT)
   238 			{
   239 			VERBOSE_INFO_PRINTF1(_L("...is OpenVg renderable"));
   240 			eglSess->OpenSgDriverL();
   241 			
   242 			// Need to set the API type before creating the context (H/W requires this to be done before the surface is created, rather than the context)
   243 			VERBOSE_INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
   244 			ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
   245 			
   246 			// Create a pixmap surface from the native image
   247 			VERBOSE_INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
   248 			EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[index], &sgImage, KPixmapAttribsNone);
   249 			
   250 			// Expect this to fail
   251 			ASSERT_EQUALS(surface, EGL_NO_SURFACE);
   252 	 		ASSERT_EGL_ERROR(EGL_BAD_NATIVE_PIXMAP);
   253 			eglSess->CloseSgDriver();
   254 			}
   255 		
   256 		if ((renderableType & EGL_OPENGL_ES_BIT) || (renderableType & EGL_OPENGL_ES2_BIT))
   257 			{
   258 			VERBOSE_INFO_PRINTF1(_L("...is OpenGles renderable"));
   259 			eglSess->OpenSgDriverL();
   260 			
   261 			// Need to set the API type before creating the context (H/W requires this to be done before the surface is created, rather than the context)
   262 			VERBOSE_INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENGL_ES_API)"));
   263 			ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENGL_ES_API));
   264 			
   265 			// Create a pixmap surface from the native image
   266 			VERBOSE_INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
   267 			EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[index], &sgImage, KPixmapAttribsNone);
   268 			
   269 			// Expect this to fail
   270 			ASSERT_EQUALS(surface, EGL_NO_SURFACE);
   271 	 		ASSERT_EGL_ERROR(EGL_BAD_NATIVE_PIXMAP);
   272 			eglSess->CloseSgDriver();
   273 			}
   274 		}	
   275 	
   276 	CleanupStack::PopAndDestroy(eglSess);
   277 	TerminateDisplayL();
   278 	RecordTestResultL();
   279 	CloseTMSGraphicsStep();
   280 	return TestStepResult();
   281 	}
   282 
   283 /**
   284 @SYMTestCaseID GRAPHICS-EGL-0075
   285 
   286 @SYMTestPriority 1
   287 
   288 @SYMPREQ 39
   289 
   290 @SYMREQ See SGL.GT0386.401 document
   291 
   292 @SYMTestCaseDesc
   293 Test that the system can detect obviously invalid pixmap objects 
   294 
   295 @SYMTestActions
   296 Try to create a pixmap surface from an odd integer
   297 
   298 @SYMTestExpectedResults
   299 This should fail with EGL_BAD_NATIVE_PIXMAP
   300 Check that all memory and handles have been deallocated.
   301 */
   302 TVerdict CEglTest_CreatePixmapSurface_Negative_Invalid_Pixmap_Type::doTestStepL()
   303 	{
   304 	SetTestStepID(_L("GRAPHICS-EGL-0075"));
   305 	INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_Negative_Invalid_Pixmap_Type::doTestStepL"));
   306 
   307 	// Create display object
   308 	GetDisplayL();
   309 	
   310 	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
   311 
   312 	// Initialise the display object
   313 	eglSess->InitializeL();
   314 	eglSess->OpenSgDriverL();
   315 	
   316     EGLConfig configs[KMaxEglConfigs];
   317 	EGLint numConfigs=0;
   318 
   319 	const EGLint KConfigAttribPixmapSurface[] = 
   320 		{
   321 		EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
   322 		EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
   323 		EGL_NONE
   324 		};
   325 	
   326 	// Query number of configs available
   327     INFO_PRINTF1(_L("Calling eglChooseConfig to get the number of configs available for pixmap surfaces..."));
   328 	ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribPixmapSurface, NULL, KMaxTInt, &numConfigs));
   329 
   330 	INFO_PRINTF1(_L("Checking number of configs..."));
   331 	ASSERT_TRUE(numConfigs >= 1);
   332 	ASSERT_TRUE(numConfigs <= KMaxEglConfigs);
   333 	INFO_PRINTF2(_L("Found %d configs"), numConfigs);
   334 		
   335 	// Get the configs
   336 	INFO_PRINTF1(_L("Calling eglChooseConfig to get configs..."));
   337 	ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribPixmapSurface, configs, KMaxEglConfigs, &numConfigs));
   338 	
   339 	EGLint badPixmap=12345;
   340 	
   341 	EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[0], &badPixmap, NULL);	
   342 	eglSess->SetExpectedError(EGL_BAD_NATIVE_PIXMAP);	
   343 	ASSERT_TRUE(eglSess->CheckExpectedError(surface));
   344 	
   345 	CleanupStack::PopAndDestroy(eglSess);
   346 	TerminateDisplayL();
   347 	RecordTestResultL();
   348 	CloseTMSGraphicsStep();
   349 	return TestStepResult();
   350 	}
   351 
   352 /**
   353 @SYMTestCaseID GRAPHICS-EGL-0420
   354 
   355 @SYMTestPriority 1
   356 
   357 @SYMPREQ 2637
   358 
   359 @SYMREQ See SGL.GT0386.401 document
   360 
   361 @SYMTestCaseDesc
   362 Test the successful creation and use of a pixmap surface for all supporting configs.
   363 
   364 @SYMTestActions
   365 Initialize the thread to use RSgImage as the native pixmap type.
   366 For each supported combination of pixel mode and usage bits (see Graphics Resource documentation for detail)
   367    Create an SgImage
   368    Choose EGL config, supplying in attribute list as EGL_MATCH_NATIVE_PIXMAP the SgImage created on the previous step
   369    For each configuration obtained on the previous step and for three possible resource close rules (close SgImage late, close SgImage early, close SgDriver and SgImage early):
   370 o   Use eglCreatePixmapSurface() to construct a surface from the RSgImage object and make it current
   371 o   Make some basic drawing to the surface (fill the area with pre-defined  colour)
   372 o   Call eglWaitClient() to finish the above drawing instructions synchronously.
   373 o   Deallocate the surface and the pixmap
   374 
   375 @SYMTestExpectedResults
   376 There is at least one configuration available for all mandatory combinations of pixel formats and usage bits.
   377 Use EGL client API to check that the surface with underlying SgImage has the expected pixel data.
   378 */
   379 TVerdict CEglTest_CreatePixmapSurface_RSgImage_Positive_MantadoryFormatUsageSupport::doTestStepL()
   380     {
   381     SetTestStepID(_L("GRAPHICS-EGL-0420"));
   382     INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_RSgImage_Positive_MantadoryFormatUsageSupport::doTestStepL"));
   383 
   384 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap);
   385 	if(!ret)
   386 		{
   387 		// The extension is not supported
   388 		RecordTestResultL();
   389 		CloseTMSGraphicsStep();
   390 		return TestStepResult();
   391 		}
   392 
   393 	// Create display object
   394 	GetDisplayL();
   395 	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
   396 	eglSess->InitializeL();
   397 	eglSess->OpenSgDriverL();
   398 
   399     // Initialise ini parser
   400     CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
   401     CleanupStack::PushL(iniParser);
   402     TInt numPixmapSgSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapSgSurfaceFormats);
   403     
   404 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   405     const EGLint KSgPixmapUsageSupport[] =
   406         {
   407         ESgUsageBitOpenVgSurface,         
   408         ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface,
   409         ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Texture2D,
   410         ESgUsageBitOpenVgSurface | ESgUsageBitOpenVgImage| ESgUsageBitOpenGles2Texture2D,
   411         ESgUsageBitOpenGles2Surface,
   412         ESgUsageBitOpenGles2Surface | ESgUsageBitOpenVgImage,
   413         ESgUsageBitOpenGles2Texture2D |ESgUsageBitOpenGles2Surface,
   414         ESgUsageBitOpenVgImage | ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface
   415         };
   416 
   417     for(TInt i = 0; i < numPixmapSgSurfaceFormats; i++)
   418         {
   419         VGImageFormat surfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
   420         TSgImageInfoTest imageInfo = TSgImageInfoTest();
   421         imageInfo.iPixelFormat = EglTestConversion::VgFormatToSgPixelFormat(surfaceFormat);;
   422         EGLint alphaPreBit = (imageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) ? EGL_VG_ALPHA_FORMAT_PRE_BIT : 0;
   423         TInt numUsageCombinations = sizeof(KSgPixmapUsageSupport) / sizeof(KSgPixmapUsageSupport[0]);
   424         for(TUint32 j = 0; j < numUsageCombinations; j++)
   425             {
   426             if(KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface))
   427                 {
   428                 if(!eglSess->IsOpenGLES2Supported())
   429                     continue;
   430                 }
   431             if(KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGlesSurface))
   432                 {
   433                 if(!eglSess->IsOpenGLESSupported())
   434                     continue;
   435                 }
   436 
   437             imageInfo.iUsage = KSgPixmapUsageSupport[j]; 
   438             RSgImage image;
   439             ASSERT_EQUALS(image.Create(imageInfo, NULL, NULL), KErrNone);
   440             CleanupClosePushL(image);
   441             TSgImageInfoTest imageInfoSupported; 
   442             ASSERT_EQUALS(image.GetInfo(imageInfoSupported), KErrNone);//returned info may include more usage bits than we actually requested
   443             if(((imageInfoSupported.iUsage & (ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface)) && 
   444                                (!eglSess->IsOpenGLES2Supported()) ||
   445                 ((imageInfoSupported.iUsage & (ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGlesSurface)) && 
   446                                (!eglSess->IsOpenGLESSupported()))))
   447                 {
   448                 CleanupStack::PopAndDestroy(&image);
   449                 continue;
   450                 }	
   451             
   452             EGLint eglRenderableTypeValue = 0;
   453             if(imageInfoSupported.iUsage & ESgUsageBitOpenVgSurface)
   454                 {
   455                 eglRenderableTypeValue = EGL_OPENVG_BIT;
   456                 }
   457             else if(imageInfoSupported.iUsage & ESgUsageBitOpenGles2Surface)
   458                 {
   459                 eglRenderableTypeValue = EGL_OPENGL_ES2_BIT;
   460                 }
   461             else if(imageInfoSupported.iUsage & ESgUsageBitOpenGlesSurface)
   462                 {
   463                 eglRenderableTypeValue = EGL_OPENGL_ES_BIT;
   464                 }
   465             else if(imageInfoSupported.iUsage & ESgUsageBitOpenGlSurface)
   466                 {
   467                 eglRenderableTypeValue = EGL_OPENGL_BIT;
   468                 }
   469             TEST(eglRenderableTypeValue != 0);
   470 
   471             // only minimum amount of renderable type matching to Native pixmap will be passed into attribute list.
   472             // And egl will decide whatever configs include at least given renderable type.
   473             const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&image),
   474 											EGL_RENDERABLE_TYPE, eglRenderableTypeValue,
   475 											EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | alphaPreBit,
   476 											EGL_NONE };     
   477             
   478             EGLConfig configs[KMaxEglConfigs];
   479             EGLint numConfigs=0;
   480             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs, KMaxEglConfigs,&numConfigs));
   481             CleanupStack::PopAndDestroy(&image);
   482             TEST(numConfigs > 0);
   483             
   484             for(TInt index = 0; index < numConfigs; index++)
   485                 {
   486                 const TInt numCloseRules = 3; 
   487                 for(TInt closeRule = 0; closeRule < numCloseRules; closeRule++)
   488                     {
   489                     CTestEglSession::TResourceCloseRule resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   490                     switch(closeRule)
   491                         {
   492                     case 0:
   493                         VERBOSE_INFO_PRINTF1(_L("Close Image Late"));
   494                         resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   495                         break;
   496                     case 1:
   497                         VERBOSE_INFO_PRINTF1(_L("Close Image Early"));
   498                         resourceCloseRule = CTestEglSession::EResourceCloseSgImageEarly;
   499                         break;
   500                     case 2:
   501                         VERBOSE_INFO_PRINTF1(_L("Close Sg Driver and Image Early"));
   502                         resourceCloseRule = CTestEglSession::EResourceCloseSgDriverAndImageEarly;
   503                         break;
   504                     default:
   505                         break;
   506                         }
   507                 
   508                     if (KSgPixmapUsageSupport[j] & ESgUsageBitOpenVgSurface)
   509                         {
   510                         VERBOSE_INFO_PRINTF1(_L("...is OpenVG renderable"));
   511                         eglSess->TryUsePixmapRSgImageOpenVgL(configs[index], imageInfo, resourceCloseRule); // we can't fail to create an image as we have already tried it 
   512                         }
   513                     if (KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGlesTexture2D))
   514                         {
   515                         VERBOSE_INFO_PRINTF1(_L("...is OpenGLES renderable"));
   516                         eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 1); // we can't fail to create an image as we have already tried it
   517                         }
   518                     if (KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGles2Surface | ESgUsageBitOpenGles2Texture2D))
   519                         {
   520                         VERBOSE_INFO_PRINTF1(_L("...is OpenGLES2 renderable"));
   521                         eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 2); // we can't fail to create an image as we have already tried it
   522                         }
   523                     }//for(TInt closeRule; closeRule < numCloseRules; closeRule++)
   524                 }//for(TInt index = 0; index < numConfigs; index++)
   525             }//for(TUint32 j = 0; j < numUsageCombinations; j++)
   526         }//for(TInt i = 0; i < numSgImagePixelFormatSupport; i++)
   527 #else
   528     const EGLint KSgPixmapUsageSupport[] =
   529         {
   530         ESgUsageOpenVgTarget,         
   531         ESgUsageOpenVgImage | ESgUsageOpenVgTarget,
   532         ESgUsageOpenVgTarget | ESgUsageOpenGles2Texture2D,
   533         ESgUsageOpenVgTarget | ESgUsageOpenVgImage| ESgUsageOpenGles2Texture2D,
   534         ESgUsageOpenGles2Target,
   535         ESgUsageOpenGles2Target | ESgUsageOpenVgImage,
   536         ESgUsageOpenGles2Texture2D |ESgUsageOpenGles2Target,
   537         ESgUsageOpenVgImage | ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target
   538         };
   539 
   540     for(TInt i = 0; i < numPixmapSgSurfaceFormats; i++)
   541         {
   542         VGImageFormat surfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
   543         TSgImageInfoTest imageInfo = TSgImageInfoTest();
   544         imageInfo.iPixelFormat = EglTestConversion::VgFormatToSgPixelFormat(surfaceFormat);;
   545         EGLint alphaPreBit = (imageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) ? EGL_VG_ALPHA_FORMAT_PRE_BIT : 0;
   546         TInt numUsageCombinations = sizeof(KSgPixmapUsageSupport) / sizeof(KSgPixmapUsageSupport[0]);
   547         for(TUint32 j = 0; j < numUsageCombinations; j++)
   548             {
   549             if(KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target))
   550                 {
   551                 if(!eglSess->IsOpenGLES2Supported())
   552                     continue;
   553                 }
   554             if(KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGlesTarget))
   555                 {
   556                 if(!eglSess->IsOpenGLESSupported())
   557                     continue;
   558                 }
   559             imageInfo.iUsage = KSgPixmapUsageSupport[j]; 
   560             RSgImage image;
   561             ASSERT_EQUALS(image.Create(imageInfo, NULL, NULL), KErrNone);
   562             CleanupClosePushL(image);
   563             TSgImageInfoTest imageInfoSupported; 
   564             ASSERT_EQUALS(image.GetInfo(imageInfoSupported), KErrNone);//returned info may include more usage bits than we actually requested
   565             if(((imageInfoSupported.iUsage & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target)) && 
   566                                (!eglSess->IsOpenGLES2Supported()) ||
   567                 ((imageInfoSupported.iUsage & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGlesTarget)) && 
   568                                (!eglSess->IsOpenGLESSupported()))))
   569                 {
   570                 CleanupStack::PopAndDestroy(&image);
   571                 continue;
   572                 }   
   573             
   574             EGLint eglRenderableTypeValue = 0;
   575             if(imageInfoSupported.iUsage & ESgUsageOpenVgTarget)
   576                 {
   577                 eglRenderableTypeValue = EGL_OPENVG_BIT;
   578                 }
   579             else if(imageInfoSupported.iUsage & ESgUsageOpenGles2Target)
   580                 {
   581                 eglRenderableTypeValue = EGL_OPENGL_ES2_BIT;
   582                 }
   583             else if(imageInfoSupported.iUsage & ESgUsageOpenGlesTarget)
   584                 {
   585                 eglRenderableTypeValue = EGL_OPENGL_ES_BIT;
   586                 }
   587             TEST(eglRenderableTypeValue != 0);
   588             
   589             // only minimum amount of renderable type matching to Native pixmap will be passed into attribute list.
   590             // And egl will decide whatever configs include at least given renderable type.
   591             const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&image),
   592                                             EGL_RENDERABLE_TYPE, eglRenderableTypeValue,
   593                                             EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | alphaPreBit,
   594                                             EGL_NONE };     
   595             
   596             EGLConfig configs[KMaxEglConfigs];
   597             EGLint numConfigs=0;
   598             ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs, KMaxEglConfigs,&numConfigs));
   599             CleanupStack::PopAndDestroy(&image);
   600             TEST(numConfigs > 0);
   601             
   602             for(TInt index = 0; index < numConfigs; index++)
   603                 {
   604                 const TInt numCloseRules = 3; 
   605                 for(TInt closeRule = 0; closeRule < numCloseRules; closeRule++)
   606                     {
   607                     CTestEglSession::TResourceCloseRule resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   608                     switch(closeRule)
   609                         {
   610                     case 0:
   611                         VERBOSE_INFO_PRINTF1(_L("Close Image Late"));
   612                         resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   613                         break;
   614                     case 1:
   615                         VERBOSE_INFO_PRINTF1(_L("Close Image Early"));
   616                         resourceCloseRule = CTestEglSession::EResourceCloseSgImageEarly;
   617                         break;
   618                     case 2:
   619                         VERBOSE_INFO_PRINTF1(_L("Close Sg Driver and Image Early"));
   620                         resourceCloseRule = CTestEglSession::EResourceCloseSgDriverAndImageEarly;
   621                         break;
   622                     default:
   623                         break;
   624                         }
   625                 
   626                     if (KSgPixmapUsageSupport[j] & ESgUsageOpenVgTarget)
   627                         {
   628                         VERBOSE_INFO_PRINTF1(_L("...is OpenVG renderable"));
   629                         eglSess->TryUsePixmapRSgImageOpenVgL(configs[index], imageInfo, resourceCloseRule); // we can't fail to create an image as we have already tried it 
   630                         }
   631                     if (KSgPixmapUsageSupport[j] & (ESgUsageOpenGlesTarget | ESgUsageOpenGles2Texture2D))
   632                         {
   633                         VERBOSE_INFO_PRINTF1(_L("...is OpenGLES renderable"));
   634                         eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 1); // we can't fail to create an image as we have already tried it
   635                         }
   636                     if (KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Target | ESgUsageOpenGles2Texture2D))
   637                         {
   638                         VERBOSE_INFO_PRINTF1(_L("...is OpenGLES2 renderable"));
   639                         eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 2); // we can't fail to create an image as we have already tried it
   640                         }
   641                     }//for(TInt closeRule; closeRule < numCloseRules; closeRule++)
   642                 }//for(TInt index = 0; index < numConfigs; index++)
   643             }//for(TUint32 j = 0; j < numUsageCombinations; j++)
   644         }//for(TInt i = 0; i < numSgImagePixelFormatSupport; i++)
   645     
   646  #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   647     
   648     CleanupStack::PopAndDestroy(2, eglSess);//iniParser, eglSess
   649     TerminateDisplayL();
   650     RecordTestResultL();
   651     CloseTMSGraphicsStep();
   652     return TestStepResult();
   653     }