os/graphics/graphicsapitest/screendriverhaitest/screendriver/src/t_cfbsdrawdevicedata.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.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#include "t_cfbsdrawdevicedata.h"
sl@0
    19
#include <hal.h>
sl@0
    20
#include <e32math.h>
sl@0
    21
sl@0
    22
_LIT(KDisplayMode, 					"displayMode");
sl@0
    23
_LIT(KDrawMode, 					"drawMode");
sl@0
    24
_LIT(KOrientationMode,				"orientationMode");
sl@0
    25
_LIT(KShadowMode, 					"shadowMode");
sl@0
    26
_LIT(KBackColor, 					"backColor");
sl@0
    27
_LIT(KNumRect,	 					"numRect");
sl@0
    28
_LIT(KRectangles, 					"rectangles");
sl@0
    29
_LIT(KRectangleSection, 			"RECTANGLES");
sl@0
    30
_LIT(KNumTestRect,		 			"numTestRect");
sl@0
    31
_LIT(KAutoUpdate,					"autoUpdate");
sl@0
    32
_LIT(KCmdNewScreenDeviceL,			"NewScreenDeviceL");
sl@0
    33
_LIT(KCmdDestructor,				"~");
sl@0
    34
_LIT(KCmdInitScreen,				"InitScreen");
sl@0
    35
_LIT(KCmdSetDisplayMode,			"SetDisplayMode");
sl@0
    36
_LIT(KCmdSetAutoUpdate,				"SetAutoUpdate");
sl@0
    37
_LIT(KCmdOrientationsAvailable,		"OrientationsAvailable");
sl@0
    38
_LIT(KCmdSetOrientation,			"SetOrientation");
sl@0
    39
_LIT(KCmdWriteRgb, 					"WriteRgb");
sl@0
    40
_LIT(KCmdWriteLine, 				"WriteLine");
sl@0
    41
_LIT(KCmdWriteBinaryLine, 			"WriteBinaryLine");
sl@0
    42
_LIT(KCmdWriteRgbMulti, 			"WriteRgbMulti");
sl@0
    43
_LIT(KCmdReadLine,		 			"ReadLine");
sl@0
    44
_LIT(KCmdWriteRGBAlphaLine, 		"WriteRGBAlphaLine");
sl@0
    45
_LIT(KCmdSetShadowMode, 			"SetShadowMode");
sl@0
    46
_LIT(KCmdShadowArea, 				"ShadowArea");
sl@0
    47
_LIT(KCmdWriteBinary, 				"WriteBinary");
sl@0
    48
_LIT(KCmdWriteBinaryLineVertical, 	"WriteBinaryLineVertical");
sl@0
    49
_LIT(KNoShadow,						"ENoShadow");
sl@0
    50
_LIT(KShadow,						"EShadow");
sl@0
    51
_LIT(KFade,							"EFade");
sl@0
    52
_LIT(KShadowFade,					"EShadowFade");
sl@0
    53
_LIT(KNone, 						"ENone");
sl@0
    54
_LIT(KGray2,						"EGray2");
sl@0
    55
_LIT(KGray4,						"EGray4");
sl@0
    56
_LIT(KGray16,						"EGray16");
sl@0
    57
_LIT(KGray256,						"EGray256");
sl@0
    58
_LIT(KColor16,						"EColor16");
sl@0
    59
_LIT(KColor256,						"EColor256");
sl@0
    60
_LIT(KColor64K,						"EColor64K");
sl@0
    61
_LIT(KColor16M,						"EColor16M");
sl@0
    62
_LIT(KRgb,							"ERgb");
sl@0
    63
_LIT(KColor4K,						"EColor4K");
sl@0
    64
_LIT(KColor16MU,					"EColor16MU");
sl@0
    65
_LIT(KColor16MA,					"EColor16MA");
sl@0
    66
_LIT(KColor16MAP,					"EColor16MAP");
sl@0
    67
_LIT(KColorLast,					"EColorLast");
sl@0
    68
_LIT(KDrawModePEN,					"EDrawModePEN");
sl@0
    69
_LIT(KDrawModeAND,					"EDrawModeAND");
sl@0
    70
_LIT(KDrawModeXOR,					"EDrawModeXOR");
sl@0
    71
_LIT(KDrawModeOR,					"EDrawModeOR");
sl@0
    72
_LIT(KDrawModeNOTSCREEN,			"EDrawModeNOTSCREEN");
sl@0
    73
_LIT(KDrawModeNOTPEN,				"EDrawModeNOTPEN");
sl@0
    74
_LIT(KDelay,						"delay");
sl@0
    75
_LIT(KOrientationNormal,			"EOrientationNormal");
sl@0
    76
_LIT(KOrientationRotated90,			"EOrientationRotated90");
sl@0
    77
_LIT(KOrientationRotated180,		"EOrientationRotated180");
sl@0
    78
_LIT(KOrientationRotated270,		"EOrientationRotated270");
sl@0
    79
sl@0
    80
/**
sl@0
    81
 * Shadow modes
sl@0
    82
 */
sl@0
    83
const CDataWrapperBase::TEnumEntryTable	CT_CFbsDrawDeviceData::iEnumShadowModes[] =
sl@0
    84
	{
sl@0
    85
	KNoShadow,		1,
sl@0
    86
	KShadow,		2,
sl@0
    87
	KFade,			3,
sl@0
    88
	KShadowFade,	4
sl@0
    89
	};
sl@0
    90
sl@0
    91
/**
sl@0
    92
 *Display Modes
sl@0
    93
 */
sl@0
    94
const CDataWrapperBase::TEnumEntryTable	CT_CFbsDrawDeviceData::iEnumDisplayModes[] =
sl@0
    95
	{
sl@0
    96
	KNone,			ENone,
sl@0
    97
	KGray2,			EGray2,
sl@0
    98
	KGray4,			EGray4,
sl@0
    99
	KGray16,		EGray16,
sl@0
   100
	KGray256,		EGray256,
sl@0
   101
	KColor16,		EColor16,
sl@0
   102
	KColor256,		EColor256,
sl@0
   103
	KColor64K,		EColor64K,
sl@0
   104
	KColor16M,		EColor16M,
sl@0
   105
	KRgb,			ERgb,
sl@0
   106
	KColor4K,		EColor4K,
sl@0
   107
	KColor16MU,		EColor16MU,
sl@0
   108
	KColor16MA,		EColor16MA,
sl@0
   109
	KColor16MA,		EColorLast,
sl@0
   110
	KColor16MAP,	EColor16MAP,
sl@0
   111
	KColorLast, 	EColor64K
sl@0
   112
	};
sl@0
   113
sl@0
   114
/**
sl@0
   115
 * Draw modes
sl@0
   116
 */
sl@0
   117
const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumDrawModes[] =
sl@0
   118
	{
sl@0
   119
	KDrawModePEN,		CGraphicsContext::EDrawModePEN,
sl@0
   120
	KDrawModeAND,		CGraphicsContext::EDrawModeAND,
sl@0
   121
	KDrawModeXOR,		CGraphicsContext::EDrawModeXOR,
sl@0
   122
	KDrawModeOR,		CGraphicsContext::EDrawModeOR,
sl@0
   123
	KDrawModeNOTSCREEN,	CGraphicsContext::EDrawModeNOTSCREEN,
sl@0
   124
	KDrawModeNOTPEN,	CGraphicsContext::EDrawModeNOTPEN
sl@0
   125
	};
sl@0
   126
sl@0
   127
