First public contribution.
1 // Copyright (c) 2005-2009 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.
19 @internalComponent - Internal Symbian test code
22 #include "tgraphicsresource.h"
23 #include "tdirectgditestbase.h"
24 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
25 #include <graphics/sgimage_sw.h>
28 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
29 const TInt KIterationsToTest = 1000;
32 CTGraphicsResource::CTGraphicsResource()
34 SetTestStepName(KTGraphicsResource);
36 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
37 iImageInfo.iCpuAccess = ESgCpuAccessReadWrite;
38 iImageInfo.iUsage = ESgUsageDirectGdiSource;
39 iImageInfo.iPixelFormat = EUidPixelFormatRGB_565;
40 iImageInfo.iShareable = ETrue;
42 Mem::FillZ(iImageData, KMaxArraySize * sizeof(TUint16));
43 TEST(KErrNone == SgDriver::Open());
47 CTGraphicsResource::~CTGraphicsResource()
49 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
50 TInt temp = SgDriver::ResourceCount();
56 Override of base class pure virtual
57 Our implementation only gets called if the base class doTestStepPreambleL() did
58 not leave. That being the case, the current test result value will be EPass.
60 @return - TVerdict code
62 TVerdict CTGraphicsResource::doTestStepL()
64 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
65 INFO_PRINTF1(_L("CTGraphicsResource can only be run with RSgImage legacy"));
66 return TestStepResult();
68 SetTestStepID(_L("GRAPHICS-UI-BENCH-0089"));
69 SmallImageCreationSimpleL();
71 SetTestStepID(_L("GRAPHICS-UI-BENCH-0090"));
72 LargeImageCreationSimpleL();
74 SetTestStepID(_L("GRAPHICS-UI-BENCH-0091"));
77 SetTestStepID(_L("GRAPHICS-UI-BENCH-0092"));
78 ImageDuplicateHandleL();
80 SetTestStepID(_L("GRAPHICS-UI-BENCH-0093"));
83 CloseTMSGraphicsStep();
84 return TestStepResult();
88 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
91 Creates and destroys images of the same size KIterationsToTest times.
93 @param aWidth The width of the created bitmaps.
94 @param aHeight The height of the created bitmaps.
95 @param aTestDescription The description of the test.
97 void CTGraphicsResource::ImageCreationSimpleL(const TInt aWidth, const TInt aHeight, const TDesC& aTestDescription)
99 iImageInfo.iSizeInPixels = TSize(aWidth, aHeight);
100 TInt sizeInBytes = aWidth*aHeight*2;
103 iProfiler->InitResults();
104 for(TInt count=KIterationsToTest; count>=0; --count)
106 TInt err = image.Create(iImageInfo, NULL, 0);
107 TESTL(err == KErrNone);
109 TESTNOERRORL(image.GetInterface(data));
110 Mem::Fill(data->DataAddress(), sizeInBytes, 0xFF);
112 iProfiler->MarkResultSetL();
114 iProfiler->ResultsAnalysis(aTestDescription, TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
119 GRAPHICS-UI-BENCH-0089
127 The test determines how long it takes to create and destroy small simple RSgImage objects.
130 Compare the results over time, and before and after changes to image construction and destruction code.
132 @SYMTestExpectedResults
133 Test should pass and display total test time and time per image
135 void CTGraphicsResource::SmallImageCreationSimpleL()
137 ImageCreationSimpleL(32, 32, _L("Small-RSgImage-Create-64K-Simple"));
142 GRAPHICS-UI-BENCH-0090
150 The test determines how long it takes to create and destroy large simple RSgImage objects.
153 Compare the results over time, and before and after changes to image construction and destruction code.
155 @SYMTestExpectedResults
156 Test should pass and display total test time and time per image
158 void CTGraphicsResource::LargeImageCreationSimpleL()
160 ImageCreationSimpleL(500, 500, _L("Large-RSgImage-Create-64K-Simple"));
165 GRAPHICS-UI-BENCH-0091
173 Tests how long it takes to duplicate an RSgImage.
176 Compare the results over time, and before and after changes to bitmap duplication code.
178 @SYMTestExpectedResults
179 Test should pass and display total test time and time per image.
181 void CTGraphicsResource::ImageDuplicateL()
183 //prepare an image to duplicate
184 iImageInfo.iSizeInPixels = TSize(300, 300);
187 TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
188 TESTL(err == KErrNone);
190 iProfiler->InitResults();
191 for(TInt count=KIterationsToTest; count>=0; --count)
194 err = image2.Create(iImageInfo, image);
195 TESTL(err == KErrNone);
197 iProfiler->MarkResultSetL();
199 iProfiler->ResultsAnalysis(_L("RSgImage-Duplicate "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
206 GRAPHICS-UI-BENCH-0092
214 Tests how long it takes to duplicate an image handle.
217 Compare the results over time, and before and after changes to image duplication code.
219 @SYMTestExpectedResults
220 Test should pass and display total test time and time per image.
222 void CTGraphicsResource::ImageDuplicateHandleL()
224 //prepare an image to duplicate
225 iImageInfo.iSizeInPixels = TSize(300, 300);
228 TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
229 TESTL(err == KErrNone);
230 TSgDrawableId id = image.Id();
232 iProfiler->InitResults();
233 for(TInt count=KIterationsToTest; count>=0; --count)
236 err = image2.Open(id);
237 TESTL(KErrNone == err);
239 iProfiler->MarkResultSetL();
241 iProfiler->ResultsAnalysis(_L("RSgImage-Duplicate-Handle"), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
248 GRAPHICS-UI-BENCH-0093
256 Measure performance of Map() and Unmap() of an RSgImage.
259 Compare the results over time, and before and after changes to image mapping code.
261 @SYMTestExpectedResults
262 Test should pass and display total test time and time per image.
264 void CTGraphicsResource::ImageMapL()
267 iImageInfo.iSizeInPixels = TSize(300, 300);
270 TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
271 TESTL(err == KErrNone);
273 const TAny* dataAddressRead;
274 TAny* dataAddressWrite;
277 iProfiler->InitResults();
278 for(TInt count=KIterationsToTest; count>=0; --count)
280 err = image.MapReadOnly(dataAddressRead, dataStride);
281 TESTL(err == KErrNone);
283 iProfiler->MarkResultSetL();
285 iProfiler->ResultsAnalysis(_L("RSgImage-MapReadOnly "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
287 iProfiler->InitResults();
288 for(TInt count=KIterationsToTest; count>=0; --count)
290 err = image.MapWriteOnly(dataAddressWrite, dataStride);
291 TESTL(err == KErrNone);
293 iProfiler->MarkResultSetL();
295 iProfiler->ResultsAnalysis(_L("RSgImage-MapWriteOnly "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
297 iProfiler->InitResults();
298 for(TInt count=KIterationsToTest; count>=0; --count)
300 err = image.MapReadWrite(dataAddressWrite, dataStride);
301 TESTL(err == KErrNone);
303 iProfiler->MarkResultSetL();
305 iProfiler->ResultsAnalysis(_L("RSgImage-MapReadWrite "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);