Update contrib.
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 "tbitbltperf.h"
23 #include <bitdrawinterfaceid.h>
24 #include <bmalphablend.h>
27 _LIT(KBitmap12bit, "z:\\system\\data\\uibench_12bit.mbm");
28 _LIT(KBitmap16bit, "z:\\system\\data\\uibench_16bit.mbm");
29 _LIT(KBitmap24bit, "z:\\system\\data\\uibench_24bit.mbm");
30 _LIT(KBitmap32bit, "z:\\system\\data\\uibench_32bit.mbm");
31 _LIT(KBitmapTile, "z:\\system\\data\\uibench_tile.mbm");
33 const TInt KIterationsToTest = 51; // Number of iterations to run tests
35 CTBitBltPerf::~CTBitBltPerf()
47 CTBitBltPerf::CTBitBltPerf()
49 SetTestStepName(KTBitBltPerfName);
53 Override of base class virtual
55 @return - TVerdict code
57 TVerdict CTBitBltPerf::doTestStepPreambleL()
59 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
61 iBitmap12bit = LoadBitmapL(KBitmap12bit, 0);
62 iBitmap16bit = LoadBitmapL(KBitmap16bit, 0);
63 iBitmap24bit = LoadBitmapL(KBitmap24bit, 0);
64 iBitmap32bit = LoadBitmapL(KBitmap32bit, 0);
65 iTile = LoadBitmapL(KBitmapTile, 0);
67 iTile16bit = CopyIntoNewBitmapL(iTile, EColor64K);
68 iTile32bit = CopyIntoNewBitmapL(iTile, EColor16M);
69 iAlpha8bit = CopyIntoNewBitmapL(iBitmap12bit, EGray256);
71 return TestStepResult();
75 Override of base class pure virtual
76 Our implementation only gets called if the base class doTestStepPreambleL() did
77 not leave. That being the case, the current test result value will be EPass.
79 @return - TVerdict code
81 TVerdict CTBitBltPerf::doTestStepL()
83 SetTestStepID(_L("GRAPHICS-UI-BENCH-0005"));
86 SetTestStepID(_L("GRAPHICS-UI-BENCH-0004"));
87 MaskedBitBltFlickerL();
89 SetTestStepID(_L("GRAPHICS-UI-BENCH-0003"));
92 SetTestStepID(_L("GRAPHICS-UI-BENCH-0001"));
95 SetTestStepID(_L("GRAPHICS-UI-BENCH-0002"));
98 SetTestStepID(_L("GRAPHICS-UI-BENCH-0056"));
99 WriteAlphaLineExTestL();
102 return TestStepResult();
106 Helper function to test bitblt bitmaps for different types of blitting. The bitmap is tiled
107 across the target, avoiding any overlapping or clipping.
109 @param aBitBltTest the bitblt test to carry out
110 @param aBitmapToBlt the bitmap to bitblt
111 @param aBitmapMask the bitmap mask
112 @param aCrop rectangle to crop bitblt to
113 @param aOrientation the orientation of the display
114 @param aTestName the name of the test
115 @param aGc the graphics context to bitblt to
117 void CTBitBltPerf::BitBltBitmapTestL(TBitBltTest aBitBltTest, CFbsBitmap* aBitmapToBlt, CFbsBitmap* aBitmapMask, TRect aCropTo, TInt aOrientation, const TDesC& aTestName, CFbsBitGc* aGc)
121 const TSize targetSize = iScreenDevice->BitmapDevice().SizeInPixels();
123 // Calculate the number of tiles that will fit fully on the pixmap
124 const TInt tileWidth = aCropTo.Width();
125 const TInt tileHeight = aCropTo.Height();
126 const TInt tileColumns = targetSize.iWidth / tileWidth;
127 const TInt tileRows = targetSize.iHeight / tileHeight;
128 const TInt numTiles = tileColumns * tileRows;
129 const TInt numPixelsPerIteration = numTiles * tileWidth * tileHeight;
131 iProfiler->InitResults();
137 for(TInt count=KIterationsToTest; count>0; --count)
139 TPoint bitmapPosition = TPoint(0,0);
140 for (TInt tile = numTiles - 1; tile >= 0; --tile)
142 aGc->BitBlt(bitmapPosition, aBitmapToBlt, aCropTo);
143 bitmapPosition.iX += tileWidth;
144 if (bitmapPosition.iX + tileWidth > targetSize.iWidth)
146 bitmapPosition.iX = 0;
147 bitmapPosition.iY += tileHeight;
155 for(TInt count=KIterationsToTest; count>0; --count)
157 TPoint bitmapPosition = TPoint(0,0);
158 for (TInt tile = numTiles - 1; tile >= 0; --tile)
160 aGc->BitBltMasked(bitmapPosition, aBitmapToBlt, aCropTo, aBitmapMask, EFalse);
161 bitmapPosition.iX += tileWidth;
162 if (bitmapPosition.iX + tileWidth > targetSize.iWidth)
164 bitmapPosition.iX = 0;
165 bitmapPosition.iY += tileHeight;
173 iProfiler->MarkResultSetL();
174 iProfiler->ResultsAnalysisPixelRate(aTestName, aOrientation, aBitmapToBlt->DisplayMode(), iScreenDevice->BitmapDevice().DisplayMode(), KIterationsToTest, numPixelsPerIteration);
180 GRAPHICS-UI-BENCH-0001
183 Tests how long it takes to bitblt a bitmap with different screen modes
186 Compare the results over time, and before and after changes to bitblt code.
188 @SYMTestExpectedResults
189 Test should pass and display total test time and time per bitmap
191 void CTBitBltPerf::SimpleBitBltL()
193 INFO_PRINTF1(_L("CTBitBltPerf::SimpleBitBlt"));
195 _LIT(KTestName, "BitBlt");
196 TBool orientation[4];
197 TRect cropTo(0,0,200,200);
199 // Bitblt for each display mode
200 for(TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++)
202 SetScreenModeL(KValidDisplayModes[dispModeIndex]);
203 iGc->OrientationsAvailable(orientation);
204 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
206 if (orientation[orient])
208 iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
210 BitBltBitmapTestL(EBitBlt, iBitmap12bit, NULL, cropTo, orient, KTestName, iGc);
211 BitBltBitmapTestL(EBitBlt, iBitmap16bit, NULL, cropTo, orient, KTestName, iGc);
212 BitBltBitmapTestL(EBitBlt, iBitmap24bit, NULL, cropTo, orient, KTestName, iGc);
213 BitBltBitmapTestL(EBitBlt, iBitmap32bit, NULL, cropTo, orient, KTestName, iGc);
217 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
222 GRAPHICS-UI-BENCH-0002
225 Tests how long it takes to bitblt a masked bitmap with different screen modes
228 Compare the results over time, and before and after changes to bitblt code.
230 @SYMTestExpectedResults
231 Test should pass and display total test time and time per bitmap
233 void CTBitBltPerf::MaskedBitBltL()
235 INFO_PRINTF1(_L("CTBitBltPerf::MaskedBitBlt"));
237 _LIT(KTestName, "MBitBlt");
238 TBool orientation[4];
239 TRect cropTo(0,0,200,200);
241 // test for each display mode
242 for(TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++)
244 SetScreenModeL(KValidDisplayModes[dispModeIndex]);
245 iGc->OrientationsAvailable(orientation);
246 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
248 if (orientation[orient])
250 iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
252 BitBltBitmapTestL(EBitBltMasked, iBitmap12bit, iTile, cropTo, orient, KTestName, iGc);
253 BitBltBitmapTestL(EBitBltMasked, iBitmap16bit, iTile, cropTo, orient, KTestName, iGc);
254 BitBltBitmapTestL(EBitBltMasked, iBitmap24bit, iTile, cropTo, orient, KTestName, iGc);
255 BitBltBitmapTestL(EBitBltMasked, iBitmap32bit, iTile, cropTo, orient, KTestName, iGc);
259 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
264 GRAPHICS-UI-BENCH-0003
267 Tests how long it takes to bitblt the same bitmap as a mask with different screen modes
270 Compare the results over time, and before and after changes to bitblt code.
272 @SYMTestExpectedResults
273 Test should pass and display total test time and time per bitmap
275 void CTBitBltPerf::MaskedBitBltSameL()
277 INFO_PRINTF1(_L("CTBitBltPerf::MaskedBitBltSame"));
279 _LIT(KTestName, "MBitBltS");
280 TBool orientation[4];
281 TRect cropTo(0,0,200,200);
283 // test for each display mode
284 for(TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++)
286 SetScreenModeL(KValidDisplayModes[dispModeIndex]);
287 iGc->OrientationsAvailable(orientation);
288 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
290 if (orientation[orient])
292 iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
294 BitBltBitmapTestL(EBitBltMasked, iTile, iTile, cropTo, orient, KTestName, iGc);
295 BitBltBitmapTestL(EBitBltMasked, iTile16bit, iTile16bit, cropTo, orient, KTestName, iGc);
296 BitBltBitmapTestL(EBitBltMasked, iTile32bit, iTile32bit, cropTo, orient, KTestName, iGc);
300 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
305 GRAPHICS-UI-BENCH-0004
308 Tests how long it takes to bitblt a masked bitmap to another bitmap
311 Compare the results over time, and before and after changes to bitblt code.
313 @SYMTestExpectedResults
314 Test should pass and display total test time and time per bitmap
316 void CTBitBltPerf::MaskedBitBltFlickerL()
318 INFO_PRINTF1(_L("CTBitBltPerf::MaskedBitBltFlickerL"));
320 _LIT(KTestName, "MBitBltF");
321 TBool orientation[4];
322 TRect cropTo(0,0,200,200);
324 // Test for each display mode
325 for(TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++)
327 SetScreenModeL(KValidDisplayModes[dispModeIndex]);
328 CFbsBitmap* flickerBitmap=new(ELeave) CFbsBitmap;
329 CleanupStack::PushL(flickerBitmap);
330 TInt ret=flickerBitmap->Create(iTile->SizeInPixels(), KValidDisplayModes[dispModeIndex]);
331 User::LeaveIfError(ret);
333 iBitmapDevice = CFbsBitmapDevice::NewL(flickerBitmap);
335 ret = iBitmapDevice->CreateContext(gc);
336 User::LeaveIfError(ret);
337 CleanupStack::PushL(gc);
339 // Why is this gc not used? Should be used instead of iGc?
340 gc->OrientationsAvailable(orientation);
341 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
343 if (orientation[orient])
345 gc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
347 BitBltBitmapTestL(EBitBltMasked, iBitmap12bit, iTile, cropTo, orient, KTestName, gc);
348 BitBltBitmapTestL(EBitBltMasked, iBitmap16bit, iTile, cropTo, orient, KTestName, gc);
349 BitBltBitmapTestL(EBitBltMasked, iBitmap24bit, iTile, cropTo, orient, KTestName, gc);
350 BitBltBitmapTestL(EBitBltMasked, iBitmap32bit, iTile, cropTo, orient, KTestName, gc);
353 gc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
355 delete iBitmapDevice;
356 iBitmapDevice = NULL;
357 CleanupStack::PopAndDestroy(2, flickerBitmap);
363 GRAPHICS-UI-BENCH-0005
366 Tests how long it takes to bitblt a masked alpha bitmap with different screen modes
369 Compare the results over time, and before and after changes to bitblt code.
371 @SYMTestExpectedResults
372 Test should pass and display total test time and time per bitmap
374 void CTBitBltPerf::MaskedBitBltAlphaL()
376 INFO_PRINTF1(_L("CTBitBltPerf::MaskedBitBltAlpha"));
378 _LIT(KTestName, "MBitBltA");
379 TBool orientation[4];
380 TRect cropTo(0,0,200,200);
382 // test for each display mode
383 for(TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++)
385 SetScreenModeL(KValidDisplayModes[dispModeIndex]);
386 iGc->OrientationsAvailable(orientation);
387 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
389 if (orientation[orient])
391 iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
393 BitBltBitmapTestL(EBitBltMasked, iBitmap12bit, iAlpha8bit, cropTo, orient, KTestName, iGc);
394 BitBltBitmapTestL(EBitBltMasked, iBitmap16bit, iAlpha8bit, cropTo, orient, KTestName, iGc);
395 BitBltBitmapTestL(EBitBltMasked, iBitmap24bit, iAlpha8bit, cropTo, orient, KTestName, iGc);
396 BitBltBitmapTestL(EBitBltMasked, iBitmap32bit, iAlpha8bit, cropTo, orient, KTestName, iGc);
400 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
405 GRAPHICS-UI-BENCH-0056
410 Tests the performace of CopyPixel and CopyTwoPixels called from WriteAlphaLineEx
413 Compare the results over time, and before and after changes to CopyPixel and CopyTwoPixels code.
415 @SYMTestExpectedResults
416 Test should pass and display total test time and average time
419 void CTBitBltPerf::WriteAlphaLineExTestL()
421 _LIT(KTestName, "WriteAlphaLineEx");
423 TDisplayMode displayMode = EColor16MU;
424 TDisplayMode sourceFormat = EColor64K;
428 TRAP(err,SetDrawDeviceModeL(displayMode));
431 _LIT(KLog,"Failed to create draw device of mode %S, error %d");
432 INFO_PRINTF3(KLog,&ColorModeName(displayMode),err);
433 if (displayMode==EColor16MA)
435 displayMode=EColor16MA;
437 _LIT(KLog,"Created draw device of mode %S");
438 INFO_PRINTF2(KLog,&ColorModeName(displayMode));
440 TAny* interface = NULL;
441 err = GetDrawDeviceInterfaceL(KFastBlitInterfaceID, interface);
444 _LIT(KLog,"No WriteAlphaLineExTest performed as getting draw device interface returned error %d");
445 INFO_PRINTF2(KLog,err);
449 ClearDrawDeviceL(KRgbWhite);
451 TSize size = TSize(50,50);
452 TRect rect = TRect(size);
453 TUint16* writeBuffer = new (ELeave) TUint16[size.iWidth];
454 CleanupStack::PushL(writeBuffer);
455 TUint8* maskBuffer = new (ELeave) TUint8[size.iWidth];
456 CleanupStack::PushL(maskBuffer);
457 TInt nOffset = sizeof(TUint16) * size.iWidth;
459 Mem::Fill(writeBuffer,nOffset,0xff);
460 Mem::Fill(maskBuffer,size.iWidth/2,0x8e);
461 Mem::Fill((maskBuffer+size.iWidth/2),size.iWidth/2,0xff);
463 MFastBlit* fastBlit = reinterpret_cast<MFastBlit*>(interface);
465 iProfiler->InitResults();
466 for(TInt count=0;count<KIterationsToTest;count++)
468 for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
470 fastBlit->WriteAlphaLineEx(rect.iTl.iX,yy,rect.Width(),0,(TUint32*)writeBuffer,sourceFormat,0,(TUint32*)maskBuffer,MAlphaBlend::EShdwBefore);
472 iProfiler->MarkResultSetL();
475 CleanupStack::PopAndDestroy(2, writeBuffer);//maskBuffer, writeBuffer
476 iProfiler->ResultsAnalysis(KTestName, CFbsBitGc::EGraphicsOrientationNormal, sourceFormat, displayMode, KIterationsToTest);