os/graphics/graphicsdeviceinterface/bitgdi/tbit/TCLIP.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/TCLIP.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1046 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <bitdev.h>
    1.20 +#include <hal.h>
    1.21 +#include "TBMP.H"
    1.22 +#include "TClip.h"
    1.23 +#include <graphics/fbsdefs.h>
    1.24 +
    1.25 +//Note: Some display modes will be scaled - see 
    1.26 +//CreateTestEnvironment(), SetScalingFactor() call
    1.27 +
    1.28 +//aTestAppNo is a new argument and it is not used yet.
    1.29 +//It can have 0 or 1 value depending on which test app 
    1.30 +//uses TestClip functionality - TClip or TClip2.
    1.31 +CTClip::CTClip(CTestStep* aStep,
    1.32 +					TInt aTestAppNo,
    1.33 +					CFbsScreenDevice* aDev,
    1.34 +					CFbsBitGc* aCon,
    1.35 +					CFbsBitmap* aBmp,
    1.36 +					CFbsFont* aFont,
    1.37 +				   	CFbsFont* aLargeFont):
    1.38 +	CTGraphicsBase(aStep),
    1.39 +	iTestAppNo(aTestAppNo),
    1.40 +	iDev(aDev),
    1.41 +	iCon(aCon),
    1.42 +	iClientRect(TRect(0,0,0,0)),
    1.43 +	iGopNum(EFirstGop),
    1.44 +	iClipList(NULL),
    1.45 +	iBitmap(aBmp),
    1.46 +	iBitmap64K(NULL),
    1.47 +	iBitmap16MU(NULL),
    1.48 +	iBitmap16MA(NULL), 
    1.49 +	iBitmapMask(NULL),
    1.50 +	iBitmapAlpha(NULL),
    1.51 +	iFont(aFont),
    1.52 +	iLargeFont(aLargeFont),
    1.53 +	iBmpSize(TSize(0,0))
    1.54 +	{}
    1.55 +
    1.56 +void CTClip::ConstructL()
    1.57 +	{
    1.58 +	iClipList=(TRect*)User::Alloc(sizeof(TRect)*ERegions);
    1.59 +	if(!iClipList)
    1.60 +		User::Panic(_L("Construct failure"),KErrGeneral);
    1.61 +	iBmpSize=iBitmap->SizeInPixels();
    1.62 +	iBitmap64K=new(ELeave) CFbsBitmap();
    1.63 +	iBitmap16MU=new(ELeave) CFbsBitmap();
    1.64 +	iBitmap16MA=new(ELeave) CFbsBitmap();
    1.65 +	iBitmapMask=new(ELeave) CFbsBitmap();
    1.66 +	iBitmapAlpha=new(ELeave) CFbsBitmap();
    1.67 +	}
    1.68 +
    1.69 +TBool CTClip::SetUpTest(TInt &aTestModeIndex)
    1.70 +	{
    1.71 +	CFbsBitGc::TGraphicsOrientation orientation;
    1.72 +	do
    1.73 +		{
    1.74 +		orientation=(CFbsBitGc::TGraphicsOrientation)(aTestModeIndex/2);
    1.75 +		if (orientation>CFbsBitGc::EGraphicsOrientationRotated270)
    1.76 +			return(EFalse);
    1.77 +		aTestModeIndex++;
    1.78 +		TPoint scalingOrigin(0,0);
    1.79 +		TInt scale=1;
    1.80 +		if ((aTestModeIndex&0x1)==CFbsBitGc::EGraphicsOrientationNormal)
    1.81 +			{
    1.82 +			scalingOrigin=TPoint(20, 10);
    1.83 +			scale=2;
    1.84 +			}
    1.85 +		iDev->SetScalingFactor(scalingOrigin, scale, scale, 1, 1);
    1.86 +		} while(!iCon->SetOrientation(orientation));
    1.87 +	iDev->GetDrawRect(iClientRect);
    1.88 +	TInt dims[2*ERegions]={0,0, 1,1, 1,2, 2,1, 2,2, 1,10, 10,1, 2,10, 10,2, 10,10};
    1.89 +	for(TUint count=0;count<ERegions;count++)
    1.90 +		{
    1.91 +		iClipList[count].iTl.iX=iClientRect.iBr.iX*2/3;
    1.92 +		iClipList[count].iTl.iY=iClientRect.iBr.iY/3;
    1.93 +		iClipList[count].iBr.iX=iClipList[count].iTl.iX+dims[count*2];
    1.94 +		iClipList[count].iBr.iY=iClipList[count].iTl.iY+dims[count*2+1];
    1.95 +		}
    1.96 +	iDev->SetAutoUpdate(ETrue);
    1.97 +	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
    1.98 +	iCon->SetPenColor(KRgbBlack);
    1.99 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.100 +	iCon->SetBrushColor(TRgb(170,170,170));
   1.101 +	Clear();
   1.102 +	iCon->UseBrushPattern(iBitmap);
   1.103 +
   1.104 +	TSize halfScreen(iClientRect.Width()/2-2, iClientRect.Height()-2);
   1.105 +	User::LeaveIfError(iBitmap64K->Load(_L("z:\\system\\data\\16ram.mbm"),0,EFalse));
   1.106 +	User::LeaveIfError(iBitmap64K->Resize(halfScreen));
   1.107 +	User::LeaveIfError(iBitmap16MU->Load(_L("z:\\system\\data\\32ram.mbm"),0,EFalse));
   1.108 +	User::LeaveIfError(iBitmap16MU->Resize(halfScreen));
   1.109 +
   1.110 +	User::LeaveIfError(iBitmap16MA->Load(_L("z:\\system\\data\\32ram.mbm"),0,EFalse));
   1.111 +	User::LeaveIfError(iBitmap16MA->Resize(halfScreen));
   1.112 +	User::LeaveIfError(iBitmapMask->Create(halfScreen, EGray2));
   1.113 +	User::LeaveIfError(iBitmapAlpha->Create(halfScreen, EGray256));
   1.114 +	return(ETrue);
   1.115 +	}
   1.116 +
   1.117 +inline CTClipStep* CTClip::Step()
   1.118 +	{
   1.119 +	return static_cast<CTClipStep*>(iStep);
   1.120 +	}
   1.121 +
   1.122 +void CTClip::Clear()
   1.123 +	{
   1.124 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.125 +	iCon->SetBrushColor(KRgbWhite);
   1.126 +	iCon->DrawRect(iClientRect);
   1.127 +	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   1.128 +	iCon->SetBrushColor(TRgb(170,170,170));
   1.129 +	}
   1.130 +
   1.131 +CTClip::~CTClip()
   1.132 +	{
   1.133 +	for(TInt i=0;i<ERegions;i++)
   1.134 +		{
   1.135 +		iClipList[i].~TRect();
   1.136 +		}
   1.137 +	User::Free(iClipList);
   1.138 +	delete iBitmap64K;
   1.139 +	delete iBitmap16MU;
   1.140 +	delete iBitmapMask;
   1.141 +	delete iBitmapAlpha;
   1.142 +	delete iBitmap16MA;
   1.143 +	}
   1.144 +
   1.145 +void CTClip::RunTestCaseL(const TInt aCurTestCase)
   1.146 +	{
   1.147 +	((CTClipStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.148 +	switch(aCurTestCase)
   1.149 +		{
   1.150 +	case 1:
   1.151 +		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0042"));
   1.152 +		TestComplexRgn();
   1.153 +		INFO_PRINTF1(_L("Complex Rgn Test complete"));
   1.154 +		break;
   1.155 +	case 2:
   1.156 +		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0038"));
   1.157 +		TestRectRgn();
   1.158 +		INFO_PRINTF1(_L("Rect Rgn Test complete"));
   1.159 +		break;
   1.160 +	case 3:
   1.161 +#if !defined(__X86GCC__)		//Tests take too long to run and don't test anything useful anyway
   1.162 +		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0039"));
   1.163 +		TestSimpleRgn();
   1.164 +		INFO_PRINTF1(_L("Simple Rgn Test complete"));
   1.165 +		break;
   1.166 +	case 4:
   1.167 +		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0041"));
   1.168 +		TestHoriRgn();
   1.169 +		INFO_PRINTF1(_L("Horizontal Rgn Test complete"));
   1.170 +		break;
   1.171 +	case 5:
   1.172 +		((CTClipStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0040"));
   1.173 +		TestVertRgn();
   1.174 +		INFO_PRINTF1(_L("Vertical Rgn Test complete"));
   1.175 +		break;
   1.176 +	case 6:
   1.177 +#endif	//__X86GCC__
   1.178 +		((CTClipStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.179 +		((CTClipStep*)iStep)->CloseTMSGraphicsStep();
   1.180 +		INFO_PRINTF1(_L("Test complete\n"));
   1.181 +		TestComplete();
   1.182 +		break;
   1.183 +		}
   1.184 +	((CTClipStep*)iStep)->RecordTestResultL();
   1.185 +	}
   1.186 +
   1.187 +/**
   1.188 +  @SYMTestCaseID GRAPHICS-BITGDI-0038
   1.189 + 
   1.190 +  @SYMDEF             
   1.191 +
   1.192 +  @SYMTestCaseDesc Tests clipping to a rect region
   1.193 +   
   1.194 +  @SYMTestPriority High
   1.195 +
   1.196 +  @SYMTestStatus Implemented
   1.197 +
   1.198 +  @SYMTestActions Iterates through a number of regions and graphic operations testing clipping with each
   1.199 + 
   1.200 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.201 +*/
   1.202 +void CTClip::TestRectRgn()
   1.203 +	{
   1.204 +	TInt testMode=0;
   1.205 +	while(SetUpTest(testMode))
   1.206 +		{
   1.207 +		for(TUint j=0;j<ERegions;j++)
   1.208 +			{
   1.209 +			TRect reg=iClipList[j];
   1.210 +			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   1.211 +				{
   1.212 +				RRegion rectreg(reg);
   1.213 +				DrawToScreen(rectreg,iClientRect);
   1.214 +				rectreg.Close();
   1.215 +				ScanArea(iClientRect.iBr.iX/2,iClientRect.iTl.iY,iClientRect.iBr.iX/2,reg.iTl.iY-iClientRect.iTl.iY); // above
   1.216 +				ScanArea(iClientRect.iBr.iX/2,reg.iTl.iY,reg.iTl.iX-iClientRect.iBr.iX/2,reg.Height()); // left
   1.217 +				ScanArea(reg.iBr.iX,reg.iTl.iY,iClientRect.iBr.iX-reg.iBr.iX,reg.Height()); // right
   1.218 +				ScanArea(iClientRect.iBr.iX/2,reg.iBr.iY,iClientRect.iBr.iX/2,iClientRect.iBr.iY-reg.iBr.iY); // below
   1.219 +				CheckInside(reg,iClientRect);
   1.220 +				}
   1.221 +			}
   1.222 +		}
   1.223 +	}
   1.224 +
   1.225 +/**
   1.226 +  @SYMTestCaseID GRAPHICS-BITGDI-0039
   1.227 + 
   1.228 +  @SYMDEF             
   1.229 +
   1.230 +  @SYMTestCaseDesc Tests clipping to a simple region
   1.231 +   
   1.232 +  @SYMTestPriority High
   1.233 +
   1.234 +  @SYMTestStatus Implemented
   1.235 +
   1.236 +  @SYMTestActions Iterates through a number of simple regions and graphic operations testing clipping with each
   1.237 + 
   1.238 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.239 +*/
   1.240 +void CTClip::TestSimpleRgn()
   1.241 +	{
   1.242 +	TInt testMode=0;
   1.243 +	while(SetUpTest(testMode))
   1.244 +		{
   1.245 +		for(TUint j=0;j<ERegions;j++)
   1.246 +			{
   1.247 +			TRect reg=iClipList[j];
   1.248 +			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   1.249 +				{
   1.250 +				DrawToScreen(reg,iClientRect);
   1.251 +				ScanArea(iClientRect.iBr.iX/2,iClientRect.iTl.iY,iClientRect.iBr.iX/2,reg.iTl.iY); // above
   1.252 +				ScanArea(iClientRect.iBr.iX/2,reg.iTl.iY,reg.iTl.iX-iClientRect.iBr.iX/2,reg.Height()); // left
   1.253 +				ScanArea(reg.iBr.iX,reg.iTl.iY,iClientRect.iBr.iX-reg.iBr.iX,reg.Height()); // right
   1.254 +				ScanArea(iClientRect.iBr.iX/2,reg.iBr.iY,iClientRect.iBr.iX/2,iClientRect.iBr.iY-reg.iBr.iY); // below
   1.255 +				CheckInside(reg,iClientRect);
   1.256 +				}
   1.257 +			}
   1.258 +		}
   1.259 +	}
   1.260 +
   1.261 +/**
   1.262 +  @SYMTestCaseID GRAPHICS-BITGDI-0040
   1.263 + 
   1.264 +  @SYMDEF             
   1.265 +
   1.266 +  @SYMTestCaseDesc Tests clipping to a vertical region
   1.267 +   
   1.268 +  @SYMTestPriority High
   1.269 +
   1.270 +  @SYMTestStatus Implemented
   1.271 +
   1.272 +  @SYMTestActions Iterates through a number of regions of different widths and graphic operations testing clipping with each
   1.273 + 
   1.274 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.275 +*/
   1.276 +void CTClip::TestVertRgn()
   1.277 +	{
   1.278 +	TInt widths[3]={1,2,5};
   1.279 +	TInt testMode=0;
   1.280 +	while(SetUpTest(testMode))
   1.281 +		{
   1.282 +		for(TInt count=0;count<3;count++) // check vertical strips
   1.283 +			{
   1.284 +			TInt i=widths[count];
   1.285 +			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   1.286 +				{
   1.287 +				for(TInt j=0;j<iClientRect.iBr.iX/2-i;j+=35)
   1.288 +					{
   1.289 +					TRect reg=TRect(iClientRect.iBr.iX/2+j,iClientRect.iTl.iY,iClientRect.iBr.iX/2+j+i,iClientRect.iBr.iY);
   1.290 +					RRegion rectreg(reg);
   1.291 +					DrawToScreen(rectreg,iClientRect);
   1.292 +					rectreg.Close();
   1.293 +		 			ScanArea(iClientRect.iBr.iX/2,reg.iTl.iY,reg.iTl.iX-iClientRect.iBr.iX/2,reg.Height()); // left
   1.294 +					ScanArea(reg.iBr.iX,reg.iTl.iY,iClientRect.iBr.iX-reg.iBr.iX,reg.Height()); // right
   1.295 +					CheckInside(reg,iClientRect);
   1.296 +					}
   1.297 +				}
   1.298 +			}
   1.299 +		}
   1.300 +	}
   1.301 +
   1.302 +/**
   1.303 +  @SYMTestCaseID GRAPHICS-BITGDI-0041
   1.304 + 
   1.305 +  @SYMDEF             
   1.306 +
   1.307 +  @SYMTestCaseDesc Tests clipping to a horizontal region
   1.308 +   
   1.309 +  @SYMTestPriority High
   1.310 +
   1.311 +  @SYMTestStatus Implemented
   1.312 +
   1.313 +  @SYMTestActions Iterates through a number of regions of different widths and graphic operations testing clipping with each
   1.314 + 
   1.315 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.316 +*/
   1.317 +void CTClip::TestHoriRgn()
   1.318 +	{
   1.319 +	TInt widths[3]={1,2,5};
   1.320 +	TInt testMode=0;
   1.321 +	while(SetUpTest(testMode))
   1.322 +		{
   1.323 +		for(TInt count=0;count<3;count++) // check horizontal strips
   1.324 +			{
   1.325 +			TInt i=widths[count];
   1.326 +			for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   1.327 +				{
   1.328 +				for(TInt j=0;j<iClientRect.iBr.iY;j+=35)
   1.329 +					{
   1.330 +					TRect reg=TRect(iClientRect.iBr.iX/2,j,iClientRect.iBr.iX,j+i);
   1.331 +					RRegion rectreg(reg);
   1.332 +					DrawToScreen(rectreg,iClientRect);
   1.333 +					rectreg.Close();
   1.334 +					ScanArea(iClientRect.iBr.iX/2,iClientRect.iTl.iY,iClientRect.iBr.iX/2,reg.iTl.iY); // above
   1.335 +					ScanArea(iClientRect.iBr.iX/2,reg.iBr.iY,iClientRect.iBr.iX/2,iClientRect.iBr.iY-reg.iBr.iY); // below
   1.336 +					CheckInside(reg,iClientRect);
   1.337 +					}
   1.338 +				}
   1.339 +			}
   1.340 +		}
   1.341 +	}
   1.342 +
   1.343 +/**
   1.344 +  @SYMTestCaseID GRAPHICS-BITGDI-0042
   1.345 + 
   1.346 +  @SYMDEF             
   1.347 +
   1.348 +  @SYMTestCaseDesc Tests clipping to a complex region
   1.349 +   
   1.350 +  @SYMTestPriority High
   1.351 +
   1.352 +  @SYMTestStatus Implemented
   1.353 +
   1.354 +  @SYMTestActions Creates a complex region then iterates through graphic operations testing clipping with each
   1.355 + 
   1.356 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.357 +*/
   1.358 +void CTClip::TestComplexRgn()
   1.359 +	{
   1.360 +	TInt testMode=0;
   1.361 +	while(SetUpTest(testMode))
   1.362 +		{
   1.363 +		TRect rect[8];
   1.364 +		rect[0].SetRect(iClientRect.iBr.iX*12/20,0,iClientRect.iBr.iX*15/20,iClientRect.iBr.iY/4);
   1.365 +		rect[1].SetRect(iClientRect.iBr.iX*11/20,iClientRect.iBr.iY/8,iClientRect.iBr.iX*13/20,iClientRect.iBr.iY/2);
   1.366 +		rect[2].SetRect(iClientRect.iBr.iX*14/20,iClientRect.iBr.iY/8,iClientRect.iBr.iX*17/20,iClientRect.iBr.iY/2);
   1.367 +		rect[3].SetRect(iClientRect.iBr.iX*12/20,iClientRect.iBr.iY*3/8,iClientRect.iBr.iX*18/20,iClientRect.iBr.iY*5/8);
   1.368 +		rect[4].SetRect(iClientRect.iBr.iX*13/20,iClientRect.iBr.iY*9/16,iClientRect.iBr.iX*19/20,iClientRect.iBr.iY*7/8);
   1.369 +		rect[5].SetRect(iClientRect.iBr.iX*17/20,iClientRect.iBr.iY*3/4,iClientRect.iBr.iX,iClientRect.iBr.iY);
   1.370 +		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);
   1.371 +		rect[7].SetRect(iClientRect.iBr.iX*18/20,iClientRect.iBr.iY/8,iClientRect.iBr.iX*18/20,iClientRect.iBr.iY/8);
   1.372 +		TRect space[12];
   1.373 +		space[0].SetRect(iClientRect.iBr.iX/2,0,rect[1].iTl.iX,rect[1].iBr.iY);
   1.374 +		space[1].SetRect(space[0].iBr.iX,0,rect[0].iTl.iX,rect[1].iTl.iY);
   1.375 +		space[2].SetRect(rect[0].iBr.iX,0,rect[2].iBr.iX,rect[2].iTl.iY);
   1.376 +		space[3].SetRect(rect[2].iBr.iX,0,iClientRect.iBr.iX,rect[3].iTl.iY);
   1.377 +		space[4].SetRect(rect[1].iBr.iX,rect[0].iBr.iY,rect[2].iTl.iX,rect[3].iTl.iY);
   1.378 +		space[5].SetRect(iClientRect.iBr.iX/2,rect[1].iBr.iY,rect[3].iTl.iX,rect[6].iTl.iY);
   1.379 +		space[6].SetRect(iClientRect.iBr.iX/2,rect[6].iTl.iY,rect[6].iTl.iX,rect[6].iBr.iY);
   1.380 +		space[7].SetRect(iClientRect.iBr.iX/2,rect[6].iBr.iY,rect[6].iBr.iX,iClientRect.iBr.iY);
   1.381 +		space[8].SetRect(rect[6].iBr.iX,rect[6].iTl.iY,rect[4].iTl.iX,iClientRect.iBr.iY);
   1.382 +		space[9].SetRect(rect[4].iTl.iX,rect[4].iBr.iY,rect[5].iTl.iX,iClientRect.iBr.iY);
   1.383 +		space[10].SetRect(rect[4].iBr.iX,rect[4].iTl.iY,iClientRect.iBr.iX,rect[5].iTl.iY);
   1.384 +		space[11].SetRect(rect[3].iBr.iX,rect[3].iTl.iY,iClientRect.iBr.iX,rect[4].iTl.iY);
   1.385 +		RRegion creg(rect[0],8);
   1.386 +		creg.AddRect(rect[1]);
   1.387 +		creg.AddRect(rect[2]);
   1.388 +		creg.AddRect(rect[3]);
   1.389 +		creg.AddRect(rect[4]);
   1.390 +		creg.AddRect(rect[5]);
   1.391 +		creg.AddRect(rect[6]);
   1.392 +		creg.AddRect(rect[7]);
   1.393 +		for(iGopNum=EFirstGop+1;iGopNum<EGraphicsOps;iGopNum++)
   1.394 +			{
   1.395 +			DrawToScreen(creg,iClientRect);
   1.396 +			TInt count=0;
   1.397 +			for(;count<8;count++)
   1.398 +				CheckInside(rect[count],iClientRect);
   1.399 +			for(count=0;count<12;count++)
   1.400 +				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);
   1.401 +			}
   1.402 +		creg.Close();
   1.403 +		}
   1.404 +	}
   1.405 +
   1.406 +void CTClip::ScanArea(TInt x,TInt y,TInt length,TInt height)
   1.407 +	{
   1.408 +	if (length<1 || height<1)
   1.409 +		{
   1.410 +		return;
   1.411 +		}
   1.412 +
   1.413 +	HBufC8* buf = HBufC8::NewL(length * 4);
   1.414 +	TPtr8 des = buf->Des();
   1.415 +	
   1.416 +	for (TInt row=0; row<height; row++)
   1.417 +		{
   1.418 +		TPoint point(x, y+row);
   1.419 +		
   1.420 +		des.Zero();
   1.421 +		iDev->GetScanLine(des,point,length,EColor16MA);
   1.422 +		
   1.423 +		for(TInt i=0; i<des.Length(); i++)
   1.424 +			{
   1.425 +			if(des[i] != 0xFF)
   1.426 +				{
   1.427 +				INFO_PRINTF1(_L("Clipping failure outside!\n"));
   1.428 +				INFO_PRINTF2(_L("Graphics operation: %d\n"),iGopNum);
   1.429 +				INFO_PRINTF5(_L("x=%d, y=%d, length=%d, height=%d\n"),x,y,length,height);
   1.430 +				INFO_PRINTF3(_L("Index=%d, Found=%x, Expected=0xFF\n"),i,des[i]);
   1.431 +				TEST(0);
   1.432 +				delete buf;
   1.433 +				return;
   1.434 +				}
   1.435 +			}
   1.436 +		}
   1.437 +				
   1.438 +	delete buf;
   1.439 +	}
   1.440 +
   1.441 +void CTClip::CheckInside(const TRect& aClip,const TRect& aRect)
   1.442 +	{
   1.443 +	const TInt length=aClip.Width();
   1.444 +	const TInt unOffsetX=-(aRect.iBr.iX/2);
   1.445 +#if defined(__X86GCC__) || defined(__MARM__)
   1.446 +	const TInt KMaxLinesToPrint=2;
   1.447 +#else
   1.448 +	const TInt KMaxLinesToPrint=10;
   1.449 +#endif
   1.450 +
   1.451 +	HBufC8* unBuf = HBufC8::NewL(length * 4);
   1.452 +	HBufC8* clBuf = HBufC8::NewL(length * 4);
   1.453 +	
   1.454 +	TPtr8 unDes = unBuf->Des();
   1.455 +	TPtr8 clDes = clBuf->Des();
   1.456 +
   1.457 +	TInt linesDiffs=0;
   1.458 +	for (TUint yy=aClip.iTl.iY; yy<aClip.iBr.iY; yy++)
   1.459 +		{
   1.460 +		TPoint unPoint(aClip.iTl.iX+unOffsetX, yy);
   1.461 +		TPoint clPoint(aClip.iTl.iX,           yy);
   1.462 +		
   1.463 +		unDes.Zero();
   1.464 +		clDes.Zero();
   1.465 +		iDev->GetScanLine(unDes,unPoint,length,EColor16MA);
   1.466 +		iDev->GetScanLine(clDes,clPoint,length,EColor16MA);
   1.467 +		
   1.468 +		TInt different = unDes.Compare(clDes);
   1.469 +		if (different)
   1.470 +			{
   1.471 +			if (linesDiffs++<KMaxLinesToPrint)
   1.472 +				{
   1.473 +				_LIT(KDots,"..");
   1.474 +				_LIT(KStart,"|.");
   1.475 +				_LIT(KEnd,".|");
   1.476 +				const TInt KMaxNumBytesToLog=14;
   1.477 +				TBuf<8*KMaxNumBytesToLog> buf1,buf2;
   1.478 +				TInt end=Min(length,KMaxNumBytesToLog);
   1.479 +				end*=4;
   1.480 +				TInt ii;
   1.481 +				TInt matches=ETrue;
   1.482 +				for (ii=0; ii<end; ++ii)
   1.483 +					{
   1.484 +					_LIT(KHex,"%02x");
   1.485 +					buf1.AppendFormat(KHex,unDes[ii]);
   1.486 +					if (unDes[ii]!=clDes[ii])
   1.487 +						{
   1.488 +						buf2.AppendFormat(KHex,clDes[ii]);
   1.489 +						matches=EFalse;
   1.490 +						}
   1.491 +					else
   1.492 +						{		//Show each pixel as |......| on the 2nd line if it matches
   1.493 +						TPtrC ptr(KDots);
   1.494 +						switch (ii%4)
   1.495 +							{
   1.496 +						case 0:
   1.497 +							ptr.Set(KStart);
   1.498 +							break;
   1.499 +						case 3:
   1.500 +							ptr.Set(KEnd);
   1.501 +							break;
   1.502 +							}
   1.503 +						buf2.Append(ptr);
   1.504 +						}
   1.505 +					}
   1.506 +				TBuf<256> buf;
   1.507 +				if (!matches)
   1.508 +					{
   1.509 +					_LIT(KLog,"ClipRect (%d,%d,%d,%d)  Row=%d  (First %d of %d pixels shown, only differing values shown on comparison line)");
   1.510 +					buf.Format(KLog,aClip.iTl.iX,aClip.iTl.iY,aClip.iBr.iX,aClip.iBr.iY,yy,end,aClip.Width());
   1.511 +					INFO_PRINTF1(buf);
   1.512 +					INFO_PRINTF1(buf1);
   1.513 +					INFO_PRINTF1(buf2);
   1.514 +					}
   1.515 +				else
   1.516 +					{
   1.517 +					_LIT(KLog,"ClipRect (%d,%d,%d,%d)  Row=%d  (First %d of %d pixels all match)");
   1.518 +					buf.Format(KLog,aClip.iTl.iX,aClip.iTl.iY,aClip.iBr.iX,aClip.iBr.iY,yy,end,aClip.Width());
   1.519 +					INFO_PRINTF1(buf);
   1.520 +					}
   1.521 +				}
   1.522 +			}
   1.523 +		}
   1.524 +	if (linesDiffs>0)
   1.525 +		{
   1.526 +		_LIT(KLog,"Clipping failure inside!  Graphics operation: %d  Lines With Diffs: %d/%d");
   1.527 +		INFO_PRINTF4(KLog,iGopNum,linesDiffs,aClip.iBr.iY-aClip.iTl.iY);
   1.528 +		}
   1.529 +	if (!Step()->IgnoreDiffs())
   1.530 +		TEST(linesDiffs==0);
   1.531 +
   1.532 +	delete unBuf;
   1.533 +	delete clBuf;
   1.534 +	}
   1.535 +
   1.536 +void CTClip::DrawToScreen(TRegion& clip_reg,TRect r)
   1.537 +	{
   1.538 +	Clear();
   1.539 +	TRect halfWid(r);
   1.540 +	halfWid.iBr.iX=halfWid.iBr.iX/2;
   1.541 +	iCon->SetClippingRect(halfWid);
   1.542 +	DoDraw(r,EFalse);
   1.543 +	iCon->CancelClippingRect();
   1.544 +	iCon->SetClippingRegion(&clip_reg);
   1.545 +	iCon->SetOrigin(TPoint(r.iBr.iX/2,0));
   1.546 +	DoDraw(r,ETrue);
   1.547 +	iCon->CancelClippingRegion();
   1.548 +	iCon->SetOrigin(TPoint(0,0));
   1.549 +	}
   1.550 +
   1.551 +void CTClip::DrawToScreen(const TRect& cliprect,TRect r)
   1.552 +	{
   1.553 +	Clear();
   1.554 +	TRect halfWid(r);
   1.555 +	halfWid.iBr.iX=halfWid.iBr.iX/2;
   1.556 +	iCon->SetClippingRect(halfWid);
   1.557 +	DoDraw(r,EFalse);
   1.558 +	iCon->SetClippingRect(cliprect);
   1.559 +	iCon->SetOrigin(TPoint(r.iBr.iX/2,0));
   1.560 +	DoDraw(r,ETrue);
   1.561 +	iCon->CancelClippingRect();
   1.562 +	iCon->SetOrigin(TPoint(0,0));
   1.563 +	}
   1.564 +
   1.565 +void CTClip::DoDraw(TRect r,TBool clipped)
   1.566 +	{
   1.567 +	TRect sh;
   1.568 +	TPoint p,z;
   1.569 +	switch(iGopNum)
   1.570 +		{
   1.571 +	case EPlot:
   1.572 +		iCon->Plot(TPoint(r.iBr.iX/6-10,r.iBr.iY/3-10));
   1.573 +		iCon->Plot(TPoint(r.iBr.iX/6,r.iBr.iY/3));
   1.574 +	break;
   1.575 +	case EDrawLine:
   1.576 +		p.SetXY(r.iBr.iX/2-1,r.iBr.iY+1);
   1.577 +		iCon->DrawLine(z,p);
   1.578 +	break;
   1.579 +	case EDottedLine:
   1.580 +		p.SetXY(r.iBr.iX/2-1,r.iBr.iY+1);
   1.581 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.582 +		iCon->DrawLine(z,p);
   1.583 +	break;
   1.584 +	case EDashedLine:
   1.585 +		p.SetXY(r.iBr.iX/2-1,r.iBr.iY+1);
   1.586 +		iCon->SetPenStyle(CGraphicsContext::EDashedPen);
   1.587 +		iCon->DrawLine(z,p);
   1.588 +	break;
   1.589 +	case EWideLine:
   1.590 +		p.SetXY(r.iBr.iX/2-11,r.iBr.iY-9);
   1.591 +		iCon->SetPenSize(TSize(5,5));
   1.592 +		iCon->DrawLine(z,p);
   1.593 +	break;
   1.594 +	case EDrawArc:
   1.595 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.596 +		p.SetXY(r.iBr.iX/2-1,0);
   1.597 +		iCon->DrawArc(sh,z,p);
   1.598 +	break;
   1.599 +	case EDottedArc:
   1.600 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.601 +		p.SetXY(r.iBr.iX/2-1,0);
   1.602 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.603 +		iCon->DrawArc(sh,z,p);
   1.604 +	break;
   1.605 +	case EDrawRect:
   1.606 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.607 +		iCon->DrawRect(sh);
   1.608 +	break;
   1.609 +	case EVerticalHatchRect:
   1.610 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.611 +		iCon->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
   1.612 +		iCon->DrawRect(sh);
   1.613 +	break;
   1.614 +	case EForwardDiagonalHatchRect:
   1.615 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.616 +		iCon->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
   1.617 +		iCon->DrawRect(sh);
   1.618 +	break;
   1.619 +	case EHorizontalHatchRect:
   1.620 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.621 +		iCon->SetBrushStyle(CGraphicsContext::EHorizontalHatchBrush);
   1.622 +		iCon->DrawRect(sh);
   1.623 +	break;
   1.624 +	case ERearwardDiagonalHatchRect:
   1.625 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.626 +		iCon->SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
   1.627 +		iCon->DrawRect(sh);
   1.628 +	break;
   1.629 +	case ESquareCrossHatchRect:
   1.630 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.631 +		iCon->SetBrushStyle(CGraphicsContext::ESquareCrossHatchBrush);
   1.632 +		iCon->DrawRect(sh);
   1.633 +	break;
   1.634 +	case EDiamondCrossHatchRect:
   1.635 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.636 +		iCon->SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush);
   1.637 +		iCon->DrawRect(sh);
   1.638 +	break;
   1.639 +	case EVerticalHatchEllipse:
   1.640 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.641 +		iCon->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
   1.642 +		iCon->DrawEllipse(sh);
   1.643 +	break;
   1.644 +	case EForwardDiagonalHatchEllipse:
   1.645 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.646 +		iCon->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
   1.647 +		iCon->DrawEllipse(sh);
   1.648 +	break;
   1.649 +	case EHorizontalHatchEllipse:
   1.650 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.651 +		iCon->SetBrushStyle(CGraphicsContext::EHorizontalHatchBrush);
   1.652 +		iCon->DrawEllipse(sh);
   1.653 +	break;
   1.654 +	case ERearwardDiagonalHatchEllipse:
   1.655 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.656 +		iCon->SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
   1.657 +		iCon->DrawEllipse(sh);
   1.658 +	break;
   1.659 +	case ESquareCrossHatchEllipse:
   1.660 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.661 +		iCon->SetBrushStyle(CGraphicsContext::ESquareCrossHatchBrush);
   1.662 +		iCon->DrawEllipse(sh);
   1.663 +	break;
   1.664 +	case EDiamondCrossHatchEllipse:
   1.665 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.666 +		iCon->SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush);
   1.667 +		iCon->DrawEllipse(sh);
   1.668 +	break;
   1.669 +	case EDottedRect:
   1.670 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.671 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.672 +		iCon->DrawRect(sh);
   1.673 +	break;
   1.674 +	case ECopyRect:
   1.675 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.676 +		if(clipped)
   1.677 +			{
   1.678 +			iCon->SetOrigin(z);
   1.679 +			iCon->CopyRect(TPoint(r.iBr.iX/2,0),sh);
   1.680 +			}
   1.681 +		else
   1.682 +			iCon->DrawRect(sh);
   1.683 +	break;
   1.684 +	case EDrawEllipse:
   1.685 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.686 +		iCon->DrawEllipse(sh);
   1.687 +	break;
   1.688 +	case EDottedEllipse:
   1.689 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.690 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.691 +		iCon->DrawEllipse(sh);
   1.692 +	break;
   1.693 +	case EDrawRoundRect:
   1.694 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.695 +		p.SetXY(r.iBr.iX>>2,r.iBr.iY>>4);
   1.696 +		iCon->DrawRoundRect(sh,p.AsSize());
   1.697 +	break;
   1.698 +	case EDottedRoundRect:
   1.699 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.700 +		p.SetXY(r.iBr.iX>>2,r.iBr.iY>>4);
   1.701 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.702 +		iCon->DrawRoundRect(sh,p.AsSize());
   1.703 +	break;
   1.704 +	case EDrawPie:
   1.705 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.706 +		p.SetXY(r.iBr.iX/2-1,0);
   1.707 +		iCon->DrawPie(sh,z,p);
   1.708 +	break;
   1.709 +	case EDottedPie:
   1.710 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.711 +		p.SetXY(r.iBr.iX/2-1,0);
   1.712 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.713 +		iCon->DrawPie(sh,z,p);
   1.714 +	break;
   1.715 +	case EDrawPolygon:
   1.716 +		{
   1.717 +		CArrayFixFlat<TPoint>* t=new CArrayFixFlat<TPoint>(3);
   1.718 +		TPoint temp(r.iBr.iX/6,r.iBr.iY/4);
   1.719 +		TRAPD(errCode, t->AppendL(temp));
   1.720 +		if(errCode != KErrNone)
   1.721 +			{
   1.722 +			return;
   1.723 +			}
   1.724 +		temp.SetXY(r.iBr.iX/12,r.iBr.iY/2);
   1.725 +		TRAP(errCode, t->AppendL(temp));
   1.726 +		if(errCode != KErrNone)
   1.727 +			{
   1.728 +			return;
   1.729 +			}
   1.730 +		temp.SetXY(r.iBr.iX/4,r.iBr.iY/2);
   1.731 +		TRAP(errCode, t->AppendL(temp));
   1.732 +		if(errCode != KErrNone)
   1.733 +			{
   1.734 +			return;
   1.735 +			}
   1.736 +		iCon->DrawPolygon(t);
   1.737 +		delete t;
   1.738 +		}
   1.739 +	break;
   1.740 +	case EDrawText:
   1.741 +		{
   1.742 +		iCon->UseFont(iFont);
   1.743 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.744 +		iCon->DrawText(testtext,p);
   1.745 +		}
   1.746 +	break;
   1.747 +	case EBoxText:
   1.748 +		{
   1.749 +		iCon->UseFont(iFont);
   1.750 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.751 +		TInt ascent=iFont->AscentInPixels();
   1.752 +		TInt height=iFont->HeightInPixels();
   1.753 +		TInt width=iFont->TextWidthInPixels(testtext);
   1.754 +		TRect box(p.iX,p.iY,p.iX+width,p.iY+height);
   1.755 +		iCon->DrawText(testtext,box,ascent);
   1.756 +		}
   1.757 +	break;
   1.758 +	case EDrawTextVertical:
   1.759 +		iCon->UseFont(iFont);
   1.760 +		p.SetXY(r.iBr.iX/6-13,r.iBr.iY/3+5);
   1.761 +		p.iX+=5;
   1.762 +		p.iY-=10;
   1.763 +		iCon->DrawTextVertical(testtext,p,EFalse);
   1.764 +	break;
   1.765 +	case ELargeText:
   1.766 +		iCon->UseFont(iLargeFont);
   1.767 +		p.SetXY(r.iBr.iX/6-13,r.iBr.iY/3+5);
   1.768 +		iCon->DrawText(largetesttext,p);
   1.769 +	break;
   1.770 +	case ELargeBoxText:
   1.771 +		{
   1.772 +		iCon->UseFont(iLargeFont);
   1.773 +		p.SetXY(r.iTl.iX, r.iTl.iY);
   1.774 +		TInt ascent=iLargeFont->AscentInPixels();
   1.775 +		TInt height=iLargeFont->HeightInPixels();
   1.776 +		TInt width=iLargeFont->TextWidthInPixels(largetesttext);
   1.777 +		TRect box(p.iX, p.iY, p.iX+width, p.iY+height);
   1.778 +		iCon->DrawText(largetesttext,box,ascent);
   1.779 +		}
   1.780 +	break;
   1.781 +	case ELargeTextVertical:
   1.782 +		iCon->UseFont(iLargeFont);
   1.783 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.784 +		iCon->DrawTextVertical(largetesttext,p,EFalse);
   1.785 +	break;
   1.786 +	case EPaintRect:
   1.787 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.788 +		iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.789 +		iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   1.790 +		iCon->DrawRect(sh);
   1.791 +	break;
   1.792 +	case EBitBltContext:
   1.793 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.794 +		if(clipped)
   1.795 +			{
   1.796 +			iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   1.797 +			iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.798 +			iCon->BitBlt(z,*iCon,sh);
   1.799 +			}
   1.800 +		else
   1.801 +			{
   1.802 +			iCon->SetPenStyle(CGraphicsContext::EDottedPen);
   1.803 +			iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   1.804 +			iCon->DrawRect(sh);
   1.805 +			}
   1.806 +	break;
   1.807 +	case EBitmapLarge:
   1.808 +		sh.SetRect(0,0,r.iBr.iX/2-1,r.iBr.iY);
   1.809 +		iCon->DrawBitmap(sh,iBitmap);
   1.810 +	break;
   1.811 +	case EBitmapSmall:
   1.812 +		p.SetXY(r.iBr.iX/6-40,r.iBr.iY/3-20);
   1.813 +		sh.SetRect(p,TSize(iBitmap->SizeInPixels().iWidth/2,iBitmap->SizeInPixels().iHeight/2));
   1.814 +		iCon->DrawBitmap(sh,iBitmap);
   1.815 +	break;
   1.816 +	case EBitBltBitmap:
   1.817 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);		
   1.818 +		iCon->BitBlt(p,iBitmap64K);
   1.819 +	break;
   1.820 +	case EDrawBitmap:
   1.821 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.822 +		sh.SetRect(p,iBitmap64K->SizeInPixels());
   1.823 +		iCon->DrawBitmap(sh,iBitmap);
   1.824 +	break;
   1.825 +	case EBitBltMasked:
   1.826 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.827 +		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   1.828 +		iCon->BitBltMasked(p,iBitmap,sh,iBitmap,ETrue);
   1.829 +	break;
   1.830 +	case EBitBltMaskedBinary:
   1.831 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.832 +		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   1.833 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.834 +		iCon->BitBltMasked(p,iBitmap,sh,iBitmapMask,EFalse);
   1.835 +	break;
   1.836 +	case EBitBltMaskedBinary64K:
   1.837 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.838 +		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   1.839 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.840 +		iCon->BitBltMasked(p,iBitmap64K,sh,iBitmapMask,EFalse);
   1.841 +	break;
   1.842 +	case EBitBltMaskedBinary16MU:
   1.843 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.844 +		sh.SetRect(TPoint(0,0),iBitmap16MU->SizeInPixels());
   1.845 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.846 +		iCon->BitBltMasked(p,iBitmap16MU,sh,iBitmapMask,EFalse);
   1.847 +	break;
   1.848 +	case EBitBltMaskedBinary16MA:
   1.849 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.850 +		sh.SetRect(TPoint(0,0),iBitmap16MA->SizeInPixels());
   1.851 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.852 +		iCon->BitBltMasked(p,iBitmap16MA,sh,iBitmapMask,EFalse);
   1.853 +	break;	
   1.854 +	case EBitBltMaskedAlpha:
   1.855 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.856 +		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   1.857 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.858 +		iCon->BitBltMasked(p,iBitmap,sh,iBitmapAlpha,EFalse);
   1.859 +	break;
   1.860 +	case EBitBltMaskedAlpha64K:
   1.861 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.862 +		sh.SetRect(TPoint(0,0),iBitmap64K->SizeInPixels());
   1.863 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.864 +		iCon->BitBltMasked(p,iBitmap64K,sh,iBitmapAlpha,EFalse);
   1.865 +	break;
   1.866 +	case EBitBltMaskedAlpha16MU:
   1.867 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.868 +		sh.SetRect(TPoint(0,0),iBitmap16MU->SizeInPixels());
   1.869 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.870 +		iCon->BitBltMasked(p,iBitmap16MU,sh,iBitmapAlpha,EFalse);
   1.871 +	break;
   1.872 +	case EBitBltMaskedAlpha16MA:
   1.873 +		p.SetXY(r.iTl.iX+1, r.iTl.iY+1);
   1.874 +		sh.SetRect(TPoint(0,0),iBitmap16MA->SizeInPixels());
   1.875 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.876 +		iCon->BitBltMasked(p,iBitmap16MA,sh,iBitmapAlpha,EFalse);
   1.877 +	break;
   1.878 +		}
   1.879 +	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   1.880 +	iCon->SetPenSize(TSize(1,1));
   1.881 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.882 +	}
   1.883 +
   1.884 +//--------------
   1.885 +CTClipStep::CTClipStep() :iIgnoreDiffs(EFalse)
   1.886 +	{
   1.887 +	SetTestStepName(KTClipStep);
   1.888 +	}
   1.889 +	
   1.890 +CTClipStep::~CTClipStep()
   1.891 +	{
   1.892 +	DestroyTestEnvironment();
   1.893 +	}
   1.894 +
   1.895 +inline TBool CTClipStep::IgnoreDiffs()
   1.896 +	{
   1.897 +	return iIgnoreDiffs;
   1.898 +	}
   1.899 +
   1.900 +CTGraphicsBase* CTClipStep::CreateTestL()
   1.901 +	{
   1.902 +	_LIT(KLog,"Create CTClip");
   1.903 +	INFO_PRINTF1(KLog);
   1.904 +	return new (ELeave) CTClip(this, iTestAppNo, iDev, iGc, iBmp, iFont, iLargeFont);
   1.905 +	}
   1.906 +
   1.907 +void CTClipStep::TestSetupL()
   1.908 +	{
   1.909 +	FbsStartup();
   1.910 +	RFbsSession::Connect();
   1.911 +	
   1.912 +	CreateTestEnvironment();
   1.913 +	}
   1.914 +	
   1.915 +void CTClipStep::TestClose()
   1.916 +	{
   1.917 +	DestroyTestEnvironment();
   1.918 +	RFbsSession::Disconnect();
   1.919 +	}
   1.920 +
   1.921 +TInt CTClipStep::CreateScreenDevice(TDisplayMode aMode)
   1.922 +	{
   1.923 +	TRAPD(err,iDev=CFbsScreenDevice::NewL(KNullDesC,aMode));
   1.924 +	const TPtrC modeName=CTGraphicsBase::ColorModeName(aMode);
   1.925 +	if (err==KErrNone)
   1.926 +		{
   1.927 +		_LIT(KLog,"Sucessfully created Screen Device, mode %S");
   1.928 +		INFO_PRINTF2(KLog,&modeName);
   1.929 +		}
   1.930 +	else
   1.931 +		{
   1.932 +		if (err==KErrNotSupported)
   1.933 +			{
   1.934 +			_LIT(KLog,"Screen Device with mode %S not available on this device");
   1.935 +			INFO_PRINTF2(KLog,&modeName);
   1.936 +			}
   1.937 +		else
   1.938 +			{
   1.939 +			_LIT(KLog,"Failed to created Screen Device with mode %S  err=%d");
   1.940 +			INFO_PRINTF3(KLog,&modeName,err);
   1.941 +			}
   1.942 +		}
   1.943 +	return err;
   1.944 +	}
   1.945 +
   1.946 +void CTClipStep::CreateTestEnvironment()
   1.947 +	{
   1.948 +	iDev=NULL;
   1.949 +	//This test will fail if any display mode other than EColor64K, EColor256, EGray256
   1.950 +	//is selected
   1.951 +	TInt ret=CreateScreenDevice(EColor64K);
   1.952 +	if (ret!=KErrNone)
   1.953 +		ret=CreateScreenDevice(EColor256);
   1.954 +	if (ret!=KErrNone)
   1.955 +		ret=CreateScreenDevice(EGray256);
   1.956 +	if (ret!=KErrNone)
   1.957 +		ret=CreateScreenDevice(EColor16MU);
   1.958 +	if (ret!=KErrNone)
   1.959 +		ret=CreateScreenDevice(EColor16M);
   1.960 +	if (ret!=KErrNone)
   1.961 +		ret=CreateScreenDevice(EColor4K);
   1.962 +	if (ret!=KErrNone)
   1.963 +		{
   1.964 +		ret=CreateScreenDevice(EColor16MA);
   1.965 +		if (ret==KErrNone)
   1.966 +			{
   1.967 +			iIgnoreDiffs=ETrue;
   1.968 +			_LIT(KLog,"Ignore Diffs set to %d (ETrue?)");
   1.969 +			INFO_PRINTF2(KLog,iIgnoreDiffs);
   1.970 +			}
   1.971 +		}
   1.972 +	if (ret!=KErrNone)
   1.973 +		{
   1.974 +		ret=CreateScreenDevice(EColor16MAP);
   1.975 +		if (ret==KErrNone)
   1.976 +			{
   1.977 +			iIgnoreDiffs=ETrue;
   1.978 +			_LIT(KLog,"Ignore Diffs set to %d (ETrue?)");
   1.979 +			INFO_PRINTF2(KLog,iIgnoreDiffs);
   1.980 +			}
   1.981 +		}
   1.982 +	if(ret!=KErrNone)
   1.983 +		User::Panic(_L("Device not created"),ret);
   1.984 +	iDev->ChangeScreenDevice(NULL);
   1.985 +	iGc=NULL;
   1.986 +	ret=iDev->CreateContext(iGc);
   1.987 +	if(iGc==NULL)
   1.988 +		User::Panic(_L("Context not created"),KErrGeneral);
   1.989 +	iGc->Activate(iDev);
   1.990 +	iFont=NULL;
   1.991 +	TFontSpec fs(_L("Swiss"),12);
   1.992 +	ret=iDev->GetNearestFontToDesignHeightInPixels(iFont,fs);
   1.993 +	if(ret!=KErrNone)
   1.994 +		User::Panic(_L("Font not created"),KErrGeneral);
   1.995 +	iLargeFont=NULL;
   1.996 +	fs.iHeight=100;
   1.997 +	ret=iDev->GetNearestFontToDesignHeightInPixels(iLargeFont,fs);
   1.998 +	if(ret!=KErrNone)
   1.999 +		User::Panic(_L("Font not created"),KErrGeneral);
  1.1000 +	
  1.1001 +	iBmp=new CFbsBitmap;
  1.1002 +	if(iBmp==NULL)
  1.1003 +		User::Panic(_L("Bitmap not created"),KErrGeneral);
  1.1004 +	if(iTestAppNo == 0)
  1.1005 +		{
  1.1006 +		// Uncompressed
  1.1007 +		TInt ret=iBmp->Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTbmp,EFalse);
  1.1008 +		if(ret!=KErrNone)
  1.1009 +			User::Panic(_L("Bitmap not loaded"),ret);
  1.1010 +		}
  1.1011 +	else
  1.1012 +		{
  1.1013 +		TInt ret=iBmp->LoadAndCompress(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTbmp,EFalse);
  1.1014 +		if(ret!=KErrNone)
  1.1015 +			User::Panic(_L("Bitmap not loaded"),ret);
  1.1016 +		}
  1.1017 +	
  1.1018 +	}
  1.1019 +
  1.1020 +void CTClipStep::DestroyTestEnvironment()
  1.1021 +	{
  1.1022 +	delete iGc;
  1.1023 +	iGc = NULL;
  1.1024 +	
  1.1025 +	delete iBmp;
  1.1026 +	iBmp = NULL;
  1.1027 +
  1.1028 +	if(iFont)
  1.1029 +		{
  1.1030 +		iDev->ReleaseFont(iFont);
  1.1031 +		iFont = NULL;
  1.1032 +		}
  1.1033 +	if(iLargeFont)
  1.1034 +		{
  1.1035 +		iDev->ReleaseFont(iLargeFont);
  1.1036 +		iLargeFont = NULL;	
  1.1037 +		}
  1.1038 +	
  1.1039 +	delete iDev;
  1.1040 +	iDev = NULL;
  1.1041 +	}
  1.1042 +
  1.1043 +//--------------
  1.1044 +CTClip2Step::CTClip2Step() :
  1.1045 +	CTClipStep()
  1.1046 +	{
  1.1047 +	iTestAppNo = 1;
  1.1048 +	SetTestStepName(KTClip2Step);
  1.1049 +	}