|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "toptimisedbmp.h" |
|
23 #include "fbsmessage.h" |
|
24 #include <test/tefunit.h> |
|
25 #include <hal.h> |
|
26 |
|
27 // The following line must be disabled for testing with the background compression code |
|
28 // When enabled foreground bitmap compression will take place. |
|
29 // #define FORCE_FOREGROUND_COMPRESSION |
|
30 |
|
31 // Number of times to repeat the tests |
|
32 const TInt KRepeatTestCount = 100; |
|
33 |
|
34 // The source bitmaps, only use the bitmaps from UIBENCH |
|
35 _LIT( KmbmFilesInRom, "z:\\system\\data\\uibench_*.mbm" ); |
|
36 |
|
37 // The 16bit rle compressed source bitmap on Z drive |
|
38 _LIT( Kmbm16bppRleComprFileInRom, "z:\\system\\data\\rlecompr_16bpp.mbm" ); |
|
39 |
|
40 // The 32bit alpha rle compressed source bitmap on Z drive |
|
41 _LIT( Kmbm32abppRleComprFileInRom, "z:\\system\\data\\rlecompr_32abpp.mbm" ); |
|
42 |
|
43 // The 16bit rle compressed source bitmap on C drive |
|
44 _LIT( Kmbm16bppRleComprFileOnC, "c:\\compressedBitmaps\\rlecompr_16bpp.mbm" ); |
|
45 |
|
46 #ifdef _DEBUG |
|
47 // The 32bit alpha rle compressed source bitmap on C drive |
|
48 _LIT( Kmbm32abppRleComprFileOnC, "c:\\compressedBitmaps\\rlecompr_32abpp.mbm" ); |
|
49 #endif |
|
50 |
|
51 // The resouce mbm file |
|
52 _LIT( KmbmResouceFile, "z:\\resource\\32bit20col.mbm" ); |
|
53 |
|
54 // The directory to copy the bitmaps to |
|
55 _LIT( KDirectoryFilesOnC , "c:\\bitmapOptimisation\\" ); |
|
56 |
|
57 // The directory to copy the compressed bitmaps to |
|
58 _LIT( KDirectoryComprBmpFilesOnC , "c:\\compressedBitmaps\\" ); |
|
59 |
|
60 CTOptimisedBmp::CTOptimisedBmp() |
|
61 { |
|
62 SetTestStepName(KTOptimisedBmpStep); |
|
63 } |
|
64 |
|
65 CTOptimisedBmp::~CTOptimisedBmp() |
|
66 { |
|
67 // clear test files |
|
68 if (iFileMan) |
|
69 { |
|
70 TBuf <255> filePath; |
|
71 _LIT(KFormat, "%S*.mbm"); |
|
72 filePath.Format(KFormat, &KDirectoryFilesOnC); |
|
73 iFileMan->Delete(filePath); |
|
74 |
|
75 //remove filepath for compressed bitmap |
|
76 filePath.Format(KFormat, &KDirectoryComprBmpFilesOnC); |
|
77 iFileMan->Delete(filePath); |
|
78 |
|
79 delete iFileMan; |
|
80 } |
|
81 iFs.RmDir(KDirectoryFilesOnC); |
|
82 |
|
83 //remove directory for compressed bitmap |
|
84 iFs.RmDir(KDirectoryComprBmpFilesOnC); |
|
85 iFs.Close(); |
|
86 } |
|
87 |
|
88 /** |
|
89 Override of base class virtual |
|
90 |
|
91 @return - TVerdict code |
|
92 */ |
|
93 TVerdict CTOptimisedBmp::doTestStepPreambleL() |
|
94 { |
|
95 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); |
|
96 |
|
97 // copy all of the files in ROM z: to c: |
|
98 TInt err = iFs.Connect(); |
|
99 User::LeaveIfError(err); |
|
100 iFs.ShareProtected(); |
|
101 err = iFs.MkDir(KDirectoryFilesOnC); |
|
102 if (err != KErrNone && err != KErrAlreadyExists) |
|
103 { |
|
104 User::Leave(err); |
|
105 } |
|
106 |
|
107 //create directory to store rle-compressed bitmap |
|
108 err = iFs.MkDir(KDirectoryComprBmpFilesOnC); |
|
109 if (err != KErrNone && err != KErrAlreadyExists) |
|
110 { |
|
111 User::Leave(err); |
|
112 } |
|
113 |
|
114 iFileMan = CFileMan::NewL( iFs ); |
|
115 |
|
116 err = iFileMan->Copy( KmbmFilesInRom, KDirectoryFilesOnC ); |
|
117 TESTL(err == KErrNone); |
|
118 |
|
119 //Copying compressed mbm files to C drive |
|
120 err = iFileMan->Copy( Kmbm16bppRleComprFileInRom, KDirectoryComprBmpFilesOnC ); |
|
121 TESTL(err == KErrNone); |
|
122 |
|
123 err = iFileMan->Copy( Kmbm32abppRleComprFileInRom, KDirectoryComprBmpFilesOnC ); |
|
124 TESTL(err == KErrNone); |
|
125 |
|
126 return TestStepResult(); |
|
127 } |
|
128 |
|
129 /** |
|
130 Override of base class pure virtual |
|
131 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
132 not leave. That being the case, the current test result value will be EPass. |
|
133 |
|
134 @return - TVerdict code |
|
135 */ |
|
136 TVerdict CTOptimisedBmp::doTestStepL() |
|
137 { |
|
138 |
|
139 /** |
|
140 @SYMTestCaseID |
|
141 GRAPHICS-UI-BENCH-0021 |
|
142 |
|
143 @SYMTestCaseDesc |
|
144 The test determines how long it takes to compress bitmaps, and how long it takes to bitblt the original and the compressed bitmaps. |
|
145 |
|
146 @SYMTestActions |
|
147 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. |
|
148 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. |
|
149 3. Over a number of iterations, measure time taken to blit the compressed bitmap loaded from step 1. |
|
150 4. Check that the blits of the uncompressed bitmap and the compressed bitmap are the same. |
|
151 |
|
152 Each of these steps is performed with various screen display modes and various display modes of the bitmap. |
|
153 |
|
154 @SYMTestExpectedResults |
|
155 Test should pass and display total and per bitmap compression, bitblt for uncompressed and compressed time. |
|
156 */ |
|
157 SetTestStepID(_L("GRAPHICS-UI-BENCH-0021")); |
|
158 CompressedBitmapTestL(); |
|
159 RecordTestResultL(); |
|
160 |
|
161 /** |
|
162 @SYMTestCaseID |
|
163 GRAPHICS-UI-BENCH-0058 |
|
164 |
|
165 @SYMTestCaseDesc |
|
166 The test determines how long it takes to load 16bpp compressed bitmaps. |
|
167 |
|
168 @SYMDEF INC095318 |
|
169 |
|
170 @SYMTestPriority High |
|
171 |
|
172 @SYMTestActions |
|
173 Compare the results over time. |
|
174 |
|
175 @SYMTestExpectedResults |
|
176 Test should pass and logs the time taken to load compressed bitmap . |
|
177 */ |
|
178 SetTestStepID(_L("GRAPHICS-UI-BENCH-0058")); |
|
179 TestDecompressBitmapL(Kmbm16bppRleComprFileOnC, _L("Load-Compressed-Bitmap-16bit")); |
|
180 RecordTestResultL(); |
|
181 |
|
182 /** |
|
183 @SYMTestCaseID |
|
184 GRAPHICS-UI-BENCH-0059 |
|
185 |
|
186 @SYMTestCaseDesc |
|
187 The test determines how long it takes to load 32 bpp compressed alpha bitmaps. |
|
188 |
|
189 @SYMDEF DEF095361 |
|
190 |
|
191 @SYMTestPriority Low |
|
192 |
|
193 @SYMTestActions |
|
194 Compare the results over time. |
|
195 |
|
196 @SYMTestExpectedResults |
|
197 Test should pass and logs the time taken to load compressed bitmap . |
|
198 */ |
|
199 #ifdef _DEBUG |
|
200 //It uses Heap Allocation failure macro |
|
201 //which is supported only for debug mode |
|
202 |
|
203 SetTestStepID(_L("GRAPHICS-UI-BENCH-0059")); |
|
204 TestDecompressBitmapAltL(Kmbm32abppRleComprFileOnC, _L("Load-Compressed-Bitmap-32abit")); |
|
205 RecordTestResultL(); |
|
206 #endif |
|
207 SetTestStepID(_L("GRAPHICS-UI-BENCH-0076")); |
|
208 GetScanLineTestL(); |
|
209 RecordTestResultL(); |
|
210 |
|
211 /** |
|
212 @SYMTestCaseID |
|
213 GRAPHICS-UI-BENCH-0085 |
|
214 |
|
215 @SYMTestCaseDesc |
|
216 The test determines how long it takes to load a bitmap from the resource folder. |
|
217 |
|
218 @SYMDEF DEF105049 |
|
219 |
|
220 @SYMTestPriority Medium |
|
221 |
|
222 @SYMTestActions |
|
223 Compare the results over time. |
|
224 |
|
225 @SYMTestExpectedResults |
|
226 Test should pass and display load time / bitmap. |
|
227 */ |
|
228 SetTestStepID(_L("GRAPHICS-UI-BENCH-0085")); |
|
229 ResourceBitmapLoadL(KmbmResouceFile, 0, ETrue, _L("Resouce Bitmap Load")); |
|
230 RecordTestResultL(); |
|
231 |
|
232 return TestStepResult(); |
|
233 } |
|
234 |
|
235 void CTOptimisedBmp::CompressedBitmapTestL() |
|
236 { |
|
237 _LIT(KTestName1, "CompressBitmap"); |
|
238 _LIT(KTestName2, "BlitUncompressedBitmap"); |
|
239 _LIT(KTestName3, "BlitCompressedBitmap"); |
|
240 |
|
241 // strings for writing target output |
|
242 _LIT(KTargetString, "_TGT="); |
|
243 _LIT(KSourceString, "_SRC="); |
|
244 |
|
245 // for each of the files in the directory |
|
246 // load, compress & compare size before and after |
|
247 TBufC<KMaxFileName> fileName(KDirectoryFilesOnC); |
|
248 TInt dirLen = KDirectoryFilesOnC().Length(); |
|
249 CDir* fileList; |
|
250 TInt err = iFs.GetDir(KDirectoryFilesOnC, KEntryAttNormal, ESortBySize, fileList); |
|
251 User::LeaveIfError(err); |
|
252 CleanupStack::PushL(fileList); |
|
253 |
|
254 #ifdef FORCE_FOREGROUND_COMPRESSION |
|
255 _LIT(KForceForegroundCompression, "Force Foreground Compression"); |
|
256 INFO_PRINTF2(KForceForegroundCompression); |
|
257 RFbsSession* fbs = RFbsSession::GetSession(); |
|
258 if (!fbs) |
|
259 { |
|
260 ERR_PRINTF1("Error: fbs cannot be NULL"); |
|
261 SetTestStepError(); |
|
262 } |
|
263 fbs->SendCommand(EFbsCompress, 1); // force to compress the bitmaps in the foreground |
|
264 #endif // FORCE_FOREGROUND_COMPRESSION |
|
265 |
|
266 |
|
267 |
|
268 CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap; |
|
269 CleanupStack::PushL(fbsBitmap); |
|
270 CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap; |
|
271 CleanupStack::PushL(fbsCompressed); |
|
272 |
|
273 for (TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++) |
|
274 { |
|
275 SetScreenModeL(KValidDisplayModes[dispModeIndex], ETrue); |
|
276 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal); |
|
277 TSize scrSize = iScreenDevice->SizeInPixels(); |
|
278 TPoint left(0 ,0); |
|
279 TPoint right(scrSize.iWidth / 2, 0); |
|
280 for (TInt ii = 0; ii < fileList->Count(); ++ii) |
|
281 { |
|
282 // Load uncompressed bitmap |
|
283 const TEntry entry((*fileList)[ii]); |
|
284 TPtr fnamePtr = fileName.Des(); |
|
285 fnamePtr.SetLength(dirLen); |
|
286 fnamePtr.Append(entry.iName); |
|
287 |
|
288 err = fbsBitmap->Load(fnamePtr, 0, EFalse); |
|
289 if (err != KErrNone) |
|
290 { |
|
291 INFO_PRINTF3(_L("Error %d loading bitmap (%S)"), err, &fnamePtr); |
|
292 fbsBitmap->Reset(); |
|
293 continue; |
|
294 } |
|
295 |
|
296 TDisplayMode bitmapDispMode = fbsBitmap->DisplayMode(); //same display mode used for fbsCompressed |
|
297 TDisplayMode screenDispMode = iScreenDevice->BitmapDevice().DisplayMode(); |
|
298 TInt rpt; |
|
299 |
|
300 // Test speed of compressing an image |
|
301 iProfiler->InitResults(); |
|
302 for (rpt = 0; rpt < KRepeatTestCount; ++rpt) |
|
303 { |
|
304 // Load bitmap to be compressed |
|
305 err = fbsCompressed->Load(fnamePtr, 0, EFalse); |
|
306 if (err != KErrNone) |
|
307 { |
|
308 INFO_PRINTF4(_L("Error %d loading the bitmap (%S), rpt = %d"), err, &fnamePtr, rpt); |
|
309 fbsCompressed->Reset(); |
|
310 break; |
|
311 } |
|
312 iProfiler->StartTimer(); |
|
313 fbsCompressed->Compress(); |
|
314 iProfiler->MarkResultSetL(); |
|
315 // on last iteration, don't reset fbsCompressed |
|
316 if (rpt < KRepeatTestCount-1) |
|
317 { |
|
318 fbsCompressed->Reset(); |
|
319 } |
|
320 } |
|
321 iProfiler->ResultsAnalysis(KTestName1, CFbsBitGc::EGraphicsOrientationNormal, bitmapDispMode, screenDispMode, KRepeatTestCount); |
|
322 |
|
323 // Clip rect size to half-screen width and screen height |
|
324 TSize sizeInPixels = fbsBitmap->SizeInPixels(); |
|
325 if (sizeInPixels.iWidth > scrSize.iWidth / 2) |
|
326 sizeInPixels.iWidth = scrSize.iWidth / 2; |
|
327 if (sizeInPixels.iHeight > scrSize.iHeight) |
|
328 sizeInPixels.iHeight = scrSize.iHeight; |
|
329 TRect blitRect(TPoint(0,0), sizeInPixels); |
|
330 TInt numPixels = sizeInPixels.iHeight * sizeInPixels.iWidth; |
|
331 |
|
332 // Test pixel rate of blitting uncompressed bitmap |
|
333 iProfiler->InitResults(); |
|
334 for (rpt = 0; rpt < KRepeatTestCount; ++rpt) |
|
335 { |
|
336 iGc->BitBlt(left, fbsBitmap, blitRect); |
|
337 } |
|
338 iProfiler->MarkResultSetL(); |
|
339 iProfiler->ResultsAnalysisPixelRate(KTestName2, CFbsBitGc::EGraphicsOrientationNormal, bitmapDispMode, screenDispMode, KRepeatTestCount, numPixels); |
|
340 |
|
341 // Test pixel rate of blitting compressed bitmap |
|
342 iProfiler->InitResults(); |
|
343 for (rpt = 0; rpt < KRepeatTestCount; ++rpt) |
|
344 { |
|
345 iGc->BitBlt(right, fbsCompressed, blitRect); |
|
346 } |
|
347 iProfiler->MarkResultSetL(); |
|
348 iProfiler->ResultsAnalysisPixelRate(KTestName3, CFbsBitGc::EGraphicsOrientationNormal, bitmapDispMode, screenDispMode, KRepeatTestCount, numPixels); |
|
349 |
|
350 // Sanity check that uncompressed and compressed bitmaps display the same |
|
351 CBitmapDevice& bmpDevice = iScreenDevice->BitmapDevice(); |
|
352 if (iScreenDevice->isScreenDevice()) |
|
353 { |
|
354 TEST(((CFbsScreenDevice&)bmpDevice).RectCompare(TRect(left, sizeInPixels), (CFbsScreenDevice&)bmpDevice, TRect(right, sizeInPixels))); |
|
355 } |
|
356 else |
|
357 { |
|
358 TEST(((CFbsBitmapDevice&)bmpDevice).RectCompare(TRect(left, sizeInPixels), (CFbsBitmapDevice&)bmpDevice, TRect(right, sizeInPixels))); |
|
359 } |
|
360 fbsBitmap->Reset(); |
|
361 fbsCompressed->Reset(); |
|
362 |
|
363 // Save offscreen bitmap to mbm file |
|
364 TBuf<KMaxFileName> testFileName; |
|
365 testFileName.Append(KTestName1); |
|
366 testFileName.Append(KTargetString); |
|
367 TBuf<10> string; |
|
368 string.Format(_L("%d"),screenDispMode); |
|
369 testFileName.Append(string); |
|
370 testFileName.Append(KSourceString); |
|
371 string.Format(_L("%d"),bitmapDispMode); |
|
372 testFileName.Append(string); |
|
373 WriteTargetOutput(testFileName); |
|
374 } |
|
375 } |
|
376 |
|
377 CleanupStack::PopAndDestroy(3, fileList); // fbsCompressed, fbsBitmap, fileList |
|
378 |
|
379 #ifdef FORCE_FOREGROUND_COMPRESSION |
|
380 fbs->SendCommand(EFbsCompress, 0); // resume normal background compression |
|
381 #endif // FORCE_FOREGROUND_COMPRESSION |
|
382 } |
|
383 |
|
384 |
|
385 void CTOptimisedBmp::StripeBitmap(CFbsBitmap& aBitmap) // Compression friendly bitmap filling |
|
386 { |
|
387 TSize size = aBitmap.SizeInPixels(); |
|
388 TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight; |
|
389 |
|
390 aBitmap.LockHeap(); |
|
391 TUint8* bmpBits = (TUint8*)aBitmap.DataAddress(); |
|
392 aBitmap.UnlockHeap(); |
|
393 TUint8* bmpBitsLimit = bmpBits + dataLength; |
|
394 TInt64 seed = aBitmap.Handle(); |
|
395 |
|
396 if (aBitmap.DisplayMode() != EColor4K) |
|
397 { |
|
398 while (bmpBits < bmpBitsLimit) |
|
399 { |
|
400 TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed)); |
|
401 while (bmpBits < tempBmpBitsLimit) |
|
402 *bmpBits++ = 0; |
|
403 tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed)); |
|
404 while (bmpBits < tempBmpBitsLimit) |
|
405 *bmpBits++ = 0xff; |
|
406 } |
|
407 } |
|
408 else |
|
409 { |
|
410 Mem::FillZ(bmpBits,dataLength); |
|
411 |
|
412 while (bmpBits < bmpBitsLimit) |
|
413 { |
|
414 TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)(Math::Rand(seed) * 2)); |
|
415 while (bmpBits < tempBmpBitsLimit) |
|
416 { |
|
417 *bmpBits++ = 0; |
|
418 *bmpBits++ = 0; |
|
419 } |
|
420 tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed)); |
|
421 while (bmpBits < tempBmpBitsLimit) |
|
422 { |
|
423 *bmpBits++ = 0xff; |
|
424 *bmpBits++ = 0x0f; |
|
425 } |
|
426 } |
|
427 } |
|
428 } |
|
429 |
|
430 /** |
|
431 Logs the time taken to load the bitmap file identified by the filename. |
|
432 @param aFileName the mbm file that is to be loaded |
|
433 @param aTestCaseName the name of the test case |
|
434 */ |
|
435 void CTOptimisedBmp::TestDecompressBitmapL(const TDesC& aFileName, const TDesC& aTestCaseName) |
|
436 { |
|
437 TInt err = KErrNone; |
|
438 iProfiler->InitResults(); //initializes the timer |
|
439 for (TInt rpt = 0; rpt < KRepeatTestCount; ++rpt) |
|
440 { |
|
441 CFbsBitmap* fbsCompressed = new (ELeave) CFbsBitmap; |
|
442 CleanupStack::PushL( fbsCompressed ); |
|
443 |
|
444 //Load mbm file identified by aFileName |
|
445 err = fbsCompressed->Load( aFileName, 0, EFalse ); //when there is no memory constraints |
|
446 TEST(err == KErrNone); |
|
447 |
|
448 fbsCompressed->Reset(); |
|
449 CleanupStack::PopAndDestroy( fbsCompressed ); |
|
450 |
|
451 iProfiler->MarkResultSetL(); |
|
452 } // rpt loop |
|
453 |
|
454 //Logs the time taken to load the bmp file |
|
455 iProfiler->ResultsAnalysis(aTestCaseName, 0, 0, 0, KRepeatTestCount); |
|
456 } |
|
457 |
|
458 #ifdef _DEBUG |
|
459 /** |
|
460 This test will only work correctly under UDEB builds of the OS. |
|
461 It is same as CTOptimisedBmp::TestDecompressBitmapL function except that it also simulates the |
|
462 lack of memory use case while loading bitmap. |
|
463 |
|
464 @param aFileName the mbm file that is to be loaded |
|
465 @param aTestCaseName the name of the test case |
|
466 */ |
|
467 void CTOptimisedBmp::TestDecompressBitmapAltL(const TDesC& aFileName, const TDesC& aTestCaseName) |
|
468 { |
|
469 TInt err = KErrNone; |
|
470 RFbsSession* fbsSession = RFbsSession::GetSession(); |
|
471 if (!fbsSession) |
|
472 { |
|
473 INFO_PRINTF1(_L("Error: fbs cannot be NULL")); |
|
474 ASSERT_NOT_NULL(fbsSession); |
|
475 } |
|
476 else |
|
477 { |
|
478 CFbsBitmap* fbsCompressed = new (ELeave) CFbsBitmap; |
|
479 CleanupStack::PushL( fbsCompressed ); |
|
480 iProfiler->InitResults(); //initializes the timer |
|
481 for (TInt rpt = 0; rpt < KRepeatTestCount; ++rpt) |
|
482 { |
|
483 //Load mbm file identified by aFileName |
|
484 //Consider no memory case |
|
485 for (TInt count = 1; ; count++) |
|
486 { |
|
487 //Explicitly make the memory fails to check how will it loads bmp |
|
488 fbsSession->SendCommand(EFbsMessDefaultAllocFail,count); |
|
489 fbsSession->SendCommand(EFbsMessDefaultMark); |
|
490 fbsSession->SendCommand(EFbsMessUserMark); |
|
491 |
|
492 err = fbsCompressed->Load( aFileName, 0, EFalse ); |
|
493 |
|
494 if (err == KErrNoMemory) |
|
495 { |
|
496 fbsSession->SendCommand(EFbsMessDefaultMarkEnd); |
|
497 fbsSession->SendCommand(EFbsMessUserMarkEnd); |
|
498 } |
|
499 else if (err == KErrNone) |
|
500 { |
|
501 fbsSession->SendCommand(EFbsMessUserMarkEnd); |
|
502 break; |
|
503 } |
|
504 } |
|
505 iProfiler->MarkResultSetL(); |
|
506 fbsCompressed->Reset(); |
|
507 } // rpt loop |
|
508 |
|
509 CleanupStack::PopAndDestroy( fbsCompressed ); |
|
510 //Logs the time taken to load the bmp file |
|
511 iProfiler->ResultsAnalysis(aTestCaseName, 0, 0, 0, KRepeatTestCount); |
|
512 } |
|
513 } |
|
514 #endif |
|
515 |
|
516 /** |
|
517 @SYMTestCaseID |
|
518 GRAPHICS-UI-BENCH-0076 |
|
519 |
|
520 @SYMDEF DEF105392 |
|
521 |
|
522 @SYMTestCaseDesc |
|
523 Tests the performance of GetScanLine function for various display modes. |
|
524 Also it tests the performance of various GetScanLineColorXX |
|
525 (where XX => display mode, for eg. GetScanLineColor64K) |
|
526 and TScanLineDecompressor::CopyPixel functions. |
|
527 To test the performance of GetScanLineColorXX and other functions for any display mode, it creates |
|
528 a bitmap of that display mode and passes it to CTOptimisedBmp::ScanlineTestL function |
|
529 along with the display mode which was used for creating it and |
|
530 the other display mode which will be used for reading this bitmap while logging the performance. |
|
531 @SYMTestActions |
|
532 Compare the results over time, and before and after changes to GetScanLine and CopyPixel code. |
|
533 @SYMTestExpectedResults |
|
534 Test should pass and display average time |
|
535 */ |
|
536 void CTOptimisedBmp::GetScanLineTestL() |
|
537 { |
|
538 CFbsBitmap bmp; |
|
539 const TSize bmpSize(22,5); |
|
540 _LIT(KTestCaseName,"GetScanLine"); |
|
541 const TDisplayMode KTestDisplayModes[] = {EColor4K, EColor64K, EColor16M, EColor16MU, EColor16MA, EColor16MAP}; |
|
542 const TInt KTestDisplayModeCnt = sizeof(KTestDisplayModes)/sizeof(TDisplayMode); |
|
543 |
|
544 for(TInt srcDispModeIndex = 0; srcDispModeIndex < KTestDisplayModeCnt; srcDispModeIndex++) |
|
545 { |
|
546 TDisplayMode displayMode = KTestDisplayModes[srcDispModeIndex]; |
|
547 User::LeaveIfError(bmp.Create(bmpSize,displayMode)); |
|
548 StripeBitmap(bmp); |
|
549 bmp.Compress(); |
|
550 for(TInt destDispModeIndex = 0; destDispModeIndex < KTestDisplayModeCnt; destDispModeIndex++) |
|
551 { |
|
552 ScanlineTestL(bmp,displayMode,KTestDisplayModes[destDispModeIndex],KTestCaseName); |
|
553 } |
|
554 bmp.Reset(); |
|
555 } |
|
556 } |
|
557 |
|
558 /** |
|
559 It reads a bitmap (aBitmap) of given display mode (aSrcDisplayMode) as a bitmap of |
|
560 another display mode (aDestDisplayMode) and logs the performance for it. |
|
561 @param aBitmap a bitmap |
|
562 @param aSrcDisplayMode The used display mode when bitmap was created. |
|
563 It is passed in this function just for logging purpose. |
|
564 @param aDestDisplayMode The display mode used for reading the bitmap aBitmap |
|
565 @param aTestCaseName The name of the test case |
|
566 */ |
|
567 void CTOptimisedBmp::ScanlineTestL(const CFbsBitmap& aBitmap, TDisplayMode aSrcDisplayMode, TDisplayMode aDestDisplayMode, const TDesC& aTestCaseName) |
|
568 { |
|
569 const TSize bmpSize(aBitmap.SizeInPixels()); |
|
570 TInt byteWidth = CFbsBitmap::ScanLineLength(bmpSize.iWidth,aDestDisplayMode); |
|
571 TUint8* buffer = new (ELeave) TUint8[byteWidth]; |
|
572 CleanupStack::PushL(buffer); |
|
573 TPtr8 scanLine(buffer,byteWidth,byteWidth); |
|
574 |
|
575 iProfiler->InitResults(); |
|
576 for(TInt count=0;count<KRepeatTestCount;count++) |
|
577 { |
|
578 // For performance testing on same scanline, read the few pixels from bitmap. |
|
579 // And for a comprehensive testing, vary the start pixel and the number of pixels to get. |
|
580 for(TInt xStart = 0; xStart <= 11; xStart++) |
|
581 { |
|
582 for (TInt xLength = 1; xLength <= 11; xLength++) |
|
583 { |
|
584 TInt xEnd = xStart + xLength; |
|
585 if (xEnd <= bmpSize.iWidth) |
|
586 { |
|
587 aBitmap.GetScanLine(scanLine,TPoint(xStart,0),xLength,aDestDisplayMode); |
|
588 } |
|
589 } |
|
590 } |
|
591 // Test the performance of reading different scanlines. |
|
592 for(TInt yy = 0; yy < bmpSize.iHeight; yy++) |
|
593 { |
|
594 aBitmap.GetScanLine(scanLine,TPoint(0,yy),bmpSize.iWidth,aDestDisplayMode); |
|
595 } |
|
596 |
|
597 iProfiler->MarkResultSetL(); |
|
598 } |
|
599 |
|
600 iProfiler->ResultsAnalysis(aTestCaseName, 0, aSrcDisplayMode, aDestDisplayMode, KRepeatTestCount); |
|
601 |
|
602 CleanupStack::PopAndDestroy(buffer); |
|
603 } |
|
604 |
|
605 /** |
|
606 Logs the time taken to load the bitmap file identified by the filename and file id. |
|
607 @param aFileName the mbm or rsc file that is to be loaded |
|
608 @param aId The bitmap identifier |
|
609 @param aShareIfLoaded Specifies whether or not the loaded bitmap will be made available for sharing between font and bitmap server clients. |
|
610 @param aTestCaseName the name of the test case |
|
611 */ |
|
612 void CTOptimisedBmp::ResourceBitmapLoadL(const TDesC& aFileName, TInt32 aId, TBool aShareIfLoaded, const TDesC& aTestCaseName) |
|
613 { |
|
614 TInt err = KErrNone; |
|
615 iProfiler->InitResults(); //initializes the timer |
|
616 for (TInt rpt = 0; rpt < KRepeatTestCount; ++rpt) |
|
617 { |
|
618 CFbsBitmap* resourceBitmap = new (ELeave) CFbsBitmap; |
|
619 CleanupStack::PushL(resourceBitmap); |
|
620 iProfiler->StartTimer(); |
|
621 //Load mbm or rsc file identified by aFileName |
|
622 err = resourceBitmap->Load( aFileName, aId, aShareIfLoaded ); //when there is no memory constraints |
|
623 iProfiler->MarkResultSetL(); |
|
624 TEST(err == KErrNone); |
|
625 resourceBitmap->Reset(); |
|
626 CleanupStack::PopAndDestroy( resourceBitmap ); |
|
627 } |
|
628 //Logs the time taken to load the bmp file |
|
629 iProfiler->ResultsAnalysis(aTestCaseName, 0, 0, 0, KRepeatTestCount); |
|
630 } |