os/graphics/graphicstest/uibench/src/te_graphicsperformanceSuiteStepBase.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 "te_graphicsperformanceSuiteStepBase.h"
    23 #include "te_graphicsperformanceSuiteDefs.h"
    24 #include <hal.h>
    25 #include <fbs.h>
    26 #include <bitdrawinterfaceid.h>
    27 #include <bmalphablend.h>
    28 #include <bitdraw.h>
    29 #include <graphics/gdi/gdiconsts.h>
    30 #include <graphics/fbsdefs.h>
    31 
    32 #ifdef _USE_PROFILER
    33 #include <profiler.h>
    34 #endif
    35 
    36 #ifdef __WINS__
    37 _LIT(KBitmapDrive, "c:");
    38 #else
    39 _LIT(KBitmapDrive, "e:");
    40 #endif
    41 _LIT(KBitmapPath, "\\uibench_sanity\\%S.mbm");
    42 
    43 /**
    44 Gets the size of the hardware display in pixels
    45 @return TSize object containing the screen size
    46 */
    47 TSize GetDisplaySizeInPixels()
    48 	{
    49 	TInt x;
    50 	HAL::Get(HALData::EDisplayXPixels, x);	// Get number x pixel of screen
    51 	TInt y;
    52 	HAL::Get(HALData::EDisplayYPixels, y);	// Get number y pixel of screen
    53 	return TSize(x,y);
    54 	}
    55 
    56 /**
    57 Returns the size of the target used for off-screen drawing
    58 @return TSize object containing the pixmap size.
    59 */
    60 TSize GetPixmapSizeInPixels()
    61 	{
    62 	return TSize(1000, 1000);
    63 	}
    64 
    65 /**
    66 Create a new virtual bitmap device
    67 */
    68 CVirtualBitmapDevice*  CVirtualBitmapDevice::NewL(TDisplayMode aDisplayMode, TBool aForceOffscreen)
    69 	{
    70 	CVirtualBitmapDevice* self = new(ELeave) CVirtualBitmapDevice();
    71 	CleanupStack::PushL(self);
    72 	self->ConstructL(aDisplayMode, aForceOffscreen);	
    73 	CleanupStack::Pop(self);
    74 	return self;
    75 	}
    76 	
    77 /*
    78 @param aDisplayMode The displaymode of the bitmap to create.
    79 @param aForceOffscreen If ETrue, a bitmap device is created instead of a screen device, regardless
    80           of whether the screen supports the display mode.
    81 */
    82 void CVirtualBitmapDevice::ConstructL(TDisplayMode aDisplayMode, TBool aForceOffscreen)
    83 	{	
    84 	// Attempt to create a screen device if not asked to use offscreen bitmap.
    85 	CFbsScreenDevice* screenDevice = NULL;
    86 	TInt ret = KErrNone;
    87 	
    88 	if (!aForceOffscreen)
    89 		{
    90 		TRAP(ret, screenDevice = CFbsScreenDevice::NewL(_L("scdv"), aDisplayMode));
    91 		}
    92 	
    93 	if (aForceOffscreen || ret != KErrNone)
    94 		{		
    95 		// Screen device cannot be created, or we didn't want one, so create an off screen bitmap device		
    96 		iBitmap = new(ELeave) CFbsBitmap;
    97 		TSize scsize= (aForceOffscreen) ? GetPixmapSizeInPixels() : GetDisplaySizeInPixels();
    98 		iBitmap->Create(scsize, aDisplayMode);
    99 		iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);		
   100 		iIsScreenDevice = EFalse;
   101 		}	
   102 	else
   103 		{
   104 		screenDevice->SetAutoUpdate(ETrue);
   105 		iBitmapDevice = screenDevice;
   106 		iIsScreenDevice = ETrue;
   107 		}	
   108 	}
   109 
   110 int CVirtualBitmapDevice::CreateContext(CGraphicsContext *&aGc)
   111 	{	
   112 	return iBitmapDevice->CreateContext(aGc);
   113 	}
   114 
   115 TSize CVirtualBitmapDevice::SizeInPixels() const 
   116 	{
   117 	return iBitmapDevice->SizeInPixels();
   118 	}
   119 
   120 
   121 TInt CVirtualBitmapDevice::isScreenDevice() 
   122 	{
   123 	return iIsScreenDevice;
   124 	}
   125 
   126 CVirtualBitmapDevice::~CVirtualBitmapDevice()
   127 	{
   128 	delete iBitmapDevice;
   129 	delete iBitmap;	
   130 	}
   131 
   132 
   133 /**
   134 Implements the same method on CFbsScreenDevice to Update the screen. This only works on a screen device.
   135 Off screen bitmaps do not have to be updated and no action will be taken in this case.
   136 */
   137 void CVirtualBitmapDevice::Update()
   138 	{
   139 	if (iIsScreenDevice)
   140 		{
   141 		CFbsScreenDevice* screenDevice = static_cast<CFbsScreenDevice*>(iBitmapDevice);
   142 		if (screenDevice)
   143 			screenDevice->Update();
   144 		}
   145 	}
   146 
   147 /**
   148 Returns the actual bitmap device
   149 */
   150 CBitmapDevice& CVirtualBitmapDevice::BitmapDevice()
   151 	{
   152 	return *iBitmapDevice;
   153 	}
   154 
   155 /**
   156 Returns the actual bitmap
   157 */
   158 CFbsBitmap& CVirtualBitmapDevice::Bitmap()
   159 	{
   160 	return *iBitmap;
   161 	}
   162 		
   163 /**
   164 Create a new virtual draw device
   165 */
   166 CVirtualDrawDevice*  CVirtualDrawDevice::NewL(TDisplayMode aDisplayMode)
   167 	{
   168 	CVirtualDrawDevice* self = new(ELeave) CVirtualDrawDevice();
   169 	CleanupStack::PushL(self);
   170 	self->ConstructL(aDisplayMode);
   171 	CleanupStack::Pop(self);
   172 	return self;
   173 	}
   174 	
   175 void CVirtualDrawDevice::ConstructL(TDisplayMode aDisplayMode)
   176 	{
   177 	// Attempt to create a screen device
   178 	CFbsDrawDevice* drawDevice = NULL;
   179 	TRAPD(ret, drawDevice = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, aDisplayMode));
   180 	if (ret != KErrNone)
   181 		{
   182 		// Screen device cannot be created so create an off screen bitmap draw device
   183 		iSize = GetDisplaySizeInPixels();
   184 		iDrawDevice  = CFbsDrawDevice::NewBitmapDeviceL(iSize, aDisplayMode, ByteSize(iSize, aDisplayMode) / iSize.iHeight);
   185 		iDeviceMemory = new (ELeave) TUint8[ByteSize(iSize, aDisplayMode)];
   186 		iDrawDevice->SetBits(iDeviceMemory);
   187 		iIsDrawDevice = EFalse;
   188 		}
   189 	else
   190 		{
   191 		iDrawDevice = drawDevice;
   192 		iSize = iDrawDevice->SizeInPixels();
   193 		iDrawDevice->SetAutoUpdate(ETrue);
   194 		iIsDrawDevice = ETrue;
   195 		}
   196 	}
   197 
   198 TInt CVirtualDrawDevice::ByteSize(const TSize& aSize, TDisplayMode aDisplayMode)
   199 	{
   200 	TInt wordSize = aSize.iWidth;
   201 	switch(aDisplayMode)
   202 		{
   203 	case EGray2:
   204 		wordSize = (wordSize + 31) / 32;
   205 		break;
   206 	case EGray4:
   207 		wordSize = (wordSize + 15) / 16;
   208 		break;
   209 	case EGray16:
   210 	case EColor16:
   211 		wordSize = (wordSize + 7) / 8;
   212 		break;
   213 	case EGray256:
   214 	case EColor256:
   215 		wordSize = (wordSize + 3) / 4;
   216 		break;
   217 	case EColor4K:
   218 	case EColor64K:
   219 		wordSize = (wordSize + 1) / 2;
   220 		break;
   221 	case EColor16M:
   222 		wordSize = (((wordSize * 3) + 11) / 12) * 3;
   223 		break;
   224 	case EColor16MU:
   225 	case EColor16MA:
   226 		//Should not be changed!
   227 		break;
   228 	default:
   229 		break;
   230 		};
   231 	return wordSize * aSize.iHeight * 4;
   232 	}
   233 
   234 CFbsDrawDevice& CVirtualDrawDevice::DrawDevice()
   235 	{
   236 	return *iDrawDevice;
   237 	}
   238 
   239 CVirtualDrawDevice::~CVirtualDrawDevice()
   240 	{
   241 	delete iDrawDevice;
   242 	delete[] iDeviceMemory;
   243 	}
   244 
   245 TBool CVirtualDrawDevice::IsDrawDevice()
   246 	{
   247 	return iIsDrawDevice;
   248 	}
   249 
   250 const TDesC& CTe_graphicsperformanceSuiteStepBase::ColorModeName(TDisplayMode aMode)
   251 	{
   252 	_LIT(KColor4K,"Color4K");
   253 	_LIT(KColor64K,"Color64K");
   254 	_LIT(KColor16M,"Color16M");
   255 	_LIT(KColor16MU,"Color16MU");
   256 	_LIT(KColor16MA,"Color16MA");
   257 	_LIT(KColor16MAP,"Color16MAP");
   258 	_LIT(KUnknown,"Unknown");
   259 	switch(aMode)
   260 		{
   261 	case EColor4K:
   262 		return KColor4K;
   263 	case EColor64K:
   264 		return KColor64K;
   265 	case EColor16M:
   266 		return KColor16M;
   267 	case EColor16MU:
   268 		return KColor16MU;
   269 	case EColor16MA:
   270 		return KColor16MA;
   271 	case EColor16MAP:
   272 		return KColor16MAP;
   273 	default:
   274 		return KUnknown;
   275 		}
   276 	}
   277 
   278 /**
   279 Implementation of CTestStep base class virtual
   280 It is used for doing all initialisation common to derived classes in here.
   281 Make it being able to leave if there are any errors here as there's no point in
   282 trying to run a test step if anything fails.
   283 The leave will be picked up by the framework.
   284 
   285 @return - TVerdict
   286 */
   287 TVerdict CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL()
   288 	{
   289 	SetTestStepResult(EPass);
   290 	
   291 	// Create and install Active Scheduler in case tests require active objects
   292 	iScheduler = new(ELeave) CActiveScheduler;
   293 	CActiveScheduler::Install(iScheduler);
   294 	
   295 	FbsStartup();
   296 	TESTNOERRORL(RFbsSession::Connect());
   297 	HAL::Get(HALData::ECPUSpeed,iCPUSpeed); 
   298 	INFO_PRINTF2(_L("CPUSpeed: %i	kHz"),iCPUSpeed);
   299 	
   300 	// get input for tests from .ini file
   301 	TEST(GetIntFromConfig(_L("Profiling"), _L("DoProfiling"), iDoProfiling));
   302 	TEST(GetBoolFromConfig(_L("SanityCheck"), _L("Bitmaps"), iShowBitmaps));
   303 	
   304 	if (iDoProfiling>0)	
   305 		{
   306 		__INITPROFILER	
   307 		}
   308 			
   309 	iProfiler = CTProfiler::NewL(*this);
   310 	__UHEAP_MARK;	
   311 	return TestStepResult();
   312 	}
   313 
   314 /**
   315 Implementation of CTestStep base class virtual
   316 It is used for doing all after test treatment common to derived classes in here.
   317 Make it being able to leave
   318 The leave will be picked up by the framework.
   319 
   320 @return - TVerdict
   321 */
   322  TVerdict CTe_graphicsperformanceSuiteStepBase::doTestStepPostambleL()
   323 	{
   324 	delete iScheduler;
   325 	iScheduler = NULL;
   326     delete iProfiler;
   327     iProfiler = NULL;
   328 	return TestStepResult();
   329 	}
   330 
   331 CTe_graphicsperformanceSuiteStepBase::~CTe_graphicsperformanceSuiteStepBase()
   332 	{	
   333 	if (iDoProfiling>0)	
   334 		{
   335 		__CLEANUPPROFILER	
   336 		}	
   337 	delete iScreenDevice;	
   338 	delete iGc;
   339 	delete iDrawDevice;
   340 	RFbsSession::Disconnect();
   341 	__UHEAP_MARKEND;
   342 	}
   343 
   344 CTe_graphicsperformanceSuiteStepBase::CTe_graphicsperformanceSuiteStepBase()
   345 	{
   346 	}
   347 
   348 CVirtualBitmapDevice* CTe_graphicsperformanceSuiteStepBase::ScreenDevice()
   349 	{
   350 	TEST(iScreenDevice!=NULL);	// Ensure it is valid
   351 	return iScreenDevice;
   352 	}
   353 
   354 /**
   355 Destroys and recreates the current target device.
   356 
   357 @param aScreenMode The display mode of the target being created
   358 @param aForceOffscreen If ETrue, an offscreen buffer is used as the target instead of the screen. The
   359          dimensions of the buffer are retrieved from GetPixmapSizeInPixels.
   360 */
   361 void CTe_graphicsperformanceSuiteStepBase::SetScreenModeL(TDisplayMode aScreenMode, TBool aForceOffscreen)
   362 	{
   363 	delete iScreenDevice;
   364 	iScreenDevice = NULL;
   365 
   366 	iScreenDevice = CVirtualBitmapDevice::NewL(aScreenMode, aForceOffscreen);
   367 	if (iScreenDevice->isScreenDevice())
   368 		{
   369 		INFO_PRINTF2(_L("SetScreenMode - supported: %S"),&ColorModeName(aScreenMode));
   370 		}
   371 	else
   372 		{
   373 		if (!aForceOffscreen)
   374 			{
   375 			INFO_PRINTF2(_L("SetScreenMode - not supported(using off screen bitmap instead): %S"),&ColorModeName(aScreenMode));
   376 			}
   377 		else
   378 			{
   379 			INFO_PRINTF2(_L("SetScreenMode - using off screen bitmap as requested: %S"),&ColorModeName(aScreenMode));
   380 			}
   381 		}
   382 	delete iGc;
   383 	iGc = NULL;
   384 	User::LeaveIfError(iScreenDevice->CreateContext((CGraphicsContext*&)iGc));
   385 	iScreenSize = iScreenDevice->SizeInPixels();
   386 	}
   387 
   388 void CTe_graphicsperformanceSuiteStepBase::SetDrawDeviceModeL(TDisplayMode aScreenMode)
   389 	{
   390 	delete iDrawDevice;
   391 	iDrawDevice = NULL;
   392 
   393 	iDrawDevice = CVirtualDrawDevice::NewL(aScreenMode);
   394 	if (iDrawDevice->IsDrawDevice())
   395 		{
   396 		INFO_PRINTF2(_L("SetDrawDeviceMode - supported: %S"),&ColorModeName(aScreenMode));
   397 		}
   398 	else
   399 		{
   400 		INFO_PRINTF2(_L("SetDrawDeviceMode - not supported(using off screen bitmap instead): %S"),&ColorModeName(aScreenMode));
   401 		}
   402 	}
   403 
   404 TInt CTe_graphicsperformanceSuiteStepBase::GetDrawDeviceInterfaceL(TInt aInterfaceId, TAny*& aInterface)
   405 	{
   406 	User::LeaveIfNull(iDrawDevice);
   407 	return iDrawDevice->DrawDevice().GetInterface(aInterfaceId, aInterface);	
   408 	}
   409 
   410 void CTe_graphicsperformanceSuiteStepBase::ClearDrawDeviceL(TRgb aColor)
   411 	{
   412 	User::LeaveIfNull(iDrawDevice);
   413 	CFbsDrawDevice& drawDevice = iDrawDevice->DrawDevice();
   414 	TSize size = drawDevice.SizeInPixels();
   415 	drawDevice.SetShadowMode(CFbsDrawDevice::ENoShadow);
   416 	drawDevice.WriteRgbMulti(0,0,size.iWidth,size.iHeight,aColor,CGraphicsContext::EDrawModePEN);
   417 	}
   418 
   419 /**
   420 Creates a bitmap for given size and display mode and leaves it on the cleanup stack
   421 
   422 @return pointer to a created CFbsBitmap 
   423 */
   424 CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CreateSoftwareBitmapLC(const TSize& aSize, TDisplayMode aMode)
   425 	{
   426 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   427 	CleanupStack::PushL(bitmap);
   428 	User::LeaveIfError(bitmap->Create(aSize, aMode));
   429 	return bitmap;
   430 	}
   431 	
   432 /**
   433 Copy a bitmap into another bitmap (generally in a different displaymode)
   434 tiles destination bitmap with source
   435 */
   436 void CTe_graphicsperformanceSuiteStepBase::CopyBitmapL(CFbsBitmap* aDst, CFbsBitmap* aSrc)
   437 	{
   438 	TSize srcSize = aSrc->SizeInPixels();
   439 	TSize dstSize = aDst->SizeInPixels();
   440 	CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(aDst);
   441 	CleanupStack::PushL(dev);
   442 	CFbsBitGc* gc = NULL;
   443 	if ( 0 == dev->CreateContext(gc) )
   444 		{
   445 		CleanupStack::PushL(gc);
   446 		TPoint point;
   447 		gc->SetBrushColor(TRANSPARENT_BLACK);
   448 		gc->SetBrushStyle(CGraphicsContext::ENullBrush);
   449 		gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   450 		gc->Clear();
   451 		gc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   452 		for(point.iY=0; point.iY<dstSize.iHeight; point.iY+=srcSize.iHeight)
   453 			{
   454 			for(point.iX=0; point.iX<dstSize.iWidth; point.iX+=srcSize.iWidth)
   455 				{
   456 				gc->BitBlt(point, aSrc);
   457 				}
   458 			}
   459 		CleanupStack::PopAndDestroy(gc);
   460 		}
   461 	CleanupStack::PopAndDestroy(dev);
   462 	}
   463 
   464 /**
   465 Copy a source bitmap into a new bitmap with the specified display mode
   466 */
   467 CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CopyIntoNewBitmapL(CFbsBitmap* aSrc, TDisplayMode aDisplayMode)
   468 	{
   469 	CFbsBitmap* dstBmp = new(ELeave) CFbsBitmap;
   470 	CleanupStack::PushL(dstBmp);
   471 	TInt ret=dstBmp->Create(aSrc->SizeInPixels(), aDisplayMode);
   472 	User::LeaveIfError(ret);
   473 	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(dstBmp);
   474 	CleanupStack::PushL(bitmapDevice);
   475 	CFbsBitGc* gc;
   476 	ret = bitmapDevice->CreateContext(gc);
   477 	User::LeaveIfError(ret);
   478 	CleanupStack::PushL(gc);
   479 	gc->BitBlt(TPoint(0,0), aSrc);
   480 	CleanupStack::PopAndDestroy(2, bitmapDevice); // gc, bitmapDevice
   481 	CleanupStack::Pop(dstBmp);
   482 	return dstBmp;
   483 	}
   484 
   485 /**
   486 Loads a bitmap from a file
   487 
   488 @param aName the filename of the bitmap to load
   489 @param aIndex the index of the bitmap to load in the file
   490 */
   491 CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::LoadBitmapL(const TDesC& aName, TInt aIndex)
   492 	{
   493 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   494 	CleanupStack::PushL(bitmap);
   495 	User::LeaveIfError(bitmap->Load(aName, aIndex));
   496 	CleanupStack::Pop(bitmap);
   497 	return bitmap;
   498 	}
   499 
   500 /**
   501 Interpolates between the two TRgb values aHi and aLo including alpha channel, with the value aX and the denoinator aN
   502 */	
   503 TRgb CTe_graphicsperformanceSuiteStepBase::InterpolateColour(TRgb aLo, TRgb aHi, TInt aX, TInt aN)
   504 	{
   505 	TInt y = aN - aX;
   506 
   507 	TUint8 a = (TUint8)( (aHi.Alpha()*aX + aLo.Alpha()*y)/aN );
   508 	TUint8 r = (TUint8)( (aHi.Red()*aX + aLo.Red()*y)/aN );
   509 	TUint8 g = (TUint8)( (aHi.Green()*aX + aLo.Green()*y)/aN );
   510 	TUint8 b = (TUint8)( (aHi.Blue()*aX + aLo.Blue()*y)/aN );
   511 	
   512 	return TRgb(r, g, b, a);
   513 	}
   514 
   515 /**
   516 Draws a VerticalGradient onto a CFbsBitmap from top/color aLo to bottom/aHi
   517 */
   518 void CTe_graphicsperformanceSuiteStepBase::VerticalGradientAlphaL(CFbsBitmap* aBitmap, TRgb aLo, TRgb aHi)
   519 	{
   520 	const TSize size = aBitmap->SizeInPixels();
   521 	const TDisplayMode mode = aBitmap->DisplayMode();
   522 	const TInt scanLineLength = CFbsBitmap::ScanLineLength(size.iWidth, mode);
   523 	HBufC8* buffer = HBufC8::NewL(scanLineLength);
   524 	CleanupStack::PushL(buffer);
   525 	TPtr8 des = buffer->Des();
   526 	des.SetLength(scanLineLength);
   527 	for(TInt i=0; i<size.iHeight; i++)
   528 		{
   529 		TRgb color = InterpolateColour(aLo, aHi, i, size.iHeight);
   530 		switch(mode)
   531 			{
   532 			case EGray256:
   533 				{
   534 				TUint8  g = color.Gray256();
   535 				TUint8* p = (TUint8*)des.Ptr();
   536 				for(TInt j=0; j<size.iWidth; j++)
   537 					{						
   538 					p[j] = g;
   539 					}
   540 				}
   541 				break;
   542 			case EColor64K:
   543 				{
   544 				TUint16  g = color._Color64K();
   545 				TUint16* p = (TUint16*)des.Ptr();
   546 				for(TInt j=0; j<size.iWidth/2; j++)
   547 					{						
   548 					p[j] = g;
   549 					}
   550 				}
   551 				break;
   552 			case EColor16MU:
   553 				{
   554 				TUint32 rgba = color._Color16MU();
   555 				TUint32* p = (TUint32*)des.Ptr();
   556 				for(TInt j=0; j<(size.iWidth/4); j++)
   557 					{						
   558 					p[j] = rgba;
   559 					}
   560 				}
   561 				break;
   562 			case EColor16MA:
   563 				{
   564 				TUint32 rgba = color._Color16MA();
   565 				TUint32* p = (TUint32*)des.Ptr();
   566 				for(TInt j=0; j<(size.iWidth/4); j++)
   567 					{						
   568 					p[j] = rgba;
   569 					}
   570 				}
   571 				break;
   572 			case EColor16MAP:
   573 				{
   574 				TUint32 rgba = color._Color16MAP();
   575 				TUint32* p = (TUint32*)des.Ptr();
   576 				for(TInt j=0; j<(size.iWidth/4); j++)
   577 					{						
   578 					p[j] = rgba;
   579 					}
   580 				}
   581 				break;
   582 			default:
   583 				ASSERT(EFalse);
   584 				break;
   585 			}
   586 		aBitmap->SetScanLine(des, i);
   587 		}
   588 	CleanupStack::PopAndDestroy(buffer);
   589 	}
   590 
   591 /**
   592 Create a checked board
   593 @param aPixelFormat The pixel format for create the target bitmap
   594 @param aSize The size of the bitmap
   595 @param aChecksPerAxis Number of checks on X and Y.
   596  */
   597 CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CreateCheckedBoardL(TDisplayMode aDisplayMode, TSize aSize, TSize aChecksPerAxis) const
   598 	{
   599 	
   600 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   601 	CleanupStack::PushL(bitmap);
   602 	bitmap->Create(aSize, aDisplayMode);
   603 	
   604 	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
   605 	CleanupStack::PushL(bitmapDevice);
   606 	
   607 	CFbsBitGc* bitGc = NULL;
   608 	User::LeaveIfError(bitmapDevice->CreateContext(bitGc));
   609 	CleanupStack::PushL(bitGc);
   610 	
   611 	bitGc->Clear();
   612 	bitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   613 	bitGc->SetPenStyle(CGraphicsContext::ENullPen);
   614 	TPoint point(0,0);
   615 	const TSize checkerSize((TReal)aSize.iWidth/aChecksPerAxis.iWidth,(TReal)aSize.iHeight/aChecksPerAxis.iHeight);
   616 	TInt brushColour = 0;
   617 	for(point.iY = 0; point.iY < aSize.iHeight; point.iY += checkerSize.iHeight)
   618 		{
   619 		for(point.iX = 0; point.iX < aSize.iWidth; point.iX += checkerSize.iWidth)
   620 			{
   621 			bitGc->SetBrushColor(KColor16Table[brushColour++ & 0x0F]);
   622 			TRect rect(point, checkerSize);
   623 			bitGc->DrawRect(rect);
   624 			}
   625 		}
   626 	
   627 	CleanupStack::PopAndDestroy(2, bitmapDevice);
   628 	CleanupStack::Pop(bitmap);
   629 	
   630 	return bitmap;
   631 	}
   632 
   633 /* 
   634 Creates a new CFbsBitmap representing the screen/off-screen bitmap. It is the client's
   635 responsibility to delete it.
   636 
   637 @see CTDirectGdiTestBase::GetTargetAsBitmapL.
   638 @return A pointer to the newly created bitmap.
   639 @leave If there was a problem copying from the source to the target.
   640 */
   641 CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::GetTargetAsBitmapL()
   642 	{
   643 	iScreenDevice->Update();
   644 	CFbsBitmap* bitmapCopy = CopyIntoNewBitmapL(&(iScreenDevice->Bitmap()), iScreenDevice->BitmapDevice().DisplayMode());
   645 	return bitmapCopy;
   646 	}
   647 
   648 /**
   649 Creates an mbm file showing the state of the target.
   650 
   651 @param aName The name of the mbm file to produce. Any spaces are replaced by underscores
   652              for easier parsing.
   653 @return KErrNone if bitmap output has been turned off in the config file, or if it was successful.
   654         KErrNoMemory if there is not enough memory to create the bitmap.
   655 */
   656 TInt CTe_graphicsperformanceSuiteStepBase::WriteTargetOutput(TPtrC aName)
   657 	{
   658 	if (!iShowBitmaps)
   659 		{
   660 		return KErrNone;
   661 		}
   662 	
   663 	CFbsBitmap* target = NULL;
   664 	TRAPD(err, target = GetTargetAsBitmapL();)
   665 	
   666 	if (err != KErrNone)
   667 		{
   668 		return err;
   669 		}
   670 
   671 	TBuf<KMaxFileName> fileName;
   672 	fileName.Append(aName);
   673 	
   674 	// replace spaces with underscores.
   675 	TInt pos = fileName.Locate(TChar(' '));
   676 	while(pos != KErrNotFound)
   677 		{
   678 		fileName[pos] = TChar('_');
   679 		pos = fileName.Locate(TChar(' '));
   680 		}	
   681 
   682 	TFileName mbmFile;
   683 	mbmFile.Append(KBitmapDrive);
   684 	mbmFile.AppendFormat(KBitmapPath, &fileName);
   685 		
   686 	err = target->Save(mbmFile);
   687 	delete target;	
   688 	return err;
   689 	}
   690 
   691 
   692 
   693 void CTe_graphicsperformanceSuiteStepBase::ExtractListL(TPtrC aList, RArray<TPtrC>& aListItems)
   694     {
   695     TPtrC tempBuf = aList;
   696     TInt position = tempBuf.Find(_L(","));
   697             
   698     while(position != KErrNotFound)
   699         {
   700         aListItems.AppendL(tempBuf.Left(position));
   701         tempBuf.Set(tempBuf.Mid(position + 2));
   702         position = tempBuf.Find(_L(","));
   703         }   
   704 
   705     if (position == KErrNotFound)
   706         {
   707         aListItems.AppendL(tempBuf);
   708         }
   709     }
   710