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 "egltest_createpixmapsurface.h"
23 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
24 #include <sgresource/sgimage.h>
26 #include <graphics/sgimage.h>
27 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
28 #include <test/tefunit.h> // for ASSERT macros
30 #include <test/egltestcommonconversion.h>
31 #include <test/egltestcommoninisettings.h>
32 #include <test/egltestcommonsgimageinfo.h>
37 @SYMTestCaseID GRAPHICS-EGL-0063
43 @SYMREQ See SGL.GT0386.401 document
46 This test ensures the matching algorithm between EGLConfig and RSgImages when the RSgImage format is EUidPixelFormatARGB_8888_PRE.
47 The algorithm is tested in both eglChooseConfig and eglCreatePixmap.
50 Create an RSgImage format with the following parameters:
51 * format: EUidPixelFormatARGB_8888_PRE
52 * usage: ESgUsageBitOpenVgSurface
53 Create second RSgImage format with the following parameters:
54 * format: EUidPixelFormatXRGB_8888
55 * usage: ESgUsageBitOpenVgSurface
57 Query a compatible config via eglChooseConfig.
58 If we get one compatible config check that is accepted by eglCreatePixmapSurface.
59 1) call eglCreatePixmap with the just queried config and as attribute:
60 * EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE
61 * as native pixmap format supply RSgImage with premultiply alpha
62 This call has to fail and give back a EGL_BAD_MATCH error.
63 2) call eglCreatePixmapSurface with the just queried config and as attribute:
64 * EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE
65 * as native pixmap format supply RSgImage with non-premultiply alpha
66 This call has to fail and give back a EGL_BAD_MATCH error.
67 3) call eglCreatePixmapSurface with the just queried config and as attribute:
68 * EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE
69 This call has to succed.
70 No memory or handle leaks.
72 @SYMTestExpectedResults
73 The first and second calls to eglCreatePixmapSurface have to fail and give back a EGL_BAD_MATCH error.
74 The third call has to succed.
75 No memory or handle leaks.
77 TVerdict CEglTest_CreatePixmapSurface_Alpha_bit_RSgImage::doTestStepL()
79 SetTestStepID(_L("GRAPHICS-EGL-0063"));
80 INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_Alpha_bit_RSgImage::doTestPartialStepL"));
82 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap);
85 // The extension is not supported
87 CloseTMSGraphicsStep();
88 return TestStepResult();
91 // Create display object
93 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
94 eglSess->InitializeL();
96 eglSess->OpenSgDriverL();
97 TSgImageInfoOpenVgTarget imageInfo = TSgImageInfoOpenVgTarget(EUidPixelFormatARGB_8888_PRE);
98 RSgImage sgImageWithPre;
99 // Create a SgImage ARGB_8888_PRE
100 CleanupClosePushL(sgImageWithPre);
101 ret = sgImageWithPre.Create(imageInfo, NULL, NULL);
102 ASSERT_EQUALS(ret, KErrNone);
104 EGLint numConfigsWithPre = 0;
105 EGLConfig configWithPre[KMaxEglConfigs];
106 const EGLint KAttrib_list_ImageWithPre[] = { EGL_MATCH_NATIVE_PIXMAP, (TInt)&sgImageWithPre,
107 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
108 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
111 INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set"));
112 eglChooseConfig(iDisplay,KAttrib_list_ImageWithPre,configWithPre,KMaxEglConfigs,&numConfigsWithPre);
113 if(!numConfigsWithPre)
115 ERR_PRINTF1(_L("No EGL Config with EGL_VG_ALPHA_FORMAT_PRE available for EUidPixelFormatARGB_8888_PRE"));
116 SetTestStepResult(EFail);
119 for(TInt index = 0; index < numConfigsWithPre; index++)
121 INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
122 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
124 INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
125 eglSess->SetExpectedError(EGL_BAD_MATCH);
126 EGLSurface surface = eglCreatePixmapSurface(iDisplay, configWithPre[index],&sgImageWithPre, KPixmapAttribsVgAlphaFormatNonPre);
127 if ( !eglSess->CheckExpectedError(EGL_FALSE) )
129 ERR_PRINTF1(_L("eglCreatePixmapSurface didn't fail as expected."));
130 SetTestStepResult(EFail);
131 if(surface != EGL_NO_SURFACE)
133 eglDestroySurface(iDisplay,surface);
134 eglSess->CheckExpectedError(EGL_SUCCESS);
135 surface = EGL_NO_SURFACE;
139 surface = eglCreatePixmapSurface(iDisplay, configWithPre[index],&sgImageWithPre, KPixmapAttribsVgAlphaFormatPre);
140 if ( !eglSess->CheckExpectedError(EGL_TRUE) )
142 ERR_PRINTF1(_L("eglCreatePixmapSurface failed."));
143 SetTestStepResult(EFail);
145 if(surface != EGL_NO_SURFACE)
147 eglDestroySurface(iDisplay,surface);
148 eglSess->CheckExpectedError(EGL_SUCCESS);
149 surface = EGL_NO_SURFACE;
153 CleanupStack::PopAndDestroy(2,eglSess);
156 CloseTMSGraphicsStep();
157 return TestStepResult();
162 @SYMTestCaseID GRAPHICS-EGL-0066
168 @SYMREQ See SGL.GT0386.401 document
171 Test passing a non-initialised RSgImage into eglCreatePixmapSurface()
174 Initialise the thread to use RSgImage as the native pixmap type
175 For each config returned from eglGetConfig() that supports OpenGLES or OpenVG rendering to pixmaps
176 * Create an empty RSgImage object but do not initialize it
177 * Use eglCreatePixmapSurface() to construct a surface from the RSgImage object.
178 o Use a NULL attrib_list
179 * Close the RSgImage object
181 @SYMTestExpectedResults
182 Check that eglCreatePixmapSurface() returns EGL_NO_SURFACE
183 Check that eglGetError() returns EGL_BAD_NATIVE_PIXMAP
184 Check for memory and handle leaks.
186 TVerdict CEglTest_CreatePixmapSurface_RSgImage_Negative_RSgImage_NotInitialised::doTestStepL()
188 SetTestStepID(_L("GRAPHICS-EGL-0066"));
189 INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_RSgImage_Negative_RSgImage_NotInitialised::doTestStepL"));
191 TBool ret = CheckForExtensionL(KEGL_RSgimage);
194 // The extension is not supported
196 CloseTMSGraphicsStep();
197 return TestStepResult();
200 // Create display object
202 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
203 eglSess->InitializeL();
205 EGLConfig configs[KMaxEglConfigs];
208 // Query number of configs available
209 INFO_PRINTF1(_L("Calling eglGetConfigs to get the number of configs available..."));
210 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
212 INFO_PRINTF1(_L("Checking number of configs..."));
213 ASSERT_TRUE(numConfigs >= 1);
214 ASSERT_TRUE(numConfigs <= KMaxEglConfigs);
215 INFO_PRINTF2(_L("Found %d configs"), numConfigs);
218 INFO_PRINTF1(_L("Calling eglGetConfigs to get configs..."));
219 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay, configs, KMaxEglConfigs, &numConfigs));
221 for(TUint index = 0; index < numConfigs; index++)
223 INFO_PRINTF2(_L("Getting Config Attributes for index %d"), index);
225 EGLint surfaceType=0;
226 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, configs[index], EGL_SURFACE_TYPE, &surfaceType));
227 if (!(surfaceType & EGL_PIXMAP_BIT))
229 // This is just an info print because we don't want to test surfaces that do not support pixmaps.
230 VERBOSE_INFO_PRINTF1(_L("Skipping config: Does not support pixmaps"));
234 EGLint renderableType=0;
235 RSgImage sgImage; // Deliberately don't initialise it
236 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &renderableType));
237 if (renderableType & EGL_OPENVG_BIT)
239 VERBOSE_INFO_PRINTF1(_L("...is OpenVg renderable"));
240 eglSess->OpenSgDriverL();
242 // Need to set the API type before creating the context (H/W requires this to be done before the surface is created, rather than the context)
243 VERBOSE_INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)"));
244 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
246 // Create a pixmap surface from the native image
247 VERBOSE_INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
248 EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[index], &sgImage, KPixmapAttribsNone);
250 // Expect this to fail
251 ASSERT_EQUALS(surface, EGL_NO_SURFACE);
252 ASSERT_EGL_ERROR(EGL_BAD_NATIVE_PIXMAP);
253 eglSess->CloseSgDriver();
256 if ((renderableType & EGL_OPENGL_ES_BIT) || (renderableType & EGL_OPENGL_ES2_BIT))
258 VERBOSE_INFO_PRINTF1(_L("...is OpenGles renderable"));
259 eglSess->OpenSgDriverL();
261 // Need to set the API type before creating the context (H/W requires this to be done before the surface is created, rather than the context)
262 VERBOSE_INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENGL_ES_API)"));
263 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENGL_ES_API));
265 // Create a pixmap surface from the native image
266 VERBOSE_INFO_PRINTF1(_L("Calling eglCreatePixmapSurface"));
267 EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[index], &sgImage, KPixmapAttribsNone);
269 // Expect this to fail
270 ASSERT_EQUALS(surface, EGL_NO_SURFACE);
271 ASSERT_EGL_ERROR(EGL_BAD_NATIVE_PIXMAP);
272 eglSess->CloseSgDriver();
276 CleanupStack::PopAndDestroy(eglSess);
279 CloseTMSGraphicsStep();
280 return TestStepResult();
284 @SYMTestCaseID GRAPHICS-EGL-0075
290 @SYMREQ See SGL.GT0386.401 document
293 Test that the system can detect obviously invalid pixmap objects
296 Try to create a pixmap surface from an odd integer
298 @SYMTestExpectedResults
299 This should fail with EGL_BAD_NATIVE_PIXMAP
300 Check that all memory and handles have been deallocated.
302 TVerdict CEglTest_CreatePixmapSurface_Negative_Invalid_Pixmap_Type::doTestStepL()
304 SetTestStepID(_L("GRAPHICS-EGL-0075"));
305 INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_Negative_Invalid_Pixmap_Type::doTestStepL"));
307 // Create display object
310 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
312 // Initialise the display object
313 eglSess->InitializeL();
314 eglSess->OpenSgDriverL();
316 EGLConfig configs[KMaxEglConfigs];
319 const EGLint KConfigAttribPixmapSurface[] =
321 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
322 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
326 // Query number of configs available
327 INFO_PRINTF1(_L("Calling eglChooseConfig to get the number of configs available for pixmap surfaces..."));
328 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribPixmapSurface, NULL, KMaxTInt, &numConfigs));
330 INFO_PRINTF1(_L("Checking number of configs..."));
331 ASSERT_TRUE(numConfigs >= 1);
332 ASSERT_TRUE(numConfigs <= KMaxEglConfigs);
333 INFO_PRINTF2(_L("Found %d configs"), numConfigs);
336 INFO_PRINTF1(_L("Calling eglChooseConfig to get configs..."));
337 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribPixmapSurface, configs, KMaxEglConfigs, &numConfigs));
339 EGLint badPixmap=12345;
341 EGLSurface surface = eglCreatePixmapSurface(iDisplay, configs[0], &badPixmap, NULL);
342 eglSess->SetExpectedError(EGL_BAD_NATIVE_PIXMAP);
343 ASSERT_TRUE(eglSess->CheckExpectedError(surface));
345 CleanupStack::PopAndDestroy(eglSess);
348 CloseTMSGraphicsStep();
349 return TestStepResult();
353 @SYMTestCaseID GRAPHICS-EGL-0420
359 @SYMREQ See SGL.GT0386.401 document
362 Test the successful creation and use of a pixmap surface for all supporting configs.
365 Initialize the thread to use RSgImage as the native pixmap type.
366 For each supported combination of pixel mode and usage bits (see Graphics Resource documentation for detail)
368 • Choose EGL config, supplying in attribute list as EGL_MATCH_NATIVE_PIXMAP the SgImage created on the previous step
369 • For each configuration obtained on the previous step and for three possible resource close rules (close SgImage late, close SgImage early, close SgDriver and SgImage early):
370 o Use eglCreatePixmapSurface() to construct a surface from the RSgImage object and make it current
371 o Make some basic drawing to the surface (fill the area with pre-defined colour)
372 o Call eglWaitClient() to finish the above drawing instructions synchronously.
373 o Deallocate the surface and the pixmap
375 @SYMTestExpectedResults
376 There is at least one configuration available for all mandatory combinations of pixel formats and usage bits.
377 Use EGL client API to check that the surface with underlying SgImage has the expected pixel data.
379 TVerdict CEglTest_CreatePixmapSurface_RSgImage_Positive_MantadoryFormatUsageSupport::doTestStepL()
381 SetTestStepID(_L("GRAPHICS-EGL-0420"));
382 INFO_PRINTF1(_L("CEglTest_CreatePixmapSurface_RSgImage_Positive_MantadoryFormatUsageSupport::doTestStepL"));
384 TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap);
387 // The extension is not supported
389 CloseTMSGraphicsStep();
390 return TestStepResult();
393 // Create display object
395 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
396 eglSess->InitializeL();
397 eglSess->OpenSgDriverL();
399 // Initialise ini parser
400 CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
401 CleanupStack::PushL(iniParser);
402 TInt numPixmapSgSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapSgSurfaceFormats);
404 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
405 const EGLint KSgPixmapUsageSupport[] =
407 ESgUsageBitOpenVgSurface,
408 ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface,
409 ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Texture2D,
410 ESgUsageBitOpenVgSurface | ESgUsageBitOpenVgImage| ESgUsageBitOpenGles2Texture2D,
411 ESgUsageBitOpenGles2Surface,
412 ESgUsageBitOpenGles2Surface | ESgUsageBitOpenVgImage,
413 ESgUsageBitOpenGles2Texture2D |ESgUsageBitOpenGles2Surface,
414 ESgUsageBitOpenVgImage | ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface
417 for(TInt i = 0; i < numPixmapSgSurfaceFormats; i++)
419 VGImageFormat surfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
420 TSgImageInfoTest imageInfo = TSgImageInfoTest();
421 imageInfo.iPixelFormat = EglTestConversion::VgFormatToSgPixelFormat(surfaceFormat);;
422 EGLint alphaPreBit = (imageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) ? EGL_VG_ALPHA_FORMAT_PRE_BIT : 0;
423 TInt numUsageCombinations = sizeof(KSgPixmapUsageSupport) / sizeof(KSgPixmapUsageSupport[0]);
424 for(TUint32 j = 0; j < numUsageCombinations; j++)
426 if(KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface))
428 if(!eglSess->IsOpenGLES2Supported())
431 if(KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGlesSurface))
433 if(!eglSess->IsOpenGLESSupported())
437 imageInfo.iUsage = KSgPixmapUsageSupport[j];
439 ASSERT_EQUALS(image.Create(imageInfo, NULL, NULL), KErrNone);
440 CleanupClosePushL(image);
441 TSgImageInfoTest imageInfoSupported;
442 ASSERT_EQUALS(image.GetInfo(imageInfoSupported), KErrNone);//returned info may include more usage bits than we actually requested
443 if(((imageInfoSupported.iUsage & (ESgUsageBitOpenGles2Texture2D | ESgUsageBitOpenGles2Surface)) &&
444 (!eglSess->IsOpenGLES2Supported()) ||
445 ((imageInfoSupported.iUsage & (ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGlesSurface)) &&
446 (!eglSess->IsOpenGLESSupported()))))
448 CleanupStack::PopAndDestroy(&image);
452 EGLint eglRenderableTypeValue = 0;
453 if(imageInfoSupported.iUsage & ESgUsageBitOpenVgSurface)
455 eglRenderableTypeValue = EGL_OPENVG_BIT;
457 else if(imageInfoSupported.iUsage & ESgUsageBitOpenGles2Surface)
459 eglRenderableTypeValue = EGL_OPENGL_ES2_BIT;
461 else if(imageInfoSupported.iUsage & ESgUsageBitOpenGlesSurface)
463 eglRenderableTypeValue = EGL_OPENGL_ES_BIT;
465 else if(imageInfoSupported.iUsage & ESgUsageBitOpenGlSurface)
467 eglRenderableTypeValue = EGL_OPENGL_BIT;
469 TEST(eglRenderableTypeValue != 0);
471 // only minimum amount of renderable type matching to Native pixmap will be passed into attribute list.
472 // And egl will decide whatever configs include at least given renderable type.
473 const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&image),
474 EGL_RENDERABLE_TYPE, eglRenderableTypeValue,
475 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | alphaPreBit,
478 EGLConfig configs[KMaxEglConfigs];
480 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs, KMaxEglConfigs,&numConfigs));
481 CleanupStack::PopAndDestroy(&image);
482 TEST(numConfigs > 0);
484 for(TInt index = 0; index < numConfigs; index++)
486 const TInt numCloseRules = 3;
487 for(TInt closeRule = 0; closeRule < numCloseRules; closeRule++)
489 CTestEglSession::TResourceCloseRule resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
493 VERBOSE_INFO_PRINTF1(_L("Close Image Late"));
494 resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
497 VERBOSE_INFO_PRINTF1(_L("Close Image Early"));
498 resourceCloseRule = CTestEglSession::EResourceCloseSgImageEarly;
501 VERBOSE_INFO_PRINTF1(_L("Close Sg Driver and Image Early"));
502 resourceCloseRule = CTestEglSession::EResourceCloseSgDriverAndImageEarly;
508 if (KSgPixmapUsageSupport[j] & ESgUsageBitOpenVgSurface)
510 VERBOSE_INFO_PRINTF1(_L("...is OpenVG renderable"));
511 eglSess->TryUsePixmapRSgImageOpenVgL(configs[index], imageInfo, resourceCloseRule); // we can't fail to create an image as we have already tried it
513 if (KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGlesTexture2D))
515 VERBOSE_INFO_PRINTF1(_L("...is OpenGLES renderable"));
516 eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 1); // we can't fail to create an image as we have already tried it
518 if (KSgPixmapUsageSupport[j] & (ESgUsageBitOpenGles2Surface | ESgUsageBitOpenGles2Texture2D))
520 VERBOSE_INFO_PRINTF1(_L("...is OpenGLES2 renderable"));
521 eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 2); // we can't fail to create an image as we have already tried it
523 }//for(TInt closeRule; closeRule < numCloseRules; closeRule++)
524 }//for(TInt index = 0; index < numConfigs; index++)
525 }//for(TUint32 j = 0; j < numUsageCombinations; j++)
526 }//for(TInt i = 0; i < numSgImagePixelFormatSupport; i++)
528 const EGLint KSgPixmapUsageSupport[] =
530 ESgUsageOpenVgTarget,
531 ESgUsageOpenVgImage | ESgUsageOpenVgTarget,
532 ESgUsageOpenVgTarget | ESgUsageOpenGles2Texture2D,
533 ESgUsageOpenVgTarget | ESgUsageOpenVgImage| ESgUsageOpenGles2Texture2D,
534 ESgUsageOpenGles2Target,
535 ESgUsageOpenGles2Target | ESgUsageOpenVgImage,
536 ESgUsageOpenGles2Texture2D |ESgUsageOpenGles2Target,
537 ESgUsageOpenVgImage | ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target
540 for(TInt i = 0; i < numPixmapSgSurfaceFormats; i++)
542 VGImageFormat surfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
543 TSgImageInfoTest imageInfo = TSgImageInfoTest();
544 imageInfo.iPixelFormat = EglTestConversion::VgFormatToSgPixelFormat(surfaceFormat);;
545 EGLint alphaPreBit = (imageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) ? EGL_VG_ALPHA_FORMAT_PRE_BIT : 0;
546 TInt numUsageCombinations = sizeof(KSgPixmapUsageSupport) / sizeof(KSgPixmapUsageSupport[0]);
547 for(TUint32 j = 0; j < numUsageCombinations; j++)
549 if(KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target))
551 if(!eglSess->IsOpenGLES2Supported())
554 if(KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGlesTarget))
556 if(!eglSess->IsOpenGLESSupported())
559 imageInfo.iUsage = KSgPixmapUsageSupport[j];
561 ASSERT_EQUALS(image.Create(imageInfo, NULL, NULL), KErrNone);
562 CleanupClosePushL(image);
563 TSgImageInfoTest imageInfoSupported;
564 ASSERT_EQUALS(image.GetInfo(imageInfoSupported), KErrNone);//returned info may include more usage bits than we actually requested
565 if(((imageInfoSupported.iUsage & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGles2Target)) &&
566 (!eglSess->IsOpenGLES2Supported()) ||
567 ((imageInfoSupported.iUsage & (ESgUsageOpenGles2Texture2D | ESgUsageOpenGlesTarget)) &&
568 (!eglSess->IsOpenGLESSupported()))))
570 CleanupStack::PopAndDestroy(&image);
574 EGLint eglRenderableTypeValue = 0;
575 if(imageInfoSupported.iUsage & ESgUsageOpenVgTarget)
577 eglRenderableTypeValue = EGL_OPENVG_BIT;
579 else if(imageInfoSupported.iUsage & ESgUsageOpenGles2Target)
581 eglRenderableTypeValue = EGL_OPENGL_ES2_BIT;
583 else if(imageInfoSupported.iUsage & ESgUsageOpenGlesTarget)
585 eglRenderableTypeValue = EGL_OPENGL_ES_BIT;
587 TEST(eglRenderableTypeValue != 0);
589 // only minimum amount of renderable type matching to Native pixmap will be passed into attribute list.
590 // And egl will decide whatever configs include at least given renderable type.
591 const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(&image),
592 EGL_RENDERABLE_TYPE, eglRenderableTypeValue,
593 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | alphaPreBit,
596 EGLConfig configs[KMaxEglConfigs];
598 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs, KMaxEglConfigs,&numConfigs));
599 CleanupStack::PopAndDestroy(&image);
600 TEST(numConfigs > 0);
602 for(TInt index = 0; index < numConfigs; index++)
604 const TInt numCloseRules = 3;
605 for(TInt closeRule = 0; closeRule < numCloseRules; closeRule++)
607 CTestEglSession::TResourceCloseRule resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
611 VERBOSE_INFO_PRINTF1(_L("Close Image Late"));
612 resourceCloseRule = CTestEglSession::EResourceCloseSgImageLate;
615 VERBOSE_INFO_PRINTF1(_L("Close Image Early"));
616 resourceCloseRule = CTestEglSession::EResourceCloseSgImageEarly;
619 VERBOSE_INFO_PRINTF1(_L("Close Sg Driver and Image Early"));
620 resourceCloseRule = CTestEglSession::EResourceCloseSgDriverAndImageEarly;
626 if (KSgPixmapUsageSupport[j] & ESgUsageOpenVgTarget)
628 VERBOSE_INFO_PRINTF1(_L("...is OpenVG renderable"));
629 eglSess->TryUsePixmapRSgImageOpenVgL(configs[index], imageInfo, resourceCloseRule); // we can't fail to create an image as we have already tried it
631 if (KSgPixmapUsageSupport[j] & (ESgUsageOpenGlesTarget | ESgUsageOpenGles2Texture2D))
633 VERBOSE_INFO_PRINTF1(_L("...is OpenGLES renderable"));
634 eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 1); // we can't fail to create an image as we have already tried it
636 if (KSgPixmapUsageSupport[j] & (ESgUsageOpenGles2Target | ESgUsageOpenGles2Texture2D))
638 VERBOSE_INFO_PRINTF1(_L("...is OpenGLES2 renderable"));
639 eglSess->TryUsePixmapRSgImageOpenGlesL(configs[index], imageInfo, resourceCloseRule, 2); // we can't fail to create an image as we have already tried it
641 }//for(TInt closeRule; closeRule < numCloseRules; closeRule++)
642 }//for(TInt index = 0; index < numConfigs; index++)
643 }//for(TUint32 j = 0; j < numUsageCombinations; j++)
644 }//for(TInt i = 0; i < numSgImagePixelFormatSupport; i++)
646 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
648 CleanupStack::PopAndDestroy(2, eglSess);//iniParser, eglSess
651 CloseTMSGraphicsStep();
652 return TestStepResult();