os/graphics/graphicscomposition/openwftest/src/openwftest.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 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
// OpenWF tests
sl@0
    15
//
sl@0
    16
#include <test/extendtef.h>
sl@0
    17
#include <hal.h>
sl@0
    18
#include "openwftest.h"
sl@0
    19
sl@0
    20
#define KCompositorVersion	0x01023456
sl@0
    21
#define KGrowCleanupStack	12
sl@0
    22
#define KMaxNotificationDelay   5000000 //5 seconds
sl@0
    23
#define KNotificationWarning    100000  //100 ms
sl@0
    24
sl@0
    25
_LIT(KTestSectionName, "TestInfo");
sl@0
    26
_LIT(KImageSectionName, "ImageInfo");
sl@0
    27
_LIT(KContiguousFlag, "ContiguousFlag");
sl@0
    28
_LIT(KTolerance, "Tolerance");
sl@0
    29
_LIT(KTestMode, "TestMode");
sl@0
    30
_LIT(KSaveImage, "SaveImage");
sl@0
    31
_LIT(KDir, "Dir");
sl@0
    32
_LIT(KDefaultDir, "c:\\openwftest\\img\\");
sl@0
    33
_LIT(KCompositionPause, "CompositionPause");
sl@0
    34
_LIT(KManualPause, "ManualPause");
sl@0
    35
sl@0
    36
//Uncomment this and rebuild if you wish to test if fastpath is enabled using breakpoints
sl@0
    37
//#define BREAKPOINT_FASTPATH
sl@0
    38
sl@0
    39
/*
sl@0
    40
 * COpenwfTest implementation
sl@0
    41
 */
sl@0
    42
COpenwfTest::COpenwfTest()
sl@0
    43
:iFastpathablePixelFormat(EUidPixelFormatXRGB_8888),
sl@0
    44
 iNonFastpathablePixelFormat(EUidPixelFormatRGB_565),
sl@0
    45
 iMappable(ETrue),
sl@0
    46
 iMaxBuffers(2),
sl@0
    47
 iMinBuffers(1),
sl@0
    48
 iCacheAttrib(ECacheNotlisted),
sl@0
    49
 iDeviceId(WFC_INVALID_HANDLE),
sl@0
    50
 iSync(EGL_NO_SYNC_KHR),
sl@0
    51
 iDevice(WFC_INVALID_HANDLE),
sl@0
    52
 iContext(WFC_INVALID_HANDLE)
sl@0
    53
	{
sl@0
    54
	}
sl@0
    55
sl@0
    56
COpenwfTest::~COpenwfTest()
sl@0
    57
	{
sl@0
    58
    TearDown();
sl@0
    59
	}
sl@0
    60
sl@0
    61
void COpenwfTest::SetupL()
sl@0
    62
    {    
sl@0
    63
    iScheduler = new(ELeave) CActiveScheduler;
sl@0
    64
    CActiveScheduler::Install(iScheduler);
sl@0
    65
sl@0
    66
    ReadIniData();
sl@0
    67
    
sl@0
    68
    iEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
sl@0
    69
    ASSERT_FALSE(iEGLDisplay == EGL_NO_DISPLAY);
sl@0
    70
    ASSERT_FALSE(iEGLDisplay == EGL_BAD_ALLOC);
sl@0
    71
    ASSERT_EQUALS(eglGetError(),EGL_SUCCESS);
sl@0
    72
    eglInitialize(iEGLDisplay, NULL, NULL);
sl@0
    73
    ASSERT_EQUALS(eglGetError(),EGL_SUCCESS);
sl@0
    74
    
sl@0
    75
    WFCint filterList[] = { WFC_DEVICE_FILTER_SCREEN_NUMBER, WFC_DEFAULT_SCREEN_NUMBER, WFC_NONE};
sl@0
    76
    ASSERT_TRUE(wfcEnumerateDevices(&iDeviceId, 1, filterList) == 1);
sl@0
    77
    ASSERT_TRUE(iDeviceId != WFC_INVALID_HANDLE);    
sl@0
    78
sl@0
    79
    iDevice = wfcCreateDevice(iDeviceId, NULL);
sl@0
    80
    ASSERT_TRUE(iDevice != WFC_INVALID_HANDLE);  
sl@0
    81
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
    82
    iContext = wfcCreateOnScreenContext(iDevice, WFC_DEFAULT_SCREEN_NUMBER, NULL);
sl@0
    83
    ASSERT_TRUE(iContext != WFC_INVALID_HANDLE);  
sl@0
    84
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
    85
sl@0
    86
    iFastpathableHeight = wfcGetContextAttribi(iDevice, iContext, WFC_CONTEXT_TARGET_HEIGHT);
sl@0
    87
    iFastpathableWidth = wfcGetContextAttribi(iDevice, iContext, WFC_CONTEXT_TARGET_WIDTH);
sl@0
    88
    iStride = iFastpathableWidth * 4;
sl@0
    89
sl@0
    90
    iFullScreenTRect = TRect(0,0,iFastpathableWidth,iFastpathableHeight);
sl@0
    91
    iFullScreenRect[0] = 0;
sl@0
    92
    iFullScreenRect[1] = 0;
sl@0
    93
    iFullScreenRect[2] = iFullScreenTRect.Width();
sl@0
    94
    iFullScreenRect[3] = iFullScreenTRect.Height();
sl@0
    95
    
sl@0
    96
    iCenterTRect = TRect(iFastpathableWidth/4,iFastpathableHeight/4,
sl@0
    97
            3*iFastpathableWidth/4,3*iFastpathableHeight/4);
sl@0
    98
    iCenterRect[0] = iCenterTRect.iTl.iX;
sl@0
    99
    iCenterRect[1] = iCenterTRect.iTl.iY;
sl@0
   100
    iCenterRect[2] = iCenterTRect.Width();
sl@0
   101
    iCenterRect[3] = iCenterTRect.Height();
sl@0
   102
    
sl@0
   103
    iHalfSizeRect[0] = 0;
sl@0
   104
    iHalfSizeRect[1] = 0;
sl@0
   105
    iHalfSizeRect[2] = iFastpathableWidth/2;
sl@0
   106
    iHalfSizeRect[3] = iFastpathableHeight/2;
sl@0
   107
    
sl@0
   108
    iUtility = CSurfaceUtility::NewL();
sl@0
   109
sl@0
   110
    if((iTestMode == EAutomatic) || iSaveImage)
sl@0
   111
        {
sl@0
   112
        // Need to initialise the on screen stream before composition
sl@0
   113
        // to ensure the content is available later 
sl@0
   114
        iUtility->GetOnScreenStream(iDevice, iContext);
sl@0
   115
        }
sl@0
   116
    if (iSaveImage)
sl@0
   117
        {   // Create a directory to save images
sl@0
   118
        iUtility->CreateImagePath(iImageDirectory);                
sl@0
   119
        }
sl@0
   120
    iAllowManualPause = ETrue; //tests can stop it (eg dispXtimes tests) 
sl@0
   121
    
sl@0
   122
    EGLint attrib_list[1] = {EGL_NONE};
sl@0
   123
    iSync = eglCreateSyncKHR(iEGLDisplay,EGL_SYNC_REUSABLE_KHR, attrib_list);
sl@0
   124
    ASSERT_NOT_EQUALS(iSync,EGL_NO_SYNC_KHR);
sl@0
   125
    ASSERT_EQUALS(eglGetError(),EGL_SUCCESS);
sl@0
   126
    }
sl@0
   127
sl@0
   128
/**
sl@0
   129
 * test Suite furniture 
sl@0
   130
 **/
sl@0
   131
void COpenwfTest::TearDownL()
sl@0
   132
    {
sl@0
   133
    // Nothing leaves in this function, 
sl@0
   134
    // but TearDownL() is needed for the CTestFixture (TEF) interface
sl@0
   135
    TearDown();
sl@0
   136
    }
sl@0
   137
sl@0
   138
void COpenwfTest::TearDown()
sl@0
   139
    {
sl@0
   140
    WFCErrorCode wfcError;
sl@0
   141
    if (iDevice != WFC_INVALID_HANDLE)
sl@0
   142
        {
sl@0
   143
        wfcError = wfcGetError(iDevice);
sl@0
   144
        if (wfcError != WFC_ERROR_NONE)
sl@0
   145
            {
sl@0
   146
            INFO_PRINTF2(_L("TearDown: There was a failure in the test. error=%d"),wfcError);
sl@0
   147
            }
sl@0
   148
        }
sl@0
   149
    if (iOnScreenStream != WFC_INVALID_HANDLE)
sl@0
   150
        {
sl@0
   151
        (void)SymbianStreamReleaseReadBuffer(iOnScreenStream, iOnScreenBuffer); //ignore the error
sl@0
   152
        iOnScreenStream = WFC_INVALID_HANDLE;
sl@0
   153
        }
sl@0
   154
    delete iUtility;
sl@0
   155
    iUtility = NULL;
sl@0
   156
    if (iContext != WFC_INVALID_HANDLE)
sl@0
   157
        {
sl@0
   158
        wfcDestroyContext(iDevice, iContext);
sl@0
   159
        iContext = WFC_INVALID_HANDLE;
sl@0
   160
        WFCErrorCode wfcError = wfcGetError(iDevice);
sl@0
   161
        if (wfcError != WFC_ERROR_NONE)
sl@0
   162
            {
sl@0
   163
            INFO_PRINTF2(_L("TearDown: wfcDestroyContext error=%d"),wfcError);
sl@0
   164
            }
sl@0
   165
        }
sl@0
   166
    if (iDevice != WFC_INVALID_HANDLE)
sl@0
   167
        {
sl@0
   168
        WFCErrorCode deviceError = wfcDestroyDevice(iDevice);
sl@0
   169
        iDevice = WFC_INVALID_HANDLE;
sl@0
   170
        if (deviceError != WFC_ERROR_NONE)
sl@0
   171
            {
sl@0
   172
            INFO_PRINTF2(_L("TearDown: wfcDestroyDevice error=%d"),deviceError);
sl@0
   173
            }
sl@0
   174
        }
sl@0
   175
    if (iSync != EGL_NO_SYNC_KHR)
sl@0
   176
        {
sl@0
   177
        EGLBoolean eglSyncError = eglDestroySyncKHR(iEGLDisplay, iSync);
sl@0
   178
        iSync = EGL_NO_SYNC_KHR;
sl@0
   179
        if (eglSyncError != EGL_TRUE)
sl@0
   180
            {
sl@0
   181
            INFO_PRINTF2(_L("TearDown: eglSyncError line %d"),__LINE__);
sl@0
   182
            }
sl@0
   183
        }
sl@0
   184
    if (iEGLDisplay != EGL_NO_DISPLAY)
sl@0
   185
        {
sl@0
   186
        EGLBoolean eglTerminateError = eglTerminate(iEGLDisplay);
sl@0
   187
        iEGLDisplay = EGL_NO_DISPLAY;
sl@0
   188
        if (eglTerminateError != EGL_TRUE)
sl@0
   189
            {
sl@0
   190
            INFO_PRINTF2(_L("TearDown: eglTerminateError line %d"),__LINE__);
sl@0
   191
            }
sl@0
   192
        }
sl@0
   193
    delete iScheduler;
sl@0
   194
    iScheduler = NULL;
sl@0
   195
    }
sl@0
   196
sl@0
   197
/**
sl@0
   198
 * To be called at the beginning of tests
sl@0
   199
 * aActivate default is ON
sl@0
   200
 */
sl@0
   201
void COpenwfTest::SetupEmptySceneL(TBool aActivate)
sl@0
   202
    {
sl@0
   203
#ifdef BREAKPOINT_FASTPATH
sl@0
   204
    __BREAKPOINT();
sl@0
   205
#endif
sl@0
   206
    wfcSetContextAttribi(iDevice, iContext, WFC_CONTEXT_ROTATION, WFC_ROTATION_0);
sl@0
   207
    wfcSetContextAttribi(iDevice, iContext, WFC_CONTEXT_BG_COLOR, 0xFFFFFFFF);
sl@0
   208
    if (aActivate)
sl@0
   209
        {
sl@0
   210
        LOG(("OpenWFTest: Running in autonomous composition mode"));
sl@0
   211
        wfcActivate(iDevice,iContext);
sl@0
   212
        }
sl@0
   213
    else
sl@0
   214
        {
sl@0
   215
        LOG(("OpenWFTest: Running in non autonomous composition mode"));
sl@0
   216
        wfcDeactivate(iDevice,iContext);
sl@0
   217
        }
sl@0
   218
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit"));
sl@0
   219
    wfcCommit(iDevice, iContext, WFC_TRUE);   // Compose the scene
sl@0
   220
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
   221
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
   222
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
   223
    LOG(("OpenWFTest: Fastpath - setting up scene - fastpath now off"));
sl@0
   224
    }
sl@0
   225
sl@0
   226
void COpenwfTest::ReadIniData()
sl@0
   227
    {
sl@0
   228
	//test mode
sl@0
   229
    TBool returnValue = iConfig.GetInt(KTestSectionName, KTestMode, iTestMode);
sl@0
   230
    ASSERT_TRUE(returnValue);
sl@0
   231
    
sl@0
   232
    //save images
sl@0
   233
	iSaveImage=EFalse;
sl@0
   234
    if (iTestMode == EAutomatic)
sl@0
   235
        {
sl@0
   236
        returnValue = iConfig.GetBool(KTestSectionName, KSaveImage, iSaveImage);
sl@0
   237
        }
sl@0
   238
    
sl@0
   239
    // Get path for the images to be saved to
sl@0
   240
    TPtrC dir;
sl@0
   241
    returnValue = iConfig.GetString(KTestSectionName, KDir, dir);
sl@0
   242
    if (returnValue)
sl@0
   243
        {
sl@0
   244
		iImageDirectory.Set(dir);
sl@0
   245
        }
sl@0
   246
    else
sl@0
   247
        {
sl@0
   248
		iImageDirectory.Set(KDefaultDir);
sl@0
   249
        }
sl@0
   250
    
sl@0
   251
    // Composition pause in microseconds
sl@0
   252
    TInt compositionPause;
sl@0
   253
    returnValue = iConfig.GetInt(KTestSectionName, KCompositionPause, compositionPause);
sl@0
   254
    ASSERT_TRUE(returnValue);
sl@0
   255
    iCompositionPause = compositionPause;
sl@0
   256
    
sl@0
   257
    // Manual pause in microseconds
sl@0
   258
    iManualPause = 0;
sl@0
   259
    if (iTestMode != EAutomatic)
sl@0
   260
        {
sl@0
   261
		TInt manualPause;
sl@0
   262
		returnValue = iConfig.GetInt(KTestSectionName, KManualPause, manualPause);
sl@0
   263
		ASSERT_TRUE(returnValue);
sl@0
   264
		iManualPause = manualPause;
sl@0
   265
        }
sl@0
   266
    
sl@0
   267
    // Force contiguous
sl@0
   268
    TBool contiguousFlag;
sl@0
   269
    returnValue = iConfig.GetBool(KImageSectionName, KContiguousFlag, contiguousFlag);
sl@0
   270
    if (returnValue && contiguousFlag)
sl@0
   271
        {
sl@0
   272
        iContiguous = EContiguous;
sl@0
   273
        }
sl@0
   274
    
sl@0
   275
    // Test tolerance
sl@0
   276
    TInt tolerance;
sl@0
   277
    returnValue = iConfig.GetInt(KImageSectionName, KTolerance, tolerance);
sl@0
   278
    if (returnValue)
sl@0
   279
        {
sl@0
   280
        iTolerance = tolerance;
sl@0
   281
        }
sl@0
   282
    }
sl@0
   283
sl@0
   284