const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumOrientationModes[] =
sl@0
   128
	{
sl@0
   129
	KOrientationNormal,		CFbsDrawDevice::EOrientationNormal,
sl@0
   130
	KOrientationRotated90,	CFbsDrawDevice::EOrientationRotated90,
sl@0
   131
	KOrientationRotated180,	CFbsDrawDevice::EOrientationRotated180,	 
sl@0
   132
	KOrientationRotated270,	CFbsDrawDevice::EOrientationRotated270
sl@0
   133
	};
sl@0
   134
sl@0
   135
CT_CFbsDrawDeviceData* CT_CFbsDrawDeviceData::NewL() 
sl@0
   136
	{
sl@0
   137
	CT_CFbsDrawDeviceData*	ret = new (ELeave) CT_CFbsDrawDeviceData();
sl@0
   138
	CleanupStack::PushL(ret);
sl@0
   139
	ret->ConstructL();
sl@0
   140
	CleanupStack::Pop(ret);
sl@0
   141
	return ret;
sl@0
   142
	}
sl@0
   143
sl@0
   144
sl@0
   145
CT_CFbsDrawDeviceData::CT_CFbsDrawDeviceData()
sl@0
   146
:	iDrawDevice(NULL),	
sl@0
   147
	iDMode(CGraphicsContext::EDrawModePEN),	
sl@0
   148
	iDispMode(EColor64K),	
sl@0
   149
	iOrientation(0),	
sl@0
   150
	iSize(0,0),	
sl@0
   151
	iPostBlendShadow(ENoPostShadow),
sl@0
   152
	iTestRect(),
sl@0
   153
	iNumTestRects(0)
sl@0
   154
	{	
sl@0
   155
	}
sl@0
   156
sl@0
   157
sl@0
   158
void CT_CFbsDrawDeviceData::ConstructL()
sl@0
   159
	{
sl@0
   160
	}
sl@0
   161
sl@0
   162
/**
sl@0
   163
 * Public destructor
sl@0
   164
 */
sl@0
   165
CT_CFbsDrawDeviceData::~CT_CFbsDrawDeviceData()
sl@0
   166
	{
sl@0
   167
	DestroyData();
sl@0
   168
	}
sl@0
   169
sl@0
   170
sl@0
   171
/**
sl@0
   172
 * Return a pointer to the object that the data wraps
sl@0
   173
 *
sl@0
   174
 * @return	pointer to the object that the data wraps
sl@0
   175
 */
sl@0
   176
TAny* CT_CFbsDrawDeviceData::GetObject()
sl@0
   177
	{
sl@0
   178
	return iDrawDevice;
sl@0
   179
	}
sl@0
   180
sl@0
   181
/**
sl@0
   182
 * Command for Destructor
sl@0
   183
 */
sl@0
   184
void CT_CFbsDrawDeviceData::DoCmdDestructor()
sl@0
   185
	{
sl@0
   186
	DestroyData();
sl@0
   187
	}
sl@0
   188
sl@0
   189
/**
sl@0
   190
 * Destroys used objects
sl@0
   191
 */
sl@0
   192
void CT_CFbsDrawDeviceData::DestroyData()
sl@0
   193
	{
sl@0
   194
	iTestRect.Reset();
sl@0
   195
	iTestRect.Close();
sl@0
   196
	iDispMode = ENone;
sl@0
   197
	iSize.SetSize(0,0);
sl@0
   198
	
sl@0
   199
	if(iDrawDevice)
sl@0
   200
		{		
sl@0
   201
		delete iDrawDevice;
sl@0
   202
		iDrawDevice = NULL;		
sl@0
   203
		}
sl@0
   204
	}
sl@0
   205
sl@0
   206
/**
sl@0
   207
 * Process a command read from the ini file
sl@0
   208
 *
sl@0
   209
 * @param aCommand			The command to process
sl@0
   210
 * @param aSection			The section in the ini containing data for the command
sl@0
   211
 * @param aAsyncErrorIndex	Command index for async calls to return errors to
sl@0
   212
 *
sl@0
   213
 * @return					ETrue if the command is processed
sl@0
   214
 *
sl@0
   215
 * @leave					System wide error
sl@0
   216
 */
sl@0
   217
TBool CT_CFbsDrawDeviceData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, 
sl@0
   218
		const TInt/* aAsyncErrorIndex*/)
sl@0
   219
	{
sl@0
   220
	TBool	ret = ETrue;
sl@0
   221
sl@0
   222
	if 	( aCommand==KCmdInitScreen )
sl@0
   223
		{
sl@0
   224
		DoCmdInitScreen();
sl@0
   225
		}
sl@0
   226
	else if ( aCommand==KCmdSetDisplayMode )	
sl@0
   227
		{
sl@0
   228
		DoCmdSetDisplayMode();
sl@0
   229
		}
sl@0
   230
	else if ( aCommand==KCmdSetAutoUpdate )	
sl@0
   231
		{
sl@0
   232
		DoCmdSetAutoUpdate(aSection);
sl@0
   233
		}
sl@0
   234
	else if ( aCommand==KCmdOrientationsAvailable )	
sl@0
   235
		{
sl@0
   236
		DoCmdOrientationsAvailable();
sl@0
   237
		}
sl@0
   238
	else if ( aCommand==KCmdSetOrientation )	
sl@0
   239
		{
sl@0
   240
		DoCmdSetOrientation(aSection);
sl@0
   241
		}
sl@0
   242
	else if ( aCommand==KCmdNewScreenDeviceL )	
sl@0
   243
		{
sl@0
   244
		DoCmdNewScreenDeviceL(aSection);
sl@0
   245
		}
sl@0
   246
	else if ( aCommand==KCmdDestructor )	
sl@0
   247
		{
sl@0
   248
		DoCmdDestructor();
sl@0
   249
		}
sl@0
   250
	else if ( aCommand==KCmdWriteLine )	
sl@0
   251
		{
sl@0
   252
		DoCmdWriteLineL(aSection);		
sl@0
   253
		}
sl@0
   254
	else if ( aCommand==KCmdWriteBinaryLine )	
sl@0
   255
		{
sl@0
   256
		DoCmdWriteBinaryLineL(aSection);		
sl@0
   257
		}
sl@0
   258
	else if ( aCommand==KCmdWriteRgb )	
sl@0
   259
		{
sl@0
   260
		DoCmdWriteRgb(aSection);		
sl@0
   261
		}
sl@0
   262
	else if( aCommand==KCmdWriteRgbMulti )
sl@0
   263
		{
sl@0
   264
		DoCmdWriteRgbMulti(aSection);		
sl@0
   265
		}
sl@0
   266
	else if( aCommand==KCmdReadLine )
sl@0
   267
		{
sl@0
   268
		DoCmdReadLineL(aSection);		
sl@0
   269
		}
sl@0
   270
	else if( aCommand==KCmdWriteRGBAlphaLine )
sl@0
   271
		{
sl@0
   272
		DoCmdWriteRGBAlphaLineL(aSection);		
sl@0
   273
		}
sl@0
   274
	else if( aCommand==KCmdSetShadowMode )
sl@0
   275
		{
sl@0
   276
		DoCmdSetShadowMode(aSection);
sl@0
   277
		}
sl@0
   278
	else if( aCommand==KCmdShadowArea )
sl@0
   279
		{
sl@0
   280
		DoCmdShadowArea(aSection);
sl@0
   281
		}
sl@0
   282
	else if( aCommand==KCmdWriteBinary )
sl@0
   283
		{
sl@0
   284
		DoCmdWriteBinaryL(aSection);
sl@0
   285
		}
sl@0
   286
	else if( aCommand==KCmdWriteBinaryLineVertical )
sl@0
   287
		{
sl@0
   288
		DoCmdWriteBinaryLineVerticalL(aSection);
sl@0
   289
		}	
sl@0
   290
	else
sl@0
   291
		{
sl@0
   292
		ret = EFalse;
sl@0
   293
		}
sl@0
   294
	
sl@0
   295
	return ret;
sl@0
   296
	}
