os/graphics/graphicstest/uibench/src/tbitbltperf_directgdi.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicstest/uibench/src/tbitbltperf_directgdi.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,680 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code 
    1.23 +*/
    1.24 +
    1.25 +#include "tbitbltperf_directgdi.h"
    1.26 +#include <graphics/directgdidriver.h>
    1.27 +#include <graphics/directgdidrawablesource.h>
    1.28 +#include <bitdrawinterfaceid.h>
    1.29 +#include <bmalphablend.h>
    1.30 +#include <bitdraw.h>
    1.31 +
    1.32 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.33 +_LIT(KBitmap12bit, "z:\\system\\data\\uibench_12bit.mbm");
    1.34 +_LIT(KBitmap16bit, "z:\\system\\data\\uibench_16bit.mbm");
    1.35 +_LIT(KBitmap24bit, "z:\\system\\data\\uibench_24bit.mbm");
    1.36 +_LIT(KBitmap32bit, "z:\\system\\data\\uibench_32bit.mbm");
    1.37 +_LIT(KBitmapTile, "z:\\system\\data\\uibench_tile.mbm");
    1.38 +#endif
    1.39 +
    1.40 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.41 +const TInt KIterationsToTest = 5; 		// Number of iterations to run tests
    1.42 +#endif
    1.43 +const TInt KMaxPixelFormats = 30;		// Number of bitmaps/tiles to create
    1.44 +
    1.45 +// For many of these tests, the size of which the destination blit is cropped to. 
    1.46 +const TRect KCropTo = TRect(0,0,200,200);
    1.47 +
    1.48 +CTBitBltPerfDirectGdi::~CTBitBltPerfDirectGdi()
    1.49 +	{
    1.50 +	}
    1.51 +
    1.52 +CTBitBltPerfDirectGdi::CTBitBltPerfDirectGdi()
    1.53 +	:iBitmapImage(KMaxPixelFormats),
    1.54 +	iBitmapTile(KMaxPixelFormats)
    1.55 +	{
    1.56 +	SetTestStepName(KTBitBltPerfDirectGdi);
    1.57 +	}
    1.58 +
    1.59 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    1.60 +/**
    1.61 +Override of base class virtual
    1.62 +
    1.63 +@return - TVerdict code
    1.64 +*/
    1.65 +TVerdict CTBitBltPerfDirectGdi::doTestStepPreambleL()
    1.66 +	{	
    1.67 +	CTDirectGdiTestBase::doTestStepPreambleL();
    1.68 +	
    1.69 +	// Create a CFbsBitmap image for each source mode we are testing.
    1.70 +	for (TInt srcMode = 0; srcMode < iSourcePixelFormatArray.Count(); ++srcMode)
    1.71 +		{
    1.72 +		TDisplayMode bitmapDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iSourcePixelFormatArray[srcMode]);
    1.73 +		
    1.74 +		CFbsBitmap* bitmapImage = NULL;
    1.75 +		switch(bitmapDisplayMode)
    1.76 +		{
    1.77 +			case EColor4K:
    1.78 +			case EGray256:
    1.79 +				bitmapImage = LoadBitmapL(KBitmap12bit, 0);
    1.80 +				break;
    1.81 +			case EColor64K:
    1.82 +				bitmapImage = LoadBitmapL(KBitmap16bit, 0);
    1.83 +				break;
    1.84 +			case EColor16M:
    1.85 +				bitmapImage = LoadBitmapL(KBitmap24bit, 0);
    1.86 +				break;
    1.87 +			default:
    1.88 +				bitmapImage = LoadBitmapL(KBitmap32bit, 0);
    1.89 +				break;
    1.90 +		}
    1.91 +		if (bitmapImage && bitmapImage->DisplayMode() != bitmapDisplayMode)
    1.92 +			{
    1.93 +			CleanupStack::PushL(bitmapImage);
    1.94 +			CFbsBitmap* tempBitmap = CopyIntoNewBitmapL(bitmapImage, bitmapDisplayMode);
    1.95 +			CleanupStack::PopAndDestroy(1, bitmapImage); //bitmapImage
    1.96 +			bitmapImage = tempBitmap;
    1.97 +			}
    1.98 +		iBitmapImage.AppendL(bitmapImage);
    1.99 +		}
   1.100 +
   1.101 +	// Create 8bit alpha bitmap
   1.102 +	CFbsBitmap* tempBitmap = LoadBitmapL(KBitmap12bit, 0);
   1.103 +	CleanupStack::PushL(tempBitmap);
   1.104 +	iAlpha8bit = CopyIntoNewBitmapL(tempBitmap, EGray256);
   1.105 +	CleanupStack::PopAndDestroy(tempBitmap);	// tempBitmap
   1.106 +
   1.107 +	// Create CFbsBitmaps for the tile images of various pixel formats.
   1.108 +	// The first entry in the array is always the default pixelformat loaded from the mbm.
   1.109 +	// Then in the rest of the array are bitmaps converted to the source pixel formats.
   1.110 +	CFbsBitmap* tile = LoadBitmapL(KBitmapTile, 0);	
   1.111 +	iBitmapTile.AppendL(tile);
   1.112 +	for (TInt srcMode = 0; srcMode < iSourcePixelFormatArray.Count(); ++srcMode)
   1.113 +		{
   1.114 +		TDisplayMode bitmapDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iSourcePixelFormatArray[srcMode]);
   1.115 +		CFbsBitmap* tileCopy = CopyIntoNewBitmapL(tile, bitmapDisplayMode);
   1.116 +		iBitmapTile.AppendL(tileCopy);
   1.117 +		}
   1.118 +	
   1.119 +	return TestStepResult();
   1.120 +	}
   1.121 +
   1.122 +/**
   1.123 +Override of base class virtual
   1.124 +
   1.125 +@return - TVerdict code
   1.126 +*/
   1.127 +TVerdict CTBitBltPerfDirectGdi::doTestStepPostambleL()
   1.128 +	{	
   1.129 +	delete iAlpha8bit;
   1.130 +	iAlpha8bit = NULL;
   1.131 +
   1.132 +	for (TInt ii = iBitmapImage.Count() - 1; ii >= 0; --ii)
   1.133 +		{
   1.134 +		delete iBitmapImage[ii];
   1.135 +		}
   1.136 +	iBitmapImage.Close();
   1.137 +
   1.138 +	for (TInt ii = iBitmapTile.Count() - 1; ii >= 0; --ii)
   1.139 +		{
   1.140 +		delete iBitmapTile[ii];
   1.141 +		}
   1.142 +	iBitmapTile.Close();
   1.143 +
   1.144 +	return CTDirectGdiTestBase::doTestStepPostambleL();
   1.145 +	}
   1.146 +#endif
   1.147 +/**
   1.148 +Override of base class pure virtual
   1.149 +Our implementation only gets called if the base class doTestStepPreambleL() did
   1.150 +not leave. That being the case, the current test result value will be EPass.
   1.151 +
   1.152 +@return - TVerdict code
   1.153 +*/
   1.154 +TVerdict CTBitBltPerfDirectGdi::doTestStepL()
   1.155 +	{
   1.156 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   1.157 +    INFO_PRINTF1(_L("CTBitBltPerfDirectGdi can only be run with RSgImage legacy"));
   1.158 +    return TestStepResult();
   1.159 +#else
   1.160 +	// for each display mode
   1.161 +	for(TInt dispModeIndex = 0; dispModeIndex < iTargetPixelFormatArray.Count(); ++dispModeIndex)
   1.162 +		{
   1.163 +		TDisplayMode targetDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iTargetPixelFormatArray[dispModeIndex]);
   1.164 +		if(SetTargetPixelFormatL(targetDisplayMode))
   1.165 +			{
   1.166 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0150"));
   1.167 +			SimpleBitBltL();
   1.168 +			RecordTestResultL();
   1.169 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0151"));
   1.170 +			SimpleDrawBitmapL();
   1.171 +			RecordTestResultL();
   1.172 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0153"));
   1.173 +			MaskedBitBltAlphaL();
   1.174 +			RecordTestResultL();
   1.175 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0154"));
   1.176 +			MaskedBitBltSameL();
   1.177 +			RecordTestResultL();
   1.178 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0155"));
   1.179 +			MaskedBitBltL();
   1.180 +			RecordTestResultL();
   1.181 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0156"));
   1.182 +			MaskedDrawBitmapL();
   1.183 +			RecordTestResultL();
   1.184 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0136"));
   1.185 +			MaskedDrawBitmapScaledL();
   1.186 +			RecordTestResultL();
   1.187 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0157"));
   1.188 +			BitBltCpuAccessL();
   1.189 +			RecordTestResultL();
   1.190 +			SetTestStepID(_L("GRAPHICS-UI-BENCH-0158"));
   1.191 +			SimpleDrawResourceL();
   1.192 +			RecordTestResultL();
   1.193 +			}
   1.194 +		}
   1.195 +
   1.196 +    CloseTMSGraphicsStep();
   1.197 +	return TestStepResult();
   1.198 +#endif	
   1.199 +	}
   1.200 +
   1.201 +#ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
   1.202 +/**
   1.203 +@SYMTestCaseID
   1.204 +GRAPHICS-UI-BENCH-0150
   1.205 +
   1.206 +@SYMPREQ PREQ39
   1.207 +
   1.208 +@SYMREQ REQ9236 
   1.209 +@SYMREQ REQ9237
   1.210 +
   1.211 +@SYMTestCaseDesc
   1.212 +Measure the performance of BitBlt() for the current screen mode and for various bitmap pixel formats.
   1.213 +
   1.214 +@SYMTestActions
   1.215 +Draw an entire bitmap using BitBlt(), with no overlapping or clipping. 
   1.216 +Measure the time taken.
   1.217 +
   1.218 +@SYMTestExpectedResults
   1.219 +The performance to be logged as a pixel rate, per bitmap.
   1.220 +*/
   1.221 +void CTBitBltPerfDirectGdi::SimpleBitBltL()
   1.222 +	{
   1.223 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::SimpleBitBlt"));
   1.224 +	
   1.225 +	_LIT(KTestName, "DirectGdiBitBlt");
   1.226 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.227 +		{
   1.228 +		BitBltBitmapTestL(EBitBlt, iBitmapImage[source], NULL, KCropTo, KTestName, iContext);
   1.229 +		}
   1.230 +	}
   1.231 +
   1.232 +/**
   1.233 +@SYMTestCaseID
   1.234 +GRAPHICS-UI-BENCH-0151
   1.235 +
   1.236 +@SYMPREQ PREQ39
   1.237 +
   1.238 +@SYMREQ REQ9236 
   1.239 +@SYMREQ REQ9237
   1.240 +
   1.241 +@SYMTestCaseDesc
   1.242 +Measures the performance of DrawBitmap() for the current screen mode, for various bitmap pixel formats.
   1.243 +The bitmap is drawn without scaling.
   1.244 +
   1.245 +@SYMTestActions
   1.246 +Create a copy of the bitmap, and scale to the required size, prior to running the test.
   1.247 +For each required source pixel format, use DrawBitmap() to tile a bitmap across the target, avoiding any
   1.248 +clipping or overlap. 
   1.249 +
   1.250 +@SYMTestExpectedResults
   1.251 +The performance to be logged as a pixel rate, per bitmap.
   1.252 +*/
   1.253 +void CTBitBltPerfDirectGdi::SimpleDrawBitmapL()
   1.254 +	{
   1.255 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::SimpleDrawBitmap"));
   1.256 +	
   1.257 +	_LIT(KTestName, "DirectGdiDrawBitmap");
   1.258 +
   1.259 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.260 +		{
   1.261 +		// Use a bitmap that needs no scaling.
   1.262 +		CFbsBitmap* bitmapBitBltImage = CopyIntoNewBitmapL(iBitmapImage[source], iBitmapImage[source]->DisplayMode());
   1.263 +		CleanupStack::PushL(bitmapBitBltImage);
   1.264 +		bitmapBitBltImage->Resize(KCropTo.Size());
   1.265 +		BitBltBitmapTestL(EDrawBitmap, bitmapBitBltImage, NULL, bitmapBitBltImage->SizeInPixels(), KTestName, iContext);
   1.266 +		CleanupStack::PopAndDestroy(1, bitmapBitBltImage);
   1.267 +		}
   1.268 +	}
   1.269 +
   1.270 +/**
   1.271 +@SYMTestCaseID
   1.272 +GRAPHICS-UI-BENCH-0155
   1.273 +
   1.274 +@SYMPREQ PREQ39
   1.275 +
   1.276 +@SYMREQ REQ9236 
   1.277 +@SYMREQ REQ9237
   1.278 +
   1.279 +@SYMTestCaseDesc
   1.280 +Measure the performance of BitBltMasked() for the current screen mode, using bitmaps of various 
   1.281 +pixel formats.
   1.282 +
   1.283 +@SYMTestActions
   1.284 +Call BitBltMasked() with a bitmap for various pixel formats of bitmap, using the same bitmap 
   1.285 +as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping. 
   1.286 +
   1.287 +@SYMTestExpectedResults
   1.288 +The performance to be logged as a pixel rate, per bitmap.
   1.289 +*/
   1.290 +void CTBitBltPerfDirectGdi::MaskedBitBltL()
   1.291 +	{
   1.292 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedBitBlt"));
   1.293 +	
   1.294 +	_LIT(KTestName, "DirectGdiMBitBlt");
   1.295 +	
   1.296 +	// for each display mode
   1.297 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.298 +		{
   1.299 +		BitBltBitmapTestL(EBitBltMasked, iBitmapImage[source], iBitmapTile[0], KCropTo, KTestName, iContext);
   1.300 +		}
   1.301 +	}
   1.302 +
   1.303 +/**
   1.304 +@SYMTestCaseID
   1.305 +GRAPHICS-UI-BENCH-0154
   1.306 +
   1.307 +@SYMPREQ PREQ39
   1.308 +
   1.309 +@SYMREQ REQ9236 
   1.310 +@SYMREQ REQ9237
   1.311 +
   1.312 +@SYMTestCaseDesc
   1.313 +Measure the performance of BitBlt(), using the same bitmap as a mask with different screen modes.
   1.314 +
   1.315 +@SYMTestActions
   1.316 +Call BitBltMasked() with a bitmap for various pixel formats of bitmap, using the bitmap 
   1.317 +as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping.
   1.318 +
   1.319 +@SYMTestExpectedResults
   1.320 +The performance to be logged as a pixel rate, per bitmap.
   1.321 +*/	
   1.322 +void CTBitBltPerfDirectGdi::MaskedBitBltSameL()
   1.323 +	{
   1.324 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedBitBltSame"));
   1.325 +	
   1.326 +	_LIT(KTestName, "DirectGdiMBitBltS");
   1.327 +	
   1.328 +	for (TInt tile = 0; tile < iBitmapTile.Count(); ++tile)
   1.329 +		{
   1.330 +		BitBltBitmapTestL(EBitBltMasked, iBitmapTile[tile], iBitmapTile[tile], KCropTo, KTestName, iContext);
   1.331 +		}
   1.332 +	}
   1.333 +
   1.334 +
   1.335 +/**
   1.336 +@SYMTestCaseID
   1.337 +GRAPHICS-UI-BENCH-0153
   1.338 +
   1.339 +@SYMPREQ PREQ39
   1.340 +
   1.341 +@SYMREQ REQ9236 
   1.342 +@SYMREQ REQ9237
   1.343 +
   1.344 +@SYMTestCaseDesc
   1.345 +Measure the performance of BitBltMasked(), with an alpha bitmap with different screen modes.
   1.346 +
   1.347 +@SYMTestActions
   1.348 +Call BitBltMasked() with a bitmap for various pixel formats of bitmap, using the same alpha bitmap 
   1.349 +as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping.
   1.350 +
   1.351 +@SYMTestExpectedResults
   1.352 +The performance to be logged as a pixel rate, per bitmap.
   1.353 +*/
   1.354 +void CTBitBltPerfDirectGdi::MaskedBitBltAlphaL()
   1.355 +	{
   1.356 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedBitBltAlpha"));	
   1.357 +	
   1.358 +	_LIT(KTestName, "DirectGdiMBitBltA");
   1.359 +	
   1.360 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.361 +		{
   1.362 +		BitBltBitmapTestL(EBitBltMasked, iBitmapImage[source], iAlpha8bit, KCropTo, KTestName, iContext);
   1.363 +		}
   1.364 +	}
   1.365 +
   1.366 +/**
   1.367 +@SYMTestCaseID
   1.368 +GRAPHICS-UI-BENCH-0157
   1.369 +
   1.370 +@SYMPREQ PREQ39
   1.371 +
   1.372 +@SYMREQ REQ9236 
   1.373 +@SYMREQ REQ9237
   1.374 +
   1.375 +@SYMTestCaseDesc
   1.376 +Measure the performance of BitBlt() for the current screen mode and for various bitmap pixel formats,
   1.377 +with a bitmap that is accessed by the CPU via DataAddresss(), and is therefore never cached by DirectGDI.
   1.378 +
   1.379 +@SYMTestActions
   1.380 +Create a copy of a test bitmap.
   1.381 +Call DataAddress() on the bitmap.
   1.382 +Draw an entire bitmap using BitBlt(), with no overlapping or clipping. 
   1.383 +Measure the time taken.
   1.384 +
   1.385 +@SYMTestExpectedResults
   1.386 +The performance to be logged as a pixel rate, per bitmap.
   1.387 +*/
   1.388 +void CTBitBltPerfDirectGdi::BitBltCpuAccessL()
   1.389 +	{
   1.390 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::BitBltCpuAccess"));
   1.391 +	
   1.392 +	_LIT(KTestName, "DirectGdiBitBltCpuAccess");
   1.393 +
   1.394 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.395 +		{
   1.396 +		CFbsBitmap* bitmapBitBltImage = CopyIntoNewBitmapL(iBitmapImage[source], iBitmapImage[source]->DisplayMode());
   1.397 +		TESTL(bitmapBitBltImage != NULL);
   1.398 +		CleanupStack::PushL(bitmapBitBltImage);
   1.399 +		bitmapBitBltImage->DataAddress();	// CPU Access so that it is not cached by DirectGDI.
   1.400 +		BitBltBitmapTestL(EBitBlt, bitmapBitBltImage, NULL, KCropTo, KTestName, iContext);
   1.401 +		CleanupStack::PopAndDestroy(1, bitmapBitBltImage);		
   1.402 +		}
   1.403 +	}
   1.404 +
   1.405 +/**
   1.406 +@SYMTestCaseID
   1.407 +GRAPHICS-UI-BENCH-0158
   1.408 +
   1.409 +@SYMPREQ PREQ39
   1.410 +
   1.411 +@SYMREQ REQ9236 
   1.412 +@SYMREQ REQ9237
   1.413 +
   1.414 +@SYMTestCaseDesc
   1.415 +Measure the performance of DrawResource() for the current screen mode and for various bitmap pixel formats,
   1.416 +with no rotation.
   1.417 +
   1.418 +@SYMTestActions
   1.419 +Draw an entire bitmap using DrawResource(), by tiling the image across the target to avoid overlapping and
   1.420 +clipping. Measure the time taken.
   1.421 +
   1.422 +@SYMTestExpectedResults
   1.423 +The performance to be logged as a pixel rate, per bitmap.
   1.424 +*/
   1.425 +void CTBitBltPerfDirectGdi::SimpleDrawResourceL()
   1.426 +	{
   1.427 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::SimpleDrawResource"));
   1.428 +	_LIT(KTestName, "DirectGdiDrawResource");
   1.429 +		
   1.430 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.431 +		{
   1.432 +		TSgImageInfo imageInfo;
   1.433 +		imageInfo.iSizeInPixels = iBitmapImage[source]->SizeInPixels();
   1.434 +		imageInfo.iPixelFormat = TDisplayModeMapping::MapDisplayModeToPixelFormat(iBitmapImage[source]->DisplayMode());
   1.435 +		imageInfo.iUsage = ESgUsageDirectGdiSource;
   1.436 +
   1.437 +		// Create an RSgImage from the CFbsBitmap.
   1.438 +		RSgImage sgImage;	
   1.439 +		TInt res = sgImage.Create(imageInfo, iBitmapImage[source]->DataAddress(), iBitmapImage[source]->DataStride());
   1.440 +		TESTNOERRORL(res);
   1.441 +		CleanupClosePushL(sgImage);		
   1.442 +			
   1.443 +		CDirectGdiDriver* drv = CDirectGdiDriver::Static();
   1.444 +		TEST(drv != NULL);
   1.445 +		
   1.446 +		RDirectGdiDrawableSource* imageSrc = new RDirectGdiDrawableSource(*drv);
   1.447 +		TEST(imageSrc != NULL);
   1.448 +		res = imageSrc->Create(sgImage);		
   1.449 +		TESTNOERRORL(res);	
   1.450 +
   1.451 +		// The test loop.
   1.452 +		// Tile across the target, and avoid clipping and overlapping of tiles.
   1.453 +		const TSize targetSize = GetPixmapSizeInPixels();
   1.454 +		const TSize tileSize = imageInfo.iSizeInPixels;
   1.455 +		const TInt tileColumns = targetSize.iWidth / tileSize.iWidth;
   1.456 +		const TInt tileRows = targetSize.iHeight / tileSize.iHeight;
   1.457 +		const TInt numTiles = tileColumns * tileRows;
   1.458 +		const TInt numPixelsPerIteration = numTiles * tileSize.iWidth * tileSize.iHeight;
   1.459 +		iProfiler->InitResults();
   1.460 +		for(TInt count=KIterationsToTest; count>0; --count)
   1.461 +			{
   1.462 +			TPoint bitmapPosition = TPoint(0,0);
   1.463 +			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   1.464 +				{
   1.465 +				iContext->DrawResource(bitmapPosition, *imageSrc, DirectGdi::EGraphicsRotationNone);
   1.466 +				bitmapPosition.iX += tileSize.iWidth;
   1.467 +				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   1.468 +					{
   1.469 +					bitmapPosition.iX = 0;
   1.470 +					bitmapPosition.iY += tileSize.iHeight;
   1.471 +					}
   1.472 +				}
   1.473 +			iDGdiDriver->Finish();
   1.474 +			}
   1.475 +		iProfiler->MarkResultSetL();
   1.476 +		TESTNOERRORL(iDGdiDriver->GetError());
   1.477 +		
   1.478 +		WriteTargetOutput(KTestName());		
   1.479 +		const TDisplayMode targetDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat);
   1.480 +		iProfiler->ResultsAnalysisPixelRate(KTestName, CFbsBitGc::EGraphicsOrientationNormal, iBitmapImage[source]->DisplayMode(), targetDisplayMode, KIterationsToTest, numPixelsPerIteration);
   1.481 +		
   1.482 +		imageSrc->Close();
   1.483 +		delete imageSrc;
   1.484 +		CleanupStack::PopAndDestroy(1, &sgImage);
   1.485 +		}
   1.486 +	}
   1.487 +
   1.488 +
   1.489 +/**
   1.490 +@SYMTestCaseID
   1.491 +GRAPHICS-UI-BENCH-0156
   1.492 +
   1.493 +@SYMPREQ PREQ39
   1.494 +
   1.495 +@SYMREQ REQ9236 
   1.496 +@SYMREQ REQ9237
   1.497 +
   1.498 +@SYMTestCaseDesc
   1.499 +Measure the performance of DrawBitmapMasked() for the current screen mode, using bitmaps of various 
   1.500 +pixel formats.
   1.501 +
   1.502 +@SYMTestActions
   1.503 +Call DrawBitmapMasked() with a bitmap for various pixel formats of bitmap, using the same bitmap 
   1.504 +as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping. 
   1.505 +
   1.506 +@SYMTestExpectedResults
   1.507 +The performance to be logged as a pixel rate, per bitmap.
   1.508 +*/
   1.509 +void CTBitBltPerfDirectGdi::MaskedDrawBitmapL()
   1.510 +	{
   1.511 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedDrawBitmap"));
   1.512 +	
   1.513 +	_LIT(KTestName, "DirectGdiDrawBitmapM");
   1.514 +	
   1.515 +	// for each display mode
   1.516 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.517 +		{
   1.518 +		BitBltBitmapTestL(EDrawBitmapMasked, iBitmapImage[source], iBitmapTile[0], KCropTo, KTestName, iContext, EFalse);
   1.519 +		}
   1.520 +	}
   1.521 +
   1.522 +/**
   1.523 +@SYMTestCaseID
   1.524 +GRAPHICS-UI-BENCH-0136
   1.525 +
   1.526 +@SYMPREQ PREQ39
   1.527 +
   1.528 +@SYMREQ REQ9236 
   1.529 +@SYMREQ REQ9237
   1.530 +
   1.531 +@SYMTestCaseDesc
   1.532 +Measure the performance of DrawBitmapMasked() for the current screen mode, using bitmaps of various 
   1.533 +pixel formats.
   1.534 +
   1.535 +@SYMTestActions
   1.536 +Call DrawBitmapMasked() with a bitmap for various pixel formats of bitmap, using the same bitmap 
   1.537 +as the mask bitmap each time. The bitmap is tiled across the target to avoid overlapping or clipping. 
   1.538 +
   1.539 +@SYMTestExpectedResults
   1.540 +The performance to be logged as a pixel rate, per bitmap.
   1.541 +*/
   1.542 +void CTBitBltPerfDirectGdi::MaskedDrawBitmapScaledL()
   1.543 +	{
   1.544 +	INFO_PRINTF1(_L("CTBitBltPerfDirectGdi::MaskedDrawBitmapScaled"));
   1.545 +	
   1.546 +	_LIT(KTestName, "DirectGdiDrawBitmapMS");
   1.547 +	
   1.548 +	// for each display mode
   1.549 +	for (TInt source = 0; source < iBitmapImage.Count(); ++source)
   1.550 +		{
   1.551 +		BitBltBitmapTestL(EDrawBitmapMasked, iBitmapImage[source], iBitmapTile[0], KCropTo, KTestName, iContext, ETrue);
   1.552 +		}
   1.553 +	}
   1.554 +
   1.555 +
   1.556 +/**
   1.557 +Helper function to test bitblt bitmaps for different types of blitting. The bitmap is 
   1.558 +tiled across the target to avoid any overdraw. Once the target is filled, the process
   1.559 +is performed for @c KIterationsToTest times.
   1.560 +
   1.561 +@param aBitBltTest the bitblt test to carry out
   1.562 +@param aBitmapToBlt the bitmap to bitblt
   1.563 +@param aBitmapMask the bitmap mask
   1.564 +@param aCrop rectangle to crop bitblt to
   1.565 +@param aOrientation the orientation of the display
   1.566 +@param aTestName the name of the test
   1.567 +@param aGc the graphics context to bitblt to
   1.568 +*/
   1.569 +void CTBitBltPerfDirectGdi::BitBltBitmapTestL(TBitBltTest aBitBltTest, CFbsBitmap* aBitmapToBlt, CFbsBitmap* aBitmapMask, TRect aCropTo, const TDesC& aTestName, CDirectGdiContext* aGc, TBool aScaled)
   1.570 +	{
   1.571 +	aGc->Clear();
   1.572 +	iDGdiDriver->Finish();
   1.573 +	const TSize targetSize = GetPixmapSizeInPixels();
   1.574 +
   1.575 +	const TInt scalingFactor = aScaled ? 2 : 1;
   1.576 +	// Calculate the number of tiles that will fit fully on the pixmap
   1.577 +	const TSize tileSize = TSize(aCropTo.Width()/scalingFactor, aCropTo.Height()/scalingFactor);
   1.578 +	const TInt tileColumns = targetSize.iWidth / tileSize.iWidth;
   1.579 +	const TInt tileRows = targetSize.iHeight / tileSize.iHeight;
   1.580 +	const TInt numTiles = tileColumns * tileRows;
   1.581 +	const TInt numPixelsPerIteration = numTiles * tileSize.iWidth * tileSize.iHeight;
   1.582 +	
   1.583 +	switch (aBitBltTest)
   1.584 +	{
   1.585 +	case EDrawBitmap:
   1.586 +		{
   1.587 +		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   1.588 +		aGc->DrawBitmap(TRect(0, 0, tileSize.iWidth, tileSize.iHeight), *aBitmapToBlt);
   1.589 +		iProfiler->InitResults();
   1.590 +		for(TInt count=KIterationsToTest; count>0; --count)
   1.591 +			{
   1.592 +			TPoint bitmapPosition = TPoint(0,0);
   1.593 +			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   1.594 +				{
   1.595 +				aGc->DrawBitmap(TRect(bitmapPosition.iX, bitmapPosition.iY, bitmapPosition.iX+tileSize.iWidth, bitmapPosition.iY+tileSize.iHeight), *aBitmapToBlt);
   1.596 +				bitmapPosition.iX += tileSize.iWidth;
   1.597 +				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   1.598 +					{
   1.599 +					bitmapPosition.iX = 0;
   1.600 +					bitmapPosition.iY += tileSize.iHeight;
   1.601 +					}
   1.602 +				}
   1.603 +			iDGdiDriver->Finish();
   1.604 +			}
   1.605 +		}
   1.606 +		break;
   1.607 +	case EDrawBitmapMasked:
   1.608 +		{
   1.609 +		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   1.610 +		aGc->DrawBitmapMasked(TRect(0, 0, tileSize.iWidth, tileSize.iHeight), *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   1.611 +		iProfiler->InitResults();
   1.612 +		for(TInt count=KIterationsToTest; count>0; --count)
   1.613 +			{
   1.614 +			TPoint bitmapPosition = TPoint(0,0);
   1.615 +			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   1.616 +				{
   1.617 +				aGc->DrawBitmapMasked(TRect(bitmapPosition.iX, bitmapPosition.iY, bitmapPosition.iX+tileSize.iWidth, bitmapPosition.iY+tileSize.iHeight), *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   1.618 +				bitmapPosition.iX += tileSize.iWidth;
   1.619 +				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   1.620 +					{
   1.621 +					bitmapPosition.iX = 0;
   1.622 +					bitmapPosition.iY += tileSize.iHeight;
   1.623 +					}
   1.624 +				}
   1.625 +			iDGdiDriver->Finish();
   1.626 +			}
   1.627 +		}
   1.628 +		break;
   1.629 +	case EBitBlt:
   1.630 +		{
   1.631 +		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   1.632 +		aGc->BitBlt(TPoint(0,0), *aBitmapToBlt, aCropTo);
   1.633 +		iProfiler->InitResults();
   1.634 +		for(TInt count=KIterationsToTest; count>0; --count)
   1.635 +			{
   1.636 +			TPoint bitmapPosition = TPoint(0,0);
   1.637 +			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   1.638 +				{
   1.639 +				aGc->BitBlt(bitmapPosition, *aBitmapToBlt, aCropTo);
   1.640 +				bitmapPosition.iX += tileSize.iWidth;
   1.641 +				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   1.642 +					{
   1.643 +					bitmapPosition.iX = 0;
   1.644 +					bitmapPosition.iY += tileSize.iHeight;
   1.645 +					}
   1.646 +				}
   1.647 +			iDGdiDriver->Finish();
   1.648 +			}
   1.649 +		}
   1.650 +		break;
   1.651 +	case EBitBltMasked:
   1.652 +		{
   1.653 +		// Do a draw outside the loop so that we aren't measuring the time to load and cache the bitmap.
   1.654 +		aGc->BitBltMasked(TPoint(0,0), *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   1.655 +		iProfiler->InitResults();
   1.656 +		for(TInt count=KIterationsToTest; count>0; --count)
   1.657 +			{
   1.658 +			TPoint bitmapPosition = TPoint(0,0);
   1.659 +			for (TInt tile = numTiles - 1; tile >= 0; --tile)
   1.660 +				{
   1.661 +				aGc->BitBltMasked(bitmapPosition, *aBitmapToBlt, aCropTo, *aBitmapMask, EFalse);
   1.662 +				bitmapPosition.iX += tileSize.iWidth;
   1.663 +				if (bitmapPosition.iX + tileSize.iWidth > targetSize.iWidth)
   1.664 +					{
   1.665 +					bitmapPosition.iX = 0;
   1.666 +					bitmapPosition.iY += tileSize.iHeight;
   1.667 +					}
   1.668 +				}
   1.669 +			iDGdiDriver->Finish();
   1.670 +			}
   1.671 +		}
   1.672 +		break;
   1.673 +	}
   1.674 +	
   1.675 +	TESTNOERRORL(iDGdiDriver->GetError());
   1.676 +	iProfiler->MarkResultSetL();
   1.677 +	
   1.678 +	WriteTargetOutput(aTestName);
   1.679 +
   1.680 +	const TDisplayMode targetDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iImageInfo.iPixelFormat);
   1.681 +	iProfiler->ResultsAnalysisPixelRate(aTestName, CFbsBitGc::EGraphicsOrientationNormal, aBitmapToBlt->DisplayMode(), targetDisplayMode, KIterationsToTest, numPixelsPerIteration);
   1.682 +	}
   1.683 +#endif