/**
sl@0
   285
 * Acquires the on screen stream and buffer number
sl@0
   286
 * NOTE: this function should be paired with a ReleaseOnScreenStream call
sl@0
   287
 * Returns ETrue on success
sl@0
   288
 */
sl@0
   289
TBool COpenwfTest::AcquireOnScreenStream()
sl@0
   290
	{
sl@0
   291
	TInt error = KErrNone;
sl@0
   292
	ASSERT_TRUE(iOnScreenStream == WFC_INVALID_HANDLE);
sl@0
   293
    if(iTestMode == EAutomatic)
sl@0
   294
    	{	//need to get the on screen stream
sl@0
   295
		iOnScreenStream = iUtility->GetOnScreenStream(iDevice, iContext);
sl@0
   296
		if(iOnScreenStream == WFC_INVALID_HANDLE)
sl@0
   297
			{
sl@0
   298
			INFO_PRINTF1(_L("Failed getting on screen stream"));
sl@0
   299
			LOG(("OpenWFTest: *** Failed getting on screen stream"));
sl@0
   300
			return EFalse;
sl@0
   301
			}
sl@0
   302
		error = SymbianStreamAcquireReadBuffer(iOnScreenStream, &iOnScreenBuffer);
sl@0
   303
		if (error != KErrNone)
sl@0
   304
			{
sl@0
   305
			LOG(("OpenWFTest: *** Unable to acquire read buffer. error = %d",error));
sl@0
   306
			INFO_PRINTF2(_L("Unable to acquire read buffer. error = %d"),error);
sl@0
   307
			}
sl@0
   308
		return (error == KErrNone);
sl@0
   309
    	}
sl@0
   310
	else
sl@0
   311
		{
sl@0
   312
		INFO_PRINTF1(_L("No need to get the on screen stream, probably manual checking mode"));
sl@0
   313
		LOG(("OpenWFTest: *** No need to get the on screen stream, probably manual checking mode"));
sl@0
   314
		return ETrue;
sl@0
   315
		}
sl@0
   316
	}
sl@0
   317
sl@0
   318
/**
sl@0
   319
 * Releases the on screen stream
sl@0
   320
 */
sl@0
   321
void COpenwfTest::ReleaseOnScreenStream()
sl@0
   322
	{
sl@0
   323
	if (iOnScreenStream != WFC_INVALID_HANDLE)
sl@0
   324
		{
sl@0
   325
		(void)SymbianStreamReleaseReadBuffer(iOnScreenStream, iOnScreenBuffer);	//ignore the error
sl@0
   326
		iOnScreenStream = WFC_INVALID_HANDLE;
sl@0
   327
		}
sl@0
   328
	if(iTestMode != EAutomatic && iAllowManualPause)
sl@0
   329
		{
sl@0
   330
		INFO_PRINTF1(_L("Performing manual wait"));
sl@0
   331
		LOG(("OpenWFTest: *** Performing manual wait"));
sl@0
   332
		TRAP_IGNORE(WaitL(iManualPause));
sl@0
   333
		}
sl@0
   334
	if(iTestMode != EAutomatic && !iAllowManualPause)
sl@0
   335
	    {
sl@0
   336
        INFO_PRINTF1(_L("Test not allowing a manual wait"));
sl@0
   337
        LOG(("OpenWFTest: *** Test not allowing a manual wait"));
sl@0
   338
	    }
sl@0
   339
	}
sl@0
   340
sl@0
   341
/**
sl@0
   342
 * Checks the rect of the on screen stream
sl@0
   343
 * Returns ETrue on success
sl@0
   344
 */
sl@0
   345
TBool COpenwfTest::CheckOnScreenStreamRect(TRect aRect, const TRgb& aExpectedColor, TInt aTolerance)
sl@0
   346
	{
sl@0
   347
    if(iTestMode == EAutomatic)
sl@0
   348
    	{
sl@0
   349
		if (iOnScreenStream == WFC_INVALID_HANDLE)
sl@0
   350
			{
sl@0
   351
			LOG(("OpenWFTest: *** We don't have access to the on screen stream"));
sl@0
   352
			INFO_PRINTF1(_L("We don't have access to the on screen stream"));
sl@0
   353
			return EFalse;
sl@0
   354
			}
sl@0
   355
		const TSurfaceId* surfaceId = NULL;
sl@0
   356
		long bufferIndex;
sl@0
   357
		TInt error = SymbianStreamGetBufferId(iOnScreenStream,iOnScreenBuffer,&bufferIndex,&surfaceId);
sl@0
   358
		if (error == KErrNone)
sl@0
   359
			{
sl@0
   360
			return CheckRect(*surfaceId,bufferIndex,aRect,aExpectedColor,aTolerance);
sl@0
   361
			}
sl@0
   362
		else
sl@0
   363
			{
sl@0
   364
			LOG(("OpenWFTest: *** Unable to get stream buffer id. error = %d",error));
sl@0
   365
			INFO_PRINTF2(_L("Unable to get stream buffer id. error = %d"),error);
sl@0
   366
			return EFalse;
sl@0
   367
			}
sl@0
   368
    	}
sl@0
   369
    else
sl@0
   370
    	{	//print out what we're hoping to see for manual testing
sl@0
   371
		LOG(("OpenWFTest: For rect %d %d %d %d",aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY));
sl@0
   372
		LOG(("OpenWFTest: The expected color is r=%d g=%d b=%d",aExpectedColor.Red(),aExpectedColor.Green(),
sl@0
   373
				aExpectedColor.Blue()));
sl@0
   374
		INFO_PRINTF5(_L("For rect %d %d %d %d"),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY);
sl@0
   375
		INFO_PRINTF4(_L("The expected color is r=%d g=%d b=%d"),aExpectedColor.Red(),aExpectedColor.Green(),
sl@0
   376
				aExpectedColor.Blue());
sl@0
   377
		return ETrue;
sl@0
   378
    	}
sl@0
   379
	}
sl@0
   380
sl@0
   381
/**
sl@0
   382
 * checks the color within the given rectangle of the given surface
sl@0
   383
 * returns ETrue on success
sl@0
   384
 */
sl@0
   385
TBool COpenwfTest::CheckRect(const TSurfaceId& aSurface, TInt aBuffer,  TRect aRect,
sl@0
   386
		const TRgb& aExpectedColor, TInt aTolerance)
sl@0
   387
	{
sl@0
   388
	INFO_PRINTF1(_L("Starting pixel checking"));
sl@0
   389
	LOG(("OpenWFTest: *** Starting pixel checking"));
sl@0
   390
	// Check pixel data
sl@0
   391
	
sl@0
   392
	TBool success = iUtility->CheckRectColor(aSurface, aRect, aBuffer, aExpectedColor, aTolerance);
sl@0
   393
	if (success)
sl@0
   394
		{
sl@0
   395
		INFO_PRINTF1(_L("Finished pixel checking - pass"));
sl@0
   396
		LOG(("OpenWFTest: *** Finished pixel checking - pass"));
sl@0
   397
		}
sl@0
   398
	else
sl@0
   399
		{
sl@0
   400
		INFO_PRINTF1(_L("Finished pixel checking - fail"));
sl@0
   401
		LOG(("OpenWFTest: *** Finished pixel checking - fail"));
sl@0
   402
		}
sl@0
   403
    return success;
sl@0
   404
	}
sl@0
   405
sl@0
   406
/**
sl@0
   407
 * If in automatic mode it will save a TGA image of the on screen stream.
sl@0
   408
 * It will also print the name of the reference image.
sl@0
   409
 * Returns ETrue on success
sl@0
   410
 */
sl@0
   411
TBool COpenwfTest::CheckOnScreenReferenceImage()
sl@0
   412
	{
sl@0
   413
	TInt error = KErrNone;
sl@0
   414
	//Create image file name
sl@0
   415
	_LIT(KSeparator, "_");
sl@0
   416
	_LIT(KTGAImgFormat, ".tga");
sl@0
   417
	iImageAddress.Zero();
sl@0
   418
	iImageAddress.Append(iTestName);
sl@0
   419
	iImageAddress.Append(KSeparator);
sl@0
   420
	iImageAddress.AppendNum(iImageCounter);
sl@0
   421
	iImageAddress.Append(KTGAImgFormat);
sl@0
   422
    
sl@0
   423
	LOGL((_L("Reference Image:%S"),&iImageAddress));
sl@0
   424
	INFO_PRINTF2(_L("Reference Image:%S"),&iImageAddress);
sl@0
   425
	//Add file path
sl@0
   426
	iImageAddress.Insert(0,iImageDirectory);
sl@0
   427
	iImageCounter++;
sl@0
   428
	
sl@0
   429
    if(iTestMode == EAutomatic && iSaveImage)
sl@0
   430
    	{
sl@0
   431
		if (iOnScreenStream == WFC_INVALID_HANDLE)
sl@0
   432
			{
sl@0
   433
			LOG(("OpenWFTest: *** We don't have access to the on screen stream",error));
sl@0
   434
			INFO_PRINTF1(_L("We don't have access to the on screen stream"));
sl@0
   435
			return EFalse;
sl@0
   436
			}
sl@0
   437
		const TSurfaceId* surfaceId = NULL;
sl@0
   438
		long bufferIndex;
sl@0
   439
		error = SymbianStreamGetBufferId(iOnScreenStream,iOnScreenBuffer,&bufferIndex,&surfaceId);
sl@0
   440
		if (error == KErrNone)
sl@0
   441
			{
sl@0
   442
			return SaveImage(*surfaceId,bufferIndex);
sl@0
   443
			}
sl@0
   444
		else
sl@0
   445
			{
sl@0
   446
			LOG(("OpenWFTest: *** Unable to get stream buffer id. error = %d",error));
sl@0
   447
			INFO_PRINTF2(_L("Unable to get stream buffer id. error = %d"),error);
sl@0
   448
			return EFalse;
sl@0
   449
			}
sl@0
   450
    	}
sl@0
   451
    return ETrue;
sl@0
   452
	}
sl@0
   453
sl@0
   454
/**
sl@0
   455
 *  helper function for saving images to files
sl@0
   456
 *  returns ETrue on success
sl@0
   457
 */
sl@0
   458
TBool COpenwfTest::SaveImage(const TSurfaceId& aSurface, TInt aNumOfBuffer)
sl@0
   459
    {
sl@0
   460
	if(iTestMode == EAutomatic && iSaveImage)
sl@0
   461
		{
sl@0
   462
		INFO_PRINTF1(_L("Start to save image"));
sl@0
   463
		LOG(("OpenWFTest: *** Start to save image"));
sl@0
   464
		TBool success = EFalse;
sl@0
   465
		TRAPD(error, success = iUtility->SaveResultImageTGAL(aSurface, aNumOfBuffer, iImageAddress));
sl@0
   466
		if(error != KErrNone || !success)
sl@0
   467
			{
sl@0
   468
			INFO_PRINTF1(_L("Failed saving image"));
sl@0
   469
			LOG(("OpenWFTest: *** Failed saving image"));
sl@0
   470
			return EFalse;
sl@0
   471
			}
sl@0
   472
		INFO_PRINTF1(_L("Saved image"));
sl@0
   473
		LOG(("OpenWFTest: *** Saved image"));
sl@0
   474
		}
sl@0
   475
    return ETrue;
sl@0
   476
    }
sl@0
   477
sl@0
   478
/**
sl@0
   479
 * Basic wait function call. Return amount of other active objects that stopped the scheduler
sl@0
   480
*/
sl@0
   481
TInt COpenwfTest::WaitL(TTimeIntervalMicroSeconds32 aDelay)	//aDelay in microseconds
sl@0
   482
	{
sl@0
   483
	CActiveWaiter* waiter = NULL;
sl@0
   484
	waiter = CActiveWaiter::NewL();
sl@0
   485
    TInt counter = waiter->Wait(aDelay);
sl@0
   486
	delete waiter;
sl@0
   487
	return counter;
sl@0
   488
	}
sl@0
   489
sl@0
   490
/**
sl@0
   491
 * aMaxDelay    The maximum time we are willing to wait in microseconds
sl@0
   492
 * aNotifications   The amount of notifications we expect to complete, must be >0
sl@0
   493
 * Returns ETrue on success
sl@0
   494
*/
sl@0
   495
TBool COpenwfTest::WaitForNotifications(TTimeIntervalMicroSeconds32 aMaxDelay,TInt aNotificatons)
sl@0
   496
    {
sl@0
   497
    if (aNotificatons == 0)
sl@0
   498
        {   //use WaitL if no notifications are expected
sl@0
   499
        return EFalse;
sl@0
   500
        }
sl@0
   501
    TTime before;
sl@0
   502
    TTime after;
sl@0
   503
    before.UniversalTime();
sl@0
   504
    TTimeIntervalMicroSeconds diff;
sl@0
   505
    TInt counter = aNotificatons;
sl@0
   506
    CActiveWaiter* waiter = NULL;
sl@0
   507
    TRAP_IGNORE(waiter = CActiveWaiter::NewL());
sl@0
   508
    if (!waiter)
sl@0
   509
        {
sl@0
   510
        INFO_PRINTF1(_L("Failed creating CActiveWaiter"));
sl@0
   511
        LOG(("OpenWFTest: *** Failed creating CActiveWaiter"));
sl@0
   512
        return EFalse;
sl@0
   513
        }
sl@0
   514
    waiter->StartWait(aMaxDelay);
sl@0
   515
    CActiveScheduler::Start();
sl@0
   516
    while(!waiter->iRun)
sl@0
   517
        {
sl@0
   518
        after.UniversalTime();
sl@0
   519
        diff = after.MicroSecondsFrom(before);
sl@0
   520
        if (diff > KNotificationWarning)
sl@0
   521
            {
sl@0
   522
            INFO_PRINTF2(_L("note: Notification took a long time to complete: %ld microseconds"),diff.Int64());
sl@0
   523
            LOG(("OpenWFTest: *** note: Notification took a long time to complete: %ld microseconds",diff.Int64()));
sl@0
   524
            }
sl@0
   525
        counter--;
sl@0
   526
        if (counter == 0)
sl@0
   527
            {   //all expected notifications were completed
sl@0
   528
            delete waiter;
sl@0
   529
            return ETrue;
sl@0
   530
            }
sl@0
   531
        CActiveScheduler::Start();
sl@0
   532
        }
sl@0
   533
    INFO_PRINTF2(_L("Not all notifications completed, counter=%d"),counter);
sl@0
   534
    LOG(("OpenWFTest: *** Not all notifications completed, counter=%d",counter));
sl@0
   535
    delete waiter;
sl@0
   536
    //the notifications didn't complete in time
sl@0
   537
    return EFalse;
sl@0
   538
    }
sl@0
   539
sl@0
   540
// Create a suite of all the tests
sl@0
   541
CTestSuite* COpenwfTest::CreateSuiteL(const TDesC& aName)
sl@0
   542
	{
sl@0
   543
	SUB_SUITE_OPT(COpenwfTest,NULL);
sl@0
   544
		//positive fastpath tests
sl@0
   545
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0000L);
sl@0
   546
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0001L);
sl@0
   547
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0002L);
sl@0
   548
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0003L);
sl@0
   549
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0004L);
sl@0
   550
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0005L);
sl@0
   551
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0006L);
sl@0
   552
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0007L);
sl@0
   553
        //fastpath with notification tests
sl@0
   554
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0010L);
sl@0
   555
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0011L);
sl@0
   556
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0012L);
sl@0
   557
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0013L);
sl@0
   558
        //negative fastpath tests
sl@0
   559
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0020L);
sl@0
   560
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0021L);
sl@0
   561
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0022L);
sl@0
   562
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0023L);
sl@0
   563
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0024L);
sl@0
   564
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0025L);
sl@0
   565
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0026L);
sl@0
   566
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_FASTPATH_0027L);
sl@0
   567
		
