graphicsdeviceinterface/screendriver/tsrc/TScdvScaling.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32math.h>
       
    17 #include <hal.h>
       
    18 #include <bitdraw.h>
       
    19 #include <bitdrawscaling.h>
       
    20 #include <bitdraworigin.h>
       
    21 #include <bitdrawinterfaceid.h>
       
    22 #include <graphics/gdi/gdiconsts.h>
       
    23 #include "TScdvScaling.h"
       
    24 
       
    25 
       
    26 
       
    27 //Test line properties: 
       
    28 //[iX, iY] - the starting point of the line
       
    29 //iLength - line length
       
    30 struct TLineProps
       
    31 	{
       
    32 	TInt iX;
       
    33 	TInt iY;
       
    34 	TInt iLength;
       
    35 	};
       
    36 //
       
    37 //Constants
       
    38 //
       
    39 //This structure defines [TDrawMode <-> clear screen color value] relation
       
    40 //When the test uses KDrawMode[i].iDrawMode, then the screen will be cleared using
       
    41 //KDrawMode[i].iClearColorVal value
       
    42 struct TDrawModeProps
       
    43 	{
       
    44 	CGraphicsContext::TDrawMode iDrawMode;
       
    45 	// keep the color value 8-bit in both EColor256 and EColor64K, special care need
       
    46 	// to be done when filling the buffer, e.g color=0x55 
       
    47 	// in EColor256 clearing means filling 0x55 0x55 0x55 etc, but
       
    48 	// in EColor64K it has to be 0x0055 0x0055 0x0055 etc
       
    49 	TUint8 iClearColorVal;
       
    50 	};
       
    51 const TDrawModeProps KDrawMode[] = 
       
    52 	{
       
    53 		{CGraphicsContext::EDrawModePEN,		0xFF},
       
    54 		{CGraphicsContext::EDrawModeAND,		0x37},
       
    55 		{CGraphicsContext::EDrawModeXOR,		0x38},
       
    56 		{CGraphicsContext::EDrawModeOR,			0xB1},
       
    57 		{CGraphicsContext::EDrawModeNOTSCREEN,	0xC0},
       
    58 		{CGraphicsContext::EDrawModeNOTPEN,		0x1D}
       
    59 	};
       
    60 const TInt KDrawModesCnt = sizeof(KDrawMode) / sizeof(KDrawMode[0]);
       
    61 //Shadow/Fade modes
       
    62 const CFbsDrawDevice::TShadowMode KShadowMode[] = 
       
    63 	{
       
    64 	CFbsDrawDevice::EShadow,
       
    65 	CFbsDrawDevice::EFade,
       
    66 	CFbsDrawDevice::EShadowFade
       
    67 	};
       
    68 const TInt KShadowModesCnt = sizeof(KShadowMode) / sizeof(KShadowMode[0]);
       
    69 //Test pixel color value
       
    70 const TUint8 KTestColorVal = 0x55;
       
    71 //All possible orientations
       
    72 const CFbsDrawDevice::TOrientation KOrientation[] = 
       
    73 	{
       
    74 	CFbsDrawDevice::EOrientationNormal,
       
    75 	CFbsDrawDevice::EOrientationRotated90,
       
    76 	CFbsDrawDevice::EOrientationRotated180,
       
    77 	CFbsDrawDevice::EOrientationRotated270
       
    78 	};
       
    79 const TInt KOrientationsCnt = sizeof(KOrientation) / sizeof(KOrientation[0]);
       
    80 //Width and Height of legacy application screen
       
    81 const TInt KLegacyAppSizeWidth = 60;
       
    82 const TInt KLegacyAppSizeHeight = 40;
       
    83 //Scaling factors: X and Y
       
    84 const TInt KScalingFactorX = 3;
       
    85 const TInt KScalingFactorY = 2;
       
    86 const TInt KMaxScalingFactor = 3;		//Max of previous 2 values
       
    87 
       
    88 //
       
    89 //Declarations
       
    90 //
       
    91 GLDEF_C TInt ByteSize(TDisplayMode aDisplayMode,TInt aWidth)
       
    92 	{
       
    93 	TInt wordSize=aWidth;
       
    94 	switch(aDisplayMode)
       
    95 		{
       
    96 		case EGray2:
       
    97 			wordSize = (wordSize + 31) / 32;
       
    98 			break;
       
    99 		case EGray4:
       
   100 			wordSize = (wordSize + 15) / 16;
       
   101 			break;
       
   102 		case EGray16:
       
   103 		case EColor16:
       
   104 			wordSize = (wordSize + 7) / 8;
       
   105 			break;
       
   106 		case EGray256:
       
   107 		case EColor256:
       
   108 			wordSize = (wordSize + 3) / 4;
       
   109 			break;
       
   110 		case EColor4K:
       
   111 		case EColor64K:
       
   112 			wordSize = (wordSize + 1) / 2;
       
   113 			break;
       
   114 		case EColor16M:
       
   115 			wordSize = ((wordSize + 3) / 4) * 3;
       
   116 			break;
       
   117 		case EColor16MU:
       
   118 		case EColor16MA:
       
   119 			//Doesn't need changing
       
   120 			break;
       
   121 		default:
       
   122 			break;
       
   123 		};
       
   124 	return wordSize * 4;
       
   125 	}
       
   126 
       
   127 static inline TInt ByteSize(TDisplayMode aDisplayMode, TSize aSize)
       
   128 	{
       
   129 	return ByteSize(aDisplayMode,aSize.iWidth) * aSize.iHeight;
       
   130 	}
       
   131 
       
   132 template <class TPixelType> 
       
   133 inline void MemFill(TPixelType* aBuffer, TInt aSize, TPixelType aValue)
       
   134 	{
       
   135 	TPixelType* p = aBuffer;
       
   136 	TInt i = 0;
       
   137 	while (i++<aSize)
       
   138 		*p++ = aValue;
       
   139 	}
       
   140 	
       
   141 //Generic test class for both Color256 and Color64K
       
   142 template <class TPixelType> class CTScaling: public CTGraphicsBase
       
   143 	{
       
   144 public:
       
   145 	CTScaling(CTestStep *aTest, TDisplayMode aDisplayMode);
       
   146 	~CTScaling();
       
   147 	void RunTestCaseL(TInt aCurTestCase);
       
   148 private:
       
   149 	void ConstructL();
       
   150 	void CreateScreenDeviceL();
       
   151 	void SetScalingSettings(const TPoint& aOrigin, TInt aFx, TInt aFy, TInt aDivX, TInt aDivY);
       
   152 	void CheckLine(const TLineProps& aLineProps, const TPoint& aOrg, const TDrawModeProps& aDrawModeProps, TPixelType aClearColorValue);
       
   153 	void CheckWriteRgbMulti(const TRect& aRcProps, const TPoint& aOrg, const TDrawModeProps& aDrawModeProps, TPixelType aClearColorValue);
       
   154 	void CheckRgbAlphaLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue);
       
   155 	void CheckRect(const TRect& aRc, const TPoint& aOrg, TPixelType aClearColorValue);
       
   156 	void WriteLine();
       
   157 	void ClearScreen(const TDrawModeProps& aDrawModeProps);
       
   158 	void SetTestData();
       
   159 	void CheckChangedPixels(TInt aChangedPixelsCnt, TPixelType aClearColorVal);
       
   160 	void CheckWriteBinary(const TPoint& aPt, const TPoint& aOrg, TPixelType aClearColorValue, TInt aLength, TInt aHeight);
       
   161 	void CheckVertLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue);
       
   162 	void WriteRgb();
       
   163 	void WriteRgbMulti();
       
   164 	void WriteRgbAlphaLine();
       
   165 	void WriteBinary();
       
   166 	void WriteBinaryLineVertical();
       
   167 	void WriteBinaryLine();
       
   168 	void WriteRgbAlphaMulti();
       
   169 	void ShadowArea();
       
   170 	void WriteRgbAlphaLine2();
       
   171 	void TestScalingSettingsInterface();
       
   172 	void PerformanceTest();
       
   173 private:
       
   174 	//Test data array
       
   175 	TPixelType iTestData[KLegacyAppSizeWidth];
       
   176 	//The device used in the tests
       
   177 	CFbsDrawDevice* iDrawDevice;
       
   178 	//Width and Height of the screen
       
   179 	TSize iPhysSize;
       
   180 	//The test allocates block of memory for a screen with PhysSize size 
       
   181 	//mode. iBits will point to the allocated memory block.
       
   182 	TPixelType* iBits;
       
   183 	TDisplayMode iDisplayMode;
       
   184 	//The scaling interface
       
   185 	MScalingSettings* iScalingSettings;
       
   186 	//The origin interface
       
   187 	MDrawDeviceOrigin* iOriginInterface;
       
   188 	TInt iCurOrientation;
       
   189 	TInt iScalingFactorX;
       
   190 	TInt iScalingFactorY;
       
   191 	};
       
   192 typedef CTScaling<TUint8> CTestNone;
       
   193 typedef CTScaling<TUint8> CTestColor256;
       
   194 typedef CTScaling<TUint16> CTestColor64K;
       
   195 
       
   196 
       
   197 
       
   198 //
       
   199 //Test code
       
   200 //
       
   201 /*template <class TPixelType>
       
   202 CTScaling<TPixelType>* CTScaling<TPixelType>::NewL(TDisplayMode aDisplayMode)	
       
   203 	{
       
   204 	CTScaling<TPixelType>* self = new (ELeave) CTScaling<TPixelType>;
       
   205 	CleanupStack::PushL(self);
       
   206 	self->ConstructL(aDisplayMode);
       
   207 	CleanupStack::Pop(self);
       
   208 	return self;
       
   209 	}
       
   210 */	
       
   211 
       
   212 template <class TPixelType>
       
   213 CTScaling<TPixelType>::CTScaling(CTestStep *aTest, TDisplayMode aDisplayMode) :
       
   214 				CTGraphicsBase(aTest),
       
   215 				iDisplayMode(aDisplayMode)
       
   216 	{
       
   217 	INFO_PRINTF1(_L("Scaling tests"));
       
   218 	}
       
   219 	
       
   220 
       
   221 template <class TPixelType>
       
   222 void CTScaling<TPixelType>::ConstructL()	
       
   223 	{
       
   224 	CreateScreenDeviceL();
       
   225 	}
       
   226 	
       
   227 template <class TPixelType>
       
   228 CTScaling<TPixelType>::~CTScaling()
       
   229 	{
       
   230 	((CTScalingStep*)iStep)->CloseTMSGraphicsStep();
       
   231 	delete[] iBits;
       
   232 	delete iDrawDevice;	
       
   233 	}
       
   234 	
       
   235 template <class TPixelType>
       
   236 void CTScaling<TPixelType>::SetScalingSettings(const TPoint& aOrigin, TInt aFx, TInt aFy, TInt aDivX, TInt aDivY)
       
   237 	{
       
   238 	TEST(iDrawDevice != NULL);	
       
   239 	if(!iScalingSettings)
       
   240 		{
       
   241 		TInt err = iDrawDevice->GetInterface(KScalingSettingsInterfaceID, 
       
   242 											  reinterpret_cast <TAny*&> (iScalingSettings));
       
   243 		TEST2(err, KErrNone);
       
   244 		}
       
   245 	TEST(iScalingSettings != NULL);
       
   246 	TInt err = iScalingSettings->Set(aFx, aFy, aDivX, aDivY);
       
   247 	TEST2(err, KErrNone);
       
   248 	if(!iOriginInterface)
       
   249 		{
       
   250 		TInt err = iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID, 
       
   251 											  reinterpret_cast <TAny*&> (iOriginInterface));
       
   252 		TEST2(err, KErrNone);
       
   253 		}
       
   254 	TEST(iOriginInterface != NULL);
       
   255 	err = iOriginInterface->Set(aOrigin);
       
   256 	TEST2(err, KErrNone);
       
   257 	}
       
   258 
       
   259 //Clears the screen initializing each screen pixel with aDrawModeProps.iClearColorVal value
       
   260 template <class TPixelType>
       
   261 void CTScaling<TPixelType>::ClearScreen(const TDrawModeProps& aDrawModeProps)
       
   262 	{
       
   263 	::MemFill(iBits, ::ByteSize(EColor256, iPhysSize), TPixelType(aDrawModeProps.iClearColorVal));
       
   264 	}
       
   265 
       
   266 //Initializes iTestData array with KTestColorVal value
       
   267 template <class TPixelType>
       
   268 void CTScaling<TPixelType>::SetTestData()
       
   269 	{
       
   270 	::MemFill(iTestData, KLegacyAppSizeWidth, TPixelType(KTestColorVal));
       
   271 	}
       
   272 
       
   273 template <class TPixelType>
       
   274 void CTScaling<TPixelType>::CheckChangedPixels(TInt aChangedPixelsCnt, TPixelType aClearColorVal)
       
   275 	{
       
   276 	const TInt KByteSize = ::ByteSize(EColor256, iPhysSize);
       
   277 	TInt changedPixelsCnt = 0;
       
   278 	for(TInt ii=0;ii<KByteSize;++ii)
       
   279 		{
       
   280 		if(iBits[ii]!=aClearColorVal)
       
   281 			{
       
   282 			++changedPixelsCnt;
       
   283 			}
       
   284 		}
       
   285 	TEST(changedPixelsCnt == aChangedPixelsCnt);
       
   286 	if (changedPixelsCnt!=aChangedPixelsCnt)
       
   287 		{
       
   288 		_LIT(KLog,"Wrong number of changed pixels, expected=%d, actual=%d, color=0x%x");
       
   289 		INFO_PRINTF4(KLog,aChangedPixelsCnt,changedPixelsCnt,aClearColorVal);
       
   290 		}
       
   291 	}
       
   292 
       
   293 //Checks a set of horisontal lines , which starting point is 
       
   294 //[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
       
   295 //and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
       
   296 //is incremented by 1.
       
   297 //The screen lines pixel values are tested against aClearColorValue value.
       
   298 //Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
       
   299 template <class TPixelType>
       
   300 void CTScaling<TPixelType>::CheckLine(const TLineProps& aLineProps, 
       
   301 					  const TPoint& aOrg, 
       
   302 					  const TDrawModeProps& aDrawModeProps, 
       
   303 					  TPixelType aClearColorValue)
       
   304 	{
       
   305 	TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
       
   306 	TInt ii;
       
   307 	for(ii=0;ii<iScalingFactorY;++ii)
       
   308 		{
       
   309 		Mem::Fill(data, sizeof(data), 0x00);
       
   310 		iDrawDevice->ReadLine(aOrg.iX + aLineProps.iX * iScalingFactorX, 
       
   311 							   aOrg.iY + aLineProps.iY * iScalingFactorY + ii, 
       
   312 							   aLineProps.iLength * iScalingFactorX, 
       
   313 							   data, 
       
   314 							   iDisplayMode);
       
   315 		const TInt length=aLineProps.iLength*iScalingFactorX;
       
   316 		TInt firstErr=length;
       
   317 		TInt numErrs=0;
       
   318 		for(TInt jj=0;jj<length;++jj)
       
   319 			{
       
   320 			//TEST(data[jj]!=aClearColorValue);
       
   321 			if (data[jj]==aClearColorValue)
       
   322 				{
       
   323 				++numErrs;
       
   324 				if (jj<firstErr)
       
   325 					firstErr=jj;
       
   326 				}
       
   327 			}
       
   328 		TEST(numErrs==0);
       
   329 		if (numErrs>0)
       
   330 			{
       
   331 			_LIT(KLog,"Line %d (of %d) of length %d has %d errors first one at %d,  ClearCol=0x%x");
       
   332 			INFO_PRINTF7(KLog,ii,iScalingFactorY,length,numErrs,firstErr,aClearColorValue);
       
   333 			}
       
   334 		}
       
   335 	TInt changedPixelsCnt = iScalingFactorY * aLineProps.iLength * iScalingFactorX;
       
   336 	CheckChangedPixels(changedPixelsCnt, aDrawModeProps.iClearColorVal);
       
   337 	}
       
   338 
       
   339 //Checks the rectangle filled using CFbsScreenDevice::WriteRgbMulti. 
       
   340 //The screen lines pixel values are tested against aClearColorValue value.
       
   341 //Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
       
   342 template <class TPixelType>
       
   343 void CTScaling<TPixelType>::CheckWriteRgbMulti(const TRect& aRcProps, 
       
   344 							   const TPoint& aOrg, 
       
   345 							   const TDrawModeProps& aDrawModeProps, 
       
   346 							   TPixelType aClearColorValue)
       
   347 	{
       
   348 	TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
       
   349 	TInt ii;
       
   350 	TInt xx = aOrg.iX + aRcProps.iTl.iX * iScalingFactorX;
       
   351 	TInt yy = aOrg.iY + aRcProps.iTl.iY * iScalingFactorY;
       
   352 	for(ii=0;ii<(iScalingFactorY * aRcProps.Height());++ii)
       
   353 		{
       
   354 		Mem::Fill(data, sizeof(data), 0x00);
       
   355 		iDrawDevice->ReadLine(xx, yy+ii, aRcProps.Width()*iScalingFactorX, data, iDisplayMode);
       
   356 		const TInt width=aRcProps.Width()*iScalingFactorX;
       
   357 		TInt firstErr=width;
       
   358 		TInt numErrs=0;
       
   359 		for(TInt jj=0;jj<width;++jj)
       
   360 			{
       
   361 			//TEST(data[jj]!=aClearColorValue);
       
   362 			if (data[jj]==aClearColorValue)
       
   363 				{
       
   364 				++numErrs;
       
   365 				if (jj<firstErr)
       
   366 					firstErr=jj;
       
   367 				}
       
   368 			}
       
   369 		TEST(numErrs==0);
       
   370 		if (numErrs>0)
       
   371 			{
       
   372 			_LIT(KLog,"Line %d of width %d has %d errors first one at %d,  ClearCol=0x%x");
       
   373 			INFO_PRINTF6(KLog,ii,width,numErrs,firstErr,aClearColorValue);
       
   374 			}
       
   375 		}
       
   376 	TInt changedPixelsCnt = iScalingFactorY * aRcProps.Width() * aRcProps.Height() * iScalingFactorX;
       
   377 	CheckChangedPixels(changedPixelsCnt, aDrawModeProps.iClearColorVal);
       
   378 	}
       
   379 
       
   380 //Checks a set of horisontal lines , which starting point is 
       
   381 //[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
       
   382 //and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
       
   383 //is incremented by 1.
       
   384 //The screen lines pixel values are tested against aClearColorValue value.
       
   385 //Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
       
   386 template <class TPixelType>
       
   387 void CTScaling<TPixelType>::CheckRgbAlphaLine(const TLineProps& aLineProps, 
       
   388 							  const TPoint& aOrg, 
       
   389 							  TPixelType aClearColorValue)
       
   390 	{
       
   391 	TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
       
   392 	for(TInt ii=0;ii<iScalingFactorY;++ii)
       
   393 		{
       
   394 		Mem::Fill(data, sizeof(data), 0x00);
       
   395 		iDrawDevice->ReadLine(aOrg.iX + aLineProps.iX * iScalingFactorX, 
       
   396 							   aOrg.iY + aLineProps.iY * iScalingFactorY + ii, 
       
   397 							   aLineProps.iLength * iScalingFactorX, 
       
   398 							   data, 
       
   399 							   iDisplayMode);
       
   400 		const TInt length=aLineProps.iLength*iScalingFactorX;
       
   401 		TInt firstErr=length;
       
   402 		TInt numErrs=0;
       
   403 		for(TInt jj=0;jj<(aLineProps.iLength * iScalingFactorX);++jj)
       
   404 			{
       
   405 			//TEST(data[jj]!=aClearColorValue);
       
   406 			if (data[jj]==aClearColorValue)
       
   407 				{
       
   408 				++numErrs;
       
   409 				if (jj<firstErr)
       
   410 					firstErr=jj;
       
   411 				}
       
   412 			}
       
   413 		TEST(numErrs==0);
       
   414 		if (numErrs>0)
       
   415 			{
       
   416 			_LIT(KLog,"Line %d of length %d has %d errors first one at %d,  ClearCol=0x%x");
       
   417 			INFO_PRINTF6(KLog,ii,length,numErrs,firstErr,aClearColorValue);
       
   418 			}
       
   419 		}
       
   420 	TInt changedPixelsCnt = iScalingFactorY * aLineProps.iLength * iScalingFactorX;
       
   421 	CheckChangedPixels(changedPixelsCnt, aClearColorValue);
       
   422 	}
       
   423 
       
   424 //Checks the rectangle filled using CFbsScreenDevice::WriteBinary. 
       
   425 //The screen lines pixel values are tested against aClearColorValue value.
       
   426 //Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
       
   427 template <class TPixelType>
       
   428 void CTScaling<TPixelType>::CheckWriteBinary(const TPoint& aPt, 
       
   429 							 const TPoint& aOrg, 
       
   430 							 TPixelType aClearColorValue, 
       
   431 							 TInt aLength, TInt aHeight)
       
   432 	{
       
   433 	TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
       
   434 	TInt ii;
       
   435 	TInt xx = aOrg.iX + aPt.iX * iScalingFactorX;
       
   436 	TInt yy = aOrg.iY + aPt.iY * iScalingFactorY;
       
   437 	for(ii=0;ii<(iScalingFactorY * aHeight);++ii)
       
   438 		{
       
   439 		Mem::Fill(data, sizeof(data), 0x00);
       
   440 		iDrawDevice->ReadLine(xx, yy + ii, aLength * iScalingFactorX, data, iDisplayMode);
       
   441 		const TInt length=aLength*iScalingFactorX;
       
   442 		TInt firstErr=length;
       
   443 		TInt numErrs=0;
       
   444 		for(TInt jj=0;jj<length;++jj)
       
   445 			{
       
   446 			//TEST(data[jj] != aClearColorValue);
       
   447 			if (data[jj]==aClearColorValue)
       
   448 				{
       
   449 				++numErrs;
       
   450 				if (jj<firstErr)
       
   451 					firstErr=jj;
       
   452 				}
       
   453 			}
       
   454 		TEST(numErrs==0);
       
   455 		if (numErrs>0)
       
   456 			{
       
   457 			_LIT(KLog,"Line %d of length %d has %d errors first one at %d,  ClearCol=0x%x");
       
   458 			INFO_PRINTF6(KLog,ii,length,numErrs,firstErr,aClearColorValue);
       
   459 			}
       
   460 		}
       
   461 	TInt changedPixelsCnt = iScalingFactorY * aLength * aHeight * iScalingFactorX;
       
   462 	CheckChangedPixels(changedPixelsCnt, aClearColorValue);
       
   463 	}
       
   464 
       
   465 //Checks a set of vertical lines , which starting point is 
       
   466 //[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
       
   467 //and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
       
   468 //is incremented by 1.
       
   469 //The screen lines pixel values are tested against aClearColorValue value.
       
   470 //Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
       
   471 template <class TPixelType>
       
   472 void CTScaling<TPixelType>::CheckVertLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue)
       
   473 	{
       
   474 	TInt x = aOrg.iX + aLineProps.iX * iScalingFactorX;
       
   475 	TInt y = aOrg.iY + aLineProps.iY * iScalingFactorY;
       
   476 	for(TInt i=0;i<iScalingFactorX;++i)
       
   477 		{
       
   478 		for(TInt j=0;j<(aLineProps.iLength * iScalingFactorY);++j)
       
   479 			{
       
   480 			TRgb val = iDrawDevice->ReadPixel(x + i, y + j);				   
       
   481 			switch (iDisplayMode)
       
   482 				{
       
   483 				case EColor64K:
       
   484 				TEST(val.Color64K() != aClearColorValue);
       
   485 				break;
       
   486 				
       
   487 				case EColor256:
       
   488 				TEST(val.Color256() != aClearColorValue);
       
   489 				break;
       
   490 				
       
   491 				default:
       
   492 				TEST(EFalse);
       
   493 				}
       
   494 			}
       
   495 		}
       
   496 	TInt changedPixelsCnt = iScalingFactorX * aLineProps.iLength * iScalingFactorY;
       
   497 	CheckChangedPixels(changedPixelsCnt, aClearColorValue);
       
   498 	}
       
   499 
       
   500 //Checks the rectangle filled using CFbsScreenDevice::ShadowArea
       
   501 //The screen lines pixel values are tested against aClearColorValue value.
       
   502 //Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
       
   503 template <class TPixelType>
       
   504 void CTScaling<TPixelType>::CheckRect(const TRect& aRc, const TPoint& aOrg, TPixelType aClearColorValue)
       
   505 	{
       
   506 	TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
       
   507 	TInt i;
       
   508 	TInt x = aOrg.iX + aRc.iTl.iX * iScalingFactorX;
       
   509 	TInt y = aOrg.iY + aRc.iTl.iY * iScalingFactorY;
       
   510 	for(i=0;i<(iScalingFactorY * aRc.Height());++i)
       
   511 		{
       
   512 		Mem::Fill(data, sizeof(data), 0x00);
       
   513 		iDrawDevice->ReadLine(x, y + i, aRc.Width() * iScalingFactorX, data, iDisplayMode);
       
   514 		for(TInt j=0;j<(aRc.Width() * iScalingFactorX);++j)
       
   515 			{
       
   516 			TEST(data[j] != aClearColorValue);
       
   517 			}
       
   518 		}
       
   519 	TInt changedPixelsCnt = iScalingFactorY * aRc.Width() * aRc.Height() * iScalingFactorX;
       
   520 	CheckChangedPixels(changedPixelsCnt, aClearColorValue);
       
   521 	}
       
   522 
       
   523 //CFbsScreenDevice::WriteLine() and CFbsScreenDevice::ReadLine() test.
       
   524 //(Set of test lines) X (Set of origins) X (Set of drawing modes) number of test cases.
       
   525 template <class TPixelType>
       
   526 void CTScaling<TPixelType>::WriteLine()
       
   527 	{
       
   528 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteLine"));
       
   529 
       
   530 	TLineProps lineProps[] = 
       
   531 		{
       
   532 		{0, 0, KLegacyAppSizeWidth - 1}, 
       
   533 		{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
       
   534 		{10, 20, KLegacyAppSizeWidth / 2},
       
   535 		{-2, -5, 20},
       
   536 		{-3, 1, 21},
       
   537 		{2, -2, 11},
       
   538 		{0, -4, 31},
       
   539 		{-1, 11, 11}
       
   540 		};
       
   541 	const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
       
   542 	TPoint ptOrg[] = 
       
   543 		{
       
   544 		TPoint(13, 21),
       
   545 		TPoint(10, 17)
       
   546 		};
       
   547 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   548 	for(TInt ll=0;ll<KOriginsCnt;++ll)
       
   549 		{
       
   550 		for(TInt line=0;line<KLinesCnt;++line)
       
   551 			{
       
   552 			for(TInt kk=0;kk<KDrawModesCnt;++kk)
       
   553 				{
       
   554 				ClearScreen(KDrawMode[kk]);
       
   555 				SetTestData();
       
   556 				SetScalingSettings(ptOrg[ll], KScalingFactorX, KScalingFactorY, 1, 1);
       
   557 				iDrawDevice->WriteLine(lineProps[line].iX, lineProps[line].iY,
       
   558 									  lineProps[line].iLength, 
       
   559 									  reinterpret_cast <TUint32*> (iTestData), 
       
   560 									  KDrawMode[kk].iDrawMode);
       
   561 				if(KDrawMode[kk].iDrawMode == CGraphicsContext::EDrawModePEN)
       
   562 					{
       
   563 					TPixelType writtenData[KLegacyAppSizeWidth];
       
   564 					Mem::FillZ(writtenData, sizeof(writtenData));
       
   565 					iDrawDevice->ReadLine(lineProps[line].iX, lineProps[line].iY,
       
   566 										   lineProps[line].iLength, 
       
   567 										   writtenData, iDisplayMode);
       
   568 					for(TInt ii=0;ii<lineProps[line].iLength;++ii)
       
   569 						{
       
   570 						TEST(writtenData[ii] == iTestData[ii]);
       
   571 						}
       
   572 					}
       
   573 				SetScalingSettings(TPoint(), 1, 1, 1, 1);
       
   574 				CheckLine(lineProps[line], ptOrg[ll], KDrawMode[kk], KDrawMode[kk].iClearColorVal);
       
   575 				}
       
   576 			}
       
   577 		}
       
   578 	}
       
   579 
       
   580 //CFbsScreenDevice::WriteRgb() and CFbsScreenDevice::ReadPixel() test.
       
   581 //(Set of test points) X (Set of origins) X (Set of drawing modes) number of test cases.
       
   582 template <class TPixelType>
       
   583 void CTScaling<TPixelType>::WriteRgb()
       
   584 	{
       
   585 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgb"));
       
   586 
       
   587 	TPoint pt[] = 
       
   588 		{
       
   589 		TPoint(0, 0), 
       
   590 		TPoint(KLegacyAppSizeWidth - 1, 0), 
       
   591 		TPoint(0, KLegacyAppSizeHeight - 1), 
       
   592 		TPoint(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1),
       
   593 		TPoint(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2),
       
   594 		TPoint(-2, -3), 
       
   595 		TPoint(0, -1),
       
   596 		TPoint(-3, 0)
       
   597 		};
       
   598 	const TInt KPointsCnt = sizeof(pt) / sizeof(pt[0]);
       
   599 	TPoint ptOrg[] = 
       
   600 		{
       
   601 		TPoint(9, 22),
       
   602 		TPoint(17, 11)
       
   603 		};
       
   604 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   605 	for(TInt l=0;l<KOriginsCnt;++l)
       
   606 		{
       
   607 		for(TInt i=0;i<KPointsCnt;++i)
       
   608 			{
       
   609 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   610 				{
       
   611 				ClearScreen(KDrawMode[k]);
       
   612 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   613 				TRgb val(KTestColorVal);
       
   614 				iDrawDevice->WriteRgb(pt[i].iX, pt[i].iY, val, KDrawMode[k].iDrawMode);
       
   615 				if(KDrawMode[k].iDrawMode == CGraphicsContext::EDrawModePEN)
       
   616 					{
       
   617 					TRgb writtenVal = iDrawDevice->ReadPixel(pt[i].iX, pt[i].iY);
       
   618 					switch (iDisplayMode)
       
   619 						{
       
   620 						case EColor64K:
       
   621 						TEST(writtenVal == TRgb::Color64K(val.Color64K()));
       
   622 						break;
       
   623 						
       
   624 						case EColor256:
       
   625 						TEST(writtenVal == val);
       
   626 						break;
       
   627 						
       
   628 						default:
       
   629 						TEST(EFalse);
       
   630 						}
       
   631 					}
       
   632 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   633 				TLineProps props;
       
   634 				props.iX = pt[i].iX;
       
   635 				props.iY = pt[i].iY;
       
   636 				props.iLength = 1;
       
   637 				CheckLine(props, ptOrg[l], KDrawMode[k], KDrawMode[k].iClearColorVal);
       
   638 				}
       
   639 			}
       
   640 		}
       
   641 	}
       
   642 
       
   643 //CFbsScreenDevice::WriteRgbMulti() test.
       
   644 template <class TPixelType>
       
   645 void CTScaling<TPixelType>::WriteRgbMulti()
       
   646 	{
       
   647 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbMulti"));
       
   648 
       
   649 	TRect rcProps[] =
       
   650 		{
       
   651 		TRect(TPoint(0, 0), TSize(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1)), 
       
   652 		TRect(TPoint(17, 11), TSize(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2)),
       
   653 		TRect(TPoint(-1, -4), TSize(31, 12)), 
       
   654 		TRect(TPoint(-3, -1), TSize(11, 11)), 
       
   655 		TRect(TPoint(0, -2), TSize(6, 17))
       
   656 		};
       
   657 	const TInt KRcCnt = sizeof(rcProps) / sizeof(rcProps[0]);
       
   658 	TPoint ptOrg[] = 
       
   659 		{
       
   660 		TPoint(21, 29),
       
   661 		TPoint(12, 14)
       
   662 		};
       
   663 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   664 	for(TInt l=0;l<KOriginsCnt;++l)
       
   665 		{
       
   666 		for(TInt i=0;i<KRcCnt;++i)
       
   667 			{
       
   668 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   669 				{
       
   670 				ClearScreen(KDrawMode[k]);
       
   671 				SetTestData();
       
   672 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   673 				TRgb val(KTestColorVal);
       
   674 				iDrawDevice->WriteRgbMulti(rcProps[i].iTl.iX, rcProps[i].iTl.iY,
       
   675 									  rcProps[i].Width(), rcProps[i].Height(),
       
   676 									  val, 
       
   677 									  KDrawMode[k].iDrawMode);
       
   678 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   679 				CheckWriteRgbMulti(rcProps[i], ptOrg[l], KDrawMode[k], KDrawMode[k].iClearColorVal);
       
   680 				}
       
   681 			}
       
   682 		}
       
   683 	}
       
   684 
       
   685 //CFbsScreenDevice::WriteRgbAlphaLine() test.
       
   686 //(Set of test lines) X (Set of origins) X (Set of drawing modes) number of test cases.
       
   687 template <class TPixelType>
       
   688 void CTScaling<TPixelType>::WriteRgbAlphaLine()
       
   689 	{
       
   690 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaLine"));
       
   691 
       
   692 	TLineProps lineProps[] = 
       
   693 		{
       
   694 		{0, 0, KLegacyAppSizeWidth - 1}, 
       
   695 		{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
       
   696 		{17, 3, KLegacyAppSizeWidth / 2},
       
   697 		{-1, -2, 11},
       
   698 		{-4, -5, 1},
       
   699 		{0, -1, 3},
       
   700 		{1, -3, 7}
       
   701 		};
       
   702 	const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
       
   703 	TPoint ptOrg[] = 
       
   704 		{
       
   705 		TPoint(19, 17),
       
   706 		TPoint(29, 25)
       
   707 		};
       
   708 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   709 	for(TInt l=0;l<KOriginsCnt;++l)
       
   710 		{
       
   711 		for(TInt i=0;i<KLinesCnt;++i)
       
   712 			{
       
   713 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   714 				{
       
   715 				ClearScreen(KDrawMode[k]);
       
   716 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   717 				TUint8 rgbBuff[KLegacyAppSizeWidth * 3];
       
   718 				Mem::Fill(rgbBuff, sizeof(rgbBuff), KTestColorVal);
       
   719 				TUint8 maskBuff[KLegacyAppSizeWidth];
       
   720 				TUint8 maskChar = 0xF1;
       
   721 				Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
       
   722 				iDrawDevice->WriteRgbAlphaLine(lineProps[i].iX, lineProps[i].iY,
       
   723 									  lineProps[i].iLength, rgbBuff, maskBuff, CGraphicsContext::EDrawModePEN);
       
   724 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   725 				CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
       
   726 				}
       
   727 			}
       
   728 		}
       
   729 	}
       
   730 
       
   731 //CFbsScreenDevice::WriteBinary() test.
       
   732 template <class TPixelType>
       
   733 void CTScaling<TPixelType>::WriteBinary()
       
   734 	{
       
   735 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinary"));
       
   736 
       
   737 	TPoint pt[] =
       
   738 		{
       
   739 		TPoint(0, 0), 
       
   740 		TPoint(27, 19),
       
   741 		TPoint(-4, -4),
       
   742 		TPoint(-1, -2),
       
   743 		TPoint(-1, -2),
       
   744 		TPoint(5, -5),
       
   745 		TPoint(-5, 0)
       
   746 		};
       
   747 	const TInt KPtCnt = sizeof(pt) / sizeof(pt[0]);
       
   748 	TPoint ptOrg[] = 
       
   749 		{
       
   750 		TPoint(19, 24),
       
   751 		TPoint(29, 26)
       
   752 		};
       
   753 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   754 	for(TInt l=0;l<KOriginsCnt;++l)
       
   755 		{
       
   756 		for(TInt i=0;i<KPtCnt;++i)
       
   757 			{
       
   758 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   759 				{
       
   760 				ClearScreen(KDrawMode[k]);
       
   761 				SetTestData();
       
   762 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   763 				const TInt KHeight = 5;
       
   764 				const TInt KLength = 11;
       
   765 				TUint32 buff[KHeight];
       
   766 				TUint32 buffChar = 0xFFFFFFFF;
       
   767 				for(TInt ooo=0;ooo<KHeight;++ooo)
       
   768 					{
       
   769 					buff[ooo] = buffChar;
       
   770 					}
       
   771 				TRgb val(KTestColorVal);
       
   772 				iDrawDevice->WriteBinary(pt[i].iX, pt[i].iY, buff, KLength, KHeight,
       
   773 										  val, KDrawMode[k].iDrawMode);
       
   774 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   775 				CheckWriteBinary(pt[i], ptOrg[l], KDrawMode[k].iClearColorVal, KLength, KHeight);
       
   776 				}
       
   777 			}
       
   778 		}
       
   779 	}
       
   780 
       
   781 //CFbsScreenDevice::WriteBinaryLineVertical() test.
       
   782 template <class TPixelType>
       
   783 void CTScaling<TPixelType>::WriteBinaryLineVertical()
       
   784 	{
       
   785 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinaryLineVertical"));
       
   786 
       
   787 	TLineProps lineProps[] = 
       
   788 		{
       
   789 		{0, 0, KLegacyAppSizeHeight - 1}, 
       
   790 		{KLegacyAppSizeWidth - 1, 0, KLegacyAppSizeHeight - 1},
       
   791 		{17, 3, 23},
       
   792 		{-2, -5, 10},
       
   793 		{-6, 24, 11},
       
   794 		{18, -6, 12},
       
   795 		{0, -3, 13},
       
   796 		{-1, 0, 14}
       
   797 		};
       
   798 	const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
       
   799 	TPoint ptOrg[] = 
       
   800 		{
       
   801 		TPoint(22, 22),
       
   802 		TPoint(19, 20)
       
   803 		};
       
   804 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   805 	for(TInt l=0;l<KOriginsCnt;++l)
       
   806 		{
       
   807 		for(TInt i=0;i<KLinesCnt;++i)
       
   808 			{
       
   809 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   810 				{
       
   811 				ClearScreen(KDrawMode[k]);
       
   812 				SetTestData();
       
   813 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   814 				const TInt KLength = 30;
       
   815 				TUint32 buff[KLength];
       
   816 				TUint32 buffChar = 0xFFFFFFFF;
       
   817 				for(TInt ooo=0;ooo<KLength;++ooo)
       
   818 					{
       
   819 					buff[ooo] = buffChar;
       
   820 					}
       
   821 				TRgb val(KTestColorVal);
       
   822 				iDrawDevice->WriteBinaryLineVertical(lineProps[i].iX, lineProps[i].iY,
       
   823 													  buff, lineProps[i].iLength, val, 
       
   824 													  KDrawMode[k].iDrawMode, EFalse);
       
   825 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   826 				CheckVertLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
       
   827 				}
       
   828 			}
       
   829 		}
       
   830 	}
       
   831 
       
   832 //CFbsScreenDevice::WriteBinaryLine() test.
       
   833 template <class TPixelType>
       
   834 void CTScaling<TPixelType>::WriteBinaryLine()
       
   835 	{
       
   836 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinaryLiine"));
       
   837 
       
   838 	TPoint pt[] =
       
   839 		{
       
   840 		TPoint(0, 0), 
       
   841 		TPoint(1, 7),
       
   842 		TPoint(18, -8),
       
   843 		TPoint(-7, 26),
       
   844 		TPoint(-4, -7),
       
   845 		TPoint(0, -2),
       
   846 		TPoint(34, -1),
       
   847 		TPoint(-1, 17)
       
   848 		};
       
   849 	const TInt KPtCnt = sizeof(pt) / sizeof(pt[0]);
       
   850 	TPoint ptOrg[] = 
       
   851 		{
       
   852 		TPoint(21, 35),
       
   853 		TPoint(40, 28)
       
   854 		};
       
   855 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   856 	for(TInt l=0;l<KOriginsCnt;++l)
       
   857 		{
       
   858 		for(TInt i=0;i<KPtCnt;++i)
       
   859 			{
       
   860 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   861 				{
       
   862 				ClearScreen(KDrawMode[k]);
       
   863 				SetTestData();
       
   864 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   865 				const TInt KHeight = 1;
       
   866 				const TInt KLength = 11;
       
   867 				TUint32 buff[KHeight];
       
   868 				TUint32 buffChar = 0xFFFFFFFF;
       
   869 				for(TInt ooo=0;ooo<KHeight;++ooo)
       
   870 					{
       
   871 					buff[ooo] = buffChar;
       
   872 					}
       
   873 				TRgb val(KTestColorVal);
       
   874 				iDrawDevice->WriteBinaryLine(pt[i].iX, pt[i].iY, buff, KLength,
       
   875 											  val, KDrawMode[k].iDrawMode);
       
   876 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   877 				CheckWriteBinary(pt[i], ptOrg[l], KDrawMode[k].iClearColorVal, KLength, KHeight);
       
   878 				}
       
   879 			}
       
   880 		}
       
   881 	}
       
   882 
       
   883 //CFbsScreenDevice::WriteRgbAlphaMulti() test.
       
   884 template <class TPixelType>
       
   885 void CTScaling<TPixelType>::WriteRgbAlphaMulti()
       
   886 	{
       
   887 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaMulti"));
       
   888 
       
   889 	TLineProps lineProps[] = 
       
   890 		{
       
   891 		{0, 0, KLegacyAppSizeWidth - 1}, 
       
   892 		{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
       
   893 		{17, 3, KLegacyAppSizeWidth / 2},
       
   894 		{-8, -8, 11},
       
   895 		{-3, 15, 12},
       
   896 		{29, -4, 13},
       
   897 		{0, -3, 14},
       
   898 		{-5, 0, 15}
       
   899 		};
       
   900 	const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
       
   901 	TPoint ptOrg[] = 
       
   902 		{
       
   903 		TPoint(24, 17),
       
   904 		TPoint(27, 20)
       
   905 		};
       
   906 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   907 	for(TInt l=0;l<KOriginsCnt;++l)
       
   908 		{
       
   909 		for(TInt i=0;i<KLinesCnt;++i)
       
   910 			{
       
   911 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   912 				{
       
   913 				ClearScreen(KDrawMode[k]);
       
   914 				SetTestData();
       
   915 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   916 				TUint8 maskBuff[KLegacyAppSizeWidth];
       
   917 				TUint8 maskChar = 0xF1;
       
   918 				Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
       
   919 				TRgb val(KTestColorVal);
       
   920 				iDrawDevice->WriteRgbAlphaMulti(lineProps[i].iX, lineProps[i].iY,
       
   921 												 lineProps[i].iLength, val, maskBuff);
       
   922 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   923 				CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
       
   924 				}
       
   925 			}
       
   926 		}
       
   927 	}
       
   928 
       
   929 //CFbsScreenDevice::ShadowArea() test.
       
   930 template <class TPixelType>
       
   931 void CTScaling<TPixelType>::ShadowArea()
       
   932 	{
       
   933 	INFO_PRINTF1(_L("CFbsDrawDevice::ShadowArea"));
       
   934 
       
   935 	TRect rcProps[] =
       
   936 		{
       
   937 		TRect(TPoint(0, 0), TSize(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1)), 
       
   938 		TRect(TPoint(17, 11), TSize(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2)),
       
   939 		TRect(TPoint(-1, -1), TSize(1, 1)),
       
   940 		TRect(TPoint(-4, -5), TSize(11, 8)),
       
   941 		TRect(TPoint(0, -6), TSize(3, 23)),
       
   942 		TRect(TPoint(-7, 0), TSize(24, 2)),
       
   943 		TRect(TPoint(5, -2), TSize(8, 9)),
       
   944 		TRect(TPoint(-4, 16), TSize(11, 8))
       
   945 		};
       
   946 	const TInt KRcCnt = sizeof(rcProps) / sizeof(rcProps[0]);
       
   947 	TPoint ptOrg[] = 
       
   948 		{
       
   949 		TPoint(25, 24),
       
   950 		TPoint(31, 29)
       
   951 		};
       
   952 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
   953 	for(TInt l=0;l<KOriginsCnt;++l)
       
   954 		{
       
   955 		for(TInt i=0;i<KRcCnt;++i)
       
   956 			{
       
   957 			for(TInt k=0;k<KDrawModesCnt;++k)
       
   958 				{
       
   959 				TDrawModeProps drawModeProps(KDrawMode[k]);
       
   960 				--drawModeProps.iClearColorVal;//I want to avoid "255" clear color value.
       
   961 				for(TInt m=0;m<KShadowModesCnt;++m)
       
   962 					{
       
   963 					iDrawDevice->SetShadowMode(KShadowMode[m]);
       
   964 					ClearScreen(drawModeProps);
       
   965 					SetTestData();
       
   966 					SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
   967 					iDrawDevice->ShadowArea(rcProps[i]);
       
   968 					SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
   969 					CheckRect(rcProps[i], ptOrg[l], drawModeProps.iClearColorVal);
       
   970 					}
       
   971 				}
       
   972 			}
       
   973 		}
       
   974 	iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow);
       
   975 	}
       
   976 
       
   977 //CFbsScreenDevice::WriteRgbAlphaLine() test.
       
   978 template <class TPixelType>
       
   979 void CTScaling<TPixelType>::WriteRgbAlphaLine2()
       
   980 	{
       
   981 	INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaLine-2"));
       
   982 
       
   983 	TLineProps lineProps[] = 
       
   984 		{
       
   985 		{0, 0, KLegacyAppSizeWidth - 1}, 
       
   986 		{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
       
   987 		{17, 3, KLegacyAppSizeWidth / 2},
       
   988 		{-1, -7, 11},
       
   989 		{0, -5, 12},
       
   990 		{-3, 0, 13},
       
   991 		{15, -7, 14},
       
   992 		{-1, -7, 15},
       
   993 		{-1, -7, 16}
       
   994 		};
       
   995 	const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
       
   996 	TPoint ptOrg[] = 
       
   997 		{
       
   998 		TPoint(18, 28),
       
   999 		TPoint(15, 15)
       
  1000 		};
       
  1001 	const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
       
  1002 	for(TInt l=0;l<KOriginsCnt;++l)
       
  1003 		{
       
  1004 		for(TInt i=0;i<KLinesCnt;++i)
       
  1005 			{
       
  1006 			for(TInt k=0;k<KDrawModesCnt;++k)
       
  1007 				{
       
  1008 				ClearScreen(KDrawMode[k]);
       
  1009 				SetTestData();
       
  1010 				SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
       
  1011 				TUint8 rgbBuff1[KLegacyAppSizeWidth * 3];
       
  1012 				TUint8 rgbBuff2[KLegacyAppSizeWidth * 3];
       
  1013 				Mem::Fill(rgbBuff1, sizeof(rgbBuff1), KTestColorVal - 15);
       
  1014 				Mem::Fill(rgbBuff2, sizeof(rgbBuff2), KTestColorVal + 22);
       
  1015 				TUint8 maskBuff[KLegacyAppSizeWidth];
       
  1016 				TUint8 maskChar = 0xF1;
       
  1017 				Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
       
  1018 				iDrawDevice->WriteRgbAlphaLine(lineProps[i].iX, lineProps[i].iY,
       
  1019 									  lineProps[i].iLength, rgbBuff1, rgbBuff2, maskBuff,
       
  1020 									  KDrawMode[k].iDrawMode);
       
  1021 				SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
  1022 				CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
       
  1023 				}
       
  1024 			}
       
  1025 		}
       
  1026 	}
       
  1027 
       
  1028 template <class TPixelType>
       
  1029 void CTScaling<TPixelType>::TestScalingSettingsInterface()
       
  1030 	{
       
  1031 	INFO_PRINTF1(_L("MScalingSettings functionality test"));
       
  1032 	TEST(iDrawDevice != NULL);	
       
  1033 
       
  1034 	MScalingSettings* scalingSettings = NULL;
       
  1035 	TInt err = iDrawDevice->GetInterface(KScalingSettingsInterfaceID, 
       
  1036 										  reinterpret_cast <TAny*&> (scalingSettings));
       
  1037 	TEST2(err, KErrNone);
       
  1038 	TEST(scalingSettings != NULL);
       
  1039 
       
  1040 	TEST(scalingSettings->IsScalingOff());
       
  1041 
       
  1042 	const TInt factorXIn = 10, factorYIn = 13, divisorXIn = 1, divisorYIn = 1;
       
  1043 	TInt factorXOut = -1, factorYOut = -1, divisorXOut = -1, divisorYOut = -1;
       
  1044 
       
  1045 	err = scalingSettings->Set(factorXIn, factorYIn, divisorXIn, divisorYIn);
       
  1046 	TEST2(err, KErrNone);
       
  1047 	TEST(!scalingSettings->IsScalingOff());
       
  1048 	scalingSettings->Get(factorXOut, factorYOut, divisorXOut, divisorYOut);
       
  1049 
       
  1050 	TEST(factorXOut == factorXOut);
       
  1051 	TEST(factorYIn == factorYOut);
       
  1052 	TEST(divisorXIn == divisorXOut);
       
  1053 	TEST(divisorYIn == divisorYOut);
       
  1054 
       
  1055 	MDrawDeviceOrigin* originInterface = NULL;
       
  1056 	err = iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID, 
       
  1057 									 reinterpret_cast <TAny*&> (originInterface));
       
  1058 	TEST2(err, KErrNone);
       
  1059 	TEST(originInterface != NULL);
       
  1060 
       
  1061 	const TPoint ptOriginIn(20, 45);
       
  1062 	TPoint ptOriginOut;
       
  1063 	err = originInterface->Set(ptOriginIn);
       
  1064 	TEST2(err, KErrNone);
       
  1065 	originInterface->Get(ptOriginOut);
       
  1066 	TEST(ptOriginIn == ptOriginOut);
       
  1067 
       
  1068 	SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
  1069 	}
       
  1070 
       
  1071 //Creates screen device and initializes ::DrawDevice global variable.
       
  1072 template <class TPixelType>
       
  1073 void CTScaling<TPixelType>::CreateScreenDeviceL()
       
  1074 	{
       
  1075 	if (iDisplayMode == ENone)
       
  1076 		return;
       
  1077 	
       
  1078 	TInt address = NULL;
       
  1079 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress,address));
       
  1080 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels, iPhysSize.iWidth));
       
  1081 	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels, iPhysSize.iHeight));
       
  1082 	__ASSERT_DEBUG(iPhysSize.iWidth > 0 && iPhysSize.iHeight > 0 && address != NULL, User::Invariant());
       
  1083 
       
  1084 	TPckgBuf<TScreenInfoV01> info;
       
  1085 	info().iScreenAddressValid = ETrue;
       
  1086 	info().iScreenAddress = reinterpret_cast <void*> (address);
       
  1087 	info().iScreenSize = iPhysSize;
       
  1088 
       
  1089 	iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(info(), iDisplayMode);
       
  1090 	TestScalingSettingsInterface();
       
  1091 	iBits = new (ELeave) TPixelType[::ByteSize(EColor256, iPhysSize)];
       
  1092 	iDrawDevice->SetUserDisplayMode(iDisplayMode);
       
  1093 	iDrawDevice->SetAutoUpdate(EFalse);
       
  1094 	iDrawDevice->SetBits(iBits);
       
  1095 	
       
  1096 
       
  1097 	}
       
  1098 
       
  1099 template <class TPixelType>
       
  1100 void CTScaling<TPixelType>::PerformanceTest()
       
  1101 	{
       
  1102 	INFO_PRINTF1(_L("CFbsDrawDevice, scaling - WriteRgb() performance test"));
       
  1103 
       
  1104 	const TInt KDrawingsCnt = 1000000;
       
  1105 	TInt i, x, y;
       
  1106 
       
  1107 	TUint time1 = User::TickCount();
       
  1108 	x = y = 0;
       
  1109 	for(i=0;i<KDrawingsCnt;i++)
       
  1110 		{
       
  1111 		if(++x > 50)
       
  1112 			{
       
  1113 			x = 0;
       
  1114 			if(++y > 50)
       
  1115 				{
       
  1116 				y = 0;
       
  1117 				}
       
  1118 			}
       
  1119 		TRgb val(0x11, 0x12, i);
       
  1120 		iDrawDevice->WriteRgb(x, y, val, CGraphicsContext::EDrawModePEN);
       
  1121 		}
       
  1122 	time1 = User::TickCount() - time1;
       
  1123 
       
  1124 	TPoint ptOrigin(5, 3);
       
  1125 	SetScalingSettings(ptOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
       
  1126 
       
  1127 	TUint time2 = User::TickCount();
       
  1128 	x = y = 0;
       
  1129 	for(i=0;i<KDrawingsCnt;i++)
       
  1130 		{
       
  1131 		if(++x > 50)
       
  1132 			{
       
  1133 			x = 0;
       
  1134 			if(++y > 50)
       
  1135 				{
       
  1136 				y = 0;
       
  1137 				}
       
  1138 			}
       
  1139 		TRgb val(0x11, 0x12, i);
       
  1140 		iDrawDevice->WriteRgb(x, y, val, CGraphicsContext::EDrawModePEN);
       
  1141 		}
       
  1142 	time2 = User::TickCount() - time2;
       
  1143 
       
  1144 	SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
       
  1145 
       
  1146 	RDebug::Print(_L("Non-scaled device, time=%d\r\n"), time1);
       
  1147 	RDebug::Print(_L("Scaled device, time=%d\r\n"), time2);
       
  1148 	}
       
  1149 
       
  1150 template <class TPixelType>
       
  1151 void CTScaling<TPixelType>::RunTestCaseL(TInt aCurTestCase)
       
  1152 	{
       
  1153 	// EColor64K and EColor256 is not supported, stop the test
       
  1154 	if (iDisplayMode == ENone)
       
  1155 		{
       
  1156 		INFO_PRINTF1(_L("EColor64K and EColor256 are not supported, The test is not run"));
       
  1157 		TestComplete();
       
  1158 		}
       
  1159 	
       
  1160 	else
       
  1161 		{
       
  1162 	    ((CTScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  1163 		switch(aCurTestCase)
       
  1164 			{
       
  1165 		case 1:
       
  1166 			{
       
  1167 			if(iCurOrientation >= KOrientationsCnt)
       
  1168 				{
       
  1169 				((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1170 				TestComplete();
       
  1171 				}
       
  1172 			else
       
  1173 				{
       
  1174 				((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1175 				if (iCurOrientation==CFbsDrawDevice::EOrientationRotated90 || iCurOrientation==CFbsDrawDevice::EOrientationRotated270)
       
  1176 					{
       
  1177 					iScalingFactorX=KScalingFactorY;
       
  1178 					iScalingFactorY=KScalingFactorX;
       
  1179 					}
       
  1180 				else
       
  1181 					{
       
  1182 					iScalingFactorX=KScalingFactorX;
       
  1183 					iScalingFactorY=KScalingFactorY;
       
  1184 					}
       
  1185 				INFO_PRINTF3(_L("Set scalling %d,%d"),iScalingFactorX,iScalingFactorY);
       
  1186 				if(iDrawDevice->SetOrientation(KOrientation[iCurOrientation]))
       
  1187 					{
       
  1188 					INFO_PRINTF2(_L("Set orientation: ===EOrientation%S==="),&RotationName(iCurOrientation));
       
  1189 					}
       
  1190 				else
       
  1191 					{
       
  1192 					INFO_PRINTF2(_L("Failed to set orientation: ===EOrientation%S==="),&RotationName(iCurOrientation));
       
  1193 					ResetCounter();
       
  1194 					}
       
  1195 				iCurOrientation++;
       
  1196 				}	
       
  1197 			}	
       
  1198 			break;
       
  1199 		case 2:
       
  1200 /**
       
  1201 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0022
       
  1202 */
       
  1203             ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0022"));
       
  1204 			WriteLine();
       
  1205 			break;
       
  1206 		case 3:
       
  1207 /**
       
  1208 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0023
       
  1209 */
       
  1210 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0023"));
       
  1211 			WriteRgb();
       
  1212 			break;
       
  1213 		case 4:
       
  1214 /**
       
  1215 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0024
       
  1216 */
       
  1217 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0024"));
       
  1218 			WriteRgbMulti();
       
  1219 			break;
       
  1220 		case 5:
       
  1221 /**
       
  1222 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0025
       
  1223 */
       
  1224 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0025"));
       
  1225 			WriteRgbAlphaLine();
       
  1226 			break;
       
  1227 		case 6:
       
  1228 /**
       
  1229 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0026
       
  1230 */
       
  1231 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0026"));
       
  1232 			WriteBinary();
       
  1233 			break;
       
  1234 		case 7:
       
  1235 /**
       
  1236 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0027
       
  1237 */
       
  1238 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0027"));
       
  1239 			WriteBinaryLineVertical();
       
  1240 			break;
       
  1241 		case 8:
       
  1242 /**
       
  1243 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0028
       
  1244 */
       
  1245 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0028"));
       
  1246 			WriteBinaryLine();
       
  1247 			break;
       
  1248 		case 9:
       
  1249 /**
       
  1250 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0029
       
  1251 */
       
  1252 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0029"));
       
  1253 			WriteRgbAlphaMulti();
       
  1254 			break;
       
  1255 		case 10:
       
  1256 /**
       
  1257 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0030
       
  1258 */
       
  1259 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0030"));
       
  1260 			ShadowArea();
       
  1261 			break;
       
  1262 		case 11:
       
  1263 /**
       
  1264 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0031
       
  1265 */
       
  1266 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0031"));
       
  1267 			WriteRgbAlphaLine2();
       
  1268 			break;
       
  1269 		case 12:
       
  1270 /**
       
  1271 	@SYMTestCaseID GRAPHICS-SCREENDRIVER-0032
       
  1272 */
       
  1273 			((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0032"));
       
  1274 			PerformanceTest();
       
  1275 			break;
       
  1276 		case 13:
       
  1277 			((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1278 			ResetCounter();
       
  1279 			break;
       
  1280 			}
       
  1281            ((CTScalingStep*)iStep)->RecordTestResultL();
       
  1282 		}
       
  1283 	}
       
  1284 	
       
  1285 static TDisplayMode GetDisplayModeL()
       
  1286 	{
       
  1287 	TDisplayMode mode = EColor64K;
       
  1288 	CFbsDrawDevice* device = NULL;
       
  1289 	TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, mode));
       
  1290 	if (err!=KErrNone)
       
  1291 		{
       
  1292 		mode = EColor256;
       
  1293 		TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, mode));
       
  1294 		
       
  1295 		if (err == KErrNotSupported)
       
  1296 			{
       
  1297 			return ENone;
       
  1298 			}
       
  1299 		}
       
  1300 	delete device;
       
  1301 	return mode;
       
  1302 	}
       
  1303 
       
  1304 //---------------
       
  1305 CTScalingStep::CTScalingStep() 
       
  1306 	{ 
       
  1307 	SetTestStepName(KTScalingStep); 
       
  1308 	} 
       
  1309 	 
       
  1310 CTGraphicsBase* CTScalingStep::CreateTestL()
       
  1311 	{ 
       
  1312 	CTGraphicsBase* theTest = NULL;
       
  1313 	switch (GetDisplayModeL())
       
  1314 		{
       
  1315 		case EColor64K:
       
  1316 			{
       
  1317 			INFO_PRINTF1(_L("Scaling - EColor64K"));
       
  1318 			theTest = new (ELeave) CTestColor64K(this, EColor64K);
       
  1319 			}
       
  1320 			break;
       
  1321 	
       
  1322 		case EColor256:
       
  1323 			{
       
  1324 			INFO_PRINTF1(_L("Scaling - EColor256"));
       
  1325 			theTest = new (ELeave) CTestColor256(this, EColor256);
       
  1326 			}
       
  1327 			break;
       
  1328 
       
  1329 		default:
       
  1330 			INFO_PRINTF1(_L("EColor64K and EColor256 are not supported"));
       
  1331 			theTest = new (ELeave) CTestNone(this, ENone);			
       
  1332 		}
       
  1333 	return 	theTest;		
       
  1334 	} 
       
  1335 
       
  1336 void CTScalingStep::TestSetupL()
       
  1337 	{
       
  1338 	TInt temp = 0;
       
  1339 	HAL::Get(KDefaultScreenNo, HALData::EDisplayColors, temp);//force HAL memory allocation
       
  1340 	
       
  1341 	}