1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltest_sibling.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,872 @@
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 <test/tefunit.h> // for ASSERT macros
1.25 +#include "egltest_sibling.h"
1.26 +
1.27 +#include <test/egltestcommonconversion.h>
1.28 +#include <test/egltestcommonsgimageinfo.h>
1.29 +
1.30 +/**
1.31 +@SYMTestCaseID GRAPHICS-EGL-0135
1.32 +
1.33 +@SYMTestPriority 1
1.34 +
1.35 +@SYMPREQ 39
1.36 +
1.37 +@SYMREQ See SGL.GT0386.401 document
1.38 +
1.39 +@SYMTestCaseDesc
1.40 +Calling CreatePBufferFromClient with VGImage which is a EGLImage sibilind has to fail.
1.41 +On the contrary if the VGImage comes from a vgCreateImage() call it has to succeed
1.42 +
1.43 +@SYMTestActions
1.44 +Create and fully construct an RSgImage object
1.45 +Pass the RSgImage object into eglCreateImageKHR() with
1.46 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.47 +• Use the current display and EGL_NO_CONTEXT
1.48 +• Use a NULL attr_list
1.49 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.50 +Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
1.51 +• Check for errors
1.52 +Call eglCreatePBufferFromClient passing this VGImage as argument and EGL OPENVG IMAGE as bufftype and a NULL attribute list
1.53 +Check that we get EGL NO SURFACE and an EGL BAD ACCESS error is generated.
1.54 +Destroy the image data
1.55 +• Pass the EGLImage into eglDestroyImageKHR()
1.56 +• Close RSgImage
1.57 +Create a VGImage by calling vgCreateImage().
1.58 +Pass this VGImage to eglCreatePBufferFromClient, this call is expected to succeed.
1.59 +Pass the VGImage to vgDestroyImage()
1.60 +Check for memory and handle leaks
1.61 +
1.62 +@SYMTestExpectedResults
1.63 +vgCreatePBufferFromClient () returns EGL NO SURFACE
1.64 +• EGL BAD ACCESS error is generated in the first case
1.65 +• No error is raised in the second case..
1.66 +No memory or handle leaks.
1.67 +*/
1.68 +TVerdict CEglTest_EGL_Image_CreatePBufferFromClient_With_Sibling_VGImage::doTestStepL()
1.69 + {
1.70 + SetTestStepID(_L("GRAPHICS-EGL-0135"));
1.71 + INFO_PRINTF1(_L("CEglTest_CreatePBufferFromClient_With_Sibling_VGImage::doTestStepL"));
1.72 +
1.73 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.74 + if(!ret)
1.75 + {
1.76 + // The extension is not supported
1.77 + RecordTestResultL();
1.78 + CloseTMSGraphicsStep();
1.79 + return TestStepResult();
1.80 + }
1.81 +
1.82 + // This test is performed for default pixel format
1.83 + PrintUsedPixelConfiguration();
1.84 +
1.85 + // Create display object
1.86 + GetDisplayL();
1.87 + CreateEglSessionL();
1.88 + iEglSess->InitializeL();
1.89 + iEglSess->OpenSgDriverL();
1.90 +
1.91 + RSgImage sgImage;
1.92 + CleanupClosePushL(sgImage);
1.93 +
1.94 + // Create a reference bitmap which we use to init the SgImage (we use index=8)
1.95 + TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
1.96 + CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
1.97 + CleanupStack::PushL(bitmap);
1.98 +
1.99 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.100 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.101 + ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
1.102 + CleanupStack::PopAndDestroy(bitmap);
1.103 +
1.104 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.105 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.106 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.107 + CleanupStack::PopAndDestroy(&sgImage);
1.108 +
1.109 + //Create a Surface and Link it to a Context bound to OpenVG
1.110 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.111 + TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
1.112 + iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
1.113 +
1.114 + INFO_PRINTF1(_L("Creating one VGImage from it"));
1.115 + VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.116 + ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
1.117 +
1.118 + INFO_PRINTF1(_L("Attempt to Create a PBuffer linked to this VGImage"));
1.119 + TEglTestConfig pbufferFormat = EglTestConversion::VgFormatToPBufferSurfaceFormat(iSurfaceFormat);
1.120 + EGLConfig currentPbufferConfig = 0;
1.121 + TRAPD(res, currentPbufferConfig=iEglSess->GetConfigExactMatchL(pbufferFormat));
1.122 + if(res == KTestNoMatchingConfig)
1.123 + {
1.124 + WARN_PRINTF2(_L("Can't create pbuffer, format %d. Terminating the test without failing"), pbufferFormat);
1.125 + // destroy eglimage and vgimage
1.126 + vgDestroyImage(vgImage);
1.127 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.128 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
1.129 + CleanAll();
1.130 + RecordTestResultL();
1.131 + CloseTMSGraphicsStep();
1.132 + return TestStepResult();
1.133 + }
1.134 + User::LeaveIfError(res); // leave here if any other error was raised other than the one above.
1.135 + EGLSurface surface = eglCreatePbufferFromClientBuffer(iDisplay,EGL_OPENVG_IMAGE,vgImage,currentPbufferConfig,NULL);
1.136 + ASSERT_EGL_TRUE(surface == EGL_NO_SURFACE);
1.137 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.138 +
1.139 + // destroy eglimage and vgimage
1.140 + vgDestroyImage(vgImage);
1.141 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.142 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
1.143 +
1.144 + //Positive test
1.145 + INFO_PRINTF1(_L("Attempt to Create a PBuffer linked to a VGImage obtained from vgCreateImage"));
1.146 + VGImage vgImage2 = vgCreateImage(KDefaultSurfaceFormat,KPixmapSize.iWidth,KPixmapSize.iHeight,VG_IMAGE_QUALITY_BETTER);
1.147 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.148 + surface = eglCreatePbufferFromClientBuffer(iDisplay,EGL_OPENVG_IMAGE,vgImage2,currentPbufferConfig,NULL);
1.149 + ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
1.150 + ASSERT_EGL_ERROR(EGL_SUCCESS);
1.151 + ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
1.152 +
1.153 + //cleanup
1.154 + vgDestroyImage(vgImage2);
1.155 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.156 + CleanAll();
1.157 +
1.158 + RecordTestResultL();
1.159 + CloseTMSGraphicsStep();
1.160 + return TestStepResult();
1.161 + }
1.162 +
1.163 +/**
1.164 +@SYMTestCaseID GRAPHICS-EGL-0136
1.165 +
1.166 +@SYMTestPriority 1
1.167 +
1.168 +@SYMPREQ 39
1.169 +
1.170 +@SYMREQ See SGL.GT0386.401 document
1.171 +
1.172 +@SYMTestCaseDesc
1.173 +Attempt to create an EGLImage out of a valid RSgImage that is already linked to another EGLImage has to fail.
1.174 +Destroy the EGLImage, then re-create an EGLImage from the same RSgImage, and this attempt is expected to succeed.
1.175 +
1.176 +@SYMTestActions
1.177 +Create a reference Bitmap
1.178 +Create and fully construct an RSgImage object having the same content as the reference bitmap
1.179 +• Set the iUsage bit to ESgUsageBitOpenVgImage
1.180 +Pass the RSgImage object into eglCreateImageKHR() with
1.181 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.182 +• Use the current display and EGL_NO_CONTEXT
1.183 +• Use a NULL attr_list
1.184 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.185 +Pass again the same RSgImage object into eglCreateImageKHR() with
1.186 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.187 +• Use the current display and EGL_NO_CONTEXT
1.188 +• Use a NULL attr_list
1.189 +Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
1.190 +Pass the EGLImage into eglDestroyImageKHR()
1.191 +Pass again the same RSgImage object into eglCreateImageKHR() with
1.192 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.193 +• Use the current display and EGL_NO_CONTEXT
1.194 +• Use a NULL attr_list
1.195 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.196 +Destroy the image data
1.197 +• Pass the EGLImage into eglDestroyImageKHR()
1.198 +• Close RSgImage
1.199 +Check for memory and handle leaks
1.200 +
1.201 +@SYMTestExpectedResults
1.202 +eglCreateImageKHR() returns EGL_NO_IMAGE_KHR (and an EGL_BAD_ACCESS error is generated) when the first EGLImage
1.203 +has not yet been destroyed. Once it is destroyed, creating aother EGLImage succeeds.
1.204 +No memory or handle leaks
1.205 +*/
1.206 +TVerdict CEglTest_EGL_Image_Sibling_Basic::doTestStepL()
1.207 + {
1.208 + SetTestStepID(_L("GRAPHICS-EGL-0136"));
1.209 + INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_Basic::doTestStepL"));
1.210 +
1.211 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.212 + if(!ret)
1.213 + {
1.214 + // The extension is not supported
1.215 + RecordTestResultL();
1.216 + CloseTMSGraphicsStep();
1.217 + return TestStepResult();
1.218 + }
1.219 +
1.220 + // This test is performed for default pixel format
1.221 + PrintUsedPixelConfiguration();
1.222 +
1.223 + // Create display object
1.224 + GetDisplayL();
1.225 + CreateEglSessionL();
1.226 + iEglSess->InitializeL();
1.227 + iEglSess->OpenSgDriverL();
1.228 +
1.229 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.230 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.231 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.232 + imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
1.233 +#endif
1.234 + RSgImage sgImage;
1.235 + CleanupClosePushL(sgImage);
1.236 + ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
1.237 +
1.238 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.239 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.240 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.241 +
1.242 + INFO_PRINTF1(_L("Trying to create another EGLImage from the same RSgImage"));
1.243 + EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.244 + ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
1.245 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.246 +
1.247 + INFO_PRINTF1(_L("Destroy first EGLImage and try to create another EGLImage from the same RSgImage"));
1.248 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
1.249 + EGLImageKHR imageKHR3 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.250 + ASSERT_EGL_TRUE(imageKHR3 != EGL_NO_IMAGE_KHR);
1.251 + ASSERT_EGL_ERROR(EGL_SUCCESS);
1.252 +
1.253 + //cleanup
1.254 + CleanupStack::PopAndDestroy(&sgImage);
1.255 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR3));
1.256 + CleanAll();
1.257 +
1.258 + RecordTestResultL();
1.259 + CloseTMSGraphicsStep();
1.260 + return TestStepResult();
1.261 + }
1.262 +
1.263 +/**
1.264 +@SYMTestCaseID GRAPHICS-EGL-0138
1.265 +
1.266 +@SYMTestPriority 1
1.267 +
1.268 +@SYMPREQ 39
1.269 +
1.270 +@SYMREQ See SGL.GT0386.401 document
1.271 +
1.272 +@SYMTestCaseDesc
1.273 +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.
1.274 +This is testing the EGLImage sibling rules from the EGLImage spec.
1.275 +
1.276 +@SYMTestActions
1.277 +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.
1.278 +Create a reference Bitmap
1.279 +Create and fully construct an RSgImage object having the same content as the reference bitmap
1.280 +• Set the iUsage bit to ESgUsageBitOpenVgImage
1.281 +Pass the RSgImage object into eglCreateImageKHR() with
1.282 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.283 +• Use the current display and EGL_NO_CONTEXT
1.284 +• Use a NULL attr_list
1.285 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.286 +Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
1.287 +• Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface.
1.288 +Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
1.289 +• Check for errors
1.290 +Pass the EGLImage into eglDestroyImageKHR()
1.291 +Pass again the same RSgImage object into eglCreateImageKHR() with
1.292 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.293 +• Use the current display and EGL_NO_CONTEXT
1.294 +• Use a NULL attr_list
1.295 +Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
1.296 +Pass the VGImage into vgDestroyImage()
1.297 +Close RSgImage
1.298 +Check for memory and handle leaks
1.299 +
1.300 +@SYMTestExpectedResults
1.301 +eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
1.302 +• And an EGL_BAD_ACCESS error is generated
1.303 +No memory or handle leaks.
1.304 +*/
1.305 +TVerdict CEglTest_EGL_Image_Sibling_VGImage::doTestStepL()
1.306 + {
1.307 + SetTestStepID(_L("GRAPHICS-EGL-0138"));
1.308 + INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage::doTestStepL"));
1.309 +
1.310 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.311 + if(!ret)
1.312 + {
1.313 + // The extension is not supported
1.314 + RecordTestResultL();
1.315 + CloseTMSGraphicsStep();
1.316 + return TestStepResult();
1.317 + }
1.318 +
1.319 + // This test is performed for default pixel format
1.320 + PrintUsedPixelConfiguration();
1.321 +
1.322 + // Create display object
1.323 + GetDisplayL();
1.324 + CreateEglSessionL();
1.325 + iEglSess->InitializeL();
1.326 + iEglSess->OpenSgDriverL();
1.327 +
1.328 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.329 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.330 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.331 + imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
1.332 +#endif
1.333 + RSgImage sgImage;
1.334 + CleanupClosePushL(sgImage);
1.335 + ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
1.336 +
1.337 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.338 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.339 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.340 +
1.341 + //Create a Surface and Link it to a Context bound to OpenVG
1.342 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.343 + TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
1.344 + iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
1.345 +
1.346 + INFO_PRINTF1(_L("Creating one VGImage from it"));
1.347 + VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.348 + ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
1.349 +
1.350 + INFO_PRINTF1(_L("Destroying the EGLImage but retain the handle value"));
1.351 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
1.352 +
1.353 + INFO_PRINTF1(_L("Attemptimg to create another VGImage from an invalid handle"));
1.354 + VGImage failingVgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.355 + ASSERT_VG_TRUE(failingVgImage == VG_INVALID_HANDLE);
1.356 + ASSERT_TRUE(vgGetError()==VG_ILLEGAL_ARGUMENT_ERROR);
1.357 +
1.358 + INFO_PRINTF1(_L("Setting the handle to EGL_NO_IMAGE_KHR"));
1.359 + imageKHR = EGL_NO_IMAGE_KHR;
1.360 +
1.361 + INFO_PRINTF1(_L("Trying to create another EGLImage from the same RSgImage"));
1.362 + EGLImageKHR imageKHR2 = GetEglSess()->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.363 + ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
1.364 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.365 +
1.366 + //cleanup
1.367 + CleanupStack::PopAndDestroy(&sgImage);
1.368 + vgDestroyImage(vgImage);
1.369 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.370 + CleanAll();
1.371 +
1.372 + RecordTestResultL();
1.373 + CloseTMSGraphicsStep();
1.374 + return TestStepResult();
1.375 + }
1.376 +
1.377 +/**
1.378 +@SYMTestCaseID GRAPHICS-EGL-0139
1.379 +
1.380 +@SYMTestPriority 1
1.381 +
1.382 +@SYMPREQ 39
1.383 +
1.384 +@SYMREQ See SGL.GT0386.401 document
1.385 +
1.386 +@SYMTestCaseDesc
1.387 +Attempt to create an EGLImage out of a valid RSgImage that is already linked
1.388 +to two VGImages (after the original EGLImage has been destroyed) has to fail.
1.389 +This is testing the EGLImage sibling rules from the EGLImage spec.
1.390 +
1.391 +@SYMTestActions
1.392 +This test will check for the “VG_KHR_EGL_image” extension, if it is not supported
1.393 +on this platform then the test will return immediately without failure.
1.394 +Create a reference Bitmap
1.395 +Create and fully construct an RSgImage object having the same content as the
1.396 +reference bitmap
1.397 +• Set the iUsage bit to ESgUsageBitOpenVgImage
1.398 +Pass the RSgImage object into eglCreateImageKHR() with
1.399 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.400 +• Use the current display and EGL_NO_CONTEXT
1.401 +• Use a NULL attr_list
1.402 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.403 +Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
1.404 +• Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface
1.405 +Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
1.406 +• Check for errors
1.407 +Use vgCreateEGLImageTargetKHR() to construct another VGImage object from the EGLImage.
1.408 +• Check for errors
1.409 +Pass the EGLImage into eglDestroyImageKHR()
1.410 +Pass again the same RSgImage object into eglCreateImageKHR() with
1.411 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.412 +• Use the current display and EGL_NO_CONTEXT
1.413 +• Use a NULL attr_list
1.414 +Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
1.415 +Pass the first VGImage into vgDestroyImage()
1.416 +Pass the second VGImage into vgDestroyImage()
1.417 +Close RSgImage
1.418 +Check for memory and handle leaks.
1.419 +
1.420 +@SYMTestExpectedResults
1.421 +eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
1.422 +• And an EGL_BAD_ACCESS error is generated
1.423 +No memory or handle leaks.
1.424 +*/
1.425 +TVerdict CEglTest_EGL_Image_Sibling_Two_VGImages::doTestStepL()
1.426 + {
1.427 + SetTestStepID(_L("GRAPHICS-EGL-0139"));
1.428 + INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_Two_VGImages::doTestStepL"));
1.429 +
1.430 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.431 + if(!ret)
1.432 + {
1.433 + // The extension is not supported
1.434 + RecordTestResultL();
1.435 + CloseTMSGraphicsStep();
1.436 + return TestStepResult();
1.437 + }
1.438 +
1.439 + // This test is performed for default pixel format
1.440 + PrintUsedPixelConfiguration();
1.441 +
1.442 + // Create display object
1.443 + GetDisplayL();
1.444 + CreateEglSessionL();
1.445 + iEglSess->InitializeL();
1.446 + iEglSess->OpenSgDriverL();
1.447 +
1.448 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.449 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.450 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.451 + imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
1.452 +#endif
1.453 + RSgImage sgImage;
1.454 + CleanupClosePushL(sgImage);
1.455 + ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
1.456 +
1.457 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.458 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.459 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.460 +
1.461 + //Create a Surface and Link it to a Context bound to OpenVG
1.462 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.463 + TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
1.464 + iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
1.465 +
1.466 + INFO_PRINTF1(_L("Creating two VGImages from it"));
1.467 + VGImage vgImage1 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.468 + ASSERT_VG_TRUE(vgImage1 != VG_INVALID_HANDLE);
1.469 + VGImage vgImage2 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.470 + ASSERT_VG_TRUE(vgImage2 != VG_INVALID_HANDLE);
1.471 +
1.472 + INFO_PRINTF1(_L("Destroying the EGLImage"));
1.473 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
1.474 +
1.475 + INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked to the two VGImages)"));
1.476 + EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.477 + ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
1.478 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.479 +
1.480 + INFO_PRINTF1(_L("Destroying the first VgImage"));
1.481 + vgDestroyImage(vgImage1);
1.482 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.483 +
1.484 + INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked now to just one VGImage)"));
1.485 + imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.486 + ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
1.487 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.488 +
1.489 + INFO_PRINTF1(_L("Destroying the second VgImage"));
1.490 + vgDestroyImage(vgImage2);
1.491 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.492 +
1.493 + INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked now to just one VGImage)"));
1.494 + imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.495 + ASSERT_EGL_TRUE(imageKHR2 != EGL_NO_IMAGE_KHR);
1.496 + ASSERT_EGL_ERROR(EGL_SUCCESS);
1.497 +
1.498 + //cleanup
1.499 + CleanupStack::PopAndDestroy(&sgImage);
1.500 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));
1.501 + CleanAll();
1.502 +
1.503 + RecordTestResultL();
1.504 + CloseTMSGraphicsStep();
1.505 + return TestStepResult();
1.506 + }
1.507 +
1.508 +/**
1.509 +@SYMTestCaseID GRAPHICS-EGL-0141
1.510 +
1.511 +@SYMTestPriority 1
1.512 +
1.513 +@SYMPREQ 39
1.514 +
1.515 +@SYMREQ See SGL.GT0386.401 document
1.516 +
1.517 +@SYMTestCaseDesc
1.518 +Attempt to create an EGLImage out of a valid RSgImage after that:
1.519 +• It has been created a VGImage from it (hence an EGLImage has been created too)
1.520 +• A Child VGImage has been created from the previous VGImage
1.521 +• the EGLImage has been destroyed too
1.522 +has to fail
1.523 +Another attempt to create an EGLImage from the same RSgImage has to fail even if we destroy the parent Image.
1.524 +Creation of an EGLImage from the same RSgImage has to succeed if the child VgImage has also been destroyed.
1.525 +
1.526 +@SYMTestActions
1.527 +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.
1.528 +Create a reference Bitmap
1.529 +Create and fully construct an RSgImage object having the same content as the reference bitmap
1.530 +• Set the iUsage bit to ESgUsageBitOpenVgImage
1.531 +Pass the RSgImage object into eglCreateImageKHR() with
1.532 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.533 +• Use the current display and EGL_NO_CONTEXT
1.534 +• Use a NULL attr_list
1.535 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.536 +Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
1.537 +• Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface
1.538 +Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
1.539 +• Check for errors
1.540 +Use vgChildImage() to construct child VGImage object from the previous VGImage.
1.541 +• Check for errors
1.542 +Pass the EGLImage into eglDestroyImageKHR()
1.543 +Pass again the same RSgImage object into eglCreateImageKHR().
1.544 +Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
1.545 +Pass the parent VGImage into vgDestroyImage()
1.546 +Pass again the same RSgImage object into eglCreateImageKHR().
1.547 +Check that eglCreateImageKHR() returns EGL_NO_IMAGE_KHR and the error generated is EGL_BAD_ACCESS
1.548 +Pass the child VGImage into vgDestroyImage()
1.549 +Pass again the same RSgImage object into eglCreateImageKHR().
1.550 +Check that eglCreateImageKHR() does not return EGL_NO_IMAGE_KHR.
1.551 +Pass the EGLImage into eglDestroyImageKHR()
1.552 +Close RSgImage
1.553 +Check for memory and handle leaks.
1.554 +
1.555 +@SYMTestExpectedResults
1.556 +eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
1.557 +• And an EGL_BAD_ACCESS error is generated
1.558 +No memory or handle leaks.
1.559 +*/
1.560 +TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child::doTestStepL()
1.561 + {
1.562 + SetTestStepID(_L("GRAPHICS-EGL-0141"));
1.563 + INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child::doTestStepL"));
1.564 +
1.565 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.566 + if(!ret)
1.567 + {
1.568 + // The extension is not supported
1.569 + RecordTestResultL();
1.570 + CloseTMSGraphicsStep();
1.571 + return TestStepResult();
1.572 + }
1.573 +
1.574 + // This test is performed for default pixel format
1.575 + PrintUsedPixelConfiguration();
1.576 +
1.577 + // Create display object
1.578 + GetDisplayL();
1.579 + CreateEglSessionL();
1.580 + iEglSess->InitializeL();
1.581 + iEglSess->OpenSgDriverL();
1.582 +
1.583 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.584 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.585 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.586 + imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
1.587 +#endif
1.588 + RSgImage sgImage;
1.589 + CleanupClosePushL(sgImage);
1.590 + ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
1.591 +
1.592 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.593 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.594 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.595 +
1.596 + //Create a Surface and Link it to a Context bound to OpenVG
1.597 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.598 + TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
1.599 + iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
1.600 +
1.601 + INFO_PRINTF1(_L("Creating one VGImage from it"));
1.602 + VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.603 + ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
1.604 +
1.605 + INFO_PRINTF1(_L("Creating a VGImage Child from the previous VGImage"));
1.606 + VGImage childVgImage = vgChildImage(vgImage,50,50,KPixmapSize.iWidth-50,KPixmapSize.iHeight-50);
1.607 + ASSERT_EGL_TRUE(childVgImage != VG_INVALID_HANDLE);
1.608 +
1.609 + INFO_PRINTF1(_L("Destroying the EGLImage"));
1.610 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
1.611 +
1.612 + INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked to both Parent and Child VGImage)"));
1.613 + EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.614 + ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
1.615 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.616 +
1.617 + INFO_PRINTF1(_L("Destroying the Parent VGImage"));
1.618 + vgDestroyImage(vgImage);
1.619 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.620 +
1.621 + INFO_PRINTF1(_L("Trying to create an EGLImage from the same RSgImage (linked to the Child VGImage)"));
1.622 + imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.623 + ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR);
1.624 + ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
1.625 +
1.626 + INFO_PRINTF1(_L("Destroying the Child VGImage"));
1.627 + vgDestroyImage(childVgImage);
1.628 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.629 +
1.630 + INFO_PRINTF1(_L("Trying to create an EGLImage and a new VGImage from the same RSgImage (now it's free)"));
1.631 + imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,NULL);
1.632 + ASSERT_EGL_TRUE(imageKHR2 != EGL_NO_IMAGE_KHR);
1.633 + ASSERT_EGL_ERROR(EGL_SUCCESS);
1.634 +
1.635 + //cleanup
1.636 + CleanupStack::PopAndDestroy(&sgImage);
1.637 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));
1.638 + CleanAll();
1.639 +
1.640 + RecordTestResultL();
1.641 + CloseTMSGraphicsStep();
1.642 + return TestStepResult();
1.643 + }
1.644 +
1.645 +
1.646 +/**
1.647 +@SYMTestCaseID GRAPHICS-EGL-0142
1.648 +
1.649 +@SYMTestPriority 1
1.650 +
1.651 +@SYMPREQ 39
1.652 +
1.653 +@SYMREQ See SGL.GT0386.401 document
1.654 +
1.655 +@SYMTestCaseDesc
1.656 +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.
1.657 +
1.658 +@SYMTestActions
1.659 +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.
1.660 +Create a reference Bitmap
1.661 +Create and fully construct an RSgImage object having the same content as the reference bitmap
1.662 +• Set the iUsage bit to ESgUsageBitOpenVgImage
1.663 +Pass the RSgImage object into eglCreateImageKHR() with
1.664 +• The target parameter set to EGL_NATIVE_PIXMAP_KHR
1.665 +• Use the current display and EGL_NO_CONTEXT
1.666 +• Use a NULL attr_list
1.667 +Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
1.668 +Create and make current and EGL context bound to OVG APIs and linked to a window surface.
1.669 +Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage.
1.670 +• Check for errors
1.671 +Use vgChildImage() to construct child VGImage object from the previous VGImage.
1.672 +• Check for errors
1.673 +Pass the parent VGImage into vgDestroyImage()
1.674 +Pass the EGLImage into eglDestroyImageKHR()
1.675 +Use OpenVG APIs to draw the previous child VGImage to this surface.
1.676 +Check Contents.
1.677 +Pass the child VGImage into vgDestroyImage()
1.678 +Close RSgImage
1.679 +Check for memory and handle leaks.
1.680 +
1.681 +@SYMTestExpectedResults
1.682 +What is drawn to the surface is exactly what is expected to be inside the child VGImage.
1.683 +No memory or handle leaks.
1.684 +*/
1.685 +TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL()
1.686 + {
1.687 + INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL"));
1.688 + SetTestStepID(_L("GRAPHICS-EGL-0142"));
1.689 +
1.690 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.691 + if(!ret)
1.692 + {
1.693 + // The extension is not supported
1.694 + RecordTestResultL();
1.695 + CloseTMSGraphicsStep();
1.696 + return TestStepResult();
1.697 + }
1.698 +
1.699 + // This test is performed for default pixel format
1.700 + PrintUsedPixelConfiguration();
1.701 +
1.702 + // Create display object
1.703 + GetDisplayL();
1.704 + CreateEglSessionL();
1.705 + iEglSess->InitializeL();
1.706 + iEglSess->OpenSgDriverL();
1.707 +
1.708 + RSgImage sgImage;
1.709 + CleanupClosePushL(sgImage);
1.710 +
1.711 + // Create a reference bitmap which we use to init the SgImage (we use index=8)
1.712 + TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
1.713 + CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
1.714 + CleanupStack::PushL(bitmap);
1.715 +
1.716 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.717 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.718 + ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
1.719 + CleanupStack::PopAndDestroy(bitmap);
1.720 + bitmap = NULL;
1.721 +
1.722 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.723 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.724 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.725 +
1.726 + //Create a Surface and Link it to a Context bound to OpenVG
1.727 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.728 + TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
1.729 + iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
1.730 +
1.731 + INFO_PRINTF1(_L("Creating one VGImage from it"));
1.732 + VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.733 + ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
1.734 +
1.735 + INFO_PRINTF1(_L("Creating a VGImage Child from the previous VGImage"));
1.736 + VGImage childVgImage = vgChildImage(vgImage,0,0,KPixmapSize.iWidth,KPixmapSize.iHeight);
1.737 + ASSERT_EGL_TRUE(childVgImage != VG_INVALID_HANDLE);
1.738 +
1.739 + INFO_PRINTF1(_L("Destroying the RSgImage, the EGLImage, and the parent VGImage"));
1.740 + CleanupStack::PopAndDestroy(&sgImage); // closes RSgImage
1.741 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); // closes EGLImage
1.742 + vgDestroyImage(vgImage); // closes VGImage (parent)
1.743 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.744 +
1.745 + INFO_PRINTF1(_L("Draw the child VGImage to the surface and check contents"));
1.746 + vgSetPixels(0, 0, childVgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
1.747 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.748 + eglWaitClient();
1.749 +
1.750 + // To check the contents we need to repopulate the reference bitmap (with same index used during init)
1.751 + TDisplayMode refBitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
1.752 + CFbsBitmap* refBitmap = iEglSess->CreateReferenceBitmapL(refBitmapMode, KPixmapSize, 8);
1.753 + CleanupStack::PushL(refBitmap);
1.754 + iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
1.755 + CleanupStack::PopAndDestroy(refBitmap);
1.756 + INFO_PRINTF1(_L("Content is as expected"));
1.757 +
1.758 + //cleanup
1.759 + vgDestroyImage(childVgImage);
1.760 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.761 + CleanAll();
1.762 +
1.763 + RecordTestResultL();
1.764 + CloseTMSGraphicsStep();
1.765 + return TestStepResult();
1.766 + }
1.767 +
1.768 +
1.769 +/**
1.770 +@SYMTestCaseID GRAPHICS-EGL-0143
1.771 +
1.772 +@SYMTestPriority 1
1.773 +
1.774 +@SYMPREQ 39
1.775 +
1.776 +@SYMREQ See SGL.GT0386.401 document
1.777 +
1.778 +@SYMTestCaseDesc
1.779 +Ensure that when using a child VGImage contents of the RSgImage are preserved even
1.780 +if the parent VGImage, the EGLImage and the original RSgImage have been destroyed.
1.781 +This test that the link of references fron the child VGImage to the actual content is
1.782 +valid even when it is the only reference left to the data.
1.783 +
1.784 +@SYMTestActions
1.785 +Perform the exact action described in GRAPHICS-EGL-0213 but close the RSgImage too.
1.786 +
1.787 +@SYMTestExpectedResults
1.788 +What is drawn to the surface is exactly what is expected to be inside the child VGImage.
1.789 +No memory or handle leaks.
1.790 +*/
1.791 +TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents_CloseSgEarlier::doTestStepL()
1.792 + {
1.793 + INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL"));
1.794 + SetTestStepID(_L("GRAPHICS-EGL-0142"));
1.795 +
1.796 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
1.797 + if(!ret)
1.798 + {
1.799 + // The extension is not supported
1.800 + RecordTestResultL();
1.801 + CloseTMSGraphicsStep();
1.802 + return TestStepResult();
1.803 + }
1.804 +
1.805 + // This test is performed for default pixel format
1.806 + PrintUsedPixelConfiguration();
1.807 +
1.808 + // Create display object
1.809 + GetDisplayL();
1.810 + CreateEglSessionL();
1.811 + iEglSess->InitializeL();
1.812 + iEglSess->OpenSgDriverL();
1.813 +
1.814 + RSgImage sgImage;
1.815 + CleanupClosePushL(sgImage);
1.816 +
1.817 + // Create a reference bitmap which we use to init the SgImage (we use index=8)
1.818 + TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
1.819 + CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
1.820 + CleanupStack::PushL(bitmap);
1.821 +
1.822 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.823 + TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
1.824 + ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
1.825 + CleanupStack::PopAndDestroy(bitmap);
1.826 + bitmap = NULL;
1.827 +
1.828 + INFO_PRINTF1(_L("Creating one EGLImage from it"));
1.829 + EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
1.830 + ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
1.831 +
1.832 + //Close the SgDriver EGL Implemtation should have its own reference to it
1.833 + CleanupStack::PopAndDestroy(&sgImage); // closes RSgImage
1.834 + iEglSess->CloseSgDriver();
1.835 +
1.836 + //Create a Surface and Link it to a Context bound to OpenVG
1.837 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.838 + TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
1.839 + iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
1.840 +
1.841 + INFO_PRINTF1(_L("Creating one VGImage from it"));
1.842 + VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
1.843 + ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
1.844 +
1.845 + INFO_PRINTF1(_L("Creating a VGImage Child from the previous VGImage"));
1.846 + VGImage childVgImage = vgChildImage(vgImage,0,0,KPixmapSize.iWidth,KPixmapSize.iHeight);
1.847 + ASSERT_EGL_TRUE(childVgImage != VG_INVALID_HANDLE);
1.848 +
1.849 + INFO_PRINTF1(_L("Destroying the RSgImage, the EGLImage, and the parent VGImage"));
1.850 + ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); // closes EGLImage
1.851 + vgDestroyImage(vgImage); // closes VGImage (parent)
1.852 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.853 +
1.854 + INFO_PRINTF1(_L("Draw the child VGImage to the surface and check contents"));
1.855 + vgSetPixels(0, 0, childVgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
1.856 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.857 + eglWaitClient();
1.858 +
1.859 + // To check the contents we need to repopulate the reference bitmap (with same index used during init)
1.860 + TDisplayMode refBitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
1.861 + CFbsBitmap* refBitmap = iEglSess->CreateReferenceBitmapL(refBitmapMode, KPixmapSize, 8);
1.862 + CleanupStack::PushL(refBitmap);
1.863 + iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap);
1.864 + CleanupStack::PopAndDestroy(refBitmap);
1.865 + INFO_PRINTF1(_L("Content is as expected"));
1.866 +
1.867 + //cleanup
1.868 + vgDestroyImage(childVgImage);
1.869 + ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
1.870 + CleanAll();
1.871 +
1.872 + RecordTestResultL();
1.873 + CloseTMSGraphicsStep();
1.874 + return TestStepResult();
1.875 + }