sl@0
   568
	END_SUITE;
sl@0
   569
	}
sl@0
   570
sl@0
   571
void TefUnitFailLeaveL()
sl@0
   572
	{
sl@0
   573
	User::Leave(KErrTEFUnitFail);
sl@0
   574
	}
sl@0
   575
sl@0
   576
CActiveNotification* CActiveNotification::NewL(RSurfaceUpdateSession& aSurfaceUpdateSession,TBool aActivate)
sl@0
   577
	{
sl@0
   578
	CActiveNotification* self = new (ELeave) CActiveNotification;
sl@0
   579
	CleanupStack::PushL(self);
sl@0
   580
	self->ConstructL(aSurfaceUpdateSession);
sl@0
   581
	CleanupStack::Pop(self);
sl@0
   582
	if (aActivate)
sl@0
   583
		{
sl@0
   584
		self->SetActive();
sl@0
   585
		}
sl@0
   586
	return self;
sl@0
   587
	}
sl@0
   588
sl@0
   589
void CActiveNotification::ConstructL(RSurfaceUpdateSession& aSurfaceUpdateSession)
sl@0
   590
	{
sl@0
   591
	CActiveScheduler::Add(this);
sl@0
   592
	iSurfaceUpdateSession = aSurfaceUpdateSession;
sl@0
   593
	}
sl@0
   594
	
sl@0
   595
CActiveNotification::CActiveNotification() : CActive(EPriorityNormal)
sl@0
   596
	{}
sl@0
   597
sl@0
   598
CActiveNotification::~CActiveNotification()
sl@0
   599
	{
sl@0
   600
	Cancel();
sl@0
   601
	}
sl@0
   602
sl@0
   603
void CActiveNotification::DoCancel()
sl@0
   604
	{  //we need to cancel all notifications - this will impact other notifications in this sus session!
sl@0
   605
    iSurfaceUpdateSession.CancelAllUpdateNotifications();
sl@0
   606
	}
sl@0
   607
sl@0
   608
void CActiveNotification::RunL()
sl@0
   609
	{
sl@0
   610
	CActiveScheduler::Stop();
sl@0
   611
	}
sl@0
   612
	
sl@0
   613
TInt CActiveNotification::RunError(TInt aError)
sl@0
   614
	{
sl@0
   615
	return aError; // exists so a break point can be placed on it.
sl@0
   616
	}
sl@0
   617
sl@0
   618
void CActiveNotification::Activate()
sl@0
   619
	{
sl@0
   620
	SetActive();
sl@0
   621
	}
sl@0
   622
sl@0
   623
CActiveWaiter* CActiveWaiter::NewL()
sl@0
   624
    {
sl@0
   625
	CActiveWaiter* self = new (ELeave) CActiveWaiter;
sl@0
   626
    CleanupStack::PushL(self);
sl@0
   627
    self->ConstructL();
sl@0
   628
    CleanupStack::Pop(self);
sl@0
   629
    return self;
sl@0
   630
    }
sl@0
   631
    
sl@0
   632
void CActiveWaiter::ConstructL()
sl@0
   633
    {
sl@0
   634
    User::LeaveIfError(iTimer.CreateLocal());
sl@0
   635
    CActiveScheduler::Add(this);
sl@0
   636
    }
sl@0
   637
    
sl@0
   638
CActiveWaiter::CActiveWaiter() : CActive(CActive::EPriorityStandard)
sl@0
   639
    {}
sl@0
   640
sl@0
   641
CActiveWaiter::~CActiveWaiter()
sl@0
   642
    {
sl@0
   643
    Cancel();
sl@0
   644
    iTimer.Close();
sl@0
   645
    }
sl@0
   646
sl@0
   647
void CActiveWaiter::DoCancel()
sl@0
   648
    {
sl@0
   649
    iTimer.Cancel();
sl@0
   650
    }
sl@0
   651
sl@0
   652
void CActiveWaiter::RunL()
sl@0
   653
    {
sl@0
   654
	iRun = ETrue;
sl@0
   655
    CActiveScheduler::Stop();
sl@0
   656
    }
sl@0
   657
    
sl@0
   658
TInt CActiveWaiter::RunError(TInt aError)
sl@0
   659
    {
sl@0
   660
    return aError; // exists so a break point can be placed on it.
sl@0
   661
    }
sl@0
   662
sl@0
   663
/**
sl@0
   664
 * Waits the set amount of time. Returns the amount of times the active scheduler 
sl@0
   665
 * was stopped (not including its own active scheduler stop)
sl@0
   666
 */
sl@0
   667
TInt CActiveWaiter::Wait(TTimeIntervalMicroSeconds32 aDelay)   //microseconds
sl@0
   668
    {
sl@0
   669
	TInt counter = 0;
sl@0
   670
    SetActive();
sl@0
   671
    iTimer.After(iStatus, aDelay);
sl@0
   672
    iRun = EFalse;
sl@0
   673
    CActiveScheduler::Start();
sl@0
   674
    while (!iRun)
sl@0
   675
    	{//may be another object that stops the scheduler running in these tests.
sl@0
   676
		counter++;
sl@0
   677
		CActiveScheduler::Start();
sl@0
   678
    	}
sl@0
   679
    return counter;
sl@0
   680
    }
sl@0
   681
sl@0
   682
/**
sl@0
   683
 * Starts an AO with the given delay. Remember the RunL will stop the active scheduler.
sl@0
   684
 */
sl@0
   685
void CActiveWaiter::StartWait(TTimeIntervalMicroSeconds32 aDelay)   //microseconds
sl@0
   686
    {
sl@0
   687
    SetActive();
sl@0
   688
    iTimer.After(iStatus, aDelay);
sl@0
   689
    }
sl@0
   690
sl@0
   691
/*
sl@0
   692
@SYMTestCaseID          GRAPHICS-OPENWFC-FASTPATH-0000
sl@0
   693
@SYMTestCaseDesc        Positive testing - Fastpath one-element scene
sl@0
   694
@SYMREQ                 
sl@0
   695
@SYMPREQ                PREQ417-54885
sl@0
   696
@SYMTestType            Unit Test
sl@0
   697
@SYMTestPriority        High
sl@0
   698
@SYMTestPurpose         Check a scene meeting fastpath criteria can be fastpathed
sl@0
   699
@SYMTestActions         
sl@0
   700
    All compositions are autonomous:
sl@0
   701
    Compose an empty scene
sl@0
   702
    Create a scene containing a screen sized element with no scaling, no alpha, no mask, no rotation
sl@0
   703
    Compose the scene
sl@0
   704
@SYMTestExpectedResults
sl@0
   705
    The final scene should be fastpathed    
sl@0
   706
*/
sl@0
   707
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0000L()
sl@0
   708
	{
sl@0
   709
    iTestName = _L("FASTPATH_0000");
sl@0
   710
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
   711
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
   712
    SetupEmptySceneL();
sl@0
   713
    
sl@0
   714
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
   715
                                                iFastpathablePixelFormat,
sl@0
   716
                                                iStride, iContiguous, iMaxBuffers);
sl@0
   717
    ASSERT_FALSE(surface.IsNull());
sl@0
   718
sl@0
   719
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
   720
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   721
    ASSERT_EQUALS(err,KErrNone);
sl@0
   722
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
   723
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
   724
    
sl@0
   725
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
   726
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
   727
    
sl@0
   728
#ifdef BREAKPOINT_FASTPATH
sl@0
   729
    __BREAKPOINT();
sl@0
   730
#endif
sl@0
   731
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
   732
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
   733
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
   734
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
   735
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
   736
    LOG(("OpenWFTest: Fastpath - Now ON"));
sl@0
   737
    
sl@0
   738
    iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
   739
    err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   740
    ASSERT_EQUALS(err,KErrNone);
sl@0
   741
    WaitL(iCompositionPause);
sl@0
   742
    
sl@0
   743
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
   744
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
   745
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
   746
    ReleaseOnScreenStream();
sl@0
   747
sl@0
   748
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
   749
    wfcDestroySource(iDevice, fpSource);
sl@0
   750
	}
sl@0
   751
sl@0
   752
/*
sl@0
   753
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0001
sl@0
   754
@SYMTestCaseDesc		Positive testing - Fastpath one-element scene  
sl@0
   755
@SYMREQ					
sl@0
   756
@SYMPREQ						PREQ417-54885
sl@0
   757
@SYMTestType				Unit Test
sl@0
   758
@SYMTestPriority		High	
sl@0
   759
@SYMTestPurpose			Check a scene including a full screen element with global alpha at opaque level 
sl@0
   760
										can be fastpathed
sl@0
   761
@SYMTestActions			
sl@0
   762
	All compositions are autonomous:
sl@0
   763
	Compose an empty scene
sl@0
   764
	Create a scene containing a screen sized element with 2 buffers
sl@0
   765
	Enable WFC_TRANPARENCY_GLOBAL_ALPHA 
sl@0
   766
	Set WFC_ELEMENT_GLOBAL_ALPHA to be 255 (opaque)
sl@0
   767
	Compose the scene
sl@0
   768
@SYMTestExpectedResults
sl@0
   769
	The final scene should be fastpathed
sl@0
   770
*/
sl@0
   771
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0001L()
sl@0
   772
	{
sl@0
   773
    iTestName = _L("FASTPATH_0001");
sl@0
   774
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
   775
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
   776
    SetupEmptySceneL();
sl@0
   777
    
sl@0
   778
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
   779
                                                iFastpathablePixelFormat,
sl@0
   780
                                                iStride, iContiguous, iMaxBuffers);
sl@0
   781
    ASSERT_FALSE(surface.IsNull());
sl@0
   782
sl@0
   783
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
   784
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   785
    ASSERT_EQUALS(err,KErrNone);
sl@0
   786
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
   787
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
   788
    
sl@0
   789
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
   790
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
   791
    //set element global alpha
sl@0
   792
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA);
sl@0
   793
    wfcSetElementAttribf(iDevice, fpElement, WFC_ELEMENT_GLOBAL_ALPHA, 1.0f);
sl@0
   794
    
sl@0
   795
#ifdef BREAKPOINT_FASTPATH
sl@0
   796
    __BREAKPOINT();
sl@0
   797
#endif
sl@0
   798
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
   799
    LOG(("OpenWFTest: Expecting FASTPATH after next commit - using element alpha"));
sl@0
   800
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
   801
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
   802
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
   803
    LOG(("OpenWFTest: Fastpath - now ON - using element alpha"));
sl@0
   804
    
sl@0
   805
    iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
   806
    err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   807
    ASSERT_EQUALS(err,KErrNone);
sl@0
   808
    WaitL(iCompositionPause);	
sl@0
   809
 
sl@0
   810
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
   811
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
   812
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
   813
    ReleaseOnScreenStream();
sl@0
   814
sl@0
   815
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
   816
    wfcDestroySource(iDevice, fpSource);  
sl@0
   817
	}
sl@0
   818
sl@0
   819
/*
sl@0
   820
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0002
sl@0
   821
@SYMTestCaseDesc		Positive testing - Fastpath one-element scene  
sl@0
   822
@SYMREQ					
sl@0
   823
@SYMPREQ						PREQ417-54885
sl@0
   824
@SYMTestType				Unit Test
sl@0
   825
@SYMTestPriority		High
sl@0
   826
@SYMTestPurpose			Check a scene including a full screen element with source alpha flagged but an 
sl@0
   827
										opaque data format can be fastpathed
sl@0
   828
@SYMTestActions			
sl@0
   829
	All compositions are autonomous:
sl@0
   830
	Compose an empty scene
sl@0
   831
	Create a scene containing a screen sized element 
sl@0
   832
	Enable WFC_TRANSPARENCY_SOURCE, but the source format has no alpha value 
sl@0
   833
	Compose the scene
sl@0
   834
@SYMTestExpectedResults
sl@0
   835
	The final scene should be fastpathed
sl@0
   836
*/	
sl@0
   837
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0002L()
sl@0
   838
	{
sl@0
   839
    iTestName = _L("FASTPATH_0002");
sl@0
   840
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
   841
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
   842
    SetupEmptySceneL();
sl@0
   843
    
sl@0
   844
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
   845
												EUidPixelFormatXRGB_8888,
sl@0
   846
                                                iStride, iContiguous, iMaxBuffers);
sl@0
   847
    ASSERT_FALSE(surface.IsNull());
sl@0
   848
sl@0
   849
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
   850
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   851
    ASSERT_EQUALS(err,KErrNone);
sl@0
   852
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
   853
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
   854
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
   855
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
   856
    //set pixel alpha on XRGB element
sl@0
   857
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_SOURCE);
sl@0
   858
    
sl@0
   859
#ifdef BREAKPOINT_FASTPATH
sl@0
   860
    __BREAKPOINT();
sl@0
   861
#endif
sl@0
   862
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
   863
    LOG(("OpenWFTest: Expecting FASTPATH after next commit - using pixel alpha"));
sl@0
   864
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
   865
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
   866
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
   867
    LOG(("OpenWFTest: Fastpath - now ON - using pixel alpha"));
sl@0
   868
    
sl@0
   869
    iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
   870
    err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   871
    ASSERT_EQUALS(err,KErrNone);
sl@0
   872
    WaitL(iCompositionPause);
sl@0
   873
 
sl@0
   874
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
   875
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
   876
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
   877
    ReleaseOnScreenStream();
sl@0
   878
sl@0
   879
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
   880
    wfcDestroySource(iDevice, fpSource);  
sl@0
   881
	}
sl@0
   882
sl@0
   883
/*
sl@0
   884
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0003
sl@0
   885
@SYMTestCaseDesc		Positive testing - Fastpath scene with a double buffered element
sl@0
   886
@SYMREQ					
sl@0
   887
@SYMPREQ						PREQ417-54885
sl@0
   888
@SYMTestType				Unit Test
sl@0
   889
@SYMTestPriority		High
sl@0
   890
@SYMTestPurpose			Check if a scene is fastpathed using the second buffer
sl@0
   891
@SYMTestActions			
sl@0
   892
	All compositions are autonomous:
sl@0
   893
	Compose an empty scene
sl@0
   894
	A) Create a scene containing an element with 2 buffers
sl@0
   895
	Set the element screen size
sl@0
   896
	Set destination and source rectangle to screen size
sl@0
   897
	Compose the scene
sl@0
   898
	B) Send an update to buffer 1 with change of colour
sl@0
   899
	Wait for notification
sl@0
   900
@SYMTestExpectedResults
sl@0
   901
	The scene should be fastpathed for A and B
sl@0
   902
	Screen colour should change after B
sl@0
   903
*/
sl@0
   904
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0003L()
sl@0
   905
	{
sl@0
   906
    iTestName = _L("FASTPATH_0003");
sl@0
   907
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
   908
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
   909
    SetupEmptySceneL();
sl@0
   910
    
sl@0
   911
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
   912
                                                iFastpathablePixelFormat,
sl@0
   913
                                                iStride, iContiguous, iMaxBuffers);
sl@0
   914
    ASSERT_FALSE(surface.IsNull());
sl@0
   915
sl@0
   916
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
   917
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   918
    ASSERT_EQUALS(err,KErrNone);
sl@0
   919
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
   920
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
   921
    
sl@0
   922
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
   923
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
   924
    
sl@0
   925
#ifdef BREAKPOINT_FASTPATH
sl@0
   926
    __BREAKPOINT();
sl@0
   927
#endif
sl@0
   928
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
   929
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
   930
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
   931
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
   932
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
   933
    LOG(("OpenWFTest: Fastpath - now ON"));
sl@0
   934
    
sl@0
   935
    iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
   936
    err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
   937
    ASSERT_EQUALS(err,KErrNone);
sl@0
   938
    WaitL(iCompositionPause);	
