os/graphics/egl/egltest/src/egltest_vgimagetosurfaces.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 <test/tefunit.h> // for ASSERT macros
    22 #include <iniparser.h>
    23 
    24 #include "egltest_vgimagetosurfaces.h"
    25 
    26 #include <test/egltestcommonsgimageinfo.h>
    27 #include <test/egltestcommonconversion.h>
    28 #include <test/egltestcommoninisettings.h>
    29 
    30 
    31 
    32 /**
    33 @SYMTestCaseID GRAPHICS-EGL-0170
    34 
    35 @SYMTestPriority 1
    36 
    37 @SYMPREQ 39
    38 
    39 @SYMREQ See SGL.GT0386.401 document
    40 
    41 @SYMTestCaseDesc
    42 Check that it is possible to draw a VGImage (created from an RSgImage) to a pBuffer Surface.
    43 
    44 @SYMTestActions
    45 Create a reference Bitmap
    46 Create and fully construct an RSgImage object having the same content as the reference bitmap 
    47 	Set the iUsage bit to ESgUsageBitOpenVgImage
    48 Create and make current and EGL context bound to OVG APIs and linked to a pBuffer surface.
    49 Pass the RSgImage object into eglCreateImageKHR() with
    50 	The target parameter set to EGL_NATIVE_PIXMAP_KHR
    51 	Use the current display and EGL_NO_CONTEXT
    52 	Use a NULL attr_list
    53 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
    54 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
    55 	Check for errors
    56 Use OpenVG to draw the just created VGImage to the pBuffer surface currently linked to the context.
    57 Call eglWaitClient() to finish the above drawing instructions synchronously.
    58 Destroy the original image data
    59 	Pass the VGImage into vgDestroyImage()
    60 	Pass the EGLImage into eglDestroyImageKHR()
    61 	Close the RSgImage 
    62 Check that the pBuffer surface matches the content from the reference bitmap.
    63 Destroy the pBuffer surface
    64 Check for memory and handle leaks
    65 
    66 @SYMTestExpectedResults
    67 pBuffer surface matches the content from the reference bitmap.
    68 The test will loop through all the possible PixelFormat available for source RSgImages and Destination Surfaces
    69 	EUidPixelFormatRGB_565
    70 	EUidPixelFormatXRGB_8888
    71 	EUidPixelFormatARGB_8888 (source only)
    72 	EUidPixelFormatARGB_8888_PRE
    73 	EUidPixelFormatA_8  (source only)
    74 */
    75 TVerdict CEglTest_EGL_Image_VgImage_To_pBuffer::doTestStepL()
    76 	{
    77 	SetTestStepID(_L("GRAPHICS-EGL-0170"));
    78 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
    79 	if(!ret)
    80 		{
    81 		// The extension is not supported
    82 		RecordTestResultL();
    83 		CloseTMSGraphicsStep();
    84 		return TestStepResult();
    85 		}
    86 
    87 	CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
    88 	CleanupStack::PushL(iniParser);
    89 
    90 	TInt numPBufferSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPBufferSurfaceFormats);
    91 	TInt numImageSourceFormats = iniParser->GetNumberOfFormats(KSectionImageSourceFormats);
    92 	if(!numImageSourceFormats && !numPBufferSurfaceFormats)
    93 		{
    94 		ERR_PRINTF1(_L("No formats to iterate through"));
    95 		User::Leave(KErrArgument);
    96 		}
    97 	for(TUint j=0; j < numPBufferSurfaceFormats; j++)
    98 		{
    99 		iSurfaceFormat = iniParser->GetVgFormat(KSectionPBufferSurfaceFormats,j);
   100 		for(TUint i=0; i < numImageSourceFormats; i++)
   101 			{
   102 			iSourceFormat = iniParser->GetPixelFormat(KSectionImageSourceFormats,i);
   103 			if (iSourceFormat == EUidPixelFormatARGB_8888 && (iSurfaceFormat == VG_sARGB_8888_PRE || iSurfaceFormat == VG_sARGB_8888))
   104 				{
   105 				// Don't perform the test for this particular format combination
   106 				//  Causes issues converting pixel values from non-pre to pre
   107 				continue;
   108 				}
   109 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   110 			// A_8 related tests are only performed for SgImage-Lite
   111 			if (iSourceFormat == EUidPixelFormatA_8)
   112 				continue;
   113 #endif	
   114 			doTestPartialStepL();
   115 			}
   116 		}
   117 
   118 	CleanupStack::PopAndDestroy(iniParser);
   119 	RecordTestResultL();
   120 	CloseTMSGraphicsStep();
   121 	return TestStepResult();
   122 	}
   123 
   124 TVerdict CEglTest_EGL_Image_VgImage_To_pBuffer::doTestPartialStepL()
   125 	{
   126 	INFO_PRINTF1(_L("CEglTest_EGL_Image_VgImage_To_pBuffer::doTestPartialStepL"));
   127 	PrintUsedPixelConfiguration();
   128 
   129 	// Create display object
   130 	GetDisplayL();
   131 	CreateEglSessionL();
   132 	iEglSess->InitializeL();
   133 	iEglSess->OpenSgDriverL();
   134 
   135 	// Create a reference bitmap which we use to init the SgImage (we use index=7)
   136 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
   137 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 7);
   138 	CleanupStack::PushL(bitmap);
   139 
   140 	INFO_PRINTF1(_L("Creating 1 RSgImage"));
   141 	RSgImage sgImage;
   142 	CleanupClosePushL(sgImage);
   143 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
   144 	TInt ret = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
   145 	ASSERT_EQUALS(ret, KErrNone);
   146 	
   147 	// If create pbuffer surface fails, don't fail if there's no matching config (but fail in any other situation):
   148     //		Support for a window surface is not mandated any pixel format
   149     //		We should not enforce it in the tests
   150     //		Silently terminate the test without failing.
   151 	TEglTestConfig pbufferFormat = EglTestConversion::VgFormatToPBufferSurfaceFormat(iSurfaceFormat);
   152 	EGLConfig currentConfig = 0;
   153 	TRAPD(res, currentConfig = iEglSess->GetConfigExactMatchL( pbufferFormat ));
   154 	if(res == KTestNoMatchingConfig)
   155 	    {
   156         INFO_PRINTF1(_L("Creation of pBuffer has failed, the test case for that configuration will be skipped"));
   157 		CleanupStack::PopAndDestroy(2, bitmap); // bitmap, sgimage
   158 		CleanAll();
   159 		RecordTestResultL();
   160 		CloseTMSGraphicsStep();
   161 		return TestStepResult();
   162 	    }
   163 	User::LeaveIfError(res); // leave here if any other error was raised other than the one above.
   164 	iEglSess->CreatePbufferSurfaceAndMakeCurrentL(currentConfig, KPixmapSize, EGL_OPENVG_API);
   165 
   166 	INFO_PRINTF1(_L("Creating 1 EGLImage from the RSgImage"));
   167 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
   168 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
   169 
   170 	INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage"));
   171 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
   172 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
   173 
   174 	// At this point we draw the VGImage created from the SgImage to the current surface.
   175 	//	# if the source is a A_8, the VGImage acts as a mask and the target surface must contain 
   176 	//		as a result the pen colour set above blended with the mask
   177 	//	# otherwise, drawing the VGImage is just a simple copy via vgSetPixels (no blending required) 
   178 	INFO_PRINTF1(_L("Copying the VGImage to the surface"));
   179 	if (iSourceFormat == EUidPixelFormatA_8)
   180 		{
   181 		// clear surface background
   182 		VGfloat bgColor[] = {0.0, 0.0, 0.0, 1.0}; // opaque black
   183 		vgSetfv(VG_CLEAR_COLOR, 4, bgColor);
   184 		vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   185 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   186 
   187 		// fill paint
   188 		VGPaint fillPaint = vgCreatePaint();
   189 		vgSetPaint(fillPaint, VG_FILL_PATH);
   190 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   191 		vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
   192 		VGuint fillColor = 0x00ff00ff; // opaque green
   193 		vgSetColor(fillPaint, fillColor);
   194 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   195 		
   196 		vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
   197 		vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
   198 		vgDrawImage(vgImage);
   199 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   200 		eglWaitClient();
   201 	    vgDestroyPaint(fillPaint);
   202 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   203 		}
   204 	else
   205 		{
   206 		vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   207 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   208 		eglWaitClient();
   209 		}
   210 	
   211 	// destroy eglimage and vgimage
   212 	vgDestroyImage(vgImage);
   213 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   214 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
   215 
   216 	// Check that the surface contains the expected pixels
   217 	//  # if the source is a A_8, to compare the surface with a reference bitmap, the following is needed:
   218 	//    a) a reference bitmap needs to be cleared to black (same colour as the surface was cleared to)
   219 	//    b) a Pen bitmap, that we clear to green (same colour as the fillPaint used to draw to the surface)
   220 	//    c) a mask bitmap, which is the reference bitmap used to create the SgImage
   221 	//  # otherwise, the surface must contain the same pixels as the bitmap used to create the SgImage 
   222 	if (iSourceFormat == EUidPixelFormatA_8)
   223 		{
   224 		// we need a reference bitmap with the same pixel format as the target surface
   225 		TUidPixelFormat format = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
   226 		TDisplayMode refbitmapMode = EglTestConversion::PixelFormatToDisplayMode(format);
   227 
   228 		CFbsBitmap* refBitmap = iEglSess->CreateReferenceMaskedBitmapL(refbitmapMode, KRgbGreen, bitmap);
   229 		CleanupStack::PushL(refBitmap);
   230 		
   231 		// compare the obtained reference bitmap with the surface drawn
   232 		iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
   233 		CleanupStack::PopAndDestroy(refBitmap);
   234 		}
   235 	else
   236 		{
   237 		iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap);
   238 		}
   239 	INFO_PRINTF1(_L("Content is as expected"));
   240 	
   241 	//cleanup
   242 	CleanupStack::PopAndDestroy(2, bitmap); // bitmap, sgImage
   243 	CleanAll();
   244 	return TestStepResult();
   245 	}
   246 
   247 /**
   248 @SYMTestCaseID GRAPHICS-EGL-0171
   249 
   250 @SYMTestPriority 1
   251 
   252 @SYMPREQ 39
   253 
   254 @SYMREQ See SGL.GT0386.401 document
   255 
   256 @SYMTestCaseDesc
   257 Check that it is possible to draw a VGImage (created from an RSgImage) to a Window Surface.
   258 
   259 @SYMTestActions
   260 Create a reference Bitmap
   261 Create an RWindow.
   262 Create and fully construct an RSgImage object having the same content as the reference bitmap 
   263 	Set the iUsage bit to ESgUsageBitOpenVgImage
   264 Create and make current and EGL context bound to OVG APIs and linked to a Window Surface 
   265 (linked to the previously created RWindow).
   266 Pass the RSgImage object into eglCreateImageKHR() with
   267 	The target parameter set to EGL_NATIVE_PIXMAP_KHR
   268 	Use the current display and EGL_NO_CONTEXT
   269 	Use a NULL attr_list
   270 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
   271 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
   272 	Check for errors
   273 Use OpenVG to draw the just drawn VGImage to the Window surface currently linked to the context.
   274 Call eglWaitClient() to finish the above drawing instructions synchronously.
   275 Destroy the original image data
   276 	Pass the VGImage into vgDestroyImage()
   277 	Pass the EGLImage into eglDestroyImageKHR()
   278 	Close the RSgImage 
   279 Check that the Window surface matches the content from the reference bitmap.
   280 Destroy the Window surface
   281 Check for memory and handle leaks
   282 
   283 @SYMTestExpectedResults
   284 Window surface matches the content from the reference bitmap.
   285 The test will loop through all the possible PixelFormat available for source 
   286 RSgImages and Destination Surfaces (accordingly to whether or not the test 
   287 is being run on hardware where just the 16MU format is supported for window surfaces)
   288 	EUidPixelFormatRGB_565
   289 	EUidPixelFormatXRGB_8888
   290 	EUidPixelFormatARGB_8888 (source only)
   291 	EUidPixelFormatARGB_8888_PRE
   292 	EUidPixelFormatA_8  (source only)
   293 No memory or handle leaks.
   294 */
   295 TVerdict CEglTest_EGL_Image_VgImage_To_Window::doTestStepL()
   296 	{
   297 	SetTestStepID(_L("GRAPHICS-EGL-0171"));
   298 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
   299 	if(!ret)
   300 		{
   301 		// The extension is not supported
   302 		RecordTestResultL();
   303 		CloseTMSGraphicsStep();
   304 		return TestStepResult();
   305 		}
   306 
   307 	CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
   308 	CleanupStack::PushL(iniParser);
   309 
   310 	TInt numWindowSurfaceFormats = iniParser->GetNumberOfFormats(KSectionWindowSurfaceFormats);
   311 	TInt numImageSourceFormats = iniParser->GetNumberOfFormats(KSectionImageSourceFormats);
   312 	if(!numImageSourceFormats && !numWindowSurfaceFormats)
   313 		{
   314 		ERR_PRINTF1(_L("No formats to iterate through"));
   315 		User::Leave(KErrArgument);
   316 		}
   317 	for(TUint j=0; j < numWindowSurfaceFormats; j++)
   318 		{
   319 		iSurfaceFormat = iniParser->GetVgFormat(KSectionWindowSurfaceFormats,j);
   320 		for(TUint i=0; i < numImageSourceFormats; i++)
   321 			{
   322 			iSourceFormat = iniParser->GetPixelFormat(KSectionImageSourceFormats,i);
   323 			if (iSourceFormat == EUidPixelFormatARGB_8888 && (iSurfaceFormat == VG_sARGB_8888_PRE || iSurfaceFormat == VG_sARGB_8888))
   324 				{
   325 				// Don't perform the test for this particular format combination
   326 				//  Causes issues converting pixel values from non-pre to pre
   327 				continue;
   328 				}
   329 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   330 			// A_8 related tests are only performed for SgImage-Lite
   331 			if (iSourceFormat == EUidPixelFormatA_8)
   332 				continue;
   333 #endif	
   334 			doTestPartialStepL();
   335 			}
   336 		}
   337 
   338 	CleanupStack::PopAndDestroy(iniParser);
   339 	RecordTestResultL();
   340 	CloseTMSGraphicsStep();
   341 	return TestStepResult();
   342 	}
   343 
   344 TVerdict CEglTest_EGL_Image_VgImage_To_Window::doTestPartialStepL()
   345 	{
   346 	INFO_PRINTF1(_L("CEglTest_EGL_Image_VgImage_To_Window::doTestPartialStepL"));
   347 	PrintUsedPixelConfiguration();
   348 	
   349 	OpenWsSessionL(KDefaultWindowGroupId);
   350 	RWindow window;
   351 	ConstructWindowL(window, KPixmapSize);
   352 	CleanupClosePushL(window);
   353 
   354 	// Create display object
   355 	GetDisplayL();
   356 	CreateEglSessionL();
   357 	iEglSess->InitializeL();
   358 	iEglSess->OpenSgDriverL();
   359 
   360 	// Create a reference bitmap which we use to init the SgImage (we use index=2)
   361 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
   362 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 2);
   363 	CleanupStack::PushL(bitmap);
   364 
   365 	INFO_PRINTF1(_L("Creating 1 RSgImage"));
   366 	RSgImage sgImage;
   367 	CleanupClosePushL(sgImage);
   368 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
   369 	TInt ret = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
   370 	ASSERT_EQUALS(ret, KErrNone);
   371 
   372 	// If create window surface fails, don't fail if there's no matching config (but fail in any other situation):
   373     //		Support for a window surface is not mandated any pixel format
   374     //		We should not enforce it in the tests
   375     //		Silently terminate the test without failing.
   376 	TEglTestConfig windowFormat = EglTestConversion::VgFormatToWindowSurfaceFormat(iSurfaceFormat);
   377 	EGLConfig config = 0;
   378 	TRAPD(res, config = iEglSess->GetConfigExactMatchL( windowFormat ));
   379 	if(res == KTestNoMatchingConfig)
   380 		{
   381 		INFO_PRINTF1(_L("Creation of window surface has failed, the test case for that configuration will be skipped"));
   382 		CleanupStack::PopAndDestroy(3, &window); // window, bitmap, sgimage
   383 		CloseWsSession();
   384 		CleanAll();
   385 		RecordTestResultL();
   386 		CloseTMSGraphicsStep();
   387 		return TestStepResult();
   388 		}
   389     User::LeaveIfError(res); // leave here if any other error was raised other than the one above.
   390 	iEglSess->CreateWindowSurfaceAndMakeCurrentL(config, window, windowFormat == EWindowAttribsColor16MAP);
   391 
   392 	INFO_PRINTF1(_L("Creating 1 EGLImage from the RSgImage"));
   393 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
   394 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
   395 
   396 	INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage"));
   397 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
   398 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
   399 	    
   400 	// At this point we draw the VGImage created from the SgImage to the current surface.
   401 	//	# if the source is a A_8, the VGImage acts as a mask and the target surface must contain 
   402 	//		as a result the pen colour set above blended with the mask
   403 	//	# otherwise, drawing the VGImage is just a simple copy via vgSetPixels (no blending required) 
   404 	INFO_PRINTF1(_L("Copying the VGImage to the surface"));
   405 	if (iSourceFormat == EUidPixelFormatA_8)
   406 		{
   407 		// clear surface background
   408 		VGfloat bgColor[] = {0.0, 0.0, 0.0, 1.0}; // opaque black
   409 		vgSetfv(VG_CLEAR_COLOR, 4, bgColor);
   410 		vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   411 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   412 
   413 		// fill paint
   414 		VGPaint fillPaint = vgCreatePaint();
   415 		vgSetPaint(fillPaint, VG_FILL_PATH);
   416 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   417 		vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
   418 		VGuint fillColor = 0x00ff00ff; // opaque green
   419 		vgSetColor(fillPaint, fillColor);
   420 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   421 		
   422 		vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
   423 		vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
   424 		vgDrawImage(vgImage);
   425 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   426 		eglWaitClient();
   427 	    vgDestroyPaint(fillPaint);
   428 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   429 		}
   430 	else
   431 		{
   432 		vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   433 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   434 		eglWaitClient();
   435 		}
   436 	
   437 	// destroy eglimage and vgimage
   438 	vgDestroyImage(vgImage);
   439 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   440 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
   441 
   442 	// Check that the surface contains the expected pixels
   443 	//  # if the source is a A_8, to compare the surface with a reference bitmap, the following is needed:
   444 	//    a) a reference bitmap needs to be cleared to black (same colour as the surface was cleared to)
   445 	//    b) a Pen bitmap, that we clear to green (same colour as the fillPaint used to draw to the surface)
   446 	//    c) a mask bitmap, which is the reference bitmap used to create the SgImage
   447 	//  # otherwise, the surface must contain the same pixels as the bitmap used to create the SgImage 
   448 	if (iSourceFormat == EUidPixelFormatA_8)
   449 		{
   450 		// we need a reference bitmap with the same pixel format as the target surface
   451 		TUidPixelFormat format = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
   452 		TDisplayMode refbitmapMode = EglTestConversion::PixelFormatToDisplayMode(format);
   453 
   454 		CFbsBitmap* refBitmap = iEglSess->CreateReferenceMaskedBitmapL(refbitmapMode, KRgbGreen, bitmap);
   455 		CleanupStack::PushL(refBitmap);
   456 		
   457 		// compare the obtained reference bitmap with the surface drawn
   458 		iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
   459 		CleanupStack::PopAndDestroy(refBitmap);
   460 		}
   461 	else
   462 		{
   463 		iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap);
   464 		}
   465 	INFO_PRINTF1(_L("Content is as expected"));
   466     eglSwapBuffers(iDisplay,iEglSess->Surface());
   467 	
   468     // cleanup, destroy the window surface before native window.
   469     iEglSess->CleanupSurfaceAndContextL();
   470 	CleanupStack::PopAndDestroy(3, &window); // window, bitmap, sgimage
   471 	CloseWsSession();
   472 	CleanAll();
   473 	return TestStepResult();
   474 	}
   475 
   476 
   477 /**
   478 @SYMTestCaseID GRAPHICS-EGL-0172
   479 
   480 @SYMTestPriority 1
   481 
   482 @SYMPREQ 39
   483 
   484 @SYMREQ See SGL.GT0386.401 document
   485 
   486 @SYMTestCaseDesc
   487 Check that it is possible to draw a VGImage (created from an RSgImage) to a pixmap surface created from an RSGImage
   488 
   489 @SYMTestActions
   490 Create a reference Bitmap
   491 Create and fully construct an RSgImage object having the same content as the reference bitmap 
   492 	Set the iUsage bit to ESgUsageBitOpenVgImage
   493 Pass the RSgImage object into eglCreateImageKHR() with
   494 	The target parameter set to EGL_NATIVE_PIXMAP_KHR
   495 	Use the current display and EGL_NO_CONTEXT
   496 	Use a NULL attr_list
   497 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
   498 Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
   499 	Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface 
   500 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
   501 	Check for errors
   502 Use OpenVG to copy the VGImage to the pixmap surface currently linked to the context.
   503 Call eglWaitClient() to finish the above drawing instructions synchronously.
   504 Destroy the original image data
   505 	Pass the VGImage into vgDestroyImage()
   506 	Pass the EGLImage into eglDestroyImageKHR()
   507 	Close the RSgImage 
   508 Check that the pixmap surface matches the content from the reference bitmap.
   509 Destroy the pixmap surface
   510 Destroy the RSgImage
   511 Check for memory and handle leaks
   512 
   513 @SYMTestExpectedResults
   514 pixmap surface matches the content from the reference bitmap 
   515 The test will loop through all the possible PixelFormat available for source 
   516 RSgImages and Destination Surfaces
   517 	EUidPixelFormatRGB_565
   518 	EUidPixelFormatXRGB_8888
   519 	EUidPixelFormatARGB_8888 (source only)
   520 	EUidPixelFormatARGB_8888_PRE
   521 	EUidPixelFormatA_8  (source only)
   522 No memory or handle leaks
   523 */
   524 TVerdict CEglTest_EGL_Image_VgImage_To_Pixmap::doTestStepL()
   525 	{
   526 	SetTestStepID(_L("GRAPHICS-EGL-0172"));
   527 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
   528 	if(!ret)
   529 		{
   530 		// The extension is not supported
   531 		RecordTestResultL();
   532 		CloseTMSGraphicsStep();
   533 		return TestStepResult();
   534 		}
   535 
   536 	CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
   537 	CleanupStack::PushL(iniParser);
   538 
   539 	TInt numPixmapSgSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapSgSurfaceFormats);
   540 	TInt numImageSourceFormats = iniParser->GetNumberOfFormats(KSectionImageSourceFormats);
   541 	if(!numImageSourceFormats && !numPixmapSgSurfaceFormats)
   542 		{
   543 		ERR_PRINTF1(_L("No formats to iterate through"));
   544 		User::Leave(KErrArgument);
   545 		}
   546 	for(TUint j=0; j < numPixmapSgSurfaceFormats; j++)
   547 		{
   548 		iSurfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,j);
   549 		for(TUint i=0; i < numImageSourceFormats; i++)
   550 			{
   551 			iSourceFormat = iniParser->GetPixelFormat(KSectionImageSourceFormats,i);
   552 			if (iSourceFormat == EUidPixelFormatARGB_8888 && (iSurfaceFormat == VG_sARGB_8888_PRE || iSurfaceFormat == VG_sARGB_8888))
   553 				{
   554 				// Don't perform the test for this particular format combination
   555 				//  Causes issues converting pixel values from non-pre to pre
   556 				continue;
   557 				}
   558 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   559 			// A_8 related tests are only performed for SgImage-Lite
   560 			if (iSourceFormat == EUidPixelFormatA_8)
   561 				continue;
   562 #endif	
   563 			doTestPartialStepL();
   564 			}
   565 		}
   566 
   567 	CleanupStack::PopAndDestroy(iniParser);
   568 	RecordTestResultL();
   569 	CloseTMSGraphicsStep();
   570 	return TestStepResult();
   571 	}
   572 
   573 TVerdict CEglTest_EGL_Image_VgImage_To_Pixmap::doTestPartialStepL()
   574 	{
   575 	INFO_PRINTF1(_L("CEglTest_EGL_Image_VgImage_To_Pixmap::doTestPartialStepL"));
   576 	PrintUsedPixelConfiguration();
   577 
   578 	// Create display object
   579 	GetDisplayL();
   580 	CreateEglSessionL();
   581 	iEglSess->InitializeL();
   582 	iEglSess->OpenSgDriverL();
   583 
   584 	// Create a reference bitmap which we use to init the SgImage (we use index=7)
   585 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
   586 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 7);
   587 	CleanupStack::PushL(bitmap);
   588 
   589 	INFO_PRINTF1(_L("Creating 1 RSgImage"));
   590 	RSgImage sgImage;
   591 	CleanupClosePushL(sgImage);
   592 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
   593 	TInt ret = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
   594 	ASSERT_EQUALS(ret, KErrNone);
   595 	
   596 	INFO_PRINTF1(_L("Creating 1 EGLImage from it"));
   597 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
   598 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
   599 
   600 	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
   601 	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
   602 	// Create a pixmap surface matching the native image pixel format
   603 	iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
   604  
   605 	INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage"));
   606 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
   607 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
   608 
   609 	// At this point we draw the VGImage created from the SgImage to the current surface.
   610 	//	# if the source is a A_8, the VGImage acts as a mask and the target surface must contain 
   611 	//		as a result the pen colour set above blended with the mask
   612 	//	# otherwise, drawing the VGImage is just a simple copy via vgSetPixels (no blending required) 
   613 	INFO_PRINTF1(_L("Copying the VGImage to the surface"));
   614 	if (iSourceFormat == EUidPixelFormatA_8)
   615 		{
   616 		// clear surface background
   617 		VGfloat bgColor[] = {0.0, 0.0, 0.0, 1.0}; // opaque black
   618 		vgSetfv(VG_CLEAR_COLOR, 4, bgColor);
   619 		vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   620 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   621 
   622 		// fill paint
   623 		VGPaint fillPaint = vgCreatePaint();
   624 		vgSetPaint(fillPaint, VG_FILL_PATH);
   625 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   626 		vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
   627 		VGuint fillColor = 0x00ff00ff; // opaque green
   628 		vgSetColor(fillPaint, fillColor);
   629 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   630 		
   631 		vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
   632 		vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
   633 		vgDrawImage(vgImage);
   634 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   635 		eglWaitClient();
   636 	    vgDestroyPaint(fillPaint);
   637 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   638 		}
   639 	else
   640 		{
   641 		vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   642 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   643 		eglWaitClient();
   644 		}
   645 	
   646 	// destroy eglimage and vgimage
   647 	vgDestroyImage(vgImage);
   648 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   649 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
   650 
   651 	// Check that the surface contains the expected pixels
   652 	//  # if the source is a A_8, to compare the surface with a reference bitmap, the following is needed:
   653 	//    a) a reference bitmap needs to be cleared to black (same colour as the surface was cleared to)
   654 	//    b) a Pen bitmap, that we clear to green (same colour as the fillPaint used to draw to the surface)
   655 	//    c) a mask bitmap, which is the reference bitmap used to create the SgImage
   656 	//  # otherwise, the surface must contain the same pixels as the bitmap used to create the SgImage 
   657 	if (iSourceFormat == EUidPixelFormatA_8)
   658 		{
   659 		// we need a reference bitmap with the same pixel format as the target surface
   660 		TUidPixelFormat format = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
   661 		TDisplayMode refbitmapMode = EglTestConversion::PixelFormatToDisplayMode(format);
   662 
   663 		CFbsBitmap* refBitmap = iEglSess->CreateReferenceMaskedBitmapL(refbitmapMode, KRgbGreen, bitmap);
   664 		CleanupStack::PushL(refBitmap);
   665 		
   666 		// compare the obtained reference bitmap with the surface drawn
   667 		iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
   668 		CleanupStack::PopAndDestroy(refBitmap);
   669 		}
   670 	else
   671 		{
   672 		iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap);
   673 		}
   674 	INFO_PRINTF1(_L("Content is as expected"));
   675 	
   676 	//cleanup
   677 	CleanupStack::PopAndDestroy(2, bitmap); // bitmap, sgImage
   678 	CleanAll();
   679 	return TestStepResult();
   680 	}
   681 
   682 /**
   683 @SYMTestCaseID GRAPHICS-EGL-0173
   684 
   685 @SYMTestPriority 1
   686 
   687 @SYMPREQ 39
   688 
   689 @SYMREQ See SGL.GT0386.401 document
   690 
   691 @SYMTestCaseDesc
   692 Check that it is possible to draw a VGImage (created from an RSgImage) to a pixmap surface based upon a CFbsBitmap, created from a CFbsBitmap Surface,.
   693 
   694 @SYMTestActions
   695 Create a reference Bitmap
   696 Create and fully construct an RSgImage object having the same content as the reference bitmap 
   697 	Set the iUsage bit to ESgUsageBitOpenVgImage
   698 Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface based upon a CFbsBitmap.
   699 Pass the RSgImage object into eglCreateImageKHR() with
   700 	The target parameter set to EGL_NATIVE_PIXMAP_KHR
   701 	Use the current display and EGL_NO_CONTEXT
   702 	Use a NULL attr_list
   703 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
   704 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
   705 	Check for errors
   706 Use OpenVG to copy the VGImage to the pixmap surface currently linked to the context.
   707 Call eglWaitClient() to finish the above drawing instructions synchronously.
   708 Destroy the original image data
   709 	Pass the VGImage into vgDestroyImage()
   710 	Pass the EGLImage into eglDestroyImageKHR()
   711 	Close the RSgImage 
   712 Check that the pixmap surface matches the content from the reference bitmap.
   713 Destroy the pixmap surface
   714 Destroy the CFbsBitmap
   715 Check for memory and handle leaks
   716 
   717 @SYMTestExpectedResults
   718 pixmap surface matches the content from the reference bitmap
   719 The test will loop through all the possible PixelFormat available for source RSgImages and Destination Surfaces
   720 	EUidPixelFormatRGB_565
   721 	EUidPixelFormatXRGB_8888
   722 	EUidPixelFormatARGB_8888 (source only)
   723 	EUidPixelFormatARGB_8888_PRE
   724 	EUidPixelFormatA_8  (source only)
   725 No memory or handle leaks
   726 */
   727 TVerdict CEglTest_EGL_Image_VGImage_To_Pixmap_CFbs::doTestStepL()
   728 	{
   729 	SetTestStepID(_L("GRAPHICS-EGL-0173"));
   730 	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
   731 	if(!ret)
   732 		{
   733 		// The extension is not supported
   734 		RecordTestResultL();
   735 		CloseTMSGraphicsStep();
   736 		return TestStepResult();
   737 		}
   738 
   739 	CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
   740 	CleanupStack::PushL(iniParser);
   741 
   742 	TInt numPixmapFbsSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapFbsSurfaceFormats);
   743 	TInt numImageSourceFormats = iniParser->GetNumberOfFormats(KSectionImageSourceFormats);
   744 	if(!numImageSourceFormats && !numPixmapFbsSurfaceFormats)
   745 		{
   746 		ERR_PRINTF1(_L("No formats to iterate through"));
   747 		User::Leave(KErrArgument);
   748 		}
   749 	for(TUint j=0; j < numPixmapFbsSurfaceFormats; j++)
   750 		{
   751 		iSurfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,j);
   752 		for(TUint i=0; i < numImageSourceFormats; i++)
   753 			{
   754 			iSourceFormat = iniParser->GetPixelFormat(KSectionImageSourceFormats,i);
   755 			if (iSourceFormat == EUidPixelFormatARGB_8888 && (iSurfaceFormat == VG_sARGB_8888_PRE || iSurfaceFormat == VG_sARGB_8888))
   756 				{
   757 				// Don't perform the test for this particular format combination
   758 				//  Causes issues converting pixel values from non-pre to pre
   759 				continue;
   760 				}
   761 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   762 			// A_8 related tests are only performed for SgImage-Lite
   763 			if (iSourceFormat == EUidPixelFormatA_8)
   764 				continue;
   765 #endif	
   766 			doTestPartialStepL();
   767 			}
   768 		}
   769 
   770 	CleanupStack::PopAndDestroy(iniParser);
   771 	RecordTestResultL();
   772 	CloseTMSGraphicsStep();
   773 	return TestStepResult();
   774 	}
   775 
   776 TVerdict CEglTest_EGL_Image_VGImage_To_Pixmap_CFbs::doTestPartialStepL()
   777 	{
   778 	INFO_PRINTF1(_L("CEglTest_EGL_Image_VGImage_To_Pixmap_CFBS::doTestPartialStepL"));
   779 	PrintUsedPixelConfiguration();
   780 
   781 	// Create display object
   782 	GetDisplayL();
   783 	CreateEglSessionL();
   784 	iEglSess->InitializeL();
   785 	iEglSess->OpenSgDriverL();
   786 
   787 
   788 	// Create a reference bitmap which we use to init the SgImage (we use index=7)
   789 	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
   790 	CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 7);
   791 	CleanupStack::PushL(bitmap);
   792 
   793 	INFO_PRINTF1(_L("Creating 1 RSgImage"));
   794 	RSgImage sgImage;
   795 	CleanupClosePushL(sgImage);
   796 	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
   797 	TInt ret = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
   798 	ASSERT_EQUALS(ret, KErrNone);
   799 	
   800 	// If create pixmap fails, don't fail if there's no matching config (but fail in any other situation):
   801     //		Support for a pixmap surface from CFbsBitmap is not mandatory
   802     //		We should not enforce it in the tests
   803     //		Silently terminate the test without failing.
   804 	TDisplayMode surfaceBitmapMode = EglTestConversion::VgFormatToDisplayMode(iSurfaceFormat);
   805 	TRAPD(res, iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(KPixmapSize, surfaceBitmapMode, EGL_OPENVG_API));
   806     if(res == KTestNoMatchingConfig)
   807 		{
   808 	    WARN_PRINTF2(_L("Can't create pixmap surface based on bitmap in mode %d, the test will be skipped"), surfaceBitmapMode);
   809 		CleanupStack::PopAndDestroy(bitmap); 
   810 		CleanAll();
   811 		RecordTestResultL();
   812 		CloseTMSGraphicsStep();
   813 		return TestStepResult();
   814 		}
   815     User::LeaveIfError(res); // leave here if any other error was raised other than the one above.
   816 
   817 	INFO_PRINTF1(_L("Creating 1 EGLImage from the RSgImage"));
   818 	// Create an EGLImage from the RSgImage
   819 	EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
   820 	ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
   821 
   822 	INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage"));
   823 	VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
   824 	ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
   825 
   826 	// At this point we draw the VGImage created from the SgImage to the current surface.
   827 	//	# if the source is a A_8, the VGImage acts as a mask and the target surface must contain 
   828 	//		as a result the pen colour set above blended with the mask
   829 	//	# otherwise, drawing the VGImage is just a simple copy via vgSetPixels (no blending required) 
   830 	INFO_PRINTF1(_L("Copying the VGImage to the surface"));
   831 	if (iSourceFormat == EUidPixelFormatA_8)
   832 		{
   833 		// clear surface background
   834 		VGfloat bgColor[] = {0.0, 0.0, 0.0, 1.0}; // opaque black
   835 		vgSetfv(VG_CLEAR_COLOR, 4, bgColor);
   836 		vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   837 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   838 
   839 		// fill paint
   840 		VGPaint fillPaint = vgCreatePaint();
   841 		vgSetPaint(fillPaint, VG_FILL_PATH);
   842 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   843 		vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
   844 		VGuint fillColor = 0x00ff00ff; // opaque green
   845 		vgSetColor(fillPaint, fillColor);
   846 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   847 		
   848 		vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
   849 		vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
   850 		vgDrawImage(vgImage);
   851 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   852 		eglWaitClient();
   853 	    vgDestroyPaint(fillPaint);
   854 		ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
   855 		}
   856 	else
   857 		{
   858 		vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
   859 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   860 		eglWaitClient();
   861 		}
   862 	
   863 	// destroy eglimage and vgimage
   864 	vgDestroyImage(vgImage);
   865 	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
   866 	ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
   867 
   868 	// Check that the surface contains the expected pixels
   869 	//  # if the source is a A_8, to compare the surface with a reference bitmap, the following is needed:
   870 	//    a) a reference bitmap needs to be cleared to black (same colour as the surface was cleared to)
   871 	//    b) a Pen bitmap, that we clear to green (same colour as the fillPaint used to draw to the surface)
   872 	//    c) a mask bitmap, which is the original reference bitmap used to create the SgImage
   873 	//  # otherwise, the surface must contain the same pixels as the bitmap used to create the SgImage 
   874 	if (iSourceFormat == EUidPixelFormatA_8)
   875 		{
   876 		// we need a reference bitmap with the same pixel format as the target surface
   877 		TUidPixelFormat format = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
   878 		TDisplayMode refbitmapMode = EglTestConversion::PixelFormatToDisplayMode(format);
   879 
   880 		CFbsBitmap* refBitmap = iEglSess->CreateReferenceMaskedBitmapL(refbitmapMode, KRgbGreen, bitmap);
   881 		CleanupStack::PushL(refBitmap);
   882 		
   883 		// compare the obtained reference bitmap with the surface drawn
   884 		iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
   885 		CleanupStack::PopAndDestroy(refBitmap);
   886 		}
   887 	else
   888 		{
   889 		iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap);
   890 		}
   891 	INFO_PRINTF1(_L("Content is as expected"));
   892 	
   893 	//cleanup
   894 	CleanupStack::PopAndDestroy(2, bitmap); //bitmap, sgImage 
   895 	CleanAll();
   896 	return TestStepResult();
   897 	}