egl/egltest/src/egltest_sibling.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 <test/tefunit.h> // for ASSERT macros
       
    22 #include "egltest_sibling.h"
       
    23 
       
    24 #include <test/egltestcommonconversion.h>
       
    25 #include <test/egltestcommonsgimageinfo.h>
       
    26 
       
    27 /**
       
    28 @SYMTestCaseID GRAPHICS-EGL-0135
       
    29 
       
    30 @SYMTestPriority 1
       
    31 
       
    32 @SYMPREQ 39
       
    33 
       
    34 @SYMREQ See SGL.GT0386.401 document
       
    35 
       
    36 @SYMTestCaseDesc
       
    37 Calling CreatePBufferFromClient with VGImage which is a EGLImage sibilind has to fail.
       
    38 On the contrary if the VGImage comes from a vgCreateImage() call it has to succeed
       
    39 
       
    40 @SYMTestActions
       
    41 Create and fully construct an RSgImage object
       
    42 Pass the RSgImage object into eglCreateImageKHR() with
       
    43 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
    44 •	Use the current display and EGL_NO_CONTEXT
       
    45 •	Use a NULL attr_list
       
    46 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR 
       
    47 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
       
    48 •	Check for errors
       
    49 Call eglCreatePBufferFromClient passing this VGImage as argument and EGL OPENVG IMAGE as bufftype and a NULL attribute list
       
    50 Check that we get EGL NO SURFACE and an EGL BAD ACCESS error is generated.
       
    51 Destroy the image data
       
    52 •	Pass the EGLImage into eglDestroyImageKHR()
       
    53 •	Close RSgImage
       
    54 Create a VGImage by calling vgCreateImage().
       
    55 Pass this VGImage to eglCreatePBufferFromClient, this call is expected to succeed.
       
    56 Pass the VGImage to vgDestroyImage()
       
    57 Check for memory and handle leaks
       
    58 
       
    59 @SYMTestExpectedResults
       
    60 vgCreatePBufferFromClient () returns EGL NO SURFACE
       
    61 •	EGL BAD ACCESS error is generated in the first case
       
    62 •	No error is raised in the second case..
       
    63 No memory or handle leaks.
       
    64 */
       
    65 TVerdict CEglTest_EGL_Image_CreatePBufferFromClient_With_Sibling_VGImage::doTestStepL()
       
    66 	{
       
    67 	SetTestStepID(_L("GRAPHICS-EGL-0135"));
       
    68 	INFO_PRINTF1(_L("CEglTest_CreatePBufferFromClient_With_Sibling_VGImage::doTestStepL"));
       
    69 
       
    70 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
    71 	if(!ret)
       
    72 		{
       
    73 		// The extension is not supported
       
    74 		RecordTestResultL();
       
    75 		CloseTMSGraphicsStep();
       
    76 		return TestStepResult();
       
    77 		}
       
    78 
       
    79 	// This test is performed for default pixel format
       
    80 	PrintUsedPixelConfiguration();
       
    81 
       
    82 	// Create display object
       
    83 	GetDisplayL();
       
    84 	CreateEglSessionL();
       
    85 	iEglSess->InitializeL();
       
    86 	iEglSess->OpenSgDriverL();
       
    87 
       
    88 	RSgImage sgImage;
       
    89 	CleanupClosePushL(sgImage);
       
    90 
       
    91 	// Create a reference bitmap which we use to init the SgImage (we use index=8)
       
    92 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
       
    93 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
       
    94 	CleanupStack::PushL(bitmap);
       
    95 	
       
    96 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
    97 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
    98 	ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
       
    99 	CleanupStack::PopAndDestroy(bitmap);
       
   100 
       
   101 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   102 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   103 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   104 	CleanupStack::PopAndDestroy(&sgImage);
       
   105 	
       
   106 	//Create a Surface and Link it to a Context bound to OpenVG
       
   107 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
       
   108 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
       
   109 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
       
   110 
       
   111 	INFO_PRINTF1(_L("Creating one VGImage from it"));
       
   112 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   113 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
       
   114 
       
   115 	INFO_PRINTF1(_L("Attempt to Create a PBuffer linked to this VGImage"));
       
   116 	TEglTestConfig pbufferFormat = EglTestConversion::VgFormatToPBufferSurfaceFormat(iSurfaceFormat);
       
   117 	EGLConfig currentPbufferConfig = 0;
       
   118 	TRAPD(res, currentPbufferConfig=iEglSess->GetConfigExactMatchL(pbufferFormat));
       
   119 	if(res == KTestNoMatchingConfig)
       
   120 	    {
       
   121 		WARN_PRINTF2(_L("Can't create pbuffer, format %d. Terminating the test without failing"), pbufferFormat);
       
   122 		// destroy eglimage and vgimage
       
   123 		vgDestroyImage(vgImage);
       
   124 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   125 		ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
       
   126 		CleanAll();
       
   127 		RecordTestResultL();
       
   128 		CloseTMSGraphicsStep();
       
   129 		return TestStepResult();
       
   130 	    }
       
   131 	User::LeaveIfError(res); // leave here if any other error was raised other than the one above.
       
   132 	EGLSurface surface = eglCreatePbufferFromClientBuffer(iDisplay,EGL_OPENVG_IMAGE,vgImage,currentPbufferConfig,NULL);
       
   133 	ASSERT_EGL_TRUE(surface == EGL_NO_SURFACE);
       
   134 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   135 
       
   136 	// destroy eglimage and vgimage
       
   137 	vgDestroyImage(vgImage);
       
   138 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   139 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
       
   140 	
       
   141 	//Positive test
       
   142 	INFO_PRINTF1(_L("Attempt to Create a PBuffer linked to a VGImage obtained from vgCreateImage"));
       
   143 	VGImage vgImage2 = vgCreateImage(KDefaultSurfaceFormat,KPixmapSize.iWidth,KPixmapSize.iHeight,VG_IMAGE_QUALITY_BETTER);
       
   144 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   145 	surface = eglCreatePbufferFromClientBuffer(iDisplay,EGL_OPENVG_IMAGE,vgImage2,currentPbufferConfig,NULL);
       
   146 	ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
       
   147 	ASSERT_EGL_ERROR(EGL_SUCCESS);
       
   148 	ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
       
   149 
       
   150 	//cleanup
       
   151 	vgDestroyImage(vgImage2);
       
   152 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   153 	CleanAll();
       
   154 
       
   155 	RecordTestResultL();
       
   156 	CloseTMSGraphicsStep();
       
   157 	return TestStepResult();
       
   158 	}
       
   159 
       
   160 /**
       
   161 @SYMTestCaseID GRAPHICS-EGL-0136
       
   162 
       
   163 @SYMTestPriority 1
       
   164 
       
   165 @SYMPREQ 39
       
   166 
       
   167 @SYMREQ See SGL.GT0386.401 document
       
   168 
       
   169 @SYMTestCaseDesc
       
   170 Attempt to create an EGLImage out of a valid RSgImage that is already linked to another EGLImage has to fail.
       
   171 Destroy the EGLImage, then re-create an EGLImage from the same RSgImage, and this attempt is expected to succeed. 
       
   172 
       
   173 @SYMTestActions
       
   174 Create a reference Bitmap
       
   175 Create and fully construct an RSgImage object having the same content as the reference bitmap 
       
   176 •	Set the iUsage bit to ESgUsageBitOpenVgImage
       
   177 Pass the RSgImage object into eglCreateImageKHR() with
       
   178 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   179 •	Use the current display and EGL_NO_CONTEXT
       
   180 •	Use a NULL attr_list
       
   181 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
       
   182 Pass again the same RSgImage object into eglCreateImageKHR() with
       
   183 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   184 •	Use the current display and EGL_NO_CONTEXT
       
   185 •	Use a NULL attr_list
       
   186 Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
       
   187 Pass the EGLImage into eglDestroyImageKHR()
       
   188 Pass again the same RSgImage object into eglCreateImageKHR() with
       
   189 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   190 •	Use the current display and EGL_NO_CONTEXT
       
   191 •	Use a NULL attr_list
       
   192 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
       
   193 Destroy the image data
       
   194 •	Pass the EGLImage into eglDestroyImageKHR()
       
   195 •	Close RSgImage
       
   196 Check for memory and handle leaks
       
   197 
       
   198 @SYMTestExpectedResults
       
   199 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR (and an EGL_BAD_ACCESS error is generated) when the first EGLImage
       
   200 has not yet been destroyed. Once it is destroyed, creating aother EGLImage succeeds.
       
   201 No memory or handle leaks
       
   202 */
       
   203 TVerdict CEglTest_EGL_Image_Sibling_Basic::doTestStepL()
       
   204 	{
       
   205 	SetTestStepID(_L("GRAPHICS-EGL-0136"));
       
   206 	INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_Basic::doTestStepL"));
       
   207 
       
   208 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
   209 	if(!ret)
       
   210 		{
       
   211 		// The extension is not supported
       
   212 		RecordTestResultL();
       
   213 		CloseTMSGraphicsStep();
       
   214 		return TestStepResult();
       
   215 		}
       
   216 
       
   217 	// This test is performed for default pixel format
       
   218 	PrintUsedPixelConfiguration();
       
   219 
       
   220 	// Create display object
       
   221 	GetDisplayL();
       
   222 	CreateEglSessionL();
       
   223 	iEglSess->InitializeL();
       
   224 	iEglSess->OpenSgDriverL();
       
   225 
       
   226 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
   227 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
   228 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   229 	imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
       
   230 #endif	
       
   231 	RSgImage sgImage;
       
   232 	CleanupClosePushL(sgImage);
       
   233 	ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
       
   234 
       
   235 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   236 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   237 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   238 	
       
   239 	INFO_PRINTF1(_L("Trying to create another EGLImage from the same RSgImage"));
       
   240 	EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   241 	ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
       
   242 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   243 	
       
   244 	INFO_PRINTF1(_L("Destroy first EGLImage and try to create another EGLImage from the same RSgImage"));
       
   245 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));		
       
   246 	EGLImageKHR imageKHR3 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   247 	ASSERT_EGL_TRUE(imageKHR3 != EGL_NO_IMAGE_KHR);
       
   248 	ASSERT_EGL_ERROR(EGL_SUCCESS);
       
   249 
       
   250 	//cleanup
       
   251 	CleanupStack::PopAndDestroy(&sgImage);
       
   252 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR3));		
       
   253 	CleanAll();
       
   254 
       
   255 	RecordTestResultL();
       
   256 	CloseTMSGraphicsStep();
       
   257 	return TestStepResult();
       
   258 	}
       
   259 
       
   260 /**
       
   261 @SYMTestCaseID GRAPHICS-EGL-0138
       
   262 
       
   263 @SYMTestPriority 1
       
   264 
       
   265 @SYMPREQ 39
       
   266 
       
   267 @SYMREQ See SGL.GT0386.401 document
       
   268 
       
   269 @SYMTestCaseDesc
       
   270 Attempt to create an EGLImage out of a valid RSgImage that is already linked to another VGImage (after the original EGLImage has been destroyed) has to fail.
       
   271 This is testing the EGLImage sibling rules from the EGLImage spec.
       
   272 
       
   273 @SYMTestActions
       
   274 This test will check for the “VG_KHR_EGL_image” extension, if it is not supported on this platform then the test will return immediately without failure.
       
   275 Create a reference Bitmap
       
   276 Create and fully construct an RSgImage object having the same content as the reference bitmap 
       
   277 •	Set the iUsage bit to ESgUsageBitOpenVgImage
       
   278 Pass the RSgImage object into eglCreateImageKHR() with
       
   279 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   280 •	Use the current display and EGL_NO_CONTEXT
       
   281 •	Use a NULL attr_list
       
   282 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
       
   283 Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
       
   284 •	Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface.
       
   285 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
       
   286 •	Check for errors
       
   287 Pass the EGLImage into eglDestroyImageKHR()
       
   288 Pass again the same RSgImage object into eglCreateImageKHR() with
       
   289 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   290 •	Use the current display and EGL_NO_CONTEXT
       
   291 •	Use a NULL attr_list
       
   292 Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
       
   293 Pass the VGImage into vgDestroyImage()
       
   294 Close RSgImage
       
   295 Check for memory and handle leaks
       
   296 
       
   297 @SYMTestExpectedResults
       
   298 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR 
       
   299 •	And an EGL_BAD_ACCESS error is generated
       
   300 No memory or handle leaks.
       
   301 */
       
   302 TVerdict CEglTest_EGL_Image_Sibling_VGImage::doTestStepL()
       
   303 	{
       
   304 	SetTestStepID(_L("GRAPHICS-EGL-0138"));
       
   305 	INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage::doTestStepL"));
       
   306 
       
   307 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
   308 	if(!ret)
       
   309 		{
       
   310 		// The extension is not supported
       
   311 		RecordTestResultL();
       
   312 		CloseTMSGraphicsStep();
       
   313 		return TestStepResult();
       
   314 		}
       
   315 
       
   316 	// This test is performed for default pixel format
       
   317 	PrintUsedPixelConfiguration();
       
   318 
       
   319 	// Create display object
       
   320 	GetDisplayL();
       
   321 	CreateEglSessionL();
       
   322 	iEglSess->InitializeL();
       
   323 	iEglSess->OpenSgDriverL();
       
   324 
       
   325 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
   326 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
   327 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   328 	imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
       
   329 #endif	
       
   330 	RSgImage sgImage;
       
   331 	CleanupClosePushL(sgImage);
       
   332 	ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
       
   333 
       
   334 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   335 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   336 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   337 
       
   338 	//Create a Surface and Link it to a Context bound to OpenVG
       
   339 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
       
   340 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
       
   341 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
       
   342 
       
   343 	INFO_PRINTF1(_L("Creating one VGImage from it"));
       
   344 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   345 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
       
   346 	
       
   347 	INFO_PRINTF1(_L("Destroying the EGLImage but retain the handle value"));
       
   348 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));		
       
   349 	
       
   350 	INFO_PRINTF1(_L("Attemptimg to create another VGImage from an invalid handle"));
       
   351 	VGImage failingVgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);	
       
   352 	ASSERT_VG_TRUE(failingVgImage == VG_INVALID_HANDLE);
       
   353 	ASSERT_TRUE(vgGetError()==VG_ILLEGAL_ARGUMENT_ERROR);
       
   354 
       
   355 	INFO_PRINTF1(_L("Setting the handle to EGL_NO_IMAGE_KHR"));
       
   356 	imageKHR = EGL_NO_IMAGE_KHR;
       
   357 
       
   358 	INFO_PRINTF1(_L("Trying to create another EGLImage from the same RSgImage"));
       
   359 	EGLImageKHR imageKHR2 = GetEglSess()->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   360 	ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
       
   361 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   362 
       
   363 	//cleanup
       
   364 	CleanupStack::PopAndDestroy(&sgImage);
       
   365 	vgDestroyImage(vgImage);
       
   366 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   367 	CleanAll();
       
   368 
       
   369 	RecordTestResultL();
       
   370 	CloseTMSGraphicsStep();
       
   371 	return TestStepResult();
       
   372 	}
       
   373 
       
   374 /**
       
   375 @SYMTestCaseID GRAPHICS-EGL-0139
       
   376 
       
   377 @SYMTestPriority 1
       
   378 
       
   379 @SYMPREQ 39
       
   380 
       
   381 @SYMREQ See SGL.GT0386.401 document
       
   382 
       
   383 @SYMTestCaseDesc
       
   384 Attempt to create an EGLImage out of a valid RSgImage that is already linked 
       
   385 to two VGImages (after the original EGLImage has been destroyed) has to fail.
       
   386 This is testing the EGLImage sibling rules from the EGLImage spec.
       
   387 
       
   388 @SYMTestActions
       
   389 This test will check for the “VG_KHR_EGL_image” extension, if it is not supported 
       
   390 on this platform then the test will return immediately without failure.
       
   391 Create a reference Bitmap
       
   392 Create and fully construct an RSgImage object having the same content as the 
       
   393 reference bitmap 
       
   394 •	Set the iUsage bit to ESgUsageBitOpenVgImage
       
   395 Pass the RSgImage object into eglCreateImageKHR() with
       
   396 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   397 •	Use the current display and EGL_NO_CONTEXT
       
   398 •	Use a NULL attr_list
       
   399 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
       
   400 Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
       
   401 •	Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface 
       
   402 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
       
   403 •	Check for errors
       
   404 Use vgCreateEGLImageTargetKHR() to construct another VGImage object from the EGLImage.
       
   405 •	Check for errors
       
   406 Pass the EGLImage into eglDestroyImageKHR()
       
   407 Pass again the same RSgImage object into eglCreateImageKHR() with
       
   408 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   409 •	Use the current display and EGL_NO_CONTEXT
       
   410 •	Use a NULL attr_list
       
   411 Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
       
   412 Pass the first VGImage into vgDestroyImage()
       
   413 Pass the second VGImage into vgDestroyImage()
       
   414 Close RSgImage
       
   415 Check for memory and handle leaks.
       
   416 
       
   417 @SYMTestExpectedResults
       
   418 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
       
   419 •	And an EGL_BAD_ACCESS error is generated
       
   420 No memory or handle leaks.
       
   421 */
       
   422 TVerdict CEglTest_EGL_Image_Sibling_Two_VGImages::doTestStepL()
       
   423 	{
       
   424 	SetTestStepID(_L("GRAPHICS-EGL-0139"));
       
   425 	INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_Two_VGImages::doTestStepL"));
       
   426 
       
   427 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
   428 	if(!ret)
       
   429 		{
       
   430 		// The extension is not supported
       
   431 		RecordTestResultL();
       
   432 		CloseTMSGraphicsStep();
       
   433 		return TestStepResult();
       
   434 		}
       
   435 
       
   436 	// This test is performed for default pixel format
       
   437 	PrintUsedPixelConfiguration();
       
   438 
       
   439 	// Create display object
       
   440 	GetDisplayL();
       
   441 	CreateEglSessionL();
       
   442 	iEglSess->InitializeL();
       
   443 	iEglSess->OpenSgDriverL();
       
   444 
       
   445 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
   446 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
   447 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   448 	imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
       
   449 #endif	
       
   450 	RSgImage sgImage;
       
   451 	CleanupClosePushL(sgImage);
       
   452 	ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
       
   453 
       
   454 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   455 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   456 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   457 
       
   458 	//Create a Surface and Link it to a Context bound to OpenVG
       
   459 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
       
   460 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
       
   461 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
       
   462 
       
   463 	INFO_PRINTF1(_L("Creating two VGImages from it"));
       
   464 	VGImage vgImage1 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   465 	ASSERT_VG_TRUE(vgImage1 != VG_INVALID_HANDLE);
       
   466 	VGImage vgImage2 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   467 	ASSERT_VG_TRUE(vgImage2 != VG_INVALID_HANDLE);
       
   468 	
       
   469 	INFO_PRINTF1(_L("Destroying the EGLImage"));
       
   470 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));		
       
   471 
       
   472 	INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked to the two VGImages)"));
       
   473 	EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   474 	ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
       
   475 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   476 
       
   477 	INFO_PRINTF1(_L("Destroying the first VgImage"));
       
   478 	vgDestroyImage(vgImage1);
       
   479 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   480 	
       
   481 	INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked now to just one VGImage)"));
       
   482 	imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   483 	ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
       
   484 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   485 
       
   486 	INFO_PRINTF1(_L("Destroying the second VgImage"));
       
   487 	vgDestroyImage(vgImage2);
       
   488 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   489 
       
   490 	INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked now to just one VGImage)"));
       
   491 	imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   492 	ASSERT_EGL_TRUE(imageKHR2 != EGL_NO_IMAGE_KHR);
       
   493 	ASSERT_EGL_ERROR(EGL_SUCCESS);
       
   494 
       
   495 	//cleanup
       
   496 	CleanupStack::PopAndDestroy(&sgImage);
       
   497 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));		
       
   498 	CleanAll();
       
   499 
       
   500 	RecordTestResultL();
       
   501 	CloseTMSGraphicsStep();
       
   502 	return TestStepResult();
       
   503 	}
       
   504 
       
   505 /**
       
   506 @SYMTestCaseID GRAPHICS-EGL-0141
       
   507 
       
   508 @SYMTestPriority 1
       
   509 
       
   510 @SYMPREQ 39
       
   511 
       
   512 @SYMREQ See SGL.GT0386.401 document
       
   513 
       
   514 @SYMTestCaseDesc
       
   515 Attempt to create an EGLImage out of a valid RSgImage after that:
       
   516 •	It has been created a VGImage from it (hence an EGLImage has been created too)
       
   517 •	A Child VGImage has been created from the previous VGImage
       
   518 •	the EGLImage has been destroyed too
       
   519 has to fail
       
   520 Another attempt to create an EGLImage from the same RSgImage has to fail even if we destroy the parent Image.
       
   521 Creation of an EGLImage from the same RSgImage has to succeed if the child VgImage has also been destroyed.
       
   522 
       
   523 @SYMTestActions
       
   524 This test will check for the “VG_KHR_EGL_image” extension, if it is not supported on this platform then the test will return immediately without failure.
       
   525 Create a reference Bitmap
       
   526 Create and fully construct an RSgImage object having the same content as the reference bitmap 
       
   527 •	Set the iUsage bit to ESgUsageBitOpenVgImage
       
   528 Pass the RSgImage object into eglCreateImageKHR() with
       
   529 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   530 •	Use the current display and EGL_NO_CONTEXT
       
   531 •	Use a NULL attr_list
       
   532 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
       
   533 Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
       
   534 •	Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface 
       
   535 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
       
   536 •	Check for errors
       
   537 Use vgChildImage() to construct child VGImage object from the previous VGImage.
       
   538 •	Check for errors
       
   539 Pass the EGLImage into eglDestroyImageKHR()
       
   540 Pass again the same RSgImage object into eglCreateImageKHR().
       
   541 Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
       
   542 Pass the parent VGImage into vgDestroyImage()
       
   543 Pass again the same RSgImage object into eglCreateImageKHR().
       
   544 Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
       
   545 Pass the child VGImage into vgDestroyImage()
       
   546 Pass again the same RSgImage object into eglCreateImageKHR().
       
   547 Check that eglCreateImageKHR() does not return EGL_NO_IMAGE_KHR.
       
   548 Pass the EGLImage into eglDestroyImageKHR()
       
   549 Close RSgImage
       
   550 Check for memory and handle leaks.
       
   551 
       
   552 @SYMTestExpectedResults
       
   553 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR 
       
   554 •	And an EGL_BAD_ACCESS error is generated
       
   555 No memory or handle leaks.
       
   556 */
       
   557 TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child::doTestStepL()
       
   558 	{
       
   559 	SetTestStepID(_L("GRAPHICS-EGL-0141"));
       
   560 	INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child::doTestStepL"));
       
   561 
       
   562 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
   563 	if(!ret)
       
   564 		{
       
   565 		// The extension is not supported
       
   566 		RecordTestResultL();
       
   567 		CloseTMSGraphicsStep();
       
   568 		return TestStepResult();
       
   569 		}
       
   570 
       
   571 	// This test is performed for default pixel format
       
   572 	PrintUsedPixelConfiguration();
       
   573 
       
   574 	// Create display object
       
   575 	GetDisplayL();
       
   576 	CreateEglSessionL();
       
   577 	iEglSess->InitializeL();
       
   578 	iEglSess->OpenSgDriverL();
       
   579 
       
   580 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
   581 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
   582 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
   583 	imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
       
   584 #endif	
       
   585 	RSgImage sgImage;
       
   586 	CleanupClosePushL(sgImage);
       
   587 	ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
       
   588 
       
   589 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   590 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   591 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   592 
       
   593 	//Create a Surface and Link it to a Context bound to OpenVG
       
   594 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
       
   595 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
       
   596 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
       
   597 
       
   598 	INFO_PRINTF1(_L("Creating one VGImage from it"));
       
   599 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   600 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
       
   601 	
       
   602 	INFO_PRINTF1(_L("Creating a VGImage Child from the previous VGImage"));
       
   603 	VGImage childVgImage = vgChildImage(vgImage,50,50,KPixmapSize.iWidth-50,KPixmapSize.iHeight-50);
       
   604 	ASSERT_EGL_TRUE(childVgImage != VG_INVALID_HANDLE);
       
   605 
       
   606 	INFO_PRINTF1(_L("Destroying the EGLImage"));
       
   607 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));		
       
   608 	
       
   609 	INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked to both Parent and Child VGImage)"));
       
   610 	EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   611 	ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
       
   612 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   613 
       
   614 	INFO_PRINTF1(_L("Destroying the Parent VGImage"));
       
   615 	vgDestroyImage(vgImage);
       
   616 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   617 
       
   618 	INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked to the Child VGImage)"));
       
   619 	imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   620 	ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
       
   621 	ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
       
   622 	
       
   623 	INFO_PRINTF1(_L("Destroying the Child VGImage"));
       
   624 	vgDestroyImage(childVgImage);
       
   625 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   626 
       
   627 	INFO_PRINTF1(_L("Trying to create an EGLImage and a new VGImage from the same RSgImage (now it's free)"));
       
   628 	imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
       
   629 	ASSERT_EGL_TRUE(imageKHR2 != EGL_NO_IMAGE_KHR);
       
   630 	ASSERT_EGL_ERROR(EGL_SUCCESS);
       
   631 
       
   632 	//cleanup
       
   633 	CleanupStack::PopAndDestroy(&sgImage);
       
   634 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));		
       
   635 	CleanAll();
       
   636 
       
   637 	RecordTestResultL();
       
   638 	CloseTMSGraphicsStep();
       
   639 	return TestStepResult();
       
   640 	}
       
   641 
       
   642 
       
   643 /**
       
   644 @SYMTestCaseID GRAPHICS-EGL-0142
       
   645 
       
   646 @SYMTestPriority 1
       
   647 
       
   648 @SYMPREQ 39
       
   649 
       
   650 @SYMREQ See SGL.GT0386.401 document
       
   651 
       
   652 @SYMTestCaseDesc
       
   653 Ensure that the when using a child VGImage contents of the RSgImage are preserved even if the parent VGImage and the EGLImage have been destroyed.
       
   654 
       
   655 @SYMTestActions
       
   656 This test will check for the “VG_KHR_EGL_image” extension, if it is not supported on this platform then the test will return immediately without failure.
       
   657 Create a reference Bitmap
       
   658 Create and fully construct an RSgImage object having the same content as the reference bitmap 
       
   659 •	Set the iUsage bit to ESgUsageBitOpenVgImage
       
   660 Pass the RSgImage object into eglCreateImageKHR() with
       
   661 •	The target parameter set to EGL_NATIVE_PIXMAP_KHR
       
   662 •	Use the current display and EGL_NO_CONTEXT
       
   663 •	Use a NULL attr_list
       
   664 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
       
   665 Create and make current and EGL context bound to OVG APIs and linked to a window surface.
       
   666 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
       
   667 •	Check for errors
       
   668 Use vgChildImage() to construct child VGImage object from the previous VGImage.
       
   669 •	Check for errors
       
   670 Pass the parent VGImage into vgDestroyImage()
       
   671 Pass the EGLImage into eglDestroyImageKHR()
       
   672 Use OpenVG APIs to draw the previous child VGImage to this surface.
       
   673 Check Contents.
       
   674 Pass the child VGImage into vgDestroyImage()
       
   675 Close RSgImage
       
   676 Check for memory and handle leaks.
       
   677 
       
   678 @SYMTestExpectedResults
       
   679 What is drawn to the surface is exactly what is expected to be inside the child VGImage.
       
   680 No memory or handle leaks.
       
   681 */
       
   682 TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL()
       
   683 	{	
       
   684 	INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL"));
       
   685 	SetTestStepID(_L("GRAPHICS-EGL-0142"));
       
   686 
       
   687 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
   688 	if(!ret)
       
   689 		{
       
   690 		// The extension is not supported
       
   691 		RecordTestResultL();
       
   692 		CloseTMSGraphicsStep();
       
   693 		return TestStepResult();
       
   694 		}
       
   695 
       
   696 	// This test is performed for default pixel format
       
   697 	PrintUsedPixelConfiguration();
       
   698 
       
   699 	// Create display object
       
   700 	GetDisplayL();
       
   701 	CreateEglSessionL();
       
   702 	iEglSess->InitializeL();
       
   703 	iEglSess->OpenSgDriverL();
       
   704 
       
   705 	RSgImage sgImage;
       
   706 	CleanupClosePushL(sgImage);
       
   707 
       
   708 	// Create a reference bitmap which we use to init the SgImage (we use index=8)
       
   709 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
       
   710 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
       
   711 	CleanupStack::PushL(bitmap);
       
   712 
       
   713 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
   714 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
   715 	ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
       
   716 	CleanupStack::PopAndDestroy(bitmap);
       
   717 	bitmap = NULL;
       
   718 
       
   719 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   720 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   721 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   722 
       
   723 	//Create a Surface and Link it to a Context bound to OpenVG
       
   724 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
       
   725 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
       
   726 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
       
   727 
       
   728 	INFO_PRINTF1(_L("Creating one VGImage from it"));
       
   729 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   730 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
       
   731 	
       
   732 	INFO_PRINTF1(_L("Creating a VGImage Child from the previous VGImage"));
       
   733 	VGImage childVgImage = vgChildImage(vgImage,0,0,KPixmapSize.iWidth,KPixmapSize.iHeight);
       
   734 	ASSERT_EGL_TRUE(childVgImage != VG_INVALID_HANDLE);
       
   735 
       
   736 	INFO_PRINTF1(_L("Destroying the RSgImage, the EGLImage, and the parent VGImage"));
       
   737 	CleanupStack::PopAndDestroy(&sgImage);								// closes RSgImage
       
   738 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));		// closes EGLImage
       
   739 	vgDestroyImage(vgImage);											// closes VGImage (parent)
       
   740 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   741 
       
   742 	INFO_PRINTF1(_L("Draw the child VGImage to the surface and check contents"));
       
   743 	vgSetPixels(0, 0, childVgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
       
   744 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   745 	eglWaitClient();
       
   746 	
       
   747 	// To check the contents we need to repopulate the reference bitmap (with same index used during init)
       
   748 	TDisplayMode refBitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
       
   749 	CFbsBitmap* refBitmap = iEglSess->CreateReferenceBitmapL(refBitmapMode, KPixmapSize, 8);
       
   750 	CleanupStack::PushL(refBitmap);
       
   751 	iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
       
   752 	CleanupStack::PopAndDestroy(refBitmap);
       
   753 	INFO_PRINTF1(_L("Content is as expected"));
       
   754 
       
   755 	//cleanup
       
   756 	vgDestroyImage(childVgImage);
       
   757 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   758 	CleanAll();
       
   759 	
       
   760 	RecordTestResultL();
       
   761 	CloseTMSGraphicsStep();
       
   762 	return TestStepResult();
       
   763 	}
       
   764 
       
   765 
       
   766 /**
       
   767 @SYMTestCaseID GRAPHICS-EGL-0143
       
   768 
       
   769 @SYMTestPriority 1
       
   770 
       
   771 @SYMPREQ 39
       
   772 
       
   773 @SYMREQ See SGL.GT0386.401 document
       
   774 
       
   775 @SYMTestCaseDesc
       
   776 Ensure that when using a child VGImage contents of the RSgImage are preserved even 
       
   777 if the parent VGImage, the EGLImage and the original RSgImage have been destroyed.
       
   778 This test that the link of references fron the child VGImage to the actual content is 
       
   779 valid even when it is the only reference left to the data.
       
   780 
       
   781 @SYMTestActions
       
   782 Perform the exact action described in GRAPHICS-EGL-0213 but close the RSgImage too.
       
   783 
       
   784 @SYMTestExpectedResults
       
   785 What is drawn to the surface is exactly what is expected to be inside the child VGImage.
       
   786 No memory or handle leaks.
       
   787 */
       
   788 TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents_CloseSgEarlier::doTestStepL()
       
   789 	{	
       
   790 	INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL"));
       
   791 	SetTestStepID(_L("GRAPHICS-EGL-0142"));
       
   792 
       
   793 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
       
   794 	if(!ret)
       
   795 		{
       
   796 		// The extension is not supported
       
   797 		RecordTestResultL();
       
   798 		CloseTMSGraphicsStep();
       
   799 		return TestStepResult();
       
   800 		}
       
   801 
       
   802 	// This test is performed for default pixel format
       
   803 	PrintUsedPixelConfiguration();
       
   804 
       
   805 	// Create display object
       
   806 	GetDisplayL();
       
   807 	CreateEglSessionL();
       
   808 	iEglSess->InitializeL();
       
   809 	iEglSess->OpenSgDriverL();
       
   810 
       
   811 	RSgImage sgImage;
       
   812 	CleanupClosePushL(sgImage);
       
   813 
       
   814 	// Create a reference bitmap which we use to init the SgImage (we use index=8)
       
   815 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
       
   816 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
       
   817 	CleanupStack::PushL(bitmap);
       
   818 
       
   819 	INFO_PRINTF1(_L("Creating one RSgImage"));	
       
   820 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
       
   821 	ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
       
   822 	CleanupStack::PopAndDestroy(bitmap);
       
   823 	bitmap = NULL;
       
   824 
       
   825 	INFO_PRINTF1(_L("Creating one EGLImage from it"));
       
   826 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
       
   827 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
       
   828 
       
   829 	//Close the SgDriver EGL Implemtation should have its own reference to it
       
   830 	CleanupStack::PopAndDestroy(&sgImage);								// closes RSgImage
       
   831 	iEglSess->CloseSgDriver();
       
   832 	
       
   833 	//Create a Surface and Link it to a Context bound to OpenVG
       
   834 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
       
   835 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
       
   836 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
       
   837 
       
   838 	INFO_PRINTF1(_L("Creating one VGImage from it"));
       
   839 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
       
   840 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
       
   841 	
       
   842 	INFO_PRINTF1(_L("Creating a VGImage Child from the previous VGImage"));
       
   843 	VGImage childVgImage = vgChildImage(vgImage,0,0,KPixmapSize.iWidth,KPixmapSize.iHeight);
       
   844 	ASSERT_EGL_TRUE(childVgImage != VG_INVALID_HANDLE);
       
   845 
       
   846 	INFO_PRINTF1(_L("Destroying the RSgImage, the EGLImage, and the parent VGImage"));
       
   847 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));		// closes EGLImage
       
   848 	vgDestroyImage(vgImage);											// closes VGImage (parent)
       
   849 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   850 
       
   851 	INFO_PRINTF1(_L("Draw the child VGImage to the surface and check contents"));
       
   852 	vgSetPixels(0, 0, childVgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
       
   853 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   854 	eglWaitClient();
       
   855 	
       
   856 	// To check the contents we need to repopulate the reference bitmap (with same index used during init)
       
   857 	TDisplayMode refBitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
       
   858 	CFbsBitmap* refBitmap = iEglSess->CreateReferenceBitmapL(refBitmapMode, KPixmapSize, 8);
       
   859 	CleanupStack::PushL(refBitmap);
       
   860 	iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
       
   861 	CleanupStack::PopAndDestroy(refBitmap);
       
   862 	INFO_PRINTF1(_L("Content is as expected"));
       
   863 
       
   864 	//cleanup
       
   865 	vgDestroyImage(childVgImage);
       
   866 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
       
   867 	CleanAll();
       
   868 	
       
   869 	RecordTestResultL();
       
   870 	CloseTMSGraphicsStep();
       
   871 	return TestStepResult();
       
   872 	}