sl@0
   297
sl@0
   298
/**
sl@0
   299
 * Tests WriteRgbMulti method from CFbsDrawDevice
sl@0
   300
 * @param aSection			The section in the ini containing data for the command
sl@0
   301
 * @return 							KErrNone if no error found.
sl@0
   302
 */
sl@0
   303
void CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti(const TTEFSectionName& aSection)
sl@0
   304
	{
sl@0
   305
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti"));
sl@0
   306
	TInt drawMode;
sl@0
   307
	TInt delay=0;
sl@0
   308
	TInt nRect = 0;
sl@0
   309
	TBool dataOk=ETrue;
sl@0
   310
	
sl@0
   311
	GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   312
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   313
	
sl@0
   314
	if ( !GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes, drawMode) )
sl@0
   315
		{
sl@0
   316
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   317
		SetBlockResult(EFail);
sl@0
   318
		dataOk = EFalse;
sl@0
   319
		}
sl@0
   320
	if(dataOk)
sl@0
   321
		{
sl@0
   322
		INFO_PRINTF2(_L("Change draw mode to: %d"), drawMode);
sl@0
   323
		iDMode=CGraphicsContext::TDrawMode(drawMode);
sl@0
   324
		
sl@0
   325
		for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++)
sl@0
   326
			{
sl@0
   327
			TRgb backColor = TestColor[nBackColor];
sl@0
   328
			Clear(backColor);
sl@0
   329
			for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
sl@0
   330
				{
sl@0
   331
				TInt shadowMode = EPostFade;
sl@0
   332
				TRect rect = iTestRect[nRect];			
sl@0
   333
				TRgb color = TestColor[nColor];				
sl@0
   334
				SetShadowAndFadingMode(shadowMode,100, 200);
sl@0
   335
				iDrawDevice->WriteRgbMulti(rect.iTl.iX,rect.iTl.iY,rect.Width(),rect.Height(),color,iDMode);
sl@0
   336
				
sl@0
   337
				User::After(delay);
sl@0
   338
				}
sl@0
   339
			}
sl@0
   340
		}
sl@0
   341
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti"));
sl@0
   342
	}
sl@0
   343
sl@0
   344
/**
sl@0
   345
 * Tests WriteRgb method from CFbsDrawDevice
sl@0
   346
 */
sl@0
   347
void CT_CFbsDrawDeviceData::DoCmdWriteRgb(const TTEFSectionName& aSection)
sl@0
   348
	{
sl@0
   349
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRgb"));
sl@0
   350
	TInt drawMode;
sl@0
   351
	TInt nRect = 0;	
sl@0
   352
	TInt delay;
sl@0
   353
	TBool dataOk=ETrue;
sl@0
   354
	
sl@0
   355
	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
sl@0
   356
		{
sl@0
   357
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   358
		SetBlockResult(EFail);
sl@0
   359
		dataOk = EFalse;
sl@0
   360
		}
sl@0
   361
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   362
	GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   363
	
sl@0
   364
	if (dataOk)
sl@0
   365
		{
sl@0
   366
		iDMode=CGraphicsContext::TDrawMode(drawMode); 	
sl@0
   367
		for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++)
sl@0
   368
			{			
sl@0
   369
			TRgb backColor = TestBackground[nBackColor];
sl@0
   370
			Clear(backColor);
sl@0
   371
			for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
sl@0
   372
				{					
sl@0
   373
				TInt shadowMode = ENoPostShadow;																					
sl@0
   374
				TRect rect = iTestRect[nRect];
sl@0
   375
				TRgb color = TestColor[nColor];
sl@0
   376
				SetShadowAndFadingMode(shadowMode,100, 200);
sl@0
   377
				iDrawDevice->WriteRgb(rect.iTl.iX,rect.iTl.iY,color,iDMode);
sl@0
   378
				User::After(delay);
sl@0
   379
				}			
sl@0
   380
			}
sl@0
   381
		}
sl@0
   382
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRgb"));
sl@0
   383
	}
sl@0
   384
sl@0
   385
/**
sl@0
   386
 *  Validates the received parameters and handles errors returned from TestScreenDrawL
sl@0
   387
 *  @param aSection			The section in the ini containing data for the command
sl@0
   388
 * 	@return 							KErrNone if no error found.
sl@0
   389
 */
sl@0
   390
void CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL(const TTEFSectionName& aSection)
sl@0
   391
 	{
sl@0
   392
 	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL"));
sl@0
   393
 	
sl@0
   394
 	if(iDrawDevice)
sl@0
   395
 		{
sl@0
   396
 		delete iDrawDevice;
sl@0
   397
	 	iDrawDevice=NULL;
sl@0
   398
 		}
sl@0
   399
 	TInt drawMode;
sl@0
   400
 	TBool dataOk = ETrue;
sl@0
   401
 	if (!GetEnumFromConfig(aSection, KDisplayMode(), iEnumDisplayModes, drawMode))
sl@0
   402
 		{
sl@0
   403
 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDisplayMode());
sl@0
   404
 	    SetBlockResult(EFail);
sl@0
   405
 	    dataOk = EFalse;
sl@0
   406
 	    }
sl@0
   407
 	if(dataOk)
sl@0
   408
 		{
sl@0
   409
 		TDisplayMode displayMode = TDisplayMode(drawMode);
sl@0
   410
 		iDispMode = displayMode;
sl@0
   411
 		TInt ScreenNo = 0;
sl@0
   412
 		
sl@0
   413
	 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels,iSize.iWidth));
sl@0
   414
	 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels,iSize.iHeight));
sl@0
   415
	 	INFO_PRINTF3(_L("WIDTH from HAL %i \nHEIGHT from HAL %i"),iSize.iWidth,iSize.iHeight);
sl@0
   416
	 	ASSERT(iSize.iWidth > 0 && iSize.iHeight > 0);
sl@0
   417
	 	 	
sl@0
   418
	 		 	
sl@0
   419
	 	TRAPD(ret,iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(ScreenNo,displayMode));
sl@0
   420
	 		
sl@0
   421
	 	// check error code
sl@0
   422
	 	if(ret != KErrNone)
sl@0
   423
	 		{
sl@0
   424
	 		ERR_PRINTF2(_L("CFbsDrawDevice creation error: %d"), ret);
sl@0
   425
	 		SetError(ret);
sl@0
   426
	 		}
sl@0
   427
	 	else
sl@0
   428
	 		{
sl@0
   429
	 		GETFROMCONFIGMANDATORY(Int, KRectangleSection(), KNumTestRect(),iNumTestRects,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   430
	 		
sl@0
   431
	 		if (!InitRectangles())
sl@0
   432
	 			{ 				
sl@0
   433
	 			SetBlockResult(EFail);
sl@0
   434
	 			ERR_PRINTF1(_L("Error: Test Rectangles NOT set!")); 						
sl@0
   435
	 			}
sl@0
   436
	 		else
sl@0
   437
	 			{ 	 			
sl@0
   438
	 			INFO_PRINTF1(_L("Test Rectangles are now set!"));	
sl@0
   439
	 			}
sl@0
   440
	 		}
sl@0
   441
	 	INFO_PRINTF1(_L("** DoCmdNewScreenDeviceL succeded!"));	
sl@0
   442
 		}
