os/graphics/graphicsdeviceinterface/bitgdi/tbit/TCLIP.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1997-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 <bitdev.h>
    17 #include <hal.h>
    18 #include "TBMP.H"
    19 #include "TClip.h"
    20 #include <graphics/fbsdefs.h>
    21 
    22 //Note: Some display modes will be scaled - see 
    23 //CreateTestEnvironment(), SetScalingFactor() call
    24 
    25 //aTestAppNo is a new argument and it is not used yet.
    26 //It can have 0 or 1 value depending on which test app 
    27 //uses TestClip functionality - TClip or TClip2.
    28 CTClip::CTClip(CTestStep* aStep,
    29 					TInt aTestAppNo,
    30 					CFbsScreenDevice* aDev,
    31 					CFbsBitGc* aCon,
    32 					CFbsBitmap* aBmp,
    33 					CFbsFont* aFont,
    34 				   	CFbsFont* aLargeFont):
    35 	CTGraphicsBase(aStep),
    36 	iTestAppNo(aTestAppNo),
    37 	iDev(aDev),
    38 	iCon(aCon),
    39 	iClientRect(TRect(0,0,0,0)),
    40 	iGopNum(EFirstGop),
    41 	iClipList(NULL),
    42 	iBitmap(aBmp),
    43 	iBitmap64K(NULL),
    44 	iBitmap16MU(NULL),
    45 	iBitmap16MA(NULL), 
    46 	iBitmapMask(NULL),
    47 	iBitmapAlpha(NULL),
    48 	iFont(aFont),
    49 	iLargeFont(aLargeFont),
    50 	iBmpSize(TSize(0,0))
    51 	{}
    52 
    53 void CTClip::ConstructL()
    54 	{
    55 	iClipList=(TRect*)User::Alloc(sizeof(TRect)*ERegions);
    56 	if(!iClipList)
    57 		User::Panic(_L("Construct failure"),KErrGeneral);
    58 	iBmpSize=iBitmap->SizeInPixels();
    59 	iBitmap64K=new(ELeave) CFbsBitmap();
    60 	iBitmap16MU=new(ELeave) CFbsBitmap();
    61 	iBitmap16MA=new(ELeave) CFbsBitmap();
    62 	iBitmapMask=new(ELeave) CFbsBitmap();
    63 	iBitmapAlpha=new(ELeave) CFbsBitmap();
    64 	}
    65 
    66 TBool CTClip::SetUpTest(TInt &aTestModeIndex)
    67 	{
    68 	CFbsBitGc::TGraphicsOrientation orientation;
    69 	do
    70 		{
    71 		orientation=(CFbsBitGc::TGraphicsOrientation)(aTestModeIndex/2);
    72 		if (orientation>CFbsBitGc::EGraphicsOrientationRotated270)
    73 			return(EFalse);
    74 		aTestModeIndex++;
    75 		TPoint scalingOrigin(0,0);
    76 		TInt scale=1;
    77 		if ((aTestModeIndex&0x1)==CFbsBitGc::EGraphicsOrientationNormal)
    78 			{
    79 			scalingOrigin=TPoint(20, 10);
    80 			scale=2;
    81 			}
    82 		iDev->SetScalingFactor(scalingOrigin, scale, scale, 1, 1);
    83 		} while(!iCon->SetOrientation(orientation));
    84 	iDev->GetDrawRect(iClientRect);
    85 	TInt dims[2*ERegions]={0,0, 1,1, 1,2, 2,1, 2,2, 1,10, 10,1, 2,10, 10,2, 10,10};
    86 	for(TUint count=0;count<ERegions;count++)
    87 		{
    88 		iClipList[count].iTl.iX=iClientRect.iBr.iX*2/3;
    89 		iClipList[count].iTl.iY=iClientRect.iBr.iY/3;
    90 		iClipList[count].iBr.iX=iClipList[count].iTl.iX+dims[count*2];
    91 		iClipList[count].iBr.iY=iClipList[count].iTl.iY+dims[count*2+1];
    92 		}
    93 	iDev->SetAutoUpdate(ETrue);
    94 	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
    95 	iCon->SetPenColor(KRgbBlack);
    96 	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
    97 	iCon->SetBrushColor(TRgb(170,170,170));
    98 	Clear();
    99 	iCon->UseBrushPattern(iBitmap);
   100 
   101 	TSize halfScreen(iClientRect.Width()/2-2, iClientRect.Height()-2);
   102 	User::LeaveIfError(iBitmap64K->Load(_L("z:\\system\\data\\16ram.mbm"),0,EFalse));
   103 	User::LeaveIfError(iBitmap64K->Resize(halfScreen));
   104 	User::LeaveIfError(iBitmap16MU->Load(_L("z:\\system\\data\\32ram.mbm"),0,EFalse));
   105 	User::LeaveIfError(iBitmap16MU->Resize(halfScreen));
   106 
   107 	User::LeaveIfError(iBitmap16MA->Load(_L("z:\\system\\data\\32ram.mbm"),0,EFalse));
   108 	User::LeaveIfError(iBitmap16MA->Resize(halfScreen));
   109 	User::LeaveIfError(iBitmapMask->Create(halfScreen, EGray2));
   110 	User::LeaveIfError(iBitmapAlpha->Create(halfScreen, EGray256));
   111 	return(ETrue);
   112 	}
   113 
   114 inline CTClipStep* CTClip::Step()
   115 	{
   116 	return static_cast<CTClipStep*>(iStep);
   117 	}
   118 
   119 void CTClip::Clear()
   120 	{
   121 	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   122 	iCon->SetBrushColor(KRgbWhite);
   123 	iCon->DrawRect(iClientRect);
   124 	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   125 	iCon->SetBrushColor(TRgb(170,170,170));
   126 	}
   127 
   128 CTClip::~CTClip()
   129 	{
   130 	for(TInt i=0;i<ERegions;i++)
   131 		{
   132 		iClipList[i].~TRect();
   133 		}
   134 	User::Free(iClipList);
   135 	delete iBitmap64K;
   136 	delete iBitmap16MU;
   137 	delete iBitmapMask;
   138 	delete iBitmapAlpha;
   139 	delete iBitmap16MA;
   140 	}
   141 
   142 void CTClip::RunTestCaseL(const TInt aCurTestCase)
   143 	{
   144 	((CTClipStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   145 	switch(aCurTestCase)
   146 		{
   147 	case 1:
   148 		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0042"));
   149 		TestComplexRgn();
   150 		INFO_PRINTF1(_L("Complex Rgn Test complete"));
   151 		break;
   152 	case 2:
   153 		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0038"));
   154 		TestRectRgn();
   155 		INFO_PRINTF1(_L("Rect Rgn Test complete"));
   156 		break;
   157 	case 3:
   158 #if !defined(__X86GCC__)		//Tests take too long to run and don't test anything useful anyway
   159 		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0039"));
   160 		TestSimpleRgn();
   161 		INFO_PRINTF1(_L("Simple Rgn Test complete"));
   162 		break;
   163 	case 4:
   164 		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0041"));
   165 		TestHoriRgn();
   166 		INFO_PRINTF1(_L("Horizontal Rgn Test complete"));
   167 		break;
   168 	case 5:
   169 		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0040"));
   170 		TestVertRgn();
   171 		INFO_PRINTF1(_L("Vertical Rgn Test complete"));
   172 		break;
   173 	case 6:
   174 #endif	//__X86GCC__
   175 		((CTClipStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   176 		((CTClipStep*)iStep)->CloseTMSGraphicsStep();
   177 		INFO_PRINTF1(_L("Test complete\n"));
   178 		TestComplete();
   179 		break;
   180 		}
   181 	((CTClipStep*)iStep)->RecordTestResultL();
   182 	}
   183 
   184 /**
   185   @SYMTestCaseID GRAPHICS-BITGDI-0038
   186  
   187   @SYMDEF             
   188 
   189   @SYMTestCaseDesc Tests clipping to a rect region
   190    
   191   @SYMTestPriority High
   192 
   193   @SYMTestStatus Implemented
   194 
   195   @SYMTestActions Iterates through a number of regions and graphic operations testing clipping with each
   196  
   197   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   198 */
   199 void CTClip::TestRectRgn()
   200 	{
   201 	TInt testMode=0;
   202 	while(SetUpTest(testMode))
   203 		{
   204 		for(TUint j=0;j<ERegions;j++)
   205 			{
   206 			TRect reg=iClipList[j];
   207 			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   208 				{
   209 				RRegion rectreg(reg);
   210 				DrawToScreen(rectreg,iClientRect);
   211 				rectreg.Close();
   212 				ScanArea(iClientRect.iBr.iX/2,iClientRect.iTl.iY,iClientRect.iBr.iX/2,reg.iTl.iY-iClientRect.iTl.iY); // above
   213 				ScanArea(iClientRect.iBr.iX/2,reg.iTl.iY,reg.iTl.iX-iClientRect.iBr.iX/2,reg.Height()); // left
   214 				ScanArea(reg.iBr.iX,reg.iTl.iY,iClientRect.iBr.iX-reg.iBr.iX,reg.Height()); // right
   215 				ScanArea(iClientRect.iBr.iX/2,reg.iBr.iY,iClientRect.iBr.iX/2,iClientRect.iBr.iY-reg.iBr.iY); // below
   216 				CheckInside(reg,iClientRect);
   217 				}
   218 			}
   219 		}
   220 	}
   221 
   222 /**
   223   @SYMTestCaseID GRAPHICS-BITGDI-0039
   224  
   225   @SYMDEF             
   226 
   227   @SYMTestCaseDesc Tests clipping to a simple region
   228    
   229   @SYMTestPriority High
   230 
   231   @SYMTestStatus Implemented
   232 
   233   @SYMTestActions Iterates through a number of simple regions and graphic operations testing clipping with each
   234  
   235   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   236 */
   237 void CTClip::TestSimpleRgn()
   238 	{
   239 	TInt testMode=0;
   240 	while(SetUpTest(testMode))
   241 		{
   242 		for(TUint j=0;j<ERegions;j++)
   243 			{
   244 			TRect reg=iClipList[j];
   245 			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   246 				{
   247 				DrawToScreen(reg,iClientRect);
   248 				ScanArea(iClientRect.iBr.iX/2,iClientRect.iTl.iY,iClientRect.iBr.iX/2,reg.iTl.iY); // above
   249 				ScanArea(iClientRect.iBr.iX/2,reg.iTl.iY,reg.iTl.iX-iClientRect.iBr.iX/2,reg.Height()); // left
   250 				ScanArea(reg.iBr.iX,reg.iTl.iY,iClientRect.iBr.iX-reg.iBr.iX,reg.Height()); // right
   251 				ScanArea(iClientRect.iBr.iX/2,reg.iBr.iY,iClientRect.iBr.iX/2,iClientRect.iBr.iY-reg.iBr.iY); // below
   252 				CheckInside(reg,iClientRect);
   253 				}
   254 			}
   255 		}
   256 	}
   257 
   258 /**
   259   @SYMTestCaseID GRAPHICS-BITGDI-0040
   260  
   261   @SYMDEF             
   262 
   263   @SYMTestCaseDesc Tests clipping to a vertical region
   264    
   265   @SYMTestPriority High
   266 
   267   @SYMTestStatus Implemented
   268 
   269   @SYMTestActions Iterates through a number of regions of different widths and graphic operations testing clipping with each
   270  
   271   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   272 */
   273 void CTClip::TestVertRgn()
   274 	{
   275 	TInt widths[3]={1,2,5};
   276 	TInt testMode=0;
   277 	while(SetUpTest(testMode))
   278 		{
   279 		for(TInt count=0;count<3;count++) // check vertical strips
   280 			{
   281 			TInt i=widths[count];
   282 			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   283 				{
   284 				for(TInt j=0;j<iClientRect.iBr.iX/2-i;j+=35)
   285 					{
   286 					TRect reg=TRect(iClientRect.iBr.iX/2+j,iClientRect.iTl.iY,iClientRect.iBr.iX/2+j+i,iClientRect.iBr.iY);
   287 					RRegion rectreg(reg);
   288 					DrawToScreen(rectreg,iClientRect);
   289 					rectreg.Close();
   290 		 			ScanArea(iClientRect.iBr.iX/2,reg.iTl.iY,reg.iTl.iX-iClientRect.iBr.iX/2,reg.Height()); // left
   291 					ScanArea(reg.iBr.iX,reg.iTl.iY,iClientRect.iBr.iX-reg.iBr.iX,reg.Height()); // right
   292 					CheckInside(reg,iClientRect);
   293 					}
   294 				}
   295 			}
   296 		}
   297 	}
   298 
   299 /**
   300   @SYMTestCaseID GRAPHICS-BITGDI-0041
   301  
   302   @SYMDEF             
   303 
   304   @SYMTestCaseDesc Tests clipping to a horizontal region
   305    
   306   @SYMTestPriority High
   307 
   308   @SYMTestStatus Implemented
   309 
   310   @SYMTestActions Iterates through a number of regions of different widths and graphic operations testing clipping with each
   311  
   312   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   313 */
   314 void CTClip::TestHoriRgn()
   315 	{
   316 	TInt widths[3]={1,2,5};
   317 	TInt testMode=0;
   318 	while(SetUpTest(testMode))
   319 		{
   320 		for(TInt count=0;count<3;count++) // check horizontal strips
   321 			{
   322 			TInt i=widths[count];
   323 			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   324 				{
   325 				for(TInt j=0;j<iClientRect.iBr.iY;j+=35)
   326 					{
   327 					TRect reg=TRect(iClientRect.iBr.iX/2,j,iClientRect.iBr.iX,j+i);
   328 					RRegion rectreg(reg);
   329 					DrawToScreen(rectreg,iClientRect);
   330 					rectreg.Close();
   331 					ScanArea(iClientRect.iBr.iX/2,iClientRect.iTl.iY,iClientRect.iBr.iX/2,reg.iTl.iY); // above
   332 					ScanArea(iClientRect.iBr.iX/2,reg.iBr.iY,iClientRect.iBr.iX/2,iClientRect.iBr.iY-reg.iBr.iY); // below
   333 					CheckInside(reg,iClientRect);
   334 					}
   335 				}
   336 			}
   337 		}
   338 	}
   339 
   340 /**
   341   @SYMTestCaseID GRAPHICS-BITGDI-0042
   342  
   343   @SYMDEF             
   344 
   345   @SYMTestCaseDesc Tests clipping to a complex region
   346    
   347   @SYMTestPriority High
   348 
   349   @SYMTestStatus Implemented
   350 
   351   @SYMTestActions Creates a complex region then iterates through graphic operations testing clipping with each
   352  
   353   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   354 */
   355 void CTClip::TestComplexRgn()
   356 	{
   357 	TInt testMode=0;
   358 	while(SetUpTest(testMode))
   359 		{
   360 		TRect rect[8];
   361 		rect[0].SetRect(iClientRect.iBr.iX*12/20,0,iClientRect.iBr.iX*15/20,iClientRect.iBr.iY/4);
   362 		rect[1].SetRect(iClientRect.iBr.iX*11/20,iClientRect.iBr.iY/8,iClientRect.iBr.iX*13/20,iClientRect.iBr.iY/2);
   363 		rect[2].SetRect(iClientRect.iBr.iX*14/20,iClientRect.iBr.iY/8,iClientRect.iBr.iX*17/20,iClientRect.iBr.iY/2);
   364 		rect[3].SetRect(iClientRect.iBr.iX*12/20,iClientRect.iBr.iY*3/8,iClientRect.iBr.iX*18/20,iClientRect.iBr.iY*5/8);
   365 		rect[4].SetRect(iClientRect.iBr.iX*13/20,iClientRect.iBr.iY*9/16,iClientRect.iBr.iX*19/20,iClientRect.iBr.iY*7/8);
   366 		rect[5].SetRect(iClientRect.iBr.iX*17/20,iClientRect.iBr.iY*3/4,iClientRect.iBr.iX,iClientRect.iBr.iY);
   367 		rect[6].SetRect(iClientRect.iBr.iX*11/20,iClientRect.iBr.iY*5/8,iClientRect.iBr.iX*11/20+1,iClientRect.iBr.iY*5/8+1);
   368 		rect[7].SetRect(iClientRect.iBr.iX*18/20,iClientRect.iBr.iY/8,iClientRect.iBr.iX*18/20,iClientRect.iBr.iY/8);
   369 		TRect space[12];
   370 		space[0].SetRect(iClientRect.iBr.iX/2,0,rect[1].iTl.iX,rect[1].iBr.iY);
   371 		space[1].SetRect(space[0].iBr.iX,0,rect[0].iTl.iX,rect[1].iTl.iY);
   372 		space[2].SetRect(rect[0].iBr.iX,0,rect[2].iBr.iX,rect[2].iTl.iY);
   373 		space[3].SetRect(rect[2].iBr.iX,0,iClientRect.iBr.iX,rect[3].iTl.iY);
   374 		space[4].SetRect(rect[1].iBr.iX,rect[0].iBr.iY,rect[2].iTl.iX,rect[3].iTl.iY);
   375 		space[5].SetRect(iClientRect.iBr.iX/2,rect[1].iBr.iY,rect[3].iTl.iX,rect[6].iTl.iY);
   376 		space[6].SetRect(iClientRect.iBr.iX/2,rect[6].iTl.iY,rect[6].iTl.iX,rect[6].iBr.iY);
   377 		space[7].SetRect(iClientRect.iBr.iX/2,rect[6].iBr.iY,rect[6].iBr.iX,iClientRect.iBr.iY);
   378 		space[8].SetRect(rect[6].iBr.iX,rect[6].iTl.iY,rect[4].iTl.iX,iClientRect.iBr.iY);
   379 		space[9].SetRect(rect[4].iTl.iX,rect[4].iBr.iY,rect[5].iTl.iX,iClientRect.iBr.iY);
   380 		space[10].SetRect(rect[4].iBr.iX,rect[4].iTl.iY,iClientRect.iBr.iX,rect[5].iTl.iY);
   381 		space[11].SetRect(rect[3].iBr.iX,rect[3].iTl.iY,iClientRect.iBr.iX,rect[4].iTl.iY);
   382 		RRegion creg(rect[0],8);
   383 		creg.AddRect(rect[1]);
   384 		creg.AddRect(rect[2]);
   385 		creg.AddRect(rect[3]);
   386 		creg.AddRect(rect[4]);
   387 		creg.AddRect(rect[5]);
   388 		creg.AddRect(rect[6]);
   389 		creg.AddRect(rect[7]);
   390 		for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   391 			{
   392 			DrawToScreen(creg,iClientRect);
   393 			TInt count=0;
   394 			for(;count<8;count++)
   395 				CheckInside(rect[count],iClientRect);
   396 			for(count=0;count<12;count++)
   397 				ScanArea(space[count].iTl.iX,space[count].iTl.iY,space[count].iBr.iX-space[count].iTl.iX,space[count].iBr.iY-space[count].iTl.iY);
   398 			}
   399 		creg.Close();
   400 		}
   401 	}
   402 
   403 void CTClip::ScanArea(TInt x,TInt y,TInt length,TInt height)
   404 	{
   405 	if (length<1 || height<1)
   406 		{
   407 		return;
   408 		}
   409 
   410 	HBufC8* buf = HBufC8::NewL(length * 4);
   411 	TPtr8 des = buf->Des();
   412 	
   413 	for (TInt row=0; row<height; row++)
   414 		{
   415 		TPoint point(x, y+row);
   416 		
   417 		des.Zero();
   418 		iDev->GetScanLine(des,point,length,EColor16MA);
   419 		
   420 		for(TInt i=0; i<des.Length(); i++)
   421 			{
   422 			if(des[i] != 0xFF)
   423 				{
   424 				INFO_PRINTF1(_L("Clipping failure outside!\n"));
   425 				INFO_PRINTF2(_L("Graphics operation: %d\n"),iGopNum);
   426 				INFO_PRINTF5(_L("x=%d, y=%d, length=%d, height=%d\n"),x,y,length,height);
   427 				INFO_PRINTF3(_L("Index=%d, Found=%x, Expected=0xFF\n"),i,des[i]);
   428 				TEST(0);
   429 				delete buf;
   430 				return;
   431 				}
   432 			}
   433 		}
   434 				
   435 	delete buf;
   436 	}
   437 
   438 void CTClip::CheckInside(const TRect& aClip,const TRect& aRect)
   439 	{
   440 	const TInt length=aClip.Width();
   441 	const TInt unOffsetX=-(aRect.iBr.iX/2);
   442 #if defined(__X86GCC__) || defined(__MARM__)
   443 	const TInt KMaxLinesToPrint=2;
   444 #else
   445 	const TInt KMaxLinesToPrint=10;
   446 #endif
   447 
   448 	HBufC8* unBuf = HBufC8::NewL(length * 4);
   449 	HBufC8* clBuf = HBufC8::NewL(length * 4);
   450 	
   451 	TPtr8 unDes = unBuf->Des();
   452 	TPtr8 clDes = clBuf->Des();
   453 
   454 	TInt linesDiffs=0;
   455 	for (TUint yy=aClip.iTl.iY; yy<aClip.iBr.iY; yy++)
   456 		{
   457 		TPoint unPoint(aClip.iTl.iX+unOffsetX, yy);
   458 		TPoint clPoint(aClip.iTl.iX,           yy);
   459 		
   460 		unDes.Zero();
   461 		clDes.Zero();
   462 		iDev->GetScanLine(unDes,unPoint,length,EColor16MA);
   463 		iDev->GetScanLine(clDes,clPoint,length,EColor16MA);
   464 		
   465 		TInt different = unDes.Compare(clDes);
   466 		if (different)
   467 			{
   468 			if (linesDiffs++<KMaxLinesToPrint)
   469 				{
   470 				_LIT(KDots,"..");
   471 				_LIT(KStart,"|.");
   472 				_LIT(KEnd,".|");
   473 				const TInt KMaxNumBytesToLog=14;
   474 				TBuf<8*KMaxNumBytesToLog> buf1,buf2;
   475 				TInt end=Min(length,KMaxNumBytesToLog);
   476 				end*=4;
   477 				TInt ii;
   478 				TInt matches=ETrue;
   479 				for (ii=0; ii<end; ++ii)
   480 					{
   481 					_LIT(KHex,"%02x");
   482 					buf1.AppendFormat(KHex,unDes[ii]);
   483 					if (unDes[ii]!=clDes[ii])
   484 						{
   485 						buf2.AppendFormat(KHex,clDes[ii]);
   486 						matches=EFalse;
   487 						}
   488 					else
   489 						{		//Show each pixel as |......| on the 2nd line if it matches
   490 						TPtrC ptr(KDots);
   491 						switch (ii%4)
   492 							{
   493 						case 0:
   494 							ptr.Set(KStart);
   495 							break;
   496 						case 3:
   497 							ptr.Set(KEnd);
   498 							break;
   499 							}
   500 						buf2.Append(ptr);
   501 						}
   502 					}
   503 				TBuf<256> buf;
   504 				if (!matches)
   505 					{
   506 					_LIT(KLog,"ClipRect (%d,%d,%d,%d)  Row=%d  (First %d of %d pixels shown, only differing values shown on comparison line)");
   507 					buf.Format(KLog,aClip.iTl.iX,aClip.iTl.iY,aClip.iBr.iX,aClip.iBr.iY,yy,end,aClip.Width());
   508 					INFO_PRINTF1(buf);
   509 					INFO_PRINTF1(buf1);
   510 					INFO_PRINTF1(buf2);
   511 					}
   512 				else
   513 					{
   514 					_LIT(KLog,"ClipRect (%d,%d,%d,%d)  Row=%d  (First %d of %d pixels all match)");
   515 					buf.Format(KLog,aClip.iTl.iX,aClip.iTl.iY,aClip.iBr.iX,aClip.iBr.iY,yy,end,aClip.Width());
   516 					INFO_PRINTF1(buf);
   517 					}
   518 				}
   519 			}
   520 		}
   521 	if (linesDiffs>0)
   522 		{
   523 		_LIT(KLog,"Clipping failure inside!  Graphics operation: %d  Lines With Diffs: %d/%d");
   524 		INFO_PRINTF4(KLog,iGopNum,linesDiffs,aClip.iBr.iY-aClip.iTl.iY);
   525 		}
   526 	if (!Step()->IgnoreDiffs())
   527 		TEST(linesDiffs==0);
   528 
   529 	delete unBuf;
   530 	delete clBuf;
   531 	}
   532 
   533 void CTClip::DrawToScreen(TRegion& clip_reg,TRect r)
   534 	{
   535 	Clear();
   536 	TRect halfWid(r);
   537 	halfWid.iBr.iX=halfWid.iBr.iX/2;
   538 	iCon->SetClippingRect(halfWid);
   539 	DoDraw(r,EFalse);
   540 	iCon->CancelClippingRect();
   541 	iCon->SetClippingRegion(&clip_reg);
   542 	iCon->SetOrigin(TPoint(r.iBr.iX/2,0));
   543 	DoDraw(r,ETrue);
   544 	iCon->CancelClippingRegion();
   545 	iCon->SetOrigin(TPoint(0,0));
   546 	}
   547 
   548 void CTClip::DrawToScreen(const TRect& cliprect,TRect r)
   549 	{
   550 	Clear();
   551 	TRect halfWid(r);
   552 	halfWid.iBr.iX=halfWid.iBr.iX/2;
   553 	iCon->SetClippingRect(halfWid);
   554 	DoDraw(r,EFalse);
   555 	iCon->SetClippingRect(cliprect);
   556 	iCon->SetOrigin(TPoint(r.iBr.iX/2,0));
   557 	DoDraw(r,ETrue);
   558 	iCon->CancelClippingRect();
   559 	iCon->SetOrigin(TPoint(0,0));
   560 	}
   561 
   562 void CTClip::DoDraw(TRect r,TBool clipped)
   563 	{
   564 	TRect sh;
   565 	TPoint p,z;
   566 	switch(iGopNum)
   567 		{
   568 	case EPlot:
   569 		iCon->Plot(TPoint(r.iBr.iX/6-10,r.iBr.iY/3-10));
   570 		iCon->Plot(TPoint(r.iBr.iX/6,r.iBr.iY/3));
   571 	break;
   572 	case EDrawLine:
   573 		p.SetXY(r.iBr.iX/2-1,r.iBr.iY+1);
   574 		iCon->DrawLine(z,p);
   575 	break;
   576 	case EDottedLine:
   577 		p.SetXY(r.iBr.iX/2-1,r.iBr.iY+1);
   578 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   579 		iCon->DrawLine(z,p);
   580 	break;
   581 	case EDashedLine:
   582 		p.SetXY(r.iBr.iX/2-1,r.iBr.iY+1);
   583 		iCon->SetPenStyle(CGraphicsContext::EDashedPen);
   584 		iCon->DrawLine(z,p);
   585 	break;
   586 	case EWideLine:
   587 		p.SetXY(r.iBr.iX/2-11,r.iBr.iY-9);
   588 		iCon->SetPenSize(TSize(5,5));
   589 		iCon->DrawLine(z,p);
   590 	break;
   591 	case EDrawArc:
   592 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   593 		p.SetXY(r.iBr.iX/2-1,0);
   594 		iCon->DrawArc(sh,z,p);
   595 	break;
   596 	case EDottedArc:
   597 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   598 		p.SetXY(r.iBr.iX/2-1,0);
   599 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   600 		iCon->DrawArc(sh,z,p);
   601 	break;
   602 	case EDrawRect:
   603 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   604 		iCon->DrawRect(sh);
   605 	break;
   606 	case EVerticalHatchRect:
   607 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   608 		iCon->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
   609 		iCon->DrawRect(sh);
   610 	break;
   611 	case EForwardDiagonalHatchRect:
   612 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   613 		iCon->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
   614 		iCon->DrawRect(sh);
   615 	break;
   616 	case EHorizontalHatchRect:
   617 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   618 		iCon->SetBrushStyle(CGraphicsContext::EHorizontalHatchBrush);
   619 		iCon->DrawRect(sh);
   620 	break;
   621 	case ERearwardDiagonalHatchRect:
   622 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   623 		iCon->SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
   624 		iCon->DrawRect(sh);
   625 	break;
   626 	case ESquareCrossHatchRect:
   627 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   628 		iCon->SetBrushStyle(CGraphicsContext::ESquareCrossHatchBrush);
   629 		iCon->DrawRect(sh);
   630 	break;
   631 	case EDiamondCrossHatchRect:
   632 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   633 		iCon->SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush);
   634 		iCon->DrawRect(sh);
   635 	break;
   636 	case EVerticalHatchEllipse:
   637 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   638 		iCon->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
   639 		iCon->DrawEllipse(sh);
   640 	break;
   641 	case EForwardDiagonalHatchEllipse:
   642 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   643 		iCon->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
   644 		iCon->DrawEllipse(sh);
   645 	break;
   646 	case EHorizontalHatchEllipse:
   647 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   648 		iCon->SetBrushStyle(CGraphicsContext::EHorizontalHatchBrush);
   649 		iCon->DrawEllipse(sh);
   650 	break;
   651 	case ERearwardDiagonalHatchEllipse:
   652 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   653 		iCon->SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
   654 		iCon->DrawEllipse(sh);
   655 	break;
   656 	case ESquareCrossHatchEllipse:
   657 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   658 		iCon->SetBrushStyle(CGraphicsContext::ESquareCrossHatchBrush);
   659 		iCon->DrawEllipse(sh);
   660 	break;
   661 	case EDiamondCrossHatchEllipse:
   662 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   663 		iCon->SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush);
   664 		iCon->DrawEllipse(sh);
   665 	break;
   666 	case EDottedRect:
   667 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   668 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   669 		iCon->DrawRect(sh);
   670 	break;
   671 	case ECopyRect:
   672 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   673 		if(clipped)
   674 			{
   675 			iCon->SetOrigin(z);
   676 			iCon->CopyRect(TPoint(r.iBr.iX/2,0),sh);
   677 			}
   678 		else
   679 			iCon->DrawRect(sh);
   680 	break;
   681 	case EDrawEllipse:
   682 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   683 		iCon->DrawEllipse(sh);
   684 	break;
   685 	case EDottedEllipse:
   686 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   687 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   688 		iCon->DrawEllipse(sh);
   689 	break;
   690 	case EDrawRoundRect:
   691 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   692 		p.SetXY(r.iBr.iX>>2,r.iBr.iY>>4);
   693 		iCon->DrawRoundRect(sh,p.AsSize());
   694 	break;
   695 	case EDottedRoundRect:
   696 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   697 		p.SetXY(r.iBr.iX>>2,r.iBr.iY>>4);
   698 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   699 		iCon->DrawRoundRect(sh,p.AsSize());
   700 	break;
   701 	case EDrawPie:
   702 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   703 		p.SetXY(r.iBr.iX/2-1,0);
   704 		iCon->DrawPie(sh,z,p);
   705 	break;
   706 	case EDottedPie:
   707 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   708 		p.SetXY(r.iBr.iX/2-1,0);
   709 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   710 		iCon->DrawPie(sh,z,p);
   711 	break;
   712 	case EDrawPolygon:
   713 		{
   714 		CArrayFixFlat<TPoint>* t=new CArrayFixFlat<TPoint>(3);
   715 		TPoint temp(r.iBr.iX/6,r.iBr.iY/4);
   716 		TRAPD(errCode, t->AppendL(temp));
   717 		if(errCode != KErrNone)
   718 			{
   719 			return;
   720 			}
   721 		temp.SetXY(r.iBr.iX/12,r.iBr.iY/2);
   722 		TRAP(errCode, t->AppendL(temp));
   723 		if(errCode != KErrNone)
   724 			{
   725 			return;
   726 			}
   727 		temp.SetXY(r.iBr.iX/4,r.iBr.iY/2);
   728 		TRAP(errCode, t->AppendL(temp));
   729 		if(errCode != KErrNone)
   730 			{
   731 			return;
   732 			}
   733 		iCon->DrawPolygon(t);
   734 		delete t;
   735 		}
   736 	break;
   737 	case EDrawText:
   738 		{
   739 		iCon->UseFont(iFont);
   740 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   741 		iCon->DrawText(testtext,p);
   742 		}
   743 	break;
   744 	case EBoxText:
   745 		{
   746 		iCon->UseFont(iFont);
   747 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   748 		TInt ascent=iFont->AscentInPixels();
   749 		TInt height=iFont->HeightInPixels();
   750 		TInt width=iFont->TextWidthInPixels(testtext);
   751 		TRect box(p.iX,p.iY,p.iX+width,p.iY+height);
   752 		iCon->DrawText(testtext,box,ascent);
   753 		}
   754 	break;
   755 	case EDrawTextVertical:
   756 		iCon->UseFont(iFont);
   757 		p.SetXY(r.iBr.iX/6-13,r.iBr.iY/3+5);
   758 		p.iX+=5;
   759 		p.iY-=10;
   760 		iCon->DrawTextVertical(testtext,p,EFalse);
   761 	break;
   762 	case ELargeText:
   763 		iCon->UseFont(iLargeFont);
   764 		p.SetXY(r.iBr.iX/6-13,r.iBr.iY/3+5);
   765 		iCon->DrawText(largetesttext,p);
   766 	break;
   767 	case ELargeBoxText:
   768 		{
   769 		iCon->UseFont(iLargeFont);
   770 		p.SetXY(r.iTl.iX, r.iTl.iY);
   771 		TInt ascent=iLargeFont->AscentInPixels();
   772 		TInt height=iLargeFont->HeightInPixels();
   773 		TInt width=iLargeFont->TextWidthInPixels(largetesttext);
   774 		TRect box(p.iX, p.iY, p.iX+width, p.iY+height);
   775 		iCon->DrawText(largetesttext,box,ascent);
   776 		}
   777 	break;
   778 	case ELargeTextVertical:
   779 		iCon->UseFont(iLargeFont);
   780 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   781 		iCon->DrawTextVertical(largetesttext,p,EFalse);
   782 	break;
   783 	case EPaintRect:
   784 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   785 		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   786 		iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   787 		iCon->DrawRect(sh);
   788 	break;
   789 	case EBitBltContext:
   790 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   791 		if(clipped)
   792 			{
   793 			iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   794 			iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   795 			iCon->BitBlt(z,*iCon,sh);
   796 			}
   797 		else
   798 			{
   799 			iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   800 			iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   801 			iCon->DrawRect(sh);
   802 			}
   803 	break;
   804 	case EBitmapLarge:
   805 		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   806 		iCon->DrawBitmap(sh,iBitmap);
   807 	break;
   808 	case EBitmapSmall:
   809 		p.SetXY(r.iBr.iX/6-40,r.iBr.iY/3-20);
   810 		sh.SetRect(p,TSize(iBitmap->SizeInPixels().iWidth/2,iBitmap->SizeInPixels().iHeight/2));
   811 		iCon->DrawBitmap(sh,iBitmap);
   812 	break;
   813 	case EBitBltBitmap:
   814 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);		
   815 		iCon->BitBlt(p,iBitmap64K);
   816 	break;
   817 	case EDrawBitmap:
   818 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   819 		sh.SetRect(p,iBitmap64K->SizeInPixels());
   820 		iCon->DrawBitmap(sh,iBitmap);
   821 	break;
   822 	case EBitBltMasked:
   823 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   824 		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   825 		iCon->BitBltMasked(p,iBitmap,sh,iBitmap,ETrue);
   826 	break;
   827 	case EBitBltMaskedBinary:
   828 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   829 		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   830 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   831 		iCon->BitBltMasked(p,iBitmap,sh,iBitmapMask,EFalse);
   832 	break;
   833 	case EBitBltMaskedBinary64K:
   834 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   835 		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   836 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   837 		iCon->BitBltMasked(p,iBitmap64K,sh,iBitmapMask,EFalse);
   838 	break;
   839 	case EBitBltMaskedBinary16MU:
   840 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   841 		sh.SetRect(TPoint(0,0),iBitmap16MU->SizeInPixels());
   842 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   843 		iCon->BitBltMasked(p,iBitmap16MU,sh,iBitmapMask,EFalse);
   844 	break;
   845 	case EBitBltMaskedBinary16MA:
   846 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   847 		sh.SetRect(TPoint(0,0),iBitmap16MA->SizeInPixels());
   848 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   849 		iCon->BitBltMasked(p,iBitmap16MA,sh,iBitmapMask,EFalse);
   850 	break;	
   851 	case EBitBltMaskedAlpha:
   852 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   853 		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   854 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   855 		iCon->BitBltMasked(p,iBitmap,sh,iBitmapAlpha,EFalse);
   856 	break;
   857 	case EBitBltMaskedAlpha64K:
   858 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   859 		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   860 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   861 		iCon->BitBltMasked(p,iBitmap64K,sh,iBitmapAlpha,EFalse);
   862 	break;
   863 	case EBitBltMaskedAlpha16MU:
   864 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   865 		sh.SetRect(TPoint(0,0),iBitmap16MU->SizeInPixels());
   866 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   867 		iCon->BitBltMasked(p,iBitmap16MU,sh,iBitmapAlpha,EFalse);
   868 	break;
   869 	case EBitBltMaskedAlpha16MA:
   870 		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   871 		sh.SetRect(TPoint(0,0),iBitmap16MA->SizeInPixels());
   872 		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   873 		iCon->BitBltMasked(p,iBitmap16MA,sh,iBitmapAlpha,EFalse);
   874 	break;
   875 		}
   876 	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   877 	iCon->SetPenSize(TSize(1,1));
   878 	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   879 	}
   880 
   881 //--------------
   882 CTClipStep::CTClipStep() :iIgnoreDiffs(EFalse)
   883 	{
   884 	SetTestStepName(KTClipStep);
   885 	}
   886 	
   887 CTClipStep::~CTClipStep()
   888 	{
   889 	DestroyTestEnvironment();
   890 	}
   891 
   892 inline TBool CTClipStep::IgnoreDiffs()
   893 	{
   894 	return iIgnoreDiffs;
   895 	}
   896 
   897 CTGraphicsBase* CTClipStep::CreateTestL()
   898 	{
   899 	_LIT(KLog,"Create CTClip");
   900 	INFO_PRINTF1(KLog);
   901 	return new (ELeave) CTClip(this, iTestAppNo, iDev, iGc, iBmp, iFont, iLargeFont);
   902 	}
   903 
   904 void CTClipStep::TestSetupL()
   905 	{
   906 	FbsStartup();
   907 	RFbsSession::Connect();
   908 	
   909 	CreateTestEnvironment();
   910 	}
   911 	
   912 void CTClipStep::TestClose()
   913 	{
   914 	DestroyTestEnvironment();
   915 	RFbsSession::Disconnect();
   916 	}
   917 
   918 TInt CTClipStep::CreateScreenDevice(TDisplayMode aMode)
   919 	{
   920 	TRAPD(err,iDev=CFbsScreenDevice::NewL(KNullDesC,aMode));
   921 	const TPtrC modeName=CTGraphicsBase::ColorModeName(aMode);
   922 	if (err==KErrNone)
   923 		{
   924 		_LIT(KLog,"Sucessfully created Screen Device, mode %S");
   925 		INFO_PRINTF2(KLog,&modeName);
   926 		}
   927 	else
   928 		{
   929 		if (err==KErrNotSupported)
   930 			{
   931 			_LIT(KLog,"Screen Device with mode %S not available on this device");
   932 			INFO_PRINTF2(KLog,&modeName);
   933 			}
   934 		else
   935 			{
   936 			_LIT(KLog,"Failed to created Screen Device with mode %S  err=%d");
   937 			INFO_PRINTF3(KLog,&modeName,err);
   938 			}
   939 		}
   940 	return err;
   941 	}
   942 
   943 void CTClipStep::CreateTestEnvironment()
   944 	{
   945 	iDev=NULL;
   946 	//This test will fail if any display mode other than EColor64K, EColor256, EGray256
   947 	//is selected
   948 	TInt ret=CreateScreenDevice(EColor64K);
   949 	if (ret!=KErrNone)
   950 		ret=CreateScreenDevice(EColor256);
   951 	if (ret!=KErrNone)
   952 		ret=CreateScreenDevice(EGray256);
   953 	if (ret!=KErrNone)
   954 		ret=CreateScreenDevice(EColor16MU);
   955 	if (ret!=KErrNone)
   956 		ret=CreateScreenDevice(EColor16M);
   957 	if (ret!=KErrNone)
   958 		ret=CreateScreenDevice(EColor4K);
   959 	if (ret!=KErrNone)
   960 		{
   961 		ret=CreateScreenDevice(EColor16MA);
   962 		if (ret==KErrNone)
   963 			{
   964 			iIgnoreDiffs=ETrue;
   965 			_LIT(KLog,"Ignore Diffs set to %d (ETrue?)");
   966 			INFO_PRINTF2(KLog,iIgnoreDiffs);
   967 			}
   968 		}
   969 	if (ret!=KErrNone)
   970 		{
   971 		ret=CreateScreenDevice(EColor16MAP);
   972 		if (ret==KErrNone)
   973 			{
   974 			iIgnoreDiffs=ETrue;
   975 			_LIT(KLog,"Ignore Diffs set to %d (ETrue?)");
   976 			INFO_PRINTF2(KLog,iIgnoreDiffs);
   977 			}
   978 		}
   979 	if(ret!=KErrNone)
   980 		User::Panic(_L("Device not created"),ret);
   981 	iDev->ChangeScreenDevice(NULL);
   982 	iGc=NULL;
   983 	ret=iDev->CreateContext(iGc);
   984 	if(iGc==NULL)
   985 		User::Panic(_L("Context not created"),KErrGeneral);
   986 	iGc->Activate(iDev);
   987 	iFont=NULL;
   988 	TFontSpec fs(_L("Swiss"),12);
   989 	ret=iDev->GetNearestFontToDesignHeightInPixels(iFont,fs);
   990 	if(ret!=KErrNone)
   991 		User::Panic(_L("Font not created"),KErrGeneral);
   992 	iLargeFont=NULL;
   993 	fs.iHeight=100;
   994 	ret=iDev->GetNearestFontToDesignHeightInPixels(iLargeFont,fs);
   995 	if(ret!=KErrNone)
   996 		User::Panic(_L("Font not created"),KErrGeneral);
   997 	
   998 	iBmp=new CFbsBitmap;
   999 	if(iBmp==NULL)
  1000 		User::Panic(_L("Bitmap not created"),KErrGeneral);
  1001 	if(iTestAppNo == 0)
  1002 		{
  1003 		// Uncompressed
  1004 		TInt ret=iBmp->Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTbmp,EFalse);
  1005 		if(ret!=KErrNone)
  1006 			User::Panic(_L("Bitmap not loaded"),ret);
  1007 		}
  1008 	else
  1009 		{
  1010 		TInt ret=iBmp->LoadAndCompress(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTbmp,EFalse);
  1011 		if(ret!=KErrNone)
  1012 			User::Panic(_L("Bitmap not loaded"),ret);
  1013 		}
  1014 	
  1015 	}
  1016 
  1017 void CTClipStep::DestroyTestEnvironment()
  1018 	{
  1019 	delete iGc;
  1020 	iGc = NULL;
  1021 	
  1022 	delete iBmp;
  1023 	iBmp = NULL;
  1024 
  1025 	if(iFont)
  1026 		{
  1027 		iDev->ReleaseFont(iFont);
  1028 		iFont = NULL;
  1029 		}
  1030 	if(iLargeFont)
  1031 		{
  1032 		iDev->ReleaseFont(iLargeFont);
  1033 		iLargeFont = NULL;	
  1034 		}
  1035 	
  1036 	delete iDev;
  1037 	iDev = NULL;
  1038 	}
  1039 
  1040 //--------------
  1041 CTClip2Step::CTClip2Step() :
  1042 	CTClipStep()
  1043 	{
  1044 	iTestAppNo = 1;
  1045 	SetTestStepName(KTClip2Step);
  1046 	}