|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 */ |
|
20 |
|
21 #include <test/tefunit.h> // for ASSERT macros |
|
22 |
|
23 #include "egltest_image_negative.h" |
|
24 |
|
25 #include <test/egltestcommonconversion.h> |
|
26 #include <test/egltestcommonsgimageinfo.h> |
|
27 |
|
28 /** |
|
29 @SYMTestCaseID GRAPHICS-EGL-0126 |
|
30 |
|
31 @SYMTestPriority 1 |
|
32 |
|
33 @SYMPREQ 39 |
|
34 |
|
35 @SYMREQ See SGL.GT0386.401 document |
|
36 |
|
37 @SYMTestCaseDesc |
|
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 |
|
41 |
|
42 @SYMTestActions |
|
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 |
|
50 |
|
51 |
|
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 |
|
57 */ |
|
58 TVerdict CEglTest_EGL_Image_eglCreateImage_Bad_Parameter::doTestStepL() |
|
59 { |
|
60 SetTestStepID(_L("GRAPHICS-EGL-0126")); |
|
61 INFO_PRINTF1(_L("CEglTest_EGL_Image_eglCreateImage_Bad_Parameter::doTestStepL")); |
|
62 |
|
63 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); |
|
64 if(!ret) |
|
65 { |
|
66 // The extension is not supported |
|
67 RecordTestResultL(); |
|
68 CloseTMSGraphicsStep(); |
|
69 return TestStepResult(); |
|
70 } |
|
71 |
|
72 // This test is performed for default pixel format |
|
73 PrintUsedPixelConfiguration(); |
|
74 |
|
75 // Create display object |
|
76 GetDisplayL(); |
|
77 CreateEglSessionL(); |
|
78 iEglSess->InitializeL(); |
|
79 iEglSess->OpenSgDriverL(); |
|
80 |
|
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); |
|
85 |
|
86 INFO_PRINTF1(_L("Creating one EGLImage from a not fully constructed RSgImage")); |
|
87 RSgImage sgImage; |
|
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); |
|
92 |
|
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; |
|
99 #else |
|
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 |
|
108 |
|
109 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone); |
|
110 |
|
111 //Creating a Valid Context |
|
112 INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)")); |
|
113 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API)); |
|
114 |
|
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); |
|
120 |
|
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); |
|
125 |
|
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); |
|
130 |
|
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); |
|
135 |
|
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); |
|
140 |
|
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); |
|
145 |
|
146 INFO_PRINTF1(_L("Calling with an invalid attribute list")); |
|
147 EGLint KEglImageAttribsInvalid[] = |
|
148 { |
|
149 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT, |
|
150 EGL_NONE |
|
151 }; |
|
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); |
|
155 |
|
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[] = |
|
158 { |
|
159 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE |
|
160 }; |
|
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); |
|
164 |
|
165 //cleanup |
|
166 ASSERT_EGL_TRUE(eglDestroyContext(iDisplay, context)); |
|
167 CleanupStack::PopAndDestroy(&sgImage); |
|
168 CleanAll(); |
|
169 |
|
170 RecordTestResultL(); |
|
171 CloseTMSGraphicsStep(); |
|
172 return TestStepResult(); |
|
173 } |
|
174 |
|
175 /** |
|
176 @SYMTestCaseID GRAPHICS-EGL-0127 |
|
177 |
|
178 @SYMTestPriority 1 |
|
179 |
|
180 @SYMPREQ 39 |
|
181 |
|
182 @SYMREQ See SGL.GT0386.401 document |
|
183 |
|
184 @SYMTestCaseDesc |
|
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. |
|
187 |
|
188 @SYMTestActions |
|
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() |
|
209 Close the RSgImage |
|
210 Destroy the pixmap |
|
211 Check for memory and handle leaks |
|
212 |
|
213 @SYMTestExpectedResults |
|
214 eglCreateImageKHR() does return EGL_BAD_PARAMETER |
|
215 No memory or handle leaks |
|
216 */ |
|
217 TVerdict CEglTest_EGL_Image_UsageBits_Enforcement::doTestStepL() |
|
218 { |
|
219 SetTestStepID(_L("GRAPHICS-EGL-0127")); |
|
220 INFO_PRINTF1(_L("CEglTest_EGL_Image_UsageBits_Enforcement::doTestStepL")); |
|
221 |
|
222 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); |
|
223 if(!ret) |
|
224 { |
|
225 // The extension is not supported |
|
226 RecordTestResultL(); |
|
227 CloseTMSGraphicsStep(); |
|
228 return TestStepResult(); |
|
229 } |
|
230 |
|
231 // This test is performed for default pixel format |
|
232 PrintUsedPixelConfiguration(); |
|
233 |
|
234 // Create display object |
|
235 GetDisplayL(); |
|
236 CreateEglSessionL(); |
|
237 iEglSess->InitializeL(); |
|
238 iEglSess->OpenSgDriverL(); |
|
239 |
|
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); |
|
244 |
|
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; |
|
251 #else |
|
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 |
|
259 |
|
260 RSgImage sgImage; |
|
261 CleanupClosePushL(sgImage); |
|
262 ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); |
|
263 |
|
264 //First Subtest: creation of an EGLImageKhr with wrong Usage will fail |
|
265 INFO_PRINTF1(_L("Trying to create an EGLImage from a RSgImage that doesn't have correct iUsage, ESgUsageBitOpenVgImage|ESgUsageOpenGlesTexture2D|ESgUsageOpenGles2Texture2D")); |
|
266 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue); |
|
267 ASSERT_EGL_TRUE(imageKHR == EGL_NO_IMAGE_KHR); |
|
268 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER); |
|
269 CleanupStack::PopAndDestroy(&sgImage); |
|
270 |
|
271 if(iEglSess->IsOpenGLES2Supported()) |
|
272 { |
|
273 TSgImageInfoTest imageInfo2; |
|
274 imageInfo2.iSizeInPixels = KPixmapSize; |
|
275 imageInfo2.iPixelFormat = iSourceFormat; |
|
276 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
277 imageInfo2.iUsage = ESgUsageBitOpenGles2Texture2D; |
|
278 #else |
|
279 imageInfo2.iUsage = ESgUsageOpenGlesTexture2D; |
|
280 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
281 |
|
282 // Create a SgImage |
|
283 RSgImage sgImage2; |
|
284 CleanupClosePushL(sgImage2); |
|
285 ASSERT_EQUALS(sgImage2.Create(imageInfo2, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); |
|
286 |
|
287 // Create a EGLImage from the RSgImage |
|
288 EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage2, KEglImageAttribsPreservedTrue); |
|
289 ASSERT_EGL_TRUE(imageKHR2 == EGL_NO_IMAGE_KHR); |
|
290 |
|
291 //Create an OffScreen Pixmap, we need it to make a Context current |
|
292 imageInfo2.iSizeInPixels = KPixmapSize; |
|
293 imageInfo2.iPixelFormat = iSourceFormat; |
|
294 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
295 imageInfo2.iUsage = ESgUsageBitOpenVgSurface; |
|
296 #else |
|
297 imageInfo2.iUsage = ESgUsageOpenVgTarget; |
|
298 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
299 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2,CTestEglSession::EResourceCloseSgImageEarly); |
|
300 |
|
301 // Create a VGImage from the EGLImage |
|
302 //Second Subtest: creation of an VGImage from an EGLImage whose RSgImage has NOT ESgUsageBitOpenVgImage as usage will fail |
|
303 VGImage vgImageTarget = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR2); |
|
304 ASSERT_VG_TRUE(vgImageTarget == VG_INVALID_HANDLE); |
|
305 ASSERT_TRUE(vgGetError()==VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); |
|
306 |
|
307 CleanupStack::PopAndDestroy(&sgImage2); |
|
308 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2)); |
|
309 } |
|
310 |
|
311 //cleanup |
|
312 CleanupStack::PopAndDestroy(bitmap); |
|
313 CleanAll(); |
|
314 |
|
315 RecordTestResultL(); |
|
316 CloseTMSGraphicsStep(); |
|
317 return TestStepResult(); |
|
318 } |
|
319 |
|
320 /** |
|
321 @SYMTestCaseID GRAPHICS-EGL-0128 |
|
322 |
|
323 @SYMTestPriority 1 |
|
324 |
|
325 @SYMPREQ 39 |
|
326 |
|
327 @SYMREQ See SGL.GT0386.401 document |
|
328 |
|
329 @SYMTestCaseDesc |
|
330 eglDestroyImageKHR handles correctly errors when given wrong input parameters. |
|
331 |
|
332 @SYMTestActions |
|
333 Create a reference Bitmap |
|
334 Create and fully construct an RSgImage object having the same content as the reference bitmap |
|
335 Set the iUsage bit to ESgUsageBitOpenVgImage |
|
336 Pass the RSgImage object into eglCreateImageKHR() with |
|
337 The target parameter set to EGL_NATIVE_PIXMAP_KHR |
|
338 Use the current display and EGL_NO_CONTEXT |
|
339 Use a NULL attr_list |
|
340 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR |
|
341 Call eglDestroyImageKHR() sequentially with the following parameters: |
|
342 1. Display equal to EGL_NO_DISPLAY |
|
343 2. The EGLImageKHR is not a valid EGLImage handle |
|
344 Destroy the image data |
|
345 Pass the EGLImage into eglDestroyImageKHR() |
|
346 Close RSgImage |
|
347 Check for memory and handle leaks |
|
348 |
|
349 @SYMTestExpectedResults |
|
350 eglDestroyImageKHR generates the correct error code: |
|
351 EGL_BAD_DISPLAY in the both case |
|
352 */ |
|
353 TVerdict CEglTest_EGL_Image_DestroyImageKHR::doTestStepL() |
|
354 { |
|
355 SetTestStepID(_L("GRAPHICS-EGL-0128")); |
|
356 INFO_PRINTF1(_L("CEglTest_EGL_Image_DestroyImageKHR::doTestStepL")); |
|
357 |
|
358 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); |
|
359 if(!ret) |
|
360 { |
|
361 // The extension is not supported |
|
362 RecordTestResultL(); |
|
363 CloseTMSGraphicsStep(); |
|
364 return TestStepResult(); |
|
365 } |
|
366 |
|
367 // This test is performed for default pixel format |
|
368 PrintUsedPixelConfiguration(); |
|
369 |
|
370 // Create display object |
|
371 GetDisplayL(); |
|
372 CreateEglSessionL(); |
|
373 iEglSess->InitializeL(); |
|
374 iEglSess->OpenSgDriverL(); |
|
375 |
|
376 INFO_PRINTF1(_L("Creating one RSgImage")); |
|
377 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize); |
|
378 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
379 imageInfo.iCpuAccess = ESgCpuAccessReadWrite; |
|
380 #endif |
|
381 RSgImage sgImage; |
|
382 CleanupClosePushL(sgImage); |
|
383 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone); |
|
384 |
|
385 INFO_PRINTF1(_L("Creating one EGLImage from it")); |
|
386 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue); |
|
387 ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR); |
|
388 |
|
389 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with EGL_NO_DISPLAY")); |
|
390 ASSERT_EGL_TRUE(!iEglSess->DestroyEGLImage(EGL_NO_DISPLAY, imageKHR)); |
|
391 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY); |
|
392 |
|
393 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with a random number (but not 1) as Display")); |
|
394 ASSERT_EGL_TRUE(!iEglSess->DestroyEGLImage(7, imageKHR)); |
|
395 ASSERT_EGL_ERROR(EGL_BAD_DISPLAY); |
|
396 |
|
397 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with valid EGLImage handle (so, that should succeed)")); |
|
398 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); |
|
399 |
|
400 INFO_PRINTF1(_L("Calling eglDestroyImageKHR with invalid handle")); |
|
401 ASSERT_EGL_TRUE(!iEglSess->DestroyEGLImage(iDisplay, imageKHR)); |
|
402 ASSERT_EGL_ERROR(EGL_BAD_PARAMETER); |
|
403 |
|
404 //cleanup |
|
405 CleanupStack::PopAndDestroy(&sgImage); |
|
406 CleanAll(); |
|
407 |
|
408 RecordTestResultL(); |
|
409 CloseTMSGraphicsStep(); |
|
410 return TestStepResult(); |
|
411 } |
|
412 |
|
413 /** |
|
414 @SYMTestCaseID GRAPHICS-EGL-0129 |
|
415 |
|
416 @SYMTestPriority 1 |
|
417 |
|
418 @SYMPREQ 39 |
|
419 |
|
420 @SYMREQ See SGL.GT0386.401 document |
|
421 |
|
422 @SYMTestCaseDesc |
|
423 Any attemp to create a VGImage from a bad EGLImage handle has to fail. |
|
424 |
|
425 @SYMTestActions |
|
426 Create a reference Bitmap |
|
427 Create and fully construct an RSgImage object having the same content as the reference bitmap |
|
428 Set the iUsage bit to ESgUsageBitOpenVgImage |
|
429 Pass the RSgImage object into eglCreateImageKHR() with |
|
430 The target parameter set to EGL_NATIVE_PIXMAP_KHR |
|
431 Use the current display and EGL_NO_CONTEXT |
|
432 Use a NULL attr_list |
|
433 Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR. |
|
434 Create a surface and a current context. |
|
435 Destroy the EGLImage but retain the handle value. |
|
436 Try to create a VGImage from this invalid handle. |
|
437 Check that the error VG_ILLEGAL_ARGUMENT_ERROR is raised. |
|
438 Check for memory and handle leaks. |
|
439 |
|
440 @SYMTestExpectedResults |
|
441 vgCreateImageTargetKHR raises a VG_ILLEGAL_ARGUMENT_ERROR error. |
|
442 Check for memory and handle leaks. |
|
443 */ |
|
444 TVerdict CEglTest_EGL_Image_VGImage_From_Invalid_EGLHandle::doTestStepL() |
|
445 { |
|
446 SetTestStepID(_L("GRAPHICS-EGL-0129")); |
|
447 INFO_PRINTF1(_L("CEglTest_VGImage_From_Invalid_EGLHandle::doTestStepL")); |
|
448 |
|
449 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); |
|
450 if(!ret) |
|
451 { |
|
452 // The extension is not supported |
|
453 RecordTestResultL(); |
|
454 CloseTMSGraphicsStep(); |
|
455 return TestStepResult(); |
|
456 } |
|
457 |
|
458 // This test is performed for default pixel format |
|
459 PrintUsedPixelConfiguration(); |
|
460 |
|
461 // Create display object |
|
462 GetDisplayL(); |
|
463 CreateEglSessionL(); |
|
464 iEglSess->InitializeL(); |
|
465 iEglSess->OpenSgDriverL(); |
|
466 |
|
467 INFO_PRINTF1(_L("Creating one RSgImage")); |
|
468 TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize); |
|
469 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
470 imageInfo.iCpuAccess = ESgCpuAccessReadWrite; |
|
471 #endif |
|
472 RSgImage sgImage; |
|
473 CleanupClosePushL(sgImage); |
|
474 ASSERT_EQUALS(sgImage.Create(imageInfo, NULL, NULL), KErrNone); |
|
475 |
|
476 INFO_PRINTF1(_L("Creating one EGLImage from it")); |
|
477 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue); |
|
478 ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR); |
|
479 |
|
480 //Create a Surface and Link it to a Context bound to OpenVG |
|
481 TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat); |
|
482 TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize); |
|
483 iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly); |
|
484 |
|
485 INFO_PRINTF1(_L("Destroying the EGLImage but retain the handle value")); |
|
486 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); |
|
487 |
|
488 INFO_PRINTF1(_L("Attemptimg to create a VGImage from an invalid handle")); |
|
489 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR); |
|
490 ASSERT_VG_TRUE(vgImage == VG_INVALID_HANDLE); |
|
491 ASSERT_TRUE(vgGetError()==VG_ILLEGAL_ARGUMENT_ERROR); |
|
492 |
|
493 vgDestroyImage(vgImage); |
|
494 ASSERT_TRUE(vgGetError()==VG_BAD_HANDLE_ERROR); |
|
495 |
|
496 //cleanup |
|
497 CleanupStack::PopAndDestroy(&sgImage); |
|
498 CleanAll(); |
|
499 |
|
500 RecordTestResultL(); |
|
501 CloseTMSGraphicsStep(); |
|
502 return TestStepResult(); |
|
503 } |
|
504 |
|
505 /** |
|
506 @SYMTestCaseID GRAPHICS-EGL-0130 |
|
507 |
|
508 @SYMTestPriority 1 |
|
509 |
|
510 @SYMPREQ 39 |
|
511 |
|
512 @SYMREQ See SGL.GT0386.401 document |
|
513 |
|
514 @SYMTestCaseDesc |
|
515 When a RSgImage is used as both the source and target of a draw operation, then the operation should not panic. |
|
516 However the outcome is undefined. |
|
517 |
|
518 @SYMTestActions |
|
519 Create and fully construct an RSgImage object |
|
520 Pass the RSgImage objects into eglCreateImageKHR() with |
|
521 The target parameter set to EGL_NATIVE_PIXMAP_KHR |
|
522 Use the current display and EGL_NO_CONTEXT |
|
523 Use a NULL attr_list |
|
524 Check that those calls to eglCreateImageKHR() do NOT return EGL_NO_IMAGE_KHR |
|
525 Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the just created EGLImage. |
|
526 Check for errors |
|
527 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. |
|
528 Set the iUsage bit to ESgUsageBitOpenVgSurface and ESgUsageBitOpenGlesSurface |
|
529 Use OpenVG to draw a single patern to the left half of the VGImage created from the EGLImage. |
|
530 Try to draw this VGImage to the right half of the pixmap surface currently linked to the context. |
|
531 Call eglWaitClient() to finish the above drawing instructions synchronously. |
|
532 Check that the pixmap contains expected pixel values. |
|
533 Pass the VGImage into vgDestroyImage() |
|
534 Pass the EGLImage into eglDestroyImageKHR() |
|
535 Close the RSgImage |
|
536 Destroy the pixmap |
|
537 Check for memory and handle leaks |
|
538 |
|
539 @SYMTestExpectedResults |
|
540 This test is not supposed to panic. |
|
541 The contents, though, are undefined since we are reading from and writing to the same memory |
|
542 No memory or handle leaks. |
|
543 */ |
|
544 TVerdict CEglTest_EGL_Image_Self_Drawing::doTestStepL() |
|
545 { |
|
546 SetTestStepID(_L("GRAPHICS-EGL-0130")); |
|
547 INFO_PRINTF1(_L("CEglTest_EGL_Image_Self_Drawing::doTestStepL")); |
|
548 |
|
549 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); |
|
550 if(!ret) |
|
551 { |
|
552 // The extension is not supported |
|
553 RecordTestResultL(); |
|
554 CloseTMSGraphicsStep(); |
|
555 return TestStepResult(); |
|
556 } |
|
557 |
|
558 // This test is performed for default pixel format |
|
559 PrintUsedPixelConfiguration(); |
|
560 |
|
561 // Create display object |
|
562 GetDisplayL(); |
|
563 CreateEglSessionL(); |
|
564 iEglSess->InitializeL(); |
|
565 iEglSess->OpenSgDriverL(); |
|
566 |
|
567 // Create a reference bitmap which we use to init the SgImage (we use index=8) |
|
568 TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat); |
|
569 CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 8); |
|
570 CleanupStack::PushL(bitmap); |
|
571 |
|
572 INFO_PRINTF1(_L("Creating one RSgImage")); |
|
573 TSgImageInfoTest imageInfo; |
|
574 imageInfo.iSizeInPixels = KPixmapSize; |
|
575 imageInfo.iPixelFormat = iSourceFormat; |
|
576 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
577 imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; |
|
578 #else |
|
579 imageInfo.iUsage = ESgUsageOpenVgImage | ESgUsageOpenVgTarget; |
|
580 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
581 RSgImage sgImage; |
|
582 CleanupClosePushL(sgImage); |
|
583 ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(),bitmap->DataStride()), KErrNone); |
|
584 |
|
585 INFO_PRINTF1(_L("Creating one EGLImage from it")); |
|
586 EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue); |
|
587 ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR); |
|
588 |
|
589 INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)")); |
|
590 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API)); |
|
591 |
|
592 EGLint numConfigsWithPre = 0; |
|
593 EGLConfig configWithPre; |
|
594 const EGLint KAttribImagePre[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&sgImage), |
|
595 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, |
|
596 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, |
|
597 EGL_NONE }; |
|
598 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KAttribImagePre, &configWithPre, 1, &numConfigsWithPre)); |
|
599 |
|
600 // Create a pixmap surface from the native image |
|
601 INFO_PRINTF1(_L("Calling eglCreatePixmapSurface")); |
|
602 EGLSurface surface = eglCreatePixmapSurface(iDisplay, configWithPre, &sgImage, KPixmapAttribsVgAlphaFormatPre ); |
|
603 ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE); |
|
604 |
|
605 // Create a context for drawing to/reading from the pixmap surface and make it current |
|
606 INFO_PRINTF1(_L("Calling eglCreateContext")); |
|
607 EGLContext context = eglCreateContext(iDisplay, configWithPre, EGL_NO_CONTEXT, NULL); |
|
608 ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT); |
|
609 |
|
610 INFO_PRINTF1(_L("Calling eglMakeCurrent")); |
|
611 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context)); |
|
612 |
|
613 // Create a VGImage from the EGLImage |
|
614 INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage")); |
|
615 VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR); |
|
616 ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE); |
|
617 |
|
618 //Copy the source VGImage to the surface |
|
619 vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); |
|
620 ASSERT_TRUE(vgGetError()==VG_NO_ERROR); |
|
621 eglWaitClient(); |
|
622 |
|
623 //cleanup |
|
624 vgDestroyImage(vgImage); |
|
625 ASSERT_TRUE(vgGetError()==VG_NO_ERROR); |
|
626 ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); |
|
627 CleanupStack::PopAndDestroy(2, bitmap); // bitmap, sgImage |
|
628 //This test doesn't check the drawing because the content of the image are undefined |
|
629 //since we are using the same buffer both as target and as source |
|
630 //The main purpose of this test is to ensure we don't get a panic |
|
631 ASSERT_EGL_TRUE(eglDestroyContext(iDisplay, context)); //Closing eglContext |
|
632 context = EGL_NO_CONTEXT; |
|
633 ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface)); //Destroying Target Surface handle |
|
634 CleanAll(); |
|
635 |
|
636 RecordTestResultL(); |
|
637 CloseTMSGraphicsStep(); |
|
638 return TestStepResult(); |
|
639 } |