sl@0
   939
 
sl@0
   940
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
   941
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
   942
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
   943
    ReleaseOnScreenStream();
sl@0
   944
    
sl@0
   945
    //Fill surface is blue
sl@0
   946
    iUtility->FillSurfaceL(surface, 1, KBlue);
sl@0
   947
	//Do content update for surface buff1
sl@0
   948
    CActiveNotification* buff1disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
   949
    CleanupStack::PushL(buff1disp);
sl@0
   950
    TTimeStamp buff1time;
sl@0
   951
    iUtility->NotifyWhenDisplayed(buff1disp->iStatus,buff1time);
sl@0
   952
    
sl@0
   953
    LOG(("OpenWFTest: Fastpath - staying ON..."));
sl@0
   954
    err = iUtility->SubmitUpdate(surface, 1, NULL);
sl@0
   955
	ASSERT_EQUALS(err,KErrNone);
sl@0
   956
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,1));	//1 AO should have completed
sl@0
   957
    
sl@0
   958
    //create ref image/check on screen content
sl@0
   959
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
   960
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
   961
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KBlue,iTolerance));
sl@0
   962
    ReleaseOnScreenStream();
sl@0
   963
sl@0
   964
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
   965
    wfcDestroySource(iDevice, fpSource);
sl@0
   966
    CleanupStack::PopAndDestroy(buff1disp);
sl@0
   967
	}
sl@0
   968
sl@0
   969
/*
sl@0
   970
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0004
sl@0
   971
@SYMTestCaseDesc		Positive testing - Fastpath two-element scene 
sl@0
   972
@SYMREQ					
sl@0
   973
@SYMPREQ						PREQ417-54885
sl@0
   974
@SYMTestType				Unit Test
sl@0
   975
@SYMTestPriority		Medium
sl@0
   976
@SYMTestPurpose			Check a scene including a full screen opaque element as the top layer can be 
sl@0
   977
										fastpathed
sl@0
   978
@SYMTestActions			
sl@0
   979
	All compositions are autonomous:
sl@0
   980
	Compose an empty scene
sl@0
   981
	A) Create a scene containing a screen sized element with WFC_TRANSPARENCY_NONE enabled
sl@0
   982
	Compose the scene
sl@0
   983
  B) Create a small rectangle behind the first element
sl@0
   984
	Compose the scene
sl@0
   985
*/
sl@0
   986
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0004L()
sl@0
   987
	{
sl@0
   988
    iTestName = _L("FASTPATH_0004");
sl@0
   989
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
   990
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
   991
    SetupEmptySceneL();
sl@0
   992
	
sl@0
   993
	TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
   994
												iFastpathablePixelFormat,
sl@0
   995
												iStride, iContiguous, iMaxBuffers);
sl@0
   996
	ASSERT_FALSE(surface.IsNull());
sl@0
   997
sl@0
   998
	WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
   999
	TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1000
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1001
	WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1002
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);	
sl@0
  1003
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1004
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1005
	
sl@0
  1006
    TSurfaceId surfaceB = iUtility->CreateSurfaceL(TSize(iFastpathableWidth/2,iFastpathableHeight/2),
sl@0
  1007
                                                iFastpathablePixelFormat,
sl@0
  1008
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1009
    ASSERT_FALSE(surfaceB.IsNull());
sl@0
  1010
    WFCSource sourceB = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceB), NULL);
sl@0
  1011
    err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1012
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1013
    WFCElement elementB = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1014
    wfcSetElementAttribi(iDevice, elementB, WFC_ELEMENT_SOURCE, sourceB);
sl@0
  1015
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iHalfSizeRect);
sl@0
  1016
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iCenterRect);
sl@0
  1017
	
sl@0
  1018
#ifdef BREAKPOINT_FASTPATH
sl@0
  1019
    __BREAKPOINT();
sl@0
  1020
#endif
sl@0
  1021
	wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  1022
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1023
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1024
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1025
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1026
	LOG(("OpenWFTest: Fastpath - now ON"));
sl@0
  1027
	
sl@0
  1028
	iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  1029
	err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1030
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1031
	WaitL(iCompositionPause);
sl@0
  1032
 
sl@0
  1033
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1034
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1035
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
  1036
    ReleaseOnScreenStream();
sl@0
  1037
	
sl@0
  1038
    LOG(("OpenWFTest: Fastpath - staying ON..."));
sl@0
  1039
#ifdef BREAKPOINT_FASTPATH
sl@0
  1040
    __BREAKPOINT();
sl@0
  1041
#endif
sl@0
  1042
	wfcInsertElement(iDevice, elementB, WFC_INVALID_HANDLE);
sl@0
  1043
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1044
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1045
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1046
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1047
	
sl@0
  1048
	iUtility->FillSurfaceL(surfaceB, 0, KBlue);
sl@0
  1049
	err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1050
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1051
	WaitL(iCompositionPause);
sl@0
  1052
 
sl@0
  1053
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1054
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1055
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
  1056
    ReleaseOnScreenStream();
sl@0
  1057
sl@0
  1058
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  1059
	wfcDestroySource(iDevice, fpSource);
sl@0
  1060
	wfcDestroySource(iDevice, sourceB);  
sl@0
  1061
	}
sl@0
  1062
sl@0
  1063
/*
sl@0
  1064
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0005
sl@0
  1065
@SYMTestCaseDesc		Positive testing - Fastpath two-element scene 
sl@0
  1066
@SYMREQ					
sl@0
  1067
@SYMPREQ						PREQ417-54885
sl@0
  1068
@SYMTestType				Unit Test
sl@0
  1069
@SYMTestPriority		Medium	
sl@0
  1070
@SYMTestPurpose			Check a scene including a full screen element with global alpha as the top layer 
sl@0
  1071
										can be fastpathed
sl@0
  1072
@SYMTestActions			
sl@0
  1073
	All compositions are autonomous:
sl@0
  1074
	Compose an empty scene
sl@0
  1075
	A) Create a scene containing a screen sized element 
sl@0
  1076
	Enable WFC_TRANPARENCY_GLOBAL_ALPHA and set WFC_ELEMENT_GLOBAL_ALPHA to be 255 (opaque)
sl@0
  1077
	Compose the scene
sl@0
  1078
	B) Create a smaller element behind the first element
sl@0
  1079
	Compose the scene
sl@0
  1080
@SYMTestExpectedResults
sl@0
  1081
	Both compositions should trigger fastpathing.
sl@0
  1082
*/
sl@0
  1083
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0005L()
sl@0
  1084
	{
sl@0
  1085
    iTestName = _L("FASTPATH_0005");
sl@0
  1086
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  1087
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  1088
    SetupEmptySceneL();
sl@0
  1089
	
sl@0
  1090
	TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  1091
												iFastpathablePixelFormat,
sl@0
  1092
												iStride, iContiguous, iMaxBuffers);
sl@0
  1093
	ASSERT_FALSE(surface.IsNull());
sl@0
  1094
sl@0
  1095
	WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  1096
	TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1097
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1098
	WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1099
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);	
sl@0
  1100
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1101
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1102
//set element global alpha
sl@0
  1103
	wfcSetElementAttribf(iDevice, fpElement, WFC_ELEMENT_GLOBAL_ALPHA, 1.0f);
sl@0
  1104
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA);
sl@0
  1105
	
sl@0
  1106
    TSurfaceId surfaceB = iUtility->CreateSurfaceL(TSize(iFastpathableWidth/2,iFastpathableHeight/2),
sl@0
  1107
                                                iFastpathablePixelFormat,
sl@0
  1108
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1109
    ASSERT_FALSE(surfaceB.IsNull());
sl@0
  1110
    WFCSource sourceB = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceB), NULL);
sl@0
  1111
    err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1112
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1113
    WFCElement elementB = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1114
    wfcSetElementAttribi(iDevice, elementB, WFC_ELEMENT_SOURCE, sourceB);
sl@0
  1115
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iHalfSizeRect);
sl@0
  1116
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iCenterRect);
sl@0
  1117
	
sl@0
  1118
#ifdef BREAKPOINT_FASTPATH
sl@0
  1119
    __BREAKPOINT();
sl@0
  1120
#endif
sl@0
  1121
	wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  1122
    LOG(("OpenWFTest: Expecting FASTPATH after next commit - using element global alpha"));
sl@0
  1123
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1124
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1125
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1126
	LOG(("OpenWFTest: Fastpath - now ON... - using element global alpha"));
sl@0
  1127
	
sl@0
  1128
	iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  1129
	ASSERT_EQUALS(iUtility->SubmitUpdate(surface, 0, NULL),KErrNone);
sl@0
  1130
	WaitL(iCompositionPause);
sl@0
  1131
 
sl@0
  1132
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1133
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1134
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
  1135
    ReleaseOnScreenStream();
sl@0
  1136
	
sl@0
  1137
sl@0
  1138
#ifdef BREAKPOINT_FASTPATH
sl@0
  1139
    __BREAKPOINT();
sl@0
  1140
#endif
sl@0
  1141
	wfcInsertElement(iDevice, elementB, WFC_INVALID_HANDLE);
sl@0
  1142
    LOG(("OpenWFTest: Expecting FASTPATH after next commit - using element global alpha"));
sl@0
  1143
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1144
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1145
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1146
	
sl@0
  1147
	iUtility->FillSurfaceL(surfaceB, 0, KBlue);
sl@0
  1148
	err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1149
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1150
	WaitL(iCompositionPause);	
sl@0
  1151
 
sl@0
  1152
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1153
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1154
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
  1155
    ReleaseOnScreenStream();
sl@0
  1156
sl@0
  1157
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  1158
	wfcDestroySource(iDevice, fpSource);
sl@0
  1159
	wfcDestroySource(iDevice, sourceB);  
sl@0
  1160
	}
sl@0
  1161
sl@0
  1162
/*
sl@0
  1163
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0006
sl@0
  1164
@SYMTestCaseDesc		Positive testing - Fastpath two-element scene 
sl@0
  1165
@SYMREQ					
sl@0
  1166
@SYMPREQ						PREQ417-54885
sl@0
  1167
@SYMTestType				Unit Test
sl@0
  1168
@SYMTestPriority		Low
sl@0
  1169
@SYMTestPurpose			Check a scene including a full screen opaque element behind a transparent element 
sl@0
  1170
										can be fastpathed
sl@0
  1171
@SYMTestActions			
sl@0
  1172
	All compositions are autonomous:
sl@0
  1173
	Compose an empty scene
sl@0
  1174
	A) Create a scene containing an element of any size 
sl@0
  1175
	Enable WFC_TRANPARENCY_GLOBAL_ALPHA and set WFC_ELEMENT_GLOBAL_ALPHA to 0 (transparent)
sl@0
  1176
	Compose the scene
sl@0
  1177
	B) Create another screen sized opaque element behind the frist 
sl@0
  1178
	Compose the scene
sl@0
  1179
@SYMTestExpectedResults
sl@0
  1180
	The final scene should fastpath for B), not for A)	
sl@0
  1181
	(The current implementation does not support this fastpath behaviour. This test can be ignored at 
sl@0
  1182
	the moment.)
sl@0
  1183
*/
sl@0
  1184
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0006L()
sl@0
  1185
	{
sl@0
  1186
    iTestName = _L("FASTPATH_0006");
sl@0
  1187
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  1188
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  1189
    SetupEmptySceneL();
sl@0
  1190
	
sl@0
  1191
	TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth/2,iFastpathableHeight/2),
sl@0
  1192
												iFastpathablePixelFormat,
sl@0
  1193
												iStride, iContiguous, iMaxBuffers);
sl@0
  1194
	ASSERT_FALSE(surface.IsNull());
sl@0
  1195
sl@0
  1196
	WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  1197
	TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1198
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1199
	WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1200
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);	
sl@0
  1201
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iHalfSizeRect);
sl@0
  1202
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iCenterRect);
sl@0
  1203
	//set element global alpha fully transparent
sl@0
  1204
	wfcSetElementAttribf(iDevice, fpElement, WFC_ELEMENT_GLOBAL_ALPHA, 0.0f);
sl@0
  1205
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA);
sl@0
  1206
	
sl@0
  1207
    TSurfaceId surfaceB = iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  1208
													iFastpathablePixelFormat,
sl@0
  1209
													iStride, iContiguous, iMaxBuffers);
sl@0
  1210
    ASSERT_FALSE(surfaceB.IsNull());
sl@0
  1211
    WFCSource sourceB = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceB), NULL);
sl@0
  1212
    err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1213
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1214
    WFCElement elementB = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1215
    wfcSetElementAttribi(iDevice, elementB, WFC_ELEMENT_SOURCE, sourceB);
sl@0
  1216
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1217
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1218
	
sl@0
  1219
#ifdef BREAKPOINT_FASTPATH
sl@0
  1220
    __BREAKPOINT();
sl@0
  1221
#endif
sl@0
  1222
	wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  1223
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit -single fully transparent element using global alpha"));
sl@0
  1224
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1225
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1226
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1227
	LOG(("OpenWFTest: Fastpath - now ON - single fully transparent element using global alpha"));
sl@0
  1228
	
sl@0
  1229
	iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  1230
	err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1231
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1232
	WaitL(iCompositionPause);	
sl@0
  1233
 
sl@0
  1234
#ifdef BREAKPOINT_FASTPATH
sl@0
  1235
    __BREAKPOINT();
sl@0
  1236
#endif
sl@0
  1237
	wfcInsertElement(iDevice, elementB, WFC_INVALID_HANDLE);
sl@0
  1238
    LOG(("OpenWFTest: Expecting FASTPATH after next commit -fullscreen opaque element behind fully transparent element"));
sl@0
  1239
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1240
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1241
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1242
	LOG(("OpenWFTest: Fastpath - now ON - fullscreen opaque element behind transparent element"));
sl@0
  1243
	
sl@0
  1244
	iUtility->FillSurfaceL(surfaceB, 0, KBlue);
sl@0
  1245
	err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1246
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1247
	WaitL(iCompositionPause);	
sl@0
  1248
 
sl@0
  1249
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1250
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1251
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KBlue,iTolerance));
sl@0
  1252
    ReleaseOnScreenStream();
sl@0
  1253
sl@0
  1254
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  1255
	wfcDestroySource(iDevice, fpSource);
sl@0
  1256
	wfcDestroySource(iDevice, sourceB);  
sl@0
  1257
	}
sl@0
  1258
sl@0
  1259
/*
sl@0
  1260
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0007
sl@0
  1261
@SYMTestCaseDesc		Positive testing - Fastpath one-element scene  
sl@0
  1262
@SYMREQ					
sl@0
  1263
@SYMPREQ						PREQ417-54885
sl@0
  1264
@SYMTestType				Unit Test
sl@0
  1265
@SYMTestPriority		High
sl@0
  1266
@SYMTestPurpose			Check a scene including destination rectangle changes can trigger fastpath on and off
sl@0
  1267
@SYMTestActions			
sl@0
  1268
	All compositions are autonomous:
sl@0
  1269
	Compose an empty scene
sl@0
  1270
	Create a scene containing a screen sized element 
sl@0
  1271
	Compose scene
sl@0
  1272
	Set the destination rectangle smaller than screen size
sl@0
  1273
	Compose the scene
sl@0
  1274
	Set the destination rectangle back to screen size
sl@0
  1275
	Compose the scene
sl@0
  1276
@SYMTestExpectedResults
sl@0
  1277
	The scenes with the element of full screen destination rectangle should be fastpathed	
sl@0
  1278
	The scene with the element of smaller destination rectangle should not be fastpathed
sl@0
  1279
*/
sl@0
  1280
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0007L()
sl@0
  1281
	{
sl@0
  1282
    iTestName = _L("FASTPATH_0007");
sl@0
  1283
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  1284
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  1285
    SetupEmptySceneL();
sl@0
  1286
	
sl@0
  1287
	TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  1288
												iFastpathablePixelFormat,
sl@0
  1289
												iStride, iContiguous, iMaxBuffers);