sl@0
   443
 	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL"));
sl@0
   444
 	}
sl@0
   445
sl@0
   446
/**
sl@0
   447
 * Inits Screen
sl@0
   448
 */
sl@0
   449
void CT_CFbsDrawDeviceData::DoCmdInitScreen()
sl@0
   450
	{
sl@0
   451
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdInitScreen"));
sl@0
   452
	TInt err = iDrawDevice->InitScreen();
sl@0
   453
	if(err != KErrNone)
sl@0
   454
		{		
sl@0
   455
		ERR_PRINTF2(_L("InitScreen error: %d"), err);
sl@0
   456
		SetError(err);
sl@0
   457
		}
sl@0
   458
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdInitScreen"));
sl@0
   459
	}
sl@0
   460
sl@0
   461
/**
sl@0
   462
 * Sets Display Mode
sl@0
   463
 * */
sl@0
   464
void CT_CFbsDrawDeviceData::DoCmdSetDisplayMode()
sl@0
   465
	{
sl@0
   466
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetDisplayMode"));
sl@0
   467
	iDrawDevice->SetDisplayMode(iDrawDevice);
sl@0
   468
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetDisplayMode"));
sl@0
   469
	}
sl@0
   470
sl@0
   471
/**
sl@0
   472
 * Sets or unsets auto-update for the screen.
sl@0
   473
 */
sl@0
   474
void CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate(const TTEFSectionName& aSection)
sl@0
   475
	{
sl@0
   476
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate"));
sl@0
   477
	TBool autoUpdate=ETrue;
sl@0
   478
	GETFROMCONFIGOPTIONAL(Bool, aSection, KAutoUpdate(),autoUpdate,_L("Error in getting parameter %S from INI file"));
sl@0
   479
	iDrawDevice->SetAutoUpdate(autoUpdate);
sl@0
   480
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate"));
sl@0
   481
	}
sl@0
   482
sl@0
   483
/**
sl@0
   484
 * checks for Available Orientations
sl@0
   485
 */
sl@0
   486
void CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable()
sl@0
   487
	{
sl@0
   488
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable"));
sl@0
   489
	TBool orientation[4];
sl@0
   490
	iDrawDevice->OrientationsAvailable(orientation);
sl@0
   491
	INFO_PRINTF2(_L("Orientation Normal : %i"),orientation[CFbsDrawDevice::EOrientationNormal]);
sl@0
   492
	INFO_PRINTF2(_L("Orientation Rotated 90 : %i"),orientation[CFbsDrawDevice::EOrientationRotated90]);
sl@0
   493
	INFO_PRINTF2(_L("Orientation Rotated 180 : %i"),orientation[CFbsDrawDevice::EOrientationRotated180]);	 
sl@0
   494
	INFO_PRINTF2(_L("Orientation Rotated 270 : %i"),orientation[CFbsDrawDevice::EOrientationRotated270]);
sl@0
   495
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable"));
sl@0
   496
	}
sl@0
   497
sl@0
   498
/**
sl@0
   499
 * Sets orientation
sl@0
   500
 */
sl@0
   501
void CT_CFbsDrawDeviceData::DoCmdSetOrientation(const TTEFSectionName& aSection)
sl@0
   502
	{
sl@0
   503
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetOrientation"));
sl@0
   504
	TBool dataOk = ETrue;
sl@0
   505
	
sl@0
   506
	
sl@0
   507
	if ( !GetEnumFromConfig(aSection, KOrientationMode(), iEnumOrientationModes, iOrientation) )
sl@0
   508
		{
sl@0
   509
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOrientationMode());
sl@0
   510
		SetBlockResult(EFail);
sl@0
   511
		dataOk = EFalse;
sl@0
   512
		}
sl@0
   513
	
sl@0
   514
	if(dataOk)
sl@0
   515
		{
sl@0
   516
		
sl@0
   517
		TBool orientationSupported = iDrawDevice->SetOrientation(CFbsDrawDevice::TOrientation(iOrientation));
sl@0
   518
		
sl@0
   519
		if (orientationSupported)
sl@0
   520
			{
sl@0
   521
			INFO_PRINTF2(_L("Orientation was set to: %d"), iOrientation);
sl@0
   522
			if (iOrientation & 1)
sl@0
   523
				{
sl@0
   524
				iSize.SetSize(iSize.iHeight, iSize.iWidth);
sl@0
   525
				}
sl@0
   526
			}
sl@0
   527
		else
sl@0
   528
			{
sl@0
   529
			ERR_PRINTF1(_L("Orientation not Supported"));
sl@0
   530
			}
sl@0
   531
		}
sl@0
   532
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetOrientation"));		
sl@0
   533
	}
sl@0
   534
sl@0
   535
/**
sl@0
   536
 * Tests WriteLine method from CFbsDrawDevice
sl@0
   537
 */
sl@0
   538
void CT_CFbsDrawDeviceData::DoCmdWriteLineL(const TTEFSectionName& aSection)
sl@0
   539
	{
sl@0
   540
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteLineL"));
sl@0
   541
	TInt byteSize = (ByteSize() / iSize.iHeight);
sl@0
   542
	TInt delay;
sl@0
   543
	TBool dataOk = ETrue;
sl@0
   544
	
sl@0
   545
	INFO_PRINTF2(_L("After setting bytesize %d"),byteSize);
sl@0
   546
	TUint8* backBuffer  = new(ELeave) TUint8[byteSize];
sl@0
   547
	CleanupStack::PushL(backBuffer);
sl@0
   548
	TUint8* writeBuffer = new(ELeave) TUint8[byteSize];
sl@0
   549
	CleanupStack::PushL(writeBuffer);
sl@0
   550
	TUint8* copyBuffer  = new(ELeave) TUint8[byteSize];
sl@0
   551
	CleanupStack::PushL(copyBuffer);
sl@0
   552
	TUint8* readBuffer  = new(ELeave) TUint8[byteSize];
sl@0
   553
	CleanupStack::PushL(readBuffer);
sl@0
   554
	
sl@0
   555
	INFO_PRINTF1(_L("after setting buffers"));
sl@0
   556
	
sl@0
   557
	TInt drawMode;	
sl@0
   558
	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
sl@0
   559
		{
sl@0
   560
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   561
		SetBlockResult(EFail);
sl@0
   562
		dataOk = EFalse;
sl@0
   563
	    }
sl@0
   564
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   565
	
sl@0
   566
	INFO_PRINTF1(_L("Test Rectangles are now set!"));
sl@0
   567
	TInt nRect = 0;
sl@0
   568
	GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   569
	
sl@0
   570
	TRect rect = iTestRect[nRect];
sl@0
   571
	TInt nBackColor = 0;
sl@0
   572
	GETFROMCONFIGMANDATORY(Int, aSection, KBackColor(),nBackColor,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   573
	
sl@0
   574
	if(dataOk)
sl@0
   575
		{
sl@0
   576
		iDMode=CGraphicsContext::TDrawMode(drawMode);
sl@0
   577
		TRgb b = TestBackground[nBackColor];
sl@0
   578
		Clear(b);
sl@0
   579
		for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
sl@0
   580
			{
sl@0
   581
			FillBuffer(writeBuffer,byteSize,iDispMode);
sl@0
   582
				
sl@0
   583
			Mem::Copy(copyBuffer,writeBuffer,byteSize);
sl@0
   584
			iDrawDevice->WriteLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)writeBuffer,iDMode);
sl@0
   585
			Mem::FillZ(readBuffer,byteSize);
sl@0
   586
			User::After(delay);
sl@0
   587
			}
sl@0
   588
		}		
