1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltest_stress_sgimage.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,637 @@
1.4 +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 +*/
1.23 +
1.24 +#include <s32file.h>
1.25 +#include <test/t_simload.h>
1.26 +#include <test/tefunit.h> //ASSERT_TRUE
1.27 +#include "egltest_stress_sgimage.h"
1.28 +
1.29 +TVerdict CEglTest_Stress::doTestStepL()
1.30 + {
1.31 + INFO_PRINTF1(_L("CEglTest_Stress:doTestStepL()"));
1.32 +
1.33 + TBuf<100> testCaseId;
1.34 + TestCaseName(testCaseId);
1.35 + SetTestStepID(testCaseId);
1.36 +
1.37 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.38 + __UHEAP_MARK;
1.39 +
1.40 + //File server is used to generate simload ini file
1.41 + User::LeaveIfError(iFs.Connect());
1.42 +
1.43 + TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KVG_KHR_EGL_image | KEGL_KHR_image_pixmap);
1.44 + if(!ret)
1.45 + {
1.46 + // The extension is not supported
1.47 + RecordTestResultL();
1.48 + CloseTMSGraphicsStep();
1.49 + return TestStepResult();
1.50 + }
1.51 +
1.52 + //Create a config file and launch the simulated load app
1.53 + ReadIniValuesL();
1.54 + PrintConfigDataL();
1.55 + CreateSimLoadAppL();
1.56 +
1.57 + INFO_PRINTF1(_L("Creating a Semaphore to signal all child processes at once"));
1.58 + RSemaphore sem;
1.59 + User::LeaveIfError(sem.CreateGlobal(KEglStressTest(), iNumberChildProcesses));
1.60 + CleanupClosePushL(sem);
1.61 +
1.62 + //Information to be passed to the child process
1.63 + TSgImageInfo info;
1.64 + TSize size(iRSgImageWidth, iRSgImageHeight);
1.65 + info.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
1.66 + info.iPixelFormat = iFormat;
1.67 + info.iSizeInPixels = size;
1.68 +
1.69 + //Utilise egl helper functions
1.70 + CreateEglSessionL();
1.71 +
1.72 + //Create a display and initialise it
1.73 + GetDisplayL();
1.74 + iEglSess->InitializeL();
1.75 +
1.76 + //Open RSGImage driver
1.77 + iEglSess->OpenSgDriverL();
1.78 +
1.79 + EGL_LEAVE_ERROR(eglBindAPI(EGL_OPENVG_API));
1.80 +
1.81 + EGLContext context;
1.82 + for(TInt i=0; i<iNumberRSgImages; i++)
1.83 + {
1.84 + RSgImage image;
1.85 + iSgImageArray.InsertL(image, i);
1.86 + User::LeaveIfError(iSgImageArray[i].Create(info, NULL, NULL));
1.87 +
1.88 + EGLConfig config;
1.89 + if(i == 0)
1.90 + {
1.91 + //Only need to determine a matching configuration once
1.92 + ChooseConfigAndCreateContextL(iDisplay, context, config, iSgImageArray[i], KStressTestMainAppPanic, iAlphaPre);
1.93 + }
1.94 +
1.95 + EGLSurface surface = EGL_NO_SURFACE; //remove arm warning
1.96 + EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(iDisplay, config, iSgImageArray[i], iAlphaPre));
1.97 +
1.98 + EGL_LEAVE_ERROR(eglMakeCurrent(iDisplay, surface, surface, context));
1.99 +
1.100 + PaintSurfaceL(iDisplay, surface, context);
1.101 + EGL_LEAVE_ERROR(eglSwapBuffers(iDisplay, surface));
1.102 +
1.103 + if(iTestType == EStressVGImage)
1.104 + {
1.105 + EGL_LEAVE_ERROR(eglMakeCurrent(iDisplay, surface, surface, context));
1.106 +
1.107 + EGLImageKHR eglImage = 0; //removes arm compiler warning
1.108 + VGImage vgImage;
1.109 +
1.110 + EGL_LEAVE_NULL(eglImage, iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &iSgImageArray[i], (int*)KEglImageAttribsPreservedTrue));
1.111 + EGL_LEAVE_NULL(vgImage, iEglSess->vgCreateImageTargetKHR(eglImage));
1.112 +
1.113 + //Close the EGLImage
1.114 + EGL_LEAVE_ERROR(iEglSess->DestroyEGLImage(iDisplay, eglImage));
1.115 +
1.116 + User::LeaveIfError(iVGImageArray.Insert(vgImage, i));
1.117 + }
1.118 +
1.119 + User::LeaveIfError(iSurfaceArray.Insert(surface, i));
1.120 + }
1.121 +
1.122 + /* Create and install the active scheduler */
1.123 + CActiveScheduler* sched = new(ELeave) CActiveScheduler;
1.124 + CActiveScheduler::Install(sched);
1.125 + CleanupStack::PushL(sched);
1.126 +
1.127 + TInt exitCounter = iNumberMainImages;
1.128 + TBool testResult = ETrue;
1.129 +
1.130 + //Create an active object for each RSgImage accessed in the main process
1.131 + CTReadWriteMain* painter = 0;
1.132 + for(TInt i=0; i<iNumberMainImages; i++)
1.133 + {
1.134 + if(iTestType == EStressVGImage)
1.135 + {
1.136 + painter = CTReadWriteMain::NewL(iDisplay, iSurfaceArray[i], context, iRSgImageWidth, iRSgImageHeight, iByteSize, iVgFormat, testResult, exitCounter, iTestType, iVGImageArray[i]);
1.137 + }
1.138 + else
1.139 + {
1.140 + painter = CTReadWriteMain::NewL(iDisplay, iSurfaceArray[i], context, iRSgImageWidth, iRSgImageHeight, iByteSize, iVgFormat, testResult, exitCounter, iTestType);
1.141 + }
1.142 +
1.143 + CleanupStack::PushL(painter);
1.144 + painter->After(TTimeIntervalMicroSeconds32(0));
1.145 + }
1.146 +
1.147 + CreateChildProcessesL();
1.148 +
1.149 + INFO_PRINTF1(_L("Signaling all child processes at once - starts data access in the child processes"));
1.150 + sem.Signal(iNumberChildProcesses);
1.151 +
1.152 + //Start the active scheduler - starts data access in the main process
1.153 + sched->Start();
1.154 +
1.155 + if(testResult == EFalse)
1.156 + {
1.157 + if (iTestType == EStressReadWriteSingleImage || iTestType == EStressReadWriteMultiImage)
1.158 + {
1.159 + // For GRAPHICS-EGL-0428 and GRAPHICS-EGL-0437 data integrity cannot be guaranteed on
1.160 + // all implementations, so the pixel value checking aspects of these tests are regarded as optional
1.161 + WARN_PRINTF1(_L("Unexpected pixel colour"));
1.162 + }
1.163 + else
1.164 + {
1.165 + ERR_PRINTF1(_L("Unexpected pixel colour"));
1.166 + SetTestStepResult(EFail);
1.167 + }
1.168 + }
1.169 +
1.170 + //Check that each child process has completed without error
1.171 + for(TInt i=0; i<iNumberChildProcesses; i++)
1.172 + {
1.173 + TRequestStatus status;
1.174 + iProcessArray[i].Logon(status);
1.175 + User::WaitForRequest(status);
1.176 +
1.177 + if(status != KErrNone)
1.178 + {
1.179 + if (status == KTestStressUnexpectedPixelError && (iTestType == EStressReadWriteSingleImage || iTestType == EStressReadWriteMultiImage))
1.180 + {
1.181 + // For GRAPHICS-EGL-0428 and GRAPHICS-EGL-0437 data integrity cannot be guaranteed on
1.182 + // all implementations, so the pixel value checking aspects of these tests are regarded as optional
1.183 + // So check that if it fails, it fails for the expected reason of no matching pixel.
1.184 + WARN_PRINTF2(_L("Child Process completed with code %d, expected KErrNone"), status.Int());
1.185 + }
1.186 + else
1.187 + {
1.188 + ERR_PRINTF2(_L("Child Process completed with code %d, expected KErrNone"), status.Int());
1.189 + SetTestStepResult(EFail);
1.190 + }
1.191 + }
1.192 + }
1.193 +
1.194 + DestroySimLoadProcess();
1.195 + DeleteConfigData();
1.196 + ClearDownArraysL(iDisplay);
1.197 + EGL_LEAVE_ERROR(eglDestroyContext(iDisplay, context));
1.198 +
1.199 + CleanupStack::PopAndDestroy(iNumberMainImages + 2, &sem); //(iNumberMainImages + 1) active objects, sched, sem
1.200 + iEglSess->CloseSgDriver();
1.201 +
1.202 + CleanAll();
1.203 + iFs.Close();
1.204 +
1.205 + __UHEAP_MARKEND;
1.206 +
1.207 +#else
1.208 + INFO_PRINTF2(_L("%S can only be run with SgImage-Lite"), &testCaseId);
1.209 +#endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.210 +
1.211 + //Comply with the terrific TMS
1.212 + RecordTestResultL();
1.213 + CloseTMSGraphicsStep();
1.214 +
1.215 + return TestStepResult();
1.216 + }
1.217 +
1.218 +CEglTest_Stress::~CEglTest_Stress()
1.219 + {
1.220 + //Free memory and close handles in case of panic in the doTestStepL()
1.221 + delete iEglSess;
1.222 +
1.223 + iFs.Close();
1.224 + iSurfaceArray.Close();
1.225 + iProcessArray.Close();
1.226 + iSgImageArray.Close();
1.227 + iVGImageArray.Close();
1.228 + }
1.229 +
1.230 +void CEglTest_Stress::PaintSurfaceL(EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext)
1.231 + {
1.232 + //Clear surface background, format of the constant is ARGB
1.233 + //Match the colour to that of the defined constant
1.234 + VGfloat red = 0.0;
1.235 + VGfloat green = 0.0;
1.236 + VGfloat blue = 0.0;
1.237 + VGfloat alpha = 0.0;
1.238 +
1.239 + //Care taken to avoid fixed width -> floating point -> fixed width rounding errors
1.240 + if(iByteSize == 4)
1.241 + {
1.242 + red = 1.0 * ((KColourInitial32 & 0x00FF0000) >> 16)/255;
1.243 + green = 1.0 * ((KColourInitial32 & 0x0000FF00) >> 8)/255;
1.244 + blue = 1.0 * (KColourInitial32 & 0x000000FF)/255;
1.245 + alpha = 1.0 * ((KColourInitial32 & 0xFF000000) >> 24)/255;
1.246 + }
1.247 + else //iByteSize == 2
1.248 + {
1.249 + red = 1.0 * ((KColourInitial16 & 0x7C00) >> 11)/31;
1.250 + green = 1.0 * ((KColourInitial16 & 0x0480) >> 5)/63;
1.251 + blue = 1.0 * (KColourInitial16 & 0x001F)/31;
1.252 + }
1.253 +
1.254 + //Format of the constant is RGBA (32 bit)
1.255 + VGfloat bgColor[] = {red, green, blue, alpha};
1.256 +
1.257 + EGL_LEAVE_ERROR(eglMakeCurrent(aDisplay, aSurface, aSurface, aContext));
1.258 +
1.259 + vgSetfv(VG_CLEAR_COLOR, 4, bgColor);
1.260 + ASSERT_VG_TRUE(vgGetError() == VG_NO_ERROR);
1.261 + vgClear(0, 0, iRSgImageWidth, iRSgImageHeight);
1.262 + ASSERT_VG_TRUE(vgGetError() == VG_NO_ERROR);
1.263 + }
1.264 +
1.265 +void CEglTest_Stress::CreateChildProcessL(TInt aProcessNumber, TTestType aTestType, TSgDrawableId aDrawableId)
1.266 + {
1.267 + TRequestStatus status;
1.268 + RProcess client;
1.269 + User::LeaveIfError(client.Create(KStressTestClientApp, KNullDesC));
1.270 +
1.271 + //Pass image and test information to the child process
1.272 + TStressProcessInfo info;
1.273 + info.iTestType = aTestType;
1.274 + info.iSgId = aDrawableId;
1.275 + info.iByteSize = iByteSize;
1.276 + info.iAlphaPre = iAlphaPre;
1.277 +
1.278 + TPckg<TStressProcessInfo> pckgInfo(info);
1.279 + User::LeaveIfError((client.SetParameter(KMultiProcessSlot, pckgInfo)));
1.280 +
1.281 + client.Rendezvous(status);
1.282 + client.Resume();
1.283 + User::WaitForRequest(status);
1.284 + TEST(status == KErrNone);
1.285 +
1.286 + //Store image handle for cleanup
1.287 + iProcessArray.InsertL(client, aProcessNumber);
1.288 + }
1.289 +
1.290 +void CEglTest_Stress::CreateChildProcessesL()
1.291 + {
1.292 + for(TInt i=0; i<iNumberChildProcesses; i++)
1.293 + {
1.294 + switch(iTestType)
1.295 + {
1.296 + case EStressReadWriteMultiImage:
1.297 + case EStressPixmapSurface:
1.298 + {
1.299 + //Each child process accesses one SgImage
1.300 + CreateChildProcessL(i, iTestType, iSgImageArray[i].Id());
1.301 + break;
1.302 + }
1.303 + case EStressRead:
1.304 + case EStressReadWriteSingleImage:
1.305 + case EStressVGImage:
1.306 + {
1.307 + //All child processes access the same SgImage
1.308 + CreateChildProcessL(i, iTestType, iSgImageArray[0].Id());
1.309 + break;
1.310 + }
1.311 + default:
1.312 + User::Panic(KStressTestMainAppPanic, KErrNotFound);
1.313 + break;
1.314 + }
1.315 + }
1.316 + }
1.317 +
1.318 +void CEglTest_Stress::ClearDownArraysL(EGLDisplay aDisplay)
1.319 + {
1.320 + for(TInt i=0; i<iSurfaceArray.Count(); i++)
1.321 + {
1.322 + ASSERT_EGL_TRUE(eglDestroySurface(aDisplay, iSurfaceArray[i]));
1.323 + }
1.324 +
1.325 + for(TInt i=0; i<iVGImageArray.Count(); i++)
1.326 + {
1.327 + vgDestroyImage(iVGImageArray[i]);
1.328 + ASSERT_VG_TRUE(vgGetError() == VG_NO_ERROR);
1.329 + }
1.330 +
1.331 + for(TInt i=0; i<iProcessArray.Count(); i++)
1.332 + {
1.333 + iProcessArray[i].Close();
1.334 + }
1.335 +
1.336 + for(TInt i=0; i<iSgImageArray.Count(); i++)
1.337 + {
1.338 + iSgImageArray[i].Close();
1.339 + }
1.340 +
1.341 + iSurfaceArray.Close();
1.342 + iProcessArray.Close();
1.343 + iSgImageArray.Close();
1.344 + iVGImageArray.Close();
1.345 + }
1.346 +
1.347 +void CEglTest_Stress::CreateSimLoadAppL()
1.348 + {
1.349 + TInt index = 1;
1.350 + TBuf<100> tempStore;
1.351 +
1.352 + //Three simload processes need to be launched t_simloadapp1.exe - t_simloadapp3.exe
1.353 + while(index <= KNumSimLoadApps)
1.354 + {
1.355 + tempStore.Format(KSimLoadApp, index++);
1.356 + CreateSimLoadProcessL(tempStore);
1.357 + }
1.358 + }
1.359 +
1.360 +void CEglTest_Stress::CreateSimLoadProcessL(const TDesC& aApp)
1.361 + {
1.362 + INFO_PRINTF2(_L("Starting App: %S"), &aApp);
1.363 +
1.364 + RProcess process;
1.365 + User::LeaveIfError(process.Create(aApp, KNullDesC));
1.366 +
1.367 + //Give the simulated load high priority to be sure it does its job
1.368 + process.SetPriority(EPriorityHigh);
1.369 + TEST(process.Priority() == EPriorityHigh);
1.370 + INFO_PRINTF3(_L("Process Priority: Actual: %d, Expected: %d"), process.Priority(), EPriorityHigh);
1.371 + process.Resume();
1.372 +
1.373 + iProcessList.AppendL(process);
1.374 + }
1.375 +
1.376 +void CEglTest_Stress::DestroySimLoadProcess()
1.377 + {
1.378 + for (TInt index = 0; index < iProcessList.Count(); index++)
1.379 + {
1.380 + // check process
1.381 + INFO_PRINTF3(_L("Process Check: Actual: %d, Expected: %d"), iProcessList[index].ExitReason(), KErrNone);
1.382 + TEST(iProcessList[index].ExitReason( )== KErrNone);
1.383 +
1.384 + // kill process
1.385 + iProcessList[index].Kill(KErrGeneral);
1.386 + INFO_PRINTF3(_L("Process Exit Reason: Actual: %d, Expected: %d"), iProcessList[index].ExitReason(), KErrGeneral);
1.387 + TEST(iProcessList[index].ExitReason() == KErrGeneral);
1.388 +
1.389 + iProcessList[index].Close();
1.390 + }
1.391 +
1.392 + iProcessList.Close();
1.393 + }
1.394 +
1.395 +void CEglTest_Stress::ReadIniValueL(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult)
1.396 + {
1.397 + if(!GetIntFromConfig(aSectName, aKeyName, aResult))
1.398 + {
1.399 + ERR_PRINTF2(_L("Error reading %S value from ini file"), &aKeyName);
1.400 + User::Leave(KErrNotFound);
1.401 + }
1.402 +
1.403 + INFO_PRINTF3(_L("Ini file value %S = %d"), &aKeyName, aResult);
1.404 + }
1.405 +
1.406 +void CEglTest_Stress::ReadIniValuesL()
1.407 + {
1.408 + ReadIniValueL(ConfigSection(), KNumberRSgImages, iNumberRSgImages);
1.409 + ReadIniValueL(ConfigSection(), KNumberMainImages, iNumberMainImages);
1.410 + ReadIniValueL(ConfigSection(), KNumberChildProcesses, iNumberChildProcesses);
1.411 + ReadIniValueL(ConfigSection(), KRSgImageWidth, iRSgImageWidth);
1.412 + ReadIniValueL(ConfigSection(), KRSgImageHeight, iRSgImageHeight);
1.413 + ReadIniValueL(ConfigSection(), KConfigSimLoadValue, iSimLoadValue);
1.414 +
1.415 + //Check for erroneous ini values
1.416 + ASSERT_TRUE(iNumberChildProcesses <= iNumberRSgImages);
1.417 + ASSERT_TRUE(iNumberMainImages <= iNumberRSgImages);
1.418 + ASSERT_TRUE(iRSgImageWidth >= 0);
1.419 + ASSERT_TRUE(iRSgImageHeight >= 0);
1.420 + ASSERT_TRUE(iSimLoadValue >= 0);
1.421 + ASSERT_TRUE(iSimLoadValue <= 100);
1.422 +
1.423 + TBuf16<100> buffer;
1.424 + TPtrC16 ptrBuffer(buffer);
1.425 + if(!GetStringFromConfig(ConfigSection(), KPixelFormat, ptrBuffer))
1.426 + {
1.427 + ERR_PRINTF2(_L("Error reading %S value from ini file"), &KPixelFormat);
1.428 + User::Leave(KErrNotFound);
1.429 + }
1.430 +
1.431 + INFO_PRINTF3(_L("Ini file value %S = %S"), &KPixelFormat, &ptrBuffer);
1.432 +
1.433 + //Derive information from the pixel format
1.434 + if(ptrBuffer == KUidPixelFormatARGB_8888)
1.435 + {
1.436 + iFormat = EUidPixelFormatARGB_8888;
1.437 + iVgFormat = VG_sARGB_8888;
1.438 + iAlphaPre = EFalse;
1.439 + iByteSize = 4;
1.440 + }
1.441 + else if(ptrBuffer == KUidPixelFormatARGB_8888_PRE)
1.442 + {
1.443 + iFormat = EUidPixelFormatARGB_8888_PRE;
1.444 + iVgFormat = VG_sARGB_8888_PRE;
1.445 + iAlphaPre = ETrue;
1.446 + iByteSize = 4;
1.447 + }
1.448 + else if(ptrBuffer == KUidPixelFormatRGB_565)
1.449 + {
1.450 + iFormat = EUidPixelFormatRGB_565;
1.451 + iVgFormat = VG_sRGB_565;
1.452 + iAlphaPre = EFalse;
1.453 + iByteSize = 2;
1.454 + }
1.455 + else
1.456 + {
1.457 + ERR_PRINTF2(_L("Unsupported pixel format %S"), &ptrBuffer);
1.458 + User::Leave(KErrNotFound);
1.459 + }
1.460 +
1.461 + //Determine the test type from the ini file section name
1.462 + if(ConfigSection().Find(KStressReadOnly) != KErrNotFound)
1.463 + {
1.464 + iTestType = EStressRead;
1.465 + }
1.466 + else if(ConfigSection().Find(KEStressReadWriteSingleImage) != KErrNotFound)
1.467 + {
1.468 + iTestType = EStressReadWriteSingleImage;
1.469 + }
1.470 + else if(ConfigSection().Find(KStressReadWriteMultiImage) != KErrNotFound)
1.471 + {
1.472 + iTestType = EStressReadWriteMultiImage;
1.473 + }
1.474 + else if(ConfigSection().Find(KStressVGImage) != KErrNotFound)
1.475 + {
1.476 + iTestType = EStressVGImage;
1.477 + }
1.478 + else if(ConfigSection().Find(KStressPixmapSurface) != KErrNotFound)
1.479 + {
1.480 + iTestType = EStressPixmapSurface;
1.481 + }
1.482 + else
1.483 + {
1.484 + ERR_PRINTF2(_L("Unknown test case %S"), &ptrBuffer);
1.485 + User::Leave(KErrNotFound);
1.486 + }
1.487 + }
1.488 +
1.489 +/**
1.490 + * This function generates an ini file for the simulated load application
1.491 + * containing two lines to determine
1.492 + * 1. The type of load (static or spiked, in this case always static)
1.493 + * 2. The simulated load level
1.494 + */
1.495 +void CEglTest_Stress::PrintConfigDataL()
1.496 + {
1.497 + RFileWriteStream writer;
1.498 + writer.PushL();
1.499 +
1.500 + TInt err = iFs.MkDirAll(KSimLoadConfigFile);
1.501 + TEST(err == KErrNone || err == KErrAlreadyExists);
1.502 + INFO_PRINTF2(_L("Create Config File: %S"), &KSimLoadConfigFile);
1.503 + User::LeaveIfError(writer.Replace(iFs, KSimLoadConfigFile, EFileStreamText|EFileWrite));
1.504 + writer.CommitL();
1.505 +
1.506 + CleanupStack::PopAndDestroy(&writer);
1.507 +
1.508 + CIniData* data=CIniData::NewL(KSimLoadConfigFile);
1.509 + CleanupStack::PushL(data);
1.510 +
1.511 + INFO_PRINTF3(_L("Config Name: %S, \t\tConfig Data: %S"), &KConfigSimLoadType, &KConfigSimLoadStatic);
1.512 + err = data->AddValue(KDefaultSectionName, KConfigSimLoadType, KConfigSimLoadStatic);
1.513 + INFO_PRINTF3(_L("AddValue - Expected: %d, Actual: %d"), KErrNone, err);
1.514 + TEST(err == KErrNone);
1.515 +
1.516 + TBuf16<100> buffer;
1.517 + TPtrC16 ptrBuffer(buffer);
1.518 + User::LeaveIfError(GetStringFromConfig(ConfigSection(), KConfigSimLoadValue, ptrBuffer));
1.519 +
1.520 + INFO_PRINTF3(_L("Config Name: %S, \t\tConfig Data: %S"), &KConfigSimLoadValue, &ptrBuffer);
1.521 + err = data->AddValue(KDefaultSectionName, KConfigSimLoadValue, ptrBuffer);
1.522 +
1.523 + INFO_PRINTF3(_L("AddValue - Expected: %d, Actual: %d"), KErrNone, err);
1.524 + TEST(err == KErrNone);
1.525 +
1.526 + data->WriteToFileL();
1.527 + CleanupStack::PopAndDestroy(data);
1.528 + }
1.529 +
1.530 +void CEglTest_Stress::DeleteConfigData()
1.531 + {
1.532 + INFO_PRINTF2(_L("Deleting Config File Name: %S"), &KSimLoadConfigFile);
1.533 + TInt err = iFs.Delete(KSimLoadConfigFile);
1.534 + TEST(err==KErrNone);
1.535 + }
1.536 +
1.537 +/**
1.538 + * class CTReadWriteMain
1.539 + * A Child of CTReadWrite which contains member data not included in the base class and
1.540 + * implementations of pure virtual functions.
1.541 + * a) One for each particular test case
1.542 + * b) Support functions MakeCurrentL() and IsFinished()
1.543 + *
1.544 + * The base class is an active object and the implemented virtual functions are invoked
1.545 + * indirectly from the RunL() function
1.546 + */
1.547 +CTReadWriteMain::CTReadWriteMain(EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext, TInt aWidth, TInt aHeight, TInt aByteSize, VGImageFormat aFormat, TBool& aTestPass, TInt& aFinishedCounter, const TTestType& aTestType)
1.548 +: CTReadWrite(aWidth, aHeight, aByteSize, aFormat, aTestType, aTestPass),
1.549 + iDisplay(aDisplay),
1.550 + iSurface(aSurface),
1.551 + iContext(aContext),
1.552 + iFinishedCounter(aFinishedCounter)
1.553 + {
1.554 + }
1.555 +
1.556 +CTReadWriteMain* CTReadWriteMain::NewL(EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext, TInt aWidth, TInt aHeight, TInt aByteSize, VGImageFormat aFormat, TBool& aTestPass, TInt& aFinishedCounter, const TTestType& aTestType, VGImage aVGImage)
1.557 + {
1.558 + CTReadWriteMain* self = new (ELeave) CTReadWriteMain(aDisplay, aSurface, aContext, aWidth, aHeight, aByteSize, aFormat, aTestPass, aFinishedCounter, aTestType);
1.559 + CleanupStack::PushL(self);
1.560 + self->ConstructL(aVGImage);
1.561 + CleanupStack::Pop(self);
1.562 + return self;
1.563 + }
1.564 +
1.565 +void CTReadWriteMain::ConstructL(VGImage aVGImage)
1.566 + {
1.567 + //NULL values indicate a programming error
1.568 + if( (iDisplay == EGL_NO_DISPLAY) || (iSurface == EGL_NO_SURFACE) || (iContext == EGL_NO_CONTEXT) || (iFinishedCounter == 0) || ((iTestType == EStressVGImage) && (aVGImage == NULL)) )
1.569 + {
1.570 + User::Leave(KErrArgument);
1.571 + }
1.572 +
1.573 + iVGImage = aVGImage;
1.574 +
1.575 + //Call base class function to complete construction
1.576 + CTReadWrite::ConstructL();
1.577 + }
1.578 +
1.579 +void CTReadWriteMain::MakeCurrentL() const
1.580 + {
1.581 + EGL_LEAVE_ERROR(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
1.582 + }
1.583 +
1.584 +void CTReadWriteMain::ReadImageFuncL()
1.585 + {
1.586 + vgReadPixels(iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
1.587 + VgLeaveIfErrorL();
1.588 + }
1.589 +
1.590 +void CTReadWriteMain::ReadFuncL()
1.591 + {
1.592 + ReadImageFuncL();
1.593 + }
1.594 +
1.595 +void CTReadWriteMain::WriteImageFuncL()
1.596 + {
1.597 + vgWritePixels(iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
1.598 + VgLeaveIfErrorL();
1.599 + }
1.600 +
1.601 +TBool CTReadWriteMain::IsFinished()
1.602 + {
1.603 + iFinishedCounter--;
1.604 +
1.605 + if(iFinishedCounter <= 0)
1.606 + {
1.607 + return ETrue;
1.608 + }
1.609 +
1.610 + return EFalse;
1.611 + }
1.612 +
1.613 +void CTReadWriteMain::VgImageFuncL()
1.614 + {
1.615 + //Alter the image data, actual pixel values are not important
1.616 + for(TInt i=0; i<iBufferSize; i++)
1.617 + {
1.618 + const TUint32 temp = iBufferSize % iFrameNumber;
1.619 + iData[i] = temp + (temp << 8) + (temp << 16) + (temp << 24);
1.620 + }
1.621 +
1.622 + //Currently panics as context->scanlinebuffer is NULL
1.623 + vgImageSubData(iVGImage, iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
1.624 + VgLeaveIfErrorL();
1.625 +
1.626 + EGL_LEAVE_ERROR(eglSwapBuffers(iDisplay, iSurface));
1.627 + }
1.628 +
1.629 +void CTReadWriteMain::PixmapSurfaceFuncL()
1.630 + {
1.631 + // clear surface background to an arbitrary colour
1.632 + VGfloat arbitraryColour = (1.0*iFrameNumber)/KNumberOfFrames;
1.633 + VGfloat backgroundColour[] = {1.0 - arbitraryColour/2, arbitraryColour/2, 1.0 - arbitraryColour, arbitraryColour};
1.634 + vgSetfv(VG_CLEAR_COLOR, 4, backgroundColour);
1.635 + VgLeaveIfErrorL();
1.636 + vgClear(0, 0, iWidth, iHeight);
1.637 + VgLeaveIfErrorL();
1.638 +
1.639 + EGL_LEAVE_ERROR(eglSwapBuffers(iDisplay, iSurface));
1.640 + }