sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "toptimisedbmp.h" sl@0: #include "fbsmessage.h" sl@0: #include sl@0: #include sl@0: sl@0: // The following line must be disabled for testing with the background compression code sl@0: // When enabled foreground bitmap compression will take place. sl@0: // #define FORCE_FOREGROUND_COMPRESSION sl@0: sl@0: // Number of times to repeat the tests sl@0: const TInt KRepeatTestCount = 100; sl@0: sl@0: // The source bitmaps, only use the bitmaps from UIBENCH sl@0: _LIT( KmbmFilesInRom, "z:\\system\\data\\uibench_*.mbm" ); sl@0: sl@0: // The 16bit rle compressed source bitmap on Z drive sl@0: _LIT( Kmbm16bppRleComprFileInRom, "z:\\system\\data\\rlecompr_16bpp.mbm" ); sl@0: sl@0: // The 32bit alpha rle compressed source bitmap on Z drive sl@0: _LIT( Kmbm32abppRleComprFileInRom, "z:\\system\\data\\rlecompr_32abpp.mbm" ); sl@0: sl@0: // The 16bit rle compressed source bitmap on C drive sl@0: _LIT( Kmbm16bppRleComprFileOnC, "c:\\compressedBitmaps\\rlecompr_16bpp.mbm" ); sl@0: sl@0: #ifdef _DEBUG sl@0: // The 32bit alpha rle compressed source bitmap on C drive sl@0: _LIT( Kmbm32abppRleComprFileOnC, "c:\\compressedBitmaps\\rlecompr_32abpp.mbm" ); sl@0: #endif sl@0: sl@0: // The resouce mbm file sl@0: _LIT( KmbmResouceFile, "z:\\resource\\32bit20col.mbm" ); sl@0: sl@0: // The directory to copy the bitmaps to sl@0: _LIT( KDirectoryFilesOnC , "c:\\bitmapOptimisation\\" ); sl@0: sl@0: // The directory to copy the compressed bitmaps to sl@0: _LIT( KDirectoryComprBmpFilesOnC , "c:\\compressedBitmaps\\" ); sl@0: sl@0: CTOptimisedBmp::CTOptimisedBmp() sl@0: { sl@0: SetTestStepName(KTOptimisedBmpStep); sl@0: } sl@0: sl@0: CTOptimisedBmp::~CTOptimisedBmp() sl@0: { sl@0: // clear test files sl@0: if (iFileMan) sl@0: { sl@0: TBuf <255> filePath; sl@0: _LIT(KFormat, "%S*.mbm"); sl@0: filePath.Format(KFormat, &KDirectoryFilesOnC); sl@0: iFileMan->Delete(filePath); sl@0: sl@0: //remove filepath for compressed bitmap sl@0: filePath.Format(KFormat, &KDirectoryComprBmpFilesOnC); sl@0: iFileMan->Delete(filePath); sl@0: sl@0: delete iFileMan; sl@0: } sl@0: iFs.RmDir(KDirectoryFilesOnC); sl@0: sl@0: //remove directory for compressed bitmap sl@0: iFs.RmDir(KDirectoryComprBmpFilesOnC); sl@0: iFs.Close(); sl@0: } sl@0: sl@0: /** sl@0: Override of base class virtual sl@0: sl@0: @return - TVerdict code sl@0: */ sl@0: TVerdict CTOptimisedBmp::doTestStepPreambleL() sl@0: { sl@0: CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); sl@0: sl@0: // copy all of the files in ROM z: to c: sl@0: TInt err = iFs.Connect(); sl@0: User::LeaveIfError(err); sl@0: iFs.ShareProtected(); sl@0: err = iFs.MkDir(KDirectoryFilesOnC); sl@0: if (err != KErrNone && err != KErrAlreadyExists) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: sl@0: //create directory to store rle-compressed bitmap sl@0: err = iFs.MkDir(KDirectoryComprBmpFilesOnC); sl@0: if (err != KErrNone && err != KErrAlreadyExists) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: sl@0: iFileMan = CFileMan::NewL( iFs ); sl@0: sl@0: err = iFileMan->Copy( KmbmFilesInRom, KDirectoryFilesOnC ); sl@0: TESTL(err == KErrNone); sl@0: sl@0: //Copying compressed mbm files to C drive sl@0: err = iFileMan->Copy( Kmbm16bppRleComprFileInRom, KDirectoryComprBmpFilesOnC ); sl@0: TESTL(err == KErrNone); sl@0: sl@0: err = iFileMan->Copy( Kmbm32abppRleComprFileInRom, KDirectoryComprBmpFilesOnC ); sl@0: TESTL(err == KErrNone); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /** sl@0: Override of base class pure virtual sl@0: Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: not leave. That being the case, the current test result value will be EPass. sl@0: sl@0: @return - TVerdict code sl@0: */ sl@0: TVerdict CTOptimisedBmp::doTestStepL() sl@0: { sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0021 sl@0: sl@0: @SYMTestCaseDesc sl@0: The test determines how long it takes to compress bitmaps, and how long it takes to bitblt the original and the compressed bitmaps. sl@0: sl@0: @SYMTestActions sl@0: 1. Over a number of iterations, measure time taken to compress a bitmap loaded from mbm file. Each iteration the mbm is loaded from scratch. sl@0: 2. Over a number of iterations, measure time taken to blit an uncompressed bitmap loaded from mbm file. This mbm file is the same as in step 1. sl@0: 3. Over a number of iterations, measure time taken to blit the compressed bitmap loaded from step 1. sl@0: 4. Check that the blits of the uncompressed bitmap and the compressed bitmap are the same. sl@0: sl@0: Each of these steps is performed with various screen display modes and various display modes of the bitmap. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass and display total and per bitmap compression, bitblt for uncompressed and compressed time. sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0021")); sl@0: CompressedBitmapTestL(); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0058 sl@0: sl@0: @SYMTestCaseDesc sl@0: The test determines how long it takes to load 16bpp compressed bitmaps. sl@0: sl@0: @SYMDEF INC095318 sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass and logs the time taken to load compressed bitmap . sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0058")); sl@0: TestDecompressBitmapL(Kmbm16bppRleComprFileOnC, _L("Load-Compressed-Bitmap-16bit")); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0059 sl@0: sl@0: @SYMTestCaseDesc sl@0: The test determines how long it takes to load 32 bpp compressed alpha bitmaps. sl@0: sl@0: @SYMDEF DEF095361 sl@0: sl@0: @SYMTestPriority Low sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass and logs the time taken to load compressed bitmap . sl@0: */ sl@0: #ifdef _DEBUG sl@0: //It uses Heap Allocation failure macro sl@0: //which is supported only for debug mode sl@0: sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0059")); sl@0: TestDecompressBitmapAltL(Kmbm32abppRleComprFileOnC, _L("Load-Compressed-Bitmap-32abit")); sl@0: RecordTestResultL(); sl@0: #endif sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0076")); sl@0: GetScanLineTestL(); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0085 sl@0: sl@0: @SYMTestCaseDesc sl@0: The test determines how long it takes to load a bitmap from the resource folder. sl@0: sl@0: @SYMDEF DEF105049 sl@0: sl@0: @SYMTestPriority Medium sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass and display load time / bitmap. sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0085")); sl@0: ResourceBitmapLoadL(KmbmResouceFile, 0, ETrue, _L("Resouce Bitmap Load")); sl@0: RecordTestResultL(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void CTOptimisedBmp::CompressedBitmapTestL() sl@0: { sl@0: _LIT(KTestName1, "CompressBitmap"); sl@0: _LIT(KTestName2, "BlitUncompressedBitmap"); sl@0: _LIT(KTestName3, "BlitCompressedBitmap"); sl@0: sl@0: // strings for writing target output sl@0: _LIT(KTargetString, "_TGT="); sl@0: _LIT(KSourceString, "_SRC="); sl@0: sl@0: // for each of the files in the directory sl@0: // load, compress & compare size before and after sl@0: TBufC fileName(KDirectoryFilesOnC); sl@0: TInt dirLen = KDirectoryFilesOnC().Length(); sl@0: CDir* fileList; sl@0: TInt err = iFs.GetDir(KDirectoryFilesOnC, KEntryAttNormal, ESortBySize, fileList); sl@0: User::LeaveIfError(err); sl@0: CleanupStack::PushL(fileList); sl@0: sl@0: #ifdef FORCE_FOREGROUND_COMPRESSION sl@0: _LIT(KForceForegroundCompression, "Force Foreground Compression"); sl@0: INFO_PRINTF2(KForceForegroundCompression); sl@0: RFbsSession* fbs = RFbsSession::GetSession(); sl@0: if (!fbs) sl@0: { sl@0: ERR_PRINTF1("Error: fbs cannot be NULL"); sl@0: SetTestStepError(); sl@0: } sl@0: fbs->SendCommand(EFbsCompress, 1); // force to compress the bitmaps in the foreground sl@0: #endif // FORCE_FOREGROUND_COMPRESSION sl@0: sl@0: sl@0: sl@0: CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(fbsBitmap); sl@0: CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(fbsCompressed); sl@0: sl@0: for (TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++) sl@0: { sl@0: SetScreenModeL(KValidDisplayModes[dispModeIndex], ETrue); sl@0: iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal); sl@0: TSize scrSize = iScreenDevice->SizeInPixels(); sl@0: TPoint left(0 ,0); sl@0: TPoint right(scrSize.iWidth / 2, 0); sl@0: for (TInt ii = 0; ii < fileList->Count(); ++ii) sl@0: { sl@0: // Load uncompressed bitmap sl@0: const TEntry entry((*fileList)[ii]); sl@0: TPtr fnamePtr = fileName.Des(); sl@0: fnamePtr.SetLength(dirLen); sl@0: fnamePtr.Append(entry.iName); sl@0: sl@0: err = fbsBitmap->Load(fnamePtr, 0, EFalse); sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error %d loading bitmap (%S)"), err, &fnamePtr); sl@0: fbsBitmap->Reset(); sl@0: continue; sl@0: } sl@0: sl@0: TDisplayMode bitmapDispMode = fbsBitmap->DisplayMode(); //same display mode used for fbsCompressed sl@0: TDisplayMode screenDispMode = iScreenDevice->BitmapDevice().DisplayMode(); sl@0: TInt rpt; sl@0: sl@0: // Test speed of compressing an image sl@0: iProfiler->InitResults(); sl@0: for (rpt = 0; rpt < KRepeatTestCount; ++rpt) sl@0: { sl@0: // Load bitmap to be compressed sl@0: err = fbsCompressed->Load(fnamePtr, 0, EFalse); sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF4(_L("Error %d loading the bitmap (%S), rpt = %d"), err, &fnamePtr, rpt); sl@0: fbsCompressed->Reset(); sl@0: break; sl@0: } sl@0: iProfiler->StartTimer(); sl@0: fbsCompressed->Compress(); sl@0: iProfiler->MarkResultSetL(); sl@0: // on last iteration, don't reset fbsCompressed sl@0: if (rpt < KRepeatTestCount-1) sl@0: { sl@0: fbsCompressed->Reset(); sl@0: } sl@0: } sl@0: iProfiler->ResultsAnalysis(KTestName1, CFbsBitGc::EGraphicsOrientationNormal, bitmapDispMode, screenDispMode, KRepeatTestCount); sl@0: sl@0: // Clip rect size to half-screen width and screen height sl@0: TSize sizeInPixels = fbsBitmap->SizeInPixels(); sl@0: if (sizeInPixels.iWidth > scrSize.iWidth / 2) sl@0: sizeInPixels.iWidth = scrSize.iWidth / 2; sl@0: if (sizeInPixels.iHeight > scrSize.iHeight) sl@0: sizeInPixels.iHeight = scrSize.iHeight; sl@0: TRect blitRect(TPoint(0,0), sizeInPixels); sl@0: TInt numPixels = sizeInPixels.iHeight * sizeInPixels.iWidth; sl@0: sl@0: // Test pixel rate of blitting uncompressed bitmap sl@0: iProfiler->InitResults(); sl@0: for (rpt = 0; rpt < KRepeatTestCount; ++rpt) sl@0: { sl@0: iGc->BitBlt(left, fbsBitmap, blitRect); sl@0: } sl@0: iProfiler->MarkResultSetL(); sl@0: iProfiler->ResultsAnalysisPixelRate(KTestName2, CFbsBitGc::EGraphicsOrientationNormal, bitmapDispMode, screenDispMode, KRepeatTestCount, numPixels); sl@0: sl@0: // Test pixel rate of blitting compressed bitmap sl@0: iProfiler->InitResults(); sl@0: for (rpt = 0; rpt < KRepeatTestCount; ++rpt) sl@0: { sl@0: iGc->BitBlt(right, fbsCompressed, blitRect); sl@0: } sl@0: iProfiler->MarkResultSetL(); sl@0: iProfiler->ResultsAnalysisPixelRate(KTestName3, CFbsBitGc::EGraphicsOrientationNormal, bitmapDispMode, screenDispMode, KRepeatTestCount, numPixels); sl@0: sl@0: // Sanity check that uncompressed and compressed bitmaps display the same sl@0: CBitmapDevice& bmpDevice = iScreenDevice->BitmapDevice(); sl@0: if (iScreenDevice->isScreenDevice()) sl@0: { sl@0: TEST(((CFbsScreenDevice&)bmpDevice).RectCompare(TRect(left, sizeInPixels), (CFbsScreenDevice&)bmpDevice, TRect(right, sizeInPixels))); sl@0: } sl@0: else sl@0: { sl@0: TEST(((CFbsBitmapDevice&)bmpDevice).RectCompare(TRect(left, sizeInPixels), (CFbsBitmapDevice&)bmpDevice, TRect(right, sizeInPixels))); sl@0: } sl@0: fbsBitmap->Reset(); sl@0: fbsCompressed->Reset(); sl@0: sl@0: // Save offscreen bitmap to mbm file sl@0: TBuf testFileName; sl@0: testFileName.Append(KTestName1); sl@0: testFileName.Append(KTargetString); sl@0: TBuf<10> string; sl@0: string.Format(_L("%d"),screenDispMode); sl@0: testFileName.Append(string); sl@0: testFileName.Append(KSourceString); sl@0: string.Format(_L("%d"),bitmapDispMode); sl@0: testFileName.Append(string); sl@0: WriteTargetOutput(testFileName); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3, fileList); // fbsCompressed, fbsBitmap, fileList sl@0: sl@0: #ifdef FORCE_FOREGROUND_COMPRESSION sl@0: fbs->SendCommand(EFbsCompress, 0); // resume normal background compression sl@0: #endif // FORCE_FOREGROUND_COMPRESSION sl@0: } sl@0: sl@0: sl@0: void CTOptimisedBmp::StripeBitmap(CFbsBitmap& aBitmap) // Compression friendly bitmap filling sl@0: { sl@0: TSize size = aBitmap.SizeInPixels(); sl@0: TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight; sl@0: sl@0: aBitmap.LockHeap(); sl@0: TUint8* bmpBits = (TUint8*)aBitmap.DataAddress(); sl@0: aBitmap.UnlockHeap(); sl@0: TUint8* bmpBitsLimit = bmpBits + dataLength; sl@0: TInt64 seed = aBitmap.Handle(); sl@0: sl@0: if (aBitmap.DisplayMode() != EColor4K) sl@0: { sl@0: while (bmpBits < bmpBitsLimit) sl@0: { sl@0: TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed)); sl@0: while (bmpBits < tempBmpBitsLimit) sl@0: *bmpBits++ = 0; sl@0: tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed)); sl@0: while (bmpBits < tempBmpBitsLimit) sl@0: *bmpBits++ = 0xff; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: Mem::FillZ(bmpBits,dataLength); sl@0: sl@0: while (bmpBits < bmpBitsLimit) sl@0: { sl@0: TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)(Math::Rand(seed) * 2)); sl@0: while (bmpBits < tempBmpBitsLimit) sl@0: { sl@0: *bmpBits++ = 0; sl@0: *bmpBits++ = 0; sl@0: } sl@0: tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed)); sl@0: while (bmpBits < tempBmpBitsLimit) sl@0: { sl@0: *bmpBits++ = 0xff; sl@0: *bmpBits++ = 0x0f; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Logs the time taken to load the bitmap file identified by the filename. sl@0: @param aFileName the mbm file that is to be loaded sl@0: @param aTestCaseName the name of the test case sl@0: */ sl@0: void CTOptimisedBmp::TestDecompressBitmapL(const TDesC& aFileName, const TDesC& aTestCaseName) sl@0: { sl@0: TInt err = KErrNone; sl@0: iProfiler->InitResults(); //initializes the timer sl@0: for (TInt rpt = 0; rpt < KRepeatTestCount; ++rpt) sl@0: { sl@0: CFbsBitmap* fbsCompressed = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL( fbsCompressed ); sl@0: sl@0: //Load mbm file identified by aFileName sl@0: err = fbsCompressed->Load( aFileName, 0, EFalse ); //when there is no memory constraints sl@0: TEST(err == KErrNone); sl@0: sl@0: fbsCompressed->Reset(); sl@0: CleanupStack::PopAndDestroy( fbsCompressed ); sl@0: sl@0: iProfiler->MarkResultSetL(); sl@0: } // rpt loop sl@0: sl@0: //Logs the time taken to load the bmp file sl@0: iProfiler->ResultsAnalysis(aTestCaseName, 0, 0, 0, KRepeatTestCount); sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: /** sl@0: This test will only work correctly under UDEB builds of the OS. sl@0: It is same as CTOptimisedBmp::TestDecompressBitmapL function except that it also simulates the sl@0: lack of memory use case while loading bitmap. sl@0: sl@0: @param aFileName the mbm file that is to be loaded sl@0: @param aTestCaseName the name of the test case sl@0: */ sl@0: void CTOptimisedBmp::TestDecompressBitmapAltL(const TDesC& aFileName, const TDesC& aTestCaseName) sl@0: { sl@0: TInt err = KErrNone; sl@0: RFbsSession* fbsSession = RFbsSession::GetSession(); sl@0: if (!fbsSession) sl@0: { sl@0: INFO_PRINTF1(_L("Error: fbs cannot be NULL")); sl@0: ASSERT_NOT_NULL(fbsSession); sl@0: } sl@0: else sl@0: { sl@0: CFbsBitmap* fbsCompressed = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL( fbsCompressed ); sl@0: iProfiler->InitResults(); //initializes the timer sl@0: for (TInt rpt = 0; rpt < KRepeatTestCount; ++rpt) sl@0: { sl@0: //Load mbm file identified by aFileName sl@0: //Consider no memory case sl@0: for (TInt count = 1; ; count++) sl@0: { sl@0: //Explicitly make the memory fails to check how will it loads bmp sl@0: fbsSession->SendCommand(EFbsMessDefaultAllocFail,count); sl@0: fbsSession->SendCommand(EFbsMessDefaultMark); sl@0: fbsSession->SendCommand(EFbsMessUserMark); sl@0: sl@0: err = fbsCompressed->Load( aFileName, 0, EFalse ); sl@0: sl@0: if (err == KErrNoMemory) sl@0: { sl@0: fbsSession->SendCommand(EFbsMessDefaultMarkEnd); sl@0: fbsSession->SendCommand(EFbsMessUserMarkEnd); sl@0: } sl@0: else if (err == KErrNone) sl@0: { sl@0: fbsSession->SendCommand(EFbsMessUserMarkEnd); sl@0: break; sl@0: } sl@0: } sl@0: iProfiler->MarkResultSetL(); sl@0: fbsCompressed->Reset(); sl@0: } // rpt loop sl@0: sl@0: CleanupStack::PopAndDestroy( fbsCompressed ); sl@0: //Logs the time taken to load the bmp file sl@0: iProfiler->ResultsAnalysis(aTestCaseName, 0, 0, 0, KRepeatTestCount); sl@0: } sl@0: } sl@0: #endif sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0076 sl@0: sl@0: @SYMDEF DEF105392 sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests the performance of GetScanLine function for various display modes. sl@0: Also it tests the performance of various GetScanLineColorXX sl@0: (where XX => display mode, for eg. GetScanLineColor64K) sl@0: and TScanLineDecompressor::CopyPixel functions. sl@0: To test the performance of GetScanLineColorXX and other functions for any display mode, it creates sl@0: a bitmap of that display mode and passes it to CTOptimisedBmp::ScanlineTestL function sl@0: along with the display mode which was used for creating it and sl@0: the other display mode which will be used for reading this bitmap while logging the performance. sl@0: @SYMTestActions sl@0: Compare the results over time, and before and after changes to GetScanLine and CopyPixel code. sl@0: @SYMTestExpectedResults sl@0: Test should pass and display average time sl@0: */ sl@0: void CTOptimisedBmp::GetScanLineTestL() sl@0: { sl@0: CFbsBitmap bmp; sl@0: const TSize bmpSize(22,5); sl@0: _LIT(KTestCaseName,"GetScanLine"); sl@0: const TDisplayMode KTestDisplayModes[] = {EColor4K, EColor64K, EColor16M, EColor16MU, EColor16MA, EColor16MAP}; sl@0: const TInt KTestDisplayModeCnt = sizeof(KTestDisplayModes)/sizeof(TDisplayMode); sl@0: sl@0: for(TInt srcDispModeIndex = 0; srcDispModeIndex < KTestDisplayModeCnt; srcDispModeIndex++) sl@0: { sl@0: TDisplayMode displayMode = KTestDisplayModes[srcDispModeIndex]; sl@0: User::LeaveIfError(bmp.Create(bmpSize,displayMode)); sl@0: StripeBitmap(bmp); sl@0: bmp.Compress(); sl@0: for(TInt destDispModeIndex = 0; destDispModeIndex < KTestDisplayModeCnt; destDispModeIndex++) sl@0: { sl@0: ScanlineTestL(bmp,displayMode,KTestDisplayModes[destDispModeIndex],KTestCaseName); sl@0: } sl@0: bmp.Reset(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: It reads a bitmap (aBitmap) of given display mode (aSrcDisplayMode) as a bitmap of sl@0: another display mode (aDestDisplayMode) and logs the performance for it. sl@0: @param aBitmap a bitmap sl@0: @param aSrcDisplayMode The used display mode when bitmap was created. sl@0: It is passed in this function just for logging purpose. sl@0: @param aDestDisplayMode The display mode used for reading the bitmap aBitmap sl@0: @param aTestCaseName The name of the test case sl@0: */ sl@0: void CTOptimisedBmp::ScanlineTestL(const CFbsBitmap& aBitmap, TDisplayMode aSrcDisplayMode, TDisplayMode aDestDisplayMode, const TDesC& aTestCaseName) sl@0: { sl@0: const TSize bmpSize(aBitmap.SizeInPixels()); sl@0: TInt byteWidth = CFbsBitmap::ScanLineLength(bmpSize.iWidth,aDestDisplayMode); sl@0: TUint8* buffer = new (ELeave) TUint8[byteWidth]; sl@0: CleanupStack::PushL(buffer); sl@0: TPtr8 scanLine(buffer,byteWidth,byteWidth); sl@0: sl@0: iProfiler->InitResults(); sl@0: for(TInt count=0;countMarkResultSetL(); sl@0: } sl@0: sl@0: iProfiler->ResultsAnalysis(aTestCaseName, 0, aSrcDisplayMode, aDestDisplayMode, KRepeatTestCount); sl@0: sl@0: CleanupStack::PopAndDestroy(buffer); sl@0: } sl@0: sl@0: /** sl@0: Logs the time taken to load the bitmap file identified by the filename and file id. sl@0: @param aFileName the mbm or rsc file that is to be loaded sl@0: @param aId The bitmap identifier sl@0: @param aShareIfLoaded Specifies whether or not the loaded bitmap will be made available for sharing between font and bitmap server clients. sl@0: @param aTestCaseName the name of the test case sl@0: */ sl@0: void CTOptimisedBmp::ResourceBitmapLoadL(const TDesC& aFileName, TInt32 aId, TBool aShareIfLoaded, const TDesC& aTestCaseName) sl@0: { sl@0: TInt err = KErrNone; sl@0: iProfiler->InitResults(); //initializes the timer sl@0: for (TInt rpt = 0; rpt < KRepeatTestCount; ++rpt) sl@0: { sl@0: CFbsBitmap* resourceBitmap = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(resourceBitmap); sl@0: iProfiler->StartTimer(); sl@0: //Load mbm or rsc file identified by aFileName sl@0: err = resourceBitmap->Load( aFileName, aId, aShareIfLoaded ); //when there is no memory constraints sl@0: iProfiler->MarkResultSetL(); sl@0: TEST(err == KErrNone); sl@0: resourceBitmap->Reset(); sl@0: CleanupStack::PopAndDestroy( resourceBitmap ); sl@0: } sl@0: //Logs the time taken to load the bmp file sl@0: iProfiler->ResultsAnalysis(aTestCaseName, 0, 0, 0, KRepeatTestCount); sl@0: }