sl@0
   589
		INFO_PRINTF1(_L("Deleting buffers"));	
sl@0
   590
        CleanupStack::PopAndDestroy(4);	
sl@0
   591
		INFO_PRINTF1(_L("Buffers deleted"));		
sl@0
   592
		INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteLineL"));
sl@0
   593
	}
sl@0
   594
sl@0
   595
/**
sl@0
   596
 * Tests WriteBinaryLine from CFbsDrawDevice
sl@0
   597
 */
sl@0
   598
void CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL(const TTEFSectionName& aSection)
sl@0
   599
	{
sl@0
   600
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL"));
sl@0
   601
	TInt drawMode;
sl@0
   602
	TInt nRect = 0;
sl@0
   603
	TInt delay;
sl@0
   604
	TBool dataOk = ETrue;
sl@0
   605
	
sl@0
   606
	if (!GetEnumFromConfig(aSection, KDrawMode(),iEnumDrawModes, drawMode))
sl@0
   607
		{
sl@0
   608
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   609
		SetBlockResult(EFail);
sl@0
   610
		dataOk = EFalse;
sl@0
   611
		}
sl@0
   612
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   613
	
sl@0
   614
	if (!GetIntFromConfig(aSection, KNumRect(), nRect))
sl@0
   615
		{
sl@0
   616
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect());
sl@0
   617
		SetBlockResult(EFail);
sl@0
   618
		dataOk = EFalse;
sl@0
   619
		}
sl@0
   620
	TInt nBackColor = 0;
sl@0
   621
	if (!GetIntFromConfig(aSection, KBackColor(), nBackColor))
sl@0
   622
		{
sl@0
   623
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBackColor());
sl@0
   624
		SetBlockResult(EFail);
sl@0
   625
		dataOk = EFalse;
sl@0
   626
		}
sl@0
   627
	TInt shadowMode = ENoPostShadow;	
sl@0
   628
	if (!GetEnumFromConfig(aSection, KShadowMode(), iEnumShadowModes, shadowMode))
sl@0
   629
		{
sl@0
   630
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KShadowMode());
sl@0
   631
		SetBlockResult(EFail);
sl@0
   632
		dataOk = EFalse;
sl@0
   633
		}
sl@0
   634
	
sl@0
   635
	if(dataOk)
sl@0
   636
		{
sl@0
   637
		iDMode=CGraphicsContext::TDrawMode(drawMode);
sl@0
   638
		
sl@0
   639
		TInt byteSize = ByteSize() / iSize.iHeight;
sl@0
   640
		TInt wordSize = (byteSize + 3) / 4;
sl@0
   641
		TUint32* writeBuffer = new(ELeave) TUint32[wordSize];
sl@0
   642
		CleanupStack::PushL(writeBuffer);
sl@0
   643
		INFO_PRINTF1(_L("Test Rectangles are now set!"));
sl@0
   644
		
sl@0
   645
		
sl@0
   646
		TRect rect = iTestRect[nRect];
sl@0
   647
			
sl@0
   648
		
sl@0
   649
			
sl@0
   650
		for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
sl@0
   651
			{
sl@0
   652
			if (rect.Width() > KRectWidth)
sl@0
   653
				{
sl@0
   654
				rect.iBr.iX = rect.iTl.iX + KRectWidth;
sl@0
   655
				}
sl@0
   656
			if (rect.Width() < 1)
sl@0
   657
				{
sl@0
   658
				rect.iBr.iX = rect.iTl.iX + 1;
sl@0
   659
				}
sl@0
   660
				
sl@0
   661
			TRgb backgroundColor = TestBackground[nBackColor];
sl@0
   662
			Clear(backgroundColor);
sl@0
   663
			TRgb testColor = TestColor[nColor];
sl@0
   664
				
sl@0
   665
			iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
sl@0
   666
			FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
sl@0
   667
			iDrawDevice->WriteBinaryLine(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),testColor,iDMode);
sl@0
   668
			User::After(delay);
sl@0
   669
			}		
sl@0
   670
		CleanupStack::PopAndDestroy();
sl@0
   671
		writeBuffer = NULL;
sl@0
   672
		}
sl@0
   673
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL"));
sl@0
   674
	}
sl@0
   675
sl@0
   676
/**
sl@0
   677
 * Tests ReadLine from CFbsDrawDevice
sl@0
   678
 * @param aSection			The section in the ini containing data for the command
sl@0
   679
 * @return 					KErrNone if no error found.
sl@0
   680
 */
sl@0
   681
void CT_CFbsDrawDeviceData::DoCmdReadLineL(const TTEFSectionName& aSection)
sl@0
   682
	{
sl@0
   683
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdReadLineL"));
sl@0
   684
	TInt byteSize = ByteSize() / iSize.iHeight;
sl@0
   685
	TUint8* writeBuffer = new(ELeave) TUint8[byteSize];
sl@0
   686
	CleanupStack::PushL(writeBuffer);
sl@0
   687
	TUint8* readBuffer = new(ELeave) TUint8[iSize.iWidth * sizeof(TRgb)];
sl@0
   688
	CleanupStack::PushL(readBuffer);
sl@0
   689
	
sl@0
   690
	FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
sl@0
   691
	FillBuffer((TUint8*)readBuffer,byteSize,iDispMode);
sl@0
   692
	
sl@0
   693
	TInt nBackColor = 0;
sl@0
   694
	if (!GetIntFromConfig(aSection, KBackColor(), nBackColor))
sl@0
   695
		{
sl@0
   696
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBackColor());
sl@0
   697
		SetBlockResult(EFail);
sl@0
   698
	    }
sl@0
   699
	
sl@0
   700
	TRgb b = TestColor[nBackColor];
sl@0
   701
	Clear(b);
sl@0
   702
sl@0
   703
	for (TInt nDispMode = 0; nDispMode < KNumDispModes; nDispMode++)
sl@0
   704
		{
sl@0
   705
		TDisplayMode dispMode = TestDisplayMode[nDispMode];
sl@0
   706
		
sl@0
   707
		for (TInt cnt=0;cnt<2;cnt++)
sl@0
   708
			{
sl@0
   709
			if (cnt==0)  //first time 
sl@0
   710
				{
sl@0
   711
				iDrawDevice->SetUserDisplayMode(dispMode);
sl@0
   712
				}
sl@0
   713
			else
sl@0
   714
				{
sl@0
   715
				iDrawDevice->SetUserDisplayMode(iDispMode);
sl@0
   716
				}
sl@0
   717
				
sl@0
   718
			for (TInt nRect = 0; nRect < iNumTestRects; nRect++)
sl@0
   719
				{
sl@0
   720
				TRect rect = iTestRect[nRect];
sl@0
   721
				for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
sl@0
   722
					{
sl@0
   723
					FillBuffer(writeBuffer,byteSize,iDispMode);
sl@0
   724
					Mem::FillZ(readBuffer,byteSize);
sl@0
   725
					iDrawDevice->ReadLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)readBuffer,dispMode);
sl@0
   726
					Mem::FillZ(readBuffer,byteSize);
sl@0
   727
					}
sl@0
   728
				}
sl@0
   729
			}
