First public contribution.
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include "egltest_stress_process_sgimage.h"
23 GLDEF_C TInt E32Main()
25 RDebug::Print(_L("Stress test client process::E32Main - entry"));
26 CTrapCleanup* TheTrapCleanup = CTrapCleanup::New();
28 TRAPD(err, LaunchClientProcessL());
31 User::Panic(KStressTestChildAppPanic, err);
34 delete TheTrapCleanup;
36 RDebug::Print(_L("Stress test client process::E32Main - exit"));
40 LOCAL_C void LaunchClientProcessL()
43 RProcess::Rendezvous(KErrNone);
46 User::LeaveIfError(sem.OpenGlobal(KEglStressTest));
47 CleanupClosePushL(sem);
49 //Access data passed from the main process
50 TStressProcessInfo info;
51 TPckg<TStressProcessInfo> pckgInfo(info);
52 User::LeaveIfError(User::GetDesParameter(KMultiProcessSlot, pckgInfo));
54 //Create RSgDriver and open the image
56 User::LeaveIfError(driver.Open());
57 CleanupClosePushL(driver);
60 User::LeaveIfError(image.Open(info.iSgId));
61 CleanupClosePushL(image);
64 EGL_LEAVE_NULL(display, eglGetDisplay(EGL_DEFAULT_DISPLAY));
65 EGL_LEAVE_ERROR(eglInitialize(display, NULL, NULL));
66 EGL_LEAVE_ERROR(eglBindAPI(EGL_OPENVG_API));
68 //Initialise to remove arm compiler warnings
70 EGLContext context = EGL_NO_CONTEXT;
71 EGLSurface surface = EGL_NO_SURFACE;
73 if(info.iTestType == EStressRead)
76 User::LeaveIfError(image.GetInfo(sginfo));
78 //Create an independant pixmap surface on which to copy the vgimage
80 User::LeaveIfError(image2.Create(sginfo, NULL, NULL));
81 CleanupClosePushL(image2);
82 ChooseConfigAndCreateContextL(display, context, config, image2, KStressTestChildAppPanic, info.iAlphaPre);
83 EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(display, config, image2, info.iAlphaPre));
84 CleanupStack::PopAndDestroy(&image2);
88 ChooseConfigAndCreateContextL(display, context, config, image, KStressTestChildAppPanic, info.iAlphaPre);
89 EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(display, config, image, info.iAlphaPre));
92 EGL_LEAVE_ERROR(eglMakeCurrent(display, surface, surface, context));
95 GenerateVgImageL(display, &image, vgImage);
97 /* Create and install the active scheduler */
98 CActiveScheduler* sched = new(ELeave) CActiveScheduler;
99 CActiveScheduler::Install(sched);
100 CleanupStack::PushL(sched);
102 TInt width = vgGetParameteri(vgImage, VG_IMAGE_WIDTH);
105 TInt height = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT);
108 VGImageFormat format = static_cast<VGImageFormat>(vgGetParameteri(vgImage, VG_IMAGE_FORMAT));
111 TBool testPass = ETrue;
113 CTReadWriteChild* painter = CTReadWriteChild::NewL(vgImage, width, height, info.iByteSize, format, info.iTestType, testPass);
114 CleanupStack::PushL(painter);
115 painter->After(TTimeIntervalMicroSeconds32(0));
117 //Data access is synchronised from the main process
121 if(testPass == EFalse)
123 // Leave with a 'known' test error so that we can catch this particular failure
124 User::Leave(KTestStressUnexpectedPixelError);
127 CleanupStack::PopAndDestroy(5, &sem); //painter, sched, image, driver, sem
133 * class CTReadWriteChild
134 * A Child of CTReadWrite which contains member data not included in the base class and
135 * implementations of pure virtual functions.
136 * a) One for each particular test case
137 * b) Support functions MakeCurrentL() and IsFinished()
139 * The base class is an active object and the implemented virtual functions are invoked
140 * indirectly from the RunL() function
142 CTReadWriteChild::CTReadWriteChild(VGImage aImage, TInt aWidth, TInt aHeight, TInt aByteSize, VGImageFormat aFormat, const TTestType& aTestType, TBool& aTestPass)
143 : CTReadWrite(aWidth, aHeight, aByteSize, aFormat, aTestType, aTestPass),
148 CTReadWriteChild* CTReadWriteChild::NewL(VGImage aImage, TInt aWidth, TInt aHeight, TInt aByteSize, VGImageFormat aFormat, const TTestType& aTestType, TBool& aTestPass)
150 CTReadWriteChild* self = new (ELeave) CTReadWriteChild(aImage, aWidth, aHeight, aByteSize, aFormat, aTestType, aTestPass);
151 CleanupStack::PushL(self);
153 CleanupStack::Pop(self);
157 void CTReadWriteChild::MakeCurrentL() const
161 void CTReadWriteChild::ReadImageFuncL()
163 vgGetImageSubData(iImage, iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
167 void CTReadWriteChild::ReadFuncL()
170 vgReadPixels(iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
173 //Small delay to aid pixel access sharing between processes
174 User::After(TTimeIntervalMicroSeconds32(1000));
177 void CTReadWriteChild::WriteImageFuncL()
179 vgImageSubData(iImage, iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
183 TBool CTReadWriteChild::IsFinished()
188 void CTReadWriteChild::VgImageFuncL()
194 void CTReadWriteChild::PixmapSurfaceFuncL()