sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@test
|
sl@0
|
19 |
@internalComponent
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <s32file.h>
|
sl@0
|
23 |
#include <hal.h>
|
sl@0
|
24 |
#include <libc/limits.h> //UINT_MAX
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "t_pseudoappeng.h"
|
sl@0
|
27 |
#include "t_pseudoapputils.h"
|
sl@0
|
28 |
#include "t_wservconsts.h"
|
sl@0
|
29 |
#include "t_winutils.h"
|
sl@0
|
30 |
#include <graphics/suerror.h>
|
sl@0
|
31 |
#include "t_pseudoappshared.h"
|
sl@0
|
32 |
|
sl@0
|
33 |
//
|
sl@0
|
34 |
// class CTPseudoAppEng
|
sl@0
|
35 |
//
|
sl@0
|
36 |
CTPseudoAppEng::CTPseudoAppEng(RWsSession& aClient, CWsScreenDevice& aScreenDevice, RWindow& aWindow)
|
sl@0
|
37 |
: CTimer(CActive::EPriorityStandard),
|
sl@0
|
38 |
iClient(aClient),
|
sl@0
|
39 |
iWindow(aWindow),
|
sl@0
|
40 |
iScreenDevice(aScreenDevice),
|
sl@0
|
41 |
iDrawing(EFalse)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
CTPseudoAppEng* CTPseudoAppEng::NewL(RWsSession& aClient, CWsScreenDevice& aScreenDevice, RWindow& aWindow)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
CTPseudoAppEng* self = new (ELeave) CTPseudoAppEng(aClient, aScreenDevice, aWindow);
|
sl@0
|
48 |
CleanupStack::PushL(self);
|
sl@0
|
49 |
self->ConstructL();
|
sl@0
|
50 |
CleanupStack::Pop(); // self;
|
sl@0
|
51 |
return self;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
CTPseudoAppEng::~CTPseudoAppEng()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
iSurfaceUpdateSession.Close();
|
sl@0
|
57 |
|
sl@0
|
58 |
if(IsActive())
|
sl@0
|
59 |
{
|
sl@0
|
60 |
Cancel();
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
delete iPseudoAppShared;
|
sl@0
|
64 |
delete iUtils;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
void CTPseudoAppEng::ConstructL()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
CTimer::ConstructL();
|
sl@0
|
70 |
|
sl@0
|
71 |
//Create CIniData class for reading in values form ini files
|
sl@0
|
72 |
#ifndef T_PSEUDOAPP1
|
sl@0
|
73 |
iUtils = CIniData::NewL(KWServPseudoAppConfigFile);
|
sl@0
|
74 |
#else
|
sl@0
|
75 |
iUtils = CIniData::NewL(KWServPseudoApp1ConfigFile);
|
sl@0
|
76 |
#endif //T_PSEUDOAPP1
|
sl@0
|
77 |
|
sl@0
|
78 |
//Connect to the surface update server
|
sl@0
|
79 |
TInt err = iSurfaceUpdateSession.Connect();
|
sl@0
|
80 |
if (err!=KErrNone)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
RDebug::Print(_L("error in connecting surface update session\n"));
|
sl@0
|
83 |
User::Exit(0);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
User::LeaveIfError(HAL::Get(HALData::EFastCounterFrequency, iCounterFreq));
|
sl@0
|
87 |
|
sl@0
|
88 |
//Enter the animation loop
|
sl@0
|
89 |
RDebug::Print(_L("Enter Animation Loop\n"));
|
sl@0
|
90 |
|
sl@0
|
91 |
CActiveScheduler::Add(this);
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
void CTPseudoAppEng::StartDrawingL()
|
sl@0
|
95 |
{
|
sl@0
|
96 |
/* Read in the configuration fron the config file *
|
sl@0
|
97 |
* and check the validity of the parameters. If *
|
sl@0
|
98 |
* invalid, take remedial action *
|
sl@0
|
99 |
* Exit if the config is really unusable *
|
sl@0
|
100 |
* Window and animation classes are created if *
|
sl@0
|
101 |
* the configs are ok */
|
sl@0
|
102 |
RDebug::Print(_L("Import configuration for t_pseudoapp class and create test screen(s)\n"));
|
sl@0
|
103 |
ImportPseudoAppConfigL();
|
sl@0
|
104 |
RDebug::Print(_L("Test screen(s) created for t_pseudoapp\n"));
|
sl@0
|
105 |
|
sl@0
|
106 |
if (iDrawing)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
User::Panic(KTPseudoAppPanicTxt(), TPseudoAppEngAlreadyStarted);
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
iDrawing = ETrue;
|
sl@0
|
112 |
|
sl@0
|
113 |
//A value of 0 will provoke a E32User-Cbase 46 panic
|
sl@0
|
114 |
After(TTimeIntervalMicroSeconds32(100000));
|
sl@0
|
115 |
|
sl@0
|
116 |
//Set iStartTime to current time
|
sl@0
|
117 |
iStartTime.UniversalTime();
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
void CTPseudoAppEng::StopDrawing()
|
sl@0
|
121 |
{
|
sl@0
|
122 |
if (!iDrawing)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
User::Panic(KTPseudoAppPanicTxt(), TPseudoAppEngAlreadyStopped);
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
// Cancel timer and display
|
sl@0
|
128 |
Cancel();
|
sl@0
|
129 |
iDrawing = EFalse;
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
void CTPseudoAppEng::TestFinishedL(const TDesC& aFileName)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
RFs myFs;
|
sl@0
|
135 |
User::LeaveIfError(myFs.Connect());
|
sl@0
|
136 |
RFileWriteStream writer;
|
sl@0
|
137 |
writer.PushL(); // writer on cleanup stack
|
sl@0
|
138 |
User::LeaveIfError(writer.Replace(myFs, aFileName, EFileWrite));
|
sl@0
|
139 |
writer << _L("Surfaces Test Finished");
|
sl@0
|
140 |
writer.CommitL();
|
sl@0
|
141 |
CleanupStack::PopAndDestroy(&writer);
|
sl@0
|
142 |
myFs.Close();
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
void CTPseudoAppEng::WriteResultsL(const TDesC& aFileName)
|
sl@0
|
146 |
{
|
sl@0
|
147 |
RFs myFs;
|
sl@0
|
148 |
User::LeaveIfError(myFs.Connect());
|
sl@0
|
149 |
|
sl@0
|
150 |
TInt err = myFs.MkDirAll(aFileName);
|
sl@0
|
151 |
|
sl@0
|
152 |
if (err==KErrNone || err==KErrAlreadyExists)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
RFileWriteStream writer;
|
sl@0
|
155 |
writer.PushL(); // writer on cleanup stack
|
sl@0
|
156 |
|
sl@0
|
157 |
User::LeaveIfError(writer.Replace(myFs, aFileName, EFileStreamText|EFileWrite));
|
sl@0
|
158 |
writer.CommitL();
|
sl@0
|
159 |
CleanupStack::PopAndDestroy(&writer); // writer
|
sl@0
|
160 |
|
sl@0
|
161 |
CIniData* myData = CIniData::NewL(aFileName);
|
sl@0
|
162 |
CleanupStack::PushL(myData);
|
sl@0
|
163 |
|
sl@0
|
164 |
TBuf<255> tempStore;
|
sl@0
|
165 |
_LIT(KIntData, "%d");
|
sl@0
|
166 |
_LIT(KRealData, "%4.1f");
|
sl@0
|
167 |
|
sl@0
|
168 |
//Write out the test result, which is essentially a pass if the code reaches here
|
sl@0
|
169 |
tempStore.Format(KIntData, 1);
|
sl@0
|
170 |
TInt err = myData->AddValue(KDefaultSectionName, KGraphicsWservSurfaceTestResult, tempStore);
|
sl@0
|
171 |
User::LeaveIfError(err);
|
sl@0
|
172 |
myData->WriteToFileL();
|
sl@0
|
173 |
|
sl@0
|
174 |
//Write out the theoretical maximum frame rate
|
sl@0
|
175 |
TReal frameRate = (iCounterFreq*static_cast<TReal>(iFrameDuration))/iGceTestResults.iTotalCompoTime;
|
sl@0
|
176 |
|
sl@0
|
177 |
tempStore.Format(KRealData, frameRate);
|
sl@0
|
178 |
err = myData->AddValue(KDefaultSectionName, KGraphicsWservSurfaceFrameRate, tempStore);
|
sl@0
|
179 |
myData->WriteToFileL();
|
sl@0
|
180 |
|
sl@0
|
181 |
//Write out the total test time
|
sl@0
|
182 |
TReal compoTime = static_cast<TReal>(iGceTestResults.iElapsedTime)/1000;
|
sl@0
|
183 |
|
sl@0
|
184 |
tempStore.Format(KRealData, compoTime);
|
sl@0
|
185 |
err = myData->AddValue(KDefaultSectionName, KGraphicsWservSurfaceTotalTestTime, tempStore);
|
sl@0
|
186 |
myData->WriteToFileL();
|
sl@0
|
187 |
|
sl@0
|
188 |
CleanupStack::PopAndDestroy(myData);
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
myFs.Close();
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
// Timer's RunL()
|
sl@0
|
195 |
void CTPseudoAppEng::RunL()
|
sl@0
|
196 |
{
|
sl@0
|
197 |
if(iFrameCounter != iFrameDuration)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
//If no surface update is required, aSurfaceId will remain as 0
|
sl@0
|
200 |
TSurfaceId temp;
|
sl@0
|
201 |
iSurfDetails.aSurfaceId = temp.CreateNullId() ;
|
sl@0
|
202 |
|
sl@0
|
203 |
while(iScreenCounter < iPseudoAppShared->iTestScreens.Count())
|
sl@0
|
204 |
{
|
sl@0
|
205 |
iPseudoAppShared->iTestScreens[iScreenCounter]->UpdateL(iSurfDetails);
|
sl@0
|
206 |
iScreenCounter++;
|
sl@0
|
207 |
break;
|
sl@0
|
208 |
}
|
sl@0
|
209 |
|
sl@0
|
210 |
if(!iSurfDetails.aSurfaceId.IsNull())
|
sl@0
|
211 |
{
|
sl@0
|
212 |
if(iUseGlobalUpdate)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
SendUpdateRequest(KAllScreens);
|
sl@0
|
215 |
}
|
sl@0
|
216 |
else
|
sl@0
|
217 |
{
|
sl@0
|
218 |
SendUpdateRequest(iScreenCounter - 1);
|
sl@0
|
219 |
}
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
if(iScreenCounter == iPseudoAppShared->iTestScreens.Count())
|
sl@0
|
223 |
{
|
sl@0
|
224 |
iScreenCounter = 0;
|
sl@0
|
225 |
iFrameCounter++;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
// Renew request
|
sl@0
|
229 |
After(TTimeIntervalMicroSeconds32(iFrameDelay));
|
sl@0
|
230 |
}
|
sl@0
|
231 |
else
|
sl@0
|
232 |
{
|
sl@0
|
233 |
#ifndef T_PSEUDOAPP1
|
sl@0
|
234 |
WriteResultsL(KWServPseudoAppResultFile);
|
sl@0
|
235 |
TestFinishedL(KWServPseudoAppFinishFile);
|
sl@0
|
236 |
#else
|
sl@0
|
237 |
WriteResultsL(KWServPseudoApp1ResultFile);
|
sl@0
|
238 |
TestFinishedL(KWServPseudoApp1FinishFile);
|
sl@0
|
239 |
#endif //T_PSEUDOAPP1
|
sl@0
|
240 |
}
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
// Timer's DoCancel()
|
sl@0
|
244 |
void CTPseudoAppEng::DoCancel()
|
sl@0
|
245 |
{
|
sl@0
|
246 |
// Cancel timer
|
sl@0
|
247 |
CTimer::DoCancel();
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
TBool CTPseudoAppEng::Drawing()
|
sl@0
|
251 |
{
|
sl@0
|
252 |
return iDrawing;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
void CTPseudoAppEng::SendUpdateRequest(TInt /*aScreen*/)
|
sl@0
|
256 |
{
|
sl@0
|
257 |
//Submit update
|
sl@0
|
258 |
TRect rc[1] =
|
sl@0
|
259 |
{
|
sl@0
|
260 |
TRect(0, 0, iSurfDetails.aSurfaceSize.iWidth, iSurfDetails.aSurfaceSize.iHeight)
|
sl@0
|
261 |
};
|
sl@0
|
262 |
|
sl@0
|
263 |
RRegion region(1, rc);
|
sl@0
|
264 |
|
sl@0
|
265 |
//Use timestamp notification to measure frame rate
|
sl@0
|
266 |
TRequestStatus status;
|
sl@0
|
267 |
|
sl@0
|
268 |
TTimeStamp timeStamp;
|
sl@0
|
269 |
iSurfaceUpdateSession.NotifyWhenDisplayed(status, timeStamp);
|
sl@0
|
270 |
iTimeStampBefore = User::FastCounter();
|
sl@0
|
271 |
|
sl@0
|
272 |
TInt ret = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, iSurfDetails.aSurfaceId, iSurfDetails.aBufferNumber, ®ion);
|
sl@0
|
273 |
|
sl@0
|
274 |
User::WaitForRequest(status);
|
sl@0
|
275 |
|
sl@0
|
276 |
TUint64 time = timeStamp();
|
sl@0
|
277 |
|
sl@0
|
278 |
if(time < iTimeStampBefore)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
time += UINT_MAX;
|
sl@0
|
281 |
}
|
sl@0
|
282 |
|
sl@0
|
283 |
iTotalCompositionTime += (time - iTimeStampBefore);
|
sl@0
|
284 |
|
sl@0
|
285 |
TTime currentTime;
|
sl@0
|
286 |
currentTime.UniversalTime();
|
sl@0
|
287 |
TTimeIntervalMicroSeconds elapsedTime = currentTime.MicroSecondsFrom(iStartTime);
|
sl@0
|
288 |
|
sl@0
|
289 |
iGceTestResults.iElapsedTime = (TUint32)(elapsedTime.Int64()/1000);
|
sl@0
|
290 |
iGceTestResults.iTotalCompoTime = (TUint32)(iTotalCompositionTime);
|
sl@0
|
291 |
|
sl@0
|
292 |
if(ret != KErrNone)
|
sl@0
|
293 |
{
|
sl@0
|
294 |
RDebug::Print(_L("Error submitting update request\n"));
|
sl@0
|
295 |
}
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
void CTPseudoAppEng::ImportPseudoAppConfigL()
|
sl@0
|
299 |
{
|
sl@0
|
300 |
TDisplayMode mode;
|
sl@0
|
301 |
TSize aScreenSize;
|
sl@0
|
302 |
TInt numberOfScreens;
|
sl@0
|
303 |
|
sl@0
|
304 |
READ_INI1(number_of_screens, numberOfScreens, iUtils);
|
sl@0
|
305 |
|
sl@0
|
306 |
iPseudoAppShared = new(ELeave) CTPseudoAppShared;
|
sl@0
|
307 |
for(TInt i=0; i<numberOfScreens; i++)
|
sl@0
|
308 |
{
|
sl@0
|
309 |
RDebug::Print(_L("Set up screen %d\n"), i);
|
sl@0
|
310 |
TImportPseudoAppConfig::ImportPseudoAppConfigL(i, iFrameDuration, iFrameDelay, mode, aScreenSize, iUtils);
|
sl@0
|
311 |
#ifndef T_PSEUDOAPP1
|
sl@0
|
312 |
iPseudoAppShared->AddTestScreenL(i, mode, iFrameDuration, aScreenSize, &iGceTestResults, KWServPseudoAppConfigFile);
|
sl@0
|
313 |
#else
|
sl@0
|
314 |
iPseudoAppShared->AddTestScreenL(i, mode, iFrameDuration, aScreenSize, &iGceTestResults, KWServPseudoApp1ConfigFile);
|
sl@0
|
315 |
#endif //T_PSEUDOAPP1
|
sl@0
|
316 |
}
|
sl@0
|
317 |
READ_INI2A(KNullDesC, use_global_surface_update, True, False, iUseGlobalUpdate, ETrue, EFalse, iUtils);
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
void CTPseudoAppEng::RotateL()
|
sl@0
|
321 |
{
|
sl@0
|
322 |
if (iPseudoAppShared)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
for(TInt i=0; i<iPseudoAppShared->iTestScreens.Count(); i++)
|
sl@0
|
325 |
{
|
sl@0
|
326 |
if (iPseudoAppShared->iTestScreens[i])
|
sl@0
|
327 |
{
|
sl@0
|
328 |
if(iPseudoAppShared->iTestScreens[i]->Rotation())
|
sl@0
|
329 |
{
|
sl@0
|
330 |
iPseudoAppShared->iTestScreens[i]->RotateL(i, iFrameCounter);
|
sl@0
|
331 |
}
|
sl@0
|
332 |
}
|
sl@0
|
333 |
}
|
sl@0
|
334 |
}
|
sl@0
|
335 |
}
|