sl@0
   730
		}	
sl@0
   731
    CleanupStack::PopAndDestroy(2);
sl@0
   732
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdReadLineL"));
sl@0
   733
	}
sl@0
   734
sl@0
   735
/**
sl@0
   736
 * Tests RGBAlphaLine from CFbsDrawDevice
sl@0
   737
 * @param aSection			The section in the ini containing data for the command
sl@0
   738
 * @return 					KErrNone if no error found.
sl@0
   739
 */
sl@0
   740
void CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL(const TTEFSectionName& aSection)
sl@0
   741
	{
sl@0
   742
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL"));
sl@0
   743
	TInt drawMode;
sl@0
   744
	
sl@0
   745
 	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
sl@0
   746
 		{
sl@0
   747
 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   748
 		SetBlockResult(EFail);
sl@0
   749
 	    }
sl@0
   750
 	
sl@0
   751
 	iDMode=CGraphicsContext::TDrawMode(drawMode);
sl@0
   752
 	TInt byteSize = ByteSize() / iSize.iHeight;
sl@0
   753
	INFO_PRINTF1(_L("In TestWriteRGBAlphaLine"));
sl@0
   754
	
sl@0
   755
	TUint8* writeBuffer = new(ELeave) TUint8[iSize.iWidth * 4];
sl@0
   756
	CleanupStack::PushL(writeBuffer);
sl@0
   757
	TUint8* writeBuffer2 = new(ELeave) TUint8[iSize.iWidth * 4];
sl@0
   758
	CleanupStack::PushL(writeBuffer2);
sl@0
   759
	TUint8* maskBuffer = new(ELeave) TUint8[iSize.iWidth * 4];
sl@0
   760
	CleanupStack::PushL(maskBuffer);
sl@0
   761
	
sl@0
   762
	FillBuffer(writeBuffer,byteSize,iDispMode);
sl@0
   763
	FillBuffer(writeBuffer2,byteSize,iDispMode);
sl@0
   764
	FillBuffer(maskBuffer,byteSize,iDispMode);
sl@0
   765
	
sl@0
   766
	TInt nRect;
sl@0
   767
	for (TInt maskFillCount=0; maskFillCount<KMaskFill;maskFillCount++)
sl@0
   768
		{
sl@0
   769
		for (nRect = 0; nRect < iNumTestRects; nRect++)
sl@0
   770
			{
sl@0
   771
			for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++)
sl@0
   772
				{
sl@0
   773
				TRgb testColor = TestColor[nBackColor];
sl@0
   774
				Clear(testColor);
sl@0
   775
				for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
sl@0
   776
					{
sl@0
   777
					//ensure the colour has the 0xff mask value
sl@0
   778
					TRgb checkColor;
sl@0
   779
					TRgb c = TestColor[nColor];
sl@0
   780
					TUint32 internal = c.Internal();
sl@0
   781
					TInt yy;
sl@0
   782
					TRect rect = iTestRect[nRect];
sl@0
   783
					TInt shadowMode =ENoPostShadow;
sl@0
   784
					//use a combined alpha for the check colour
sl@0
   785
					TUint32 combinedAlpha = MaskFill[maskFillCount]*((internal&0xff000000)>>24);
sl@0
   786
					combinedAlpha = ((combinedAlpha <<16) & 0xff000000);
sl@0
   787
					checkColor.SetInternal((internal&0x00ffffff)|combinedAlpha);
sl@0
   788
					SetShadowAndFadingMode(shadowMode,100, 200);
sl@0
   789
					for (yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
sl@0
   790
						{
sl@0
   791
						iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),
sl@0
   792
								writeBuffer,
sl@0
   793
								writeBuffer2,
sl@0
   794
								maskBuffer,
sl@0
   795
								iDMode);
sl@0
   796
						}
sl@0
   797
					//require to Shadow After the checkColor, no shadow with a zero mask
sl@0
   798
					TBool shadowModeChanged = EFalse;
sl@0
   799
					if (MaskFill[maskFillCount])
sl@0
   800
						{
sl@0
   801
						iPostBlendShadow = (TPostShadowMode) shadowMode;
sl@0
   802
						shadowMode = 0;
sl@0
   803
						shadowModeChanged = ETrue;
sl@0
   804
						}
sl@0
   805
					if(shadowModeChanged)
sl@0
   806
						{
sl@0
   807
						shadowMode = iPostBlendShadow;
sl@0
   808
						}
sl@0
   809
					iPostBlendShadow = ENoPostShadow;
sl@0
   810
					}
sl@0
   811
				}
sl@0
   812
			}
sl@0
   813
		}
sl@0
   814
	INFO_PRINTF1(_L("** delete buffers"));
sl@0
   815
    CleanupStack::PopAndDestroy(3);
sl@0
   816
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL"));
sl@0
   817
	}
sl@0
   818
sl@0
   819
/**
sl@0
   820
 * Tests ShadowArea from CFbsDrawDevice
sl@0
   821
 * @return 	KErrNone if no error found.
sl@0
   822
 */
sl@0
   823
void CT_CFbsDrawDeviceData::DoCmdShadowArea(const TTEFSectionName& aSection)
sl@0
   824
	{
sl@0
   825
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdShadowArea"));
sl@0
   826
	TInt delay=0;
sl@0
   827
	TBool dataOk = ETrue;
sl@0
   828
	
sl@0
   829
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   830
	
sl@0
   831
	if(dataOk)
sl@0
   832
		{
sl@0
   833
		INFO_PRINTF1(_L("In TestShadow()"));
sl@0
   834
		TInt nBackColor = 1;	 	
sl@0
   835
		TRgb testColor = TestColor[nBackColor];
sl@0
   836
		Clear(testColor);
sl@0
   837
sl@0
   838
		for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++)
sl@0
   839
			{
sl@0
   840
			for (TInt nRect = 0; nRect < iNumTestRects; nRect++)
sl@0
   841
				{
sl@0
   842
				for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
sl@0
   843
					{
sl@0
   844
					TRect rect = iTestRect[nRect];
sl@0
   845
					iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
sl@0
   846
					iDrawDevice->ShadowArea(rect);
sl@0
   847
					
sl@0
   848
					User::After(delay);
sl@0
   849
					}
sl@0
   850
				}
sl@0
   851
			}
sl@0
   852
		}
sl@0
   853
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdShadowArea"));
sl@0
   854
			
sl@0
   855
	}
sl@0
   856
sl@0
   857
/**
sl@0
   858
 * Tests WriteBinaryLineVertical from CFbsDrawDevice
sl@0
   859
 * @return 			KErrNone if no error found.
sl@0
   860
 */
sl@0
   861
void CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL(const TTEFSectionName& aSection)
sl@0
   862
	{
sl@0
   863
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL"));
sl@0
   864
	TInt drawMode;
sl@0
   865
 	TInt delay;
sl@0
   866
 	TBool dataOk = ETrue;
sl@0
   867
	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
sl@0
   868
		{
sl@0
   869
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   870
		SetBlockResult(EFail);
sl@0
   871
		dataOk = EFalse;
sl@0
   872
		}
sl@0
   873
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   874
	TInt nRect = 0;
sl@0
   875
	if (!GetIntFromConfig(aSection, KNumRect(), nRect))
sl@0
   876
		{
sl@0
   877
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect());
sl@0
   878
		SetBlockResult(EFail);
sl@0
   879
		dataOk = EFalse;
sl@0
   880
		}
sl@0
   881
sl@0
   882
	if(dataOk)
