os/graphics/graphicsapitest/screendriverhaitest/screendriver/src/t_cfbsdrawdevicedata.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsapitest/screendriverhaitest/screendriver/src/t_cfbsdrawdevicedata.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1187 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +#include "t_cfbsdrawdevicedata.h"
    1.22 +#include <hal.h>
    1.23 +#include <e32math.h>
    1.24 +
    1.25 +_LIT(KDisplayMode, 					"displayMode");
    1.26 +_LIT(KDrawMode, 					"drawMode");
    1.27 +_LIT(KOrientationMode,				"orientationMode");
    1.28 +_LIT(KShadowMode, 					"shadowMode");
    1.29 +_LIT(KBackColor, 					"backColor");
    1.30 +_LIT(KNumRect,	 					"numRect");
    1.31 +_LIT(KRectangles, 					"rectangles");
    1.32 +_LIT(KRectangleSection, 			"RECTANGLES");
    1.33 +_LIT(KNumTestRect,		 			"numTestRect");
    1.34 +_LIT(KAutoUpdate,					"autoUpdate");
    1.35 +_LIT(KCmdNewScreenDeviceL,			"NewScreenDeviceL");
    1.36 +_LIT(KCmdDestructor,				"~");
    1.37 +_LIT(KCmdInitScreen,				"InitScreen");
    1.38 +_LIT(KCmdSetDisplayMode,			"SetDisplayMode");
    1.39 +_LIT(KCmdSetAutoUpdate,				"SetAutoUpdate");
    1.40 +_LIT(KCmdOrientationsAvailable,		"OrientationsAvailable");
    1.41 +_LIT(KCmdSetOrientation,			"SetOrientation");
    1.42 +_LIT(KCmdWriteRgb, 					"WriteRgb");
    1.43 +_LIT(KCmdWriteLine, 				"WriteLine");
    1.44 +_LIT(KCmdWriteBinaryLine, 			"WriteBinaryLine");
    1.45 +_LIT(KCmdWriteRgbMulti, 			"WriteRgbMulti");
    1.46 +_LIT(KCmdReadLine,		 			"ReadLine");
    1.47 +_LIT(KCmdWriteRGBAlphaLine, 		"WriteRGBAlphaLine");
    1.48 +_LIT(KCmdSetShadowMode, 			"SetShadowMode");
    1.49 +_LIT(KCmdShadowArea, 				"ShadowArea");
    1.50 +_LIT(KCmdWriteBinary, 				"WriteBinary");
    1.51 +_LIT(KCmdWriteBinaryLineVertical, 	"WriteBinaryLineVertical");
    1.52 +_LIT(KNoShadow,						"ENoShadow");
    1.53 +_LIT(KShadow,						"EShadow");
    1.54 +_LIT(KFade,							"EFade");
    1.55 +_LIT(KShadowFade,					"EShadowFade");
    1.56 +_LIT(KNone, 						"ENone");
    1.57 +_LIT(KGray2,						"EGray2");
    1.58 +_LIT(KGray4,						"EGray4");
    1.59 +_LIT(KGray16,						"EGray16");
    1.60 +_LIT(KGray256,						"EGray256");
    1.61 +_LIT(KColor16,						"EColor16");
    1.62 +_LIT(KColor256,						"EColor256");
    1.63 +_LIT(KColor64K,						"EColor64K");
    1.64 +_LIT(KColor16M,						"EColor16M");
    1.65 +_LIT(KRgb,							"ERgb");
    1.66 +_LIT(KColor4K,						"EColor4K");
    1.67 +_LIT(KColor16MU,					"EColor16MU");
    1.68 +_LIT(KColor16MA,					"EColor16MA");
    1.69 +_LIT(KColor16MAP,					"EColor16MAP");
    1.70 +_LIT(KColorLast,					"EColorLast");
    1.71 +_LIT(KDrawModePEN,					"EDrawModePEN");
    1.72 +_LIT(KDrawModeAND,					"EDrawModeAND");
    1.73 +_LIT(KDrawModeXOR,					"EDrawModeXOR");
    1.74 +_LIT(KDrawModeOR,					"EDrawModeOR");
    1.75 +_LIT(KDrawModeNOTSCREEN,			"EDrawModeNOTSCREEN");
    1.76 +_LIT(KDrawModeNOTPEN,				"EDrawModeNOTPEN");
    1.77 +_LIT(KDelay,						"delay");
    1.78 +_LIT(KOrientationNormal,			"EOrientationNormal");
    1.79 +_LIT(KOrientationRotated90,			"EOrientationRotated90");
    1.80 +_LIT(KOrientationRotated180,		"EOrientationRotated180");
    1.81 +_LIT(KOrientationRotated270,		"EOrientationRotated270");
    1.82 +
    1.83 +/**
    1.84 + * Shadow modes
    1.85 + */
    1.86 +const CDataWrapperBase::TEnumEntryTable	CT_CFbsDrawDeviceData::iEnumShadowModes[] =
    1.87 +	{
    1.88 +	KNoShadow,		1,
    1.89 +	KShadow,		2,
    1.90 +	KFade,			3,
    1.91 +	KShadowFade,	4
    1.92 +	};
    1.93 +
    1.94 +/**
    1.95 + *Display Modes
    1.96 + */
    1.97 +const CDataWrapperBase::TEnumEntryTable	CT_CFbsDrawDeviceData::iEnumDisplayModes[] =
    1.98 +	{
    1.99 +	KNone,			ENone,
   1.100 +	KGray2,			EGray2,
   1.101 +	KGray4,			EGray4,
   1.102 +	KGray16,		EGray16,
   1.103 +	KGray256,		EGray256,
   1.104 +	KColor16,		EColor16,
   1.105 +	KColor256,		EColor256,
   1.106 +	KColor64K,		EColor64K,
   1.107 +	KColor16M,		EColor16M,
   1.108 +	KRgb,			ERgb,
   1.109 +	KColor4K,		EColor4K,
   1.110 +	KColor16MU,		EColor16MU,
   1.111 +	KColor16MA,		EColor16MA,
   1.112 +	KColor16MA,		EColorLast,
   1.113 +	KColor16MAP,	EColor16MAP,
   1.114 +	KColorLast, 	EColor64K
   1.115 +	};
   1.116 +
   1.117 +/**
   1.118 + * Draw modes
   1.119 + */
   1.120 +const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumDrawModes[] =
   1.121 +	{
   1.122 +	KDrawModePEN,		CGraphicsContext::EDrawModePEN,
   1.123 +	KDrawModeAND,		CGraphicsContext::EDrawModeAND,
   1.124 +	KDrawModeXOR,		CGraphicsContext::EDrawModeXOR,
   1.125 +	KDrawModeOR,		CGraphicsContext::EDrawModeOR,
   1.126 +	KDrawModeNOTSCREEN,	CGraphicsContext::EDrawModeNOTSCREEN,
   1.127 +	KDrawModeNOTPEN,	CGraphicsContext::EDrawModeNOTPEN
   1.128 +	};
   1.129 +
   1.130 +const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumOrientationModes[] =
   1.131 +	{
   1.132 +	KOrientationNormal,		CFbsDrawDevice::EOrientationNormal,
   1.133 +	KOrientationRotated90,	CFbsDrawDevice::EOrientationRotated90,
   1.134 +	KOrientationRotated180,	CFbsDrawDevice::EOrientationRotated180,	 
   1.135 +	KOrientationRotated270,	CFbsDrawDevice::EOrientationRotated270
   1.136 +	};
   1.137 +
   1.138 +CT_CFbsDrawDeviceData* CT_CFbsDrawDeviceData::NewL() 
   1.139 +	{
   1.140 +	CT_CFbsDrawDeviceData*	ret = new (ELeave) CT_CFbsDrawDeviceData();
   1.141 +	CleanupStack::PushL(ret);
   1.142 +	ret->ConstructL();
   1.143 +	CleanupStack::Pop(ret);
   1.144 +	return ret;
   1.145 +	}
   1.146 +
   1.147 +
   1.148 +CT_CFbsDrawDeviceData::CT_CFbsDrawDeviceData()
   1.149 +:	iDrawDevice(NULL),	
   1.150 +	iDMode(CGraphicsContext::EDrawModePEN),	
   1.151 +	iDispMode(EColor64K),	
   1.152 +	iOrientation(0),	
   1.153 +	iSize(0,0),	
   1.154 +	iPostBlendShadow(ENoPostShadow),
   1.155 +	iTestRect(),
   1.156 +	iNumTestRects(0)
   1.157 +	{	
   1.158 +	}
   1.159 +
   1.160 +
   1.161 +void CT_CFbsDrawDeviceData::ConstructL()
   1.162 +	{
   1.163 +	}
   1.164 +
   1.165 +/**
   1.166 + * Public destructor
   1.167 + */
   1.168 +CT_CFbsDrawDeviceData::~CT_CFbsDrawDeviceData()
   1.169 +	{
   1.170 +	DestroyData();
   1.171 +	}
   1.172 +
   1.173 +
   1.174 +/**
   1.175 + * Return a pointer to the object that the data wraps
   1.176 + *
   1.177 + * @return	pointer to the object that the data wraps
   1.178 + */
   1.179 +TAny* CT_CFbsDrawDeviceData::GetObject()
   1.180 +	{
   1.181 +	return iDrawDevice;
   1.182 +	}
   1.183 +
   1.184 +/**
   1.185 + * Command for Destructor
   1.186 + */
   1.187 +void CT_CFbsDrawDeviceData::DoCmdDestructor()
   1.188 +	{
   1.189 +	DestroyData();
   1.190 +	}
   1.191 +
   1.192 +/**
   1.193 + * Destroys used objects
   1.194 + */
   1.195 +void CT_CFbsDrawDeviceData::DestroyData()
   1.196 +	{
   1.197 +	iTestRect.Reset();
   1.198 +	iTestRect.Close();
   1.199 +	iDispMode = ENone;
   1.200 +	iSize.SetSize(0,0);
   1.201 +	
   1.202 +	if(iDrawDevice)
   1.203 +		{		
   1.204 +		delete iDrawDevice;
   1.205 +		iDrawDevice = NULL;		
   1.206 +		}
   1.207 +	}
   1.208 +
   1.209 +/**
   1.210 + * Process a command read from the ini file
   1.211 + *
   1.212 + * @param aCommand			The command to process
   1.213 + * @param aSection			The section in the ini containing data for the command
   1.214 + * @param aAsyncErrorIndex	Command index for async calls to return errors to
   1.215 + *
   1.216 + * @return					ETrue if the command is processed
   1.217 + *
   1.218 + * @leave					System wide error
   1.219 + */
   1.220 +TBool CT_CFbsDrawDeviceData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, 
   1.221 +		const TInt/* aAsyncErrorIndex*/)
   1.222 +	{
   1.223 +	TBool	ret = ETrue;
   1.224 +
   1.225 +	if 	( aCommand==KCmdInitScreen )
   1.226 +		{
   1.227 +		DoCmdInitScreen();
   1.228 +		}
   1.229 +	else if ( aCommand==KCmdSetDisplayMode )	
   1.230 +		{
   1.231 +		DoCmdSetDisplayMode();
   1.232 +		}
   1.233 +	else if ( aCommand==KCmdSetAutoUpdate )	
   1.234 +		{
   1.235 +		DoCmdSetAutoUpdate(aSection);
   1.236 +		}
   1.237 +	else if ( aCommand==KCmdOrientationsAvailable )	
   1.238 +		{
   1.239 +		DoCmdOrientationsAvailable();
   1.240 +		}
   1.241 +	else if ( aCommand==KCmdSetOrientation )	
   1.242 +		{
   1.243 +		DoCmdSetOrientation(aSection);
   1.244 +		}
   1.245 +	else if ( aCommand==KCmdNewScreenDeviceL )	
   1.246 +		{
   1.247 +		DoCmdNewScreenDeviceL(aSection);
   1.248 +		}
   1.249 +	else if ( aCommand==KCmdDestructor )	
   1.250 +		{
   1.251 +		DoCmdDestructor();
   1.252 +		}
   1.253 +	else if ( aCommand==KCmdWriteLine )	
   1.254 +		{
   1.255 +		DoCmdWriteLineL(aSection);		
   1.256 +		}
   1.257 +	else if ( aCommand==KCmdWriteBinaryLine )	
   1.258 +		{
   1.259 +		DoCmdWriteBinaryLineL(aSection);		
   1.260 +		}
   1.261 +	else if ( aCommand==KCmdWriteRgb )	
   1.262 +		{
   1.263 +		DoCmdWriteRgb(aSection);		
   1.264 +		}
   1.265 +	else if( aCommand==KCmdWriteRgbMulti )
   1.266 +		{
   1.267 +		DoCmdWriteRgbMulti(aSection);		
   1.268 +		}
   1.269 +	else if( aCommand==KCmdReadLine )
   1.270 +		{
   1.271 +		DoCmdReadLineL(aSection);		
   1.272 +		}
   1.273 +	else if( aCommand==KCmdWriteRGBAlphaLine )
   1.274 +		{
   1.275 +		DoCmdWriteRGBAlphaLineL(aSection);		
   1.276 +		}
   1.277 +	else if( aCommand==KCmdSetShadowMode )
   1.278 +		{
   1.279 +		DoCmdSetShadowMode(aSection);
   1.280 +		}
   1.281 +	else if( aCommand==KCmdShadowArea )
   1.282 +		{
   1.283 +		DoCmdShadowArea(aSection);
   1.284 +		}
   1.285 +	else if( aCommand==KCmdWriteBinary )
   1.286 +		{
   1.287 +		DoCmdWriteBinaryL(aSection);
   1.288 +		}
   1.289 +	else if( aCommand==KCmdWriteBinaryLineVertical )
   1.290 +		{
   1.291 +		DoCmdWriteBinaryLineVerticalL(aSection);
   1.292 +		}	
   1.293 +	else
   1.294 +		{
   1.295 +		ret = EFalse;
   1.296 +		}
   1.297 +	
   1.298 +	return ret;
   1.299 +	}
   1.300 +
   1.301 +/**
   1.302 + * Tests WriteRgbMulti method from CFbsDrawDevice
   1.303 + * @param aSection			The section in the ini containing data for the command
   1.304 + * @return 							KErrNone if no error found.
   1.305 + */
   1.306 +void CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti(const TTEFSectionName& aSection)
   1.307 +	{
   1.308 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti"));
   1.309 +	TInt drawMode;
   1.310 +	TInt delay=0;
   1.311 +	TInt nRect = 0;
   1.312 +	TBool dataOk=ETrue;
   1.313 +	
   1.314 +	GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk);
   1.315 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.316 +	
   1.317 +	if ( !GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes, drawMode) )
   1.318 +		{
   1.319 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.320 +		SetBlockResult(EFail);
   1.321 +		dataOk = EFalse;
   1.322 +		}
   1.323 +	if(dataOk)
   1.324 +		{
   1.325 +		INFO_PRINTF2(_L("Change draw mode to: %d"), drawMode);
   1.326 +		iDMode=CGraphicsContext::TDrawMode(drawMode);
   1.327 +		
   1.328 +		for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++)
   1.329 +			{
   1.330 +			TRgb backColor = TestColor[nBackColor];
   1.331 +			Clear(backColor);
   1.332 +			for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
   1.333 +				{
   1.334 +				TInt shadowMode = EPostFade;
   1.335 +				TRect rect = iTestRect[nRect];			
   1.336 +				TRgb color = TestColor[nColor];				
   1.337 +				SetShadowAndFadingMode(shadowMode,100, 200);
   1.338 +				iDrawDevice->WriteRgbMulti(rect.iTl.iX,rect.iTl.iY,rect.Width(),rect.Height(),color,iDMode);
   1.339 +				
   1.340 +				User::After(delay);
   1.341 +				}
   1.342 +			}
   1.343 +		}
   1.344 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti"));
   1.345 +	}
   1.346 +
   1.347 +/**
   1.348 + * Tests WriteRgb method from CFbsDrawDevice
   1.349 + */
   1.350 +void CT_CFbsDrawDeviceData::DoCmdWriteRgb(const TTEFSectionName& aSection)
   1.351 +	{
   1.352 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRgb"));
   1.353 +	TInt drawMode;
   1.354 +	TInt nRect = 0;	
   1.355 +	TInt delay;
   1.356 +	TBool dataOk=ETrue;
   1.357 +	
   1.358 +	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
   1.359 +		{
   1.360 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.361 +		SetBlockResult(EFail);
   1.362 +		dataOk = EFalse;
   1.363 +		}
   1.364 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.365 +	GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk);
   1.366 +	
   1.367 +	if (dataOk)
   1.368 +		{
   1.369 +		iDMode=CGraphicsContext::TDrawMode(drawMode); 	
   1.370 +		for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++)
   1.371 +			{			
   1.372 +			TRgb backColor = TestBackground[nBackColor];
   1.373 +			Clear(backColor);
   1.374 +			for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
   1.375 +				{					
   1.376 +				TInt shadowMode = ENoPostShadow;																					
   1.377 +				TRect rect = iTestRect[nRect];
   1.378 +				TRgb color = TestColor[nColor];
   1.379 +				SetShadowAndFadingMode(shadowMode,100, 200);
   1.380 +				iDrawDevice->WriteRgb(rect.iTl.iX,rect.iTl.iY,color,iDMode);
   1.381 +				User::After(delay);
   1.382 +				}			
   1.383 +			}
   1.384 +		}
   1.385 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRgb"));
   1.386 +	}
   1.387 +
   1.388 +/**
   1.389 + *  Validates the received parameters and handles errors returned from TestScreenDrawL
   1.390 + *  @param aSection			The section in the ini containing data for the command
   1.391 + * 	@return 							KErrNone if no error found.
   1.392 + */
   1.393 +void CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL(const TTEFSectionName& aSection)
   1.394 + 	{
   1.395 + 	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL"));
   1.396 + 	
   1.397 + 	if(iDrawDevice)
   1.398 + 		{
   1.399 + 		delete iDrawDevice;
   1.400 +	 	iDrawDevice=NULL;
   1.401 + 		}
   1.402 + 	TInt drawMode;
   1.403 + 	TBool dataOk = ETrue;
   1.404 + 	if (!GetEnumFromConfig(aSection, KDisplayMode(), iEnumDisplayModes, drawMode))
   1.405 + 		{
   1.406 + 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDisplayMode());
   1.407 + 	    SetBlockResult(EFail);
   1.408 + 	    dataOk = EFalse;
   1.409 + 	    }
   1.410 + 	if(dataOk)
   1.411 + 		{
   1.412 + 		TDisplayMode displayMode = TDisplayMode(drawMode);
   1.413 + 		iDispMode = displayMode;
   1.414 + 		TInt ScreenNo = 0;
   1.415 + 		
   1.416 +	 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels,iSize.iWidth));
   1.417 +	 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels,iSize.iHeight));
   1.418 +	 	INFO_PRINTF3(_L("WIDTH from HAL %i \nHEIGHT from HAL %i"),iSize.iWidth,iSize.iHeight);
   1.419 +	 	ASSERT(iSize.iWidth > 0 && iSize.iHeight > 0);
   1.420 +	 	 	
   1.421 +	 		 	
   1.422 +	 	TRAPD(ret,iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(ScreenNo,displayMode));
   1.423 +	 		
   1.424 +	 	// check error code
   1.425 +	 	if(ret != KErrNone)
   1.426 +	 		{
   1.427 +	 		ERR_PRINTF2(_L("CFbsDrawDevice creation error: %d"), ret);
   1.428 +	 		SetError(ret);
   1.429 +	 		}
   1.430 +	 	else
   1.431 +	 		{
   1.432 +	 		GETFROMCONFIGMANDATORY(Int, KRectangleSection(), KNumTestRect(),iNumTestRects,_L("Error in getting parameter %S from INI file"),dataOk);
   1.433 +	 		
   1.434 +	 		if (!InitRectangles())
   1.435 +	 			{ 				
   1.436 +	 			SetBlockResult(EFail);
   1.437 +	 			ERR_PRINTF1(_L("Error: Test Rectangles NOT set!")); 						
   1.438 +	 			}
   1.439 +	 		else
   1.440 +	 			{ 	 			
   1.441 +	 			INFO_PRINTF1(_L("Test Rectangles are now set!"));	
   1.442 +	 			}
   1.443 +	 		}
   1.444 +	 	INFO_PRINTF1(_L("** DoCmdNewScreenDeviceL succeded!"));	
   1.445 + 		}
   1.446 + 	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL"));
   1.447 + 	}
   1.448 +
   1.449 +/**
   1.450 + * Inits Screen
   1.451 + */
   1.452 +void CT_CFbsDrawDeviceData::DoCmdInitScreen()
   1.453 +	{
   1.454 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdInitScreen"));
   1.455 +	TInt err = iDrawDevice->InitScreen();
   1.456 +	if(err != KErrNone)
   1.457 +		{		
   1.458 +		ERR_PRINTF2(_L("InitScreen error: %d"), err);
   1.459 +		SetError(err);
   1.460 +		}
   1.461 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdInitScreen"));
   1.462 +	}
   1.463 +
   1.464 +/**
   1.465 + * Sets Display Mode
   1.466 + * */
   1.467 +void CT_CFbsDrawDeviceData::DoCmdSetDisplayMode()
   1.468 +	{
   1.469 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetDisplayMode"));
   1.470 +	iDrawDevice->SetDisplayMode(iDrawDevice);
   1.471 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetDisplayMode"));
   1.472 +	}
   1.473 +
   1.474 +/**
   1.475 + * Sets or unsets auto-update for the screen.
   1.476 + */
   1.477 +void CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate(const TTEFSectionName& aSection)
   1.478 +	{
   1.479 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate"));
   1.480 +	TBool autoUpdate=ETrue;
   1.481 +	GETFROMCONFIGOPTIONAL(Bool, aSection, KAutoUpdate(),autoUpdate,_L("Error in getting parameter %S from INI file"));
   1.482 +	iDrawDevice->SetAutoUpdate(autoUpdate);
   1.483 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate"));
   1.484 +	}
   1.485 +
   1.486 +/**
   1.487 + * checks for Available Orientations
   1.488 + */
   1.489 +void CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable()
   1.490 +	{
   1.491 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable"));
   1.492 +	TBool orientation[4];
   1.493 +	iDrawDevice->OrientationsAvailable(orientation);
   1.494 +	INFO_PRINTF2(_L("Orientation Normal : %i"),orientation[CFbsDrawDevice::EOrientationNormal]);
   1.495 +	INFO_PRINTF2(_L("Orientation Rotated 90 : %i"),orientation[CFbsDrawDevice::EOrientationRotated90]);
   1.496 +	INFO_PRINTF2(_L("Orientation Rotated 180 : %i"),orientation[CFbsDrawDevice::EOrientationRotated180]);	 
   1.497 +	INFO_PRINTF2(_L("Orientation Rotated 270 : %i"),orientation[CFbsDrawDevice::EOrientationRotated270]);
   1.498 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable"));
   1.499 +	}
   1.500 +
   1.501 +/**
   1.502 + * Sets orientation
   1.503 + */
   1.504 +void CT_CFbsDrawDeviceData::DoCmdSetOrientation(const TTEFSectionName& aSection)
   1.505 +	{
   1.506 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetOrientation"));
   1.507 +	TBool dataOk = ETrue;
   1.508 +	
   1.509 +	
   1.510 +	if ( !GetEnumFromConfig(aSection, KOrientationMode(), iEnumOrientationModes, iOrientation) )
   1.511 +		{
   1.512 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOrientationMode());
   1.513 +		SetBlockResult(EFail);
   1.514 +		dataOk = EFalse;
   1.515 +		}
   1.516 +	
   1.517 +	if(dataOk)
   1.518 +		{
   1.519 +		
   1.520 +		TBool orientationSupported = iDrawDevice->SetOrientation(CFbsDrawDevice::TOrientation(iOrientation));
   1.521 +		
   1.522 +		if (orientationSupported)
   1.523 +			{
   1.524 +			INFO_PRINTF2(_L("Orientation was set to: %d"), iOrientation);
   1.525 +			if (iOrientation & 1)
   1.526 +				{
   1.527 +				iSize.SetSize(iSize.iHeight, iSize.iWidth);
   1.528 +				}
   1.529 +			}
   1.530 +		else
   1.531 +			{
   1.532 +			ERR_PRINTF1(_L("Orientation not Supported"));
   1.533 +			}
   1.534 +		}
   1.535 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetOrientation"));		
   1.536 +	}
   1.537 +
   1.538 +/**
   1.539 + * Tests WriteLine method from CFbsDrawDevice
   1.540 + */
   1.541 +void CT_CFbsDrawDeviceData::DoCmdWriteLineL(const TTEFSectionName& aSection)
   1.542 +	{
   1.543 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteLineL"));
   1.544 +	TInt byteSize = (ByteSize() / iSize.iHeight);
   1.545 +	TInt delay;
   1.546 +	TBool dataOk = ETrue;
   1.547 +	
   1.548 +	INFO_PRINTF2(_L("After setting bytesize %d"),byteSize);
   1.549 +	TUint8* backBuffer  = new(ELeave) TUint8[byteSize];
   1.550 +	CleanupStack::PushL(backBuffer);
   1.551 +	TUint8* writeBuffer = new(ELeave) TUint8[byteSize];
   1.552 +	CleanupStack::PushL(writeBuffer);
   1.553 +	TUint8* copyBuffer  = new(ELeave) TUint8[byteSize];
   1.554 +	CleanupStack::PushL(copyBuffer);
   1.555 +	TUint8* readBuffer  = new(ELeave) TUint8[byteSize];
   1.556 +	CleanupStack::PushL(readBuffer);
   1.557 +	
   1.558 +	INFO_PRINTF1(_L("after setting buffers"));
   1.559 +	
   1.560 +	TInt drawMode;	
   1.561 +	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
   1.562 +		{
   1.563 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.564 +		SetBlockResult(EFail);
   1.565 +		dataOk = EFalse;
   1.566 +	    }
   1.567 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.568 +	
   1.569 +	INFO_PRINTF1(_L("Test Rectangles are now set!"));
   1.570 +	TInt nRect = 0;
   1.571 +	GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk);
   1.572 +	
   1.573 +	TRect rect = iTestRect[nRect];
   1.574 +	TInt nBackColor = 0;
   1.575 +	GETFROMCONFIGMANDATORY(Int, aSection, KBackColor(),nBackColor,_L("Error in getting parameter %S from INI file"),dataOk);
   1.576 +	
   1.577 +	if(dataOk)
   1.578 +		{
   1.579 +		iDMode=CGraphicsContext::TDrawMode(drawMode);
   1.580 +		TRgb b = TestBackground[nBackColor];
   1.581 +		Clear(b);
   1.582 +		for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
   1.583 +			{
   1.584 +			FillBuffer(writeBuffer,byteSize,iDispMode);
   1.585 +				
   1.586 +			Mem::Copy(copyBuffer,writeBuffer,byteSize);
   1.587 +			iDrawDevice->WriteLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)writeBuffer,iDMode);
   1.588 +			Mem::FillZ(readBuffer,byteSize);
   1.589 +			User::After(delay);
   1.590 +			}
   1.591 +		}		
   1.592 +		INFO_PRINTF1(_L("Deleting buffers"));	
   1.593 +        CleanupStack::PopAndDestroy(4);	
   1.594 +		INFO_PRINTF1(_L("Buffers deleted"));		
   1.595 +		INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteLineL"));
   1.596 +	}
   1.597 +
   1.598 +/**
   1.599 + * Tests WriteBinaryLine from CFbsDrawDevice
   1.600 + */
   1.601 +void CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL(const TTEFSectionName& aSection)
   1.602 +	{
   1.603 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL"));
   1.604 +	TInt drawMode;
   1.605 +	TInt nRect = 0;
   1.606 +	TInt delay;
   1.607 +	TBool dataOk = ETrue;
   1.608 +	
   1.609 +	if (!GetEnumFromConfig(aSection, KDrawMode(),iEnumDrawModes, drawMode))
   1.610 +		{
   1.611 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.612 +		SetBlockResult(EFail);
   1.613 +		dataOk = EFalse;
   1.614 +		}
   1.615 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.616 +	
   1.617 +	if (!GetIntFromConfig(aSection, KNumRect(), nRect))
   1.618 +		{
   1.619 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect());
   1.620 +		SetBlockResult(EFail);
   1.621 +		dataOk = EFalse;
   1.622 +		}
   1.623 +	TInt nBackColor = 0;
   1.624 +	if (!GetIntFromConfig(aSection, KBackColor(), nBackColor))
   1.625 +		{
   1.626 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBackColor());
   1.627 +		SetBlockResult(EFail);
   1.628 +		dataOk = EFalse;
   1.629 +		}
   1.630 +	TInt shadowMode = ENoPostShadow;	
   1.631 +	if (!GetEnumFromConfig(aSection, KShadowMode(), iEnumShadowModes, shadowMode))
   1.632 +		{
   1.633 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KShadowMode());
   1.634 +		SetBlockResult(EFail);
   1.635 +		dataOk = EFalse;
   1.636 +		}
   1.637 +	
   1.638 +	if(dataOk)
   1.639 +		{
   1.640 +		iDMode=CGraphicsContext::TDrawMode(drawMode);
   1.641 +		
   1.642 +		TInt byteSize = ByteSize() / iSize.iHeight;
   1.643 +		TInt wordSize = (byteSize + 3) / 4;
   1.644 +		TUint32* writeBuffer = new(ELeave) TUint32[wordSize];
   1.645 +		CleanupStack::PushL(writeBuffer);
   1.646 +		INFO_PRINTF1(_L("Test Rectangles are now set!"));
   1.647 +		
   1.648 +		
   1.649 +		TRect rect = iTestRect[nRect];
   1.650 +			
   1.651 +		
   1.652 +			
   1.653 +		for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
   1.654 +			{
   1.655 +			if (rect.Width() > KRectWidth)
   1.656 +				{
   1.657 +				rect.iBr.iX = rect.iTl.iX + KRectWidth;
   1.658 +				}
   1.659 +			if (rect.Width() < 1)
   1.660 +				{
   1.661 +				rect.iBr.iX = rect.iTl.iX + 1;
   1.662 +				}
   1.663 +				
   1.664 +			TRgb backgroundColor = TestBackground[nBackColor];
   1.665 +			Clear(backgroundColor);
   1.666 +			TRgb testColor = TestColor[nColor];
   1.667 +				
   1.668 +			iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
   1.669 +			FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
   1.670 +			iDrawDevice->WriteBinaryLine(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),testColor,iDMode);
   1.671 +			User::After(delay);
   1.672 +			}		
   1.673 +		CleanupStack::PopAndDestroy();
   1.674 +		writeBuffer = NULL;
   1.675 +		}
   1.676 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL"));
   1.677 +	}
   1.678 +
   1.679 +/**
   1.680 + * Tests ReadLine from CFbsDrawDevice
   1.681 + * @param aSection			The section in the ini containing data for the command
   1.682 + * @return 					KErrNone if no error found.
   1.683 + */
   1.684 +void CT_CFbsDrawDeviceData::DoCmdReadLineL(const TTEFSectionName& aSection)
   1.685 +	{
   1.686 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdReadLineL"));
   1.687 +	TInt byteSize = ByteSize() / iSize.iHeight;
   1.688 +	TUint8* writeBuffer = new(ELeave) TUint8[byteSize];
   1.689 +	CleanupStack::PushL(writeBuffer);
   1.690 +	TUint8* readBuffer = new(ELeave) TUint8[iSize.iWidth * sizeof(TRgb)];
   1.691 +	CleanupStack::PushL(readBuffer);
   1.692 +	
   1.693 +	FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
   1.694 +	FillBuffer((TUint8*)readBuffer,byteSize,iDispMode);
   1.695 +	
   1.696 +	TInt nBackColor = 0;
   1.697 +	if (!GetIntFromConfig(aSection, KBackColor(), nBackColor))
   1.698 +		{
   1.699 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBackColor());
   1.700 +		SetBlockResult(EFail);
   1.701 +	    }
   1.702 +	
   1.703 +	TRgb b = TestColor[nBackColor];
   1.704 +	Clear(b);
   1.705 +
   1.706 +	for (TInt nDispMode = 0; nDispMode < KNumDispModes; nDispMode++)
   1.707 +		{
   1.708 +		TDisplayMode dispMode = TestDisplayMode[nDispMode];
   1.709 +		
   1.710 +		for (TInt cnt=0;cnt<2;cnt++)
   1.711 +			{
   1.712 +			if (cnt==0)  //first time 
   1.713 +				{
   1.714 +				iDrawDevice->SetUserDisplayMode(dispMode);
   1.715 +				}
   1.716 +			else
   1.717 +				{
   1.718 +				iDrawDevice->SetUserDisplayMode(iDispMode);
   1.719 +				}
   1.720 +				
   1.721 +			for (TInt nRect = 0; nRect < iNumTestRects; nRect++)
   1.722 +				{
   1.723 +				TRect rect = iTestRect[nRect];
   1.724 +				for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
   1.725 +					{
   1.726 +					FillBuffer(writeBuffer,byteSize,iDispMode);
   1.727 +					Mem::FillZ(readBuffer,byteSize);
   1.728 +					iDrawDevice->ReadLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)readBuffer,dispMode);
   1.729 +					Mem::FillZ(readBuffer,byteSize);
   1.730 +					}
   1.731 +				}
   1.732 +			}
   1.733 +		}	
   1.734 +    CleanupStack::PopAndDestroy(2);
   1.735 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdReadLineL"));
   1.736 +	}
   1.737 +
   1.738 +/**
   1.739 + * Tests RGBAlphaLine from CFbsDrawDevice
   1.740 + * @param aSection			The section in the ini containing data for the command
   1.741 + * @return 					KErrNone if no error found.
   1.742 + */
   1.743 +void CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL(const TTEFSectionName& aSection)
   1.744 +	{
   1.745 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL"));
   1.746 +	TInt drawMode;
   1.747 +	
   1.748 + 	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
   1.749 + 		{
   1.750 + 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.751 + 		SetBlockResult(EFail);
   1.752 + 	    }
   1.753 + 	
   1.754 + 	iDMode=CGraphicsContext::TDrawMode(drawMode);
   1.755 + 	TInt byteSize = ByteSize() / iSize.iHeight;
   1.756 +	INFO_PRINTF1(_L("In TestWriteRGBAlphaLine"));
   1.757 +	
   1.758 +	TUint8* writeBuffer = new(ELeave) TUint8[iSize.iWidth * 4];
   1.759 +	CleanupStack::PushL(writeBuffer);
   1.760 +	TUint8* writeBuffer2 = new(ELeave) TUint8[iSize.iWidth * 4];
   1.761 +	CleanupStack::PushL(writeBuffer2);
   1.762 +	TUint8* maskBuffer = new(ELeave) TUint8[iSize.iWidth * 4];
   1.763 +	CleanupStack::PushL(maskBuffer);
   1.764 +	
   1.765 +	FillBuffer(writeBuffer,byteSize,iDispMode);
   1.766 +	FillBuffer(writeBuffer2,byteSize,iDispMode);
   1.767 +	FillBuffer(maskBuffer,byteSize,iDispMode);
   1.768 +	
   1.769 +	TInt nRect;
   1.770 +	for (TInt maskFillCount=0; maskFillCount<KMaskFill;maskFillCount++)
   1.771 +		{
   1.772 +		for (nRect = 0; nRect < iNumTestRects; nRect++)
   1.773 +			{
   1.774 +			for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++)
   1.775 +				{
   1.776 +				TRgb testColor = TestColor[nBackColor];
   1.777 +				Clear(testColor);
   1.778 +				for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
   1.779 +					{
   1.780 +					//ensure the colour has the 0xff mask value
   1.781 +					TRgb checkColor;
   1.782 +					TRgb c = TestColor[nColor];
   1.783 +					TUint32 internal = c.Internal();
   1.784 +					TInt yy;
   1.785 +					TRect rect = iTestRect[nRect];
   1.786 +					TInt shadowMode =ENoPostShadow;
   1.787 +					//use a combined alpha for the check colour
   1.788 +					TUint32 combinedAlpha = MaskFill[maskFillCount]*((internal&0xff000000)>>24);
   1.789 +					combinedAlpha = ((combinedAlpha <<16) & 0xff000000);
   1.790 +					checkColor.SetInternal((internal&0x00ffffff)|combinedAlpha);
   1.791 +					SetShadowAndFadingMode(shadowMode,100, 200);
   1.792 +					for (yy = rect.iTl.iY; yy < rect.iBr.iY; yy++)
   1.793 +						{
   1.794 +						iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),
   1.795 +								writeBuffer,
   1.796 +								writeBuffer2,
   1.797 +								maskBuffer,
   1.798 +								iDMode);
   1.799 +						}
   1.800 +					//require to Shadow After the checkColor, no shadow with a zero mask
   1.801 +					TBool shadowModeChanged = EFalse;
   1.802 +					if (MaskFill[maskFillCount])
   1.803 +						{
   1.804 +						iPostBlendShadow = (TPostShadowMode) shadowMode;
   1.805 +						shadowMode = 0;
   1.806 +						shadowModeChanged = ETrue;
   1.807 +						}
   1.808 +					if(shadowModeChanged)
   1.809 +						{
   1.810 +						shadowMode = iPostBlendShadow;
   1.811 +						}
   1.812 +					iPostBlendShadow = ENoPostShadow;
   1.813 +					}
   1.814 +				}
   1.815 +			}
   1.816 +		}
   1.817 +	INFO_PRINTF1(_L("** delete buffers"));
   1.818 +    CleanupStack::PopAndDestroy(3);
   1.819 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL"));
   1.820 +	}
   1.821 +
   1.822 +/**
   1.823 + * Tests ShadowArea from CFbsDrawDevice
   1.824 + * @return 	KErrNone if no error found.
   1.825 + */
   1.826 +void CT_CFbsDrawDeviceData::DoCmdShadowArea(const TTEFSectionName& aSection)
   1.827 +	{
   1.828 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdShadowArea"));
   1.829 +	TInt delay=0;
   1.830 +	TBool dataOk = ETrue;
   1.831 +	
   1.832 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.833 +	
   1.834 +	if(dataOk)
   1.835 +		{
   1.836 +		INFO_PRINTF1(_L("In TestShadow()"));
   1.837 +		TInt nBackColor = 1;	 	
   1.838 +		TRgb testColor = TestColor[nBackColor];
   1.839 +		Clear(testColor);
   1.840 +
   1.841 +		for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++)
   1.842 +			{
   1.843 +			for (TInt nRect = 0; nRect < iNumTestRects; nRect++)
   1.844 +				{
   1.845 +				for (TInt nColor = 0; nColor < KNumTestColors; nColor++)
   1.846 +					{
   1.847 +					TRect rect = iTestRect[nRect];
   1.848 +					iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
   1.849 +					iDrawDevice->ShadowArea(rect);
   1.850 +					
   1.851 +					User::After(delay);
   1.852 +					}
   1.853 +				}
   1.854 +			}
   1.855 +		}
   1.856 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdShadowArea"));
   1.857 +			
   1.858 +	}
   1.859 +
   1.860 +/**
   1.861 + * Tests WriteBinaryLineVertical from CFbsDrawDevice
   1.862 + * @return 			KErrNone if no error found.
   1.863 + */
   1.864 +void CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL(const TTEFSectionName& aSection)
   1.865 +	{
   1.866 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL"));
   1.867 +	TInt drawMode;
   1.868 + 	TInt delay;
   1.869 + 	TBool dataOk = ETrue;
   1.870 +	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
   1.871 +		{
   1.872 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.873 +		SetBlockResult(EFail);
   1.874 +		dataOk = EFalse;
   1.875 +		}
   1.876 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.877 +	TInt nRect = 0;
   1.878 +	if (!GetIntFromConfig(aSection, KNumRect(), nRect))
   1.879 +		{
   1.880 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect());
   1.881 +		SetBlockResult(EFail);
   1.882 +		dataOk = EFalse;
   1.883 +		}
   1.884 +
   1.885 +	if(dataOk)
   1.886 +		{
   1.887 +		iDMode=CGraphicsContext::TDrawMode(drawMode);
   1.888 +		
   1.889 +		TInt byteSize = ByteSize() / iSize.iHeight;
   1.890 +		TInt wordSize = (byteSize + 3) / 4;
   1.891 +		TUint32* writeBuffer = new(ELeave) TUint32[wordSize];
   1.892 +		TInt nBackColor = 1;
   1.893 +		TInt nColor = 4;					
   1.894 +		
   1.895 +		TRect rect = iTestRect[nRect];
   1.896 +		if (rect.Width() > KRectWidth)
   1.897 +			{
   1.898 +			rect.iBr.iX = rect.iTl.iX + KRectWidth;
   1.899 +			}
   1.900 +		if (rect.Width() < 1)
   1.901 +			{
   1.902 +			rect.iBr.iX = rect.iTl.iX + 1;
   1.903 +			}
   1.904 +		
   1.905 +		TRgb b = TestBackground[nBackColor];
   1.906 +		TRgb c = TestColor[nColor];
   1.907 +		Clear(b);
   1.908 +
   1.909 +
   1.910 +		//NOTE Call Command within script: SetShadowmode
   1.911 +		FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
   1.912 +		iDrawDevice->WriteBinaryLineVertical(rect.iTl.iX,rect.iBr.iY - 1,writeBuffer,rect.Height(),c,iDMode,ETrue);
   1.913 +
   1.914 +		User::After(delay);
   1.915 +		delete [] writeBuffer;
   1.916 +		writeBuffer = NULL;
   1.917 +		}
   1.918 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL"));
   1.919 +	}
   1.920 +
   1.921 +/**
   1.922 + * Sets the current shadowing mode
   1.923 + * @param aSection			The section in the ini containing data for the command
   1.924 + */
   1.925 +void CT_CFbsDrawDeviceData::DoCmdSetShadowMode(const TTEFSectionName& aSection)
   1.926 +	{
   1.927 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetShadowMode"));
   1.928 +	TInt shadowMode = ENoPostShadow;
   1.929 +	if(!GetEnumFromConfig(aSection, KShadowMode(), iEnumShadowModes, shadowMode))
   1.930 +		{
   1.931 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KShadowMode());
   1.932 +		SetBlockResult(EFail);
   1.933 +		}
   1.934 +	else
   1.935 +		{
   1.936 +		iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
   1.937 +		}
   1.938 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetShadowMode"));
   1.939 +	}
   1.940 +
   1.941 +/**
   1.942 + * Tests WriteBinary method from CFbsDrawDevice
   1.943 + * @param aSection			The section in the ini containing data for the command
   1.944 + * @return 							KErrNone if no error found.
   1.945 + */
   1.946 +void CT_CFbsDrawDeviceData::DoCmdWriteBinaryL(const TTEFSectionName& aSection)
   1.947 +	{
   1.948 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryL"));
   1.949 +	TInt drawMode;
   1.950 +	TInt delay;
   1.951 +	TBool dataOk = ETrue;
   1.952 +	if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode))
   1.953 +		{
   1.954 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode());
   1.955 +		SetBlockResult(EFail);
   1.956 +		dataOk = EFalse;
   1.957 +		}
   1.958 +	GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk);
   1.959 +	TInt nRect = 0;
   1.960 +	if (!GetIntFromConfig(aSection, KNumRect(), nRect))
   1.961 +		{
   1.962 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect());
   1.963 +		SetBlockResult(EFail);
   1.964 +		dataOk = EFalse;
   1.965 +		}
   1.966 +	if(dataOk)
   1.967 +		{
   1.968 +		iDMode=CGraphicsContext::TDrawMode(drawMode);
   1.969 +		TInt byteSize = ByteSize() / iSize.iHeight;
   1.970 +		TInt wordSize = (byteSize + 3) / 4;
   1.971 +		TUint32* writeBuffer = new (ELeave)TUint32[wordSize];
   1.972 +		
   1.973 +		TRect rect = iTestRect[nRect];
   1.974 +		TInt nBackColor = 0;
   1.975 +		TInt nColor = 4;
   1.976 +
   1.977 +		if (rect.Width() > KRectWidth)
   1.978 +			{
   1.979 +			rect.iBr.iX = rect.iTl.iX + KRectWidth;
   1.980 +			}
   1.981 +		if (rect.Width() < 1)
   1.982 +			{
   1.983 +			rect.iBr.iX = rect.iTl.iX + 1;
   1.984 +			}
   1.985 +		
   1.986 +		TRgb b = TestBackground[nBackColor];
   1.987 +		Clear(b);
   1.988 +		TRgb c = TestColor[nColor];
   1.989 +		//NOTE Call Command within script: SetShadowmode
   1.990 +		FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode);
   1.991 +		iDrawDevice->WriteBinary(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),rect.Height(),c,iDMode);
   1.992 +		
   1.993 +		User::After(delay);
   1.994 +		delete [] writeBuffer;
   1.995 +		writeBuffer = NULL;
   1.996 +		}
   1.997 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryL"));
   1.998 +	}
   1.999 +
  1.1000 +/**
  1.1001 + * Clears screen with specified color
  1.1002 + */
  1.1003 +void CT_CFbsDrawDeviceData::Clear(TRgb aColor)
  1.1004 +	{
  1.1005 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::Clear"));
  1.1006 +	iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow);
  1.1007 +	iDrawDevice->WriteRgbMulti(0,0,iSize.iWidth,iSize.iHeight,aColor,CGraphicsContext::EDrawModeWriteAlpha);
  1.1008 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::Clear"));
  1.1009 +	}
  1.1010 +/**
  1.1011 + * Sets Shadow and fading modes
  1.1012 + * @param one of the supported shadow modes ENoShadow,EShadow,EFade,EShadowFade
  1.1013 + * @param a black point
  1.1014 + * @param a white point
  1.1015 + */
  1.1016 +void CT_CFbsDrawDeviceData::SetShadowAndFadingMode(TInt shadowMode,TInt blackPoint, TInt whitePoint)
  1.1017 +	{
  1.1018 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::SetShadowAndFadingMode"));
  1.1019 +	iDrawDevice->SetFadingParameters(blackPoint,whitePoint);  
  1.1020 +	iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode));
  1.1021 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::SetShadowAndFadingMode"));
  1.1022 +	}
  1.1023 +
  1.1024 +
  1.1025 +/**
  1.1026 + * Fills a buffer to be displayed on screen
  1.1027 + * 
  1.1028 + * @param aBuffer
  1.1029 + * @param aByteSize
  1.1030 + * @param aDispMode
  1.1031 + */
  1.1032 +void CT_CFbsDrawDeviceData::FillBuffer(TUint8* aBuffer,TInt aByteSize,TDisplayMode aDispMode)
  1.1033 +	{
  1.1034 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::FillBuffer"));
  1.1035 +	TUint8* bufferLimit = aBuffer + aByteSize;
  1.1036 +
  1.1037 +	TInt64 seed = TInt64(TInt(aBuffer) * aByteSize * aDispMode * User::TickCount());
  1.1038 +
  1.1039 +	if (aDispMode != EColor4K)
  1.1040 +		{
  1.1041 +		while (aBuffer < bufferLimit)
  1.1042 +			{
  1.1043 +			*aBuffer++ = (TUint8)Math::Rand(seed);
  1.1044 +			}
  1.1045 +		}
  1.1046 +	else
  1.1047 +		{
  1.1048 +		while (aBuffer < bufferLimit)
  1.1049 +			{
  1.1050 +			if (TInt(aBuffer) & 3 == 3)
  1.1051 +				{
  1.1052 +				*aBuffer++ = 0;
  1.1053 +				}
  1.1054 +			else
  1.1055 +				{
  1.1056 +				*aBuffer++ = (TUint8)Math::Rand(seed);
  1.1057 +				}
  1.1058 +			}
  1.1059 +		}
  1.1060 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::FillBuffer"));
  1.1061 +	}
  1.1062 +
  1.1063 +/**
  1.1064 + * Sets the Byte Size based on screen Width and Height
  1.1065 + */
  1.1066 +TInt CT_CFbsDrawDeviceData::ByteSize()
  1.1067 +	{
  1.1068 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::ByteSize"));	
  1.1069 +	TInt wordSize = iSize.iWidth;
  1.1070 +	switch (iDispMode)
  1.1071 +		{
  1.1072 +	case EGray2:
  1.1073 +		wordSize = (wordSize + 31) / 32;
  1.1074 +		break;
  1.1075 +	case EGray4:
  1.1076 +		wordSize = (wordSize + 15) / 16;
  1.1077 +		break;
  1.1078 +	case EGray16:
  1.1079 +	case EColor16:
  1.1080 +		wordSize = (wordSize + 7) / 8;
  1.1081 +		break;
  1.1082 +	case EGray256:
  1.1083 +	case EColor256:
  1.1084 +		wordSize = (wordSize + 3) / 4;
  1.1085 +		break;
  1.1086 +	case EColor4K:
  1.1087 +	case EColor64K:
  1.1088 +		wordSize = (wordSize + 1) / 2;
  1.1089 +		break;
  1.1090 +	case EColor16M:
  1.1091 +		wordSize = (((wordSize * 3) + 11) / 12) * 3;
  1.1092 +		break;
  1.1093 +	case EColor16MU:
  1.1094 +	case EColor16MA:
  1.1095 +		//Should not be changed!
  1.1096 +		break;
  1.1097 +	default:
  1.1098 +		break;
  1.1099 +		};
  1.1100 +	
  1.1101 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::ByteSize"));	
  1.1102 +	return wordSize * iSize.iHeight * 4;
  1.1103 +	}
  1.1104 +
  1.1105 +/**
  1.1106 + *	This method reads a string with this form: (a,,b,c,d) and splits it in an TInt array. 
  1.1107 + * 
  1.1108 + */
  1.1109 +void CT_CFbsDrawDeviceData::ReadRectL(HBufC& aString, RArray<TInt>& aResult)
  1.1110 +	{
  1.1111 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::ReadRectL"));
  1.1112 +	TChar chr;
  1.1113 +	TLex lex(aString);
  1.1114 +	TBuf<256> buf;
  1.1115 +	
  1.1116 +	lex.Inc();			
  1.1117 +	while(!lex.Eos())
  1.1118 +        {
  1.1119 +        chr = lex.Get();
  1.1120 +        // Check if there was a list separator
  1.1121 +        if (chr == ',')
  1.1122 +            {
  1.1123 +            HBufC* param = buf.AllocLC();
  1.1124 +            buf.Zero();
  1.1125 +            TInt x = 0;
  1.1126 +            TLex lexX(*param);
  1.1127 +            lexX.Val(x);
  1.1128 +            aResult.Append(x);
  1.1129 +            CleanupStack::Pop(param); // pointer to buf is stored in RPointerArray
  1.1130 +            }
  1.1131 +        // If not separator character we can store the character into array
  1.1132 +        else
  1.1133 +            {
  1.1134 +            if (chr != ')')
  1.1135 +            	{
  1.1136 +            	buf.Append(chr);
  1.1137 +            	}
  1.1138 +            }
  1.1139 +        }
  1.1140 +        
  1.1141 +	HBufC* param = buf.AllocLC();
  1.1142 +	TInt x = 0;
  1.1143 +    TLex lexX(*param);
  1.1144 +    lexX.Val(x);
  1.1145 +    aResult.Append(x);	
  1.1146 +	CleanupStack::PopAndDestroy(param);
  1.1147 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::ReadRectL"));
  1.1148 +	}
  1.1149 +
  1.1150 +/**
  1.1151 + *	This method reads a string with this form: (a,,b,c,d) and splits it in an TInt array. 
  1.1152 + * 
  1.1153 + */
  1.1154 +TBool CT_CFbsDrawDeviceData::InitRectangles()
  1.1155 +	{
  1.1156 +	INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::InitRectangles"));
  1.1157 +	TBool readResult = ETrue;
  1.1158 +	RPointerArray<HBufC> dimensions;
  1.1159 +	RArray<TInt> result;
  1.1160 +	TInt err = KErrNone;
  1.1161 +	
  1.1162 +	if ( GetArrayRectFromConfig( KRectangleSection(), KRectangles(), dimensions))//its validated by the above call	
  1.1163 +		{
  1.1164 +		for (TInt i = 0; i < iNumTestRects; i++)
  1.1165 +			{
  1.1166 +			TRAP(err , ReadRectL(*dimensions[i], result));
  1.1167 +			if (err != KErrNone)
  1.1168 +				{
  1.1169 +				readResult = EFalse;
  1.1170 +				break;
  1.1171 +				}
  1.1172 +			else
  1.1173 +				{							
  1.1174 +				iTestRect.Append(TRect(result[0],result[1],result[2],result[3]));
  1.1175 +				result.Reset();
  1.1176 +				}
  1.1177 +			}		
  1.1178 +		} 
  1.1179 +	else
  1.1180 +		{		
  1.1181 +		readResult = EFalse;
  1.1182 +		}
  1.1183 +	dimensions.ResetAndDestroy();
  1.1184 +	result.Reset();
  1.1185 +	result.Close();
  1.1186 +
  1.1187 +	INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::InitRectangles"));
  1.1188 +  	return readResult;
  1.1189 +
  1.1190 +	}