Update contrib.
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
23 #include "egltest_image_negative.h"
25 #include <test/egltestcommonconversion.h>
26 #include <test/egltestcommonsgimageinfo.h>
29 @SYMTestCaseID GRAPHICS-EGL-0126
35 @SYMREQ See SGL.GT0386.401 document
38 Test that eglCreateImageKHR() fails and returns the correct error
39 when one of the parameters other than Target has an invalid value.
40 The value of the Target parameter must always be EGL_NATIVE_PIXMAP_KHR
43 Call eglCreateImageKHR() with NULL instead of a valid RSgImage handle
44 Create a not fully constructed RSgImage object (i.e. do not call RSgImage::Create() )and pass its handle when calling eglCreateImageKHR().
45 Fully construct an RSgImage and call eglCreateImageKHR() with a valid egl context
46 Call eglCreateImageKHR() with a non valid target (meaningless number instead of EGL_NATIVE_PIXMAP_KHR)
47 Call eglCreateImageKHR() with diplay = EGL_NO_DISPLAY
48 Call eglCreateImageKHR() with a meaningless number in place of iDisplay
49 Destroy the RSgImage object
52 @SYMTestExpectedResults
53 eglCreateImageKHR() returns EGL_NO_IMAGE_KHR in all cases
54 And an EGL_BAD_PARAMETER error is generated in all cases but the last
55 The last case should generate EGL_BAD_DISPLAY error
56 No memory or handle leaks
58 TVerdict CEglTest_EGL_Image_eglCreateImage_Bad_Parameter::doTestStepL()
60 SetTestStepID(_L("GRAPHICS-EGL-0126"));
61 INFO_PRINTF1(_L("CEglTest_EGL_Image_eglCreateImage_Bad_Parameter::doTestStepL"));
63 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
66 // The extension is not supported
68 CloseTMSGraphicsStep();
69 return TestStepResult();
72 // This test is performed for default pixel format
73 PrintUsedPixelConfiguration();
75 // Create display object
78 iEglSess->InitializeL();
79 iEglSess->OpenSgDriverL();
81 INFO_PRINTF1(_L("Creating one EGLImage from a NULL RSgImage"));
82 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, NULL, KEglImageAttribsPreservedTrue);
83 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
84 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
86 INFO_PRINTF1(_L("Creating one EGLImage from a not fully constructed RSgImage"));
88 CleanupClosePushL(sgImage);
89 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsPreservedTrue);
90 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
91 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
93 // Create an RSgImage with proper attributes
94 TSgImageInfo imageInfo;
95 imageInfo.iSizeInPixels = KPixmapSize;
96 imageInfo.iPixelFormat = iSourceFormat;
97 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
98 imageInfo.iUsage = ESgUsageBitOpenVgImage;
100 imageInfo.iUsage = ESgUsageOpenVgImage;
101 imageInfo.iShareable = EFalse;
102 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
103 //imageInfo.iMutable = ETrue;
104 imageInfo.iScreenId = KSgScreenIdMain;
105 imageInfo.iUserAttributes = NULL;
106 imageInfo.iUserAttributeCount=0;
107 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
109 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
111 //Creating a Valid Context
112 INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
113 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
115 INFO_PRINTF1(_L("Calling eglCreateContext"));
116 TEglTestConfig pixmapFormat = EglTestConversion::VgFormatToPixmapSgSurfaceFormat(iSurfaceFormat);
117 EGLConfig currentConfig = iEglSess->GetConfigExactMatchL(pixmapFormat);
118 EGLContext context = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
119 ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT);
121 INFO_PRINTF1(_L("Calling with a valid context instead of EGL_NO_CONTEXT"));
122 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,context,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsPreservedTrue);
123 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
124 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
126 INFO_PRINTF1(_L("Calling with a non valid target, using registered by meaningless in this context number - EGL_RENDERABLE_TYPE"));
127 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT, EGL_RENDERABLE_TYPE,&sgImage,KEglImageAttribsPreservedTrue);
128 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
129 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
131 INFO_PRINTF1(_L("Calling with a non valid target, using registered by meaningless in this context number - EGL_RENDERABLE_TYPE, and a valid context too"));
132 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,context,EGL_RENDERABLE_TYPE,&sgImage,KEglImageAttribsPreservedTrue);
133 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
134 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
136 INFO_PRINTF1(_L("Calling with a display set to EGL_NO_DISPLAY"));
137 imageKHR = iEglSess->eglCreateImageKhrL(EGL_NO_DISPLAY,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsPreservedTrue);
138 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
139 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
141 INFO_PRINTF1(_L("Calling with a a \"random\" value instead of a Display"));
142 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay+3,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsPreservedTrue);
143 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
144 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
146 INFO_PRINTF1(_L("Calling with an invalid attribute list"));
147 EGLint KEglImageAttribsInvalid[] =
149 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
152 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsInvalid);
153 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
154 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
156 INFO_PRINTF1(_L("Calling with a corrupt attribute list (fail to provide an EGL_NONE attribute at the end of the list)"));
157 EGLint KEglImageAttribsCorrupt[] =
159 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE
161 imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsCorrupt);
162 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
163 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
166 ASSERT_EGL_TRUE(eglDestroyContext(iDisplay, context));
167 CleanupStack::PopAndDestroy(&sgImage);
171 CloseTMSGraphicsStep();
172 return TestStepResult();
176 @SYMTestCaseID GRAPHICS-EGL-0127
182 @SYMREQ See SGL.GT0386.401 document
185 Check that iUsage bits are enforced.
186 Its not possible to create a VGImage from an RSgImage cant be used as a VGImage source.
189 Create a reference Bitmap
190 Create and fully construct an RSgImage object having the same content as the reference bitmap
191 Set the iUsage bits to ESgUsageBitOpenGlesSurface
192 Pass the RSgImage objects into eglCreateImageKHR() with
193 The target parameter set to EGL_NATIVE_PIXMAP_KHR
194 Use the current display and EGL_NO_CONTEXT
195 Use a NULL attr_list
196 Check that those calls to eglCreateImageKHR() returns EGL_NO_IMAGE_KHR
197 The following will only be exercised if OpenGL_ES2 is supported
198 Set the iUsage bits to ESgUsageBitOpenGles2Texture2D
199 Pass the RSgImage objects into eglCreateImageKHR() with
200 The target parameter set to EGL_NATIVE_PIXMAP_KHR
201 Use the current display and EGL_NO_CONTEXT
202 Use a NULL attr_list
203 Check that those calls to eglCreateImageKHR() do NOT return EGL_NO_IMAGE_KHR
204 Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface.
205 Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface
206 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the just created EGLImage.
207 This call should return VG_UNSUPPORTED_IMAGE_FORMAT_ERROR since the underlying RSgImage needs iUsage of ESgOpenVgImage to make this call succeed.
208 Pass the EGLImage into eglDestroyImageKHR()
211 Check for memory and handle leaks
213 @SYMTestExpectedResults
214 eglCreateImageKHR() does return EGL_BAD_PARAMETER
215 No memory or handle leaks
217 TVerdict CEglTest_EGL_Image_UsageBits_Enforcement::doTestStepL()
219 SetTestStepID(_L("GRAPHICS-EGL-0127"));
220 INFO_PRINTF1(_L("CEglTest_EGL_Image_UsageBits_Enforcement::doTestStepL"));
222 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
225 // The extension is not supported
227 CloseTMSGraphicsStep();
228 return TestStepResult();
231 // This test is performed for default pixel format
232 PrintUsedPixelConfiguration();
234 // Create display object
237 iEglSess->InitializeL();
238 iEglSess->OpenSgDriverL();
240 // Create a reference bitmap which we use to init the SgImage (we use index=8)
241 TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
242 CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
243 CleanupStack::PushL(bitmap);
245 // Create RSgImage's attributes.
246 TSgImageInfoTest imageInfo;
247 imageInfo.iSizeInPixels = KPixmapSize;
248 imageInfo.iPixelFormat = iSourceFormat;
249 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
250 imageInfo.iUsage = ESgUsageBitOpenGlesSurface;
252 imageInfo.iUsage = ESgUsageDirectGdiSource;
253 imageInfo.iShareable = EFalse;
254 imageInfo.iCpuAccess = ESgCpuAccessNone;
255 imageInfo.iScreenId = KSgScreenIdMain;
256 imageInfo.iUserAttributes = NULL;
257 imageInfo.iUserAttributeCount = 0;
258 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
261 CleanupClosePushL(sgImage);
262 ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
264 //First Subtest: Attempted creation of an EGLImageKhr from an RSgImage with the wrong Usage should fail
265 INFO_PRINTF1(_L("Attempt creation of an EGLImage from a RSgImage with incorrect iUsage ESgUsageBitOpenGlesSurface"));
266 INFO_PRINTF1(_L("Correct iUsage needs to have at least one of ESgUsageBitOpenVgImage, ESgUsageOpenGlesTexture2D or ESgUsageOpenGles2Texture2D bits set"));
268 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
269 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR);
270 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
271 CleanupStack::PopAndDestroy(&sgImage);
273 if(iEglSess->IsOpenGLES2Supported())
275 TSgImageInfoTest imageInfo2;
276 imageInfo2.iSizeInPixels = KPixmapSize;
277 imageInfo2.iPixelFormat = iSourceFormat;
278 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
279 imageInfo2.iUsage = ESgUsageBitOpenGles2Texture2D;
281 imageInfo2.iUsage = ESgUsageOpenGlesTexture2D;
282 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
286 CleanupClosePushL(sgImage2);
287 ASSERT_EQUALS(sgImage2.Create(imageInfo2, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
289 // The creation of an EGLImage from a RSgImage with correct usage (ESgUsageBitOpenGles2Texture2D or ESgUsageOpenGlesTexture2D) should pass
290 EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage2, KEglImageAttribsPreservedTrue);
291 ASSERT_EGL_TRUE(imageKHR2 != EGL_NO_IMAGE_KHR);
293 //Create an OffScreen Pixmap, we need it to make a Context current
294 imageInfo2.iSizeInPixels = KPixmapSize;
295 imageInfo2.iPixelFormat = iSourceFormat;
296 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
297 imageInfo2.iUsage = ESgUsageBitOpenVgSurface;
299 imageInfo2.iUsage = ESgUsageOpenVgTarget;
300 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
301 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2,CTestEglSession::EResourceCloseSgImageEarly);
303 // Create a VGImage from the EGLImage
304 //Second Subtest: creation of an VGImage from an EGLImage whose RSgImage has NOT ESgUsageBitOpenVgImage as usage will fail
305 VGImage vgImageTarget = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR2);
306 ASSERT_VG_TRUE(vgImageTarget == VG_INVALID_HANDLE);
307 ASSERT_TRUE(vgGetError()==VG_UNSUPPORTED_IMAGE_FORMAT_ERROR);
309 CleanupStack::PopAndDestroy(&sgImage2);
310 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2));
314 CleanupStack::PopAndDestroy(bitmap);
318 CloseTMSGraphicsStep();
319 return TestStepResult();
323 @SYMTestCaseID GRAPHICS-EGL-0128
329 @SYMREQ See SGL.GT0386.401 document
332 eglDestroyImageKHR handles correctly errors when given wrong input parameters.
335 Create a reference Bitmap
336 Create and fully construct an RSgImage object having the same content as the reference bitmap
337 Set the iUsage bit to ESgUsageBitOpenVgImage
338 Pass the RSgImage object into eglCreateImageKHR() with
339 The target parameter set to EGL_NATIVE_PIXMAP_KHR
340 Use the current display and EGL_NO_CONTEXT
341 Use a NULL attr_list
342 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR
343 Call eglDestroyImageKHR() sequentially with the following parameters:
344 1. Display equal to EGL_NO_DISPLAY
345 2. The EGLImageKHR is not a valid EGLImage handle
346 Destroy the image data
347 Pass the EGLImage into eglDestroyImageKHR()
349 Check for memory and handle leaks
351 @SYMTestExpectedResults
352 eglDestroyImageKHR generates the correct error code:
353 EGL_BAD_DISPLAY in the both case
355 TVerdict CEglTest_EGL_Image_DestroyImageKHR::doTestStepL()
357 SetTestStepID(_L("GRAPHICS-EGL-0128"));
358 INFO_PRINTF1(_L("CEglTest_EGL_Image_DestroyImageKHR::doTestStepL"));
360 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
363 // The extension is not supported
365 CloseTMSGraphicsStep();
366 return TestStepResult();
369 // This test is performed for default pixel format
370 PrintUsedPixelConfiguration();
372 // Create display object
375 iEglSess->InitializeL();
376 iEglSess->OpenSgDriverL();
378 INFO_PRINTF1(_L("Creating one RSgImage"));
379 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
380 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
381 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
384 CleanupClosePushL(sgImage);
385 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
387 INFO_PRINTF1(_L("Creating one EGLImage from it"));
388 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
389 ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
391 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with EGL_NO_DISPLAY"));
392 ASSERT_EGL_TRUE(!iEglSess->DestroyEGLImage(EGL_NO_DISPLAY, imageKHR));
393 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
395 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with a random number (but not 1) as Display"));
396 ASSERT_EGL_TRUE(!iEglSess->DestroyEGLImage(7, imageKHR));
397 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY);
399 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with valid EGLImage handle (so, that should succeed)"));
400 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
402 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with invalid handle"));
403 ASSERT_EGL_TRUE(!iEglSess->DestroyEGLImage(iDisplay, imageKHR));
404 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER);
407 CleanupStack::PopAndDestroy(&sgImage);
411 CloseTMSGraphicsStep();
412 return TestStepResult();
416 @SYMTestCaseID GRAPHICS-EGL-0129
422 @SYMREQ See SGL.GT0386.401 document
425 Any attemp to create a VGImage from a bad EGLImage handle has to fail.
428 Create a reference Bitmap
429 Create and fully construct an RSgImage object having the same content as the reference bitmap
430 Set the iUsage bit to ESgUsageBitOpenVgImage
431 Pass the RSgImage object into eglCreateImageKHR() with
432 The target parameter set to EGL_NATIVE_PIXMAP_KHR
433 Use the current display and EGL_NO_CONTEXT
434 Use a NULL attr_list
435 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR.
436 Create a surface and a current context.
437 Destroy the EGLImage but retain the handle value.
438 Try to create a VGImage from this invalid handle.
439 Check that the error VG_ILLEGAL_ARGUMENT_ERROR is raised.
440 Check for memory and handle leaks.
442 @SYMTestExpectedResults
443 vgCreateImageTargetKHR raises a VG_ILLEGAL_ARGUMENT_ERROR error.
444 Check for memory and handle leaks.
446 TVerdict CEglTest_EGL_Image_VGImage_From_Invalid_EGLHandle::doTestStepL()
448 SetTestStepID(_L("GRAPHICS-EGL-0129"));
449 INFO_PRINTF1(_L("CEglTest_VGImage_From_Invalid_EGLHandle::doTestStepL"));
451 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
454 // The extension is not supported
456 CloseTMSGraphicsStep();
457 return TestStepResult();
460 // This test is performed for default pixel format
461 PrintUsedPixelConfiguration();
463 // Create display object
466 iEglSess->InitializeL();
467 iEglSess->OpenSgDriverL();
469 INFO_PRINTF1(_L("Creating one RSgImage"));
470 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize);
471 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
472 imageInfo.iCpuAccess = ESgCpuAccessReadWrite;
475 CleanupClosePushL(sgImage);
476 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone);
478 INFO_PRINTF1(_L("Creating one EGLImage from it"));
479 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
480 ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
482 //Create a Surface and Link it to a Context bound to OpenVG
483 TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
484 TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
485 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly);
487 INFO_PRINTF1(_L("Destroying the EGLImage but retain the handle value"));
488 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
490 INFO_PRINTF1(_L("Attemptimg to create a VGImage from an invalid handle"));
491 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
492 ASSERT_VG_TRUE(vgImage == VG_INVALID_HANDLE);
493 ASSERT_TRUE(vgGetError()==VG_ILLEGAL_ARGUMENT_ERROR);
495 vgDestroyImage(vgImage);
496 ASSERT_TRUE(vgGetError()==VG_BAD_HANDLE_ERROR);
499 CleanupStack::PopAndDestroy(&sgImage);
503 CloseTMSGraphicsStep();
504 return TestStepResult();
508 @SYMTestCaseID GRAPHICS-EGL-0130
514 @SYMREQ See SGL.GT0386.401 document
517 When a RSgImage is used as both the source and target of a draw operation, then the operation should not panic.
518 However the outcome is undefined.
521 Create and fully construct an RSgImage object
522 Pass the RSgImage objects into eglCreateImageKHR() with
523 The target parameter set to EGL_NATIVE_PIXMAP_KHR
524 Use the current display and EGL_NO_CONTEXT
525 Use a NULL attr_list
526 Check that those calls to eglCreateImageKHR() do NOT return EGL_NO_IMAGE_KHR
527 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the just created EGLImage.
529 Create Pixmap Surface from the previous RSgImage and make it current in a way that is compatible as a target for the VGImage to be drawn to.
530 Set the iUsage bit to ESgUsageBitOpenVgSurface and ESgUsageBitOpenGlesSurface
531 Use OpenVG to draw a single patern to the left half of the VGImage created from the EGLImage.
532 Try to draw this VGImage to the right half of the pixmap surface currently linked to the context.
533 Call eglWaitClient() to finish the above drawing instructions synchronously.
534 Check that the pixmap contains expected pixel values.
535 Pass the VGImage into vgDestroyImage()
536 Pass the EGLImage into eglDestroyImageKHR()
539 Check for memory and handle leaks
541 @SYMTestExpectedResults
542 This test is not supposed to panic.
543 The contents, though, are undefined since we are reading from and writing to the same memory
544 No memory or handle leaks.
546 TVerdict CEglTest_EGL_Image_Self_Drawing::doTestStepL()
548 SetTestStepID(_L("GRAPHICS-EGL-0130"));
549 INFO_PRINTF1(_L("CEglTest_EGL_Image_Self_Drawing::doTestStepL"));
551 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
554 // The extension is not supported
556 CloseTMSGraphicsStep();
557 return TestStepResult();
560 // This test is performed for default pixel format
561 PrintUsedPixelConfiguration();
563 // Create display object
566 iEglSess->InitializeL();
567 iEglSess->OpenSgDriverL();
569 // Create a reference bitmap which we use to init the SgImage (we use index=8)
570 TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
571 CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8);
572 CleanupStack::PushL(bitmap);
574 INFO_PRINTF1(_L("Creating one RSgImage"));
575 TSgImageInfoTest imageInfo;
576 imageInfo.iSizeInPixels = KPixmapSize;
577 imageInfo.iPixelFormat = iSourceFormat;
578 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
579 imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
581 imageInfo.iUsage = ESgUsageOpenVgImage | ESgUsageOpenVgTarget;
582 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
584 CleanupClosePushL(sgImage);
585 ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(),bitmap->DataStride()), KErrNone);
587 INFO_PRINTF1(_L("Creating one EGLImage from it"));
588 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue);
589 ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR);
591 INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
592 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
594 EGLint numConfigsWithPre = 0;
595 EGLConfig configWithPre;
596 const EGLint KAttribImagePre[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&sgImage),
597 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
598 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
600 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KAttribImagePre, &configWithPre, 1, &numConfigsWithPre));
602 // Create a pixmap surface from the native image
603 INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
604 EGLSurface surface = eglCreatePixmapSurface(iDisplay, configWithPre, &sgImage, KPixmapAttribsVgAlphaFormatPre );
605 ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
607 // Create a context for drawing to/reading from the pixmap surface and make it current
608 INFO_PRINTF1(_L("Calling eglCreateContext"));
609 EGLContext context = eglCreateContext(iDisplay, configWithPre, EGL_NO_CONTEXT, NULL);
610 ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT);
612 INFO_PRINTF1(_L("Calling eglMakeCurrent"));
613 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context));
615 // Create a VGImage from the EGLImage
616 INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage"));
617 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR);
618 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE);
620 //Copy the source VGImage to the surface
621 vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
622 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
626 vgDestroyImage(vgImage);
627 ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
628 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR));
629 CleanupStack::PopAndDestroy(2, bitmap); // bitmap, sgImage
630 //This test doesn't check the drawing because the content of the image are undefined
631 //since we are using the same buffer both as target and as source
632 //The main purpose of this test is to ensure we don't get a panic
633 ASSERT_EGL_TRUE(eglDestroyContext(iDisplay, context)); //Closing eglContext
634 context = EGL_NO_CONTEXT;
635 ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface)); //Destroying Target Surface handle
639 CloseTMSGraphicsStep();
640 return TestStepResult();