sl@0
   883
		{
sl@0
   884
		iDMode=CGraphicsContext::TDrawMode(drawMode);
sl@0
   885
		
sl@0
   886
		TInt byteSize = ByteSize() / iSize.iHeight;
sl@0
   887
		TInt wordSize = (byteSize + 3) / 4;
sl@0
   888
		TUint32* writeBuffer = new(ELeave) TUint32[wordSize];
sl@0
   889
		TInt nBackColor = 1;
sl@0
   890
		TInt nColor = 4;					
sl@0
   891
		
sl@0
   892
		TRect rect = iTestRect[nRect];
sl@0
   893
		if (rect.Width() > KRectWidth)
sl@0
   894
			{
sl@0
   895
			rect.iBr.iX = rect.iTl.iX + KRectWidth;
sl@0
   896
			}
sl@0
   897
		if (rect.Width() < 1)
sl@0
   898
			{
sl@0
   899
			rect.iBr.iX = rect.iTl.iX + 1;
sl@0
   900
			}
sl@0
   901
		
sl@0
   902
		TRgb b = TestBackground[nBackColor];
sl@0
   903
		TRgb c = TestColor[nColor];
sl@0
   904
		Clear(b);
sl@0
   905
sl@0
   906
sl@0
   907
		//NOTE Call Command within script: SetShadowmode
sl@0
   908
		FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
sl@0
   909
		iDrawDevice->WriteBinaryLineVertical(rect.iTl.iX,rect.iBr.iY - 1,writeBuffer,rect.Height(),c,iDMode,ETrue);
sl@0
   910
sl@0
   911
		User::After(delay);
sl@0
   912
		delete [] writeBuffer;
sl@0
   913
		writeBuffer = NULL;
sl@0
   914
		}
sl@0
   915
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL"));
sl@0
   916
	}
sl@0
   917
sl@0
   918
/**
sl@0
   919
 * Sets the current shadowing mode
sl@0
   920
 * @param aSection			The section in the ini containing data for the command
sl@0
   921
 */
sl@0
   922
void CT_CFbsDrawDeviceData::DoCmdSetShadowMode(const TTEFSectionName& aSection)
sl@0
   923
	{
sl@0
   924
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetShadowMode"));
sl@0
   925
	TInt shadowMode = ENoPostShadow;
sl@0
   926
	if(!GetEnumFromConfig(aSection, KShadowMode(), iEnumShadowModes, shadowMode))
sl@0
   927
		{
sl@0
   928
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KShadowMode());
sl@0
   929
		SetBlockResult(EFail);
sl@0
   930
		}
sl@0
   931
	else
sl@0
   932
		{
sl@0
   933
		iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
sl@0
   934
		}
sl@0
   935
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetShadowMode"));
sl@0
   936
	}
sl@0
   937
sl@0
   938
/**
sl@0
   939
 * Tests WriteBinary method from CFbsDrawDevice
sl@0
   940
 * @param aSection			The section in the ini containing data for the command
sl@0
   941
 * @return 							KErrNone if no error found.
sl@0
   942
 */
sl@0
   943
void CT_CFbsDrawDeviceData::DoCmdWriteBinaryL(const TTEFSectionName& aSection)
sl@0
   944
	{
sl@0
   945
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryL"));
sl@0
   946
	TInt drawMode;
sl@0
   947
	TInt delay;
sl@0
   948
	TBool dataOk = ETrue;
sl@0
   949
	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
sl@0
   950
		{
sl@0
   951
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
sl@0
   952
		SetBlockResult(EFail);
sl@0
   953
		dataOk = EFalse;
sl@0
   954
		}
sl@0
   955
	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
sl@0
   956
	TInt nRect = 0;
sl@0
   957
	if (!GetIntFromConfig(aSection, KNumRect(), nRect))
sl@0
   958
		{
sl@0
   959
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect());
sl@0
   960
		SetBlockResult(EFail);
sl@0
   961
		dataOk = EFalse;
sl@0
   962
		}
sl@0
   963
	if(dataOk)
sl@0
   964
		{
sl@0
   965
		iDMode=CGraphicsContext::TDrawMode(drawMode);
sl@0
   966
		TInt byteSize = ByteSize() / iSize.iHeight;
sl@0
   967
		TInt wordSize = (byteSize + 3) / 4;
sl@0
   968
		TUint32* writeBuffer = new (ELeave)TUint32[wordSize];
sl@0
   969
		
sl@0
   970
		TRect rect = iTestRect[nRect];
sl@0
   971
		TInt nBackColor = 0;
sl@0
   972
		TInt nColor = 4;
sl@0
   973
sl@0
   974
		if (rect.Width() > KRectWidth)
sl@0
   975
			{
sl@0
   976
			rect.iBr.iX = rect.iTl.iX + KRectWidth;
sl@0
   977
			}
sl@0
   978
		if (rect.Width() < 1)
sl@0
   979
			{
sl@0
   980
			rect.iBr.iX = rect.iTl.iX + 1;
sl@0
   981
			}
sl@0
   982
		
sl@0
   983
		TRgb b = TestBackground[nBackColor];
sl@0
   984
		Clear(b);
sl@0
   985
		TRgb c = TestColor[nColor];
sl@0
   986
		//NOTE Call Command within script: SetShadowmode
sl@0
   987
		FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
sl@0
   988
		iDrawDevice->WriteBinary(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),rect.Height(),c,iDMode);
sl@0
   989
		
sl@0
   990
		User::After(delay);
sl@0
   991
		delete [] writeBuffer;
sl@0
   992
		writeBuffer = NULL;
sl@0
   993
		}
sl@0
   994
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryL"));
sl@0
   995
	}
sl@0
   996
sl@0
   997
/**
sl@0
   998
 * Clears screen with specified color
sl@0
   999
 */
sl@0
  1000
void CT_CFbsDrawDeviceData::Clear(TRgb aColor)
sl@0
  1001
	{
sl@0
  1002
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::Clear"));
sl@0
  1003
	iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow);
sl@0
  1004
	iDrawDevice->WriteRgbMulti(0,0,iSize.iWidth,iSize.iHeight,aColor,CGraphicsContext::EDrawModeWriteAlpha);
sl@0
  1005
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::Clear"));
sl@0
  1006
	}
sl@0
  1007
/**
sl@0
  1008
 * Sets Shadow and fading modes
sl@0
  1009
 * @param one of the supported shadow modes ENoShadow,EShadow,EFade,EShadowFade
sl@0
  1010
 * @param a black point
sl@0
  1011
 * @param a white point
sl@0
  1012
 */
sl@0
  1013
void CT_CFbsDrawDeviceData::SetShadowAndFadingMode(TInt shadowMode,TInt blackPoint, TInt whitePoint)
sl@0
  1014
	{
sl@0
  1015
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::SetShadowAndFadingMode"));
sl@0
  1016
	iDrawDevice->SetFadingParameters(blackPoint,whitePoint);  
sl@0
  1017
	iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
sl@0
  1018
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::SetShadowAndFadingMode"));
sl@0
  1019
	}
sl@0
  1020
sl@0
  1021
sl@0
  1022
/**
sl@0
  1023
 * Fills a buffer to be displayed on screen
sl@0
  1024
 * 
sl@0
  1025
 * @param aBuffer
sl@0
  1026
 * @param aByteSize
sl@0
  1027
 * @param aDispMode
sl@0
  1028
 */
sl@0
  1029
