1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltest_stress_process_sgimage.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,198 @@
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 "egltest_stress_process_sgimage.h"
1.25 +
1.26 +GLDEF_C TInt E32Main()
1.27 + {
1.28 + RDebug::Print(_L("Stress test client process::E32Main - entry"));
1.29 + CTrapCleanup* TheTrapCleanup = CTrapCleanup::New();
1.30 +
1.31 + TRAPD(err, LaunchClientProcessL());
1.32 + if (err)
1.33 + {
1.34 + User::Panic(KStressTestChildAppPanic, err);
1.35 + }
1.36 +
1.37 + delete TheTrapCleanup;
1.38 +
1.39 + RDebug::Print(_L("Stress test client process::E32Main - exit"));
1.40 + return KErrNone;
1.41 + }
1.42 +
1.43 +LOCAL_C void LaunchClientProcessL()
1.44 + {
1.45 + __UHEAP_MARK;
1.46 + RProcess::Rendezvous(KErrNone);
1.47 +
1.48 + RSemaphore sem;
1.49 + User::LeaveIfError(sem.OpenGlobal(KEglStressTest));
1.50 + CleanupClosePushL(sem);
1.51 +
1.52 + //Access data passed from the main process
1.53 + TStressProcessInfo info;
1.54 + TPckg<TStressProcessInfo> pckgInfo(info);
1.55 + User::LeaveIfError(User::GetDesParameter(KMultiProcessSlot, pckgInfo));
1.56 +
1.57 + //Create RSgDriver and open the image
1.58 + RSgDriver driver;
1.59 + User::LeaveIfError(driver.Open());
1.60 + CleanupClosePushL(driver);
1.61 +
1.62 + RSgImage image;
1.63 + User::LeaveIfError(image.Open(info.iSgId));
1.64 + CleanupClosePushL(image);
1.65 +
1.66 + EGLDisplay display;
1.67 + EGL_LEAVE_NULL(display, eglGetDisplay(EGL_DEFAULT_DISPLAY));
1.68 + EGL_LEAVE_ERROR(eglInitialize(display, NULL, NULL));
1.69 + EGL_LEAVE_ERROR(eglBindAPI(EGL_OPENVG_API));
1.70 +
1.71 + //Initialise to remove arm compiler warnings
1.72 + EGLConfig config = 0;
1.73 + EGLContext context = EGL_NO_CONTEXT;
1.74 + EGLSurface surface = EGL_NO_SURFACE;
1.75 +
1.76 + if(info.iTestType == EStressRead)
1.77 + {
1.78 + TSgImageInfo sginfo;
1.79 + User::LeaveIfError(image.GetInfo(sginfo));
1.80 +
1.81 + //Create an independant pixmap surface on which to copy the vgimage
1.82 + RSgImage image2;
1.83 + User::LeaveIfError(image2.Create(sginfo, NULL, NULL));
1.84 + CleanupClosePushL(image2);
1.85 + ChooseConfigAndCreateContextL(display, context, config, image2, KStressTestChildAppPanic, info.iAlphaPre);
1.86 + EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(display, config, image2, info.iAlphaPre));
1.87 + CleanupStack::PopAndDestroy(&image2);
1.88 + }
1.89 + else
1.90 + {
1.91 + ChooseConfigAndCreateContextL(display, context, config, image, KStressTestChildAppPanic, info.iAlphaPre);
1.92 + EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(display, config, image, info.iAlphaPre));
1.93 + }
1.94 +
1.95 + EGL_LEAVE_ERROR(eglMakeCurrent(display, surface, surface, context));
1.96 +
1.97 + VGImage vgImage;
1.98 + GenerateVgImageL(display, &image, vgImage);
1.99 +
1.100 + /* Create and install the active scheduler */
1.101 + CActiveScheduler* sched = new(ELeave) CActiveScheduler;
1.102 + CActiveScheduler::Install(sched);
1.103 + CleanupStack::PushL(sched);
1.104 +
1.105 + TInt width = vgGetParameteri(vgImage, VG_IMAGE_WIDTH);
1.106 + VgLeaveIfErrorL();
1.107 +
1.108 + TInt height = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT);
1.109 + VgLeaveIfErrorL();
1.110 +
1.111 + VGImageFormat format = static_cast<VGImageFormat>(vgGetParameteri(vgImage, VG_IMAGE_FORMAT));
1.112 + VgLeaveIfErrorL();
1.113 +
1.114 + TBool testPass = ETrue;
1.115 +
1.116 + CTReadWriteChild* painter = CTReadWriteChild::NewL(vgImage, width, height, info.iByteSize, format, info.iTestType, testPass);
1.117 + CleanupStack::PushL(painter);
1.118 + painter->After(TTimeIntervalMicroSeconds32(0));
1.119 +
1.120 + //Data access is synchronised from the main process
1.121 + sem.Wait();
1.122 + sched->Start();
1.123 +
1.124 + if(testPass == EFalse)
1.125 + {
1.126 + // Leave with a 'known' test error so that we can catch this particular failure
1.127 + User::Leave(KTestStressUnexpectedPixelError);
1.128 + }
1.129 +
1.130 + CleanupStack::PopAndDestroy(5, &sem); //painter, sched, image, driver, sem
1.131 +
1.132 + __UHEAP_MARKEND;
1.133 + }
1.134 +
1.135 +/**
1.136 + * class CTReadWriteChild
1.137 + * A Child of CTReadWrite which contains member data not included in the base class and
1.138 + * implementations of pure virtual functions.
1.139 + * a) One for each particular test case
1.140 + * b) Support functions MakeCurrentL() and IsFinished()
1.141 + *
1.142 + * The base class is an active object and the implemented virtual functions are invoked
1.143 + * indirectly from the RunL() function
1.144 + */
1.145 +CTReadWriteChild::CTReadWriteChild(VGImage aImage, TInt aWidth, TInt aHeight, TInt aByteSize, VGImageFormat aFormat, const TTestType& aTestType, TBool& aTestPass)
1.146 +: CTReadWrite(aWidth, aHeight, aByteSize, aFormat, aTestType, aTestPass),
1.147 + iImage(aImage)
1.148 + {
1.149 + }
1.150 +
1.151 +CTReadWriteChild* CTReadWriteChild::NewL(VGImage aImage, TInt aWidth, TInt aHeight, TInt aByteSize, VGImageFormat aFormat, const TTestType& aTestType, TBool& aTestPass)
1.152 + {
1.153 + CTReadWriteChild* self = new (ELeave) CTReadWriteChild(aImage, aWidth, aHeight, aByteSize, aFormat, aTestType, aTestPass);
1.154 + CleanupStack::PushL(self);
1.155 + self->ConstructL();
1.156 + CleanupStack::Pop(self);
1.157 + return self;
1.158 + }
1.159 +
1.160 +void CTReadWriteChild::MakeCurrentL() const
1.161 + {
1.162 + }
1.163 +
1.164 +void CTReadWriteChild::ReadImageFuncL()
1.165 + {
1.166 + vgGetImageSubData(iImage, iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
1.167 + VgLeaveIfErrorL();
1.168 + }
1.169 +
1.170 +void CTReadWriteChild::ReadFuncL()
1.171 + {
1.172 + vgDrawImage(iImage);
1.173 + vgReadPixels(iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
1.174 + VgLeaveIfErrorL();
1.175 +
1.176 + //Small delay to aid pixel access sharing between processes
1.177 + User::After(TTimeIntervalMicroSeconds32(1000));
1.178 + }
1.179 +
1.180 +void CTReadWriteChild::WriteImageFuncL()
1.181 + {
1.182 + vgImageSubData(iImage, iData, iWidth*iByteSize, iFormat, 0, 0, iWidth, iHeight);
1.183 + VgLeaveIfErrorL();
1.184 + }
1.185 +
1.186 +TBool CTReadWriteChild::IsFinished()
1.187 + {
1.188 + return ETrue;
1.189 + }
1.190 +
1.191 +void CTReadWriteChild::VgImageFuncL()
1.192 + {
1.193 + vgDrawImage(iImage);
1.194 + VgLeaveIfErrorL();
1.195 + }
1.196 +
1.197 +void CTReadWriteChild::PixmapSurfaceFuncL()
1.198 + {
1.199 + vgDrawImage(iImage);
1.200 + VgLeaveIfErrorL();
1.201 + }