os/graphics/egl/egltest/inc/egltestcommonutils.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
*/
sl@0
    20
sl@0
    21
sl@0
    22
#ifndef EGLTESTCOMMONUTILS_H
sl@0
    23
#define EGLTESTCOMMONUTILS_H
sl@0
    24
sl@0
    25
#include <w32std.h>
sl@0
    26
#include <pixelformats.h>
sl@0
    27
#include <EGL/eglext.h>
sl@0
    28
#include <VG/openvg.h>
sl@0
    29
sl@0
    30
sl@0
    31
/******************************************************************************/	
sl@0
    32
/***																		***/	
sl@0
    33
/*** 	Global constants and definitions for EGL Tests						***/
sl@0
    34
/***																		***/	
sl@0
    35
/******************************************************************************/	
sl@0
    36
sl@0
    37
const TUidPixelFormat KDefaultSourceFormat = EUidPixelFormatARGB_8888_PRE;
sl@0
    38
const VGImageFormat   KDefaultSurfaceFormat = VG_sARGB_8888_PRE;
sl@0
    39
sl@0
    40
const TInt KMaxEglConfigs = 1024;
sl@0
    41
const TInt KTestNoMatchingConfig = -1714;
sl@0
    42
sl@0
    43
enum TExtensionsGroups
sl@0
    44
	{
sl@0
    45
    EIsUndefined,
sl@0
    46
    EIsRSgImage,
sl@0
    47
	EIsEGL,
sl@0
    48
	EIsVG,	
sl@0
    49
	EIsGLES
sl@0
    50
	};
sl@0
    51
	
sl@0
    52
/**
sl@0
    53
 Provides an index into KConfigAttribs
sl@0
    54
 */
sl@0
    55
enum TEglTestConfig
sl@0
    56
	{ 
sl@0
    57
	EPixmapAttribsColor64K,
sl@0
    58
	EPixmapAttribsColor16MU,
sl@0
    59
	EPixmapAttribsColor16MAP,
sl@0
    60
	EWindowAttribsColor64K,
sl@0
    61
	EWindowAttribsColor16MA,
sl@0
    62
	EWindowAttribsColor16MAP,
sl@0
    63
	EPBufferAttribsColor64K,
sl@0
    64
	EPBufferAttribsColor16MU,
sl@0
    65
	EPBufferAttribsColor16MA,
sl@0
    66
	EPBufferAttribsColor16MAP,	
sl@0
    67
	EPBufferAttribsColorGles64K,
sl@0
    68
	EWindowAttribsColor16MA_Preserved,
sl@0
    69
	EEglTestConfigMax			// Must be the last item in the list. 
sl@0
    70
	};
sl@0
    71
sl@0
    72
// Symbian config attributes for pixmaps / pbuffers / windows
sl@0
    73
