Update contrib.
1 // Copyright (c) 2007-2010 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 "egltestcommonsession.h"
22 #include "egltestcommonutils.h"
23 #include "egltestcommonsgimageinfo.h"
25 #include <test/tefunit.h>
27 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
28 #include <sgresource/sgresource.h>
30 #include <graphics/sgresourceinternal.h>
31 #include <graphics/sgresource.h>
32 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
33 #include <VG/openvg.h>
37 #define CHECK_EXPECTED_ERROR(aFunctionReturnValue) \
38 if(!(CheckExpectedError(aFunctionReturnValue))) \
40 ERR_PRINTF2(_L("thread %d: Unexpected EGL error information"), iThreadIdx); \
41 User::Leave(KErrTEFUnitFail); \
44 const TMapEglConfigToPixelFormat KMapEglConfigToPixelFormat[] =
46 {16, 0, 5,6,5, 0, EGL_RGB_BUFFER, EUidPixelFormatRGB_565, EColor64K},
47 {32, 0, 8,8,8, 0, EGL_RGB_BUFFER, EUidPixelFormatXRGB_8888, EColor16MU},
48 {32, 8, 8,8,8, EGL_VG_ALPHA_FORMAT_NONPRE, EGL_RGB_BUFFER, EUidPixelFormatARGB_8888, EColor16MA},
49 {32, 8, 8,8,8, EGL_VG_ALPHA_FORMAT_PRE, EGL_RGB_BUFFER, EUidPixelFormatARGB_8888_PRE, EColor16MAP}
52 EXPORT_C CTestEglSession::CTestEglSession(CTestExecuteLogger& aLogger, EGLDisplay& aDisplay, TInt aThreadIdx)
53 : iLogger(aLogger), iThreadIdx(aThreadIdx), iExtensionGroupCached(EIsUndefined), iDisplay(aDisplay), iExpectedErrorCode(EGL_SUCCESS)
56 EXPORT_C CTestEglSession* CTestEglSession::NewLC(CTestExecuteLogger& aLogger, EGLDisplay& aDisplay, TInt aThreadIdx)
58 CTestEglSession* self = new (ELeave) CTestEglSession(aLogger, aDisplay, aThreadIdx);
59 CleanupStack::PushL(self);
63 EXPORT_C CTestEglSession* CTestEglSession::NewL(CTestExecuteLogger& aLogger, EGLDisplay& aDisplay, TInt aThreadIdx)
65 CTestEglSession* self = CTestEglSession::NewLC(aLogger, aDisplay, aThreadIdx);
66 CleanupStack::Pop(self);
70 EXPORT_C CTestEglSession::~CTestEglSession()
72 iExtensionStrings.Reset();
74 if (iDisplay != EGL_NO_DISPLAY)
76 // Unbind and destroy context only if we successfuly created it
77 if (iContext != EGL_NO_CONTEXT)
79 INFO_PRINTF2(_L("thread %d: Calling eglMakeCurrent(NULL values) from ~CTestEglSession..."), iThreadIdx);
80 ret = eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
83 WARN_PRINTF3(_L("thread %d: eglMakeCurrent returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError());
86 // Warn because this should be done by the test, rather than relying on the d'tor
87 // which may not leave if there is an error (so no CHECK_EXPECTED_ERROR)
88 WARN_PRINTF2(_L("thread %d: Calling eglDestroyContext() from ~CTestEglSession..."), iThreadIdx);
89 ret = eglDestroyContext(iDisplay, iContext);
92 WARN_PRINTF3(_L("thread %d: eglDestroyContext returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError());
96 if (iSurface != EGL_NO_SURFACE)
98 // Warn because this should be done by the test, rather than relying on the d'tor
99 // which may not leave if there is an error (so no CHECK_EXPECTED_ERROR)
100 WARN_PRINTF2(_L("thread %d: Calling eglDestroySurface() from ~CTestEglSession..."), iThreadIdx);
101 ret = eglDestroySurface(iDisplay, iSurface);
104 WARN_PRINTF3(_L("thread %d: eglDestroySurface returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError());
108 if (iTerminateDisplay)
110 INFO_PRINTF1(_L("Calling eglTerminate..."));
111 ret = eglTerminate(iDisplay);
112 iDisplay = EGL_NO_DISPLAY;
115 WARN_PRINTF3(_L("thread %d: eglTerminate returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError());
120 // Only destroy native resource after the surface and context that wraps it has been destroyed.
128 EXPORT_C void CTestEglSession::SetExpectedError(EGLint aExpectedErrorCode)
130 VERBOSE_INFO_PRINTF3(_L("thread %d: Setting the expected error code for the next EGL call to %x"), iThreadIdx, aExpectedErrorCode);
132 iExpectedErrorCode = aExpectedErrorCode;
136 EXPORT_C void CTestEglSession::ResetExpectedError()
138 iExpectedErrorCode = EGL_SUCCESS;
142 Checks whether the call to an EGL method returned the correct error information.
143 The method checks whether eglGetError() returns the expected error value as specified by calling SetExpectedError()
144 It also checks that the value returned by the EGL method was appropriate for the expected error value.
145 @param aFunctionReturnValue Pass in the value retured from the EGL method
146 @return Whether the expected error information was returned from a call to an EGL method.
148 EXPORT_C TBool CTestEglSession::CheckExpectedError(EGLint aFunctionReturnValue)
150 TBool isExpectedError = ETrue;
151 EGLint eglErr = eglGetError();
153 // First check that we got the correct return value
154 if ((iExpectedErrorCode == EGL_SUCCESS) && !aFunctionReturnValue)
156 ERR_PRINTF3(_L("thread %d: Wrong function return value: %d"), iThreadIdx, aFunctionReturnValue);
157 isExpectedError = EFalse;
159 // Also check that we got the
160 if (eglErr != iExpectedErrorCode)
162 ERR_PRINTF4(_L("thread %d: eglGetError() returned %x, but expected %x"), iThreadIdx, eglErr, iExpectedErrorCode);
163 isExpectedError = EFalse;
165 else if (eglErr != EGL_SUCCESS)
167 VERBOSE_INFO_PRINTF3(_L("thread %d: eglGetError() returned %x, as expected"), iThreadIdx, eglErr);
170 // Reset the expected error
171 ResetExpectedError();
173 return isExpectedError;
176 EXPORT_C void CTestEglSession::CheckExpectedErrorL(EGLint aExpectedErrorCode)
178 EGLint eglErr = eglGetError();
179 // check that we got the expected error
180 if (eglErr != aExpectedErrorCode)
182 ERR_PRINTF4(_L("thread %d: eglGetError() returned %x, but expected %x"), iThreadIdx, eglErr, aExpectedErrorCode);
183 User::Leave(KErrTEFUnitFail);
187 void CTestEglSession::QueryExtensionsL(TExtensionsGroups aExtensionBelongsTo)
189 // reset the cached extensions
190 iExtensionStrings.Reset();
192 const char* extensionsString = NULL;
193 if(aExtensionBelongsTo == EIsEGL)
195 INFO_PRINTF2(_L("thread %d: Calling eglQueryString for EGL_EXTENSIONS)"), iThreadIdx);
196 extensionsString = eglQueryString(iDisplay, EGL_EXTENSIONS);
198 else if(aExtensionBelongsTo == EIsVG)
200 INFO_PRINTF2(_L("thread %d: Calling vgGetString for VG_EXTENSIONS)"), iThreadIdx);
202 // OpenVG needs a current VG context before it will allow the call to vgGetString
203 // The created surface will remain un-used, hence we create it with an arbitrary pixel format
204 EGLConfig currentConfig = GetConfigExactMatchL(EPBufferAttribsColor64K);
205 CreatePbufferSurfaceAndMakeCurrentL(currentConfig, TSize(1,1), EGL_OPENVG_API);
207 extensionsString = (const char*) vgGetString(VG_EXTENSIONS);
209 //cleanup the context & surface
210 CleanupSurfaceSgImageL();
214 ERR_PRINTF2(_L("CTestEglSession::QueryExtensionsL() - Unknown extension group provided (%d)."), aExtensionBelongsTo);
215 User::Leave(KErrArgument);
217 CHECK_EXPECTED_ERROR(extensionsString!=NULL);
219 TPtrC8 ptrExtensions((const TUint8 *) extensionsString );
222 buffer.CreateL(ptrExtensions.Length());
223 buffer.CleanupClosePushL();
224 buffer.Copy(ptrExtensions);
225 INFO_PRINTF3(_L("thread %d: QueryExtensionsL: \"%S\""), iThreadIdx, &buffer);
226 CleanupStack::PopAndDestroy(&buffer);
229 while (posSpace > 0 && ptrExtensions.Length() > 0)
231 posSpace = ptrExtensions.Locate(' '); // strictly looking for a single space
232 ASSERT_FALSE(posSpace==0); // Would imply extension starting with a space or with 2 spaces in a row
235 iExtensionStrings.Append(ptrExtensions.Left(posSpace));
236 if (posSpace <= ptrExtensions.Length())
238 ptrExtensions.Set(ptrExtensions.Mid(posSpace+1));
243 iExtensionStrings.Append(ptrExtensions);
248 TBool CTestEglSession::FindExtensionStringL(TExtensionsGroups aExtensionBelongsTo, const TDesC8& aExtensionString)
250 //Load the extensions for this group if not already cached
251 if (iExtensionGroupCached != aExtensionBelongsTo)
253 QueryExtensionsL(aExtensionBelongsTo); // Load extension info
254 iExtensionGroupCached = aExtensionBelongsTo;
257 TInt countExtensionStrings = iExtensionStrings.Count();
258 for(TUint i=0; i<countExtensionStrings; i++)
260 if (iExtensionStrings[i].Compare(aExtensionString)==0)
267 // No match: copy the extension string into a 16 bit buffer for logging
268 const TInt KBufLenMissingExtension=128;
269 TBuf16<KBufLenMissingExtension> bufMissingExtension16;
270 bufMissingExtension16.Copy(aExtensionString.Left(KBufLenMissingExtension));
272 WARN_PRINTF2(_L("EGL extension missing: [%S]"), &bufMissingExtension16);
277 Converts from TRgb space to Vg floating point colour
279 EXPORT_C void CTestEglSession::ConvertColor(const TRgb& aSource, VGfloat* aTarget)
282 aTarget[0] = (VGfloat)aSource.Red() / 255.f;
283 aTarget[1] = (VGfloat)aSource.Green() / 255.f;
284 aTarget[2] = (VGfloat)aSource.Blue() / 255.f;
285 aTarget[3] = (VGfloat)aSource.Alpha() / 255.f;
288 /** Breakpoint to manually view available configs while debugging */
289 EXPORT_C void CTestEglSession::ViewConfigsL()
291 EGLConfig configs[KMaxEglConfigs];
294 // Query number of configs available
295 INFO_PRINTF1(_L("Calling eglGetConfigs to get the number of configs available..."));
296 CHECK_EXPECTED_ERROR(eglGetConfigs(iDisplay, NULL, KMaxTInt, &numConfigs));
298 INFO_PRINTF1(_L("Checking number of configs..."));
299 ASSERT_TRUE(numConfigs >= 1);
300 INFO_PRINTF2(_L("Found %d configs"), numConfigs);
303 INFO_PRINTF1(_L("Calling eglGetConfigs to get configs..."));
304 CHECK_EXPECTED_ERROR(eglGetConfigs(iDisplay, configs, KMaxEglConfigs, &numConfigs));
306 for(TUint index = 0; index < numConfigs; index++)
308 EGLint EGL_BUFFER_SIZE_value;
309 EGLint EGL_ALPHA_SIZE_value;
310 EGLint EGL_BLUE_SIZE_value;
311 EGLint EGL_GREEN_SIZE_value;
312 EGLint EGL_RED_SIZE_value;
313 #ifdef PRINT_ALL_CONFIGS_DETAILS
314 EGLint EGL_DEPTH_SIZE_value;
315 EGLint EGL_STENCIL_SIZE_value;
316 EGLint EGL_CONFIG_CAVEAT_value;
317 EGLint EGL_CONFIG_ID_value;
318 EGLint EGL_LEVEL_value;
319 EGLint EGL_MAX_PBUFFER_HEIGHT_value;
320 EGLint EGL_MAX_PBUFFER_PIXELS_value;
321 EGLint EGL_MAX_PBUFFER_WIDTH_value;
322 EGLint EGL_NATIVE_RENDERABLE_value;
323 EGLint EGL_NATIVE_VISUAL_ID_value;
324 EGLint EGL_NATIVE_VISUAL_TYPE_value;
325 EGLint EGL_SAMPLES_value;
326 EGLint EGL_SAMPLE_BUFFERS_value;
328 EGLint EGL_SURFACE_TYPE_value;
329 #ifdef PRINT_ALL_CONFIGS_DETAILS
330 EGLint EGL_TRANSPARENT_TYPE_value;
331 EGLint EGL_TRANSPARENT_BLUE_VALUE_value;
332 EGLint EGL_TRANSPARENT_GREEN_VALUE_value;
333 EGLint EGL_TRANSPARENT_RED_VALUE_value;
334 EGLint EGL_BIND_TO_TEXTURE_RGB_value;
335 EGLint EGL_BIND_TO_TEXTURE_RGBA_value;
336 EGLint EGL_MIN_SWAP_INTERVAL_value;
337 EGLint EGL_MAX_SWAP_INTERVAL_value;
338 EGLint EGL_LUMINANCE_SIZE_value;
339 EGLint EGL_ALPHA_MASK_SIZE_value;
340 EGLint EGL_COLOR_BUFFER_TYPE_value;
342 EGLint EGL_RENDERABLE_TYPE_value;
344 eglGetConfigAttrib(iDisplay, configs[index], EGL_BUFFER_SIZE, &EGL_BUFFER_SIZE_value);
345 eglGetConfigAttrib(iDisplay, configs[index], EGL_ALPHA_SIZE, &EGL_ALPHA_SIZE_value);
346 eglGetConfigAttrib(iDisplay, configs[index], EGL_BLUE_SIZE, &EGL_BLUE_SIZE_value);
347 eglGetConfigAttrib(iDisplay, configs[index], EGL_GREEN_SIZE, &EGL_GREEN_SIZE_value);
348 eglGetConfigAttrib(iDisplay, configs[index], EGL_RED_SIZE, &EGL_RED_SIZE_value);
349 #ifdef PRINT_ALL_CONFIGS_DETAILS
350 eglGetConfigAttrib(iDisplay, configs[index], EGL_DEPTH_SIZE, &EGL_DEPTH_SIZE_value);
351 eglGetConfigAttrib(iDisplay, configs[index], EGL_STENCIL_SIZE, &EGL_STENCIL_SIZE_value);
352 eglGetConfigAttrib(iDisplay, configs[index], EGL_CONFIG_CAVEAT, &EGL_CONFIG_CAVEAT_value);
353 eglGetConfigAttrib(iDisplay, configs[index], EGL_CONFIG_ID, &EGL_CONFIG_ID_value);
354 eglGetConfigAttrib(iDisplay, configs[index], EGL_LEVEL, &EGL_LEVEL_value);
355 eglGetConfigAttrib(iDisplay, configs[index], EGL_MAX_PBUFFER_HEIGHT, &EGL_MAX_PBUFFER_HEIGHT_value);
356 eglGetConfigAttrib(iDisplay, configs[index], EGL_MAX_PBUFFER_PIXELS, &EGL_MAX_PBUFFER_PIXELS_value);
357 eglGetConfigAttrib(iDisplay, configs[index], EGL_MAX_PBUFFER_WIDTH, &EGL_MAX_PBUFFER_WIDTH_value);
358 eglGetConfigAttrib(iDisplay, configs[index], EGL_NATIVE_RENDERABLE, &EGL_NATIVE_RENDERABLE_value);
359 eglGetConfigAttrib(iDisplay, configs[index], EGL_NATIVE_VISUAL_ID, &EGL_NATIVE_VISUAL_ID_value);
360 eglGetConfigAttrib(iDisplay, configs[index], EGL_NATIVE_VISUAL_TYPE, &EGL_NATIVE_VISUAL_TYPE_value);
361 eglGetConfigAttrib(iDisplay, configs[index], EGL_SAMPLES, &EGL_SAMPLES_value);
362 eglGetConfigAttrib(iDisplay, configs[index], EGL_SAMPLE_BUFFERS, &EGL_SAMPLE_BUFFERS_value);
364 eglGetConfigAttrib(iDisplay, configs[index], EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value);
365 #ifdef PRINT_ALL_CONFIGS_DETAILS
366 eglGetConfigAttrib(iDisplay, configs[index], EGL_TRANSPARENT_TYPE, &EGL_TRANSPARENT_TYPE_value);
367 eglGetConfigAttrib(iDisplay, configs[index], EGL_TRANSPARENT_BLUE_VALUE, &EGL_TRANSPARENT_BLUE_VALUE_value);
368 eglGetConfigAttrib(iDisplay, configs[index], EGL_TRANSPARENT_GREEN_VALUE, &EGL_TRANSPARENT_GREEN_VALUE_value);
369 eglGetConfigAttrib(iDisplay, configs[index], EGL_TRANSPARENT_RED_VALUE, &EGL_TRANSPARENT_RED_VALUE_value);
370 eglGetConfigAttrib(iDisplay, configs[index], EGL_BIND_TO_TEXTURE_RGB, &EGL_BIND_TO_TEXTURE_RGB_value);
371 eglGetConfigAttrib(iDisplay, configs[index], EGL_BIND_TO_TEXTURE_RGBA, &EGL_BIND_TO_TEXTURE_RGBA_value);
372 eglGetConfigAttrib(iDisplay, configs[index], EGL_MIN_SWAP_INTERVAL, &EGL_MIN_SWAP_INTERVAL_value);
373 eglGetConfigAttrib(iDisplay, configs[index], EGL_MAX_SWAP_INTERVAL, &EGL_MAX_SWAP_INTERVAL_value);
374 eglGetConfigAttrib(iDisplay, configs[index], EGL_LUMINANCE_SIZE, &EGL_LUMINANCE_SIZE_value);
375 eglGetConfigAttrib(iDisplay, configs[index], EGL_ALPHA_MASK_SIZE, &EGL_ALPHA_MASK_SIZE_value);
376 eglGetConfigAttrib(iDisplay, configs[index], EGL_COLOR_BUFFER_TYPE, &EGL_COLOR_BUFFER_TYPE_value);
378 eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value);
382 INFO_PRINTF7(_L("(idx: %3d) RGBA=(%2d) %2d,%2d,%2d,%2d"), index, EGL_BUFFER_SIZE_value,
383 EGL_RED_SIZE_value, EGL_GREEN_SIZE_value, EGL_BLUE_SIZE_value,
384 EGL_ALPHA_SIZE_value);
385 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 0))
390 INFO_PRINTF2(_L("\n\n^^^^^^ CONFIG [%d] VALUES ******"), index);
391 if (EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT)
393 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d. <<< Has EGL_PIXMAP_BIT"), EGL_SURFACE_TYPE_value);
397 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d. <<< BAD (not pixmap)"), EGL_SURFACE_TYPE_value);
401 if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)
403 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d. <<< Has EGL_OPENVG_BIT"), EGL_RENDERABLE_TYPE_value);
407 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d. <<< BAD (not open vg)"), EGL_RENDERABLE_TYPE_value);
413 INFO_PRINTF1(_L("^^^^^^^ GOOD ^^^^^^^"));
416 #ifdef PRINT_ALL_CONFIGS_DETAILS
417 INFO_PRINTF2(_L("\n\n***** CONFIG [%d] VALUES ******"), index);
418 INFO_PRINTF2(_L("EGL_BUFFER_SIZE=%d."), EGL_BUFFER_SIZE_value);
419 INFO_PRINTF2(_L("EGL_ALPHA_SIZE=%d."), EGL_ALPHA_SIZE_value);
420 INFO_PRINTF2(_L("EGL_BLUE_SIZE=%d."), EGL_BLUE_SIZE_value);
421 INFO_PRINTF2(_L("EGL_GREEN_SIZE=%d."), EGL_GREEN_SIZE_value);
422 INFO_PRINTF2(_L("EGL_RED_SIZE=%d."), EGL_RED_SIZE_value);
423 INFO_PRINTF2(_L("EGL_DEPTH_SIZE=%d."), EGL_DEPTH_SIZE_value);
424 INFO_PRINTF2(_L("EGL_STENCIL_SIZE=%d."), EGL_STENCIL_SIZE_value);
425 INFO_PRINTF2(_L("EGL_CONFIG_CAVEAT=%d."), EGL_CONFIG_CAVEAT_value);
426 INFO_PRINTF2(_L("EGL_CONFIG_ID=%d."), EGL_CONFIG_ID_value);
427 INFO_PRINTF2(_L("EGL_LEVEL=%d."), EGL_LEVEL_value);
428 INFO_PRINTF2(_L("EGL_MAX_PBUFFER_HEIGHT=%d."), EGL_MAX_PBUFFER_HEIGHT_value);
429 INFO_PRINTF2(_L("EGL_MAX_PBUFFER_PIXELS=%d."), EGL_MAX_PBUFFER_PIXELS_value);
430 INFO_PRINTF2(_L("EGL_MAX_PBUFFER_WIDTH=%d."), EGL_MAX_PBUFFER_WIDTH_value);
431 INFO_PRINTF2(_L("EGL_NATIVE_RENDERABLE=%d."), EGL_NATIVE_RENDERABLE_value);
432 INFO_PRINTF2(_L("EGL_NATIVE_VISUAL_ID=%d."), EGL_NATIVE_VISUAL_ID_value);
433 INFO_PRINTF2(_L("EGL_NATIVE_VISUAL_TYPE=%d."), EGL_NATIVE_VISUAL_TYPE_value);
434 INFO_PRINTF2(_L("EGL_SAMPLES=%d."), EGL_SAMPLES_value);
435 INFO_PRINTF2(_L("EGL_SAMPLE_BUFFERS=%d."), EGL_SAMPLE_BUFFERS_value);
436 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d."), EGL_SURFACE_TYPE_value);
437 INFO_PRINTF2(_L("EGL_TRANSPARENT_TYPE=%d."), EGL_TRANSPARENT_TYPE_value);
438 INFO_PRINTF2(_L("EGL_TRANSPARENT_BLUE_VALUE=%d."), EGL_TRANSPARENT_BLUE_VALUE_value);
439 INFO_PRINTF2(_L("EGL_TRANSPARENT_GREEN_VALUE=%d."), EGL_TRANSPARENT_GREEN_VALUE_value);
440 INFO_PRINTF2(_L("EGL_TRANSPARENT_RED_VALUE=%d."), EGL_TRANSPARENT_RED_VALUE_value);
441 INFO_PRINTF2(_L("EGL_BIND_TO_TEXTURE_RGB=%d."), EGL_BIND_TO_TEXTURE_RGB_value);
442 INFO_PRINTF2(_L("EGL_BIND_TO_TEXTURE_RGBA=%d."), EGL_BIND_TO_TEXTURE_RGBA_value);
443 INFO_PRINTF2(_L("EGL_MIN_SWAP_INTERVAL=%d."), EGL_MIN_SWAP_INTERVAL_value);
444 INFO_PRINTF2(_L("EGL_MAX_SWAP_INTERVAL=%d."), EGL_MAX_SWAP_INTERVAL_value);
445 INFO_PRINTF2(_L("EGL_LUMINANCE_SIZE=%d."), EGL_LUMINANCE_SIZE_value);
446 INFO_PRINTF2(_L("EGL_ALPHA_MASK_SIZE=%d."), EGL_ALPHA_MASK_SIZE_value);
447 INFO_PRINTF2(_L("EGL_COLOR_BUFFER_TYPE=%d."), EGL_COLOR_BUFFER_TYPE_value);
448 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d."), EGL_RENDERABLE_TYPE_value);
449 INFO_PRINTF2(_L("\n*********************************\n\n"), index);
454 LOCAL_C TEglConfigMatchType GetMatchType(EGLint aAttrib, TEglConfigMatchRule aMatchRule)
456 const TConfigMatchRuleItem* curMatchRuleItem = KConfigMatchRules[aMatchRule];
458 while(curMatchRuleItem->iAttrib != EGL_NONE)
460 if (aAttrib == curMatchRuleItem->iAttrib)
462 return curMatchRuleItem->iMatchType;
467 RDebug::Printf("Unknown attrib %x", aAttrib);
468 return eMatchUnknown;
472 Returns the first index of a config that matches the requested config extactly
474 TInt CTestEglSession::GetFullMatchConfigIndex(EGLDisplay aDisplay, EGLConfig *aConfigs, TInt aNumConfigs,
475 const EGLint aWantedAttribs[], TEglConfigMatchRule aMatchRule)
478 for(TUint idxConfig=0; idxConfig<aNumConfigs; idxConfig++)
480 const EGLint *curAttrib = aWantedAttribs;
483 while(*curAttrib != EGL_NONE && match)
485 ASSERT_EGL_TRUE(eglGetConfigAttrib(aDisplay, aConfigs[idxConfig], *curAttrib, &value));
487 switch(GetMatchType(*curAttrib, aMatchRule))
490 if (value != curAttrib[1])
496 if (value < curAttrib[1]) // Note, we detect "failure to match", hence "<" not ">="!
502 if ((value & curAttrib[1]) != curAttrib[1])
511 // We should not get here.
518 // If we get here with match set, we have matched all attributes, and have found a match.
527 TInt CTestEglSession::ConfigToPixelFormatTableLength() const
529 return sizeof(KMapEglConfigToPixelFormat) / sizeof(TMapEglConfigToPixelFormat);
532 const TMapEglConfigToPixelFormat& CTestEglSession::ConfigToPixelFormatTable(TInt aIndex) const
534 return KMapEglConfigToPixelFormat[aIndex];
538 Returns pixel format inforamtion for a given EGL config.
539 @param aConfig The EGL config for which pixel format information will be returned.
540 @return A pointer to the pixel format information for the given EGL config.
541 Tf the config cannot be mapped, then NULL is returned.
543 EXPORT_C const TMapEglConfigToPixelFormat* CTestEglSession::GetPixelFormatFromEglConfigL(EGLConfig aConfig)
550 EGLint colorBufferType=0;
551 EGLint surfaceType = 0;
553 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_BUFFER_SIZE, &bufferSize));
554 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_ALPHA_SIZE, &alphaSize));
555 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_RED_SIZE, &redSize));
556 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_GREEN_SIZE, &greenSize));
557 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &blueSize));
558 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_COLOR_BUFFER_TYPE, &colorBufferType));
559 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &surfaceType));
561 INFO_PRINTF7(_L(">>>>> Config info: %d, %d, %d,%d,%d, 0x%x"), bufferSize, alphaSize, redSize, greenSize, blueSize, colorBufferType);
563 for(TUint i=0; i<ConfigToPixelFormatTableLength(); i++)
565 if ((ConfigToPixelFormatTable(i).iBufferSize == bufferSize)
566 && (ConfigToPixelFormatTable(i).iAlphaSize == alphaSize)
567 && (ConfigToPixelFormatTable(i).iRedSize == redSize)
568 && (ConfigToPixelFormatTable(i).iGreenSize == greenSize)
569 && (ConfigToPixelFormatTable(i).iBlueSize == blueSize)
570 && (ConfigToPixelFormatTable(i).iColorBufferType == colorBufferType)
571 && ((ConfigToPixelFormatTable(i).iSurfaceTypeFlags & surfaceType) == ConfigToPixelFormatTable(i).iSurfaceTypeFlags))
573 return &ConfigToPixelFormatTable(i);
580 EXPORT_C void CTestEglSession::CleanupSurfaceFbsBitmapL()
582 CleanupSurfaceAndContextL();
588 EXPORT_C void CTestEglSession::CleanupSurfaceAndContextL()
590 ASSERT_TRUE(iSurface != EGL_NO_SURFACE);
591 ASSERT_TRUE(iContext != EGL_NO_CONTEXT);
594 INFO_PRINTF1(_L("Calling eglMakeCurrent(NULL values)..."));
595 CHECK_EXPECTED_ERROR(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
597 INFO_PRINTF1(_L("Calling eglDestroyContext()..."));
598 CHECK_EXPECTED_ERROR(eglDestroyContext(iDisplay, iContext));
599 iContext = EGL_NO_CONTEXT;
601 INFO_PRINTF1(_L("Calling eglDestroySurface()..."));
602 CHECK_EXPECTED_ERROR(eglDestroySurface(iDisplay, iSurface));
603 iSurface = EGL_NO_SURFACE;
606 EXPORT_C CFbsBitmap* CTestEglSession::NativeFbsBitmap()
611 EXPORT_C RSgImage& CTestEglSession::NativeSgImage()
616 EXPORT_C EGLSurface CTestEglSession::Surface() const
621 EXPORT_C EGLContext CTestEglSession::Context() const
626 EXPORT_C EGLConfig CTestEglSession::GetConfigExactMatchL(TEglTestConfig aConfigAttribIndex, TEglConfigMatchRule aMatchRule)
628 if(aConfigAttribIndex >= EEglTestConfigMax )
630 ERR_PRINTF1(_L("Attribute index out of range, please check the INI file"));
631 User::Leave(KErrArgument);
634 EGLConfig configs[KMaxEglConfigs];
636 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[aConfigAttribIndex], configs, KMaxEglConfigs, &numConfigs));
639 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error)
640 WARN_PRINTF1(_L("GetConfigExactMatchL - Could not find a matching config, eglChooseConfig returned 0 configs!"));
641 User::Leave(KTestNoMatchingConfig);
644 // Check that any of the configs returned matches the desired attributes
645 TInt match = GetFullMatchConfigIndex(iDisplay, configs, numConfigs, KConfigAttribs[aConfigAttribIndex], aMatchRule);
646 if (match == KErrNotFound)
648 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error)
649 WARN_PRINTF1(_L("GetConfigExactMatchL - Could not find a matching config amongst those returned by eglChooseConfig!"));
650 User::Leave(KTestNoMatchingConfig);
652 return configs[match];
656 Creates a pixmap surface from a CFbsBitmap, draws to it and checks that the drawing operation succeeded.
658 EXPORT_C void CTestEglSession::TryUsePixmapCFbsBitmapL()
660 INFO_PRINTF2(_L("thread %d: TryUsePixmapCFbsBitmapL"), iThreadIdx);
661 EGLConfig currentConfig = GetConfigExactMatchL(EPixmapAttribsColor64K);
662 TryUsePixmapCFbsBitmapOpenVgL(currentConfig, KPixmapSize, EColor64K);
666 Creates a pixmap surface from a CFbsBitmap, draws to it and checks that the drawing operation succeeded.
668 EXPORT_C void CTestEglSession::TryUsePixmapCFbsBitmapOpenVgL(EGLConfig aConfig, const TSize& aSize, TDisplayMode aDisplayMode)
670 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aSize, aDisplayMode);
673 // Wait for the drawing to complete
676 CheckImageDataL(iFbsBitmap);
677 CheckImageDataVgL(VG_sRGB_565);
678 CleanupSurfaceFbsBitmapL();
683 Creates a pixmap surface from a CFbsBitmap, draws to it and checks that the drawing operation succeeded.
685 EXPORT_C void CTestEglSession::TryUsePixmapCFbsBitmapOpenGlesL(EGLConfig aConfig, const TSize& aSize, TDisplayMode aDisplayMode, TInt aRenderVersion)
687 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aSize, aDisplayMode,EGL_OPENGL_ES_API, aRenderVersion);
690 // Wait for the drawing to complete
693 CheckImageDataFullRedishL(iFbsBitmap);
694 CleanupSurfaceFbsBitmapL();
699 Creates a pixmap surface from a RSgImage, draws to it and checks that the drawing operation succeeded.
701 EXPORT_C void CTestEglSession::TryUsePixmapRSgImageL()
703 INFO_PRINTF2(_L("thread %d: TryUsePixmapRSgImageL"), iThreadIdx);
704 TSgImageInfo imageInfo;
705 imageInfo.iSizeInPixels = KPixmapSize;
706 imageInfo.iPixelFormat = EUidPixelFormatXRGB_8888;
707 // will draw to and read from the image using OpenVg
708 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
709 imageInfo.iUsage = ESgUsageBitOpenVgSurface | ESgUsageBitOpenVgImage;
711 // will also read from the image using DirectGdi
712 imageInfo.iUsage = ESgUsageOpenVgTarget | ESgUsageDirectGdiSource;
713 imageInfo.iShareable = EFalse;
714 imageInfo.iCpuAccess = ESgCpuAccessNone;
715 imageInfo.iScreenId = KSgScreenIdMain;
716 imageInfo.iUserAttributes = NULL;
717 imageInfo.iUserAttributeCount=0;
719 CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, EResourceCloseSgImageLate);
722 // Wait for the drawing to complete
725 //we can't retrieve data directly from the SgImage as
726 //non-unified architecture doesn't allow readback from the GPU
727 CheckImageDataVgL(VG_sXRGB_8888);
728 CleanupSurfaceSgImageL();
732 EXPORT_C TBool CTestEglSession::TryUsePixmapRSgImageOpenGlesL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, TInt aRenderVersion)
734 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule ,EGL_OPENGL_ES_API, aRenderVersion);
738 // Wait for the drawing to complete
741 //we can't retrieve data directly from SgImage as non-unified
742 //architecture doesn't allow readback from the GPU
744 if (aImageInfo.iPixelFormat == EUidPixelFormatXRGB_8888 ||
745 aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE)
747 CheckImageDataGLesL();
750 CleanupSurfaceSgImageL();
756 Compound operation that constructs an RSgImage and uses it to create a pixmap suface.
757 It then draws to the surface using OpenVG and checks whether the drawing succeeded.
758 It cleans up the pixmap surface it destroyed.
759 @param aConfig The EGL config to be used when creating the pixmap surface
760 @param aImageInfo Used to create the RSgImage pixmap
761 @param aCloseNativeImageEarly When ETrue, the RSgImage is closed as soon as the pixmap surface has been
762 created. Otherwise, the RSgImage is closed during cleanup, when the pixmap surface is destroyed.
763 @return Whether it was possible to create an iSgImage for the given aImageInfo
765 EXPORT_C TBool CTestEglSession::TryUsePixmapRSgImageOpenVgL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule)
767 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule);
771 // Wait for the drawing to complete
774 //we can't retrieve data directly from the SgImage as
775 //non-unified architecture doesn't allow readback from the GPU
776 CheckImageDataVgL(VG_sXRGB_8888);
777 CleanupSurfaceSgImageL();
782 EXPORT_C void CTestEglSession::CreateWindowSurfaceAndMakeCurrentL(EGLConfig aConfig, RWindow& aWindow, TBool aVgAlphaFormatPre, EGLenum aBindAPI, TInt aRenderVersionNumber, EGLint* aAttribList)
784 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
785 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
787 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
789 // Create a Window surface from the native image
790 const EGLint* windowAttribs = aAttribList;
793 windowAttribs = (aVgAlphaFormatPre && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
795 iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, windowAttribs);
796 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
798 // Create a context for drawing to/reading from the pixmap surface and make it current
799 const EGLint KAttribsListCtxNone[] = { EGL_NONE };
800 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
801 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone;
802 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx);
803 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
804 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
808 EXPORT_C TBool CTestEglSession::CongfigSupportsOpenVgL(EGLConfig aConfig)
810 EGLint EGL_RENDERABLE_TYPE_value = 0;
811 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value));
812 return (EGL_RENDERABLE_TYPE_value&EGL_OPENVG_BIT)>0;
815 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentAndMatchL(const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, EGLenum aBindAPI, TInt aRenderVersionNumber)
817 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
818 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
821 ASSERT_EQUALS(iSgImage.Create(aImageInfo, NULL, 0), KErrNone);
823 EGLint renderableType = 0;
824 if(aBindAPI == EGL_OPENVG_API)
826 renderableType = EGL_OPENVG_BIT;
828 else if(aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber==1)
830 renderableType = EGL_OPENGL_ES_BIT;
832 else if(aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber==2)
834 renderableType = EGL_OPENGL_ES2_BIT;
838 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentAndMatchL - Unkown API requested!"));
839 User::Leave(KErrArgument);
841 EGLint attrib_list[] = {
842 EGL_MATCH_NATIVE_PIXMAP,(TInt)&iSgImage,
843 EGL_RENDERABLE_TYPE,renderableType,
844 EGL_SURFACE_TYPE,EGL_PIXMAP_BIT,
847 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
851 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,attrib_list,&config,1,&numConfigs));
854 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error)
855 WARN_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentAndMatchL - Could not find a matching config!"));
858 // Leave with a unique knonwn error code - useful to catch this error in negative tests
859 User::Leave(KTestNoMatchingConfig);
862 // Create a pixmap surface from the native image
863 EGLint EGL_RENDERABLE_TYPE_value = 0;
864 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, config, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value));
865 const EGLint* pixmapAttribs = ((aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
866 iSurface = eglCreatePixmapSurface(iDisplay, config, &iSgImage, pixmapAttribs);
867 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
869 if (aResourceCloseRule == EResourceCloseSgImageEarly)
871 // EGL should have taken its own reference to the SgImage, so it should be able to continue
872 // to use the underlying data after this local image has been closed.
876 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly)
878 // EGL should have taken its own reference to the SgDriver, so it should be able to continue
879 // to use its reference to the image resource after this local reference to the driver has
885 // Create a context for drawing to/reading from the pixmap surface and make it current
886 const EGLint KAttribsListCtxNone[] = { EGL_NONE };
887 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
888 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone;
889 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx);
890 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
891 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
895 Compound operation that constructs an RSgImage and uses it to create a pixmap suface.
896 It then makes it current to the thread.
897 @param aConfig The EGL config to be used when creating the pixmap surface
898 @param aImageInfo Used to create the RSgImage pixmap
899 @param aCloseNativeImageEarly When ETrue, the RSgImage is closed as soon as the pixmap surface has been
900 created. Otherwise, the RSgImage is left to be destroyed later by some other method
901 - e.g at the same time as destroying the surface.
902 @return Whether it was possible to create an iSgImage for the given aImageInfo
904 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, EGLenum aBindAPI, TInt aRenderVersionNumber)
906 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
907 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
910 ASSERT_EQUALS(iSgImage.Create(aImageInfo, NULL, 0), KErrNone);
912 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
914 // Create a pixmap surface from the native image
915 EGLint EGL_RENDERABLE_TYPE_value = 0;
916 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value));
917 const EGLint* pixmapAttribs = ((aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
918 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, &iSgImage, pixmapAttribs);
919 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
921 if (aResourceCloseRule == EResourceCloseSgImageEarly)
923 // EGL should have taken its own reference to the SgImage, so it should be able to continue
924 // to use the underlying data after this local image has been closed.
927 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly)
929 // EGL should have taken its own reference to the SgDriver, so it should be able to continue
930 // to use its reference to the image resource after this local reference to the driver has
936 // Create a context for drawing to/reading from the pixmap surface and make it current
937 const EGLint KAttribsListCtxNone[] = { EGL_NONE };
938 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
939 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone;
940 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx);
941 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
942 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
945 EXPORT_C TInt CTestEglSession::CreateBitmap(CFbsBitmap* aFbsBitmap, const TSize& aSize, TDisplayMode aDisplayMode)
947 //Fist try with CreateHardwareBitmap to check whether we are on hardware
948 TInt result = aFbsBitmap->CreateHardwareBitmap(aSize, aDisplayMode, KUidEglTestServer);
950 if(result == KErrNotSupported)
952 //we are not on hardware
953 result = aFbsBitmap->Create(aSize, aDisplayMode);
958 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSize& aSize, TDisplayMode displayMode, EGLenum aBindAPI, TInt aRenderVersionNumber)
960 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
961 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
963 // Create an empty native CFbsBitmap
965 iFbsBitmap = new(ELeave)CFbsBitmap;
966 ASSERT_EQUALS(CreateBitmap(iFbsBitmap, aSize, displayMode), KErrNone);
968 const EGLint* attrib_list = NULL;
969 if(aBindAPI == EGL_OPENVG_API)
971 // no attribs to modify
973 else if(aBindAPI == EGL_OPENGL_ES_API)
975 // no attribs to modify
977 else if(aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber==2)
979 const EGLint KAttribGLES2[] = {EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE};
980 attrib_list=KAttribGLES2;
984 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentL - Unkown API requested!"));
985 User::Leave(KErrArgument);
987 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
989 // Create a pixmap surface from the native image
990 EGLint EGL_RENDERABLE_TYPE_value = 0;
991 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value));
992 const EGLint* pixmapAttribs = ((displayMode == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
993 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, iFbsBitmap, pixmapAttribs);
994 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
996 // Create a context for drawing to/reading from the pixmap surface and make it current
997 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list);
998 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
999 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
1002 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentAndMatchL(const TSize& aSize, TDisplayMode aDisplayMode, EGLenum aBindAPI, TInt aRenderVersionNumber)
1004 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
1005 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
1008 iFbsBitmap = new(ELeave)CFbsBitmap;
1009 ASSERT_EQUALS(CreateBitmap(iFbsBitmap, aSize, aDisplayMode), KErrNone);
1011 EGLint renderableType = 0;
1012 if(aBindAPI == EGL_OPENVG_API)
1014 renderableType = EGL_OPENVG_BIT;
1016 else if(aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber==1)
1018 renderableType = EGL_OPENGL_ES_BIT;
1020 else if(aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber==2)
1022 renderableType = EGL_OPENGL_ES2_BIT;
1026 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentAndMatchL - Unkown API requested!"));
1027 User::Leave(KErrArgument);
1029 EGLint attrib_list[] = {
1030 EGL_MATCH_NATIVE_PIXMAP,(TInt)iFbsBitmap,
1031 EGL_RENDERABLE_TYPE,renderableType,
1032 EGL_SURFACE_TYPE,EGL_PIXMAP_BIT,
1035 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
1039 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay,attrib_list,&config,1,&numConfigs));
1040 if (numConfigs <= 0)
1042 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error)
1043 WARN_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentAndMatchL - Could not find a matching config!"));
1046 // Leave with a unique knonwn error code - useful to catch this error in negative tests
1047 User::Leave(KTestNoMatchingConfig);
1050 // Create a pixmap surface from the native image
1051 const EGLint* pixmapAttribs = (aDisplayMode == EColor16MAP && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
1052 iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs);
1053 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
1055 // Create a context for drawing to/reading from the pixmap surface and make it current
1056 const EGLint KAttribsListCtxNone[] = { EGL_NONE };
1057 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
1058 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone;
1059 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx);
1060 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
1061 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
1064 EXPORT_C void CTestEglSession::CreatePbufferSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSize& aSize, EGLenum aBindAPI, TInt aRenderVersionNumber)
1066 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
1067 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
1069 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
1070 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
1072 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
1074 // PBuffer attribs options are:
1075 // EGL_WIDTH, EGL_HEIGHT, EGL_LARGEST_PBUFFER,
1076 // EGL_TEXTURE_FORMAT, EGL_TEXTURE_TARGET, EGL_MIPMAP_TEXTURE,
1077 // EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT
1078 // Create a pbuffer surface of the given size
1079 const EGLint KPbufferAttribs[] = {
1080 EGL_WIDTH, aSize.iWidth,
1081 EGL_HEIGHT, aSize.iHeight,
1083 iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs);
1084 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
1086 // Create a context for drawing to/reading from the pixmap surface and make it current
1087 const EGLint KAttribsListCtxNone[] = { EGL_NONE };
1088 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
1089 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone;
1090 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx);
1091 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
1092 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
1095 EXPORT_C void CTestEglSession::DrawOpenVgL()
1097 ASSERT_TRUE(iSurface != EGL_NO_SURFACE);
1098 ASSERT_TRUE(iContext != EGL_NO_CONTEXT);
1100 // Draw to the pixmap surface
1102 VGfloat colorBackground[4];
1103 ConvertColor(KRgbReddish, colorBackground);
1104 vgSetfv(VG_CLEAR_COLOR, 4, colorBackground);
1105 vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
1107 // And add a square: greenish
1108 VGfloat colorSquare[4];
1109 ConvertColor(KRgbGreenish, colorSquare);
1110 vgSetfv(VG_CLEAR_COLOR, 4, colorSquare);
1111 vgClear(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iX, KPixmapSquare.Width(), KPixmapSquare.Height());
1114 EXPORT_C void CTestEglSession::DrawOpenGLesL()
1116 ASSERT_TRUE(iSurface != EGL_NO_SURFACE);
1117 ASSERT_TRUE(iContext != EGL_NO_CONTEXT);
1118 //GreenishRGB 0x46, 0xDC, 0x78
1119 const GLfloat glRed = KRgbReddish.Red();
1120 const GLfloat glGreen = KRgbReddish.Green();
1121 const GLfloat glBlue = KRgbReddish.Blue();
1122 const GLfloat glAlpha = KRgbReddish.Alpha();
1123 const GLfloat glRedBits = 255.f;
1124 const GLfloat glGreenBits = 255.f;
1125 const GLfloat glBlueBits = 255.f;
1126 const GLfloat glAlphaBits = 255.f;
1128 // Disable cdither - when using exact comparison to reference bitmap
1129 // because reference bitmap cannot be created to match dither exactly
1130 glDisable(GL_DITHER);
1131 // Clear the surface to the colour specified
1132 glClearColor((glRed)/glRedBits, (glGreen)/glGreenBits, (glBlue)/glBlueBits, glAlpha/glAlphaBits);
1134 //glColor3f(KRgbGreenish.Red(),KRgbGreenish.Green(),KRgbGreenish.Blue());
1135 //glRectf(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iY,KPixmapSquare.iTl.iX + KPixmapSquare.Width(),KPixmapSquare.iTl.iY + KPixmapSquare.Height());
1137 glClear(GL_COLOR_BUFFER_BIT);
1140 EXPORT_C void CTestEglSession::CheckImageDataL(CFbsBitmap* aFbsBitmap)
1142 // Use native API's to check pixel values in the surface - note that this is not an OpenVG test, so no boundary pixels are tested
1143 TRgb rgbPixelSample;
1144 // Outside the square
1145 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(10,10));
1146 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse));
1147 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(90,90));
1148 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse));
1150 // Inside the square
1151 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(30,30));
1152 ASSERT_TRUE(PixelsMatch(KRgbGreenish, rgbPixelSample, EFalse));
1153 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(70,70));
1154 ASSERT_TRUE(PixelsMatch(KRgbGreenish, rgbPixelSample, EFalse));
1157 EXPORT_C void CTestEglSession::CheckImageDataFullRedishL(CFbsBitmap* aFbsBitmap)
1159 // Use native API's to check pixel values in the surface - note that this is not an OpenVG test, so no boundary pixels are tested
1160 TRgb rgbPixelSample;
1161 // Outside the square
1162 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(10,10));
1163 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse));
1164 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(90,90));
1165 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse));
1167 // Inside the square
1168 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(30,30));
1169 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse));
1170 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(70,70));
1171 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse));
1175 Use OpenVG to check pixel values
1176 @param aDataFormat The VG image data format of the current surface
1178 EXPORT_C void CTestEglSession::CheckImageDataVgL(VGImageFormat aDataFormat)
1184 TUint16 intPixelSample=0;
1186 // Outside the square
1187 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1);
1188 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse));
1189 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1);
1190 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse));
1192 // Inside the square
1193 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1);
1194 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse));
1195 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1);
1196 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse));
1201 TUint32 intPixelSample=0;
1203 // Outside the square
1204 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1);
1205 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse));
1206 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1);
1207 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse));
1209 // Inside the square
1210 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1);
1211 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse));
1212 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1);
1213 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse));
1218 TUint32 intPixelSample=0;
1220 // Outside the square
1221 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1);
1222 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse));
1223 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1);
1224 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse));
1226 // Inside the square
1227 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1);
1228 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse));
1229 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1);
1230 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse));
1234 WARN_PRINTF2(_L("Unexpected image data format %d in CTestEglSession::CheckImageDataVgL"), aDataFormat);
1235 ASSERT_TRUE(EFalse);
1240 Use OpenGLes to check pixel values
1241 @param aDataFormat The VG image data format of the current surface
1243 EXPORT_C void CTestEglSession::CheckImageDataGLesL()
1245 TUint32 intPixelSample;
1246 glReadPixels(10,10,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample);
1247 SwapChannels(intPixelSample);
1248 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse));
1250 glReadPixels(45,45,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample);
1251 SwapChannels(intPixelSample);
1252 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse));
1254 glReadPixels(55,55,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample);
1255 SwapChannels(intPixelSample);
1256 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse));
1258 glReadPixels(99,99,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample);
1259 SwapChannels(intPixelSample);
1260 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse));
1264 EXPORT_C void CTestEglSession::SwapChannels(TUint32 &aSwapMe)
1266 TUint32 buff = aSwapMe;
1269 aSwapMe |= (buff & 0x000000FF) << 16;
1270 aSwapMe |= (buff & 0x0000FF00);
1271 aSwapMe |= (buff & 0x00FF0000) >> 16;
1272 aSwapMe |= (buff & 0xFF000000);
1276 Destroys the surface and underlying RSgImage object.
1277 Nulls the current context.
1279 EXPORT_C void CTestEglSession::CleanupSurfaceSgImageL()
1281 CleanupSurfaceAndContextL();
1287 Resets the internal surface and context handles without destroying them.
1288 Also closes the internal RSgImage handled that is associated to the surface.
1290 EGL destroys all surface and context handles associated with a display when
1291 eglTerminate() is called.
1293 EXPORT_C void CTestEglSession::ResetSurfaceAndContextSgImageL()
1295 INFO_PRINTF1(_L("CTestEglSession::ResetSurfaceAndContextSgImageL()"));
1297 iContext = EGL_NO_CONTEXT;
1298 iSurface = EGL_NO_SURFACE;
1303 Check that the pixel values match within a predefined tolerance
1304 @param aExpected the expected pixel colour vaule
1305 @param aActual the actual pixel colour value
1306 @param aCheckAlpha Whether to check the alpha channel value
1307 @return Whether the pixel values match - within the allowed tolerance
1309 EXPORT_C TBool CTestEglSession::PixelsMatch(const TRgb& aExpected, const TRgb& aActual, TBool aCheckAlpha)
1311 // This value has been carefully selected. If it is too high it could be hidding genuine pixel value
1312 // differences, while too low will be too strict to allow for pixel conversions, i.e. from 16bpp to 32bpp
1313 const TInt KPixelTolerance = 8;
1315 if (aCheckAlpha && aExpected.Alpha()== 0 &&
1316 aActual.Red() == 0 &&
1317 aActual.Green() == 0 &&
1318 aActual.Blue() == 0 &&
1319 aActual.Alpha() == 0)
1321 // if the expected value for alpha is 0, all actual values should be 0
1324 else if (Abs(aExpected.Red() - aActual.Red()) > KPixelTolerance ||
1325 Abs(aExpected.Green() - aActual.Green()) > KPixelTolerance ||
1326 Abs(aExpected.Blue() - aActual.Blue()) > KPixelTolerance ||
1327 aCheckAlpha && Abs(aExpected.Alpha() - aActual.Alpha()) > KPixelTolerance)
1329 // one or more of the actual values differ by more than the allowed tolerance
1330 ERR_PRINTF6(_L("thread %d: Expected r:%d g:%d b:%d a:%d"), iThreadIdx, aExpected.Red(), aExpected.Green(), aExpected.Blue(), aExpected.Alpha());
1331 ERR_PRINTF6(_L("thread %d: Actual r:%d g:%d b:%d a:%d"), iThreadIdx, aActual.Red(), aActual.Green(), aActual.Blue(), aActual.Alpha());
1332 ERR_PRINTF6(_L("thread %d: diff r:%d g:%d b:%d a:%d"), iThreadIdx, Abs(aExpected.Red() - aActual.Red()), Abs(aExpected.Green() - aActual.Green()), Abs(aExpected.Blue() - aActual.Blue()), Abs(aExpected.Alpha() - aActual.Alpha()));
1338 EXPORT_C void CTestEglSession::InitializeL(TBool aTerminateDisplay)
1340 // Initialize display object
1341 INFO_PRINTF2(_L("thread %d: Calling eglInitialize..."), iThreadIdx);
1344 CHECK_EXPECTED_ERROR(eglInitialize(iDisplay, &major, &minor));
1345 // Remember if the user wants us to terminate the display.
1346 iTerminateDisplay = aTerminateDisplay;
1348 INFO_PRINTF4(_L("thread %d: Initialised: EGL Version %d.%d"), iThreadIdx, major, minor);
1352 EXPORT_C void CTestEglSession::TerminateDisplayL()
1354 if (iSurface != EGL_NO_SURFACE)
1356 WARN_PRINTF2(_L("thread %d: iSurface has not been destoroyed in TerminateDisplayL..."), iThreadIdx);
1358 if (iContext != EGL_NO_CONTEXT)
1360 WARN_PRINTF2(_L("thread %d: iContext has not been destoroyed in TerminateDisplayL..."), iThreadIdx);
1362 if (iDisplay != EGL_NO_DISPLAY)
1364 INFO_PRINTF2(_L("thread %d: Calling eglMakeCurrent(NULL values) from TerminateDisplayL..."), iThreadIdx);
1366 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1368 INFO_PRINTF1(_L("Calling eglTerminate..."));
1369 ASSERT_EGL_TRUE(eglTerminate(iDisplay));
1370 iDisplay = EGL_NO_DISPLAY;
1372 iTerminateDisplay = EFalse;
1375 EXPORT_C void CTestEglSession::OpenSgDriverL()
1379 VERBOSE_INFO_PRINTF2(_L("CTestEglSession<0x%08x> Opening SgDriver"), this);
1380 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1381 TInt ret=iSgDriver.Open();
1383 TInt ret=SgDriver::Open();
1384 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1385 ASSERT_EQUALS(ret, KErrNone);
1386 iSgDriverOpen = ETrue;
1390 EXPORT_C void CTestEglSession::CloseSgDriver()
1394 VERBOSE_INFO_PRINTF2(_L("CTestEglSession<0x%08x> Closing SgDriver"), this);
1395 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1399 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1400 iSgDriverOpen = EFalse;
1404 EXPORT_C void CTestEglSession::OpenFbsSessionL()
1406 if (!iFbsSessionOpen)
1408 INFO_PRINTF2(_L("CTestEglSession<0x%08x> Opening FbsSession"), this);
1409 TInt ret=RFbsSession::Connect();
1410 ASSERT_EQUALS(ret, KErrNone);
1411 iFbsSessionOpen = ETrue;
1415 EXPORT_C void CTestEglSession::CloseFbsSession()
1417 if (iFbsSessionOpen)
1419 INFO_PRINTF2(_L("CTestEglSession<0x%08x> Closing FbsSession"), this);
1420 RFbsSession::Disconnect();
1421 iFbsSessionOpen = EFalse;
1425 EXPORT_C TBool CTestEglSession::FetchProcEglCreateImageKhr()
1427 if (!ipfnEglCreateImageKHR)
1429 INFO_PRINTF2(_L("thread %d: Calling eglGetProcAddress(\"eglCreateImageKHR\")"), iThreadIdx);
1430 ipfnEglCreateImageKHR = reinterpret_cast<TFPtrEglCreateImageKhr>(eglGetProcAddress("eglCreateImageKHR"));
1431 if (ipfnEglCreateImageKHR==NULL)
1433 EGLint eglError = eglGetError();
1434 WARN_PRINTF2(_L("eglCreateImageKHR() not found - EGL Error: 0x%x"), eglError);
1437 return (ipfnEglCreateImageKHR!=NULL);
1440 EXPORT_C EGLImageKHR CTestEglSession::eglCreateImageKhrL(EGLDisplay aDisplay,EGLContext aContext,EGLenum aTarget,RSgImage* aSgImage,const EGLint *aAttr_List)
1442 TBool bSuccess = FetchProcEglCreateImageKhr();
1443 ASSERT_TRUE(bSuccess);
1444 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR"), iThreadIdx);
1445 EGLImageKHR eglImage = ipfnEglCreateImageKHR(aDisplay,aContext,aTarget,reinterpret_cast<EGLClientBuffer>(aSgImage),const_cast<EGLint *>(aAttr_List));
1449 EXPORT_C EGLImageKHR CTestEglSession::eglCreateImageKhrL(EGLDisplay aDisplay,EGLContext aContext,EGLenum aTarget,CFbsBitmap &aCFbsBitmap, const EGLint *aAttr_List)
1451 TBool bSuccess = FetchProcEglCreateImageKhr();
1452 ASSERT_TRUE(bSuccess);
1453 INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR, with CFBsBitmap)"), iThreadIdx);
1454 //the following call to eglCreateImageKHR MUST fail, error handling is made outside
1455 EGLImageKHR eglImage = ipfnEglCreateImageKHR(aDisplay,aContext,aTarget,reinterpret_cast<EGLClientBuffer>(&aCFbsBitmap),const_cast<EGLint *>(aAttr_List));
1459 EXPORT_C TBool CTestEglSession::FetchProcEglDestroyImageKhr()
1461 if (!ipfnEglDestroyImageKHR)
1463 INFO_PRINTF2(_L("thread %d: Calling eglGetProcAddress(\"eglDestroyImageKHR\")"), iThreadIdx);
1464 ipfnEglDestroyImageKHR = reinterpret_cast<TFPtrEglDestroyImageKhr>(eglGetProcAddress("eglDestroyImageKHR"));
1465 if (ipfnEglDestroyImageKHR==NULL)
1467 EGLint eglError = eglGetError();
1468 WARN_PRINTF2(_L("eglDestroyImageKHR() not found - EGL Error: 0x%x"), eglError);
1471 return (ipfnEglDestroyImageKHR!=NULL);
1474 EXPORT_C TBool CTestEglSession::DestroyEGLImage(EGLDisplay aDisplay, EGLImageKHR aEGLImageKHR)
1476 TBool bSuccess = FetchProcEglDestroyImageKhr();
1477 ASSERT_TRUE(bSuccess);
1478 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling eglDestroyImageKHR"), iThreadIdx);
1479 return ipfnEglDestroyImageKHR(aDisplay,aEGLImageKHR);
1482 EXPORT_C TBool CTestEglSession::FetchProcvgCreateImageTargetKhr()
1484 if (!ipfnvgCreateImageTargetKHR)
1486 INFO_PRINTF2(_L("thread %d: Calling eglGetProcAddress (\"vgCreateEGLImageTargetKHR\")"), iThreadIdx);
1487 ipfnvgCreateImageTargetKHR = reinterpret_cast<TFPtrVgCreateEglImageTargetKhr>(eglGetProcAddress("vgCreateEGLImageTargetKHR"));
1488 if (ipfnvgCreateImageTargetKHR==NULL)
1490 EGLint eglError = eglGetError();
1491 WARN_PRINTF2(_L("vgCreateImageTargetKHR() not found - EGL Error: 0x%x"), eglError);
1494 return (ipfnvgCreateImageTargetKHR!=NULL);
1497 EXPORT_C VGImage CTestEglSession::vgCreateImageTargetKHR(VGeglImageKHR aImage)
1499 TBool bSuccess = FetchProcvgCreateImageTargetKhr();
1500 ASSERT_TRUE(bSuccess);
1501 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling vgCreateEGLImageTargetKHR"), iThreadIdx);
1502 return ipfnvgCreateImageTargetKHR(aImage);
1505 EXPORT_C TBool CTestEglSession::IsACompatibleConfig(EGLConfig aConfig,RSgImage& aImage,TBool aLog)
1507 EGLint EGL_BUFFER_SIZE_value;
1508 EGLint EGL_ALPHA_SIZE_value;
1509 EGLint EGL_BLUE_SIZE_value;
1510 EGLint EGL_GREEN_SIZE_value;
1511 EGLint EGL_RED_SIZE_value;
1512 EGLint EGL_SURFACE_TYPE_value;
1513 EGLint EGL_RENDERABLE_TYPE_value;
1514 EGLint EGL_CONFIG_ID_value;
1516 eglGetConfigAttrib(iDisplay, aConfig, EGL_CONFIG_ID, &EGL_CONFIG_ID_value);
1517 eglGetConfigAttrib(iDisplay, aConfig, EGL_BUFFER_SIZE, &EGL_BUFFER_SIZE_value);
1518 eglGetConfigAttrib(iDisplay, aConfig, EGL_ALPHA_SIZE, &EGL_ALPHA_SIZE_value);
1519 eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &EGL_BLUE_SIZE_value);
1520 eglGetConfigAttrib(iDisplay, aConfig, EGL_GREEN_SIZE, &EGL_GREEN_SIZE_value);
1521 eglGetConfigAttrib(iDisplay, aConfig, EGL_RED_SIZE, &EGL_RED_SIZE_value);
1522 eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value);
1523 eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value);
1524 #ifdef PRINTG_CONFIGS_LOG
1525 INFO_PRINTF7(_L("(Config: %3d) RGBA=(%2d) %2d,%2d,%2d,%2d"), EGL_CONFIG_ID_value, EGL_BUFFER_SIZE_value,
1526 EGL_RED_SIZE_value, EGL_GREEN_SIZE_value, EGL_BLUE_SIZE_value,
1527 EGL_ALPHA_SIZE_value);
1528 INFO_PRINTF2(_L("RENDERABLE_TYPE %d"),EGL_RENDERABLE_TYPE_value);
1531 if(!(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT))
1537 //requested usage bits
1538 TSgImageInfo requestedImageInfo;
1539 aImage.GetInfo(requestedImageInfo);
1541 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1542 //potential usage bits
1544 potential.Open(aImage.Id(),ESgDoNotRestrictUsage);
1545 TSgImageInfo potentialImageInfo;
1546 potential.GetInfo(potentialImageInfo);
1550 switch(requestedImageInfo.iPixelFormat)
1552 case EUidPixelFormatRGB_565:
1553 if (!(EGL_RED_SIZE_value == 5 && EGL_GREEN_SIZE_value == 6 && EGL_BLUE_SIZE_value == 5 && EGL_ALPHA_SIZE_value == 0))
1558 case EUidPixelFormatXRGB_8888:
1559 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 0))
1564 case EUidPixelFormatARGB_8888_PRE:
1565 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 8))
1569 //just OVG cares about the premultiplied alpha
1570 if(EGL_RENDERABLE_TYPE_value& EGL_OPENVG_BIT)
1571 //if(requestedImageInfo.iUsage & ESgUsageBitOpenVgSurface)
1573 if(!(EGL_SURFACE_TYPE_value & EGL_VG_ALPHA_FORMAT_PRE_BIT))
1577 WARN_PRINTF2(_L("This Config can't be used with Pre-multipliedAlpha becasue EGL_SURFACE_TYPE has the wrong bits = %x"), EGL_SURFACE_TYPE_value);
1586 ERR_PRINTF2(_L("Wrong PixelFormat for a target, %x"), requestedImageInfo.iPixelFormat);
1595 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1597 //Check if strict matching requirements are met:
1598 //- All the supported APIs included in the EGL_RENDERABLE_TYPE of the
1599 // EGLConfig must be matched by the corresponding iUsage of RSgImage
1600 //- The following usages included in the iUsage of the RSgImage must be
1601 // matched by the corresponding API in EGL_RENDERABLE_TYPE of the EGLConfig:
1602 // ESgUsageBitOpenGlSurface-> EGL_OPENGL_BIT
1603 // ESgUsageBitOpenGlesSurface-> EGL_OPENGL_ES_BIT
1604 // ESgUsageBitOpenGles2Surface-> EGL_OPENGL_ES2_BIT
1605 // ESgUsageBitOpenVgSurface->EGL_OPENVG_BIT
1607 EGLint usageBitsMask = 0;
1608 if(requestedImageInfo.iUsage & ESgUsageBitOpenVgSurface)
1610 usageBitsMask |= EGL_OPENVG_BIT;
1612 if(requestedImageInfo.iUsage & ESgUsageBitOpenGles2Surface)
1614 usageBitsMask |= EGL_OPENGL_ES2_BIT;
1616 if(requestedImageInfo.iUsage & ESgUsageBitOpenGlesSurface)
1618 usageBitsMask |= EGL_OPENGL_ES_BIT;
1620 if(requestedImageInfo.iUsage & ESgUsageBitOpenGlSurface)
1622 usageBitsMask |= EGL_OPENGL_BIT;
1625 if(usageBitsMask != EGL_RENDERABLE_TYPE_value)
1630 // requested usage & RENDERABLE_TYPE > 0
1631 EGLint usageBitsMask = 0;
1632 if(requestedImageInfo.iUsage & ESgUsageOpenVgTarget)
1634 usageBitsMask |= EGL_OPENVG_BIT;
1636 if(requestedImageInfo.iUsage & ESgUsageOpenGlesTarget)
1638 usageBitsMask |= EGL_OPENGL_ES_BIT;
1640 if(requestedImageInfo.iUsage & ESgUsageOpenGles2Target)
1642 usageBitsMask |= EGL_OPENGL_ES2_BIT;
1644 if(!(usageBitsMask & EGL_RENDERABLE_TYPE_value))
1649 // potential usage >= RENDERABLE_TYPE
1651 EGLint potentialUsageBitsMask = 0;
1652 if(potentialImageInfo.iUsage & ESgUsageOpenVgTarget)
1654 potentialUsageBitsMask |= EGL_OPENVG_BIT;
1656 if(potentialImageInfo.iUsage & ESgUsageOpenGlesTarget)
1658 potentialUsageBitsMask |= EGL_OPENGL_ES_BIT;
1660 if(potentialImageInfo.iUsage & ESgUsageOpenGles2Target)
1662 potentialUsageBitsMask |= EGL_OPENGL_ES2_BIT;
1665 potentialUsageBitsMask = EGL_RENDERABLE_TYPE_value &~ potentialUsageBitsMask;
1666 if(potentialUsageBitsMask)
1670 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1674 EXPORT_C TBool CTestEglSession::CheckNeededExtensionL(TInt aExtension, const TDesC& aExtensionName)
1676 TBuf8<128> extensionName;
1677 extensionName.Copy(aExtensionName);
1678 if(aExtension & KEGL_RSgimage || extensionName.Compare(KEglRSgImage)==0)
1680 TBool bFoundExtensionEGL_NOK_pixmap_type_rsgimage = FindExtensionStringL(EIsEGL,KEglRSgImage);
1681 if (!bFoundExtensionEGL_NOK_pixmap_type_rsgimage)
1683 // The extension is not supported
1687 if(aExtension & KEGL_KHR_image_base || extensionName.Compare(KEglKhrImageBase)==0)
1689 TBool bFoundExtensionEGL_KHR_image = FindExtensionStringL(EIsEGL,KEglKhrImageBase);
1690 if (!bFoundExtensionEGL_KHR_image)
1692 // The extension is not supported
1696 if(aExtension & KEGL_KHR_image_pixmap || extensionName.Compare(KEglKhrImagePixmap)==0)
1698 TBool bFoundExtensionEGL_KHR_image = FindExtensionStringL(EIsEGL,KEglKhrImagePixmap);
1699 if (!bFoundExtensionEGL_KHR_image)
1701 // The extension is not supported
1705 if(aExtension & KVG_KHR_EGL_image || extensionName.Compare(KVgKhrEglImage)==0)
1707 TBool bFoundExtensionVG_KHR_EGL_image = FindExtensionStringL(EIsVG,KVgKhrEglImage);
1708 if (!bFoundExtensionVG_KHR_EGL_image)
1710 // The extension is not supported
1714 if(aExtension & KEGL_KHR_reusable_sync || extensionName.Compare(KEglKhrReusableSync)==0)
1716 TBool bFoundExtensionEGL_KHR_reusable_sync = FindExtensionStringL(EIsEGL,KEglKhrReusableSync);
1717 if (!bFoundExtensionEGL_KHR_reusable_sync)
1719 // The extension is not supported
1723 if(aExtension & KEGL_NOK__private__signal_sync || extensionName.Compare(KEglNokPrivateSignalSync)==0)
1725 TBool bFoundExtensionEGL_NOK__private__signal_sync = FindExtensionStringL(EIsEGL,KEglNokPrivateSignalSync);
1726 if (!bFoundExtensionEGL_NOK__private__signal_sync)
1728 // The extension is not supported
1732 if(aExtension & KEGL_NOKIA_swap_buffers || extensionName.Compare(KEglNokiaSwapBuffers)==0)
1734 TBool bFoundExtensionEGL_NOKIA_swap_buffer = FindExtensionStringL(EIsEGL,KEglNokiaSwapBuffers);
1735 if (!bFoundExtensionEGL_NOKIA_swap_buffer)
1737 // The extension is not supported
1741 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1742 if(aExtension & KEGL_SYMBIAN_image_preserved || extensionName.Compare(KEglSymbianImagePreserved)
1744 TBool bFoundExtensionEGL_SYMBIAN_image_preserved = FindExtensionStringL(EIsEGL,KEglSymbianImagePreserved);
1745 if (!bFoundExtensionEGL_SYMBIAN_image_preserved)
1747 // The extension is not supported
1751 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1752 if(aExtension & KEGL_NOK_image_endpoint || extensionName.Compare(KEglNokiaImageEndpoint)==0)
1754 TBool bFoundExtensionEGL_NOK_image_endpoint = FindExtensionStringL(EIsEGL,KEglNokiaImageEndpoint);
1755 if (!bFoundExtensionEGL_NOK_image_endpoint)
1757 // The extension is not supported
1761 if(aExtension & KEGL_NOK_surface_scaling || extensionName.Compare(KEglNokiaSurfaceScaling)==0)
1763 TBool bFoundExtensionEGL_NOK_surface_scaling = FindExtensionStringL(EIsEGL,KEglNokiaSurfaceScaling);
1764 if (!bFoundExtensionEGL_NOK_surface_scaling)
1766 // The extension is not supported
1773 EXPORT_C CFbsBitmap* CTestEglSession::CreateReferenceBitmapL(TDisplayMode aMode)
1777 ERR_PRINTF1(_L("Queried Reference Bitmap dispaly mode equal to ENone"));
1778 User::Leave(KErrTEFUnitFail);
1780 return CreateReferenceBitmapL(aMode,KRgbGreenish);
1783 EXPORT_C CFbsBitmap* CTestEglSession::CreateReferenceBitmapL(TDisplayMode aMode,const TRgb& aColour)
1786 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
1787 CleanupStack::PushL(bitmap);
1788 if(bitmap->Create(KPixmapSize,aMode) != KErrNone)
1792 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
1793 CleanupStack::PushL(bitmapDevice);
1794 CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
1795 CleanupStack::PushL(fbsBitGc);
1796 fbsBitGc->Activate(bitmapDevice);
1797 fbsBitGc->SetBrushColor(aColour);
1799 CleanupStack::PopAndDestroy(2,bitmapDevice);
1800 CleanupStack::Pop(bitmap);
1804 EXPORT_C CFbsBitmap* CTestEglSession::CreateReferenceMaskedBitmapL(TDisplayMode aRefBitmapMode, const TRgb& aPenBitmapColor, const CFbsBitmap* aMaskBitmap)
1808 // create the refBitmat (same size as the mask bitmap)
1809 // Note that we clear it to 'opaque black' as we assume the target surface has been cleared to 'opaque black' too
1810 // If either the surface or the refBitmap are cleared to another colour, update the other accordingly
1811 CFbsBitmap* refBitmap = new(ELeave) CFbsBitmap();
1812 CleanupStack::PushL(refBitmap);
1813 User::LeaveIfError(refBitmap->Create(aMaskBitmap->SizeInPixels(), aRefBitmapMode));
1814 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(refBitmap);
1815 CleanupStack::PushL(bitmapDevice);
1816 CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
1817 CleanupStack::PushL(fbsBitGc);
1818 fbsBitGc->Activate(bitmapDevice);
1819 fbsBitGc->SetBrushColor(KRgbBlack);
1822 // create the penBitmap (same size as the mask bitmap)
1823 CFbsBitmap* penBitmap = new(ELeave) CFbsBitmap();
1824 CleanupStack::PushL(penBitmap);
1825 User::LeaveIfError(penBitmap->Create(aMaskBitmap->SizeInPixels(), aRefBitmapMode));
1826 CFbsBitmapDevice* penbitmapDevice = CFbsBitmapDevice::NewL(penBitmap);
1827 CleanupStack::PushL(penbitmapDevice);
1828 CFbsBitGc* penBitGc = CFbsBitGc::NewL();
1829 CleanupStack::PushL(penBitGc);
1830 penBitGc->Activate(penbitmapDevice);
1831 penBitGc->SetBrushColor(aPenBitmapColor);
1834 // perform a masked bitmap transfer to the active refBitmap
1835 TRect bmpRect(TPoint(0, 0), refBitmap->SizeInPixels());
1836 fbsBitGc->Activate(bitmapDevice);
1837 fbsBitGc->BitBltMasked(TPoint(0, 0), penBitmap, bmpRect, aMaskBitmap, EFalse);
1839 CleanupStack::PopAndDestroy(5, bitmapDevice);
1840 CleanupStack::Pop(refBitmap);
1845 EXPORT_C CFbsBitmap* CTestEglSession::CreateReferenceBitmapL(TDisplayMode aMode, const TSize &aSize, const TInt aIndex)
1848 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
1849 CleanupStack::PushL(bitmap);
1850 User::LeaveIfError(bitmap->Create(aSize,aMode));
1852 TInt height = bitmap->SizeInPixels().iHeight;
1853 TInt width = bitmap->SizeInPixels().iWidth;
1855 // Initialise colour values to a random value (guarantees pixel uniqueness if update is done accordingly)
1861 TBitmapUtil bmpUtil(bitmap);
1862 bmpUtil.Begin(TPoint(0,0));
1863 for (TInt colIndex = 0; colIndex < width; ++colIndex)
1865 bmpUtil.SetPos(TPoint(colIndex, 0));
1866 for (TInt rowIndex =0; rowIndex < height; ++rowIndex)
1868 TRgb rgb(red, green, blue, alpha);
1869 switch(bitmap->DisplayMode())
1873 bmpUtil.SetPixel(rgb.Color64K());
1878 bmpUtil.SetPixel(rgb.Color16MU());
1883 bmpUtil.SetPixel(rgb.Color16MA());
1888 bmpUtil.SetPixel(rgb.Color16MAP());
1893 bmpUtil.SetPixel(rgb.Gray256());
1898 // We should not get here - colour mode not supported by these tests
1899 ERR_PRINTF1(_L("CTestEglSession::CreateReferenceBitmapL - Colour mode not supported!"));
1906 red = ++red + aIndex;
1911 green = --green - aIndex;
1913 green = green + 256;
1916 blue = ++blue + aIndex;
1921 alpha = --alpha - aIndex;
1923 alpha = alpha + 256;
1927 CleanupStack::Pop(bitmap);
1931 EXPORT_C void CTestEglSession::CheckVgDrawingL(VGImageFormat aDataFormat, const CFbsBitmap* aReferenceBitmap)
1934 TInt height = aReferenceBitmap->SizeInPixels().iHeight;
1935 TInt width = aReferenceBitmap->SizeInPixels().iWidth;
1941 TUint16* vgPixel = new(ELeave) TUint16[width];
1942 CleanupArrayDeletePushL(vgPixel);
1943 for (TInt y=0; y < height; y++)
1945 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin!
1946 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1);
1948 for (TInt x=0; x < width; x++)
1950 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y));
1951 if(!PixelsMatch(refPixel, TRgb::Color64K(vgPixel[x]), EFalse))
1953 User::Leave(KErrTEFUnitFail);
1957 CleanupStack::PopAndDestroy(vgPixel);
1963 TUint32* vgPixel = new(ELeave) TUint32[width];
1964 CleanupArrayDeletePushL(vgPixel);
1965 for (TInt y=0; y < height; y++)
1967 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin!
1968 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1);
1970 for (TInt x=0; x < width; x++)
1972 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y));
1973 if(!PixelsMatch(refPixel, TRgb::Color16MU(vgPixel[x]), EFalse))
1975 User::Leave(KErrTEFUnitFail);
1979 CleanupStack::PopAndDestroy(vgPixel);
1985 TUint32* vgPixel = new(ELeave) TUint32[width];
1986 CleanupArrayDeletePushL(vgPixel);
1987 for (TInt y=0; y < height; y++)
1989 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin!
1990 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1);
1992 for (TInt x=0; x < width; x++)
1994 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y));
1995 if(!PixelsMatch(refPixel, TRgb::Color16MA(vgPixel[x]), ETrue))
1997 User::Leave(KErrTEFUnitFail);
2001 CleanupStack::PopAndDestroy(vgPixel);
2005 case VG_sARGB_8888_PRE:
2007 TUint32* vgPixel = new(ELeave) TUint32[width];
2008 CleanupArrayDeletePushL(vgPixel);
2009 for (TInt y=0; y < height; y++)
2011 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin!
2012 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1);
2014 for (TInt x=0; x < width; x++)
2016 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y));
2017 if(!PixelsMatch(refPixel, TRgb::Color16MAP(vgPixel[x]), ETrue))
2019 User::Leave(KErrTEFUnitFail);
2023 CleanupStack::PopAndDestroy(vgPixel);
2028 // We should not get here - colour mode not supported by these tests
2029 ERR_PRINTF1(_L("CTestEglSession::CheckVgDrawingL - Colour mode not supported!"));
2035 EXPORT_C TBool CTestEglSession::IsOpenGLESSupported()
2037 if(!iIsSupportedRenderInitialized)
2039 CheckAllAvailableRenders();
2041 return iIsOpenGLESSupported;
2044 EXPORT_C TBool CTestEglSession::IsOpenGLES2Supported()
2046 if(!iIsSupportedRenderInitialized)
2048 CheckAllAvailableRenders();
2050 return iIsOpenGLES2Supported;
2052 EXPORT_C TBool CTestEglSession::IsOpenVGSupported()
2054 if(!iIsSupportedRenderInitialized)
2056 CheckAllAvailableRenders();
2058 return iIsOpenVGSupported;
2061 void CTestEglSession::CheckAllAvailableRenders()
2063 ASSERT_EGL_TRUE(iDisplay != EGL_NO_DISPLAY);
2064 TPtrC8 ptrEglClientApis((const TText8 *)eglQueryString(iDisplay, EGL_CLIENT_APIS));
2065 _LIT8(KOpenGLES, "OpenGL_ES");
2066 EGLint numConfigs= 0;
2068 if(ptrEglClientApis.Find(KOpenGLES) != KErrNotFound)
2071 const EGLint KAttrib_list_gles2[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
2073 EGLBoolean eglRes = eglChooseConfig(iDisplay, KAttrib_list_gles2, &config,1, &numConfigs);
2074 ASSERT_EGL_TRUE(eglRes == EGL_TRUE);
2077 iIsOpenGLES2Supported = ETrue;
2081 const EGLint KAttrib_list_gles[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
2083 eglRes = eglChooseConfig(iDisplay, KAttrib_list_gles, &config,1, &numConfigs);
2084 ASSERT_EGL_TRUE(eglRes == EGL_TRUE);
2087 iIsOpenGLESSupported = ETrue;
2090 _LIT8(KOpenVG, "OpenVG");
2091 if(ptrEglClientApis.Find(KOpenVG) != KErrNotFound)
2095 const EGLint KAttrib_list_vg[] = { EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
2097 EGLBoolean eglRes = eglChooseConfig(iDisplay, KAttrib_list_vg, &config,1, &numConfigs);
2098 ASSERT_EGL_TRUE(eglRes == EGL_TRUE);
2101 iIsOpenVGSupported = ETrue;
2104 iIsSupportedRenderInitialized = ETrue;