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 <iniparser.h>
22 #include <test/tefunit.h> // for ASSERT macros
24 #include "egltest_nativepixmaptype.h"
25 #include <test/egltestcommonconversion.h>
26 #include <test/egltestcommoninisettings.h>
30 @SYMTestCaseID GRAPHICS-EGL-0015
36 @SYMREQ See SGL.GT0386.401 document
39 Checks the single threaded usage of a Pixmap<RSgImage>
43 Use a Pixmap<RSgImage>
45 @SYMTestExpectedResults
46 Use of Pixmap<RSgImage> succeeds
48 TVerdict CEglTest_NativePixmapType_SingleThread_Positive_RSgImage::doTestStepL()
50 SetTestStepID(_L("GRAPHICS-EGL-0015"));
51 INFO_PRINTF1(_L("CEglTest_NativePixmapType_SingleThread_Positive_RSgImage::doTestStepL"));
53 TBool ret = CheckForExtensionL(KEGL_RSgimage);
56 // The extension is not supported
58 CloseTMSGraphicsStep();
59 return TestStepResult();
62 // Create display object
64 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
65 eglSess->InitializeL();
67 // Try to create and use an RSgImage pixmap
68 eglSess->TryUsePixmapRSgImageL();
70 CleanupStack::PopAndDestroy(eglSess);
73 CloseTMSGraphicsStep();
74 return TestStepResult();
78 @SYMTestCaseID GRAPHICS-EGL-0028
84 @SYMREQ See SGL.GT0386.401 document
87 These tests check usage of a Pixmap<RSgImage> within two threads.
90 Execute threads A and B in the following order
91 A: Call eglInitialize()
92 B: Call eglInitialize()
94 A: Use Pixmap<RSgImage>
95 B: Use Pixmap<RSgImage>
97 @SYMTestExpectedResults
98 Use_Pixmap<RSgImage> succeeds for both threads
100 TVerdict CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doTestStepL()
102 SetTestStepID(_L("GRAPHICS-EGL-0028"));
103 INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doTestStepL"));
105 TBool ret = CheckForExtensionL(KEGL_RSgimage);
109 Test_MultiThreadL(2, ETrue);
113 INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doTestStepL"));
115 CloseTMSGraphicsStep();
116 return TestStepResult();
119 void CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doThreadFunctionL(TInt aIdx)
121 INFO_PRINTF2(_L("thread %d: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doThreadFunctionL"), aIdx);
124 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
126 eglSess->InitializeL();
130 eglSess->TryUsePixmapRSgImageL();
132 CleanupStack::PopAndDestroy(eglSess);
134 INFO_PRINTF2(_L("thread %d: Exit CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doThreadFunctionL"), aIdx);
138 @SYMTestCaseID GRAPHICS-EGL-0029
144 @SYMREQ See SGL.GT0386.401 document
147 These tests check usage of a Pixmap<RSgImage> within two threads.
148 Threads are indipendent (no rendezvous).
151 Execute threads A and B in the following order
152 A: Call eglInitialize()
153 B: Call eglInitialize()
155 A: Use Pixmap<RSgImage>
156 B: Use Pixmap<RSgImage>
158 @SYMTestExpectedResults
159 Use_Pixmap<RSgImage> succeeds for both threads
161 TVerdict CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doTestStepL()
163 SetTestStepID(_L("GRAPHICS-EGL-0029"));
164 INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doTestStepL"));
166 TBool ret = CheckForExtensionL(KEGL_RSgimage);
170 Test_MultiThreadL(2, ETrue);
174 INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doTestStepL"));
176 CloseTMSGraphicsStep();
177 return TestStepResult();
180 void CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doThreadFunctionL(TInt aIdx)
182 INFO_PRINTF2(_L("thread %d: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doThreadFunctionL"), aIdx);
184 //first check if the extension is present
185 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
186 eglSess->InitializeL();
188 eglSess->TryUsePixmapRSgImageL();
190 CleanupStack::PopAndDestroy(eglSess);
192 INFO_PRINTF2(_L("thread %d: Exit CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doThreadFunctionL"), aIdx);
197 @SYMTestCaseID GRAPHICS-EGL-0030
203 @SYMREQ See SGL.GT0386.401 document
206 These test checks that one call to eglInitialize per process is sufficient.
207 Both threads use a Pixmap<RSgImage>
210 Execute threads A and B in the following order
211 A: Call eglInitialize()
212 B: <no initialisation>
214 A: Use Pixmap<RSgImage>
215 B: Use Pixmap<RSgImage>
217 @SYMTestExpectedResults
218 Use_Pixmap<RSgImage> succeeds for both threads
220 TVerdict CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doTestStepL()
222 SetTestStepID(_L("GRAPHICS-EGL-0030"));
223 INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doTestStepL"));
225 TBool ret = CheckForExtensionL(KEGL_RSgimage);
229 Test_MultiThreadL(2, ETrue);
233 INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doTestStepL"));
235 CloseTMSGraphicsStep();
236 return TestStepResult();
239 void CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doThreadFunctionL(TInt aIdx)
241 INFO_PRINTF2(_L("thread %d: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doThreadFunctionL"), aIdx);
244 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
248 eglSess->InitializeL();
253 INFO_PRINTF2(_L("thread %d: skipping initialisation"), aIdx);
258 eglSess->TryUsePixmapRSgImageL();
260 CleanupStack::PopAndDestroy(eglSess);
262 INFO_PRINTF2(_L("thread %d: Exit CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doThreadFunctionL"), aIdx);
265 // MultiProcess tests
268 @SYMTestCaseID GRAPHICS-EGL-0041
274 @SYMREQ See SGL.GT0386.401 document
277 These tests check usage of a Pixmap<RSgImage> within two processes.
280 Execute processes A and B in the following order
282 A: Call eglInitialize()
283 B: Call eglInitialize()
285 A: Use_Pixmap<RSgImage>
286 B: Use_Pixmap<RSgImage>
288 @SYMTestExpectedResults
289 Use_Pixmap<RSgImage> should succeed for both processes
291 TVerdict CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doTestStepL()
293 SetTestStepID(_L("GRAPHICS-EGL-0041"));
294 INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doTestStepL"));
296 // First check whether RSgImage is supported
297 TBool ret = CheckForExtensionL(KEGL_RSgimage);
301 // Now run the multiprocess test - each process can safely assume that RSgImage support is available.
302 Test_MultiProcessL(KEglTestStepDllName, 2, KNativePixmapType_MultiProcess_Both_RSgImage);
305 INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doTestStepL"));
307 CloseTMSGraphicsStep();
308 return TestStepResult();
311 void CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doProcessFunctionL(TInt aIdx)
313 INFO_PRINTF2(_L("process %d: CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doProcessFunctionL"), aIdx);
315 // Create display object
318 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
320 // Initialize the thread
321 eglSess->InitializeL();
323 // Rendezvous: ensure that both threads get to this point before continuing
326 // Try to create and use an RSgImage pixmap
327 INFO_PRINTF2(_L("process %d: Calling TryUsePixmapRSgImageL..."), aIdx);
328 eglSess->TryUsePixmapRSgImageL();
330 CleanupStack::PopAndDestroy(eglSess);
333 INFO_PRINTF2(_L("process %d: Exit CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doThreadFunctionL"), aIdx);
337 @SYMTestCaseID GRAPHICS-EGL-0044
343 @SYMREQ See SGL.GT0386.401 document
346 Ensure that when asking for an EGLconfig via eglChooseConfig
347 passing an RSgImage with given iUsage and iPixelFormat attributes,
348 just the matching configs are returned.
351 Fully construct an RSgImage setting iUsage and/or iPixelFormat
352 Loop through different values of iUsage and iPixelFormat and change RSgImage attributes accordingly
353 • Query all the configs available on the display calling eglGetConfigs.
354 • Loop through the possible configs and manually check how many they are and save their index.
355 • Call eglChooseConfig() having in the attrib_list the attribute EGL MATCH NATIVE PIXMAP set as the handle to the RSgImage previously created.
356 • Check if the number of the returned matching config is equal to the one manually checked earlier. Check if the returned configs are actually the same.
358 Destroy the RSgImage object
360 @SYMTestExpectedResults
361 Returned Configs have to be the ones expected.
362 The values that iPixelFormat have to assume are:
363 • EUidPixelFormatRGB_565
364 • EUidPixelFormatXRGB_8888
365 • EUidPixelFormatARGB_8888_PRE
366 It’s not possible to test any other pixel formats (such as
367 EUidPixelFormatARGB_8888) because it is not allowed to create an RSgImage
368 with that pixel format and iUsage bit saying that it is going to be used
370 The values that iUsage have to assume are:
371 • ESgUsageBitOpenVgSurface
372 • ESgUsageBitOpenGles2Surface
373 • ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface
374 • ESgUsageBitOpenVgImage
375 If OpenGLES2 is not supported creation of the SgImage is expected to fail
376 with KErrNotSupported error code.
378 TVerdict CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL()
380 SetTestStepID(_L("GRAPHICS-EGL-0044"));
381 INFO_PRINTF1(_L("CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL"));
383 TBool ret = CheckForExtensionL(KEGL_RSgimage);
386 // The extension is not supported
388 CloseTMSGraphicsStep();
389 return TestStepResult();
392 // Create display object
395 iEglSess->InitializeL();
396 iEglSess->OpenSgDriverL();
398 CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
399 CleanupStack::PushL(iniParser);
401 TInt numRSgImageTargetFormats = iniParser->GetNumberOfFormats(KSectionPixmapSgSurfaceFormats);
402 if(!numRSgImageTargetFormats)
404 ERR_PRINTF1(_L("No formats to iterate through!"));
405 User::Leave(KErrArgument);
408 TBool isGles2Supported = iEglSess->IsOpenGLES2Supported();
409 for(TUint i=0; i < numRSgImageTargetFormats; i++)
411 //We are running thorugh all the possible "target" configurations because
412 //they have one allowed pixel format less than the source has
413 //so this test is expected to fail for EUidPixelFormatARGB_8888
414 iSurfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
415 iSourceFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
417 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
418 INFO_PRINTF1(_L("Trying usage bit ESgUsageBitOpenVgSurface"));
419 iSgImageSurfaceUsage = ESgUsageBitOpenVgSurface;
421 INFO_PRINTF1(_L("Trying usage bit ESgUsageOpenVgTarget"));
422 iSgImageSurfaceUsage = ESgUsageOpenVgTarget;
423 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
424 doTestPartialStepL();
426 //if OpenGLES2 is not supported we must not succeed in creating SgImage
427 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
428 INFO_PRINTF1(_L("Trying usage bit ESgUsageVitOpenGles2Surface"));
429 iSgImageSurfaceUsage = ESgUsageBitOpenGles2Surface;
430 TRAPD(res, doTestPartialStepL());
431 TESTL(res == (isGles2Supported ? KErrNone : KErrTEFUnitFail));
432 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
434 //if OpenGLES2 is not supported we must not succeed in creating SgImage
435 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
436 INFO_PRINTF1(_L("Trying usage bit ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface"));
437 iSgImageSurfaceUsage = ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface;
438 TRAP(res, doTestPartialStepL());
439 TESTL(res == (isGles2Supported ? KErrNone : KErrTEFUnitFail));
440 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
442 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
443 INFO_PRINTF1(_L("Trying usage bit ESgUsageBitOpenVgImage"));
444 iSgImageSurfaceUsage = ESgUsageBitOpenVgImage;
446 INFO_PRINTF1(_L("Trying usage bit ESgUsageOpenVgImage"));
447 iSgImageSurfaceUsage = ESgUsageOpenVgImage;
448 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
449 doTestPartialStepL();
452 CleanupStack::PopAndDestroy(iniParser);
456 CloseTMSGraphicsStep();
457 return TestStepResult();
460 TVerdict CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL()
462 INFO_PRINTF1(_L("CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL"));
463 PrintUsedPixelConfiguration();
465 //Creating one RSgImage containing reference bitmap's contents
466 INFO_PRINTF1(_L("Creating one RSgImage"));
468 CleanupClosePushL(sgImage);
469 TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
470 TSgImageInfo imageInfo;
471 imageInfo.iSizeInPixels = KPixmapSize;
472 imageInfo.iPixelFormat = pixelFormat;
473 imageInfo.iUsage = iSgImageSurfaceUsage;
475 // Create a reference bitmap which we use to init the SgImage (we use index=4)
476 TDisplayMode bitmapMode = EglTestConversion::VgFormatToDisplayMode(iSurfaceFormat);
477 CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, 4);
478 CleanupStack::PushL(bitmap);
479 ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
480 CleanupStack::PopAndDestroy(bitmap);
483 //create bitmap for further use
484 bitmap = new (ELeave) CFbsBitmap;
485 CleanupStack::PushL(bitmap);
486 TSgImageInfo requestedImageInfo;
487 sgImage.GetInfo(requestedImageInfo);
489 TDisplayMode displayMode = EglTestConversion::PixelFormatToDisplayMode((TUidPixelFormat) (requestedImageInfo.iPixelFormat));
490 TESTL(bitmap->Create(requestedImageInfo.iSizeInPixels, displayMode) == KErrNone);
492 //Query all the config available on the display
493 INFO_PRINTF1(_L("Calling eglGetConfigs, querying for the configs' number available on this display"));
495 eglGetConfigs(iDisplay,NULL,0,&numConfigs);
498 ERR_PRINTF1(_L("No available configs!"));
500 User::Leave(KErrTEFUnitFail);
503 //allocate a array to store all these configs and retrieve all the IDs
504 INFO_PRINTF2(_L("There are %d configs available on this display"),numConfigs);
505 EGLConfig* configs = new(ELeave) EGLConfig[numConfigs];
506 CleanupStack::PushL(configs);
507 INFO_PRINTF1(_L("Calling eglGetConfigs, querying for all configs available on this display"));
508 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay,configs,KMaxEglConfigs,&numConfigs));
510 //"manually check" if a config is compatible with this RSgImage
511 RArray<EGLint> compatibleConfigsIdsArray;
512 CleanupClosePushL(compatibleConfigsIdsArray);
513 RArray<EGLConfig> compatibleConfigsHandleArray;
514 CleanupClosePushL(compatibleConfigsHandleArray);
515 for(TUint i=0;i<numConfigs;i++)
517 if(GetEglSess()->IsACompatibleConfig(configs[i],sgImage,EFalse))
519 compatibleConfigsHandleArray.AppendL(configs[i]);
521 eglGetConfigAttrib(iDisplay, configs[i], EGL_CONFIG_ID, &configID);
522 compatibleConfigsIdsArray.Append(configID);
523 VERBOSE_INFO_PRINTF2(_L("Config %d is compatible"), configs[i]);
526 const TInt numCompatibleConfigs = compatibleConfigsIdsArray.Count();
527 INFO_PRINTF2(_L("Of which %d are compatible with this RSgImage"),numCompatibleConfigs);
529 //Setting the attributes list to EGL_MATCH_NATIVE_PIXMAP with value the handle to the RSgImage
530 const EGLint KAttrib_listFail[] = { EGL_MATCH_NATIVE_PIXMAP,NULL,EGL_NONE };
531 const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP,(TInt)&sgImage,EGL_NONE };
533 Mem::FillZ(configs, sizeof(EGLConfig)*numConfigs);
535 //Ask all the configs eglChooseConfig thinks are compatible with this RSgImage
536 //just a negative test
537 INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set, but null pointer"));
538 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_listFail,configs,numConfigs,&numConfigs) == EGL_FALSE);
539 GetEglSess()->CheckExpectedErrorL(EGL_BAD_ATTRIBUTE);
541 //actually retrieve those config
542 INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set"));
543 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs,numConfigs,&numConfigs) == EGL_TRUE);
545 RArray<EGLint> configsIdsArray;
546 CleanupClosePushL(configsIdsArray);
547 RArray<EGLConfig> configsHandleArray;
548 CleanupClosePushL(configsHandleArray);
549 for(TUint i=0;i<numConfigs;i++)
551 configsHandleArray.Append(configs[i]);
553 eglGetConfigAttrib(iDisplay, configs[i], EGL_CONFIG_ID, &configID);
554 configsIdsArray.Append(configID);
557 INFO_PRINTF3(_L("Checking number of configs returned by eglChooseConfig: %d, number configs, calculated mannually: %d"), numConfigs, numCompatibleConfigs);
558 ASSERT_EGL_TRUE(numConfigs <= numCompatibleConfigs);
560 //Check if the config "manually checked" match with the ones eglChooseConfig returned
561 TInt numFoundInConfig = 0; //signify, how many IDs from compatible configs matches
562 //to the IDs from config retreived by eglChooseConfig, where image is supplied as a native pixmap
564 //check that all configs we checked previously mannually, have corresponding config retrieved via EGL API
565 for(TUint i=0;i<numCompatibleConfigs;i++)
567 TBool found = EFalse;
568 if (configsIdsArray.Find(compatibleConfigsIdsArray[i]) != KErrNotFound)
571 VERBOSE_INFO_PRINTF2(_L("Config %d It's compatible as expected!"),compatibleConfigsHandleArray[i]);
576 //Check whether we can create pixmap surface based on CFbsBitmap.
577 //If this succeeds the config was not intended to be used
578 //for RSgImage but CFbsBitmap, which is legitimate and we
579 //shall exclude this config from our consideration.
580 EGLint EGL_RENDERABLE_TYPE_value = 0;
581 eglGetConfigAttrib(iDisplay, compatibleConfigsHandleArray[i], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value);
582 const EGLint* KAttribs = ((pixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
583 EGLSurface surface = eglCreatePixmapSurface(iDisplay,compatibleConfigsHandleArray[i],bitmap,KAttribs);
584 ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
585 ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
588 TEST(numFoundInConfig==numConfigs);
590 //now checking that eglCreatePixmapSurface returns a surface just with the proper configs
591 //just the configs seen as compatible should allow to create a pixmap surface
592 memset(configs,0,sizeof(EGLConfig)*numConfigs);
594 INFO_PRINTF1(_L("Now testing eglCreatePixmapSurface"));
595 INFO_PRINTF1(_L("Calling eglGetConfigs, querying for all configs available on this display"));
596 ASSERT_EGL_TRUE(eglGetConfigs(iDisplay,configs,KMaxEglConfigs,&numConfigs));
598 configsHandleArray.Reset();
599 configsIdsArray.Reset();
600 for(TUint i=0;i<numConfigs;i++)
602 configsHandleArray.Append(configs[i]);
604 eglGetConfigAttrib(iDisplay, configs[i], EGL_CONFIG_ID, &configID);
605 configsIdsArray.Append(configID);
608 for(TUint i=0;i<numConfigs;i++)//iterates through all the configs available on this display
610 EGLint EGL_SURFACE_TYPE_value = 0;
611 EGLint EGL_RENDERABLE_TYPE_value = 0;
612 eglGetConfigAttrib(iDisplay, configsHandleArray[i], EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value);
613 eglGetConfigAttrib(iDisplay, configsHandleArray[i], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value);
615 //bind the API to the renderable type of the config
616 if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)
618 eglBindAPI(EGL_OPENVG_API);
622 eglBindAPI(EGL_OPENGL_ES_API);
625 TBool found = EFalse;
626 if (compatibleConfigsIdsArray.Find(configsIdsArray[i]) != KErrNotFound)
629 VERBOSE_INFO_PRINTF2(_L("Config %d It's compatible as expected!"),configsHandleArray[i]);
633 if(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT) //we are interested just on pixmap surfaces
635 //we need to set the alpha bit value if we are using 16MAP sgImages and vgtarget
636 const EGLint* KAttribs = ((pixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
637 EGLSurface surface = eglCreatePixmapSurface(iDisplay,configsHandleArray[i],&sgImage,KAttribs);
638 if(surface != EGL_NO_SURFACE)
640 ASSERT_EGL_ERROR(EGL_SUCCESS);
644 //if EGL_NO_SURFACE and found,
645 //we have to eliminate the case when it is possible to create pixmap surface based on CFbsBitmap.
646 //If this succeeds the config was not intended to be used
647 //for RSgImage but CFbsBitmap, which is legitimate and we
648 //shall exclude this config from our consideration.
649 surface = eglCreatePixmapSurface(iDisplay,configsHandleArray[i],bitmap,KAttribs);
650 ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
651 ASSERT_EGL_ERROR(EGL_SUCCESS);
655 // if EGL_NO_SURFACE and !found, then the error raised by eglCreatePixmapSurface must be EGL_BAD_MATCH
656 ASSERT_EGL_ERROR(EGL_BAD_MATCH);
658 if(surface != EGL_NO_SURFACE)
660 ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
665 // clean-up everything
666 CleanupStack::PopAndDestroy(7, &sgImage); // the 4 arrays, config, bitmap, sgimage
667 return TestStepResult();
672 @SYMTestCaseID GRAPHICS-EGL-0420
679 Ensure that the system can tell the difference between an RSgImage and a CFbsBitmap.
682 Cycling through 64K, 16MU and 16MAP.
683 - For each pixel format, create a CFbsBitmap and pass it into eglChooseConfig() via EGL_MATCH_NATIVE_PIXMAP.
684 - If eglChooseConfig() returns no results for any pixel format then that’s OK, as we are not mandating that
685 the EGL implementation supports CFbsBitmaps
686 - call eglCreatePixmapSurface() with the bitmap to check it returns a suitable error and doesn’t crash.
687 - If it doesn’t crash then we have started to demonstrate it recognises this is not an RSgImage.
688 - This also ensures that we are not mandating any of the above pixel formats, just trying them out.
689 - If eglChooseConfig() does return some results, then use each config to create a pixmap surface and draw something.
690 - This will check that eglCreatePixmapSurface() can tell the difference, as well as some very basic sanity checking.
692 @SYMTestExpectedResults
693 If eglChooseConfig() returns no results, that's ok as long as it doesn’t crash.
694 If eglChooseConfig() returns some results, eglCreatePixmapSurface(), a surface can be successfully created and used.
696 TVerdict CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL()
698 SetTestStepID(_L("GRAPHICS-EGL-0420"));
699 INFO_PRINTF1(_L("CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL"));
701 TBool ret = CheckForExtensionL(KEGL_RSgimage);
704 // The extension is not supported
706 CloseTMSGraphicsStep();
707 return TestStepResult();
710 // Create display object
713 iEglSess->InitializeL();
714 iEglSess->OpenSgDriverL();
716 CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
717 CleanupStack::PushL(iniParser);
718 TInt numPixmapFbsSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapFbsSurfaceFormats);
719 if(!numPixmapFbsSurfaceFormats)
721 ERR_PRINTF1(_L("No formats to iterate through!"));
722 User::Leave(KErrArgument);
725 for(TUint i=0; i < numPixmapFbsSurfaceFormats; i++)
727 //We are running thorugh all the possible CFbsBitmap format configurations
728 iSurfaceFormat = iniParser->GetVgFormat(KSectionPixmapFbsSurfaceFormats,i);
729 iSourceFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
730 doTestPartialStepL();
733 CleanupStack::PopAndDestroy(iniParser);
737 CloseTMSGraphicsStep();
738 return TestStepResult();
741 TVerdict CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL()
743 INFO_PRINTF1(_L("CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL"));
744 PrintUsedPixelConfiguration();
746 //Creating one reference CFbsBitmap in the specified format
747 INFO_PRINTF1(_L("Creating a CFbsBitmap..."));
748 TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
749 CFbsBitmap* bitmap = GetEglSess()->CreateReferenceBitmapL(bitmapMode);
750 CleanupStack::PushL(bitmap);
753 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
755 const EGLint KAttribList[] = {EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(bitmap),
756 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
757 EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
759 const EGLint* KPixmapAttribs = (iSourceFormat == EUidPixelFormatARGB_8888_PRE) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
761 //Calling eglChooseConfig with the reference CFbsBitmap
762 INFO_PRINTF1(_L("Calling eglChooseConfig with EGL_MATCH_NATIVE_PIXMAP to check if the system understands CFbsBitmaps..."));
763 EGLConfig currentConfig;
765 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttribList,¤tConfig,1,&numconfigs))
768 //If eglChooseConfig() returns no results for any pixel format then that’s OK.
769 //This also ensures that we are not mandating any of the above pixel formats, just trying them out.
770 INFO_PRINTF1(_L("eglChooseConfig() returns no results for this pixel format. Continue the test"));
774 //If eglChooseConfig() does return some results, then use config to create a pixmap surface and draw something
775 INFO_PRINTF1(_L("eglChooseConfig() returns a config for this pixel format. Do some sanity"));
776 EGLSurface surface = eglCreatePixmapSurface(iDisplay,currentConfig,bitmap,KPixmapAttribs);
777 ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
778 EGLContext context = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
779 ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT);
780 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context));
782 // Draw something to the surface
783 VGfloat color[4] = { 1.0f, 0.f, 1.0f, 0.f };
784 vgSetfv(VG_CLEAR_COLOR, 4, color);
785 ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
786 vgClear(0, 0, bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
787 ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
788 INFO_PRINTF1(_L("Pixmap successfully created and drawn onto. Sanity check completed!"));
790 //destroy surface-context
791 ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
792 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
795 // clean-up everything
796 CleanupStack::PopAndDestroy(bitmap);
797 return TestStepResult();