static const EGLint KConfigAttribs[EEglTestConfigMax][15] =
sl@0
    74
	{
sl@0
    75
		{
sl@0
    76
		//EColor64K - Pixmap
sl@0
    77
		EGL_BUFFER_SIZE,    16,
sl@0
    78
		EGL_RED_SIZE,		5,
sl@0
    79
		EGL_GREEN_SIZE, 	6,
sl@0
    80
		EGL_BLUE_SIZE,		5,
sl@0
    81
		EGL_ALPHA_SIZE, 	0,
sl@0
    82
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
    83
		EGL_SURFACE_TYPE,	EGL_PIXMAP_BIT,
sl@0
    84
		EGL_NONE
sl@0
    85
		},
sl@0
    86
		{
sl@0
    87
		//EColor16MU - Pixmap
sl@0
    88
		EGL_BUFFER_SIZE,    24,
sl@0
    89
		EGL_RED_SIZE,		8,
sl@0
    90
		EGL_GREEN_SIZE, 	8,
sl@0
    91
		EGL_BLUE_SIZE,		8,
sl@0
    92
		EGL_ALPHA_SIZE,     0,
sl@0
    93
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
    94
		EGL_SURFACE_TYPE,	EGL_PIXMAP_BIT,
sl@0
    95
		EGL_NONE
sl@0
    96
		},
sl@0
    97
		{
sl@0
    98
		//EColor16MAP - Pixmap
sl@0
    99
		EGL_BUFFER_SIZE,    32,
sl@0
   100
		EGL_RED_SIZE,		8,
sl@0
   101
		EGL_GREEN_SIZE, 	8,
sl@0
   102
		EGL_BLUE_SIZE,		8,
sl@0
   103
		EGL_ALPHA_SIZE, 	8,
sl@0
   104
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   105
		EGL_SURFACE_TYPE,	EGL_PIXMAP_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
sl@0
   106
		EGL_NONE
sl@0
   107
		},
sl@0
   108
		{
sl@0
   109
		//EWindowAttribsColor64K - Window
sl@0
   110
		EGL_BUFFER_SIZE,    16,
sl@0
   111
		EGL_RED_SIZE,		5,
sl@0
   112
		EGL_GREEN_SIZE, 	6,
sl@0
   113
		EGL_BLUE_SIZE,		5,
sl@0
   114
		EGL_ALPHA_SIZE, 	0,
sl@0
   115
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   116
		EGL_SURFACE_TYPE,	EGL_WINDOW_BIT,
sl@0
   117
		EGL_NONE
sl@0
   118
		},
sl@0
   119
		{
sl@0
   120
		//EWindowAttribsColor16MA - Window
sl@0
   121
		EGL_BUFFER_SIZE,    32,
sl@0
   122
		EGL_RED_SIZE,		8,
sl@0
   123
		EGL_GREEN_SIZE, 	8,
sl@0
   124
		EGL_BLUE_SIZE,		8,
sl@0
   125
		EGL_ALPHA_SIZE, 	8,
sl@0
   126
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   127
		EGL_SURFACE_TYPE,	EGL_WINDOW_BIT,
sl@0
   128
		EGL_NONE
sl@0
   129
		},
sl@0
   130
		{
sl@0
   131
		//EWindowAttribsColor16MAP - Window
sl@0
   132
		EGL_BUFFER_SIZE,    32,
sl@0
   133
		EGL_RED_SIZE,		8,
sl@0
   134
		EGL_GREEN_SIZE, 	8,
sl@0
   135
		EGL_BLUE_SIZE,		8,
sl@0
   136
		EGL_ALPHA_SIZE, 	8,
sl@0
   137
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   138
		EGL_SURFACE_TYPE,	EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
sl@0
   139
		EGL_NONE
sl@0
   140
		},
sl@0
   141
		{
sl@0
   142
		// EPBufferAttribsColor64K - PBuffer
sl@0
   143
		EGL_BUFFER_SIZE,    16,
sl@0
   144
		EGL_RED_SIZE,		5,
sl@0
   145
		EGL_GREEN_SIZE, 	6,
sl@0
   146
		EGL_BLUE_SIZE,		5,
sl@0
   147
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   148
		EGL_SURFACE_TYPE,	EGL_PBUFFER_BIT,
sl@0
   149
		EGL_NONE
sl@0
   150
		},
sl@0
   151
		{
sl@0
   152
		// EPBufferAttribsColor16MU - PBuffer
sl@0
   153
		EGL_BUFFER_SIZE,    24,
sl@0
   154
		EGL_RED_SIZE,		8,
sl@0
   155
		EGL_GREEN_SIZE, 	8,
sl@0
   156
		EGL_BLUE_SIZE,		8,
sl@0
   157
		EGL_ALPHA_SIZE, 	0,
sl@0
   158
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   159
		EGL_SURFACE_TYPE,	EGL_PBUFFER_BIT,
sl@0
   160
		EGL_NONE
sl@0
   161
		},
sl@0
   162
		{
sl@0
   163
		// EPBufferAttribsColor16MA - PBuffer
sl@0
   164
		EGL_BUFFER_SIZE,    32,
sl@0
   165
		EGL_RED_SIZE,		8,
sl@0
   166
		EGL_GREEN_SIZE, 	8,
sl@0
   167
		EGL_BLUE_SIZE,		8,
sl@0
   168
		EGL_ALPHA_SIZE, 	8,
sl@0
   169
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   170
		EGL_SURFACE_TYPE,	EGL_PBUFFER_BIT,
sl@0
   171
		EGL_NONE
sl@0
   172
		},
sl@0
   173
		{
sl@0
   174
		// EPBufferAttribsColor16MAP - PBuffer
sl@0
   175
		EGL_BUFFER_SIZE,    32,
sl@0
   176
		EGL_RED_SIZE,		8,
sl@0
   177
		EGL_GREEN_SIZE, 	8,
sl@0
   178
		EGL_BLUE_SIZE,		8,
sl@0
   179
		EGL_ALPHA_SIZE, 	8,
sl@0
   180
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   181
		EGL_SURFACE_TYPE,	EGL_PBUFFER_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
sl@0
   182
		EGL_NONE
sl@0
   183
		},
sl@0
   184
		{
sl@0
   185
		// EPBufferAttribsColorGles64K - PBuffer
sl@0
   186
		EGL_BUFFER_SIZE,    16,
sl@0
   187
		EGL_RED_SIZE,		5,
sl@0
   188
		EGL_GREEN_SIZE, 	6,
sl@0
   189
		EGL_BLUE_SIZE,		5,
sl@0
   190
		EGL_ALPHA_SIZE, 	0,
sl@0
   191
		EGL_RENDERABLE_TYPE,EGL_OPENGL_ES_BIT,
sl@0
   192
		EGL_SURFACE_TYPE,	EGL_PBUFFER_BIT,
sl@0
   193
		EGL_NONE
sl@0
   194
		},
sl@0
   195
		{
sl@0
   196
		//EWindowAttribsColor16MA Preserved - Window 
sl@0
   197
		EGL_BUFFER_SIZE,    32,
sl@0
   198
		EGL_RED_SIZE,       8,
sl@0
   199
		EGL_GREEN_SIZE,     8,
sl@0
   200
		EGL_BLUE_SIZE,      8,
sl@0
   201
		EGL_ALPHA_SIZE,     8,
sl@0
   202
		EGL_RENDERABLE_TYPE,EGL_OPENVG_BIT,
sl@0
   203
		EGL_SURFACE_TYPE,   EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT,
sl@0
   204
		EGL_NONE
sl@0
   205
		},	
sl@0
   206
	};