sl@0
  1290
	ASSERT_FALSE(surface.IsNull());
sl@0
  1291
sl@0
  1292
	WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  1293
	TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1294
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1295
	WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1296
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);	
sl@0
  1297
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1298
	//NOT full screen destination
sl@0
  1299
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iCenterRect);
sl@0
  1300
	
sl@0
  1301
#ifdef BREAKPOINT_FASTPATH
sl@0
  1302
    __BREAKPOINT();
sl@0
  1303
#endif
sl@0
  1304
	wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  1305
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit"));
sl@0
  1306
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1307
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1308
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1309
	LOG(("OpenWFTest: Fastpath - still OFF"));
sl@0
  1310
	
sl@0
  1311
	iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  1312
	err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  1313
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1314
	WaitL(iCompositionPause);	
sl@0
  1315
 
sl@0
  1316
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1317
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1318
    ASSERT_TRUE(CheckOnScreenStreamRect(iCenterTRect,KGreen,iTolerance));
sl@0
  1319
    ReleaseOnScreenStream();
sl@0
  1320
	
sl@0
  1321
	//NOW set full screen
sl@0
  1322
	wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1323
	
sl@0
  1324
#ifdef BREAKPOINT_FASTPATH
sl@0
  1325
    __BREAKPOINT();
sl@0
  1326
#endif
sl@0
  1327
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1328
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1329
	wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1330
	ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1331
	WaitL(iCompositionPause);
sl@0
  1332
 
sl@0
  1333
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1334
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1335
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
  1336
    ReleaseOnScreenStream();
sl@0
  1337
sl@0
  1338
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  1339
	wfcDestroySource(iDevice, fpSource);  
sl@0
  1340
	}
sl@0
  1341
sl@0
  1342
//NOTIFICATION TESTS
sl@0
  1343
void COpenwfTest::FastpathNotificationsTestL(TBool aAutonomous)
sl@0
  1344
	{
sl@0
  1345
    SetupEmptySceneL(aAutonomous);
sl@0
  1346
sl@0
  1347
    //Create 3 elements A+C fastpathable, B centered
sl@0
  1348
    TSurfaceId surfaceA = iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  1349
                                                iFastpathablePixelFormat,
sl@0
  1350
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1351
    ASSERT_FALSE(surfaceA.IsNull());
sl@0
  1352
    WFCSource sourceA = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceA), NULL);
sl@0
  1353
    TInt err = iUtility->SubmitUpdate(surfaceA, 0, NULL);
sl@0
  1354
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1355
    WFCElement elementA = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1356
    wfcSetElementAttribi(iDevice, elementA, WFC_ELEMENT_SOURCE, sourceA);
sl@0
  1357
    wfcSetElementAttribiv(iDevice, elementA, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1358
    wfcSetElementAttribiv(iDevice, elementA, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1359
    
sl@0
  1360
    TSurfaceId surfaceB = iUtility->CreateSurfaceL(TSize(iFastpathableWidth/2,iFastpathableHeight/2),
sl@0
  1361
                                                iFastpathablePixelFormat,
sl@0
  1362
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1363
    ASSERT_FALSE(surfaceB.IsNull());
sl@0
  1364
    WFCSource sourceB = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceB), NULL);
sl@0
  1365
    err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1366
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1367
    WFCElement elementB = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1368
    wfcSetElementAttribi(iDevice, elementB, WFC_ELEMENT_SOURCE, sourceB);
sl@0
  1369
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iHalfSizeRect);
sl@0
  1370
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iCenterRect);
sl@0
  1371
    
sl@0
  1372
    TSurfaceId surfaceC = iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  1373
                                                iFastpathablePixelFormat,
sl@0
  1374
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1375
    ASSERT_FALSE(surfaceC.IsNull());
sl@0
  1376
    WFCSource sourceC = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceC), NULL);
sl@0
  1377
    err = iUtility->SubmitUpdate(surfaceC, 0, NULL);
sl@0
  1378
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1379
    WFCElement elementC = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1380
    wfcSetElementAttribi(iDevice, elementC, WFC_ELEMENT_SOURCE, sourceC);
sl@0
  1381
    wfcSetElementAttribiv(iDevice, elementC, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1382
    wfcSetElementAttribiv(iDevice, elementC, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1383
sl@0
  1384
    //**********STARTING ACTUAL TEST!**********
sl@0
  1385
    //**********SURFACE A FASTPATHABLE**********
sl@0
  1386
	//Add A to scene
sl@0
  1387
    wfcInsertElement(iDevice, elementA, WFC_INVALID_HANDLE);
sl@0
  1388
#ifdef BREAKPOINT_FASTPATH
sl@0
  1389
    __BREAKPOINT();
sl@0
  1390
#endif
sl@0
  1391
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1392
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1393
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1394
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1395
    LOG(("OpenWFTest: Fastpath - now ON"));
sl@0
  1396
	//Set A buffer0 red
sl@0
  1397
    iUtility->FillSurfaceL(surfaceA, 0, KRed);
sl@0
  1398
	//Do content update Abuff0 idisp iavail
sl@0
  1399
    CActiveNotification* surfAbuff0disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1400
    CleanupStack::PushL(surfAbuff0disp);
sl@0
  1401
    TTimeStamp surfAbuff0time;
sl@0
  1402
    CActiveNotification* surfAbuff0avail = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1403
    CleanupStack::PushL(surfAbuff0avail);
sl@0
  1404
    //iUtility->NotifyWhenDisplayed(surfAbuff0disp,surfAbuff0time);
sl@0
  1405
    iUtility->NotifyWhenDisplayed(surfAbuff0disp->iStatus,surfAbuff0time);
sl@0
  1406
    iUtility->NotifyWhenAvailable(surfAbuff0avail->iStatus); 
sl@0
  1407
    err = iUtility->SubmitUpdate(surfaceA, 0, NULL);
sl@0
  1408
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1409
	
sl@0
  1410
    if(!aAutonomous)
sl@0
  1411
    	{
sl@0
  1412
        WaitL(iCompositionPause);
sl@0
  1413
		//Check A buff0 iDisp doesnt complete
sl@0
  1414
		ASSERT_EQUALS(surfAbuff0disp->iStatus.Int(),KRequestPending);
sl@0
  1415
		//Check A buff0 iAvail doesnt complete
sl@0
  1416
		ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1417
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1418
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1419
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1420
    	}
sl@0
  1421
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,1));
sl@0
  1422
	
sl@0
  1423
	//Check A buff0 iDisp completes
sl@0
  1424
    ASSERT_EQUALS(surfAbuff0disp->iStatus.Int(),KErrNone);
sl@0
  1425
	//Check A buff0 iAvail doesnt complete
sl@0
  1426
    ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1427
    
sl@0
  1428
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1429
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1430
    ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KRed,iTolerance));
sl@0
  1431
    ReleaseOnScreenStream();
sl@0
  1432
sl@0
  1433
	//Set A buffer1 Yellow
sl@0
  1434
    iUtility->FillSurfaceL(surfaceA, 1, KYellow);
sl@0
  1435
	
sl@0
  1436
	//Check A buff0 iavail doesnt complete
sl@0
  1437
    ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1438
    
sl@0
  1439
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1440
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1441
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KRed,iTolerance));
sl@0
  1442
	ReleaseOnScreenStream();
sl@0
  1443
	
sl@0
  1444
	//Do content update Abuff1 idisp iavail
sl@0
  1445
    CActiveNotification* surfAbuff1disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1446
    CleanupStack::PushL(surfAbuff1disp);
sl@0
  1447
    TTimeStamp surfAbuff1time;
sl@0
  1448
    CActiveNotification* surfAbuff1avail = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1449
    CleanupStack::PushL(surfAbuff1avail);
sl@0
  1450
    iUtility->NotifyWhenDisplayed(surfAbuff1disp->iStatus,surfAbuff1time);
sl@0
  1451
    iUtility->NotifyWhenAvailable(surfAbuff1avail->iStatus); 
sl@0
  1452
    err = iUtility->SubmitUpdate(surfaceA, 1, NULL);
sl@0
  1453
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1454
    
sl@0
  1455
    if(!aAutonomous)
sl@0
  1456
    	{
sl@0
  1457
        WaitL(iCompositionPause);
sl@0
  1458
		//Check A buff1 iDisp doesnt complete
sl@0
  1459
		ASSERT_EQUALS(surfAbuff1disp->iStatus.Int(),KRequestPending);
sl@0
  1460
		//Check A buff1 iAvail doesnt complete
sl@0
  1461
		ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1462
		//Check A buff0 iAvail doesnt complete
sl@0
  1463
	    ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1464
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1465
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1466
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1467
    	}
sl@0
  1468
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,2));
sl@0
  1469
	
sl@0
  1470
	//Check A buff1 idisp completes
sl@0
  1471
    ASSERT_EQUALS(surfAbuff1disp->iStatus.Int(),KErrNone);
sl@0
  1472
	//Check A buff0 iAvail completes
sl@0
  1473
    ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KErrNone);
sl@0
  1474
	//Check A buff1 iAvail doesnt complete
sl@0
  1475
    ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1476
    
sl@0
  1477
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1478
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1479
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KYellow,iTolerance));
sl@0
  1480
	ReleaseOnScreenStream();
sl@0
  1481
	
sl@0
  1482
	//**********SURFACE B NOT VISIBLE**********
sl@0
  1483
	//Add surfaceB to scene behind surfaceA
sl@0
  1484
    wfcInsertElement(iDevice, elementB, WFC_INVALID_HANDLE);
sl@0
  1485
#ifdef BREAKPOINT_FASTPATH
sl@0
  1486
    __BREAKPOINT();
sl@0
  1487
#endif
sl@0
  1488
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1489
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1490
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1491
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1492
    LOG(("OpenWFTest: Fastpath - still ON"));
sl@0
  1493
	//Set B buffer0 green
sl@0
  1494
    iUtility->FillSurfaceL(surfaceB, 0, KGreen);
sl@0
  1495
	//Do content update idisp iavail
sl@0
  1496
    CActiveNotification* surfBbuff0disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1497
    CleanupStack::PushL(surfBbuff0disp);
sl@0
  1498
    TTimeStamp surfBbuff0time;
sl@0
  1499
    CActiveNotification* surfBbuff0avail = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1500
    CleanupStack::PushL(surfBbuff0avail);
sl@0
  1501
    iUtility->NotifyWhenDisplayed(surfBbuff0disp->iStatus,surfBbuff0time);
sl@0
  1502
    iUtility->NotifyWhenAvailable(surfBbuff0avail->iStatus); 
sl@0
  1503
    err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1504
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1505
	
sl@0
  1506
    if(!aAutonomous)
sl@0
  1507
    	{
sl@0
  1508
        WaitL(iCompositionPause);
sl@0
  1509
		//Check B buff0 iAvail doesnt complete
sl@0
  1510
		ASSERT_EQUALS(surfBbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1511
		//Check B buff0 iDisp doesnt complete
sl@0
  1512
		ASSERT_EQUALS(surfBbuff0disp->iStatus.Int(),KRequestPending);
sl@0
  1513
		//Check A buff1 iAvail doesnt complete
sl@0
  1514
		ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1515
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1516
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1517
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1518
    	}
sl@0
  1519
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,1));
sl@0
  1520
    
sl@0
  1521
	//Check B buff0 idisp completes - could be no error or not visible
sl@0
  1522
    ASSERT_TRUE((surfBbuff0disp->iStatus.Int()==KErrNotVisible)||(surfBbuff0disp->iStatus.Int()==KErrNone));
sl@0
  1523
	//Check B buff0 iavail doesnt complete
sl@0
  1524
    ASSERT_EQUALS(surfBbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1525
	//Check A buff1 iavail doesnt complete
sl@0
  1526
    ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1527
	
sl@0
  1528
	//Set B buffer1 blue
sl@0
  1529
	iUtility->FillSurfaceL(surfaceB, 1, KBlue);
sl@0
  1530
	//Do content update idisp iavail
sl@0
  1531
    CActiveNotification* surfBbuff1disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1532
    CleanupStack::PushL(surfBbuff1disp);
sl@0
  1533
    TTimeStamp surfBbuff1time;
sl@0
  1534
    CActiveNotification* surfBbuff1avail = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1535
    CleanupStack::PushL(surfBbuff1avail);
sl@0
  1536
    iUtility->NotifyWhenDisplayed(surfBbuff1disp->iStatus,surfBbuff1time);
sl@0
  1537
    iUtility->NotifyWhenAvailable(surfBbuff1avail->iStatus); 
sl@0
  1538
    err = iUtility->SubmitUpdate(surfaceB, 1, NULL);
sl@0
  1539
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1540
    
sl@0
  1541
    if(!aAutonomous)
sl@0
  1542
    	{
sl@0
  1543
        WaitL(iCompositionPause);
sl@0
  1544
		//Check B buff1 iAvail doesnt complete
sl@0
  1545
		ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1546
		//Check B buff1 iDisp doesnt complete
sl@0
  1547
		ASSERT_EQUALS(surfBbuff1disp->iStatus.Int(),KRequestPending);
sl@0
  1548
		//Check B buff0 iAvail doesnt complete
sl@0
  1549
		ASSERT_EQUALS(surfBbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1550
		//Check A buff1 iAvail doesnt complete
sl@0
  1551
		ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1552
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1553
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1554
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1555
    	}
sl@0
  1556
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,2));
sl@0
  1557
    
sl@0
  1558
    //Check B buff1 idisp completes - could be no error or not visible
sl@0
  1559
    ASSERT_TRUE((surfBbuff1disp->iStatus.Int()==KErrNotVisible)||(surfBbuff1disp->iStatus.Int()==KErrNone));
sl@0
  1560
	//Check B buff1 iavail doesnt complete
sl@0
  1561
    ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1562
	//Check B buff0 iavail completes - could be no error or not visible
sl@0
  1563
    ASSERT_TRUE((surfBbuff0avail->iStatus.Int()==KErrNotVisible)||(surfBbuff0avail->iStatus.Int()==KErrNone));
sl@0
  1564
	//Check A buff1 iavail doesnt complete
sl@0
  1565
    ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1566
    
sl@0
  1567
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1568
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1569
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KYellow,iTolerance));
sl@0
  1570
	ReleaseOnScreenStream();
sl@0
  1571
	
sl@0
  1572
	//**********SURFACE C ALSO FASTPATHABLE**********
sl@0
  1573
	//Add C to scene in front of surfaceA
sl@0
  1574
    wfcInsertElement(iDevice, elementC, elementA);
sl@0
  1575
#ifdef BREAKPOINT_FASTPATH
sl@0
  1576
    __BREAKPOINT();
sl@0
  1577
#endif
sl@0
  1578
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1579
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1580
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1581
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1582
    LOG(("OpenWFTest: Fastpath - still ON"));
sl@0
  1583
	//Set C to brown
sl@0
  1584
    iUtility->FillSurfaceL(surfaceC, 0, KBrown);
sl@0
  1585
	//Do content update Cbuff0 idisp iavail
sl@0
  1586
    CActiveNotification* surfCbuff0disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1587
    CleanupStack::PushL(surfCbuff0disp);
sl@0
  1588
    TTimeStamp surfCbuff0time;
sl@0
  1589
    CActiveNotification* surfCbuff0avail = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1590
    CleanupStack::PushL(surfCbuff0avail);
sl@0
  1591
    iUtility->NotifyWhenDisplayed(surfCbuff0disp->iStatus,surfCbuff0time);
sl@0
  1592
    iUtility->NotifyWhenAvailable(surfCbuff0avail->iStatus); 
