1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltest_nativepixmaptype.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,798 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 +*/
1.23 +
1.24 +#include <iniparser.h>
1.25 +#include <test/tefunit.h> // for ASSERT macros
1.26 +
1.27 +#include "egltest_nativepixmaptype.h"
1.28 +#include <test/egltestcommonconversion.h>
1.29 +#include <test/egltestcommoninisettings.h>
1.30 +
1.31 +
1.32 +/**
1.33 +@SYMTestCaseID GRAPHICS-EGL-0015
1.34 +
1.35 +@SYMTestPriority 1
1.36 +
1.37 +@SYMPREQ 39
1.38 +
1.39 +@SYMREQ See SGL.GT0386.401 document
1.40 +
1.41 +@SYMTestCaseDesc
1.42 +Checks the single threaded usage of a Pixmap<RSgImage>
1.43 +
1.44 +@SYMTestActions
1.45 +Call eglInitialize()
1.46 +Use a Pixmap<RSgImage>
1.47 +
1.48 +@SYMTestExpectedResults
1.49 +Use of Pixmap<RSgImage> succeeds
1.50 +*/
1.51 +TVerdict CEglTest_NativePixmapType_SingleThread_Positive_RSgImage::doTestStepL()
1.52 + {
1.53 + SetTestStepID(_L("GRAPHICS-EGL-0015"));
1.54 + INFO_PRINTF1(_L("CEglTest_NativePixmapType_SingleThread_Positive_RSgImage::doTestStepL"));
1.55 +
1.56 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.57 + if(!ret)
1.58 + {
1.59 + // The extension is not supported
1.60 + RecordTestResultL();
1.61 + CloseTMSGraphicsStep();
1.62 + return TestStepResult();
1.63 + }
1.64 +
1.65 + // Create display object
1.66 + GetDisplayL();
1.67 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
1.68 + eglSess->InitializeL();
1.69 +
1.70 + // Try to create and use an RSgImage pixmap
1.71 + eglSess->TryUsePixmapRSgImageL();
1.72 +
1.73 + CleanupStack::PopAndDestroy(eglSess);
1.74 + TerminateDisplayL();
1.75 + RecordTestResultL();
1.76 + CloseTMSGraphicsStep();
1.77 + return TestStepResult();
1.78 + }
1.79 +
1.80 +/**
1.81 +@SYMTestCaseID GRAPHICS-EGL-0028
1.82 +
1.83 +@SYMTestPriority 1
1.84 +
1.85 +@SYMPREQ 39
1.86 +
1.87 +@SYMREQ See SGL.GT0386.401 document
1.88 +
1.89 +@SYMTestCaseDesc
1.90 +These tests check usage of a Pixmap<RSgImage> within two threads.
1.91 +
1.92 +@SYMTestActions
1.93 +Execute threads A and B in the following order
1.94 +A: Call eglInitialize()
1.95 +B: Call eglInitialize()
1.96 +-----
1.97 +A: Use Pixmap<RSgImage>
1.98 +B: Use Pixmap<RSgImage>
1.99 +
1.100 +@SYMTestExpectedResults
1.101 +Use_Pixmap<RSgImage> succeeds for both threads
1.102 +*/
1.103 +TVerdict CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doTestStepL()
1.104 + {
1.105 + SetTestStepID(_L("GRAPHICS-EGL-0028"));
1.106 + INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doTestStepL"));
1.107 +
1.108 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.109 +
1.110 + if(ret)
1.111 + {
1.112 + Test_MultiThreadL(2, ETrue);
1.113 + TerminateDisplayL();
1.114 + }
1.115 +
1.116 + INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doTestStepL"));
1.117 + RecordTestResultL();
1.118 + CloseTMSGraphicsStep();
1.119 + return TestStepResult();
1.120 + }
1.121 +
1.122 +void CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doThreadFunctionL(TInt aIdx)
1.123 + {
1.124 + INFO_PRINTF2(_L("thread %d: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doThreadFunctionL"), aIdx);
1.125 +
1.126 + GetDisplayL();
1.127 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
1.128 +
1.129 + eglSess->InitializeL();
1.130 +
1.131 + Rendezvous(aIdx);
1.132 +
1.133 + eglSess->TryUsePixmapRSgImageL();
1.134 +
1.135 + CleanupStack::PopAndDestroy(eglSess);
1.136 +
1.137 + INFO_PRINTF2(_L("thread %d: Exit CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice::doThreadFunctionL"), aIdx);
1.138 + }
1.139 +
1.140 +/**
1.141 +@SYMTestCaseID GRAPHICS-EGL-0029
1.142 +
1.143 +@SYMTestPriority 1
1.144 +
1.145 +@SYMPREQ 39
1.146 +
1.147 +@SYMREQ See SGL.GT0386.401 document
1.148 +
1.149 +@SYMTestCaseDesc
1.150 +These tests check usage of a Pixmap<RSgImage> within two threads.
1.151 +Threads are indipendent (no rendezvous).
1.152 +
1.153 +@SYMTestActions
1.154 +Execute threads A and B in the following order
1.155 +A: Call eglInitialize()
1.156 +B: Call eglInitialize()
1.157 +-----
1.158 +A: Use Pixmap<RSgImage>
1.159 +B: Use Pixmap<RSgImage>
1.160 +
1.161 +@SYMTestExpectedResults
1.162 +Use_Pixmap<RSgImage> succeeds for both threads
1.163 +*/
1.164 +TVerdict CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doTestStepL()
1.165 + {
1.166 + SetTestStepID(_L("GRAPHICS-EGL-0029"));
1.167 + INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doTestStepL"));
1.168 +
1.169 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.170 +
1.171 + if(ret)
1.172 + {
1.173 + Test_MultiThreadL(2, ETrue);
1.174 + TerminateDisplayL();
1.175 + }
1.176 +
1.177 + INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doTestStepL"));
1.178 + RecordTestResultL();
1.179 + CloseTMSGraphicsStep();
1.180 + return TestStepResult();
1.181 + }
1.182 +
1.183 +void CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doThreadFunctionL(TInt aIdx)
1.184 + {
1.185 + INFO_PRINTF2(_L("thread %d: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doThreadFunctionL"), aIdx);
1.186 + GetDisplayL();
1.187 + //first check if the extension is present
1.188 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
1.189 + eglSess->InitializeL();
1.190 +
1.191 + eglSess->TryUsePixmapRSgImageL();
1.192 +
1.193 + CleanupStack::PopAndDestroy(eglSess);
1.194 +
1.195 + INFO_PRINTF2(_L("thread %d: Exit CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitTwice_NoRendezvous::doThreadFunctionL"), aIdx);
1.196 + }
1.197 +
1.198 +
1.199 +/**
1.200 +@SYMTestCaseID GRAPHICS-EGL-0030
1.201 +
1.202 +@SYMTestPriority 1
1.203 +
1.204 +@SYMPREQ 39
1.205 +
1.206 +@SYMREQ See SGL.GT0386.401 document
1.207 +
1.208 +@SYMTestCaseDesc
1.209 +These test checks that one call to eglInitialize per process is sufficient.
1.210 +Both threads use a Pixmap<RSgImage>
1.211 +
1.212 +@SYMTestActions
1.213 +Execute threads A and B in the following order
1.214 +A: Call eglInitialize()
1.215 +B: <no initialisation>
1.216 +-----
1.217 +A: Use Pixmap<RSgImage>
1.218 +B: Use Pixmap<RSgImage>
1.219 +
1.220 +@SYMTestExpectedResults
1.221 +Use_Pixmap<RSgImage> succeeds for both threads
1.222 +*/
1.223 +TVerdict CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doTestStepL()
1.224 + {
1.225 + SetTestStepID(_L("GRAPHICS-EGL-0030"));
1.226 + INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doTestStepL"));
1.227 +
1.228 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.229 +
1.230 + if(ret)
1.231 + {
1.232 + Test_MultiThreadL(2, ETrue);
1.233 + TerminateDisplayL();
1.234 + }
1.235 +
1.236 + INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doTestStepL"));
1.237 + RecordTestResultL();
1.238 + CloseTMSGraphicsStep();
1.239 + return TestStepResult();
1.240 + }
1.241 +
1.242 +void CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doThreadFunctionL(TInt aIdx)
1.243 + {
1.244 + INFO_PRINTF2(_L("thread %d: CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doThreadFunctionL"), aIdx);
1.245 +
1.246 + GetDisplayL();
1.247 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
1.248 +
1.249 + if (aIdx == 0)
1.250 + {
1.251 + eglSess->InitializeL();
1.252 + }
1.253 + Rendezvous(aIdx);
1.254 + if (aIdx == 1)
1.255 + {
1.256 + INFO_PRINTF2(_L("thread %d: skipping initialisation"), aIdx);
1.257 + }
1.258 +
1.259 + Rendezvous(aIdx);
1.260 +
1.261 + eglSess->TryUsePixmapRSgImageL();
1.262 +
1.263 + CleanupStack::PopAndDestroy(eglSess);
1.264 +
1.265 + INFO_PRINTF2(_L("thread %d: Exit CEglTest_NativePixmapType_MultiThread_Positive_RSgImage_InitOneThreadOnly::doThreadFunctionL"), aIdx);
1.266 + }
1.267 +
1.268 +// MultiProcess tests
1.269 +
1.270 +/**
1.271 +@SYMTestCaseID GRAPHICS-EGL-0041
1.272 +
1.273 +@SYMTestPriority 1
1.274 +
1.275 +@SYMPREQ 39
1.276 +
1.277 +@SYMREQ See SGL.GT0386.401 document
1.278 +
1.279 +@SYMTestCaseDesc
1.280 +These tests check usage of a Pixmap<RSgImage> within two processes.
1.281 +
1.282 +@SYMTestActions
1.283 +Execute processes A and B in the following order
1.284 +
1.285 +A: Call eglInitialize()
1.286 +B: Call eglInitialize()
1.287 +-----
1.288 +A: Use_Pixmap<RSgImage>
1.289 +B: Use_Pixmap<RSgImage>
1.290 +
1.291 +@SYMTestExpectedResults
1.292 +Use_Pixmap<RSgImage> should succeed for both processes
1.293 +*/
1.294 +TVerdict CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doTestStepL()
1.295 + {
1.296 + SetTestStepID(_L("GRAPHICS-EGL-0041"));
1.297 + INFO_PRINTF1(_L("CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doTestStepL"));
1.298 +
1.299 + // First check whether RSgImage is supported
1.300 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.301 +
1.302 + if(ret)
1.303 + {
1.304 + // Now run the multiprocess test - each process can safely assume that RSgImage support is available.
1.305 + Test_MultiProcessL(KEglTestStepDllName, 2, KNativePixmapType_MultiProcess_Both_RSgImage);
1.306 + }
1.307 +
1.308 + INFO_PRINTF1(_L("Exit: CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doTestStepL"));
1.309 + RecordTestResultL();
1.310 + CloseTMSGraphicsStep();
1.311 + return TestStepResult();
1.312 + }
1.313 +
1.314 +void CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doProcessFunctionL(TInt aIdx)
1.315 + {
1.316 + INFO_PRINTF2(_L("process %d: CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doProcessFunctionL"), aIdx);
1.317 +
1.318 + // Create display object
1.319 + GetDisplayL();
1.320 +
1.321 + CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
1.322 +
1.323 + // Initialize the thread
1.324 + eglSess->InitializeL();
1.325 +
1.326 + // Rendezvous: ensure that both threads get to this point before continuing
1.327 + Rendezvous(aIdx);
1.328 +
1.329 + // Try to create and use an RSgImage pixmap
1.330 + INFO_PRINTF2(_L("process %d: Calling TryUsePixmapRSgImageL..."), aIdx);
1.331 + eglSess->TryUsePixmapRSgImageL();
1.332 +
1.333 + CleanupStack::PopAndDestroy(eglSess);
1.334 + TerminateDisplayL();
1.335 +
1.336 + INFO_PRINTF2(_L("process %d: Exit CEglTest_NativePixmapType_MultiProcess_Both_RSgImage::doThreadFunctionL"), aIdx);
1.337 + }
1.338 +
1.339 +/**
1.340 +@SYMTestCaseID GRAPHICS-EGL-0044
1.341 +
1.342 +@SYMTestPriority 1
1.343 +
1.344 +@SYMPREQ 39
1.345 +
1.346 +@SYMREQ See SGL.GT0386.401 document
1.347 +
1.348 +@SYMTestCaseDesc
1.349 +Ensure that when asking for an EGLconfig via eglChooseConfig
1.350 +passing an RSgImage with given iUsage and iPixelFormat attributes,
1.351 +just the matching configs are returned.
1.352 +
1.353 +@SYMTestActions
1.354 +Fully construct an RSgImage setting iUsage and/or iPixelFormat
1.355 +Loop through different values of iUsage and iPixelFormat and change RSgImage attributes accordingly
1.356 +• Query all the configs available on the display calling eglGetConfigs.
1.357 +• Loop through the possible configs and manually check how many they are and save their index.
1.358 +• Call eglChooseConfig() having in the attrib_list the attribute EGL MATCH NATIVE PIXMAP set as the handle to the RSgImage previously created.
1.359 +• 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.
1.360 +End Loop
1.361 +Destroy the RSgImage object
1.362 +
1.363 +@SYMTestExpectedResults
1.364 +Returned Configs have to be the ones expected.
1.365 +The values that iPixelFormat have to assume are:
1.366 +• EUidPixelFormatRGB_565
1.367 +• EUidPixelFormatXRGB_8888
1.368 +• EUidPixelFormatARGB_8888_PRE
1.369 +It’s not possible to test any other pixel formats (such as
1.370 +EUidPixelFormatARGB_8888) because it is not allowed to create an RSgImage
1.371 +with that pixel format and iUsage bit saying that it is going to be used
1.372 +as a target.
1.373 +The values that iUsage have to assume are:
1.374 +• ESgUsageBitOpenVgSurface
1.375 +• ESgUsageBitOpenGles2Surface
1.376 +• ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface
1.377 +• ESgUsageBitOpenVgImage
1.378 +If OpenGLES2 is not supported creation of the SgImage is expected to fail
1.379 +with KErrNotSupported error code.
1.380 +*/
1.381 +TVerdict CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL()
1.382 + {
1.383 + SetTestStepID(_L("GRAPHICS-EGL-0044"));
1.384 + INFO_PRINTF1(_L("CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL"));
1.385 +
1.386 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.387 + if(!ret)
1.388 + {
1.389 + // The extension is not supported
1.390 + RecordTestResultL();
1.391 + CloseTMSGraphicsStep();
1.392 + return TestStepResult();
1.393 + }
1.394 +
1.395 + // Create display object
1.396 + GetDisplayL();
1.397 + CreateEglSessionL();
1.398 + iEglSess->InitializeL();
1.399 + iEglSess->OpenSgDriverL();
1.400 +
1.401 + CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
1.402 + CleanupStack::PushL(iniParser);
1.403 +
1.404 + TInt numRSgImageTargetFormats = iniParser->GetNumberOfFormats(KSectionPixmapSgSurfaceFormats);
1.405 + if(!numRSgImageTargetFormats)
1.406 + {
1.407 + ERR_PRINTF1(_L("No formats to iterate through!"));
1.408 + User::Leave(KErrArgument);
1.409 + }
1.410 +
1.411 + TBool isGles2Supported = iEglSess->IsOpenGLES2Supported();
1.412 + for(TUint i=0; i < numRSgImageTargetFormats; i++)
1.413 + {
1.414 + //We are running thorugh all the possible "target" configurations because
1.415 + //they have one allowed pixel format less than the source has
1.416 + //so this test is expected to fail for EUidPixelFormatARGB_8888
1.417 + iSurfaceFormat = iniParser->GetVgFormat(KSectionPixmapSgSurfaceFormats,i);
1.418 + iSourceFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.419 +
1.420 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.421 + INFO_PRINTF1(_L("Trying usage bit ESgUsageBitOpenVgSurface"));
1.422 + iSgImageSurfaceUsage = ESgUsageBitOpenVgSurface;
1.423 +#else
1.424 + INFO_PRINTF1(_L("Trying usage bit ESgUsageOpenVgTarget"));
1.425 + iSgImageSurfaceUsage = ESgUsageOpenVgTarget;
1.426 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.427 + doTestPartialStepL();
1.428 +
1.429 + //if OpenGLES2 is not supported we must not succeed in creating SgImage
1.430 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.431 + INFO_PRINTF1(_L("Trying usage bit ESgUsageVitOpenGles2Surface"));
1.432 + iSgImageSurfaceUsage = ESgUsageBitOpenGles2Surface;
1.433 + TRAPD(res, doTestPartialStepL());
1.434 + TESTL(res == (isGles2Supported ? KErrNone : KErrTEFUnitFail));
1.435 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.436 +
1.437 + //if OpenGLES2 is not supported we must not succeed in creating SgImage
1.438 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.439 + INFO_PRINTF1(_L("Trying usage bit ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface"));
1.440 + iSgImageSurfaceUsage = ESgUsageBitOpenVgSurface | ESgUsageBitOpenGles2Surface;
1.441 + TRAP(res, doTestPartialStepL());
1.442 + TESTL(res == (isGles2Supported ? KErrNone : KErrTEFUnitFail));
1.443 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.444 +
1.445 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.446 + INFO_PRINTF1(_L("Trying usage bit ESgUsageBitOpenVgImage"));
1.447 + iSgImageSurfaceUsage = ESgUsageBitOpenVgImage;
1.448 +#else
1.449 + INFO_PRINTF1(_L("Trying usage bit ESgUsageOpenVgImage"));
1.450 + iSgImageSurfaceUsage = ESgUsageOpenVgImage;
1.451 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.452 + doTestPartialStepL();
1.453 + }
1.454 +
1.455 + CleanupStack::PopAndDestroy(iniParser);
1.456 + CleanAll();
1.457 +
1.458 + RecordTestResultL();
1.459 + CloseTMSGraphicsStep();
1.460 + return TestStepResult();
1.461 + }
1.462 +
1.463 +TVerdict CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL()
1.464 + {
1.465 + INFO_PRINTF1(_L("CEglTest_ChooseConfig_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL"));
1.466 + PrintUsedPixelConfiguration();
1.467 +
1.468 + //Creating one RSgImage containing reference bitmap's contents
1.469 + INFO_PRINTF1(_L("Creating one RSgImage"));
1.470 + RSgImage sgImage;
1.471 + CleanupClosePushL(sgImage);
1.472 + TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.473 + TSgImageInfo imageInfo;
1.474 + imageInfo.iSizeInPixels = KPixmapSize;
1.475 + imageInfo.iPixelFormat = pixelFormat;
1.476 + imageInfo.iUsage = iSgImageSurfaceUsage;
1.477 +
1.478 + // Create a reference bitmap which we use to init the SgImage (we use index=4)
1.479 + TDisplayMode bitmapMode = EglTestConversion::VgFormatToDisplayMode(iSurfaceFormat);
1.480 + CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, 4);
1.481 + CleanupStack::PushL(bitmap);
1.482 + ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone);
1.483 + CleanupStack::PopAndDestroy(bitmap);
1.484 + bitmap = NULL;
1.485 +
1.486 + //create bitmap for further use
1.487 + bitmap = new (ELeave) CFbsBitmap;
1.488 + CleanupStack::PushL(bitmap);
1.489 + TSgImageInfo requestedImageInfo;
1.490 + sgImage.GetInfo(requestedImageInfo);
1.491 +
1.492 + TDisplayMode displayMode = EglTestConversion::PixelFormatToDisplayMode((TUidPixelFormat) (requestedImageInfo.iPixelFormat));
1.493 + TESTL(bitmap->Create(requestedImageInfo.iSizeInPixels, displayMode) == KErrNone);
1.494 +
1.495 + //Query all the config available on the display
1.496 + INFO_PRINTF1(_L("Calling eglGetConfigs, querying for the configs' number available on this display"));
1.497 + EGLint numConfigs;
1.498 + eglGetConfigs(iDisplay,NULL,0,&numConfigs);
1.499 + if(!numConfigs)
1.500 + {
1.501 + ERR_PRINTF1(_L("No available configs!"));
1.502 + CleanAll();
1.503 + User::Leave(KErrTEFUnitFail);
1.504 + }
1.505 +
1.506 + //allocate a array to store all these configs and retrieve all the IDs
1.507 + INFO_PRINTF2(_L("There are %d configs available on this display"),numConfigs);
1.508 + EGLConfig* configs = new(ELeave) EGLConfig[numConfigs];
1.509 + CleanupStack::PushL(configs);
1.510 + INFO_PRINTF1(_L("Calling eglGetConfigs, querying for all configs available on this display"));
1.511 + ASSERT_EGL_TRUE(eglGetConfigs(iDisplay,configs,KMaxEglConfigs,&numConfigs));
1.512 +
1.513 + //"manually check" if a config is compatible with this RSgImage
1.514 + RArray<EGLint> compatibleConfigsIdsArray;
1.515 + CleanupClosePushL(compatibleConfigsIdsArray);
1.516 + RArray<EGLConfig> compatibleConfigsHandleArray;
1.517 + CleanupClosePushL(compatibleConfigsHandleArray);
1.518 + for(TUint i=0;i<numConfigs;i++)
1.519 + {
1.520 + if(GetEglSess()->IsACompatibleConfig(configs[i],sgImage,EFalse))
1.521 + {
1.522 + compatibleConfigsHandleArray.AppendL(configs[i]);
1.523 + EGLint configID = 0;
1.524 + eglGetConfigAttrib(iDisplay, configs[i], EGL_CONFIG_ID, &configID);
1.525 + compatibleConfigsIdsArray.Append(configID);
1.526 + VERBOSE_INFO_PRINTF2(_L("Config %d is compatible"), configs[i]);
1.527 + }
1.528 + }
1.529 + const TInt numCompatibleConfigs = compatibleConfigsIdsArray.Count();
1.530 + INFO_PRINTF2(_L("Of which %d are compatible with this RSgImage"),numCompatibleConfigs);
1.531 +
1.532 + //Setting the attributes list to EGL_MATCH_NATIVE_PIXMAP with value the handle to the RSgImage
1.533 + const EGLint KAttrib_listFail[] = { EGL_MATCH_NATIVE_PIXMAP,NULL,EGL_NONE };
1.534 + const EGLint KAttrib_list[] = { EGL_MATCH_NATIVE_PIXMAP,(TInt)&sgImage,EGL_NONE };
1.535 +
1.536 + Mem::FillZ(configs, sizeof(EGLConfig)*numConfigs);
1.537 +
1.538 + //Ask all the configs eglChooseConfig thinks are compatible with this RSgImage
1.539 + //just a negative test
1.540 + INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set, but null pointer"));
1.541 + ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_listFail,configs,numConfigs,&numConfigs) == EGL_FALSE);
1.542 + GetEglSess()->CheckExpectedErrorL(EGL_BAD_ATTRIBUTE);
1.543 +
1.544 + //actually retrieve those config
1.545 + INFO_PRINTF1(_L("Calling eglChooseConfig with the EGL_MATCH_NATIVE_PIXMAP flag set"));
1.546 + ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttrib_list,configs,numConfigs,&numConfigs) == EGL_TRUE);
1.547 +
1.548 + RArray<EGLint> configsIdsArray;
1.549 + CleanupClosePushL(configsIdsArray);
1.550 + RArray<EGLConfig> configsHandleArray;
1.551 + CleanupClosePushL(configsHandleArray);
1.552 + for(TUint i=0;i<numConfigs;i++)
1.553 + {
1.554 + configsHandleArray.Append(configs[i]);
1.555 + EGLint configID = 0;
1.556 + eglGetConfigAttrib(iDisplay, configs[i], EGL_CONFIG_ID, &configID);
1.557 + configsIdsArray.Append(configID);
1.558 + }
1.559 +
1.560 + INFO_PRINTF3(_L("Checking number of configs returned by eglChooseConfig: %d, number configs, calculated mannually: %d"), numConfigs, numCompatibleConfigs);
1.561 + ASSERT_EGL_TRUE(numConfigs <= numCompatibleConfigs);
1.562 +
1.563 + //Check if the config "manually checked" match with the ones eglChooseConfig returned
1.564 + TInt numFoundInConfig = 0; //signify, how many IDs from compatible configs matches
1.565 + //to the IDs from config retreived by eglChooseConfig, where image is supplied as a native pixmap
1.566 +
1.567 + //check that all configs we checked previously mannually, have corresponding config retrieved via EGL API
1.568 + for(TUint i=0;i<numCompatibleConfigs;i++)
1.569 + {
1.570 + TBool found = EFalse;
1.571 + if (configsIdsArray.Find(compatibleConfigsIdsArray[i]) != KErrNotFound)
1.572 + {
1.573 + found = ETrue;
1.574 + VERBOSE_INFO_PRINTF2(_L("Config %d It's compatible as expected!"),compatibleConfigsHandleArray[i]);
1.575 + numFoundInConfig++;
1.576 + }
1.577 + if(!found)
1.578 + {
1.579 + //Check whether we can create pixmap surface based on CFbsBitmap.
1.580 + //If this succeeds the config was not intended to be used
1.581 + //for RSgImage but CFbsBitmap, which is legitimate and we
1.582 + //shall exclude this config from our consideration.
1.583 + EGLint EGL_RENDERABLE_TYPE_value = 0;
1.584 + eglGetConfigAttrib(iDisplay, compatibleConfigsHandleArray[i], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value);
1.585 + const EGLint* KAttribs = ((pixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
1.586 + EGLSurface surface = eglCreatePixmapSurface(iDisplay,compatibleConfigsHandleArray[i],bitmap,KAttribs);
1.587 + ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
1.588 + ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
1.589 + }
1.590 + }
1.591 + TEST(numFoundInConfig==numConfigs);
1.592 +
1.593 + //now checking that eglCreatePixmapSurface returns a surface just with the proper configs
1.594 + //just the configs seen as compatible should allow to create a pixmap surface
1.595 + memset(configs,0,sizeof(EGLConfig)*numConfigs);
1.596 +
1.597 + INFO_PRINTF1(_L("Now testing eglCreatePixmapSurface"));
1.598 + INFO_PRINTF1(_L("Calling eglGetConfigs, querying for all configs available on this display"));
1.599 + ASSERT_EGL_TRUE(eglGetConfigs(iDisplay,configs,KMaxEglConfigs,&numConfigs));
1.600 +
1.601 + configsHandleArray.Reset();
1.602 + configsIdsArray.Reset();
1.603 + for(TUint i=0;i<numConfigs;i++)
1.604 + {
1.605 + configsHandleArray.Append(configs[i]);
1.606 + EGLint configID = 0;
1.607 + eglGetConfigAttrib(iDisplay, configs[i], EGL_CONFIG_ID, &configID);
1.608 + configsIdsArray.Append(configID);
1.609 + }
1.610 +
1.611 + for(TUint i=0;i<numConfigs;i++)//iterates through all the configs available on this display
1.612 + {
1.613 + EGLint EGL_SURFACE_TYPE_value = 0;
1.614 + EGLint EGL_RENDERABLE_TYPE_value = 0;
1.615 + eglGetConfigAttrib(iDisplay, configsHandleArray[i], EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value);
1.616 + eglGetConfigAttrib(iDisplay, configsHandleArray[i], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value);
1.617 +
1.618 + //bind the API to the renderable type of the config
1.619 + if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)
1.620 + {
1.621 + eglBindAPI(EGL_OPENVG_API);
1.622 + }
1.623 + else
1.624 + {
1.625 + eglBindAPI(EGL_OPENGL_ES_API);
1.626 + }
1.627 +
1.628 + TBool found = EFalse;
1.629 + if (compatibleConfigsIdsArray.Find(configsIdsArray[i]) != KErrNotFound)
1.630 + {
1.631 + found = ETrue;
1.632 + VERBOSE_INFO_PRINTF2(_L("Config %d It's compatible as expected!"),configsHandleArray[i]);
1.633 + numFoundInConfig++;
1.634 + }
1.635 +
1.636 + if(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT) //we are interested just on pixmap surfaces
1.637 + {
1.638 + //we need to set the alpha bit value if we are using 16MAP sgImages and vgtarget
1.639 + const EGLint* KAttribs = ((pixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
1.640 + EGLSurface surface = eglCreatePixmapSurface(iDisplay,configsHandleArray[i],&sgImage,KAttribs);
1.641 + if(surface != EGL_NO_SURFACE)
1.642 + {
1.643 + ASSERT_EGL_ERROR(EGL_SUCCESS);
1.644 + }
1.645 + else if (found)
1.646 + {
1.647 + //if EGL_NO_SURFACE and found,
1.648 + //we have to eliminate the case when it is possible to create pixmap surface based on CFbsBitmap.
1.649 + //If this succeeds the config was not intended to be used
1.650 + //for RSgImage but CFbsBitmap, which is legitimate and we
1.651 + //shall exclude this config from our consideration.
1.652 + surface = eglCreatePixmapSurface(iDisplay,configsHandleArray[i],bitmap,KAttribs);
1.653 + ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
1.654 + ASSERT_EGL_ERROR(EGL_SUCCESS);
1.655 + }
1.656 + else
1.657 + {
1.658 + // if EGL_NO_SURFACE and !found, then the error raised by eglCreatePixmapSurface must be EGL_BAD_MATCH
1.659 + ASSERT_EGL_ERROR(EGL_BAD_MATCH);
1.660 + }
1.661 + if(surface != EGL_NO_SURFACE)
1.662 + {
1.663 + ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
1.664 + }
1.665 + }
1.666 + }
1.667 +
1.668 + // clean-up everything
1.669 + CleanupStack::PopAndDestroy(7, &sgImage); // the 4 arrays, config, bitmap, sgimage
1.670 + return TestStepResult();
1.671 + }
1.672 +
1.673 +
1.674 +/**
1.675 +@SYMTestCaseID GRAPHICS-EGL-0420
1.676 +
1.677 +@SYMTestPriority 1
1.678 +
1.679 +@SYMPREQ 2637
1.680 +
1.681 +@SYMTestCaseDesc
1.682 +Ensure that the system can tell the difference between an RSgImage and a CFbsBitmap.
1.683 +
1.684 +@SYMTestActions
1.685 +Cycling through 64K, 16MU and 16MAP.
1.686 + - For each pixel format, create a CFbsBitmap and pass it into eglChooseConfig() via EGL_MATCH_NATIVE_PIXMAP.
1.687 + - If eglChooseConfig() returns no results for any pixel format then that’s OK, as we are not mandating that
1.688 + the EGL implementation supports CFbsBitmaps
1.689 + - call eglCreatePixmapSurface() with the bitmap to check it returns a suitable error and doesn’t crash.
1.690 + - If it doesn’t crash then we have started to demonstrate it recognises this is not an RSgImage.
1.691 + - This also ensures that we are not mandating any of the above pixel formats, just trying them out.
1.692 + - If eglChooseConfig() does return some results, then use each config to create a pixmap surface and draw something.
1.693 + - This will check that eglCreatePixmapSurface() can tell the difference, as well as some very basic sanity checking.
1.694 +
1.695 +@SYMTestExpectedResults
1.696 +If eglChooseConfig() returns no results, that's ok as long as it doesn’t crash.
1.697 +If eglChooseConfig() returns some results, eglCreatePixmapSurface(), a surface can be successfully created and used.
1.698 +*/
1.699 +TVerdict CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL()
1.700 + {
1.701 + SetTestStepID(_L("GRAPHICS-EGL-0420"));
1.702 + INFO_PRINTF1(_L("CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestStepL"));
1.703 +
1.704 + TBool ret = CheckForExtensionL(KEGL_RSgimage);
1.705 + if(!ret)
1.706 + {
1.707 + // The extension is not supported
1.708 + RecordTestResultL();
1.709 + CloseTMSGraphicsStep();
1.710 + return TestStepResult();
1.711 + }
1.712 +
1.713 + // Create display object
1.714 + GetDisplayL();
1.715 + CreateEglSessionL();
1.716 + iEglSess->InitializeL();
1.717 + iEglSess->OpenSgDriverL();
1.718 +
1.719 + CEglTestCommonIniSettings* iniParser = CEglTestCommonIniSettings::NewL();
1.720 + CleanupStack::PushL(iniParser);
1.721 + TInt numPixmapFbsSurfaceFormats = iniParser->GetNumberOfFormats(KSectionPixmapFbsSurfaceFormats);
1.722 + if(!numPixmapFbsSurfaceFormats)
1.723 + {
1.724 + ERR_PRINTF1(_L("No formats to iterate through!"));
1.725 + User::Leave(KErrArgument);
1.726 + }
1.727 +
1.728 + for(TUint i=0; i < numPixmapFbsSurfaceFormats; i++)
1.729 + {
1.730 + //We are running thorugh all the possible CFbsBitmap format configurations
1.731 + iSurfaceFormat = iniParser->GetVgFormat(KSectionPixmapFbsSurfaceFormats,i);
1.732 + iSourceFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat);
1.733 + doTestPartialStepL();
1.734 + }
1.735 +
1.736 + CleanupStack::PopAndDestroy(iniParser);
1.737 + CleanAll();
1.738 +
1.739 + RecordTestResultL();
1.740 + CloseTMSGraphicsStep();
1.741 + return TestStepResult();
1.742 + }
1.743 +
1.744 +TVerdict CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL()
1.745 + {
1.746 + INFO_PRINTF1(_L("CEglTest_CFbsBitmap_EGL_MATCH_NATIVE_PIXMAP_KHR::doTestPartialStepL"));
1.747 + PrintUsedPixelConfiguration();
1.748 +
1.749 + //Creating one reference CFbsBitmap in the specified format
1.750 + INFO_PRINTF1(_L("Creating a CFbsBitmap..."));
1.751 + TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat);
1.752 + CFbsBitmap* bitmap = GetEglSess()->CreateReferenceBitmapL(bitmapMode);
1.753 + CleanupStack::PushL(bitmap);
1.754 +
1.755 + //Calling eglBindAPI
1.756 + ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
1.757 +
1.758 + const EGLint KAttribList[] = {EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast<EGLint>(bitmap),
1.759 + EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
1.760 + EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
1.761 + EGL_NONE };
1.762 + const EGLint* KPixmapAttribs = (iSourceFormat == EUidPixelFormatARGB_8888_PRE) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
1.763 +
1.764 + //Calling eglChooseConfig with the reference CFbsBitmap
1.765 + INFO_PRINTF1(_L("Calling eglChooseConfig with EGL_MATCH_NATIVE_PIXMAP to check if the system understands CFbsBitmaps..."));
1.766 + EGLConfig currentConfig;
1.767 + EGLint numconfigs=0;
1.768 + ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,KAttribList,¤tConfig,1,&numconfigs))
1.769 + if (numconfigs==0)
1.770 + {
1.771 + //If eglChooseConfig() returns no results for any pixel format then that’s OK.
1.772 + //This also ensures that we are not mandating any of the above pixel formats, just trying them out.
1.773 + INFO_PRINTF1(_L("eglChooseConfig() returns no results for this pixel format. Continue the test"));
1.774 + }
1.775 + else
1.776 + {
1.777 + //If eglChooseConfig() does return some results, then use config to create a pixmap surface and draw something
1.778 + INFO_PRINTF1(_L("eglChooseConfig() returns a config for this pixel format. Do some sanity"));
1.779 + EGLSurface surface = eglCreatePixmapSurface(iDisplay,currentConfig,bitmap,KPixmapAttribs);
1.780 + ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
1.781 + EGLContext context = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
1.782 + ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT);
1.783 + ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context));
1.784 +
1.785 + // Draw something to the surface
1.786 + VGfloat color[4] = { 1.0f, 0.f, 1.0f, 0.f };
1.787 + vgSetfv(VG_CLEAR_COLOR, 4, color);
1.788 + ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
1.789 + vgClear(0, 0, bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
1.790 + ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR);
1.791 + INFO_PRINTF1(_L("Pixmap successfully created and drawn onto. Sanity check completed!"));
1.792 +
1.793 + //destroy surface-context
1.794 + ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface));
1.795 + ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1.796 + }
1.797 +
1.798 + // clean-up everything
1.799 + CleanupStack::PopAndDestroy(bitmap);
1.800 + return TestStepResult();
1.801 + }