sl@0
   207
sl@0
   208
enum TEglConfigMatchType
sl@0
   209
{
sl@0
   210
	/** Dummy, used for "uninitialized/unknowns/error" situations */
sl@0
   211
    eMatchUnknown,			
sl@0
   212
    /** Matches whatever - don't actually compare anything. */
sl@0
   213
    eMatchAlways,   		
sl@0
   214
    /** Matches equal values - config must match requested value. */
sl@0
   215
    eMatchEqual,			
sl@0
   216
    /** Matches greater or equal - config must be equal or greater than requested value. */
sl@0
   217
    eMatchAtLeast,			
sl@0
   218
    /** Match bitmask - config bits must have the requested bits. */
sl@0
   219
    eMatchBitMask			
sl@0
   220
};
sl@0
   221
sl@0
   222
const TInt KNumConfigMatchRules = 2;
sl@0
   223
sl@0
   224
struct TConfigMatchRuleItem
sl@0
   225
	{
sl@0
   226
	EGLint 				iAttrib;
sl@0
   227
	TEglConfigMatchType iMatchType;
sl@0
   228
	};
sl@0
   229
sl@0
   230
/**
sl@0
   231
 Defines rules for how to match a requested config with the configs returned by eglChooseConfig.
sl@0
   232
 */
sl@0
   233
static const TConfigMatchRuleItem KConfigMatchRules[KNumConfigMatchRules][15] =
sl@0
   234
{
sl@0
   235
	{
sl@0
   236
		// EConfigMatchStandard
sl@0
   237
		{ EGL_BUFFER_SIZE, eMatchAtLeast },
sl@0
   238
		{ EGL_RED_SIZE, eMatchEqual },
sl@0
   239
		{ EGL_GREEN_SIZE, eMatchEqual },
sl@0
   240
		{ EGL_BLUE_SIZE, eMatchEqual },
sl@0
   241
		{ EGL_ALPHA_SIZE, eMatchEqual },		
sl@0
   242
		{ EGL_RENDERABLE_TYPE, eMatchBitMask },
sl@0
   243
		{ EGL_SURFACE_TYPE, eMatchBitMask },
sl@0
   244
		{ EGL_NONE, eMatchUnknown }
sl@0
   245
	},
sl@0
   246
	{
sl@0
   247
		// EConfigMatchIgnoreAlpha
sl@0
   248
		{ EGL_BUFFER_SIZE, eMatchAtLeast },
sl@0
   249
		{ EGL_RED_SIZE, eMatchEqual },
sl@0
   250
		{ EGL_GREEN_SIZE, eMatchEqual },
sl@0
   251
		{ EGL_BLUE_SIZE, eMatchEqual },
sl@0
   252
		{ EGL_ALPHA_SIZE, eMatchAlways },		
sl@0
   253
		{ EGL_RENDERABLE_TYPE, eMatchBitMask },
sl@0
   254
		{ EGL_SURFACE_TYPE, eMatchBitMask },
sl@0
   255
		{ EGL_NONE, eMatchUnknown }
sl@0
   256
	}
sl@0
   257
};
sl@0
   258