sl@0
  1593
    err = iUtility->SubmitUpdate(surfaceC, 0, NULL);
sl@0
  1594
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1595
	
sl@0
  1596
    if(!aAutonomous)
sl@0
  1597
    	{
sl@0
  1598
        WaitL(iCompositionPause);
sl@0
  1599
		//Check C buff0 iAvail doesnt complete
sl@0
  1600
		ASSERT_EQUALS(surfCbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1601
		//Check C buff0 iDisp doesnt complete
sl@0
  1602
		ASSERT_EQUALS(surfCbuff0disp->iStatus.Int(),KRequestPending);
sl@0
  1603
		//Check B buff1 iAvail doesnt complete
sl@0
  1604
		ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1605
		//Check A buff1 iAvail doesnt complete
sl@0
  1606
		ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1607
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1608
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1609
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1610
    	}
sl@0
  1611
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,1));
sl@0
  1612
    
sl@0
  1613
	//Check C buff0 idisp completes
sl@0
  1614
    ASSERT_EQUALS(surfCbuff0disp->iStatus.Int(),KErrNone);
sl@0
  1615
	//Check C buff0 iavail does not complete
sl@0
  1616
    ASSERT_EQUALS(surfCbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1617
	//Check B buff1 iavail doesnt complete
sl@0
  1618
    ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1619
	//Check A buff1 iavail doesnt complete
sl@0
  1620
    ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1621
    
sl@0
  1622
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1623
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1624
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KBrown,iTolerance));
sl@0
  1625
	ReleaseOnScreenStream();
sl@0
  1626
	
sl@0
  1627
	//Set C buffer1 grey
sl@0
  1628
    iUtility->FillSurfaceL(surfaceC, 1, KGray);
sl@0
  1629
	//Do content update Cbuff1 idisp iavail
sl@0
  1630
    CActiveNotification* surfCbuff1disp = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1631
    CleanupStack::PushL(surfCbuff1disp);
sl@0
  1632
    TTimeStamp surfCbuff1time;
sl@0
  1633
    CActiveNotification* surfCbuff1avail = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  1634
    CleanupStack::PushL(surfCbuff1avail);
sl@0
  1635
    iUtility->NotifyWhenDisplayed(surfCbuff1disp->iStatus,surfCbuff1time);
sl@0
  1636
    iUtility->NotifyWhenAvailable(surfCbuff1avail->iStatus); 
sl@0
  1637
    err = iUtility->SubmitUpdate(surfaceC, 1, NULL);
sl@0
  1638
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1639
    
sl@0
  1640
    if(!aAutonomous)
sl@0
  1641
    	{
sl@0
  1642
        WaitL(iCompositionPause);
sl@0
  1643
		//Check C buff1 iAvail doesnt complete
sl@0
  1644
		ASSERT_EQUALS(surfCbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1645
		//Check C buff1 iDisp doesnt complete
sl@0
  1646
		ASSERT_EQUALS(surfCbuff1disp->iStatus.Int(),KRequestPending);
sl@0
  1647
		//Check C buff0 iAvail doesnt complete
sl@0
  1648
		ASSERT_EQUALS(surfCbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1649
		//Check B buff1 iAvail doesnt complete
sl@0
  1650
		ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1651
		//Check A buff1 iAvail doesnt complete
sl@0
  1652
		ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1653
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1654
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1655
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1656
    	}
sl@0
  1657
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,2));
sl@0
  1658
    
sl@0
  1659
	//Check C buff1 idisp completes
sl@0
  1660
    ASSERT_EQUALS(surfCbuff1disp->iStatus.Int(),KErrNone);
sl@0
  1661
	//Check C buff1 iavail does not complete
sl@0
  1662
    ASSERT_EQUALS(surfCbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1663
	//Check C buff0 iavail completes
sl@0
  1664
    ASSERT_EQUALS(surfCbuff0avail->iStatus.Int(),KErrNone);
sl@0
  1665
	//Check B buff1 iavail doesnt complete
sl@0
  1666
    ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1667
	//Check A buff1 iavail doesnt complete
sl@0
  1668
    ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1669
    
sl@0
  1670
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1671
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1672
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGray,iTolerance));
sl@0
  1673
	ReleaseOnScreenStream();
sl@0
  1674
	
sl@0
  1675
    //**********SURFACE A BACK TO FRONT**********
sl@0
  1676
	//Move A to the front
sl@0
  1677
    wfcInsertElement(iDevice, elementA, elementC);
sl@0
  1678
#ifdef BREAKPOINT_FASTPATH
sl@0
  1679
    __BREAKPOINT();
sl@0
  1680
#endif
sl@0
  1681
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1682
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1683
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1684
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1685
    LOG(("OpenWFTest: Fastpath - still ON"));
sl@0
  1686
	//Set A buffer0 magenta
sl@0
  1687
    iUtility->FillSurfaceL(surfaceA, 0, KMagenta);
sl@0
  1688
	//Do content update Abuff0 idisp iavail
sl@0
  1689
    surfAbuff0disp->Activate();
sl@0
  1690
    surfAbuff0avail->Activate();
sl@0
  1691
    iUtility->NotifyWhenDisplayed(surfAbuff0disp->iStatus,surfAbuff0time);
sl@0
  1692
    iUtility->NotifyWhenAvailable(surfAbuff0avail->iStatus); 
sl@0
  1693
    err = iUtility->SubmitUpdate(surfaceA, 0, NULL);
sl@0
  1694
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1695
	
sl@0
  1696
    if(!aAutonomous)
sl@0
  1697
    	{
sl@0
  1698
        WaitL(iCompositionPause);
sl@0
  1699
		//Check A buff0 iAvail doesnt complete
sl@0
  1700
		ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1701
		//Check A buff0 iDisp doesnt complete
sl@0
  1702
		ASSERT_EQUALS(surfAbuff0disp->iStatus.Int(),KRequestPending);
sl@0
  1703
		//Check C buff1 iAvail doesnt complete
sl@0
  1704
		ASSERT_EQUALS(surfCbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1705
		//Check B buff1 iAvail doesnt complete
sl@0
  1706
		ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1707
		//Check A buff1 iAvail doesnt complete
sl@0
  1708
		ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1709
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1710
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1711
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1712
    	}
sl@0
  1713
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,2));
sl@0
  1714
    
sl@0
  1715
	//Check A buff0 idisp completes
sl@0
  1716
    ASSERT_EQUALS(surfAbuff0disp->iStatus.Int(),KErrNone);
sl@0
  1717
	//Check A buff0 iavail does not complete
sl@0
  1718
    ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1719
	//Check A buff1 iavail does complete
sl@0
  1720
    ASSERT_EQUALS(surfAbuff1avail->iStatus.Int(),KErrNone);
sl@0
  1721
	//Check C buff1 iavail does not complete
sl@0
  1722
    ASSERT_EQUALS(surfCbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1723
	//Check B buff1 iavail doesnt complete
sl@0
  1724
    ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1725
    
sl@0
  1726
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1727
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1728
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KMagenta,iTolerance));
sl@0
  1729
	ReleaseOnScreenStream();
sl@0
  1730
    
sl@0
  1731
    //**********SURFACE B TO FRONT - STOPS FASTPATH HAPPENING**********
sl@0
  1732
    //Move B to the front
sl@0
  1733
	wfcInsertElement(iDevice, elementB, elementA);
sl@0
  1734
#ifdef BREAKPOINT_FASTPATH
sl@0
  1735
    __BREAKPOINT();
sl@0
  1736
#endif
sl@0
  1737
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit"));
sl@0
  1738
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1739
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1740
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1741
    LOG(("OpenWFTest: Fastpath - now OFF..."));
sl@0
  1742
	//Set B buffer0 dark red
sl@0
  1743
	iUtility->FillSurfaceL(surfaceB, 0, KDarkRed);
sl@0
  1744
	//Do content update Abuff0 idisp iavail
sl@0
  1745
	surfBbuff0disp->Activate();
sl@0
  1746
	surfBbuff0avail->Activate();
sl@0
  1747
	iUtility->NotifyWhenDisplayed(surfBbuff0disp->iStatus,surfBbuff0time);
sl@0
  1748
	iUtility->NotifyWhenAvailable(surfBbuff0avail->iStatus); 
sl@0
  1749
	err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1750
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1751
	
sl@0
  1752
    if(!aAutonomous)
sl@0
  1753
    	{
sl@0
  1754
        WaitL(iCompositionPause);
sl@0
  1755
		//Check B buff0 iAvail doesnt complete
sl@0
  1756
		ASSERT_EQUALS(surfBbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1757
		//Check B buff0 iDisp doesnt complete
sl@0
  1758
		ASSERT_EQUALS(surfBbuff0disp->iStatus.Int(),KRequestPending);
sl@0
  1759
		//Check A buff0 iAvail doesnt complete
sl@0
  1760
		ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1761
		//Check C buff1 iAvail doesnt complete
sl@0
  1762
		ASSERT_EQUALS(surfCbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1763
		//Check B buff1 iAvail doesnt complete
sl@0
  1764
		ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1765
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1766
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1767
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1768
    	}
sl@0
  1769
    ASSERT_TRUE(WaitForNotifications(KMaxNotificationDelay,2));
sl@0
  1770
	
sl@0
  1771
	//Check B buff0 iAvail doesnt complete
sl@0
  1772
	ASSERT_EQUALS(surfBbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1773
	//Check B buff0 iDisp completes
sl@0
  1774
	ASSERT_EQUALS(surfBbuff0disp->iStatus.Int(),KErrNone);
sl@0
  1775
	//Check A buff0 iAvail doesnt complete
sl@0
  1776
	ASSERT_EQUALS(surfAbuff0avail->iStatus.Int(),KRequestPending);
sl@0
  1777
	//Check C buff1 iAvail doesnt complete
sl@0
  1778
	ASSERT_EQUALS(surfCbuff1avail->iStatus.Int(),KRequestPending);
sl@0
  1779
	//Check B buff1 iAvail completes
sl@0
  1780
	ASSERT_EQUALS(surfBbuff1avail->iStatus.Int(),KErrNone);
sl@0
  1781
	
sl@0
  1782
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1783
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1784
	//Check dark red center of screen
sl@0
  1785
	ASSERT_TRUE(CheckOnScreenStreamRect(iCenterTRect,KDarkRed,iTolerance));
sl@0
  1786
	//Check magenta around the borders
sl@0
  1787
	ASSERT_TRUE(CheckOnScreenStreamRect(TRect(0,0,iCenterTRect.iTl.iX,iCenterTRect.iTl.iY),KMagenta,iTolerance));
sl@0
  1788
	ASSERT_TRUE(CheckOnScreenStreamRect(TRect(iCenterTRect.iBr.iX+1,iCenterTRect.iBr.iY+1,
sl@0
  1789
			iFastpathableWidth,iFastpathableHeight),KMagenta,iTolerance));
sl@0
  1790
	ReleaseOnScreenStream();
sl@0
  1791
	
sl@0
  1792
	ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  1793
    
sl@0
  1794
    wfcDestroySource(iDevice, sourceA);
sl@0
  1795
    wfcDestroySource(iDevice, sourceB);
sl@0
  1796
    wfcDestroySource(iDevice, sourceC);
sl@0
  1797
    
sl@0
  1798
	CleanupStack::PopAndDestroy(12,surfAbuff0disp);
sl@0
  1799
	}
sl@0
  1800
/*
sl@0
  1801
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0010
sl@0
  1802
@SYMTestCaseDesc		Positive testing - Fastpath with notification checking for autonomous composition
sl@0
  1803
@SYMREQ					
sl@0
  1804
@SYMPREQ						PREQ417-54885
sl@0
  1805
@SYMTestType				Integration Test
sl@0
  1806
@SYMTestPriority		High
sl@0
  1807
@SYMTestPurpose			Check fastpath does not cause any problem to notifications
sl@0
  1808
@SYMTestActions			
sl@0
  1809
	Autonomous composition
sl@0
  1810
	All elements created are double buffered and opaque:
sl@0
  1811
	Compose an empty scene
sl@0
  1812
	
sl@0
  1813
	A) Create a scene containing a screen sized element A
sl@0
  1814
	Fill buffer 0 of element A with red colour 
sl@0
  1815
	Submit the scene
sl@0
  1816
	Do content update of buffer 0 for available (iAvailable) and display time (iDisplayed)
sl@0
  1817
	Compose the scene, iDisplayed for buffer 0 should complete
sl@0
  1818
	
sl@0
  1819
	Fill buffer 1 of element A with yellow colour
sl@0
  1820
	Do content update of buffer 1 
sl@0
  1821
	Compose the scene, iDisplayed for buffer 1 should complete
sl@0
  1822
	Wait for iAvailable of buffer 0 to complete	
sl@0
  1823
	(iAvailable of buffer 1 will not complete until further content update)	
sl@0
  1824
	
sl@0
  1825
	B) Add a new element B of smaller non fastpathable size behind element A
sl@0
  1826
	Fill buffer 0 of element B with green colour
sl@0
  1827
	Submit the scene
sl@0
  1828
	Do content update of buffer 0 of element B 
sl@0
  1829
	Compose the scene, iDisplayed for buffer 0 of element B should not complete
sl@0
  1830
	iAvailable for buffer 1 of element A should not complete
sl@0
  1831
		
sl@0
  1832
	Fill buffer 1 of element B with blue colour
sl@0
  1833
	Do content update of buffer 1 of element B 
sl@0
  1834
	Wait for iDisplay to complete (possibly with KErrNotVisible)
sl@0
  1835
	Wait for iAvailable for buffer 0 of element B to complete (possibly with KErrNotVisible)
sl@0
  1836
	
sl@0
  1837
	C) Add a new screen size element C in front of A and B
sl@0
  1838
	Fill buffer 0 of element C to be brown
sl@0
  1839
	Do content update of buffer 0 of element C 
sl@0
  1840
	Compose the scene, iDisplayed of buffer 0 of element C should complete
sl@0
  1841
	iAvailable of buffer 1 of element B should not complete
sl@0
  1842
	
sl@0
  1843
	Fill buffer 1 of element C with grey colour
sl@0
  1844
	Do content update of buffer 1 of element C 
sl@0
  1845
	Compose the scene, iDisplayed of buffer 1 of element C should complete
sl@0
  1846
	Wait for iAvailable of buffer 0 of element C to complete
sl@0
  1847
		
sl@0
  1848
	D) Move element A to the front
sl@0
  1849
	Fill buffer 0 of element A with magenta colour
sl@0
  1850
	Do content update of buffer 0 of element A 
sl@0
  1851
	Compose the scene, iDisplayed for buffer 0 of element A should complete
sl@0
  1852
	Wait for iAvailable of buffer 1 of element A to complete
sl@0
  1853
	iAvailable of buffer 1 of element C should not complete
sl@0
  1854
	
sl@0
  1855
	E) Move element B to the front *NOW NOT FASTPATHING*
sl@0
  1856
	Fill buffer 0 of element B with dark red colour
sl@0
  1857
	Do content update of buffer 0 of element B
sl@0
  1858
	Compose the scene, iDisplayed for buffer 0 of element B should complete
sl@0
  1859
	Wait for iAvailable of buffer 1 of element B to complete
sl@0
  1860
	iAvailable of buffer 1 of element C should not complete
sl@0
  1861
	iAvailable of buffer 0 of element A should not complete
sl@0
  1862
		
sl@0
  1863
@SYMTestExpectedResults
sl@0
  1864
	All composition should trigger fastpath 
sl@0
  1865
	Request status checks iAvailable and iDisplayed should be set to KErrNone every time.	
sl@0
  1866
	Screen colour should change in the sequence of red, yellow, brown, grey, magenta
sl@0
  1867
*/
sl@0
  1868
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0010L()
sl@0
  1869
	{
sl@0
  1870
    iTestName = _L("FASTPATH_0010");
sl@0
  1871
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  1872
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  1873
    FastpathNotificationsTestL(ETrue);
sl@0
  1874
	}
sl@0
  1875
sl@0
  1876
/*
sl@0
  1877
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0011
sl@0
  1878
@SYMTestCaseDesc		Positive testing - Fastpath with notification checking for non-autonomous composition
sl@0
  1879
@SYMREQ					
sl@0
  1880
@SYMPREQ						PREQ417-54885
sl@0
  1881
@SYMTestType				Integration Test
sl@0
  1882
@SYMTestPriority		High
sl@0
  1883
@SYMTestPurpose			Check fastpath does not cause any problem to notifications
sl@0
  1884
@SYMTestActions			
sl@0
  1885
	A repeat of GRAPHICS-OPENWFC-FASTPATH-0010 but with non autonomous composition
sl@0
  1886
	
sl@0
  1887
	Where possible TRequestStatuses are additionally checked after submit updates and before
sl@0
  1888
	explicit wfcCompose calls are made.
sl@0
  1889
	
sl@0
  1890
@SYMTestExpectedResults
sl@0
  1891
	Just commit should not trigger any changes to the scene or notifications to complete
sl@0
  1892
	Just content updates should not trigger any changes to the scene or notifications to complete
sl@0
  1893
	Only after Commit, Content update and Force compose should things happen.
sl@0
  1894
	Request status checks iAvailable and iDisplayed should be completed.
sl@0
  1895
	Screen colour should change in the sequence of red, yellow, green, blue, brown and grey
sl@0
  1896
*/
sl@0
  1897
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0011L()
sl@0
  1898
	{
sl@0
  1899
    iTestName = _L("FASTPATH_0011");
sl@0
  1900
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  1901
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  1902
    FastpathNotificationsTestL(EFalse);
sl@0
  1903
	}
sl@0
  1904
sl@0
  1905
//NOTIFICATION TESTS
sl@0
  1906
void COpenwfTest::FastpathDispXNotificationsTestL(TBool aAutonomous)
sl@0
  1907
	{
sl@0
  1908
    SetupEmptySceneL(aAutonomous);
sl@0
  1909
    if (aAutonomous)
sl@0
  1910
        {   //if we have manual pauses the test will complete early
sl@0
  1911
        iAllowManualPause = EFalse;
sl@0
  1912
        }
sl@0
  1913
	
sl@0
  1914
	//Create 2 fastpathable elements
sl@0
  1915
    TSurfaceId surfaceA = iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  1916
                                                iFastpathablePixelFormat,
sl@0
  1917
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1918
sl@0
  1919
    ASSERT_FALSE(surfaceA.IsNull());
sl@0
  1920
    WFCSource sourceA = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceA), NULL);
sl@0
  1921
    TInt err = iUtility->SubmitUpdate(surfaceA, 0, NULL);
sl@0
  1922
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1923
    WFCElement elementA = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1924
    wfcSetElementAttribi(iDevice, elementA, WFC_ELEMENT_SOURCE, sourceA);
sl@0
  1925
    wfcSetElementAttribiv(iDevice, elementA, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  1926
    wfcSetElementAttribiv(iDevice, elementA, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  1927
    
sl@0
  1928
    TSurfaceId surfaceB = iUtility->CreateSurfaceL(TSize(iFastpathableWidth/2,iFastpathableHeight/2),
sl@0
  1929
                                                iFastpathablePixelFormat,
sl@0
  1930
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  1931
    ASSERT_FALSE(surfaceB.IsNull());
sl@0
  1932
    WFCSource sourceB = wfcCreateSourceFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceB), NULL);
sl@0
  1933
    err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1934
    ASSERT_EQUALS(err,KErrNone);
sl@0
  1935
    WFCElement elementB = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  1936
    wfcSetElementAttribi(iDevice, elementB, WFC_ELEMENT_SOURCE, sourceB);
sl@0
  1937
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iHalfSizeRect);
sl@0
  1938
    wfcSetElementAttribiv(iDevice, elementB, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iCenterRect);
sl@0
  1939
	
sl@0
  1940
	//**********STARTING ACTUAL TEST!**********
sl@0
  1941
	//Add A to scene
sl@0
  1942
	wfcInsertElement(iDevice, elementA, WFC_INVALID_HANDLE);
sl@0
  1943
#ifdef BREAKPOINT_FASTPATH
sl@0
  1944
    __BREAKPOINT();
sl@0
  1945
#endif
sl@0
  1946
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  1947
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1948
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1949
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1950
    LOG(("OpenWFTest: Fastpath - now ON"));
sl@0
  1951
	//Set A buffer0 red
sl@0
  1952
	iUtility->FillSurfaceL(surfaceA, 0, KRed);
sl@0
  1953
	err = iUtility->SubmitUpdate(surfaceA, 0, NULL);
sl@0
  1954
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1955
    if(!aAutonomous)
sl@0
  1956
    	{
sl@0
  1957
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1958
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1959
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1960
    	}
sl@0
  1961
    WaitL(iCompositionPause);
sl@0
  1962
    
sl@0
  1963
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1964
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1965
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KRed,iTolerance));
sl@0
  1966
	ReleaseOnScreenStream();
