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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include <test/tefunit.h> // for ASSERT macros
22 #include "egltest_sibling.h"
24 #include <test/egltestcommonconversion.h>
25 #include <test/egltestcommonsgimageinfo.h>
28 @SYMTestCaseID GRAPHICS-EGL-0135
34 @SYMREQ See SGL.GT0386.401 document
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
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.
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()
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
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.
65 TVerdict CEglTest_EGL_Image_CreatePBufferFromClient_With_Sibling_VGImage::doTestStepL()
67 SetTestStepID(_L("GRAPHICS-EGL-0135"));
68 INFO_PRINTF1(_L("CEglTest_CreatePBufferFromClient_With_Sibling_VGImage::doTestStepL"));
70 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
73 // The extension is not supported
75 CloseTMSGraphicsStep();
76 return TestStepResult();
79 // This test is performed for default pixel format
80 PrintUsedPixelConfiguration();
82 // Create display object
85 iEglSess->InitializeL();
86 iEglSess->OpenSgDriverL();
89 CleanupClosePushL(sgImage);
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);
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);
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);
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);
111 INFO_PRINTF1(_L("Creating one VGImage from it"));
112 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
113 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
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)
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));
128 CloseTMSGraphicsStep();
129 return TestStepResult();
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);
136 // destroy eglimage and vgimage
137 vgDestroyImage(vgImage);
138 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
139 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
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));
151 vgDestroyImage(vgImage2);
152 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
156 CloseTMSGraphicsStep();
157 return TestStepResult();
161 @SYMTestCaseID GRAPHICS-EGL-0136
167 @SYMREQ See SGL.GT0386.401 document
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.
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()
196 Check for memory and handle leaks
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
203 TVerdict CEglTest_EGL_Image_Sibling_Basic::doTestStepL()
205 SetTestStepID(_L("GRAPHICS-EGL-0136"));
206 INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_Basic::doTestStepL"));
208 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
211 // The extension is not supported
213 CloseTMSGraphicsStep();
214 return TestStepResult();
217 // This test is performed for default pixel format
218 PrintUsedPixelConfiguration();
220 // Create display object
223 iEglSess->InitializeL();
224 iEglSess->OpenSgDriverL();
226 INFO_PRINTF1(_L("Creating one RSgImage"));
227 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
228 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
229 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
232 CleanupClosePushL(sgImage);
233 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
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);
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);
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);
251 CleanupStack::PopAndDestroy(&sgImage);
252 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR3));
256 CloseTMSGraphicsStep();
257 return TestStepResult();
261 @SYMTestCaseID GRAPHICS-EGL-0138
267 @SYMREQ See SGL.GT0386.401 document
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.
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.
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()
295 Check for memory and handle leaks
297 @SYMTestExpectedResults
298 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
299 • And an EGL_BAD_ACCESS error is generated
300 No memory or handle leaks.
302 TVerdict CEglTest_EGL_Image_Sibling_VGImage::doTestStepL()
304 SetTestStepID(_L("GRAPHICS-EGL-0138"));
305 INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage::doTestStepL"));
307 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
310 // The extension is not supported
312 CloseTMSGraphicsStep();
313 return TestStepResult();
316 // This test is performed for default pixel format
317 PrintUsedPixelConfiguration();
319 // Create display object
322 iEglSess->InitializeL();
323 iEglSess->OpenSgDriverL();
325 INFO_PRINTF1(_L("Creating one RSgImage"));
326 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
327 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
328 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
331 CleanupClosePushL(sgImage);
332 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
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);
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);
343 INFO_PRINTF1(_L("Creating one VGImage from it"));
344 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
345 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
347 INFO_PRINTF1(_L("Destroying the EGLImage but retain the handle value"));
348 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
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);
355 INFO_PRINTF1(_L("Setting the handle to EGL_NO_IMAGE_KHR"));
356 imageKHR = EGL_NO_IMAGE_KHR;
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);
364 CleanupStack::PopAndDestroy(&sgImage);
365 vgDestroyImage(vgImage);
366 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
370 CloseTMSGraphicsStep();
371 return TestStepResult();
375 @SYMTestCaseID GRAPHICS-EGL-0139
381 @SYMREQ See SGL.GT0386.401 document
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.
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
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.
404 Use vgCreateEGLImageTargetKHR() to construct another VGImage object from the EGLImage.
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()
415 Check for memory and handle leaks.
417 @SYMTestExpectedResults
418 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
419 • And an EGL_BAD_ACCESS error is generated
420 No memory or handle leaks.
422 TVerdict CEglTest_EGL_Image_Sibling_Two_VGImages::doTestStepL()
424 SetTestStepID(_L("GRAPHICS-EGL-0139"));
425 INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_Two_VGImages::doTestStepL"));
427 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
430 // The extension is not supported
432 CloseTMSGraphicsStep();
433 return TestStepResult();
436 // This test is performed for default pixel format
437 PrintUsedPixelConfiguration();
439 // Create display object
442 iEglSess->InitializeL();
443 iEglSess->OpenSgDriverL();
445 INFO_PRINTF1(_L("Creating one RSgImage"));
446 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
447 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
448 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
451 CleanupClosePushL(sgImage);
452 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
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);
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);
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);
469 INFO_PRINTF1(_L("Destroying the EGLImage"));
470 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
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);
477 INFO_PRINTF1(_L("Destroying the first VgImage"));
478 vgDestroyImage(vgImage1);
479 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
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);
486 INFO_PRINTF1(_L("Destroying the second VgImage"));
487 vgDestroyImage(vgImage2);
488 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
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);
496 CleanupStack::PopAndDestroy(&sgImage);
497 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));
501 CloseTMSGraphicsStep();
502 return TestStepResult();
506 @SYMTestCaseID GRAPHICS-EGL-0141
512 @SYMREQ See SGL.GT0386.401 document
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
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.
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.
537 Use vgChildImage() to construct child VGImage object from the previous VGImage.
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()
550 Check for memory and handle leaks.
552 @SYMTestExpectedResults
553 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
554 • And an EGL_BAD_ACCESS error is generated
555 No memory or handle leaks.
557 TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child::doTestStepL()
559 SetTestStepID(_L("GRAPHICS-EGL-0141"));
560 INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child::doTestStepL"));
562 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
565 // The extension is not supported
567 CloseTMSGraphicsStep();
568 return TestStepResult();
571 // This test is performed for default pixel format
572 PrintUsedPixelConfiguration();
574 // Create display object
577 iEglSess->InitializeL();
578 iEglSess->OpenSgDriverL();
580 INFO_PRINTF1(_L("Creating one RSgImage"));
581 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
582 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
583 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
586 CleanupClosePushL(sgImage);
587 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
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);
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);
598 INFO_PRINTF1(_L("Creating one VGImage from it"));
599 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
600 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
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);
606 INFO_PRINTF1(_L("Destroying the EGLImage"));
607 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
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);
614 INFO_PRINTF1(_L("Destroying the Parent VGImage"));
615 vgDestroyImage(vgImage);
616 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
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);
623 INFO_PRINTF1(_L("Destroying the Child VGImage"));
624 vgDestroyImage(childVgImage);
625 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
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);
633 CleanupStack::PopAndDestroy(&sgImage);
634 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));
638 CloseTMSGraphicsStep();
639 return TestStepResult();
644 @SYMTestCaseID GRAPHICS-EGL-0142
650 @SYMREQ See SGL.GT0386.401 document
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.
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.
668 Use vgChildImage() to construct child VGImage object from the previous VGImage.
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.
674 Pass the child VGImage into vgDestroyImage()
676 Check for memory and handle leaks.
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.
682 TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL()
684 INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL"));
685 SetTestStepID(_L("GRAPHICS-EGL-0142"));
687 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
690 // The extension is not supported
692 CloseTMSGraphicsStep();
693 return TestStepResult();
696 // This test is performed for default pixel format
697 PrintUsedPixelConfiguration();
699 // Create display object
702 iEglSess->InitializeL();
703 iEglSess->OpenSgDriverL();
706 CleanupClosePushL(sgImage);
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);
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);
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);
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);
728 INFO_PRINTF1(_L("Creating one VGImage from it"));
729 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
730 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
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);
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);
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);
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"));
756 vgDestroyImage(childVgImage);
757 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
761 CloseTMSGraphicsStep();
762 return TestStepResult();
767 @SYMTestCaseID GRAPHICS-EGL-0143
773 @SYMREQ See SGL.GT0386.401 document
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.
782 Perform the exact action described in GRAPHICS-EGL-0213 but close the RSgImage too.
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.
788 TVerdict CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents_CloseSgEarlier::doTestStepL()
790 INFO_PRINTF1(_L("CEglTest_EGL_Image_Sibling_VGImage_Child_CheckContents::doTestStepL"));
791 SetTestStepID(_L("GRAPHICS-EGL-0142"));
793 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
796 // The extension is not supported
798 CloseTMSGraphicsStep();
799 return TestStepResult();
802 // This test is performed for default pixel format
803 PrintUsedPixelConfiguration();
805 // Create display object
808 iEglSess->InitializeL();
809 iEglSess->OpenSgDriverL();
812 CleanupClosePushL(sgImage);
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);
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);
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);
829 //Close the SgDriver EGL Implemtation should have its own reference to it
830 CleanupStack::PopAndDestroy(&sgImage); // closes RSgImage
831 iEglSess->CloseSgDriver();
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);
838 INFO_PRINTF1(_L("Creating one VGImage from it"));
839 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
840 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
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);
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);
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);
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"));
865 vgDestroyImage(childVgImage);
866 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
870 CloseTMSGraphicsStep();
871 return TestStepResult();