os/graphics/egl/egltest/src/egltest_createpixmapsurface.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/src/egltest_createpixmapsurface.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,653 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test 
    1.22 +*/
    1.23 +
    1.24 +#include "egltest_createpixmapsurface.h"
    1.25 +
    1.26 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.27 +#include <sgresource/sgimage.h>
    1.28 +#else
    1.29 +#include <graphics/sgimage.h>
    1.30 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.31 +#include <test/tefunit.h> // for ASSERT macros
    1.32 +
    1.33 +#include <test/egltestcommonconversion.h>
    1.34 +#include <test/egltestcommoninisettings.h>
    1.35 +#include <test/egltestcommonsgimageinfo.h>
    1.36 +
    1.37 +
    1.38 +
    1.39 +/**
    1.40 +@SYMTestCaseID GRAPHICS-EGL-0063
    1.41 +
    1.42 +@SYMTestPriority 1
    1.43 +
    1.44 +@SYMPREQ 39
    1.45 +
    1.46 +@SYMREQ See SGL.GT0386.401 document
    1.47 +
    1.48 +@SYMTestCaseDesc
    1.49 +This test ensures the matching algorithm between EGLConfig and RSgImages when the RSgImage format is EUidPixelFormatARGB_8888_PRE.
    1.50 +The algorithm is tested in both eglChooseConfig and eglCreatePixmap.
    1.51 +
    1.52 +@SYMTestActions
    1.53 +Create an RSgImage format with the following parameters:
    1.54 +* format: EUidPixelFormatARGB_8888_PRE
    1.55 +* usage: ESgUsageBitOpenVgSurface
    1.56 +Create second RSgImage format with the following parameters:
    1.57 +* format: EUidPixelFormatXRGB_8888
    1.58 +* usage: ESgUsageBitOpenVgSurface
    1.59 +
    1.60 +Query a compatible config via eglChooseConfig.
    1.61 +If we get one compatible config check that is accepted by eglCreatePixmapSurface.
    1.62 +1) call eglCreatePixmap with the just queried config and as attribute:
    1.63 +	* EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE
    1.64 +	* as native pixmap format supply RSgImage with premultiply alpha   
    1.65 +This call has to fail and give back a EGL_BAD_MATCH error.
    1.66 +2) call eglCreatePixmapSurface with the just queried config and as attribute:
    1.67 +    * EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE
    1.68 +    * as native pixmap format supply RSgImage with non-premultiply alpha   
    1.69 +This call has to fail and give back a EGL_BAD_MATCH error.
    1.70 +3) call eglCreatePixmapSurface with the just queried config and as attribute:
    1.71 +	* EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE
    1.72 +This call has to succed.
    1.73 +No memory or handle leaks.
    1.74 +
    1.75 +@SYMTestExpectedResults
    1.76 +The first and second calls to eglCreatePixmapSurface have to fail and give back a EGL_BAD_MATCH error.
    1.77 +The third call has to succed.
    1.78 +No memory or handle leaks.
    1.79 +*/
    1.80 +TVerdict CEglTest_CreatePixmapSurface_Alpha_bit_RSgImage::doTestStepL()
    1.81 +	{
    1.82 +	SetTestStepID(_L("GRAPHICS-EGL-0063"));
    1.83 +	INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_Alpha_bit_RSgImage::doTestPartialStepL"));	
    1.84 +
    1.85 +	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap);
    1.86 +	if(!ret)
    1.87 +		{
    1.88 +		// The extension is not supported
    1.89 +		RecordTestResultL();
    1.90 +		CloseTMSGraphicsStep();
    1.91 +		return TestStepResult();
    1.92 +		}
    1.93 +
    1.94 +	// Create display object
    1.95 +	GetDisplayL();
    1.96 +	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
    1.97 +	eglSess->InitializeL();
    1.98 +	
    1.99 +	eglSess->OpenSgDriverL();
   1.100 +	TSgImageInfoOpenVgTarget imageInfo = TSgImageInfoOpenVgTarget(EUidPixelFormatARGB_8888_PRE);
   1.101 +    RSgImage sgImageWithPre;
   1.102 +    // Create a SgImage ARGB_8888_PRE
   1.103 +	CleanupClosePushL(sgImageWithPre);
   1.104 +    ret = sgImageWithPre.Create(imageInfo, NULL, NULL);
   1.105 +    ASSERT_EQUALS(ret, KErrNone);
   1.106 +    
   1.107 +	EGLint numConfigsWithPre = 0;		
   1.108 +	EGLConfig configWithPre[KMaxEglConfigs];
   1.109 +	const EGLint KAttrib_list_ImageWithPre[] = { EGL_MATCH_NATIVE_PIXMAP,	(TInt)&sgImageWithPre,
   1.110 +												 EGL_RENDERABLE_TYPE, 		EGL_OPENVG_BIT,
   1.111 +												 EGL_SURFACE_TYPE, 			EGL_PIXMAP_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
   1.112 +												 EGL_NONE };
   1.113 +
   1.114 +	INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set"));
   1.115 +	eglChooseConfig(iDisplay,KAttrib_list_ImageWithPre,configWithPre,KMaxEglConfigs,&numConfigsWithPre);
   1.116 +    if(!numConfigsWithPre)
   1.117 +        {
   1.118 +        ERR_PRINTF1(_L("No EGL Config with EGL_VG_ALPHA_FORMAT_PRE available for EUidPixelFormatARGB_8888_PRE"));
   1.119 +        SetTestStepResult(EFail);           
   1.120 +        }
   1.121 +
   1.122 +	for(TInt index = 0; index < numConfigsWithPre; index++)
   1.123 +	    {
   1.124 +	    INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
   1.125 +	    ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
   1.126 +	
   1.127 +	    INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
   1.128 +		eglSess->SetExpectedError(EGL_BAD_MATCH);
   1.129 +		EGLSurface surface = eglCreatePixmapSurface(iDisplay, configWithPre[index],&sgImageWithPre, KPixmapAttribsVgAlphaFormatNonPre);
   1.130 +		if ( !eglSess->CheckExpectedError(EGL_FALSE) )
   1.131 +			{
   1.132 +			ERR_PRINTF1(_L("eglCreatePixmapSurface didn't fail as expected."));
   1.133 +			SetTestStepResult(EFail);			
   1.134 +			if(surface != EGL_NO_SURFACE)
   1.135 +				{
   1.136 +				eglDestroySurface(iDisplay,surface);
   1.137 +				eglSess->CheckExpectedError(EGL_SUCCESS);
   1.138 +				surface = EGL_NO_SURFACE;
   1.139 +				}
   1.140 +			}		
   1.141 +	
   1.142 +		surface = eglCreatePixmapSurface(iDisplay, configWithPre[index],&sgImageWithPre, KPixmapAttribsVgAlphaFormatPre);
   1.143 +		if ( !eglSess->CheckExpectedError(EGL_TRUE) )
   1.144 +			{
   1.145 +			ERR_PRINTF1(_L("eglCreatePixmapSurface failed."));
   1.146 +			SetTestStepResult(EFail);			
   1.147 +			}
   1.148 +		if(surface != EGL_NO_SURFACE)
   1.149 +			{
   1.150 +			eglDestroySurface(iDisplay,surface);
   1.151 +			eglSess->CheckExpectedError(EGL_SUCCESS);
   1.152 +			surface = EGL_NO_SURFACE;
   1.153 +			}		
   1.154 +		}
   1.155 +	
   1.156 +	CleanupStack::PopAndDestroy(2,eglSess);
   1.157 +	TerminateDisplayL();
   1.158 +	RecordTestResultL();
   1.159 +	CloseTMSGraphicsStep();
   1.160 +	return TestStepResult();
   1.161 +	}
   1.162 +
   1.163 +
   1.164 +/**
   1.165 +@SYMTestCaseID GRAPHICS-EGL-0066
   1.166 +
   1.167 +@SYMTestPriority 1
   1.168 +
   1.169 +@SYMPREQ 39
   1.170 +
   1.171 +@SYMREQ See SGL.GT0386.401 document
   1.172 +
   1.173 +@SYMTestCaseDesc
   1.174 +Test passing a non-initialised RSgImage into eglCreatePixmapSurface()
   1.175 +
   1.176 +@SYMTestActions
   1.177 +Initialise the thread to use RSgImage as the native pixmap type
   1.178 +For each config returned from eglGetConfig() that supports OpenGLES or OpenVG rendering to pixmaps
   1.179 +	*	Create an empty RSgImage object but do not initialize it
   1.180 +	*	Use eglCreatePixmapSurface() to construct a surface from the RSgImage object.
   1.181 +		o	Use a NULL attrib_list
   1.182 +	*	Close the RSgImage object
   1.183 +
   1.184 +@SYMTestExpectedResults
   1.185 +Check that eglCreatePixmapSurface() returns EGL_NO_SURFACE
   1.186 +Check that eglGetError() returns EGL_BAD_NATIVE_PIXMAP
   1.187 +Check for memory and handle leaks.
   1.188 +*/
   1.189 +TVerdict CEglTest_CreatePixmapSurface_RSgImage_Negative_RSgImage_NotInitialised::doTestStepL()
   1.190 +	{
   1.191 +	SetTestStepID(_L("GRAPHICS-EGL-0066"));
   1.192 +	INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_RSgImage_Negative_RSgImage_NotInitialised::doTestStepL"));
   1.193 +
   1.194 +	TBool ret = CheckForExtensionL(KEGL_RSgimage);
   1.195 +	if(!ret)
   1.196 +		{
   1.197 +		// The extension is not supported
   1.198 +		RecordTestResultL();
   1.199 +		CloseTMSGraphicsStep();
   1.200 +		return TestStepResult();
   1.201 +		}
   1.202 +
   1.203 +	// Create display object
   1.204 +	GetDisplayL();
   1.205 +	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
   1.206 +	eglSess->InitializeL();
   1.207 +
   1.208 +	EGLConfig configs[KMaxEglConfigs];
   1.209 +	EGLint numConfigs=0;
   1.210 +
   1.211 +	// Query number of configs available
   1.212 +	INFO_PRINTF1(_L("Calling eglGetConfigs to get the number of configs available..."));
   1.213 +	ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
   1.214 +
   1.215 +	INFO_PRINTF1(_L("Checking number of configs..."));
   1.216 +	ASSERT_TRUE(numConfigs >= 1);
   1.217 +	ASSERT_TRUE(numConfigs <= KMaxEglConfigs);
   1.218 +	INFO_PRINTF2(_L("Found %d configs"), numConfigs);
   1.219 +		
   1.220 +	// Get the configs
   1.221 +	INFO_PRINTF1(_L("Calling eglGetConfigs to get configs..."));
   1.222 +	ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, configs, KMaxEglConfigs, &numConfigs));
   1.223 +	
   1.224 +	for(TUint index = 0; index < numConfigs; index++)
   1.225 +		{
   1.226 +		INFO_PRINTF2(_L("Getting Config Attributes for index %d"), index);
   1.227 +		
   1.228 +		EGLint surfaceType=0;
   1.229 +		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, configs[index], EGL_SURFACE_TYPE, &surfaceType));
   1.230 +		if (!(surfaceType & EGL_PIXMAP_BIT))
   1.231 +			{
   1.232 +			// This is just an info print because we don't want to test surfaces that do not support pixmaps.
   1.233 +			VERBOSE_INFO_PRINTF1(_L("Skipping config: Does not support pixmaps"));
   1.234 +			continue;
   1.235 +			}
   1.236 +		
   1.237 +		EGLint renderableType=0;
   1.238 +		RSgImage sgImage; // Deliberately don't initialise it
   1.239 +		ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &renderableType));		
   1.240 +		if (renderableType & EGL_OPENVG_BIT)
   1.241 +			{
   1.242 +			VERBOSE_INFO_PRINTF1(_L("...is OpenVg renderable"));
   1.243 +			eglSess->OpenSgDriverL();
   1.244 +			
   1.245 +			// 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)
   1.246 +			VERBOSE_INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
   1.247 +			ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
   1.248 +			
   1.249 +			// Create a pixmap surface from the native image
   1.250 +			VERBOSE_INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
   1.251 +			EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[index], &sgImage, KPixmapAttribsNone);
   1.252 +			
   1.253 +			// Expect this to fail
   1.254 +			ASSERT_EQUALS(surface, EGL_NO_SURFACE);
   1.255 +	 		ASSERT_EGL_ERROR(EGL_BAD_NATIVE_PIXMAP);
   1.256 +			eglSess->CloseSgDriver();
   1.257 +			}
   1.258 +		
   1.259 +		if ((renderableType & EGL_OPENGL_ES_BIT) || (renderableType & EGL_OPENGL_ES2_BIT))
   1.260 +			{
   1.261 +			VERBOSE_INFO_PRINTF1(_L("...is OpenGles renderable"));
   1.262 +			eglSess->OpenSgDriverL();
   1.263 +			
   1.264 +			// 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)
   1.265 +			VERBOSE_INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENGL_ES_API)"));
   1.266 +			ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENGL_ES_API));
   1.267 +			
   1.268 +			// Create a pixmap surface from the native image
   1.269 +			VERBOSE_INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
   1.270 +			EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[index], &sgImage, KPixmapAttribsNone);
   1.271 +			
   1.272 +			// Expect this to fail
   1.273 +			ASSERT_EQUALS(surface, EGL_NO_SURFACE);
   1.274 +	 		ASSERT_EGL_ERROR(EGL_BAD_NATIVE_PIXMAP);
   1.275 +			eglSess->CloseSgDriver();
   1.276 +			}
   1.277 +		}	
   1.278 +	
   1.279 +	CleanupStack::PopAndDestroy(eglSess);
   1.280 +	TerminateDisplayL();
   1.281 +	RecordTestResultL();
   1.282 +	CloseTMSGraphicsStep();
   1.283 +	return TestStepResult();
   1.284 +	}
   1.285 +
   1.286 +/**
   1.287 +@SYMTestCaseID GRAPHICS-EGL-0075
   1.288 +
   1.289 +@SYMTestPriority 1
   1.290 +
   1.291 +@SYMPREQ 39
   1.292 +
   1.293 +@SYMREQ See SGL.GT0386.401 document
   1.294 +
   1.295 +@SYMTestCaseDesc
   1.296 +Test that the system can detect obviously invalid pixmap objects 
   1.297 +
   1.298 +@SYMTestActions
   1.299 +Try to create a pixmap surface from an odd integer
   1.300 +
   1.301 +@SYMTestExpectedResults
   1.302 +This should fail with EGL_BAD_NATIVE_PIXMAP
   1.303 +Check that all memory and handles have been deallocated.
   1.304 +*/
   1.305 +TVerdict CEglTest_CreatePixmapSurface_Negative_Invalid_Pixmap_Type::doTestStepL()
   1.306 +	{
   1.307 +	SetTestStepID(_L("GRAPHICS-EGL-0075"));
   1.308 +	INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_Negative_Invalid_Pixmap_Type::doTestStepL"));
   1.309 +
   1.310 +	// Create display object
   1.311 +	GetDisplayL();
   1.312 +	
   1.313 +	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
   1.314 +
   1.315 +	// Initialise the display object
   1.316 +	eglSess->InitializeL();
   1.317 +	eglSess->OpenSgDriverL();
   1.318 +	
   1.319 +    EGLConfig configs[KMaxEglConfigs];
   1.320 +	EGLint numConfigs=0;
   1.321 +
   1.322 +	const EGLint KConfigAttribPixmapSurface[] = 
   1.323 +		{
   1.324 +		EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
   1.325 +		EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
   1.326 +		EGL_NONE
   1.327 +		};
   1.328 +	
   1.329 +	// Query number of configs available
   1.330 +    INFO_PRINTF1(_L("Calling eglChooseConfig to get the number of configs available for pixmap surfaces..."));
   1.331 +	ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribPixmapSurface, NULL, KMaxTInt, &numConfigs));
   1.332 +
   1.333 +	INFO_PRINTF1(_L("Checking number of configs..."));
   1.334 +	ASSERT_TRUE(numConfigs >= 1);
   1.335 +	ASSERT_TRUE(numConfigs <= KMaxEglConfigs);
   1.336 +	INFO_PRINTF2(_L("Found %d configs"), numConfigs);
   1.337 +		
   1.338 +	// Get the configs
   1.339 +	INFO_PRINTF1(_L("Calling eglChooseConfig to get configs..."));
   1.340 +	ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribPixmapSurface, configs, KMaxEglConfigs, &numConfigs));
   1.341 +	
   1.342 +	EGLint badPixmap=12345;
   1.343 +	
   1.344 +	EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[0], &badPixmap, NULL);	
   1.345 +	eglSess->SetExpectedError(EGL_BAD_NATIVE_PIXMAP);	
   1.346 +	ASSERT_TRUE(eglSess->CheckExpectedError(surface));
   1.347 +	
   1.348 +	CleanupStack::PopAndDestroy(eglSess);
   1.349 +	TerminateDisplayL();
   1.350 +	RecordTestResultL();
   1.351 +	CloseTMSGraphicsStep();
   1.352 +	return TestStepResult();
   1.353 +	}
   1.354 +
   1.355 +/**
   1.356 +@SYMTestCaseID GRAPHICS-EGL-0420
   1.357 +
   1.358 +@SYMTestPriority 1
   1.359 +
   1.360 +@SYMPREQ 2637
   1.361 +
   1.362 +@SYMREQ See SGL.GT0386.401 document
   1.363 +
   1.364 +@SYMTestCaseDesc
   1.365 +Test the successful creation and use of a pixmap surface for all supporting configs.
   1.366 +
   1.367 +@SYMTestActions
   1.368 +Initialize the thread to use RSgImage as the native pixmap type.
   1.369 +For each supported combination of pixel mode and usage bits (see Graphics Resource documentation for detail)
   1.370 +   Create an SgImage
   1.371 +   Choose EGL config, supplying in attribute list as EGL_MATCH_NATIVE_PIXMAP the SgImage created on the previous step
   1.372 +   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):
   1.373 +o   Use eglCreatePixmapSurface() to construct a surface from the RSgImage object and make it current
   1.374 +o   Make some basic drawing to the surface (fill the area with pre-defined  colour)
   1.375 +o   Call eglWaitClient() to finish the above drawing instructions synchronously.
   1.376 +o   Deallocate the surface and the pixmap
   1.377 +
   1.378 +@SYMTestExpectedResults
   1.379 +There is at least one configuration available for all mandatory combinations of pixel formats and usage bits.
   1.380 +Use EGL client API to check that the surface with underlying SgImage has the expected pixel data.
   1.381 +*/
   1.382 +TVerdict CEglTest_CreatePixmapSurface_RSgImage_Positive_MantadoryFormatUsageSupport::doTestStepL()
   1.383 +    {
   1.384 +    SetTestStepID(_L("GRAPHICS-EGL-0420"));
   1.385 +    INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_RSgImage_Positive_MantadoryFormatUsageSupport::doTestStepL"));
   1.386 +
   1.387 +	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap);
   1.388 +	if(!ret)
   1.389 +		{
   1.390 +		// The extension is not supported
   1.391 +		RecordTestResultL();
   1.392 +		CloseTMSGraphicsStep();
   1.393 +		return TestStepResult();
   1.394 +		}
   1.395 +
   1.396 +	// Create display object
   1.397 +	GetDisplayL();
   1.398 +	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
   1.399 +	eglSess->InitializeL();
   1.400 +	eglSess->OpenSgDriverL();
   1.401 +
   1.402 +    // Initialise ini parser
   1.403 +    CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
   1.404 +    CleanupStack::PushL(iniParser);
   1.405 +    TInt numPixmapSgSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapSgSurfaceFormats);
   1.406 +    
   1.407 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   1.408 +    const EGLint KSgPixmapUsageSupport[] =
   1.409 +        {
   1.410 +        ESgUsageBitOpenVgSurface,         
   1.411 +        ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface,
   1.412 +        ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Texture2D,
   1.413 +        ESgUsageBitOpenVgSurface | ESgUsageBitOpenVgImage| ESgUsageBitOpenGles2Texture2D,
   1.414 +        ESgUsageBitOpenGles2Surface,
   1.415 +        ESgUsageBitOpenGles2Surface | ESgUsageBitOpenVgImage,
   1.416 +        ESgUsageBitOpenGles2Texture2D |ESgUsageBitOpenGles2Surface,
   1.417 +        ESgUsageBitOpenVgImage | ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface
   1.418 +        };
   1.419 +
   1.420 +    for(TInt i = 0; i < numPixmapSgSurfaceFormats; i++)
   1.421 +        {
   1.422 +        VGImageFormat surfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
   1.423 +        TSgImageInfoTest imageInfo = TSgImageInfoTest();
   1.424 +        imageInfo.iPixelFormat = EglTestConversion::VgFormatToSgPixelFormat(surfaceFormat);;
   1.425 +        EGLint alphaPreBit = (imageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) ? EGL_VG_ALPHA_FORMAT_PRE_BIT : 0;
   1.426 +        TInt numUsageCombinations = sizeof(KSgPixmapUsageSupport) / sizeof(KSgPixmapUsageSupport[0]);
   1.427 +        for(TUint32 j = 0; j < numUsageCombinations; j++)
   1.428 +            {
   1.429 +            if(KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface))
   1.430 +                {
   1.431 +                if(!eglSess->IsOpenGLES2Supported())
   1.432 +                    continue;
   1.433 +                }
   1.434 +            if(KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGlesSurface))
   1.435 +                {
   1.436 +                if(!eglSess->IsOpenGLESSupported())
   1.437 +                    continue;
   1.438 +                }
   1.439 +
   1.440 +            imageInfo.iUsage = KSgPixmapUsageSupport[j]; 
   1.441 +            RSgImage image;
   1.442 +            ASSERT_EQUALS(image.Create(imageInfo, NULL, NULL), KErrNone);
   1.443 +            CleanupClosePushL(image);
   1.444 +            TSgImageInfoTest imageInfoSupported; 
   1.445 +            ASSERT_EQUALS(image.GetInfo(imageInfoSupported), KErrNone);//returned info may include more usage bits than we actually requested
   1.446 +            if(((imageInfoSupported.iUsage & (ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface)) && 
   1.447 +                               (!eglSess->IsOpenGLES2Supported()) ||
   1.448 +                ((imageInfoSupported.iUsage & (ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGlesSurface)) && 
   1.449 +                               (!eglSess->IsOpenGLESSupported()))))
   1.450 +                {
   1.451 +                CleanupStack::PopAndDestroy(&image);
   1.452 +                continue;
   1.453 +                }	
   1.454 +            
   1.455 +            EGLint eglRenderableTypeValue = 0;
   1.456 +            if(imageInfoSupported.iUsage & ESgUsageBitOpenVgSurface)
   1.457 +                {
   1.458 +                eglRenderableTypeValue = EGL_OPENVG_BIT;
   1.459 +                }
   1.460 +            else if(imageInfoSupported.iUsage & ESgUsageBitOpenGles2Surface)
   1.461 +                {
   1.462 +                eglRenderableTypeValue = EGL_OPENGL_ES2_BIT;
   1.463 +                }
   1.464 +            else if(imageInfoSupported.iUsage & ESgUsageBitOpenGlesSurface)
   1.465 +                {
   1.466 +                eglRenderableTypeValue = EGL_OPENGL_ES_BIT;
   1.467 +                }
   1.468 +            else if(imageInfoSupported.iUsage & ESgUsageBitOpenGlSurface)
   1.469 +                {
   1.470 +                eglRenderableTypeValue = EGL_OPENGL_BIT;
   1.471 +                }
   1.472 +            TEST(eglRenderableTypeValue != 0);
   1.473 +
   1.474 +            // only minimum amount of renderable type matching to Native pixmap will be passed into attribute list.
   1.475 +            // And egl will decide whatever configs include at least given renderable type.
   1.476 +            const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&image),
   1.477 +											EGL_RENDERABLE_TYPE, eglRenderableTypeValue,
   1.478 +											EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | alphaPreBit,
   1.479 +											EGL_NONE };     
   1.480 +            
   1.481 +            EGLConfig configs[KMaxEglConfigs];
   1.482 +            EGLint numConfigs=0;
   1.483 +            ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs, KMaxEglConfigs,&numConfigs));
   1.484 +            CleanupStack::PopAndDestroy(&image);
   1.485 +            TEST(numConfigs > 0);
   1.486 +            
   1.487 +            for(TInt index = 0; index < numConfigs; index++)
   1.488 +                {
   1.489 +                const TInt numCloseRules = 3; 
   1.490 +                for(TInt closeRule = 0; closeRule < numCloseRules; closeRule++)
   1.491 +                    {
   1.492 +                    CTestEglSession::TResourceCloseRule resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   1.493 +                    switch(closeRule)
   1.494 +                        {
   1.495 +                    case 0:
   1.496 +                        VERBOSE_INFO_PRINTF1(_L("Close Image Late"));
   1.497 +                        resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   1.498 +                        break;
   1.499 +                    case 1:
   1.500 +                        VERBOSE_INFO_PRINTF1(_L("Close Image Early"));
   1.501 +                        resourceCloseRule = CTestEglSession::EResourceCloseSgImageEarly;
   1.502 +                        break;
   1.503 +                    case 2:
   1.504 +                        VERBOSE_INFO_PRINTF1(_L("Close Sg Driver and Image Early"));
   1.505 +                        resourceCloseRule = CTestEglSession::EResourceCloseSgDriverAndImageEarly;
   1.506 +                        break;
   1.507 +                    default:
   1.508 +                        break;
   1.509 +                        }
   1.510 +                
   1.511 +                    if (KSgPixmapUsageSupport[j] & ESgUsageBitOpenVgSurface)
   1.512 +                        {
   1.513 +                        VERBOSE_INFO_PRINTF1(_L("...is OpenVG renderable"));
   1.514 +                        eglSess->TryUsePixmapRSgImageOpenVgL(configs[index], imageInfo, resourceCloseRule); // we can't fail to create an image as we have already tried it 
   1.515 +                        }
   1.516 +                    if (KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGlesTexture2D))
   1.517 +                        {
   1.518 +                        VERBOSE_INFO_PRINTF1(_L("...is OpenGLES renderable"));
   1.519 +                        eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 1); // we can't fail to create an image as we have already tried it
   1.520 +                        }
   1.521 +                    if (KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGles2Surface | ESgUsageBitOpenGles2Texture2D))
   1.522 +                        {
   1.523 +                        VERBOSE_INFO_PRINTF1(_L("...is OpenGLES2 renderable"));
   1.524 +                        eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 2); // we can't fail to create an image as we have already tried it
   1.525 +                        }
   1.526 +                    }//for(TInt closeRule; closeRule < numCloseRules; closeRule++)
   1.527 +                }//for(TInt index = 0; index < numConfigs; index++)
   1.528 +            }//for(TUint32 j = 0; j < numUsageCombinations; j++)
   1.529 +        }//for(TInt i = 0; i < numSgImagePixelFormatSupport; i++)
   1.530 +#else
   1.531 +    const EGLint KSgPixmapUsageSupport[] =
   1.532 +        {
   1.533 +        ESgUsageOpenVgTarget,         
   1.534 +        ESgUsageOpenVgImage | ESgUsageOpenVgTarget,
   1.535 +        ESgUsageOpenVgTarget | ESgUsageOpenGles2Texture2D,
   1.536 +        ESgUsageOpenVgTarget | ESgUsageOpenVgImage| ESgUsageOpenGles2Texture2D,
   1.537 +        ESgUsageOpenGles2Target,
   1.538 +        ESgUsageOpenGles2Target | ESgUsageOpenVgImage,
   1.539 +        ESgUsageOpenGles2Texture2D |ESgUsageOpenGles2Target,
   1.540 +        ESgUsageOpenVgImage | ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target
   1.541 +        };
   1.542 +
   1.543 +    for(TInt i = 0; i < numPixmapSgSurfaceFormats; i++)
   1.544 +        {
   1.545 +        VGImageFormat surfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
   1.546 +        TSgImageInfoTest imageInfo = TSgImageInfoTest();
   1.547 +        imageInfo.iPixelFormat = EglTestConversion::VgFormatToSgPixelFormat(surfaceFormat);;
   1.548 +        EGLint alphaPreBit = (imageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) ? EGL_VG_ALPHA_FORMAT_PRE_BIT : 0;
   1.549 +        TInt numUsageCombinations = sizeof(KSgPixmapUsageSupport) / sizeof(KSgPixmapUsageSupport[0]);
   1.550 +        for(TUint32 j = 0; j < numUsageCombinations; j++)
   1.551 +            {
   1.552 +            if(KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target))
   1.553 +                {
   1.554 +                if(!eglSess->IsOpenGLES2Supported())
   1.555 +                    continue;
   1.556 +                }
   1.557 +            if(KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGlesTarget))
   1.558 +                {
   1.559 +                if(!eglSess->IsOpenGLESSupported())
   1.560 +                    continue;
   1.561 +                }
   1.562 +            imageInfo.iUsage = KSgPixmapUsageSupport[j]; 
   1.563 +            RSgImage image;
   1.564 +            ASSERT_EQUALS(image.Create(imageInfo, NULL, NULL), KErrNone);
   1.565 +            CleanupClosePushL(image);
   1.566 +            TSgImageInfoTest imageInfoSupported; 
   1.567 +            ASSERT_EQUALS(image.GetInfo(imageInfoSupported), KErrNone);//returned info may include more usage bits than we actually requested
   1.568 +            if(((imageInfoSupported.iUsage & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target)) && 
   1.569 +                               (!eglSess->IsOpenGLES2Supported()) ||
   1.570 +                ((imageInfoSupported.iUsage & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGlesTarget)) && 
   1.571 +                               (!eglSess->IsOpenGLESSupported()))))
   1.572 +                {
   1.573 +                CleanupStack::PopAndDestroy(&image);
   1.574 +                continue;
   1.575 +                }   
   1.576 +            
   1.577 +            EGLint eglRenderableTypeValue = 0;
   1.578 +            if(imageInfoSupported.iUsage & ESgUsageOpenVgTarget)
   1.579 +                {
   1.580 +                eglRenderableTypeValue = EGL_OPENVG_BIT;
   1.581 +                }
   1.582 +            else if(imageInfoSupported.iUsage & ESgUsageOpenGles2Target)
   1.583 +                {
   1.584 +                eglRenderableTypeValue = EGL_OPENGL_ES2_BIT;
   1.585 +                }
   1.586 +            else if(imageInfoSupported.iUsage & ESgUsageOpenGlesTarget)
   1.587 +                {
   1.588 +                eglRenderableTypeValue = EGL_OPENGL_ES_BIT;
   1.589 +                }
   1.590 +            TEST(eglRenderableTypeValue != 0);
   1.591 +            
   1.592 +            // only minimum amount of renderable type matching to Native pixmap will be passed into attribute list.
   1.593 +            // And egl will decide whatever configs include at least given renderable type.
   1.594 +            const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&image),
   1.595 +                                            EGL_RENDERABLE_TYPE, eglRenderableTypeValue,
   1.596 +                                            EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | alphaPreBit,
   1.597 +                                            EGL_NONE };     
   1.598 +            
   1.599 +            EGLConfig configs[KMaxEglConfigs];
   1.600 +            EGLint numConfigs=0;
   1.601 +            ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs, KMaxEglConfigs,&numConfigs));
   1.602 +            CleanupStack::PopAndDestroy(&image);
   1.603 +            TEST(numConfigs > 0);
   1.604 +            
   1.605 +            for(TInt index = 0; index < numConfigs; index++)
   1.606 +                {
   1.607 +                const TInt numCloseRules = 3; 
   1.608 +                for(TInt closeRule = 0; closeRule < numCloseRules; closeRule++)
   1.609 +                    {
   1.610 +                    CTestEglSession::TResourceCloseRule resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   1.611 +                    switch(closeRule)
   1.612 +                        {
   1.613 +                    case 0:
   1.614 +                        VERBOSE_INFO_PRINTF1(_L("Close Image Late"));
   1.615 +                        resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
   1.616 +                        break;
   1.617 +                    case 1:
   1.618 +                        VERBOSE_INFO_PRINTF1(_L("Close Image Early"));
   1.619 +                        resourceCloseRule = CTestEglSession::EResourceCloseSgImageEarly;
   1.620 +                        break;
   1.621 +                    case 2:
   1.622 +                        VERBOSE_INFO_PRINTF1(_L("Close Sg Driver and Image Early"));
   1.623 +                        resourceCloseRule = CTestEglSession::EResourceCloseSgDriverAndImageEarly;
   1.624 +                        break;
   1.625 +                    default:
   1.626 +                        break;
   1.627 +                        }
   1.628 +                
   1.629 +                    if (KSgPixmapUsageSupport[j] & ESgUsageOpenVgTarget)
   1.630 +                        {
   1.631 +                        VERBOSE_INFO_PRINTF1(_L("...is OpenVG renderable"));
   1.632 +                        eglSess->TryUsePixmapRSgImageOpenVgL(configs[index], imageInfo, resourceCloseRule); // we can't fail to create an image as we have already tried it 
   1.633 +                        }
   1.634 +                    if (KSgPixmapUsageSupport[j] & (ESgUsageOpenGlesTarget | ESgUsageOpenGles2Texture2D))
   1.635 +                        {
   1.636 +                        VERBOSE_INFO_PRINTF1(_L("...is OpenGLES renderable"));
   1.637 +                        eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 1); // we can't fail to create an image as we have already tried it
   1.638 +                        }
   1.639 +                    if (KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Target | ESgUsageOpenGles2Texture2D))
   1.640 +                        {
   1.641 +                        VERBOSE_INFO_PRINTF1(_L("...is OpenGLES2 renderable"));
   1.642 +                        eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 2); // we can't fail to create an image as we have already tried it
   1.643 +                        }
   1.644 +                    }//for(TInt closeRule; closeRule < numCloseRules; closeRule++)
   1.645 +                }//for(TInt index = 0; index < numConfigs; index++)
   1.646 +            }//for(TUint32 j = 0; j < numUsageCombinations; j++)
   1.647 +        }//for(TInt i = 0; i < numSgImagePixelFormatSupport; i++)
   1.648 +    
   1.649 + #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   1.650 +    
   1.651 +    CleanupStack::PopAndDestroy(2, eglSess);//iniParser, eglSess
   1.652 +    TerminateDisplayL();
   1.653 +    RecordTestResultL();
   1.654 +    CloseTMSGraphicsStep();
   1.655 +    return TestStepResult();
   1.656 +    }