sl@0
  1967
	
sl@0
  1968
	//Add surfaceB to scene infront of surfaceA
sl@0
  1969
	wfcInsertElement(iDevice, elementB, elementA);
sl@0
  1970
#ifdef BREAKPOINT_FASTPATH
sl@0
  1971
    __BREAKPOINT();
sl@0
  1972
#endif
sl@0
  1973
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit"));
sl@0
  1974
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  1975
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1976
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1977
    LOG(("OpenWFTest: Fastpath - now OFF"));
sl@0
  1978
	//Set B buffer0 green
sl@0
  1979
	iUtility->FillSurfaceL(surfaceB, 0, KBlue);
sl@0
  1980
	err = iUtility->SubmitUpdate(surfaceB, 0, NULL);
sl@0
  1981
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1982
    if(!aAutonomous)
sl@0
  1983
    	{
sl@0
  1984
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  1985
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  1986
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  1987
    	}
sl@0
  1988
    WaitL(iCompositionPause);
sl@0
  1989
    
sl@0
  1990
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  1991
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  1992
	//Check blue center of screen
sl@0
  1993
    ASSERT_TRUE(CheckOnScreenStreamRect(iCenterTRect,KBlue,iTolerance));
sl@0
  1994
	//Check red around the borders
sl@0
  1995
	ASSERT_TRUE(CheckOnScreenStreamRect(TRect(0,0,iCenterTRect.iTl.iX,iCenterTRect.iTl.iY),KRed,iTolerance));
sl@0
  1996
	ASSERT_TRUE(CheckOnScreenStreamRect(TRect(iCenterTRect.iBr.iX+1,iCenterTRect.iBr.iY+1,
sl@0
  1997
			iFastpathableWidth,iFastpathableHeight),KRed,iTolerance));
sl@0
  1998
	ReleaseOnScreenStream();
sl@0
  1999
	
sl@0
  2000
	//Set A buffer1 yellow
sl@0
  2001
	iUtility->FillSurfaceL(surfaceA, 1, KYellow);
sl@0
  2002
	//Set B buffer1 KGreen
sl@0
  2003
	iUtility->FillSurfaceL(surfaceB, 1, KGreen);
sl@0
  2004
	
sl@0
  2005
	//Do content updated surfaceA dispXtimes 10
sl@0
  2006
	CActiveNotification* surfAbuff1dispX = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  2007
	CleanupStack::PushL(surfAbuff1dispX);
sl@0
  2008
	iUtility->NotifyWhenDisplayedXTimes(10,surfAbuff1dispX->iStatus);
sl@0
  2009
	err = iUtility->SubmitUpdate(surfaceA, 1, NULL);
sl@0
  2010
	//Do content updated surfaceB dispXtimes 5
sl@0
  2011
	CActiveNotification* surfBbuff1dispX = CActiveNotification::NewL(iUtility->Session(),ETrue);
sl@0
  2012
	CleanupStack::PushL(surfBbuff1dispX);
sl@0
  2013
	iUtility->NotifyWhenDisplayedXTimes(5,surfBbuff1dispX->iStatus);
sl@0
  2014
	err = iUtility->SubmitUpdate(surfaceB, 1, NULL);
sl@0
  2015
	
sl@0
  2016
    if(!aAutonomous)
sl@0
  2017
    	{
sl@0
  2018
		for(TInt i=0;i<4;i++)
sl@0
  2019
			{
sl@0
  2020
			wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  2021
		    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2022
		    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2023
		    WaitL(iCompositionPause);
sl@0
  2024
			//Check A has not completed yet
sl@0
  2025
			ASSERT_EQUALS(surfAbuff1dispX->iStatus.Int(),KRequestPending);
sl@0
  2026
			//Check B has not completed yet
sl@0
  2027
			ASSERT_EQUALS(surfBbuff1dispX->iStatus.Int(),KRequestPending);
sl@0
  2028
			}
sl@0
  2029
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  2030
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2031
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2032
    	}
sl@0
  2033
	//surfBbuff1dispX should complete, and its RunL will stop the scheduler
sl@0
  2034
    CActiveScheduler::Start();
sl@0
  2035
	//Check B has completed
sl@0
  2036
    ASSERT_EQUALS(surfBbuff1dispX->iStatus.Int(),KErrNone);
sl@0
  2037
	//Check A has not completed yet
sl@0
  2038
	ASSERT_EQUALS(surfAbuff1dispX->iStatus.Int(),KRequestPending);
sl@0
  2039
	
sl@0
  2040
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  2041
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  2042
	//Check green center of screen
sl@0
  2043
    ASSERT_TRUE(CheckOnScreenStreamRect(iCenterTRect,KGreen,iTolerance));
sl@0
  2044
	//Check yellow around the borders
sl@0
  2045
	ASSERT_TRUE(CheckOnScreenStreamRect(TRect(0,0,iCenterTRect.iTl.iX,iCenterTRect.iTl.iY),KYellow,iTolerance));
sl@0
  2046
	ASSERT_TRUE(CheckOnScreenStreamRect(TRect(iCenterTRect.iBr.iX+1,iCenterTRect.iBr.iY+1,
sl@0
  2047
			iFastpathableWidth,iFastpathableHeight),KYellow,iTolerance));
sl@0
  2048
	ReleaseOnScreenStream();
sl@0
  2049
	
sl@0
  2050
    //check it hasn't completed unexpectedly early while using on screen stream
sl@0
  2051
    ASSERT_EQUALS(surfAbuff1dispX->iStatus.Int(),KRequestPending);
sl@0
  2052
    
sl@0
  2053
	//Remove surfaceB from the scene
sl@0
  2054
	wfcRemoveElement(iDevice, elementB);
sl@0
  2055
#ifdef BREAKPOINT_FASTPATH
sl@0
  2056
    __BREAKPOINT();
sl@0
  2057
#endif
sl@0
  2058
    LOG(("OpenWFTest: Expecting FASTPATH after next commit"));
sl@0
  2059
	wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  2060
    if(!aAutonomous)
sl@0
  2061
    	{
sl@0
  2062
		for(TInt i=0;i<4;i++)
sl@0
  2063
			{
sl@0
  2064
			wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  2065
		    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2066
		    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2067
		    LOG(("OpenWFTest: Fastpath - now ON"));
sl@0
  2068
		    WaitL(iCompositionPause);
sl@0
  2069
			//Check A has not completed yet
sl@0
  2070
			ASSERT_EQUALS(surfAbuff1dispX->iStatus.Int(),KRequestPending);
sl@0
  2071
			}
sl@0
  2072
		wfcCompose(iDevice, iContext, WFC_TRUE);
sl@0
  2073
    	}
sl@0
  2074
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2075
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2076
sl@0
  2077
	//surfAbuff1dispX should complete, and its RunL will stop the scheduler
sl@0
  2078
    CActiveScheduler::Start();
sl@0
  2079
    ASSERT_EQUALS(surfAbuff1dispX->iStatus.Int(),KErrNone);
sl@0
  2080
sl@0
  2081
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  2082
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  2083
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KYellow,iTolerance));
sl@0
  2084
	ReleaseOnScreenStream();
sl@0
  2085
	
sl@0
  2086
	ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  2087
	//Shutdown
sl@0
  2088
    wfcDestroySource(iDevice, sourceA);
sl@0
  2089
    wfcDestroySource(iDevice, sourceB);
sl@0
  2090
    
sl@0
  2091
	CleanupStack::PopAndDestroy(2,surfAbuff1dispX);
sl@0
  2092
	}
sl@0
  2093
sl@0
  2094
/*
sl@0
  2095
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0012
sl@0
  2096
@SYMTestCaseDesc		Positive testing - Fastpath with notification checking DisplayXTime
sl@0
  2097
@SYMREQ					
sl@0
  2098
@SYMPREQ						PREQ417-54885
sl@0
  2099
@SYMTestType				Integration Test
sl@0
  2100
@SYMTestPriority		High
sl@0
  2101
@SYMTestPurpose			Check fastpath does not cause any problem to notifications
sl@0
  2102
@SYMTestActions			
sl@0
  2103
	All compositions are autonomous:
sl@0
  2104
	Compose an empty scene
sl@0
  2105
	A) Create a scene containing a screen sized opaque element A
sl@0
  2106
	Commit the scene
sl@0
  2107
	Make a content update for available (iAvailable) and display time (aDisplayed)
sl@0
  2108
	Wait for the request status objects to complete
sl@0
  2109
	
sl@0
  2110
	B) Add a small element B in front of A
sl@0
  2111
	Compose the scene
sl@0
  2112
	Content update for both A and B, set display 10 times to A, set display 5 times to B 
sl@0
  2113
	Wait for the 5 times
sl@0
  2114
	
sl@0
  2115
	C) Remove element B
sl@0
  2116
	Commit the scene
sl@0
  2117
	Compose the scene
sl@0
  2118
	Wait for the 10 times
sl@0
  2119
@SYMTestExpectedResults
sl@0
  2120
	Composition should fastpath in sections A and C
sl@0
  2121
	Elements A's 10 times should not complete before element B's 5 times
sl@0
  2122
*/
sl@0
  2123
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0012L()
sl@0
  2124
	{
sl@0
  2125
    iTestName = _L("FASTPATH_0012");
sl@0
  2126
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2127
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2128
	FastpathDispXNotificationsTestL(ETrue);
sl@0
  2129
	}
sl@0
  2130
sl@0
  2131
/*
sl@0
  2132
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0013
sl@0
  2133
@SYMTestCaseDesc		Positive testing - Fastpath with notification checking DisplayXTime
sl@0
  2134
@SYMREQ					
sl@0
  2135
@SYMPREQ						PREQ417-54885
sl@0
  2136
@SYMTestType				Integration Test
sl@0
  2137
@SYMTestPriority		High
sl@0
  2138
@SYMTestPurpose			Check fastpath does not cause any problem to notifications
sl@0
  2139
@SYMTestActions			
sl@0
  2140
	Repeats GRAPHICS-OPENWFC-FASTPATH-0013 in non autonomous mode.
sl@0
  2141
	This allows gives the added benefit of accurate counting of wfcCompose calls, checking the displayXtimes
sl@0
  2142
	notifications only complete after the correct number of composes.
sl@0
  2143
@SYMTestExpectedResults
sl@0
  2144
	Composition should fastpath in sections A and C
sl@0
  2145
	Both should complete after their expect amount of compose calls with no errors
sl@0
  2146
*/
sl@0
  2147
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0013L()
sl@0
  2148
	{
sl@0
  2149
    iTestName = _L("FASTPATH_0013");
sl@0
  2150
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2151
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2152
    FastpathDispXNotificationsTestL(EFalse);
sl@0
  2153
	}
