os/graphics/graphicstest/uibench/src/tbitbltperf_directgdi.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2007-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 "tbitbltperf_directgdi.h"
    23 #include <graphics/directgdidriver.h>
    24 #include <graphics/directgdidrawablesource.h>
    25 #include <bitdrawinterfaceid.h>
    26 #include <bmalphablend.h>
    27 #include <bitdraw.h>
    28 
    29 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    30 _LIT(KBitmap12bit, "z:\\system\\data\\uibench_12bit.mbm");
    31 _LIT(KBitmap16bit, "z:\\system\\data\\uibench_16bit.mbm");
    32 _LIT(KBitmap24bit, "z:\\system\\data\\uibench_24bit.mbm");
    33 _LIT(KBitmap32bit, "z:\\system\\data\\uibench_32bit.mbm");
    34 _LIT(KBitmapTile, "z:\\system\\data\\uibench_tile.mbm");
    35 #endif
    36 
    37 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    38 const TInt KIterationsToTest = 5; 		// Number of iterations to run tests
    39 #endif
    40 const TInt KMaxPixelFormats = 30;		// Number of bitmaps/tiles to create
    41 
    42 // For many of these tests, the size of which the destination blit is cropped to. 
    43 const TRect KCropTo = TRect(0,0,200,200);
    44 
    45 CTBitBltPerfDirectGdi::~CTBitBltPerfDirectGdi()
    46 	{
    47 	}
    48 
    49 CTBitBltPerfDirectGdi::CTBitBltPerfDirectGdi()
    50 	:iBitmapImage(KMaxPixelFormats),
    51 	iBitmapTile(KMaxPixelFormats)
    52 	{
    53 	SetTestStepName(KTBitBltPerfDirectGdi);
    54 	}
    55 
    56 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    57 /**
    58 Override of base class virtual
    59 
    60 @return - TVerdict code
    61 */
    62 TVerdict CTBitBltPerfDirectGdi::doTestStepPreambleL()
    63 	{	
    64 	CTDirectGdiTestBase::doTestStepPreambleL();
    65 	
    66 	// Create a CFbsBitmap image for each source mode we are testing.
    67 	for (TInt srcMode = 0; srcMode < iSourcePixelFormatArray.Count(); ++srcMode)
    68 		{
    69 		TDisplayMode bitmapDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iSourcePixelFormatArray[srcMode]);
    70 		
    71 		CFbsBitmap* bitmapImage = NULL;
    72 		switch(bitmapDisplayMode)
    73 		{
    74 			case EColor4K:
    75 			case EGray256:
    76 				bitmapImage = LoadBitmapL(KBitmap12bit, 0);
    77 				break;
    78 			case EColor64K:
    79 				bitmapImage = LoadBitmapL(KBitmap16bit, 0);
    80 				break;
    81 			case EColor16M:
    82 				bitmapImage = LoadBitmapL(KBitmap24bit, 0);
    83 				break;
    84 			default:
    85 				bitmapImage = LoadBitmapL(KBitmap32bit, 0);
    86 				break;
    87 		}
    88 		if (bitmapImage && bitmapImage->DisplayMode() != bitmapDisplayMode)
    89 			{
    90 			CleanupStack::PushL(bitmapImage);
    91 			CFbsBitmap* tempBitmap = CopyIntoNewBitmapL(bitmapImage, bitmapDisplayMode);
    92 			CleanupStack::PopAndDestroy(1, bitmapImage); //bitmapImage
    93 			bitmapImage = tempBitmap;
    94 			}
    95 		iBitmapImage.AppendL(bitmapImage);
    96 		}
    97 
    98 	// Create 8bit alpha bitmap
    99 	CFbsBitmap* tempBitmap = LoadBitmapL(KBitmap12bit, 0);
   100 	CleanupStack::PushL(tempBitmap);
   101 	iAlpha8bit = CopyIntoNewBitmapL(tempBitmap, EGray256);
   102 	CleanupStack::PopAndDestroy(tempBitmap);	// tempBitmap
   103 
   104 	// Create CFbsBitmaps for the tile images of various pixel formats.
   105 	// The first entry in the array is always the default pixelformat loaded from the mbm.
   106 	// Then in the rest of the array are bitmaps converted to the source pixel formats.
   107 	CFbsBitmap* tile = LoadBitmapL(KBitmapTile, 0);	
   108 	iBitmapTile.AppendL(tile);
   109 	for (TInt srcMode = 0; srcMode < iSourcePixelFormatArray.Count(); ++srcMode)
   110 		{
   111 		TDisplayMode bitmapDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iSourcePixelFormatArray[srcMode]);
   112 		CFbsBitmap* tileCopy = CopyIntoNewBitmapL(tile, bitmapDisplayMode);
   113 		iBitmapTile.AppendL(tileCopy);
   114 		}
   115 	
   116 	return TestStepResult();
   117 	}
   118 
   119 /**
   120 Override of base class virtual
   121 
   122 @return - TVerdict code
   123 */
   124 TVerdict CTBitBltPerfDirectGdi::doTestStepPostambleL()
   125 	{	
   126 	delete iAlpha8bit;
   127 	iAlpha8bit = NULL;
   128 
   129 	for (TInt ii = iBitmapImage.Count() - 1; ii >= 0; --ii)
   130 		{
   131 		delete iBitmapImage[ii];
   132 		}
   133 	iBitmapImage.Close();
   134 
   135 	for (TInt ii = iBitmapTile.Count() - 1; ii >= 0; --ii)
   136 		{
   137 		delete iBitmapTile[ii];
   138 		}
   139 	iBitmapTile.Close();
   140 
   141 	return CTDirectGdiTestBase::doTestStepPostambleL();
   142 	}
   143 #endif
   144 /**
   145 Override of base class pure virtual
   146 Our implementation only gets called if the base class doTestStepPreambleL() did
   147 not leave. That being the case, the current test result value will be EPass.
   148 
   149 @return - TVerdict code
   150 */
   151 TVerdict CTBitBltPerfDirectGdi::doTestStepL()
   152 	{
   153 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   154     INFO_PRINTF1(_L("CTBitBltPerfDirectGdi can only be run with RSgImage legacy"));
   155     return TestStepResult();
   156 #else
   157 	// for each display mode
   158 	for(TInt dispModeIndex = 0; dispModeIndex < iTargetPixelFormatArray.Count(); ++dispModeIndex)
   159 		{
   160 		TDisplayMode targetDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iTargetPixelFormatArray[dispModeIndex]);
   161 		if(SetTargetPixelFormatL(targetDisplayMode))
   162 			{
   163 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0150"));
   164 			SimpleBitBltL();
   165 			RecordTestResultL();
   166 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0151"));
   167 			SimpleDrawBitmapL();
   168 			RecordTestResultL();
   169 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0153"));
   170 			MaskedBitBltAlphaL();
   171 			RecordTestResultL();
   172 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0154"));
   173 			MaskedBitBltSameL();
   174 			RecordTestResultL();
   175 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0155"));
   176 			MaskedBitBltL();
   177 			RecordTestResultL();
   178 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0156"));
   179 			MaskedDrawBitmapL();
   180 			RecordTestResultL();
   181 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0136"));
   182 			MaskedDrawBitmapScaledL();
   183 			RecordTestResultL();
   184 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0157"));
   185 			BitBltCpuAccessL();
   186 			RecordTestResultL();
   187 			SetTestStepID(_L("GRAPHICS-UI-BENCH-0158"));
   188 			SimpleDrawResourceL();
   189 			RecordTestResultL();
   190 			}
   191 		}
   192 
   193     CloseTMSGraphicsStep();
   194 	return TestStepResult();
   195 #endif	
   196 	}
   197 
   198 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   199 /**
   200 @SYMTestCaseID
   201 GRAPHICS-UI-BENCH-0150
   202 
   203 @SYMPREQ PREQ39
   204 
   205 @SYMREQ REQ9236 
   206 @SYMREQ REQ9237
   207 
   208 @SYMTestCaseDesc
   209 Measure the performance of BitBlt() for the current screen mode and for various bitmap pixel formats.
   210 
   211 @SYMTestActions
   212 Draw an entire bitmap using BitBlt(), with no overlapping or clipping. 
   213 Measure the time taken.
   214 
   215 @SYMTestExpectedResults
   216 The performance to be logged as a pixel rate, per bitmap.
   217 */
   218 void CTBitBltPerfDirectGdi::SimpleBitBltL()
   219 	{
   220 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::SimpleBitBlt"));
   221 	
   222 	_LIT(KTestName, "DirectGdiBitBlt");
   223 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   224 		{
   225 		BitBltBitmapTestL(EBitBlt, iBitmapImage[source], NULL, KCropTo, KTestName, iContext);
   226 		}
   227 	}
   228 
   229 /**
   230 @SYMTestCaseID
   231 GRAPHICS-UI-BENCH-0151
   232 
   233 @SYMPREQ PREQ39
   234 
   235 @SYMREQ REQ9236 
   236 @SYMREQ REQ9237
   237 
   238 @SYMTestCaseDesc
   239 Measures the performance of DrawBitmap() for the current screen mode, for various bitmap pixel formats.
   240 The bitmap is drawn without scaling.
   241 
   242 @SYMTestActions
   243 Create a copy of the bitmap, and scale to the required size, prior to running the test.
   244 For each required source pixel format, use DrawBitmap() to tile a bitmap across the target, avoiding any
   245 clipping or overlap. 
   246 
   247 @SYMTestExpectedResults
   248 The performance to be logged as a pixel rate, per bitmap.
   249 */
   250 void CTBitBltPerfDirectGdi::SimpleDrawBitmapL()
   251 	{
   252 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::SimpleDrawBitmap"));
   253 	
   254 	_LIT(KTestName, "DirectGdiDrawBitmap");
   255 
   256 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   257 		{
   258 		// Use a bitmap that needs no scaling.
   259 		CFbsBitmap* bitmapBitBltImage = CopyIntoNewBitmapL(iBitmapImage[source], iBitmapImage[source]->DisplayMode());
   260 		CleanupStack::PushL(bitmapBitBltImage);
   261 		bitmapBitBltImage->Resize(KCropTo.Size());
   262 		BitBltBitmapTestL(EDrawBitmap, bitmapBitBltImage, NULL, bitmapBitBltImage->SizeInPixels(), KTestName, iContext);
   263 		CleanupStack::PopAndDestroy(1, bitmapBitBltImage);
   264 		}
   265 	}
   266 
   267 /**
   268 @SYMTestCaseID
   269 GRAPHICS-UI-BENCH-0155
   270 
   271 @SYMPREQ PREQ39
   272 
   273 @SYMREQ REQ9236 
   274 @SYMREQ REQ9237
   275 
   276 @SYMTestCaseDesc
   277 Measure the performance of BitBltMasked() for the current screen mode, using bitmaps of various 
   278 pixel formats.
   279 
   280 @SYMTestActions
   281 Call BitBltMasked() with a bitmap for various pixel formats of bitmap, using the same bitmap 
   282 as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping. 
   283 
   284 @SYMTestExpectedResults
   285 The performance to be logged as a pixel rate, per bitmap.
   286 */
   287 void CTBitBltPerfDirectGdi::MaskedBitBltL()
   288 	{
   289 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedBitBlt"));
   290 	
   291 	_LIT(KTestName, "DirectGdiMBitBlt");
   292 	
   293 	// for each display mode
   294 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   295 		{
   296 		BitBltBitmapTestL(EBitBltMasked, iBitmapImage[source], iBitmapTile[0], KCropTo, KTestName, iContext);
   297 		}
   298 	}
   299 
   300 /**
   301 @SYMTestCaseID
   302 GRAPHICS-UI-BENCH-0154
   303 
   304 @SYMPREQ PREQ39
   305 
   306 @SYMREQ REQ9236 
   307 @SYMREQ REQ9237
   308 
   309 @SYMTestCaseDesc
   310 Measure the performance of BitBlt(), using the same bitmap as a mask with different screen modes.
   311 
   312 @SYMTestActions
   313 Call BitBltMasked() with a bitmap for various pixel formats of bitmap, using the bitmap 
   314 as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping.
   315 
   316 @SYMTestExpectedResults
   317 The performance to be logged as a pixel rate, per bitmap.
   318 */	
   319 void CTBitBltPerfDirectGdi::MaskedBitBltSameL()
   320 	{
   321 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedBitBltSame"));
   322 	
   323 	_LIT(KTestName, "DirectGdiMBitBltS");
   324 	
   325 	for (TInt tile = 0; tile < iBitmapTile.Count(); ++tile)
   326 		{
   327 		BitBltBitmapTestL(EBitBltMasked, iBitmapTile[tile], iBitmapTile[tile], KCropTo, KTestName, iContext);
   328 		}
   329 	}
   330 
   331 
   332 /**
   333 @SYMTestCaseID
   334 GRAPHICS-UI-BENCH-0153
   335 
   336 @SYMPREQ PREQ39
   337 
   338 @SYMREQ REQ9236 
   339 @SYMREQ REQ9237
   340 
   341 @SYMTestCaseDesc
   342 Measure the performance of BitBltMasked(), with an alpha bitmap with different screen modes.
   343 
   344 @SYMTestActions
   345 Call BitBltMasked() with a bitmap for various pixel formats of bitmap, using the same alpha bitmap 
   346 as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping.
   347 
   348 @SYMTestExpectedResults
   349 The performance to be logged as a pixel rate, per bitmap.
   350 */
   351 void CTBitBltPerfDirectGdi::MaskedBitBltAlphaL()
   352 	{
   353 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedBitBltAlpha"));	
   354 	
   355 	_LIT(KTestName, "DirectGdiMBitBltA");
   356 	
   357 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   358 		{
   359 		BitBltBitmapTestL(EBitBltMasked, iBitmapImage[source], iAlpha8bit, KCropTo, KTestName, iContext);
   360 		}
   361 	}
   362 
   363 /**
   364 @SYMTestCaseID
   365 GRAPHICS-UI-BENCH-0157
   366 
   367 @SYMPREQ PREQ39
   368 
   369 @SYMREQ REQ9236 
   370 @SYMREQ REQ9237
   371 
   372 @SYMTestCaseDesc
   373 Measure the performance of BitBlt() for the current screen mode and for various bitmap pixel formats,
   374 with a bitmap that is accessed by the CPU via DataAddresss(), and is therefore never cached by DirectGDI.
   375 
   376 @SYMTestActions
   377 Create a copy of a test bitmap.
   378 Call DataAddress() on the bitmap.
   379 Draw an entire bitmap using BitBlt(), with no overlapping or clipping. 
   380 Measure the time taken.
   381 
   382 @SYMTestExpectedResults
   383 The performance to be logged as a pixel rate, per bitmap.
   384 */
   385 void CTBitBltPerfDirectGdi::BitBltCpuAccessL()
   386 	{
   387 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::BitBltCpuAccess"));
   388 	
   389 	_LIT(KTestName, "DirectGdiBitBltCpuAccess");
   390 
   391 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   392 		{
   393 		CFbsBitmap* bitmapBitBltImage = CopyIntoNewBitmapL(iBitmapImage[source], iBitmapImage[source]->DisplayMode());
   394 		TESTL(bitmapBitBltImage != NULL);
   395 		CleanupStack::PushL(bitmapBitBltImage);
   396 		bitmapBitBltImage->DataAddress();	// CPU Access so that it is not cached by DirectGDI.
   397 		BitBltBitmapTestL(EBitBlt, bitmapBitBltImage, NULL, KCropTo, KTestName, iContext);
   398 		CleanupStack::PopAndDestroy(1, bitmapBitBltImage);		
   399 		}
   400 	}
   401 
   402 /**
   403 @SYMTestCaseID
   404 GRAPHICS-UI-BENCH-0158
   405 
   406 @SYMPREQ PREQ39
   407 
   408 @SYMREQ REQ9236 
   409 @SYMREQ REQ9237
   410 
   411 @SYMTestCaseDesc
   412 Measure the performance of DrawResource() for the current screen mode and for various bitmap pixel formats,
   413 with no rotation.
   414 
   415 @SYMTestActions
   416 Draw an entire bitmap using DrawResource(), by tiling the image across the target to avoid overlapping and
   417 clipping. Measure the time taken.
   418 
   419 @SYMTestExpectedResults
   420 The performance to be logged as a pixel rate, per bitmap.
   421 */
   422 void CTBitBltPerfDirectGdi::SimpleDrawResourceL()
   423 	{
   424 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::SimpleDrawResource"));
   425 	_LIT(KTestName, "DirectGdiDrawResource");
   426 		
   427 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   428 		{
   429 		TSgImageInfo imageInfo;
   430 		imageInfo.iSizeInPixels = iBitmapImage[source]->SizeInPixels();
   431 		imageInfo.iPixelFormat = TDisplayModeMapping::MapDisplayModeToPixelFormat(iBitmapImage[source]->DisplayMode());
   432 		imageInfo.iUsage = ESgUsageDirectGdiSource;
   433 
   434 		// Create an RSgImage from the CFbsBitmap.
   435 		RSgImage sgImage;	
   436 		TInt res = sgImage.Create(imageInfo, iBitmapImage[source]->DataAddress(), iBitmapImage[source]->DataStride());
   437 		TESTNOERRORL(res);
   438 		CleanupClosePushL(sgImage);		
   439 			
   440 		CDirectGdiDriver* drv = CDirectGdiDriver::Static();
   441 		TEST(drv != NULL);
   442 		
   443 		RDirectGdiDrawableSource* imageSrc = new RDirectGdiDrawableSource(*drv);
   444 		TEST(imageSrc != NULL);
   445 		res = imageSrc->Create(sgImage);		
   446 		TESTNOERRORL(res);	
   447 
   448 		// The test loop.
   449 		// Tile across the target, and avoid clipping and overlapping of tiles.
   450 		const TSize targetSize = GetPixmapSizeInPixels();
   451 		const TSize tileSize = imageInfo.iSizeInPixels;
   452 		const TInt tileColumns = targetSize.iWidth / tileSize.iWidth;
   453 		const TInt tileRows = targetSize.iHeight / tileSize.iHeight;
   454 		const TInt numTiles = tileColumns * tileRows;
   455 		const TInt numPixelsPerIteration = numTiles * tileSize.iWidth * tileSize.iHeight;
   456 		iProfiler->InitResults();
   457 		for(TInt count=KIterationsToTest; count>0; --count)
   458 			{
   459 			TPoint bitmapPosition = TPoint(0,0);
   460 			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   461 				{
   462 				iContext->DrawResource(bitmapPosition, *imageSrc, DirectGdi::EGraphicsRotationNone);
   463 				bitmapPosition.iX += tileSize.iWidth;
   464 				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   465 					{
   466 					bitmapPosition.iX = 0;
   467 					bitmapPosition.iY += tileSize.iHeight;
   468 					}
   469 				}
   470 			iDGdiDriver->Finish();
   471 			}
   472 		iProfiler->MarkResultSetL();
   473 		TESTNOERRORL(iDGdiDriver->GetError());
   474 		
   475 		WriteTargetOutput(KTestName());		
   476 		const TDisplayMode targetDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat);
   477 		iProfiler->ResultsAnalysisPixelRate(KTestName, CFbsBitGc::EGraphicsOrientationNormal, iBitmapImage[source]->DisplayMode(), targetDisplayMode, KIterationsToTest, numPixelsPerIteration);
   478 		
   479 		imageSrc->Close();
   480 		delete imageSrc;
   481 		CleanupStack::PopAndDestroy(1, &sgImage);
   482 		}
   483 	}
   484 
   485 
   486 /**
   487 @SYMTestCaseID
   488 GRAPHICS-UI-BENCH-0156
   489 
   490 @SYMPREQ PREQ39
   491 
   492 @SYMREQ REQ9236 
   493 @SYMREQ REQ9237
   494 
   495 @SYMTestCaseDesc
   496 Measure the performance of DrawBitmapMasked() for the current screen mode, using bitmaps of various 
   497 pixel formats.
   498 
   499 @SYMTestActions
   500 Call DrawBitmapMasked() with a bitmap for various pixel formats of bitmap, using the same bitmap 
   501 as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping. 
   502 
   503 @SYMTestExpectedResults
   504 The performance to be logged as a pixel rate, per bitmap.
   505 */
   506 void CTBitBltPerfDirectGdi::MaskedDrawBitmapL()
   507 	{
   508 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedDrawBitmap"));
   509 	
   510 	_LIT(KTestName, "DirectGdiDrawBitmapM");
   511 	
   512 	// for each display mode
   513 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   514 		{
   515 		BitBltBitmapTestL(EDrawBitmapMasked, iBitmapImage[source], iBitmapTile[0], KCropTo, KTestName, iContext, EFalse);
   516 		}
   517 	}
   518 
   519 /**
   520 @SYMTestCaseID
   521 GRAPHICS-UI-BENCH-0136
   522 
   523 @SYMPREQ PREQ39
   524 
   525 @SYMREQ REQ9236 
   526 @SYMREQ REQ9237
   527 
   528 @SYMTestCaseDesc
   529 Measure the performance of DrawBitmapMasked() for the current screen mode, using bitmaps of various 
   530 pixel formats.
   531 
   532 @SYMTestActions
   533 Call DrawBitmapMasked() with a bitmap for various pixel formats of bitmap, using the same bitmap 
   534 as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping. 
   535 
   536 @SYMTestExpectedResults
   537 The performance to be logged as a pixel rate, per bitmap.
   538 */
   539 void CTBitBltPerfDirectGdi::MaskedDrawBitmapScaledL()
   540 	{
   541 	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedDrawBitmapScaled"));
   542 	
   543 	_LIT(KTestName, "DirectGdiDrawBitmapMS");
   544 	
   545 	// for each display mode
   546 	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   547 		{
   548 		BitBltBitmapTestL(EDrawBitmapMasked, iBitmapImage[source], iBitmapTile[0], KCropTo, KTestName, iContext, ETrue);
   549 		}
   550 	}
   551 
   552 
   553 /**
   554 Helper function to test bitblt bitmaps for different types of blitting. The bitmap is 
   555 tiled across the target to avoid any overdraw. Once the target is filled, the process
   556 is performed for @c KIterationsToTest times.
   557 
   558 @param aBitBltTest the bitblt test to carry out
   559 @param aBitmapToBlt the bitmap to bitblt
   560 @param aBitmapMask the bitmap mask
   561 @param aCrop rectangle to crop bitblt to
   562 @param aOrientation the orientation of the display
   563 @param aTestName the name of the test
   564 @param aGc the graphics context to bitblt to
   565 */
   566 void CTBitBltPerfDirectGdi::BitBltBitmapTestL(TBitBltTest aBitBltTest, CFbsBitmap* aBitmapToBlt, CFbsBitmap* aBitmapMask, TRect aCropTo, const TDesC& aTestName, CDirectGdiContext* aGc, TBool aScaled)
   567 	{
   568 	aGc->Clear();
   569 	iDGdiDriver->Finish();
   570 	const TSize targetSize = GetPixmapSizeInPixels();
   571 
   572 	const TInt scalingFactor = aScaled ? 2 : 1;
   573 	// Calculate the number of tiles that will fit fully on the pixmap
   574 	const TSize tileSize = TSize(aCropTo.Width()/scalingFactor, aCropTo.Height()/scalingFactor);
   575 	const TInt tileColumns = targetSize.iWidth / tileSize.iWidth;
   576 	const TInt tileRows = targetSize.iHeight / tileSize.iHeight;
   577 	const TInt numTiles = tileColumns * tileRows;
   578 	const TInt numPixelsPerIteration = numTiles * tileSize.iWidth * tileSize.iHeight;
   579 	
   580 	switch (aBitBltTest)
   581 	{
   582 	case EDrawBitmap:
   583 		{
   584 		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   585 		aGc->DrawBitmap(TRect(0, 0, tileSize.iWidth, tileSize.iHeight), *aBitmapToBlt);
   586 		iProfiler->InitResults();
   587 		for(TInt count=KIterationsToTest; count>0; --count)
   588 			{
   589 			TPoint bitmapPosition = TPoint(0,0);
   590 			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   591 				{
   592 				aGc->DrawBitmap(TRect(bitmapPosition.iX, bitmapPosition.iY, bitmapPosition.iX+tileSize.iWidth, bitmapPosition.iY+tileSize.iHeight), *aBitmapToBlt);
   593 				bitmapPosition.iX += tileSize.iWidth;
   594 				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   595 					{
   596 					bitmapPosition.iX = 0;
   597 					bitmapPosition.iY += tileSize.iHeight;
   598 					}
   599 				}
   600 			iDGdiDriver->Finish();
   601 			}
   602 		}
   603 		break;
   604 	case EDrawBitmapMasked:
   605 		{
   606 		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   607 		aGc->DrawBitmapMasked(TRect(0, 0, tileSize.iWidth, tileSize.iHeight), *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   608 		iProfiler->InitResults();
   609 		for(TInt count=KIterationsToTest; count>0; --count)
   610 			{
   611 			TPoint bitmapPosition = TPoint(0,0);
   612 			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   613 				{
   614 				aGc->DrawBitmapMasked(TRect(bitmapPosition.iX, bitmapPosition.iY, bitmapPosition.iX+tileSize.iWidth, bitmapPosition.iY+tileSize.iHeight), *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   615 				bitmapPosition.iX += tileSize.iWidth;
   616 				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   617 					{
   618 					bitmapPosition.iX = 0;
   619 					bitmapPosition.iY += tileSize.iHeight;
   620 					}
   621 				}
   622 			iDGdiDriver->Finish();
   623 			}
   624 		}
   625 		break;
   626 	case EBitBlt:
   627 		{
   628 		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   629 		aGc->BitBlt(TPoint(0,0), *aBitmapToBlt, aCropTo);
   630 		iProfiler->InitResults();
   631 		for(TInt count=KIterationsToTest; count>0; --count)
   632 			{
   633 			TPoint bitmapPosition = TPoint(0,0);
   634 			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   635 				{
   636 				aGc->BitBlt(bitmapPosition, *aBitmapToBlt, aCropTo);
   637 				bitmapPosition.iX += tileSize.iWidth;
   638 				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   639 					{
   640 					bitmapPosition.iX = 0;
   641 					bitmapPosition.iY += tileSize.iHeight;
   642 					}
   643 				}
   644 			iDGdiDriver->Finish();
   645 			}
   646 		}
   647 		break;
   648 	case EBitBltMasked:
   649 		{
   650 		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   651 		aGc->BitBltMasked(TPoint(0,0), *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   652 		iProfiler->InitResults();
   653 		for(TInt count=KIterationsToTest; count>0; --count)
   654 			{
   655 			TPoint bitmapPosition = TPoint(0,0);
   656 			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   657 				{
   658 				aGc->BitBltMasked(bitmapPosition, *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   659 				bitmapPosition.iX += tileSize.iWidth;
   660 				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   661 					{
   662 					bitmapPosition.iX = 0;
   663 					bitmapPosition.iY += tileSize.iHeight;
   664 					}
   665 				}
   666 			iDGdiDriver->Finish();
   667 			}
   668 		}
   669 		break;
   670 	}
   671 	
   672 	TESTNOERRORL(iDGdiDriver->GetError());
   673 	iProfiler->MarkResultSetL();
   674 	
   675 	WriteTargetOutput(aTestName);
   676 
   677 	const TDisplayMode targetDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat);
   678 	iProfiler->ResultsAnalysisPixelRate(aTestName, CFbsBitGc::EGraphicsOrientationNormal, aBitmapToBlt->DisplayMode(), targetDisplayMode, KIterationsToTest, numPixelsPerIteration);
   679 	}
   680 #endif