void CT_CFbsDrawDeviceData::FillBuffer(TUint8* aBuffer,TInt aByteSize,TDisplayMode aDispMode)
sl@0
  1030
	{
sl@0
  1031
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::FillBuffer"));
sl@0
  1032
	TUint8* bufferLimit = aBuffer + aByteSize;
sl@0
  1033
sl@0
  1034
	TInt64 seed = TInt64(TInt(aBuffer) * aByteSize * aDispMode * User::TickCount());
sl@0
  1035
sl@0
  1036
	if (aDispMode != EColor4K)
sl@0
  1037
		{
sl@0
  1038
		while (aBuffer < bufferLimit)
sl@0
  1039
			{
sl@0
  1040
			*aBuffer++ = (TUint8)Math::Rand(seed);
sl@0
  1041
			}
sl@0
  1042
		}
sl@0
  1043
	else
sl@0
  1044
		{
sl@0
  1045
		while (aBuffer < bufferLimit)
sl@0
  1046
			{
sl@0
  1047
			if (TInt(aBuffer) & 3 == 3)
sl@0
  1048
				{
sl@0
  1049
				*aBuffer++ = 0;
sl@0
  1050
				}
sl@0
  1051
			else
sl@0
  1052
				{
sl@0
  1053
				*aBuffer++ = (TUint8)Math::Rand(seed);
sl@0
  1054
				}
sl@0
  1055
			}
sl@0
  1056
		}
sl@0
  1057
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::FillBuffer"));
sl@0
  1058
	}
sl@0
  1059
sl@0
  1060
/**
sl@0
  1061
 * Sets the Byte Size based on screen Width and Height
sl@0
  1062
 */
sl@0
  1063
TInt CT_CFbsDrawDeviceData::ByteSize()
sl@0
  1064
	{
sl@0
  1065
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::ByteSize"));	
sl@0
  1066
	TInt wordSize = iSize.iWidth;
sl@0
  1067
	switch (iDispMode)
sl@0
  1068
		{
sl@0
  1069
	case EGray2:
sl@0
  1070
		wordSize = (wordSize + 31) / 32;
sl@0
  1071
		break;
sl@0
  1072
	case EGray4:
sl@0
  1073
		wordSize = (wordSize + 15) / 16;
sl@0
  1074
		break;
sl@0
  1075
	case EGray16:
sl@0
  1076
	case EColor16:
sl@0
  1077
		wordSize = (wordSize + 7) / 8;
sl@0
  1078
		break;
sl@0
  1079
	case EGray256:
sl@0
  1080
	case EColor256:
sl@0
  1081
		wordSize = (wordSize + 3) / 4;
sl@0
  1082
		break;
sl@0
  1083
	case EColor4K:
sl@0
  1084
	case EColor64K:
sl@0
  1085
		wordSize = (wordSize + 1) / 2;
sl@0
  1086
		break;
sl@0
  1087
	case EColor16M:
sl@0
  1088
		wordSize = (((wordSize * 3) + 11) / 12) * 3;
sl@0
  1089
		break;
sl@0
  1090
	case EColor16MU:
sl@0
  1091
	case EColor16MA:
sl@0
  1092
		//Should not be changed!
sl@0
  1093
		break;
sl@0
  1094
	default:
sl@0
  1095
		break;
sl@0
  1096
		};
sl@0
  1097
	
sl@0
  1098
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::ByteSize"));	
sl@0
  1099
	return wordSize * iSize.iHeight * 4;
sl@0
  1100
	}
sl@0
  1101
sl@0
  1102
/**
sl@0
  1103
 *	This method reads a string with this form: (a,,b,c,d) and splits it in an TInt array. 
sl@0
  1104
 * 
sl@0
  1105
 */
sl@0
  1106
void CT_CFbsDrawDeviceData::ReadRectL(HBufC& aString, RArray<TInt>& aResult)
sl@0
  1107
	{
sl@0
  1108
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::ReadRectL"));
sl@0
  1109
	TChar chr;
sl@0
  1110
	TLex lex(aString);
sl@0
  1111
	TBuf<256> buf;
sl@0
  1112
	
sl@0
  1113
	lex.Inc();			
sl@0
  1114
	while(!lex.Eos())
sl@0
  1115
        {
sl@0
  1116
        chr = lex.Get();
sl@0
  1117
        // Check if there was a list separator
sl@0
  1118
        if (chr == ',')
sl@0
  1119
            {
sl@0
  1120
            HBufC* param = buf.AllocLC();
sl@0
  1121
            buf.Zero();
sl@0
  1122
            TInt x = 0;
sl@0
  1123
            TLex lexX(*param);
sl@0
  1124
            lexX.Val(x);
sl@0
  1125
            aResult.Append(x);
sl@0
  1126
            CleanupStack::Pop(param); // pointer to buf is stored in RPointerArray
sl@0
  1127
            }
sl@0
  1128
        // If not separator character we can store the character into array
sl@0
  1129
        else
sl@0
  1130
            {
sl@0
  1131
            if (chr != ')')
sl@0
  1132
            	{
sl@0
  1133
            	buf.Append(chr);
sl@0
  1134
            	}
sl@0
  1135
            }
sl@0
  1136
        }
sl@0
  1137
        
sl@0
  1138
	HBufC* param = buf.AllocLC();
sl@0
  1139
	TInt x = 0;
sl@0
  1140
    TLex lexX(*param);
sl@0
  1141
    lexX.Val(x);
sl@0
  1142
    aResult.Append(x);	
sl@0
  1143
	CleanupStack::PopAndDestroy(param);
sl@0
  1144
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::ReadRectL"));
sl@0
  1145
	}
sl@0
  1146
sl@0
  1147
/**
sl@0
  1148
 *	This method reads a string with this form: (a,,b,c,d) and splits it in an TInt array. 
sl@0
  1149
 * 
sl@0
  1150
 */
sl@0
  1151
TBool CT_CFbsDrawDeviceData::InitRectangles()
sl@0
  1152
	{
sl@0
  1153
	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::InitRectangles"));
sl@0
  1154
	TBool readResult = ETrue;
sl@0
  1155
	RPointerArray<HBufC> dimensions;
sl@0
  1156
	RArray<TInt> result;
sl@0
  1157
	TInt err = KErrNone;
sl@0
  1158
	
sl@0
  1159
	if ( GetArrayRectFromConfig( KRectangleSection(), KRectangles(), dimensions))//its validated by the above call	
sl@0
  1160
		{
sl@0
  1161
		for (TInt i = 0; i < iNumTestRects; i++)
sl@0
  1162
			{
sl@0
  1163
			TRAP(err , ReadRectL(*dimensions[i], result));
sl@0
  1164
			if (err != KErrNone)
sl@0
  1165
				{
sl@0
  1166
				readResult = EFalse;
sl@0
  1167
				break;
sl@0
  1168
				}
sl@0
  1169
			else
sl@0
  1170
				{							
sl@0
  1171
				iTestRect.Append(TRect(result[0],result[1],result[2],result[3]));
sl@0
  1172
				result.Reset();
sl@0
  1173
				}
sl@0
  1174
			}		
sl@0
  1175
		} 
sl@0
  1176
	else
sl@0
  1177
		{		
sl@0
  1178
		readResult = EFalse;
sl@0
  1179
		}
sl@0
  1180
	dimensions.ResetAndDestroy();
sl@0
  1181
	result.Reset();
sl@0
  1182
	result.Close();
sl@0
  1183
sl@0
  1184
	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::InitRectangles"));
sl@0
  1185
  	return readResult;
sl@0
  1186
sl@0
  1187
	}