sl@0
|
1 |
// Copyright (c) 2005-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 - Internal Symbian test code
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "tgraphicsresource.h"
|
sl@0
|
23 |
#include "tdirectgditestbase.h"
|
sl@0
|
24 |
#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
|
sl@0
|
25 |
#include <graphics/sgimage_sw.h>
|
sl@0
|
26 |
#endif
|
sl@0
|
27 |
|
sl@0
|
28 |
#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
|
sl@0
|
29 |
const TInt KIterationsToTest = 1000;
|
sl@0
|
30 |
#endif
|
sl@0
|
31 |
|
sl@0
|
32 |
CTGraphicsResource::CTGraphicsResource()
|
sl@0
|
33 |
{
|
sl@0
|
34 |
SetTestStepName(KTGraphicsResource);
|
sl@0
|
35 |
|
sl@0
|
36 |
#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
|
sl@0
|
37 |
iImageInfo.iCpuAccess = ESgCpuAccessReadWrite;
|
sl@0
|
38 |
iImageInfo.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
39 |
iImageInfo.iPixelFormat = EUidPixelFormatRGB_565;
|
sl@0
|
40 |
iImageInfo.iShareable = ETrue;
|
sl@0
|
41 |
|
sl@0
|
42 |
Mem::FillZ(iImageData, KMaxArraySize * sizeof(TUint16));
|
sl@0
|
43 |
TEST(KErrNone == SgDriver::Open());
|
sl@0
|
44 |
#endif
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
CTGraphicsResource::~CTGraphicsResource()
|
sl@0
|
48 |
{
|
sl@0
|
49 |
#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
|
sl@0
|
50 |
TInt temp = SgDriver::ResourceCount();
|
sl@0
|
51 |
SgDriver::Close();
|
sl@0
|
52 |
#endif
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
Override of base class pure virtual
|
sl@0
|
57 |
Our implementation only gets called if the base class doTestStepPreambleL() did
|
sl@0
|
58 |
not leave. That being the case, the current test result value will be EPass.
|
sl@0
|
59 |
|
sl@0
|
60 |
@return - TVerdict code
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
TVerdict CTGraphicsResource::doTestStepL()
|
sl@0
|
63 |
{
|
sl@0
|
64 |
#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
|
sl@0
|
65 |
INFO_PRINTF1(_L("CTGraphicsResource can only be run with RSgImage legacy"));
|
sl@0
|
66 |
return TestStepResult();
|
sl@0
|
67 |
#else
|
sl@0
|
68 |
SetTestStepID(_L("GRAPHICS-UI-BENCH-0089"));
|
sl@0
|
69 |
SmallImageCreationSimpleL();
|
sl@0
|
70 |
RecordTestResultL();
|
sl@0
|
71 |
SetTestStepID(_L("GRAPHICS-UI-BENCH-0090"));
|
sl@0
|
72 |
LargeImageCreationSimpleL();
|
sl@0
|
73 |
RecordTestResultL();
|
sl@0
|
74 |
SetTestStepID(_L("GRAPHICS-UI-BENCH-0091"));
|
sl@0
|
75 |
ImageDuplicateL();
|
sl@0
|
76 |
RecordTestResultL();
|
sl@0
|
77 |
SetTestStepID(_L("GRAPHICS-UI-BENCH-0092"));
|
sl@0
|
78 |
ImageDuplicateHandleL();
|
sl@0
|
79 |
RecordTestResultL();
|
sl@0
|
80 |
SetTestStepID(_L("GRAPHICS-UI-BENCH-0093"));
|
sl@0
|
81 |
ImageMapL();
|
sl@0
|
82 |
RecordTestResultL();
|
sl@0
|
83 |
CloseTMSGraphicsStep();
|
sl@0
|
84 |
return TestStepResult();
|
sl@0
|
85 |
#endif
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
Helper function.
|
sl@0
|
91 |
Creates and destroys images of the same size KIterationsToTest times.
|
sl@0
|
92 |
|
sl@0
|
93 |
@param aWidth The width of the created bitmaps.
|
sl@0
|
94 |
@param aHeight The height of the created bitmaps.
|
sl@0
|
95 |
@param aTestDescription The description of the test.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
void CTGraphicsResource::ImageCreationSimpleL(const TInt aWidth, const TInt aHeight, const TDesC& aTestDescription)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
iImageInfo.iSizeInPixels = TSize(aWidth, aHeight);
|
sl@0
|
100 |
TInt sizeInBytes = aWidth*aHeight*2;
|
sl@0
|
101 |
RSgImage image;
|
sl@0
|
102 |
|
sl@0
|
103 |
iProfiler->InitResults();
|
sl@0
|
104 |
for(TInt count=KIterationsToTest; count>=0; --count)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
TInt err = image.Create(iImageInfo, NULL, 0);
|
sl@0
|
107 |
TESTL(err == KErrNone);
|
sl@0
|
108 |
MSgImage_Sw* data;
|
sl@0
|
109 |
TESTNOERRORL(image.GetInterface(data));
|
sl@0
|
110 |
Mem::Fill(data->DataAddress(), sizeInBytes, 0xFF);
|
sl@0
|
111 |
image.Close();
|
sl@0
|
112 |
iProfiler->MarkResultSetL();
|
sl@0
|
113 |
}
|
sl@0
|
114 |
iProfiler->ResultsAnalysis(aTestDescription, TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
@SYMTestCaseID
|
sl@0
|
119 |
GRAPHICS-UI-BENCH-0089
|
sl@0
|
120 |
|
sl@0
|
121 |
@SYMPREQ PREQ39
|
sl@0
|
122 |
|
sl@0
|
123 |
@SYMREQ REQ9236
|
sl@0
|
124 |
@SYMREQ REQ9237
|
sl@0
|
125 |
|
sl@0
|
126 |
@SYMTestCaseDesc
|
sl@0
|
127 |
The test determines how long it takes to create and destroy small simple RSgImage objects.
|
sl@0
|
128 |
|
sl@0
|
129 |
@SYMTestActions
|
sl@0
|
130 |
Compare the results over time, and before and after changes to image construction and destruction code.
|
sl@0
|
131 |
|
sl@0
|
132 |
@SYMTestExpectedResults
|
sl@0
|
133 |
Test should pass and display total test time and time per image
|
sl@0
|
134 |
*/
|
sl@0
|
135 |
void CTGraphicsResource::SmallImageCreationSimpleL()
|
sl@0
|
136 |
{
|
sl@0
|
137 |
ImageCreationSimpleL(32, 32, _L("Small-RSgImage-Create-64K-Simple"));
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
/**
|
sl@0
|
141 |
@SYMTestCaseID
|
sl@0
|
142 |
GRAPHICS-UI-BENCH-0090
|
sl@0
|
143 |
|
sl@0
|
144 |
@SYMPREQ PREQ39
|
sl@0
|
145 |
|
sl@0
|
146 |
@SYMREQ REQ9236
|
sl@0
|
147 |
@SYMREQ REQ9237
|
sl@0
|
148 |
|
sl@0
|
149 |
@SYMTestCaseDesc
|
sl@0
|
150 |
The test determines how long it takes to create and destroy large simple RSgImage objects.
|
sl@0
|
151 |
|
sl@0
|
152 |
@SYMTestActions
|
sl@0
|
153 |
Compare the results over time, and before and after changes to image construction and destruction code.
|
sl@0
|
154 |
|
sl@0
|
155 |
@SYMTestExpectedResults
|
sl@0
|
156 |
Test should pass and display total test time and time per image
|
sl@0
|
157 |
*/
|
sl@0
|
158 |
void CTGraphicsResource::LargeImageCreationSimpleL()
|
sl@0
|
159 |
{
|
sl@0
|
160 |
ImageCreationSimpleL(500, 500, _L("Large-RSgImage-Create-64K-Simple"));
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
/**
|
sl@0
|
164 |
@SYMTestCaseID
|
sl@0
|
165 |
GRAPHICS-UI-BENCH-0091
|
sl@0
|
166 |
|
sl@0
|
167 |
@SYMPREQ PREQ39
|
sl@0
|
168 |
|
sl@0
|
169 |
@SYMREQ REQ9236
|
sl@0
|
170 |
@SYMREQ REQ9237
|
sl@0
|
171 |
|
sl@0
|
172 |
@SYMTestCaseDesc
|
sl@0
|
173 |
Tests how long it takes to duplicate an RSgImage.
|
sl@0
|
174 |
|
sl@0
|
175 |
@SYMTestActions
|
sl@0
|
176 |
Compare the results over time, and before and after changes to bitmap duplication code.
|
sl@0
|
177 |
|
sl@0
|
178 |
@SYMTestExpectedResults
|
sl@0
|
179 |
Test should pass and display total test time and time per image.
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
void CTGraphicsResource::ImageDuplicateL()
|
sl@0
|
182 |
{
|
sl@0
|
183 |
//prepare an image to duplicate
|
sl@0
|
184 |
iImageInfo.iSizeInPixels = TSize(300, 300);
|
sl@0
|
185 |
|
sl@0
|
186 |
RSgImage image;
|
sl@0
|
187 |
TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
|
sl@0
|
188 |
TESTL(err == KErrNone);
|
sl@0
|
189 |
|
sl@0
|
190 |
iProfiler->InitResults();
|
sl@0
|
191 |
for(TInt count=KIterationsToTest; count>=0; --count)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
RSgImage image2;
|
sl@0
|
194 |
err = image2.Create(iImageInfo, image);
|
sl@0
|
195 |
TESTL(err == KErrNone);
|
sl@0
|
196 |
image2.Close();
|
sl@0
|
197 |
iProfiler->MarkResultSetL();
|
sl@0
|
198 |
}
|
sl@0
|
199 |
iProfiler->ResultsAnalysis(_L("RSgImage-Duplicate "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
|
sl@0
|
200 |
|
sl@0
|
201 |
image.Close();
|
sl@0
|
202 |
}
|
sl@0
|
203 |
|
sl@0
|
204 |
/**
|
sl@0
|
205 |
@SYMTestCaseID
|
sl@0
|
206 |
GRAPHICS-UI-BENCH-0092
|
sl@0
|
207 |
|
sl@0
|
208 |
@SYMPREQ PREQ39
|
sl@0
|
209 |
|
sl@0
|
210 |
@SYMREQ REQ9236
|
sl@0
|
211 |
@SYMREQ REQ9237
|
sl@0
|
212 |
|
sl@0
|
213 |
@SYMTestCaseDesc
|
sl@0
|
214 |
Tests how long it takes to duplicate an image handle.
|
sl@0
|
215 |
|
sl@0
|
216 |
@SYMTestActions
|
sl@0
|
217 |
Compare the results over time, and before and after changes to image duplication code.
|
sl@0
|
218 |
|
sl@0
|
219 |
@SYMTestExpectedResults
|
sl@0
|
220 |
Test should pass and display total test time and time per image.
|
sl@0
|
221 |
*/
|
sl@0
|
222 |
void CTGraphicsResource::ImageDuplicateHandleL()
|
sl@0
|
223 |
{
|
sl@0
|
224 |
//prepare an image to duplicate
|
sl@0
|
225 |
iImageInfo.iSizeInPixels = TSize(300, 300);
|
sl@0
|
226 |
|
sl@0
|
227 |
RSgImage image;
|
sl@0
|
228 |
TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
|
sl@0
|
229 |
TESTL(err == KErrNone);
|
sl@0
|
230 |
TSgDrawableId id = image.Id();
|
sl@0
|
231 |
|
sl@0
|
232 |
iProfiler->InitResults();
|
sl@0
|
233 |
for(TInt count=KIterationsToTest; count>=0; --count)
|
sl@0
|
234 |
{
|
sl@0
|
235 |
RSgImage image2;
|
sl@0
|
236 |
err = image2.Open(id);
|
sl@0
|
237 |
TESTL(KErrNone == err);
|
sl@0
|
238 |
image2.Close();
|
sl@0
|
239 |
iProfiler->MarkResultSetL();
|
sl@0
|
240 |
}
|
sl@0
|
241 |
iProfiler->ResultsAnalysis(_L("RSgImage-Duplicate-Handle"), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
|
sl@0
|
242 |
|
sl@0
|
243 |
image.Close();
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
/**
|
sl@0
|
247 |
@SYMTestCaseID
|
sl@0
|
248 |
GRAPHICS-UI-BENCH-0093
|
sl@0
|
249 |
|
sl@0
|
250 |
@SYMPREQ PREQ39
|
sl@0
|
251 |
|
sl@0
|
252 |
@SYMREQ REQ9236
|
sl@0
|
253 |
@SYMREQ REQ9237
|
sl@0
|
254 |
|
sl@0
|
255 |
@SYMTestCaseDesc
|
sl@0
|
256 |
Measure performance of Map() and Unmap() of an RSgImage.
|
sl@0
|
257 |
|
sl@0
|
258 |
@SYMTestActions
|
sl@0
|
259 |
Compare the results over time, and before and after changes to image mapping code.
|
sl@0
|
260 |
|
sl@0
|
261 |
@SYMTestExpectedResults
|
sl@0
|
262 |
Test should pass and display total test time and time per image.
|
sl@0
|
263 |
*/
|
sl@0
|
264 |
void CTGraphicsResource::ImageMapL()
|
sl@0
|
265 |
{
|
sl@0
|
266 |
//prepare an image
|
sl@0
|
267 |
iImageInfo.iSizeInPixels = TSize(300, 300);
|
sl@0
|
268 |
|
sl@0
|
269 |
RSgImage image;
|
sl@0
|
270 |
TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
|
sl@0
|
271 |
TESTL(err == KErrNone);
|
sl@0
|
272 |
|
sl@0
|
273 |
const TAny* dataAddressRead;
|
sl@0
|
274 |
TAny* dataAddressWrite;
|
sl@0
|
275 |
TInt dataStride;
|
sl@0
|
276 |
|
sl@0
|
277 |
iProfiler->InitResults();
|
sl@0
|
278 |
for(TInt count=KIterationsToTest; count>=0; --count)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
err = image.MapReadOnly(dataAddressRead, dataStride);
|
sl@0
|
281 |
TESTL(err == KErrNone);
|
sl@0
|
282 |
image.Unmap();
|
sl@0
|
283 |
iProfiler->MarkResultSetL();
|
sl@0
|
284 |
}
|
sl@0
|
285 |
iProfiler->ResultsAnalysis(_L("RSgImage-MapReadOnly "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
|
sl@0
|
286 |
|
sl@0
|
287 |
iProfiler->InitResults();
|
sl@0
|
288 |
for(TInt count=KIterationsToTest; count>=0; --count)
|
sl@0
|
289 |
{
|
sl@0
|
290 |
err = image.MapWriteOnly(dataAddressWrite, dataStride);
|
sl@0
|
291 |
TESTL(err == KErrNone);
|
sl@0
|
292 |
image.Unmap();
|
sl@0
|
293 |
iProfiler->MarkResultSetL();
|
sl@0
|
294 |
}
|
sl@0
|
295 |
iProfiler->ResultsAnalysis(_L("RSgImage-MapWriteOnly "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
|
sl@0
|
296 |
|
sl@0
|
297 |
iProfiler->InitResults();
|
sl@0
|
298 |
for(TInt count=KIterationsToTest; count>=0; --count)
|
sl@0
|
299 |
{
|
sl@0
|
300 |
err = image.MapReadWrite(dataAddressWrite, dataStride);
|
sl@0
|
301 |
TESTL(err == KErrNone);
|
sl@0
|
302 |
image.Unmap();
|
sl@0
|
303 |
iProfiler->MarkResultSetL();
|
sl@0
|
304 |
}
|
sl@0
|
305 |
iProfiler->ResultsAnalysis(_L("RSgImage-MapReadWrite "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
|
sl@0
|
306 |
|
sl@0
|
307 |
image.Close();
|
sl@0
|
308 |
}
|
sl@0
|
309 |
#endif
|