sl@0
   259
/**
sl@0
   260
 Provides an index into KConfigMatchRules
sl@0
   261
 */
sl@0
   262
enum TEglConfigMatchRule
sl@0
   263
	{ 
sl@0
   264
	EConfigMatchStandard,
sl@0
   265
	EConfigMatchIgnoreAlpha,
sl@0
   266
	};
sl@0
   267
sl@0
   268
// Attributes that can be passed into eglCreatePixmapSurface()
sl@0
   269
const EGLint KPixmapAttribsNone[] = { EGL_NONE };
sl@0
   270
const EGLint KPixmapAttribsVgAlphaFormatPre[] = 
sl@0
   271
	{
sl@0
   272
	EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE,
sl@0
   273
	EGL_NONE
sl@0
   274
	};
sl@0
   275
sl@0
   276
const EGLint KPixmapAttribsVgAlphaFormatNonPre[] = 
sl@0
   277
    {
sl@0
   278
    EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_NONPRE,
sl@0
   279
    EGL_NONE
sl@0
   280
    };
sl@0
   281
sl@0
   282
// Attributes that can be passed into eglCreateImageKHR()
sl@0
   283
const EGLint KEglImageAttribsNone[] = { EGL_NONE };
sl@0
   284
const EGLint KEglImageAttribsPreservedTrue[] = 
sl@0
   285
	{
sl@0
   286
	EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
sl@0
   287
	EGL_NONE
sl@0
   288
	};
sl@0
   289
const EGLint KEglImageAttribsPreservedFalse[] = 
sl@0
   290
	{
sl@0
   291
	EGL_IMAGE_PRESERVED_KHR, EGL_FALSE,
sl@0
   292
	EGL_NONE
sl@0
   293
	};
sl@0
   294
sl@0
   295
// Attributes that can be passed into eglCreateSyncKHR()
sl@0
   296
const EGLint KEglSyncAttribsNone[] = {EGL_NONE};
sl@0
   297
sl@0
   298
/**
sl@0
   299
 Performs a TEFUNIT style ASSERT, but also outputs the last EGL error code.
sl@0
   300
 Use this macro to check that EGL function calls have succeeded.
sl@0
   301
 */
sl@0
   302
#define ASSERT_EGL_TRUE(aFunction) \
sl@0
   303
	if(!(aFunction)) \
sl@0
   304
		{ \
sl@0
   305
		EGLint eglError = eglGetError(); \
sl@0
   306
		ERR_PRINTF2(_L("EGL Error: 0x%x"), eglError); \
sl@0
   307
		User::Leave(KErrTEFUnitFail); \
sl@0
   308
		}
sl@0
   309
sl@0
   310
/**
sl@0
   311
 Performs a TEFUNIT style ASSERT, but also outputs the last EGL error code.
sl@0
   312
 Use this macro to check that the expected EGL error has occurred.
sl@0
   313
*/
sl@0
   314
#define ASSERT_EGL_ERROR(aExpectedError) \
sl@0
   315
		{ \
sl@0
   316
		EGLint eglError = eglGetError(); \
sl@0
   317
		if (eglError != aExpectedError) \
sl@0
   318
			{ \
sl@0
   319
			ERR_PRINTF3(_L("Actual EGL Error: 0x%x, but Expected EGL Error: 0x%x"), eglError, aExpectedError); \
sl@0
   320
			User::Leave(KErrTEFUnitFail); \
sl@0
   321
			} \
sl@0
   322
		}
sl@0
   323
sl@0
   324
/**
sl@0
   325
  Performs a TEFUNIT style TEST. Use this macro to check that 
sl@0
   326
  EGL function calls have succeeded and the expected EGL error has occurred.
sl@0
   327
 */
sl@0
   328
#define TEST_EGL_ERROR(aFunction, aExpectedError) \
sl@0
   329
    TEST(aFunction); \
sl@0
   330
    TEST(eglGetError() == aExpectedError);
sl@0
   331
sl@0
   332
/**
sl@0
   333
 Performs a TEFUNIT style ASSERT, but also outputs the last VG error code.
sl@0
   334
 Use this macro to check that VG function calls have succeeded.
sl@0
   335
 */
sl@0
   336
#define ASSERT_VG_TRUE(aFunction) \
sl@0
   337
	if(!(aFunction)) \
