Update contrib.
1 // Copyright (c) 2008-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.
16 #include "textendedbitmap.h"
17 #include "tdirectgditestbase.h"
24 const TInt KIterationsToTest = 1000;
25 const TDisplayMode KDisplayMode = EColor64K;
26 // Test the performance of extended bitmaps using the extended bitmap
27 // Uid supported by the test example rasterizer
28 const TUid KExtendedBitmapUid = {0x10285A78};
31 CTExtendedBitmap::CTExtendedBitmap()
33 SetTestStepName(KTExtendedBitmap);
36 CTExtendedBitmap::~CTExtendedBitmap()
39 delete [] iExtendedBmpData;
47 Override of base class pure virtual
48 Our implementation only gets called if the base class doTestStepPreambleL() did
49 not leave. That being the case, the current test result value will be EPass.
51 @return - TVerdict code
53 TVerdict CTExtendedBitmap::doTestStepL()
55 SetTestStepID(_L("GRAPHICS-UI-BENCH-0159"));
56 CreateExtendedBitmapL();
58 SetTestStepID(_L("GRAPHICS-UI-BENCH-0160"));
59 DeleteExtendedBitmapL();
61 SetTestStepID(_L("GRAPHICS-UI-BENCH-0161"));
62 GetScanlinePreRenderedExtendedBitmapL();
64 SetTestStepID(_L("GRAPHICS-UI-BENCH-0162"));
65 GetScanlineNonPreRenderedExtendedBitmapL();
67 SetTestStepID(_L("GRAPHICS-UI-BENCH-0163"));
68 BitBltExtendedBitmapL();
70 SetTestStepID(_L("GRAPHICS-UI-BENCH-0164"));
71 BitBltNormalBitmapL();
73 SetTestStepID(_L("GRAPHICS-UI-BENCH-0165"));
74 DrawBitmapExtendedBitmapL();
76 SetTestStepID(_L("GRAPHICS-UI-BENCH-0166"));
77 DrawBitmapNormalBitmapL();
79 SetTestStepID(_L("GRAPHICS-UI-BENCH-0173"));
80 GetPixelL(ETrue); // extended bitmap
82 SetTestStepID(_L("GRAPHICS-UI-BENCH-0173"));
83 GetPixelL(EFalse); // normal bitmap
86 return TestStepResult();
90 Called before doTestStepL() to allow
91 initialization steps common to each test case to take place.
93 @return - TVerdict code
95 TVerdict CTExtendedBitmap::doTestStepPreambleL()
97 TVerdict res = CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
99 const TRgb colors[] = {TRgb(0,255,255), TRgb(255,0,255), TRgb(255,255,0)};
100 const TInt numColors = sizeof(colors)/sizeof(colors[0]);
101 const TUint8 stripe = 1; // 1 mean draw horizontal stripes, 0 means draw vertical stripes
102 iExtendedBmpDataSize = sizeof(colors)+sizeof(stripe); // estimate the data size
103 iExtendedBmpData = new(ELeave) TUint8[iExtendedBmpDataSize];
105 ws.Open(iExtendedBmpData, iExtendedBmpDataSize);
106 CleanupClosePushL(ws);
107 for (TInt i = 0; i < numColors; i++)
112 iExtendedBmpDataSize = ws.Sink()->TellL(MStreamBuf::EWrite).Offset(); // get the actual size written
113 CleanupStack::PopAndDestroy(&ws);
115 iExtendedBmp = new(ELeave) CFbsBitmap;
116 TInt err = iExtendedBmp->CreateExtendedBitmap(KBitmapSize, KDisplayMode, KExtendedBitmapUid, iExtendedBmpData, iExtendedBmpDataSize);
117 TESTL(err == KErrNone);
119 iNormalBmp = new(ELeave) CFbsBitmap;
120 err = iNormalBmp->Create(KBitmapSize, KDisplayMode);
121 TESTL(err == KErrNone);
123 iTargetBmp = new(ELeave) CFbsBitmap;
124 err = iTargetBmp->Create(KBitmapSize, KDisplayMode);
125 TESTL(err == KErrNone);
127 iBitmapDevice = CFbsBitmapDevice::NewL(iTargetBmp);
128 TESTL(iBitmapDevice != NULL);
130 iBitGc = CFbsBitGc::NewL();
131 iBitGc->Activate(iBitmapDevice);
133 iRasterizer = CFbsBitmap::Rasterizer();
134 if (iRasterizer == NULL)
136 INFO_PRINTF1(_L("Error: Extended bitmap tests only work when the example rasterizer is available, make sure \"-DFBSRASTERIZER_DLL=fbsrasterizer_test.dll\" is included in your rombuild command."));
137 User::Leave(KErrGeneral);
145 GRAPHICS-UI-BENCH-0159
155 The test determines how long it takes to create an extended bitmap.
158 Measure the average time taken to create an extended bitmap by creating an
159 extended bitmap 1000 times and then calculating the average time.
161 @SYMTestExpectedResults
162 Test should pass and display total test time and time per extended bitmap creation.
164 void CTExtendedBitmap::CreateExtendedBitmapL()
166 CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
168 CleanupStack::PushL(bmp);
170 iProfiler->InitResults();
171 for(TInt count=KIterationsToTest; count>0; --count)
173 iProfiler->StartTimer();
174 TInt err = bmp->CreateExtendedBitmap(KBitmapSize, EColor64K, KExtendedBitmapUid, iExtendedBmpData, iExtendedBmpDataSize);
175 iProfiler->MarkResultSetL();
176 TESTL(err == KErrNone);
178 // Reset the bitmap so the time taken to reset it the next time CreateExtendedBitmap()
179 // is called is not included in the test
183 iProfiler->ResultsAnalysis(_L("Create-ExtendedBitmap-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
185 CleanupStack::PopAndDestroy(bmp);
190 GRAPHICS-UI-BENCH-0160
200 The test determines how long it takes to delete an extended bitmap.
203 Measure the average time taken to delete an extended bitmap by creating and
204 deleting an extended bitmap 1000 times and then calculating the average time for the deletion.
206 @SYMTestExpectedResults
207 Test should pass and display total test time and time per extended bitmap deletion.
209 void CTExtendedBitmap::DeleteExtendedBitmapL()
211 CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
213 CleanupStack::PushL(bmp);
215 iProfiler->InitResults();
216 for(TInt count=KIterationsToTest; count>0; --count)
218 TInt err = bmp->CreateExtendedBitmap(KBitmapSize, EColor64K, KExtendedBitmapUid, iExtendedBmpData, iExtendedBmpDataSize);
219 TESTL(err == KErrNone);
220 CleanupStack::Pop(bmp);
222 iProfiler->StartTimer();
224 iProfiler->MarkResultSetL();
226 bmp = new(ELeave) CFbsBitmap;
228 CleanupStack::PushL(bmp);
230 iProfiler->ResultsAnalysis(_L("Delete-ExtendedBitmap-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
232 CleanupStack::PopAndDestroy(bmp);
237 GRAPHICS-UI-BENCH-0161
247 Measure the average time taken to get a scanline from an extended bitmap directly using
248 the example rasterizer where there is one call to BeginBitmap() and EndBitmap() for
249 many GetScanLine() calls. This test only measures the performance of the example rasterizer.
250 It is included here to help isolate performance changes in CTExtendedBitmap::BitBltExtendedBitmapL()
251 and CTExtendedBitmap::DrawBitmapExtendedBitmapL().
254 Measure the average time taken to get a scanline from an extended bitmap directly using
255 the example rasterizer by calling CFbsRasterizer::ScanLine() 1000 times for an extended
258 @SYMTestExpectedResults
259 Test should pass and display total test time and time per scanline.
261 @see GetScanlineNonPreRenderedExtendedBitmapL()
263 void CTExtendedBitmap::GetScanlinePreRenderedExtendedBitmapL()
265 CFbsRasterizer::TBitmapDesc bitmapDesc;
266 TInt64 bitmapId = iExtendedBmp->SerialNumber();
267 bitmapDesc.iSizeInPixels = KBitmapSize;
268 bitmapDesc.iDispMode = KDisplayMode;
269 bitmapDesc.iDataType = KExtendedBitmapUid;
270 bitmapDesc.iData = iExtendedBmpData;
271 bitmapDesc.iDataSize = iExtendedBmpDataSize;
272 iRasterizer->BeginBitmap(bitmapId, bitmapDesc, NULL);
275 const TUint32* scanline;
278 iProfiler->InitResults();
279 for(TInt count=KIterationsToTest; count>0; --count)
281 for (h = 0; h < KBitmapSize.iHeight; h++)
284 scanline = iRasterizer->ScanLine(bitmapId, point, KBitmapSize.iWidth);
285 TESTL(scanline != NULL);
287 iProfiler->MarkResultSetL();
289 iProfiler->ResultsAnalysis(_L("GetScanline-PreRendered-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
291 iRasterizer->EndBitmap(bitmapId);
296 GRAPHICS-UI-BENCH-0162
305 Measure the average time taken to get a scanline from an extended bitmap directly using
306 the example rasterizer where the calls to BeginBitmap() and EndBitmap() are done for each
310 Call CFbsRasterizer::ScanLine() 1000 times for an extended bitmap. This test case is similar
311 to GetScanlinePreRenderedExtendedBitmapL() but in this case each CFbsRasterizer::ScanLine()
312 call is bracketed by CFbsRasterizer::BeginBitmap() and CFbsRasterizer::EndBitmap() to highlight
313 the performance hit that would be seen by an application calling CFbsBitmap::GetScanLine()
314 when using an extended bitmap rasterizer that does not have a cache.
316 @SYMTestExpectedResults
317 Test should pass and display total test time and time per scanline when bracketed by
318 CFbsRasterizer::BeginBitmap() and CFbsRasterizer::EndBitmap().
320 @see GetScanlinePreRenderedExtendedBitmapL()
322 void CTExtendedBitmap::GetScanlineNonPreRenderedExtendedBitmapL()
324 CFbsRasterizer::TBitmapDesc bitmapDesc;
325 TInt64 bitmapId = iExtendedBmp->SerialNumber();
326 bitmapDesc.iSizeInPixels = KBitmapSize;
327 bitmapDesc.iDispMode = KDisplayMode;
328 bitmapDesc.iDataType = KExtendedBitmapUid;
329 bitmapDesc.iData = iExtendedBmpData;
330 bitmapDesc.iDataSize = iExtendedBmpDataSize;
333 const TUint32* scanline;
336 iProfiler->InitResults();
337 for(TInt count=KIterationsToTest; count>0; --count)
339 for (h = 0; h < KBitmapSize.iHeight; h++)
341 // Only the first call to BeginBitmap() should cause rasterization of the bitmap,
342 // since the test rasterizer has a cache of recently used bitmaps.
343 iRasterizer->BeginBitmap(bitmapId, bitmapDesc, NULL);
345 scanline = iRasterizer->ScanLine(bitmapId, point, KBitmapSize.iWidth);
346 TESTL(scanline != NULL);
347 iRasterizer->EndBitmap(bitmapId);
349 iProfiler->MarkResultSetL();
351 iProfiler->ResultsAnalysis(_L("GetScanline-NonPreRendered-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
356 GRAPHICS-UI-BENCH-0163
366 The test determines how long it takes to BitBlt() an extended bitmap to an offscreen bitmap.
367 This test is paired with BitBltNormalBitmapL().
370 Measure the time taken to BitBlt() an extended bitmap to an offscreen buffer 1000 times
371 and calculate the average time taken.
373 @SYMTestExpectedResults
374 Test should pass and display total test time and time per image BitBlt().
376 @see BitBltNormalBitmapL()
378 void CTExtendedBitmap::BitBltExtendedBitmapL()
380 const TPoint pt(0,0);
382 iProfiler->InitResults();
383 for(TInt count=KIterationsToTest; count>0; --count)
385 iBitGc->BitBlt(pt, iExtendedBmp);
386 iProfiler->MarkResultSetL();
388 iProfiler->ResultsAnalysis(_L("BitBlt-ExtendedBitmap-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
393 GRAPHICS-UI-BENCH-0164
398 The test determines how long it takes to BitBlt() a standard bitmap that is the same size
399 as the extended bitmap used in the previous test case BitBltExtendedBitmapL().
400 This test is paired with BitBltExtendedBitmapL().
403 Measure the time taken to BitBlt() a normal bitmap to an offscreen buffer 1000 times
404 and calculate the average time taken.
406 @SYMTestExpectedResults
407 Test should pass and display total test time and time per image BitBlt().
409 @see BitBltExtendedBitmapL()
411 void CTExtendedBitmap::BitBltNormalBitmapL()
413 const TPoint pt(0,0);
415 iProfiler->InitResults();
416 for(TInt count=KIterationsToTest; count>0; --count)
418 iBitGc->BitBlt(pt, iNormalBmp);
419 iProfiler->MarkResultSetL();
421 iProfiler->ResultsAnalysis(_L("BitBlt-NormalBitmap-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
426 GRAPHICS-UI-BENCH-0165
436 The test determines how long it takes to draw an extended bitmap to an offscreen bitmap
437 using DrawBitmap(). This test is paired with DrawBitmapNormalBitmapL().
440 Measure the time taken to DrawBitmap() an extended bitmap to an offscreen buffer 1000 times
441 and calculate the average time taken. This test is paired with DrawBitmapNormalBitmapL().
443 @SYMTestExpectedResults
444 Test should pass and display total test time and time per image DrawBitmap().
446 @see DrawBitmapNormalBitmapL()
448 void CTExtendedBitmap::DrawBitmapExtendedBitmapL()
450 const TPoint pt(0,0);
451 const TRect rect(pt, KBitmapSize);
453 iProfiler->InitResults();
454 for(TInt count=KIterationsToTest; count>0; --count)
456 iBitGc->DrawBitmap(rect, iExtendedBmp, rect);
457 iProfiler->MarkResultSetL();
459 iProfiler->ResultsAnalysis(_L("DrawBitmap-ExtendedBitmap-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
464 GRAPHICS-UI-BENCH-0166
469 The test determines how long it takes to draw a standard bitmap that is the same size
470 as the extended bitmap used in the previous test case (DrawBitmapExtendedBitmapL())
471 using DrawBitmap(). This test is paired with DrawBitmapExtendedBitmapL().
472 This test is paired with DrawBitmapExtendedBitmapL().
475 Measure the time taken to DrawBitmap() a normal bitmap to an offscreen buffer 1000 times
476 and calculate the average time taken.
478 @SYMTestExpectedResults
479 Test should pass and display total test time and time per image DrawBitmap().
481 @see DrawBitmapExtendedBitmapL()
483 void CTExtendedBitmap::DrawBitmapNormalBitmapL()
485 const TPoint pt(0,0);
486 const TRect rect(pt, KBitmapSize);
488 iProfiler->InitResults();
489 for(TInt count=KIterationsToTest; count>0; --count)
491 iBitGc->DrawBitmap(rect, iNormalBmp, rect);
492 iProfiler->MarkResultSetL();
494 iProfiler->ResultsAnalysis(_L("DrawBitmap-NormalBitmap-64K"), 0, EColor64K, EColor64K, KIterationsToTest);
499 GRAPHICS-UI-BENCH-0173
508 Measure the average time taken to get 128 pixels from a normal or extended bitmap.
511 Measure the average time taken to get 128 pixels from a normal or extended bitmap
512 by calling CFbsBitmap::GetPixel() 1000 times on the bitmap.
514 @SYMTestExpectedResults
515 Test should pass and display total test time and time per 128 pixels.
517 void CTExtendedBitmap::GetPixelL(TBool aIsExtendedBmp)
519 CFbsBitmap* bmp = NULL;
520 _LIT(KTestName, "GetPixel-%S-64K");
525 _LIT(KExtBmpName, "ExtendedBitmap");
526 buf.Format(KTestName, &KExtBmpName);
531 _LIT(KNormalBmpName, "NormalBitmap");
532 buf.Format(KTestName, &KNormalBmpName);
539 iProfiler->InitResults();
540 for(TInt count=KIterationsToTest; count>0; --count)
542 for (y = 0; y < KBitmapSize.iHeight; ++y)
545 bmp->GetPixel(color, point);
547 iProfiler->MarkResultSetL();
549 iProfiler->ResultsAnalysis(buf, 0, KDisplayMode, KDisplayMode, KIterationsToTest);