sl@0
  2154
sl@0
  2155
/*
sl@0
  2156
 *	NEGATIVE TESTING
sl@0
  2157
 * */
sl@0
  2158
/*
sl@0
  2159
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0020
sl@0
  2160
@SYMTestCaseDesc		Negative testing - Fastpath one-element scene
sl@0
  2161
@SYMREQ					
sl@0
  2162
@SYMPREQ						PREQ417-54885
sl@0
  2163
@SYMTestType				Unit Test
sl@0
  2164
@SYMTestPriority		High
sl@0
  2165
@SYMTestPurpose			Check a scene including a full screen element with source alpha cannot be fastpathed
sl@0
  2166
@SYMTestActions			
sl@0
  2167
	All compositions are autonomous:
sl@0
  2168
	Create a scene containing a screen sized element 
sl@0
  2169
	Enable WFC_TRANSPARENCY_SOURCE  
sl@0
  2170
	Set the value of WFC_ELEMENT_SOURCE between 0 and 255 (non-inclusive).
sl@0
  2171
	Compose the scene
sl@0
  2172
@SYMTestExpectedResults
sl@0
  2173
	The scene cannot be fastpathed.
sl@0
  2174
*/
sl@0
  2175
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0020L()
sl@0
  2176
	{
sl@0
  2177
    iTestName = _L("FASTPATH_0020");
sl@0
  2178
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2179
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2180
    SetupEmptySceneL();
sl@0
  2181
    
sl@0
  2182
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  2183
												EUidPixelFormatARGB_8888,
sl@0
  2184
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  2185
    ASSERT_FALSE(surface.IsNull());
sl@0
  2186
sl@0
  2187
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  2188
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2189
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2190
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  2191
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
  2192
    
sl@0
  2193
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  2194
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  2195
    //set per pixel alpha
sl@0
  2196
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_SOURCE);
sl@0
  2197
    
sl@0
  2198
#ifdef BREAKPOINT_FASTPATH
sl@0
  2199
    __BREAKPOINT();
sl@0
  2200
#endif
sl@0
  2201
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  2202
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit - using source alpha"));
sl@0
  2203
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  2204
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2205
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2206
    
sl@0
  2207
    for (TInt i=0;i<=256;i+=64)
sl@0
  2208
    	{
sl@0
  2209
		i=(i==256)?255:i;
sl@0
  2210
		iUtility->FillSurfaceL(surface, 0, TRgb(0,255,0,i));
sl@0
  2211
		err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2212
		ASSERT_EQUALS(err,KErrNone);
sl@0
  2213
		WaitL(iCompositionPause);
sl@0
  2214
    	}
sl@0
  2215
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  2216
    wfcDestroySource(iDevice, fpSource);  
sl@0
  2217
	}
sl@0
  2218
sl@0
  2219
/*
sl@0
  2220
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0021
sl@0
  2221
@SYMTestCaseDesc		Negative testing - Fastpath one-element scene
sl@0
  2222
@SYMREQ					
sl@0
  2223
@SYMPREQ						PREQ417-54885
sl@0
  2224
@SYMTestType				Unit Test
sl@0
  2225
@SYMTestPriority		High	
sl@0
  2226
@SYMTestPurpose			Check a scene including a full screen element with global alpha cannot be fastpathed
sl@0
  2227
@SYMTestActions			
sl@0
  2228
	All compositions are autonomous:
sl@0
  2229
	Create a scene containing a screen sized element 
sl@0
  2230
	Enable WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA
sl@0
  2231
	Set the value of WFC_ELEMENT_GLOBAL_ALPHA between 0 and 255 (non-inclusive)
sl@0
  2232
	Compose the scene
sl@0
  2233
@SYMTestExpectedResults
sl@0
  2234
	The scene cannot be fastpathed.
sl@0
  2235
*/
sl@0
  2236
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0021L()
sl@0
  2237
	{
sl@0
  2238
    iTestName = _L("FASTPATH_0021");
sl@0
  2239
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2240
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2241
    SetupEmptySceneL();
sl@0
  2242
    
sl@0
  2243
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  2244
												EUidPixelFormatXRGB_8888,
sl@0
  2245
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  2246
    ASSERT_FALSE(surface.IsNull());
sl@0
  2247
sl@0
  2248
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  2249
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2250
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2251
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  2252
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
  2253
    
sl@0
  2254
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  2255
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  2256
    //set element global alpha
sl@0
  2257
	wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA);
sl@0
  2258
	wfcSetElementAttribf(iDevice, fpElement, WFC_ELEMENT_GLOBAL_ALPHA, 0.0f);
sl@0
  2259
	
sl@0
  2260
#ifdef BREAKPOINT_FASTPATH
sl@0
  2261
    __BREAKPOINT();
sl@0
  2262
#endif
sl@0
  2263
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  2264
	iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  2265
	err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2266
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit - using element global alpha not fully opaque"));
sl@0
  2267
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  2268
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2269
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2270
    
sl@0
  2271
    for (TInt i=0;i<=256;i+=64)
sl@0
  2272
    	{
sl@0
  2273
		i=(i==256)?255:i;
sl@0
  2274
		wfcSetElementAttribf(iDevice, fpElement, WFC_ELEMENT_GLOBAL_ALPHA, (TReal32)i/255);
sl@0
  2275
		if(i == 255)
sl@0
  2276
			{
sl@0
  2277
#ifdef BREAKPOINT_FASTPATH
sl@0
  2278
			__BREAKPOINT();
sl@0
  2279
#endif
sl@0
  2280
			}
sl@0
  2281
        if(i == 255)
sl@0
  2282
            {
sl@0
  2283
            LOG(("OpenWFTest: Expecting FASTPATH after next commit - using element global alpha fully opaque"));
sl@0
  2284
            }
sl@0
  2285
        else
sl@0
  2286
            {
sl@0
  2287
            LOG(("OpenWFTest: Expecting COMPOSITION after next commit - using element global alpha not fully opaque"));
sl@0
  2288
            }
sl@0
  2289
	    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  2290
	    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2291
	    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2292
		WaitL(iCompositionPause);
sl@0
  2293
    	}
sl@0
  2294
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  2295
    wfcDestroySource(iDevice, fpSource);  
sl@0
  2296
	}
sl@0
  2297
sl@0
  2298
/*
sl@0
  2299
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0022
sl@0
  2300
@SYMTestCaseDesc		Negative testing - Fastpath one-element scene
sl@0
  2301
@SYMREQ					
sl@0
  2302
@SYMPREQ						PREQ417-54885
sl@0
  2303
@SYMTestType				Unit Test
sl@0
  2304
@SYMTestPriority		High	
sl@0
  2305
@SYMTestPurpose			Check a scene with RGB 565 format cannot be fastpathed
sl@0
  2306
@SYMTestActions			
sl@0
  2307
	Create a scene containing a screen sized element with an unsupported source format, such as 565
sl@0
  2308
	Compose the scene
sl@0
  2309
@SYMTestExpectedResults
sl@0
  2310
	The scene cannot be fastpathed.	
sl@0
  2311
*/
sl@0
  2312
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0022L()
sl@0
  2313
	{
sl@0
  2314
    iTestName = _L("FASTPATH_0022");
sl@0
  2315
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2316
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2317
    SetupEmptySceneL();
sl@0
  2318
    
sl@0
  2319
    //NON fastpathable pixel format
sl@0
  2320
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  2321
												iNonFastpathablePixelFormat,
sl@0
  2322
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  2323
    ASSERT_FALSE(surface.IsNull());
sl@0
  2324
sl@0
  2325
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  2326
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2327
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2328
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  2329
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
  2330
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  2331
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  2332
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  2333
    
sl@0
  2334
#ifdef BREAKPOINT_FASTPATH
sl@0
  2335
    __BREAKPOINT();
sl@0
  2336
#endif
sl@0
  2337
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit - using non fastpathable pixel format"));
sl@0
  2338
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  2339
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2340
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2341
    
sl@0
  2342
    iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  2343
    err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2344
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2345
    WaitL(iCompositionPause);
sl@0
  2346
    
sl@0
  2347
    ASSERT_TRUE(AcquireOnScreenStream());
sl@0
  2348
    ASSERT_TRUE(CheckOnScreenReferenceImage());
sl@0
  2349
	ASSERT_TRUE(CheckOnScreenStreamRect(iFullScreenTRect,KGreen,iTolerance));
sl@0
  2350
	ReleaseOnScreenStream();
sl@0
  2351
sl@0
  2352
	ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  2353
    wfcDestroySource(iDevice, fpSource);  
sl@0
  2354
	}
sl@0
  2355
sl@0
  2356
/*
sl@0
  2357
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0023
sl@0
  2358
@SYMTestCaseDesc		Negative testing - Fastpath one-element scene
sl@0
  2359
@SYMREQ					
sl@0
  2360
@SYMPREQ						PREQ417-54885
sl@0
  2361
@SYMTestType				Unit Test
sl@0
  2362
@SYMTestPriority		High
sl@0
  2363
@SYMTestPurpose			Check a scene with mask settings cannot be fastpathed
sl@0
  2364
@SYMTestActions			
sl@0
  2365
	All compositions are autonomous:
sl@0
  2366
	Create a scene containing a screen sized element A
sl@0
  2367
	Enable WFC_TRANSPARENCY_MASK
sl@0
  2368
	Set a value to WFC_ELEMENT_MASK
sl@0
  2369
	Create a mask element, set the size to be the same as element A's desitnation rectangle 
sl@0
  2370
	Compose the scene
sl@0
  2371
@SYMTestExpectedResults
sl@0
  2372
	The scene cannot be fastpathed.
sl@0
  2373
*/
sl@0
  2374
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0023L()
sl@0
  2375
	{
sl@0
  2376
    iTestName = _L("FASTPATH_0023");
sl@0
  2377
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2378
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2379
    SetupEmptySceneL();
sl@0
  2380
sl@0
  2381
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  2382
												iFastpathablePixelFormat,
sl@0
  2383
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  2384
    ASSERT_FALSE(surface.IsNull());
sl@0
  2385
sl@0
  2386
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  2387
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2388
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2389
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  2390
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
  2391
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  2392
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  2393
    
sl@0
  2394
    TSurfaceId surfaceMask = iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  2395
                                                iFastpathablePixelFormat,
sl@0
  2396
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  2397
    ASSERT_FALSE(surfaceMask.IsNull());
sl@0
  2398
    WFCMask mask = wfcCreateMaskFromStream(iDevice, iContext, reinterpret_cast<WFCNativeStreamType>(&surfaceMask), NULL);
sl@0
  2399
    err = iUtility->SubmitUpdate(surfaceMask, 0, NULL);
sl@0
  2400
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2401
    
sl@0
  2402
    //set the mask to fpElement
sl@0
  2403
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_TRANSPARENCY_TYPES, WFC_TRANSPARENCY_MASK);
sl@0
  2404
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_MASK, mask);
sl@0
  2405
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  2406
    
sl@0
  2407
#ifdef BREAKPOINT_FASTPATH
sl@0
  2408
    __BREAKPOINT();
sl@0
  2409
#endif
sl@0
  2410
    wfcInsertElement(iDevice, fpElement, WFC_INVALID_HANDLE);
sl@0
  2411
    LOG(("OpenWFTest: Expecting COMPOSITION after next commit - using a mask"));
sl@0
  2412
    wfcCommit(iDevice, iContext, WFC_TRUE);
sl@0
  2413
    wfcFence(iDevice, iContext, iEGLDisplay, iSync);
sl@0
  2414
    ASSERT_EQUALS(eglClientWaitSyncKHR(iEGLDisplay,iSync,0,(EGLTimeKHR)EGL_FOREVER_KHR),EGL_CONDITION_SATISFIED_KHR);
sl@0
  2415
    LOG(("OpenWFTest:Fastpath - still off - using a mask"));
sl@0
  2416
    
sl@0
  2417
    iUtility->FillSurfaceL(surface, 0, KGreen);
sl@0
  2418
    err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2419
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2420
    iUtility->FillSurfaceL(surfaceMask, 0, KBlack);
sl@0
  2421
    err = iUtility->SubmitUpdate(surfaceMask, 0, NULL);
sl@0
  2422
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2423
    WaitL(iCompositionPause);	
sl@0
  2424
 
sl@0
  2425
    ASSERT_EQUALS(wfcGetError(iDevice),WFC_ERROR_NONE);
sl@0
  2426
    wfcDestroySource(iDevice, fpSource);
sl@0
  2427
	}
sl@0
  2428
sl@0
  2429
/*
sl@0
  2430
@SYMTestCaseID			GRAPHICS-OPENWFC-FASTPATH-0024
sl@0
  2431
@SYMTestCaseDesc		Negative testing - Fastpath one-element scene
sl@0
  2432
@SYMREQ					
sl@0
  2433
@SYMPREQ						PREQ417-54885
sl@0
  2434
@SYMTestType				Unit Test
sl@0
  2435
@SYMTestPriority		High
sl@0
  2436
@SYMTestPurpose			Check a scene with alpha and mask settings cannot be fastpathed
sl@0
  2437
@SYMTestActions			
sl@0
  2438
	All compositions are autonomous:
sl@0
  2439
	Create a scene containing a screen sized element A
sl@0
  2440
	Enable WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA
sl@0
  2441
	Set the value of WFC_ELEMENT_GLOBAL_ALPHA to be 255 
sl@0
  2442
	Enable WFC_TRANSPARENCY_MASK
sl@0
  2443
	Set a value to WFC_ELEMENT_MASK 	
sl@0
  2444
	Create a mask element, set it the same size of element A's destination rectangle
sl@0
  2445
	Compose the scene
sl@0
  2446
@SYMTestExpectedResults
sl@0
  2447
	The scene cannot be fastpathed.
sl@0
  2448
*/
sl@0
  2449
void COpenwfTest::GRAPHICS_OPENWFC_FASTPATH_0024L()
sl@0
  2450
	{
sl@0
  2451
    iTestName = _L("FASTPATH_0024");
sl@0
  2452
    INFO_PRINTF2(_L("GRAPHICS_OPENWFC_%SL()"),&iTestName);
sl@0
  2453
    LOGL((_L("OpenWFTest: GRAPHICS_OPENWFC_%SL()"),&iTestName));
sl@0
  2454
    SetupEmptySceneL();
sl@0
  2455
sl@0
  2456
    TSurfaceId surface=iUtility->CreateSurfaceL(TSize(iFastpathableWidth,iFastpathableHeight),
sl@0
  2457
												iFastpathablePixelFormat,
sl@0
  2458
                                                iStride, iContiguous, iMaxBuffers);
sl@0
  2459
    ASSERT_FALSE(surface.IsNull());
sl@0
  2460
sl@0
  2461
    WFCSource fpSource = wfcCreateSourceFromStream(iDevice, iContext,reinterpret_cast<WFCNativeStreamType>(&surface), NULL);
sl@0
  2462
    TInt err = iUtility->SubmitUpdate(surface, 0, NULL);
sl@0
  2463
    ASSERT_EQUALS(err,KErrNone);
sl@0
  2464
    WFCElement fpElement = wfcCreateElement(iDevice, iContext, NULL);
sl@0
  2465
    wfcSetElementAttribi(iDevice, fpElement, WFC_ELEMENT_SOURCE, fpSource);
sl@0
  2466
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_SOURCE_RECTANGLE, 4, iFullScreenRect);
sl@0
  2467
    wfcSetElementAttribiv(iDevice, fpElement, WFC_ELEMENT_DESTINATION_RECTANGLE, 4, iFullScreenRect);
sl@0
  2468
    
sl@0
  2469
    TSurfaceId surfaceMask = iUtility->CreateS