sl@0
   338
		{ \
sl@0
   339
		VGErrorCode vgError = vgGetError(); \
sl@0
   340
		ERR_PRINTF2(_L("VG Error: 0x%x"), vgError); \
sl@0
   341
		User::Leave(KErrTEFUnitFail); \
sl@0
   342
		}
sl@0
   343
sl@0
   344
/**
sl@0
   345
 Performs a TEFUNIT style ASSERT, but also outputs the last VG error code.
sl@0
   346
 Use this macro to check that the expected VG error has occurred.
sl@0
   347
*/
sl@0
   348
#define ASSERT_VG_ERROR(aExpectedError) \
sl@0
   349
		{ \
sl@0
   350
		VGErrorCode vgError = vgGetError(); \
sl@0
   351
		if (vgError != aExpectedError) \
sl@0
   352
			{ \
sl@0
   353
			ERR_PRINTF3(_L("Actual VG Error: 0x%x, but Expected VG Error: 0x%x"), vgError, aExpectedError); \
sl@0
   354
			User::Leave(KErrTEFUnitFail); \
sl@0
   355
			} \
sl@0
   356
		}
sl@0
   357
sl@0
   358
sl@0
   359
// The following macros allow verbose logging to be switched on and off programmatically. 
sl@0
   360
#define VERBOSE_INFO_PRINTF1(p1)		if (iVerboseLogging) { INFO_PRINTF1(p1); }
sl@0
   361
#define VERBOSE_INFO_PRINTF2(p1, p2)	if (iVerboseLogging) { INFO_PRINTF2(p1, p2); }
sl@0
   362
#define VERBOSE_INFO_PRINTF3(p1, p2, p3)	if (iVerboseLogging) { INFO_PRINTF3(p1, p2, p3); }
sl@0
   363
sl@0
   364
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
sl@0
   365
_LIT8(KEglRSgImage,"EGL_NOK_pixmap_type_rsgimage");
sl@0
   366
#else
sl@0
   367
_LIT8(KEglRSgImage,"EGL_SYMBIAN_PIXMAP_TYPE_RSGIMAGE");
sl@0
   368
#endif
sl@0
   369
_LIT8(KEglKhrImageBase,"EGL_KHR_image_base");
sl@0
   370
_LIT8(KEglKhrImagePixmap,"EGL_KHR_image_pixmap");
sl@0
   371
_LIT8(KVgKhrEglImage,"VG_KHR_EGL_image");
sl@0
   372
_LIT8(KEglKhrReusableSync,"EGL_KHR_reusable_sync");
sl@0
   373
_LIT8(KEglNokPrivateSignalSync,"EGL_NOK__private__signal_sync");
sl@0
   374
_LIT8(KEglNokiaSwapBuffers,"EGL_NOKIA_swap_buffers");
sl@0
   375
_LIT8(KEglNokiaImageEndpoint,"EGL_NOK_image_endpoint");
sl@0
   376
_LIT8(KEglNokiaSurfaceScaling,"EGL_NOK_surface_scaling");
sl@0
   377
#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
sl@0
   378
_LIT8(KEglSymbianImagePreserved,"EGL_SYMBIAN_image_preserved");
sl@0
   379
#endif
sl@0
   380
sl@0
   381
sl@0
   382
enum TExtensionsId
sl@0
   383
	{
sl@0
   384
	KEGLUndefined,
sl@0
   385
    KEGL_RSgimage 					= 0x01,
sl@0
   386
    KEGL_KHR_image_base				= 0x02,
sl@0
   387
    KEGL_KHR_image_pixmap			= 0x04,	
sl@0
   388
    KVG_KHR_EGL_image				= 0x08,
sl@0
   389
	KEGL_KHR_reusable_sync			= 0x10,
sl@0
   390
	KEGL_NOK__private__signal_sync  = 0x20,
sl@0
   391
	KEGL_NOKIA_swap_buffers         = 0x40,
sl@0
   392
    KEGL_SYMBIAN_image_preserved    = 0x80,
sl@0
   393
    KEGL_NOK_image_endpoint         = 0x100,
sl@0
   394
    KEGL_NOK_surface_scaling        = 0x200
sl@0
   395
	};
sl@0
   396
sl@0
   397
const TUid KUidEglTestServer={0x10281B40};
sl@0
   398
const TUid KUidEglTestServerNga={0x10285DC0};
sl@0
   399
sl@0
   400
#endif	// EGLTESTCOMMONUTILS_H