1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicstest/uibench/src/tgraphicsresource.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,309 @@
1.4 +// Copyright (c) 2005-2009 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 + @internalComponent - Internal Symbian test code
1.23 +*/
1.24 +
1.25 +#include "tgraphicsresource.h"
1.26 +#include "tdirectgditestbase.h"
1.27 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.28 +#include <graphics/sgimage_sw.h>
1.29 +#endif
1.30 +
1.31 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.32 +const TInt KIterationsToTest = 1000;
1.33 +#endif
1.34 +
1.35 +CTGraphicsResource::CTGraphicsResource()
1.36 + {
1.37 + SetTestStepName(KTGraphicsResource);
1.38 +
1.39 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.40 + iImageInfo.iCpuAccess = ESgCpuAccessReadWrite;
1.41 + iImageInfo.iUsage = ESgUsageDirectGdiSource;
1.42 + iImageInfo.iPixelFormat = EUidPixelFormatRGB_565;
1.43 + iImageInfo.iShareable = ETrue;
1.44 +
1.45 + Mem::FillZ(iImageData, KMaxArraySize * sizeof(TUint16));
1.46 + TEST(KErrNone == SgDriver::Open());
1.47 +#endif
1.48 + }
1.49 +
1.50 +CTGraphicsResource::~CTGraphicsResource()
1.51 + {
1.52 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.53 + TInt temp = SgDriver::ResourceCount();
1.54 + SgDriver::Close();
1.55 +#endif
1.56 + }
1.57 +
1.58 +/**
1.59 +Override of base class pure virtual
1.60 +Our implementation only gets called if the base class doTestStepPreambleL() did
1.61 +not leave. That being the case, the current test result value will be EPass.
1.62 +
1.63 +@return - TVerdict code
1.64 +*/
1.65 +TVerdict CTGraphicsResource::doTestStepL()
1.66 + {
1.67 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.68 + INFO_PRINTF1(_L("CTGraphicsResource can only be run with RSgImage legacy"));
1.69 + return TestStepResult();
1.70 +#else
1.71 + SetTestStepID(_L("GRAPHICS-UI-BENCH-0089"));
1.72 + SmallImageCreationSimpleL();
1.73 + RecordTestResultL();
1.74 + SetTestStepID(_L("GRAPHICS-UI-BENCH-0090"));
1.75 + LargeImageCreationSimpleL();
1.76 + RecordTestResultL();
1.77 + SetTestStepID(_L("GRAPHICS-UI-BENCH-0091"));
1.78 + ImageDuplicateL();
1.79 + RecordTestResultL();
1.80 + SetTestStepID(_L("GRAPHICS-UI-BENCH-0092"));
1.81 + ImageDuplicateHandleL();
1.82 + RecordTestResultL();
1.83 + SetTestStepID(_L("GRAPHICS-UI-BENCH-0093"));
1.84 + ImageMapL();
1.85 + RecordTestResultL();
1.86 + CloseTMSGraphicsStep();
1.87 + return TestStepResult();
1.88 +#endif
1.89 + }
1.90 +
1.91 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1.92 +/**
1.93 +Helper function.
1.94 +Creates and destroys images of the same size KIterationsToTest times.
1.95 +
1.96 +@param aWidth The width of the created bitmaps.
1.97 +@param aHeight The height of the created bitmaps.
1.98 +@param aTestDescription The description of the test.
1.99 +*/
1.100 +void CTGraphicsResource::ImageCreationSimpleL(const TInt aWidth, const TInt aHeight, const TDesC& aTestDescription)
1.101 + {
1.102 + iImageInfo.iSizeInPixels = TSize(aWidth, aHeight);
1.103 + TInt sizeInBytes = aWidth*aHeight*2;
1.104 + RSgImage image;
1.105 +
1.106 + iProfiler->InitResults();
1.107 + for(TInt count=KIterationsToTest; count>=0; --count)
1.108 + {
1.109 + TInt err = image.Create(iImageInfo, NULL, 0);
1.110 + TESTL(err == KErrNone);
1.111 + MSgImage_Sw* data;
1.112 + TESTNOERRORL(image.GetInterface(data));
1.113 + Mem::Fill(data->DataAddress(), sizeInBytes, 0xFF);
1.114 + image.Close();
1.115 + iProfiler->MarkResultSetL();
1.116 + }
1.117 + iProfiler->ResultsAnalysis(aTestDescription, TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
1.118 + }
1.119 +
1.120 +/**
1.121 +@SYMTestCaseID
1.122 +GRAPHICS-UI-BENCH-0089
1.123 +
1.124 +@SYMPREQ PREQ39
1.125 +
1.126 +@SYMREQ REQ9236
1.127 +@SYMREQ REQ9237
1.128 +
1.129 +@SYMTestCaseDesc
1.130 +The test determines how long it takes to create and destroy small simple RSgImage objects.
1.131 +
1.132 +@SYMTestActions
1.133 +Compare the results over time, and before and after changes to image construction and destruction code.
1.134 +
1.135 +@SYMTestExpectedResults
1.136 +Test should pass and display total test time and time per image
1.137 +*/
1.138 +void CTGraphicsResource::SmallImageCreationSimpleL()
1.139 + {
1.140 + ImageCreationSimpleL(32, 32, _L("Small-RSgImage-Create-64K-Simple"));
1.141 + }
1.142 +
1.143 +/**
1.144 +@SYMTestCaseID
1.145 +GRAPHICS-UI-BENCH-0090
1.146 +
1.147 +@SYMPREQ PREQ39
1.148 +
1.149 +@SYMREQ REQ9236
1.150 +@SYMREQ REQ9237
1.151 +
1.152 +@SYMTestCaseDesc
1.153 +The test determines how long it takes to create and destroy large simple RSgImage objects.
1.154 +
1.155 +@SYMTestActions
1.156 +Compare the results over time, and before and after changes to image construction and destruction code.
1.157 +
1.158 +@SYMTestExpectedResults
1.159 +Test should pass and display total test time and time per image
1.160 +*/
1.161 +void CTGraphicsResource::LargeImageCreationSimpleL()
1.162 + {
1.163 + ImageCreationSimpleL(500, 500, _L("Large-RSgImage-Create-64K-Simple"));
1.164 + }
1.165 +
1.166 +/**
1.167 +@SYMTestCaseID
1.168 +GRAPHICS-UI-BENCH-0091
1.169 +
1.170 +@SYMPREQ PREQ39
1.171 +
1.172 +@SYMREQ REQ9236
1.173 +@SYMREQ REQ9237
1.174 +
1.175 +@SYMTestCaseDesc
1.176 +Tests how long it takes to duplicate an RSgImage.
1.177 +
1.178 +@SYMTestActions
1.179 +Compare the results over time, and before and after changes to bitmap duplication code.
1.180 +
1.181 +@SYMTestExpectedResults
1.182 +Test should pass and display total test time and time per image.
1.183 +*/
1.184 +void CTGraphicsResource::ImageDuplicateL()
1.185 + {
1.186 + //prepare an image to duplicate
1.187 + iImageInfo.iSizeInPixels = TSize(300, 300);
1.188 +
1.189 + RSgImage image;
1.190 + TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
1.191 + TESTL(err == KErrNone);
1.192 +
1.193 + iProfiler->InitResults();
1.194 + for(TInt count=KIterationsToTest; count>=0; --count)
1.195 + {
1.196 + RSgImage image2;
1.197 + err = image2.Create(iImageInfo, image);
1.198 + TESTL(err == KErrNone);
1.199 + image2.Close();
1.200 + iProfiler->MarkResultSetL();
1.201 + }
1.202 + iProfiler->ResultsAnalysis(_L("RSgImage-Duplicate "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
1.203 +
1.204 + image.Close();
1.205 + }
1.206 +
1.207 +/**
1.208 +@SYMTestCaseID
1.209 +GRAPHICS-UI-BENCH-0092
1.210 +
1.211 +@SYMPREQ PREQ39
1.212 +
1.213 +@SYMREQ REQ9236
1.214 +@SYMREQ REQ9237
1.215 +
1.216 +@SYMTestCaseDesc
1.217 +Tests how long it takes to duplicate an image handle.
1.218 +
1.219 +@SYMTestActions
1.220 +Compare the results over time, and before and after changes to image duplication code.
1.221 +
1.222 +@SYMTestExpectedResults
1.223 +Test should pass and display total test time and time per image.
1.224 +*/
1.225 +void CTGraphicsResource::ImageDuplicateHandleL()
1.226 + {
1.227 + //prepare an image to duplicate
1.228 + iImageInfo.iSizeInPixels = TSize(300, 300);
1.229 +
1.230 + RSgImage image;
1.231 + TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
1.232 + TESTL(err == KErrNone);
1.233 + TSgDrawableId id = image.Id();
1.234 +
1.235 + iProfiler->InitResults();
1.236 + for(TInt count=KIterationsToTest; count>=0; --count)
1.237 + {
1.238 + RSgImage image2;
1.239 + err = image2.Open(id);
1.240 + TESTL(KErrNone == err);
1.241 + image2.Close();
1.242 + iProfiler->MarkResultSetL();
1.243 + }
1.244 + iProfiler->ResultsAnalysis(_L("RSgImage-Duplicate-Handle"), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
1.245 +
1.246 + image.Close();
1.247 + }
1.248 +
1.249 +/**
1.250 +@SYMTestCaseID
1.251 +GRAPHICS-UI-BENCH-0093
1.252 +
1.253 +@SYMPREQ PREQ39
1.254 +
1.255 +@SYMREQ REQ9236
1.256 +@SYMREQ REQ9237
1.257 +
1.258 +@SYMTestCaseDesc
1.259 +Measure performance of Map() and Unmap() of an RSgImage.
1.260 +
1.261 +@SYMTestActions
1.262 +Compare the results over time, and before and after changes to image mapping code.
1.263 +
1.264 +@SYMTestExpectedResults
1.265 +Test should pass and display total test time and time per image.
1.266 +*/
1.267 +void CTGraphicsResource::ImageMapL()
1.268 + {
1.269 + //prepare an image
1.270 + iImageInfo.iSizeInPixels = TSize(300, 300);
1.271 +
1.272 + RSgImage image;
1.273 + TInt err = image.Create(iImageInfo, iImageData, KImageDataStride);
1.274 + TESTL(err == KErrNone);
1.275 +
1.276 + const TAny* dataAddressRead;
1.277 + TAny* dataAddressWrite;
1.278 + TInt dataStride;
1.279 +
1.280 + iProfiler->InitResults();
1.281 + for(TInt count=KIterationsToTest; count>=0; --count)
1.282 + {
1.283 + err = image.MapReadOnly(dataAddressRead, dataStride);
1.284 + TESTL(err == KErrNone);
1.285 + image.Unmap();
1.286 + iProfiler->MarkResultSetL();
1.287 + }
1.288 + iProfiler->ResultsAnalysis(_L("RSgImage-MapReadOnly "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
1.289 +
1.290 + iProfiler->InitResults();
1.291 + for(TInt count=KIterationsToTest; count>=0; --count)
1.292 + {
1.293 + err = image.MapWriteOnly(dataAddressWrite, dataStride);
1.294 + TESTL(err == KErrNone);
1.295 + image.Unmap();
1.296 + iProfiler->MarkResultSetL();
1.297 + }
1.298 + iProfiler->ResultsAnalysis(_L("RSgImage-MapWriteOnly "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
1.299 +
1.300 + iProfiler->InitResults();
1.301 + for(TInt count=KIterationsToTest; count>=0; --count)
1.302 + {
1.303 + err = image.MapReadWrite(dataAddressWrite, dataStride);
1.304 + TESTL(err == KErrNone);
1.305 + image.Unmap();
1.306 + iProfiler->MarkResultSetL();
1.307 + }
1.308 + iProfiler->ResultsAnalysis(_L("RSgImage-MapReadWrite "), TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat), 0, 0, KIterationsToTest);
1.309 +
1.310 + image.Close();
1.311 + }
1.312 +#endif