os/graphics/graphicsdeviceinterface/bitgdi/tbit/TGDI.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/TGDI.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2782 @@
     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 +// Test wrapper to bitgdi component of graphics.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @test
    1.24 + @internalComponent - Internal Symbian test code 
    1.25 +*/
    1.26 +#include <tgdi.mbg>
    1.27 +
    1.28 +#include "TGDI.H"
    1.29 +#include "TBMP.H"
    1.30 +#include <bitdev.h>
    1.31 +
    1.32 +#define MAXCOLORS 255
    1.33 +
    1.34 +_LIT(KT23BitmapFileName,"z:\\system\\data\\tgdi.mbm");
    1.35 +
    1.36 +// TestGdi methods
    1.37 +
    1.38 +EXPORT_C TestGdi::TestGdi():
    1.39 +	iDev(NULL),
    1.40 +	iCon(NULL),
    1.41 +	iSize(0,0),
    1.42 +	iSection(NULL)
    1.43 +	{}
    1.44 +
    1.45 +// This function is modified. contents are moved to below function
    1.46 +EXPORT_C void TestGdi::Construct(CBitmapDevice* aDevice,CFbsBitGc* aContext,TDes& aFailureSection)
    1.47 +	{
    1.48 +	TRAP_IGNORE(ConstructL(aDevice, aContext, aFailureSection));
    1.49 +	}
    1.50 +
    1.51 +// This is additional function with suffix L
    1.52 +EXPORT_C void TestGdi::ConstructL(CBitmapDevice* aDevice,CFbsBitGc* aContext,TDes& aFailureSection)
    1.53 +	{
    1.54 +	__ASSERT_ALWAYS(aFailureSection.MaxLength() == KFailureSectionNameBufferLength,User::Panic(_L("TGDI"),KErrBadDescriptor));
    1.55 +
    1.56 +	iDev = aDevice;
    1.57 +	iCon = aContext;
    1.58 +	iSize = iDev->SizeInPixels();
    1.59 +	iSection = &aFailureSection;
    1.60 +
    1.61 +	iCon->SetPenSize(TSize(1,1));
    1.62 +	iCon->SetDrawMode(CGraphicsContext::EDrawModePEN);
    1.63 +	iCon->SetPenColor(KRgbBlack);
    1.64 +	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
    1.65 +	iCon->SetBrushColor(KRgbBlack);
    1.66 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
    1.67 +
    1.68 +	iRect.iTl.iX=iSize.iWidth/3;
    1.69 +	iRect.iTl.iY=iSize.iHeight/3;
    1.70 +	iRect.iBr.iX=iSize.iWidth*2/3;
    1.71 +	iRect.iBr.iY=iSize.iHeight*2/3;
    1.72 +	iBitmapWidth=50;
    1.73 +	iBitmapHeight=87;
    1.74 +	iZeroRect.SetRect(iRect.iTl,iRect.iTl);
    1.75 +	iUnitRect.SetRect(iRect.iTl,iRect.iTl+TPoint(1,1));
    1.76 +	iUnNormRect.iTl=iRect.iBr;
    1.77 +	iUnNormRect.iBr=iRect.iTl;
    1.78 +	iLargeRect.SetRect(-iSize.iWidth,-iSize.iHeight,iSize.iWidth*2,iSize.iHeight*2);
    1.79 +	iCentredRect.iTl=TPoint(0,0)-iRect.iTl;
    1.80 +	iCentredRect.iBr=iRect.iTl;
    1.81 +	for(TInt count=0;count<8;count++)
    1.82 +		iOffScreenRects[count]=iRect;
    1.83 +	iOffScreenRects[0].Move(-iSize.iWidth,-iSize.iHeight);
    1.84 +	iOffScreenRects[1].Move(0,-iSize.iHeight);
    1.85 +	iOffScreenRects[2].Move(iSize.iWidth,-iSize.iHeight);
    1.86 +	iOffScreenRects[3].Move(iSize.iWidth,0);
    1.87 +	iOffScreenRects[4].Move(iSize.iWidth,iSize.iHeight);
    1.88 +	iOffScreenRects[5].Move(0,iSize.iHeight);
    1.89 +	iOffScreenRects[6].Move(-iSize.iWidth,iSize.iHeight);
    1.90 +	iOffScreenRects[7].Move(-iSize.iWidth,0);
    1.91 +
    1.92 +	TInt ret = iBitmap.Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTgdigen,EFalse);
    1.93 +	User::LeaveIfError(ret);
    1.94 +
    1.95 +	ret = iBitmap2.Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTblank,EFalse);
    1.96 +	User::LeaveIfError(ret);
    1.97 +	}
    1.98 +
    1.99 +EXPORT_C TBool TestGdi::Test()
   1.100 +	{
   1.101 +	// Get FBSERV to create its long lived objects to avoid trigering memory leaks.
   1.102 +	CFbsBitmap* srcBmp = new CFbsBitmap;
   1.103 +	if (srcBmp==NULL || srcBmp->Create(iSize,EColor16MU)!=KErrNone)
   1.104 +		{
   1.105 +		return EFalse;
   1.106 +		}
   1.107 +	delete srcBmp;
   1.108 +	
   1.109 +	CFbsBitmap* t23SrcBmp = new (ELeave) CFbsBitmap();
   1.110 +	TInt ret = t23SrcBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_sourcebitmap);
   1.111 +	delete t23SrcBmp;
   1.112 +	if(ret != KErrNone)
   1.113 +		{
   1.114 +		return EFalse;
   1.115 +		}
   1.116 +	
   1.117 +	TRAPD(err,DoTestL());
   1.118 +	if (err != KErrNone)
   1.119 +		iSection->AppendFormat(_L(", error %d"), err);
   1.120 +
   1.121 +	iBitmap.Reset();
   1.122 +	iBitmap2.Reset();
   1.123 +
   1.124 +	return err == KErrNone;
   1.125 +	}
   1.126 +
   1.127 +void TestGdi::DoTestL()
   1.128 +	{
   1.129 +	*iSection = _L("Testing graphics functions");
   1.130 +	CheckL(iSize!=TSize(0,0));
   1.131 +	Clear();
   1.132 +	TRgb col;
   1.133 +	iDev->GetPixel(col,TPoint(iSize.iWidth/2,iSize.iHeight/2));
   1.134 +	CheckL(col==KRgbWhite);
   1.135 +	iCon->Plot(iRect.iTl);
   1.136 +	CheckPlotL(iRect.iTl);
   1.137 +	Clear();
   1.138 +	CheckClearL();
   1.139 +/**
   1.140 + @SYMTestCaseID GRAPHICS-TestGdi-0001
   1.141 +*/
   1.142 +	SetTestStepID(_L("GRAPHICS-TestGdi-0001"));
   1.143 +	DoArcL();
   1.144 +	RecordTestResultL();
   1.145 +/**
   1.146 + @SYMTestCaseID GRAPHICS-TestGdi-0002
   1.147 +*/
   1.148 +	SetTestStepID(_L("GRAPHICS-TestGdi-0002"));
   1.149 +	DoEllipseL();
   1.150 +	RecordTestResultL();
   1.151 +/**
   1.152 + @SYMTestCaseID GRAPHICS-TestGdi-0003
   1.153 +*/
   1.154 +	SetTestStepID(_L("GRAPHICS-TestGdi-0003"));
   1.155 +	DoRoundRectL();
   1.156 +	RecordTestResultL();
   1.157 +/**
   1.158 + @SYMTestCaseID GRAPHICS-TestGdi-0004
   1.159 +*/
   1.160 +	SetTestStepID(_L("GRAPHICS-TestGdi-0004"));
   1.161 +	DoPieL();
   1.162 +	RecordTestResultL();
   1.163 +/**
   1.164 + @SYMTestCaseID GRAPHICS-TestGdi-0005
   1.165 +*/
   1.166 +	SetTestStepID(_L("GRAPHICS-TestGdi-0005"));
   1.167 +	DoModeL();
   1.168 +	RecordTestResultL();
   1.169 +/**
   1.170 + @SYMTestCaseID GRAPHICS-TestGdi-0006
   1.171 +*/
   1.172 +	SetTestStepID(_L("GRAPHICS-TestGdi-0006"));
   1.173 +	DoColorL();
   1.174 +	RecordTestResultL();
   1.175 +/**
   1.176 + @SYMTestCaseID GRAPHICS-TestGdi-0007
   1.177 +*/
   1.178 +	SetTestStepID(_L("GRAPHICS-TestGdi-0007"));
   1.179 +	DoLineL();
   1.180 +	RecordTestResultL();
   1.181 +/**
   1.182 + @SYMTestCaseID GRAPHICS-TestGdi-0008
   1.183 +*/
   1.184 +	SetTestStepID(_L("GRAPHICS-TestGdi-0008"));
   1.185 +	DoWideLineL();
   1.186 +	RecordTestResultL();
   1.187 +/**
   1.188 + @SYMTestCaseID GRAPHICS-TestGdi-0009
   1.189 +*/
   1.190 +	SetTestStepID(_L("GRAPHICS-TestGdi-0009"));
   1.191 +	DoRectL();
   1.192 +	RecordTestResultL();
   1.193 +/**
   1.194 + @SYMTestCaseID GRAPHICS-TestGdi-0010
   1.195 +*/
   1.196 +	SetTestStepID(_L("GRAPHICS-TestGdi-0010"));
   1.197 +	DoPolygonArrayL();
   1.198 +	RecordTestResultL();
   1.199 +/**
   1.200 + @SYMTestCaseID GRAPHICS-TestGdi-0011
   1.201 +*/
   1.202 +	SetTestStepID(_L("GRAPHICS-TestGdi-0011"));
   1.203 +	DoPolygonPtrL();
   1.204 +	RecordTestResultL();
   1.205 +/**
   1.206 + @SYMTestCaseID GRAPHICS-TestGdi-0012
   1.207 +*/
   1.208 +	SetTestStepID(_L("GRAPHICS-TestGdi-0012"));
   1.209 +	DoPolygonPtr0();
   1.210 +	RecordTestResultL();
   1.211 +/**
   1.212 + @SYMTestCaseID GRAPHICS-TestGdi-0013
   1.213 +*/
   1.214 +	SetTestStepID(_L("GRAPHICS-TestGdi-0013"));
   1.215 +	DoText();
   1.216 +	RecordTestResultL();
   1.217 +/**
   1.218 + @SYMTestCaseID GRAPHICS-TestGdi-0014
   1.219 +*/
   1.220 +	SetTestStepID(_L("GRAPHICS-TestGdi-0014"));
   1.221 +	DoPaintL();
   1.222 +	RecordTestResultL();
   1.223 +/**
   1.224 + @SYMTestCaseID GRAPHICS-TestGdi-0015
   1.225 +*/
   1.226 +	SetTestStepID(_L("GRAPHICS-TestGdi-0015"));
   1.227 +	DoCopyL();
   1.228 +	RecordTestResultL();
   1.229 +/**
   1.230 + @SYMTestCaseID GRAPHICS-TestGdi-0016
   1.231 +*/
   1.232 +	SetTestStepID(_L("GRAPHICS-TestGdi-0016"));
   1.233 +	DoBltL();
   1.234 +	RecordTestResultL();
   1.235 +/**
   1.236 + @SYMTestCaseID GRAPHICS-TestGdi-0017
   1.237 +*/
   1.238 +	SetTestStepID(_L("GRAPHICS-TestGdi-0017"));
   1.239 +	DoBltMaskedL();
   1.240 +	RecordTestResultL();
   1.241 +/**
   1.242 + @SYMTestCaseID GRAPHICS-TestGdi-0018
   1.243 +*/
   1.244 +	SetTestStepID(_L("GRAPHICS-TestGdi-0018"));
   1.245 +	DoShadowL();
   1.246 +	RecordTestResultL();
   1.247 +/**
   1.248 + @SYMTestCaseID GRAPHICS-TestGdi-0019
   1.249 +*/
   1.250 +	SetTestStepID(_L("GRAPHICS-TestGdi-0019"));
   1.251 +	DoFadeL();
   1.252 +	RecordTestResultL();
   1.253 +/**
   1.254 + @SYMTestCaseID GRAPHICS-TestGdi-0020
   1.255 +*/
   1.256 +	SetTestStepID(_L("GRAPHICS-TestGdi-0020"));
   1.257 +	DoDrawBitmapSemiTransparentMaskedL();
   1.258 +	RecordTestResultL();
   1.259 +	// If DoDrawBitmapMaskedL causes a User Panic 21, it might be a positive failure of case #24. 
   1.260 +	SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001"));	
   1.261 +	DoDrawBitmapMaskedL(ETrue);
   1.262 +	RecordTestResultL();
   1.263 +	SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001"));
   1.264 +	DoDrawBitmapMaskedL(EFalse);
   1.265 +	RecordTestResultL();
   1.266 +	//test bitmap width 52 (wordalignable)
   1.267 +	iBitmapWidth=52;
   1.268 +/**
   1.269 + @SYMTestCaseID GRAPHICS-TestGdi-0021
   1.270 +*/
   1.271 +	SetTestStepID(_L("GRAPHICS-TestGdi-0021"));
   1.272 +	DoBltL();
   1.273 +	RecordTestResultL();
   1.274 +/**
   1.275 + @SYMTestCaseID GRAPHICS-TestGdi-0022
   1.276 +*/
   1.277 +	SetTestStepID(_L("GRAPHICS-TestGdi-0022"));
   1.278 +	DoBltMaskedL();
   1.279 +	RecordTestResultL();
   1.280 +	SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001"));
   1.281 +	DoDrawBitmapMaskedL(ETrue);
   1.282 +	RecordTestResultL();
   1.283 +	SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001"));
   1.284 +	DoDrawBitmapMaskedL(EFalse);
   1.285 +	RecordTestResultL();
   1.286 +	//test with compressed bitmaps
   1.287 +/**
   1.288 + @SYMTestCaseID GRAPHICS-TestGdi-0023
   1.289 +*/
   1.290 +	SetTestStepID(_L("GRAPHICS-TestGdi-0023"));
   1.291 +	DoBltCompressedL();
   1.292 +	RecordTestResultL();
   1.293 +/**
   1.294 + @SYMTestCaseID GRAPHICS-TestGdi-0024
   1.295 +*/
   1.296 +	SetTestStepID(_L("GRAPHICS-TestGdi-0024"));
   1.297 +	DoBoxTextVertical();
   1.298 +	RecordTestResultL();
   1.299 +	}
   1.300 +
   1.301 +void TestGdi::CheckL(TBool aValue)
   1.302 +	{
   1.303 +	if (!aValue)
   1.304 +		User::Leave(KErrGeneral);
   1.305 +	}
   1.306 +
   1.307 +void TestGdi::Clear()
   1.308 +	{
   1.309 +	iCon->SetDrawMode(CGraphicsContext::EDrawModePEN);
   1.310 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.311 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.312 +	iCon->SetBrushColor(KRgbWhite);
   1.313 +	iCon->DrawRect(TRect(TPoint(0,0),iSize));
   1.314 +	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
   1.315 +	iCon->SetPenColor(KRgbBlack);
   1.316 +	iCon->SetBrushColor(KRgbBlack);
   1.317 +	}
   1.318 +
   1.319 +LOCAL_C void FreeAlloc(TAny* aPtr)
   1.320 +	{
   1.321 +	TRgb* scanline = reinterpret_cast <TRgb*> (aPtr);
   1.322 +	User::Free(scanline);
   1.323 +	}
   1.324 +	
   1.325 +void TestGdi::ScanAreaL(TInt x,TInt y,TInt length,TInt height,TRgb Color)
   1.326 +	{
   1.327 +	if(x>iSize.iWidth)
   1.328 +		return;
   1.329 +	if(x<0)
   1.330 +		{
   1.331 +		length=length+x;
   1.332 +		x=0;
   1.333 +		}
   1.334 +	if(x+length>iSize.iWidth)
   1.335 +		length=iSize.iWidth-x;
   1.336 +	if(length<=0)
   1.337 +		return;
   1.338 +	TRgb* scanline=(TRgb*)User::Alloc(sizeof(TRgb)*length);
   1.339 +	CleanupStack::PushL(TCleanupItem(FreeAlloc, scanline));
   1.340 +	TPtr8 scln((TUint8*)scanline,length*sizeof(TRgb));
   1.341 +	for(TInt row=0;row<height;row++)
   1.342 +		{
   1.343 +		if(y+row>=0 && y+row<iSize.iHeight)
   1.344 +			{
   1.345 +			iDev->GetScanLine(scln,TPoint(x,y+row),length,ERgb);
   1.346 +			for(TInt index=0;index<length;index++)
   1.347 +				{
   1.348 +				CheckL(scanline[index] == Color);
   1.349 +				}
   1.350 +				
   1.351 +			}
   1.352 +		}
   1.353 +	for(TInt i=0;i<height;i++)
   1.354 +		{
   1.355 +		scanline[i].~TRgb();
   1.356 +		}
   1.357 +	CleanupStack::PopAndDestroy(scanline);
   1.358 +	}
   1.359 +
   1.360 +void TestGdi::CheckClearL()
   1.361 +	{
   1.362 +	TInt quarht=iSize.iHeight>>2;
   1.363 +	TInt halfht=iSize.iHeight>>1;
   1.364 +	TInt thrqht=quarht+halfht;
   1.365 +	ScanAreaL(0,0,iSize.iWidth,1,KRgbWhite);
   1.366 +	ScanAreaL(0,quarht,iSize.iWidth,quarht+1,KRgbWhite);
   1.367 +	ScanAreaL(0,halfht,iSize.iWidth,halfht+1,KRgbWhite);
   1.368 +	ScanAreaL(0,thrqht,iSize.iWidth,thrqht+1,KRgbWhite);
   1.369 +	ScanAreaL(0,iSize.iHeight-1,iSize.iWidth,iSize.iHeight,KRgbWhite);
   1.370 +	ScanAreaL(iRect.iTl.iX,iRect.iTl.iY,1,1,KRgbWhite);
   1.371 +	}
   1.372 +
   1.373 +void TestGdi::CheckPlotL(const TPoint& pt)
   1.374 +	{
   1.375 +	ScanAreaL(pt.iX,pt.iY,1,1,KRgbBlack);
   1.376 +	ScanAreaL(pt.iX-1,pt.iY-1,3,1,KRgbWhite);
   1.377 +	ScanAreaL(pt.iX-1,pt.iY+1,3,1,KRgbWhite);
   1.378 +	ScanAreaL(pt.iX-1,pt.iY,1,1,KRgbWhite);
   1.379 +	ScanAreaL(pt.iX+1,pt.iY,1,1,KRgbWhite);
   1.380 +	Clear();
   1.381 +	}
   1.382 +
   1.383 +void TestGdi::CheckRectInsideL(const TRect& rect)
   1.384 +	{
   1.385 +	ScanAreaL(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX-rect.iTl.iX,1,KRgbBlack);
   1.386 +	ScanAreaL(rect.iTl.iX,rect.iBr.iY-1,rect.iBr.iX-rect.iTl.iX,1,KRgbBlack);
   1.387 +	}
   1.388 +
   1.389 +void TestGdi::CheckRectOutsideL(const TRect& rect)
   1.390 +	{
   1.391 +	ScanAreaL(rect.iTl.iX-1,rect.iTl.iY-1,rect.iBr.iX-rect.iTl.iX,1,KRgbWhite);
   1.392 +	ScanAreaL(rect.iTl.iX-1,rect.iBr.iY,rect.iBr.iX-rect.iTl.iX+1,1,KRgbWhite);
   1.393 +	}
   1.394 +
   1.395 +void TestGdi::CheckQuadOutsideL(const TRect& rect)
   1.396 +	{
   1.397 +	ScanAreaL(rect.iTl.iX-1,rect.iTl.iY-6,rect.iBr.iX-rect.iTl.iX+1,1,KRgbWhite);
   1.398 +	ScanAreaL(rect.iTl.iX-1,rect.iBr.iY-5,rect.iBr.iX-rect.iTl.iX+1,1,KRgbWhite);
   1.399 +	}
   1.400 +
   1.401 +void TestGdi::CheckQuadInsideL(const TRect& rect)
   1.402 +	{
   1.403 +	if(rect.iBr.iX-rect.iTl.iX-11>0)
   1.404 +		ScanAreaL(rect.iTl.iX+5,(rect.iTl.iY+rect.iBr.iY)/2,rect.iBr.iX-rect.iTl.iX-11,1,KRgbBlack);
   1.405 +	}
   1.406 +
   1.407 +void TestGdi::DoModeL()
   1.408 +	{
   1.409 +	if(iDev->DisplayMode()==EGray2) return;
   1.410 +	*iSection = _L("Drawing mode");
   1.411 +	Clear();
   1.412 +	iCon->Plot(iRect.iTl);
   1.413 +	CheckPlotL(iRect.iTl);
   1.414 +
   1.415 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTPEN);
   1.416 +	iCon->SetPenColor(KRgbWhite);
   1.417 +	iCon->Plot(iRect.iTl);
   1.418 +	CheckPlotL(iRect.iTl);
   1.419 +
   1.420 +	iCon->SetPenColor(KRgbDarkGray);
   1.421 +	iCon->Plot(iRect.iTl);
   1.422 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeAND);
   1.423 +	iCon->SetPenColor(KRgbGray);
   1.424 +	iCon->Plot(iRect.iTl);
   1.425 +	CheckPlotL(iRect.iTl);
   1.426 +	
   1.427 +	iCon->SetPenColor(KRgbGray);
   1.428 +	iCon->Plot(iRect.iTl);
   1.429 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeANDNOT);
   1.430 +	iCon->SetPenColor(KRgbGray);
   1.431 +	iCon->Plot(iRect.iTl);
   1.432 +	CheckPlotL(iRect.iTl);
   1.433 +	
   1.434 +	iCon->Plot(iRect.iTl);
   1.435 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeOR);
   1.436 +	iCon->Plot(iRect.iTl);
   1.437 +	CheckPlotL(iRect.iTl);
   1.438 +	
   1.439 +	iCon->Plot(iRect.iTl);
   1.440 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeORNOT);
   1.441 +	iCon->SetPenColor(KRgbWhite);
   1.442 +	iCon->Plot(iRect.iTl);
   1.443 +	CheckPlotL(iRect.iTl);
   1.444 +	
   1.445 +	iCon->SetPenColor(KRgbGray);
   1.446 +	iCon->Plot(iRect.iTl);
   1.447 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeXOR);
   1.448 +	iCon->SetPenColor(KRgbGray);
   1.449 +	iCon->Plot(iRect.iTl);
   1.450 +	CheckPlotL(iRect.iTl);
   1.451 +	
   1.452 +	iCon->SetPenColor(KRgbDarkGray);
   1.453 +	iCon->Plot(iRect.iTl);
   1.454 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTXOR);
   1.455 +	iCon->SetPenColor(KRgbGray);
   1.456 +	iCon->Plot(iRect.iTl);
   1.457 +	CheckPlotL(iRect.iTl);
   1.458 +	
   1.459 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
   1.460 +	iCon->Plot(iRect.iTl);
   1.461 +	CheckPlotL(iRect.iTl);
   1.462 +	
   1.463 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTAND);
   1.464 +	iCon->SetPenColor(KRgbWhite);
   1.465 +	iCon->Plot(iRect.iTl);
   1.466 +	CheckPlotL(iRect.iTl);
   1.467 +	
   1.468 +	iCon->Plot(iRect.iTl);
   1.469 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTANDNOT);
   1.470 +	iCon->SetPenColor(KRgbWhite);
   1.471 +	iCon->Plot(iRect.iTl);
   1.472 +	CheckPlotL(iRect.iTl);
   1.473 +	
   1.474 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTOR);
   1.475 +	iCon->SetPenColor(KRgbBlack);
   1.476 +	iCon->Plot(iRect.iTl);
   1.477 +	CheckPlotL(iRect.iTl);
   1.478 +
   1.479 +	iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTORNOT);
   1.480 +	iCon->SetPenColor(KRgbWhite);
   1.481 +	iCon->Plot(iRect.iTl);
   1.482 +	CheckPlotL(iRect.iTl);
   1.483 +	}
   1.484 +
   1.485 +void TestGdi::DoColorL()
   1.486 +	{
   1.487 +	*iSection = _L("Colors");
   1.488 +	Clear();
   1.489 +	for(TInt count=0;count<256;count++)
   1.490 +		{
   1.491 +		iCon->SetPenColor(TRgb::Gray256(count));
   1.492 +		iCon->Plot(iRect.iTl);
   1.493 +		TRgb screencolor;
   1.494 +		iDev->GetPixel(screencolor,iRect.iTl);
   1.495 +		switch(iDev->DisplayMode())
   1.496 +			{
   1.497 +		case EGray2:
   1.498 +			CheckL(screencolor.Gray2()==count>>7);
   1.499 +			break;
   1.500 +		case EGray4:
   1.501 +			CheckL(Abs(screencolor.Gray4()-(count>>6))<2);
   1.502 +			break;
   1.503 +		case EGray16:
   1.504 +			if(screencolor.Gray16()!=(count>>4))
   1.505 +				CheckL(Abs(screencolor.Gray4()-(count>>6))<2);
   1.506 +			break;
   1.507 +		case EGray256:
   1.508 +			CheckL(screencolor.Gray256()==count);
   1.509 +			break;
   1.510 +		default:
   1.511 +			break;
   1.512 +			}
   1.513 +		iCon->SetPenColor(KRgbWhite);
   1.514 +		iCon->Plot(iRect.iTl);
   1.515 +		iDev->GetPixel(screencolor,iRect.iTl);
   1.516 +		CheckL(screencolor==KRgbWhite);
   1.517 +		}
   1.518 +	}
   1.519 +
   1.520 +void TestGdi::DoLineL()
   1.521 +	{
   1.522 +	*iSection = _L("Line drawing");
   1.523 +	Clear();
   1.524 +	iCon->DrawLine(iRect.iTl,iRect.iTl);
   1.525 +	iCon->DrawLine(iRect.iTl,iRect.iTl+TPoint(1,1));
   1.526 +	CheckPlotL(iRect.iTl);
   1.527 +	Clear();
   1.528 +	iCon->DrawLine(iRect.iTl,TPoint(iRect.iBr.iX,iRect.iTl.iY));
   1.529 +	CheckRectInsideL(TRect(iRect.iTl,TPoint(iRect.iBr.iX,iRect.iTl.iY+1)));
   1.530 +	CheckRectOutsideL(TRect(iRect.iTl,TPoint(iRect.iBr.iX,iRect.iTl.iY+1)));
   1.531 +	Clear();
   1.532 +	iCon->DrawLine(TPoint(-iRect.iTl.iX,iRect.iTl.iY),TPoint(iRect.iBr.iX*2,iRect.iTl.iY));
   1.533 +	CheckRectInsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY,iRect.iBr.iX*2,iRect.iTl.iY+1));
   1.534 +	CheckRectOutsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY,iRect.iBr.iX*2,iRect.iTl.iY+1));
   1.535 +	Clear();
   1.536 +	TInt y=iRect.iTl.iY;
   1.537 +	for(;y<iRect.iBr.iY;y++)
   1.538 +		iCon->DrawLine(TPoint(iRect.iTl.iX,y),TPoint(iRect.iBr.iX,y));
   1.539 +	CheckRectInsideL(iRect);
   1.540 +	CheckRectOutsideL(iRect);
   1.541 +	Clear();
   1.542 +	for(TInt count=0;count<8;count++)
   1.543 +		for(y=iOffScreenRects[count].iBr.iY;y<iOffScreenRects[count].iTl.iY;y++)
   1.544 +			iCon->DrawLine(TPoint(iOffScreenRects[count].iTl.iX,y),TPoint(iOffScreenRects[count].iBr.iX,y));
   1.545 +	CheckClearL();
   1.546 +	iCon->SetPenSize(TSize(100,100));
   1.547 +	iCon->DrawLine(TPoint(iRect.iTl.iX,iRect.iTl.iY),TPoint(iRect.iBr.iX,iRect.iTl.iY));
   1.548 +	CheckRectInsideL(TRect(iRect.iTl.iX+50,iRect.iTl.iY-49,iRect.iBr.iX-50,iRect.iTl.iY+50));
   1.549 +	CheckRectOutsideL(TRect(iRect.iTl.iX,iRect.iTl.iY-49,iRect.iBr.iX,iRect.iTl.iY+51));
   1.550 +	Clear();
   1.551 +	iCon->DrawLine(TPoint(-iRect.iTl.iX,iRect.iTl.iY),TPoint(iRect.iBr.iX*2,iRect.iTl.iY));
   1.552 +	CheckRectInsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY-49,iRect.iBr.iX*2,iRect.iTl.iY+50));
   1.553 +	CheckRectOutsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY-49,iRect.iBr.iX*2,iRect.iTl.iY+51));
   1.554 +	Clear();
   1.555 +	iCon->SetPenSize(TSize(1,1));
   1.556 +	}
   1.557 +
   1.558 +void TestGdi::DoWideLineL()
   1.559 +	{
   1.560 +	*iSection = _L("Wide Line drawing");
   1.561 +
   1.562 +	Clear();
   1.563 +	iCon->SetPenStyle(CFbsBitGc::ESolidPen);
   1.564 +	iCon->SetPenColor(KRgbBlack);
   1.565 +	iCon->SetPenSize(TSize(4,4));
   1.566 +	TPoint pos(-24,10);
   1.567 +	TSize size(288,216);
   1.568 +	
   1.569 +	// Black arrow, pointing up.
   1.570 +	TPoint midLeft(pos.iX, size.iHeight / 2 + pos.iY);
   1.571 +	TPoint midTop(pos.iX + size.iWidth / 2, pos.iY);
   1.572 +	TPoint midRight(size.iWidth, size.iHeight / 2 + pos.iY);
   1.573 +	TPoint midBottom(pos.iX + size.iWidth / 2, size.iHeight);	
   1.574 +	iCon->DrawLine(midLeft, midTop);
   1.575 +	iCon->DrawLine(midTop, midRight);
   1.576 +	iCon->DrawLine(midTop, midBottom);
   1.577 +
   1.578 +	// Check halfway along left side of arrowhead
   1.579 +	TPoint checkPt(midLeft);
   1.580 +	checkPt += midTop;
   1.581 +	checkPt.iX /= 2;
   1.582 +	checkPt.iY /= 2;
   1.583 +	TRgb pixel;
   1.584 +	iDev->GetPixel(pixel, checkPt);
   1.585 +	if (pixel.Internal() != KRgbBlack.Internal())
   1.586 +		{
   1.587 +		User::Panic(_L("Line not found!"), 1);
   1.588 +		}
   1.589 +	
   1.590 +	Clear();
   1.591 +	iCon->SetPenSize(TSize(1,1));	
   1.592 +	}
   1.593 +
   1.594 +void TestGdi::DoArcL()
   1.595 +	{
   1.596 +	*iSection = _L("Arcs");
   1.597 +	Clear();
   1.598 +	iCon->DrawArc(iRect,iRect.iTl,iRect.iTl);
   1.599 +	CheckRectOutsideL(iRect);
   1.600 +	Clear();
   1.601 +	iCon->DrawArc(iLargeRect,iRect.iTl,iRect.iTl);
   1.602 +	iCon->DrawArc(iUnNormRect,iRect.iTl,iRect.iTl);
   1.603 +	CheckClearL();
   1.604 +	iCon->DrawArc(iCentredRect,iCentredRect.iTl,iCentredRect.iTl);
   1.605 +	Clear();
   1.606 +	TInt count=0;
   1.607 +	for(;count<8;count++)
   1.608 +		iCon->DrawArc(iOffScreenRects[count],iOffScreenRects[count].iTl,iOffScreenRects[count].iTl);
   1.609 +	CheckClearL();
   1.610 +	#include "TGDIGEN.H"
   1.611 +	for(count=0;count<numellipses;count++)
   1.612 +		iCon->DrawArc(ellrect[count],ellrect[count].iTl,ellrect[count].iTl);
   1.613 +	TSize size=iBitmap.SizeInPixels();
   1.614 +	if(size.iWidth>iSize.iWidth)
   1.615 +		size.iWidth=iSize.iWidth;
   1.616 +	if(size.iHeight>iSize.iHeight)
   1.617 +		size.iHeight=iSize.iHeight;
   1.618 +	for(TInt yy=0;yy<size.iHeight>>1;yy++)
   1.619 +		{
   1.620 +		for(TInt xx=0;xx<size.iWidth>>1;xx++)
   1.621 +			{
   1.622 +			TPoint pt(xx,yy);
   1.623 +			TRgb bmprgb,scrrgb;
   1.624 +			iBitmap.GetPixel(bmprgb,pt);
   1.625 +			iDev->GetPixel(scrrgb,pt);
   1.626 +			if(bmprgb==KRgbBlack)
   1.627 +				CheckL(scrrgb==KRgbBlack);
   1.628 +			}
   1.629 +		}
   1.630 +	}
   1.631 +
   1.632 +void TestGdi::DoRectL()
   1.633 +	{
   1.634 +	*iSection = _L("Rectangles");
   1.635 +	Clear();
   1.636 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.637 +	iCon->DrawRect(iRect);
   1.638 +	CheckRectOutsideL(iRect);
   1.639 +	Clear();
   1.640 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.641 +	iCon->DrawRect(iRect);
   1.642 +	CheckRectInsideL(iRect);
   1.643 +	CheckRectOutsideL(iRect);
   1.644 +	CheckQuadInsideL(iRect);
   1.645 +	Clear();
   1.646 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.647 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.648 +	iCon->DrawRect(iRect);
   1.649 +	CheckRectInsideL(iRect);
   1.650 +	CheckRectOutsideL(iRect);
   1.651 +	CheckQuadInsideL(iRect);
   1.652 +	Clear();
   1.653 +	iCon->DrawRect(iUnitRect);
   1.654 +	CheckPlotL(iUnitRect.iTl);
   1.655 +	Clear();
   1.656 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.657 +	iCon->DrawRect(iUnitRect);
   1.658 +	CheckPlotL(iUnitRect.iTl);
   1.659 +	Clear();
   1.660 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.661 +	iCon->DrawRect(iUnitRect);
   1.662 +	CheckPlotL(iUnitRect.iTl);
   1.663 +	Clear();
   1.664 +	iCon->DrawRect(iCentredRect);
   1.665 +	CheckRectInsideL(iCentredRect);
   1.666 +	CheckRectOutsideL(iCentredRect);
   1.667 +	Clear();
   1.668 +	iCon->DrawRect(iZeroRect);
   1.669 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.670 +	iCon->DrawRect(iZeroRect);
   1.671 +	iCon->DrawRect(iUnNormRect);
   1.672 +	for(TInt count=0;count<8;count++)
   1.673 +		iCon->DrawRect(iOffScreenRects[count]);
   1.674 +	CheckClearL();
   1.675 +	iCon->DrawRect(TRect(iRect.iTl.iX/2,iRect.iTl.iY,iRect.iTl.iX,iRect.iBr.iY));
   1.676 +	iCon->CopyRect(TPoint(iSize.iWidth/2,iSize.iHeight/6),TRect(iRect.iTl.iX/2,iRect.iTl.iY,iRect.iTl.iX,iRect.iBr.iY));
   1.677 +	CheckRectInsideL(TRect(iRect.iTl.iX/2+iSize.iWidth/2,iRect.iTl.iY+iSize.iHeight/6,iRect.iTl.iX+iSize.iWidth/2,iRect.iBr.iY+iSize.iHeight/6));
   1.678 +	CheckRectOutsideL(TRect(iRect.iTl.iX/2+iSize.iWidth/2,iRect.iTl.iY+iSize.iHeight/6,iRect.iTl.iX+iSize.iWidth/2,iRect.iBr.iY+iSize.iHeight/6));
   1.679 +	Clear();
   1.680 +	}
   1.681 +
   1.682 +void TestGdi::DoEllipseL()
   1.683 +	{
   1.684 +	*iSection = _L("Ellipses");
   1.685 +	Clear();
   1.686 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.687 +	iCon->DrawEllipse(iRect);
   1.688 +	CheckRectOutsideL(iRect);
   1.689 +	Clear();
   1.690 +	iCon->DrawEllipse(iRect);
   1.691 +	CheckRectOutsideL(iRect);
   1.692 +	CheckQuadInsideL(iRect);
   1.693 +	Clear();
   1.694 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.695 +	iCon->DrawEllipse(iRect);
   1.696 +	CheckRectOutsideL(iRect);
   1.697 +	CheckQuadInsideL(iRect);
   1.698 +	Clear();
   1.699 +	iCon->DrawEllipse(iLargeRect);
   1.700 +	CheckQuadInsideL(iRect);
   1.701 +	Clear();
   1.702 +	iCon->DrawEllipse(iCentredRect);
   1.703 +	CheckQuadInsideL(iCentredRect);
   1.704 +	CheckRectOutsideL(iCentredRect);
   1.705 +	Clear();
   1.706 +	iCon->DrawEllipse(iUnNormRect);
   1.707 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.708 +	iCon->DrawEllipse(iLargeRect);
   1.709 +	TInt count=0;
   1.710 +	for(;count<8;count++)
   1.711 +		iCon->DrawEllipse(iOffScreenRects[count]);
   1.712 +	CheckClearL();
   1.713 +	#include "TGDIGEN.H"
   1.714 +	for(count=0;count<numellipses;count++)
   1.715 +		iCon->DrawEllipse(ellrect[count]);
   1.716 +	TSize size=iBitmap.SizeInPixels();
   1.717 +	if(size.iWidth>iSize.iWidth)
   1.718 +		size.iWidth=iSize.iWidth;
   1.719 +	if(size.iHeight>iSize.iHeight)
   1.720 +		size.iHeight=iSize.iHeight;
   1.721 +	for(TInt yy=0;yy<size.iHeight>>1;yy++)
   1.722 +		{
   1.723 +		for(TInt xx=0;xx<size.iWidth>>1;xx++)
   1.724 +			{
   1.725 +			TPoint pt(xx,yy);
   1.726 +			TRgb bmprgb,scrrgb;
   1.727 +			iBitmap.GetPixel(bmprgb,pt);
   1.728 +			iDev->GetPixel(scrrgb,pt);
   1.729 +			if(bmprgb==KRgbBlack)
   1.730 +				CheckL(scrrgb==KRgbBlack);
   1.731 +			}
   1.732 +		}
   1.733 +	}
   1.734 +
   1.735 +void TestGdi::DoPieL()
   1.736 +	{
   1.737 +	*iSection = _L("Pie segments");
   1.738 +	Clear();
   1.739 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.740 +	iCon->DrawPie(iRect,iRect.iTl,iRect.iTl);
   1.741 +	CheckRectOutsideL(iRect);
   1.742 +	Clear();
   1.743 +	iCon->DrawPie(iRect,iRect.iTl,iRect.iTl);
   1.744 +	CheckRectOutsideL(iRect);
   1.745 +	CheckQuadInsideL(iRect);
   1.746 +	Clear();
   1.747 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.748 +	iCon->DrawPie(iRect,iRect.iTl,iRect.iTl);
   1.749 +	CheckRectOutsideL(iRect);
   1.750 +	CheckQuadInsideL(iRect);
   1.751 +	Clear();
   1.752 +	iCon->DrawPie(iLargeRect,iRect.iTl,iRect.iTl);
   1.753 +	CheckQuadInsideL(iRect);
   1.754 +	Clear();
   1.755 +	iCon->DrawPie(iCentredRect,iCentredRect.iTl,iCentredRect.iTl);
   1.756 +	CheckQuadInsideL(iCentredRect);
   1.757 +	CheckRectOutsideL(iCentredRect);
   1.758 +	Clear();
   1.759 +	iCon->DrawPie(iUnNormRect,iRect.iTl,iRect.iTl);
   1.760 +	TInt count=0;
   1.761 +	for(;count<8;count++)
   1.762 +		iCon->DrawPie(iOffScreenRects[count],iOffScreenRects[count].iTl,iOffScreenRects[count].iTl);
   1.763 +	CheckClearL();
   1.764 +	#include "TGDIGEN.H"
   1.765 +	for(count=0;count<numellipses;count++)
   1.766 +		iCon->DrawPie(ellrect[count],ellrect[count].iTl,ellrect[count].iTl);
   1.767 +	TSize size=iBitmap.SizeInPixels();
   1.768 +	if(size.iWidth>iSize.iWidth)
   1.769 +		size.iWidth=iSize.iWidth;
   1.770 +	if(size.iHeight>iSize.iHeight)
   1.771 +		size.iHeight=iSize.iHeight;
   1.772 +	for(TInt yy=0;yy<size.iHeight>>1;yy++)
   1.773 +		{
   1.774 +		for(TInt xx=0;xx<size.iWidth>>1;xx++)
   1.775 +			{
   1.776 +			TPoint pt(xx,yy);
   1.777 +			TRgb bmprgb,scrrgb;
   1.778 +			iBitmap.GetPixel(bmprgb,pt);
   1.779 +			iDev->GetPixel(scrrgb,pt);
   1.780 +			if(bmprgb==KRgbBlack)
   1.781 +				CheckL(scrrgb==KRgbBlack);
   1.782 +			}
   1.783 +		}
   1.784 +	}
   1.785 +
   1.786 +void TestGdi::DoRoundRectL()
   1.787 +	{
   1.788 +	*iSection = _L("RoundRects");
   1.789 +	TSize rrsize(20,10);
   1.790 +	Clear();
   1.791 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.792 +	iCon->DrawRoundRect(iRect,rrsize);
   1.793 +	CheckRectOutsideL(iRect);
   1.794 +	Clear();
   1.795 +	iCon->DrawRoundRect(iRect,rrsize);
   1.796 +	CheckRectOutsideL(iRect);
   1.797 +	CheckQuadInsideL(iRect);
   1.798 +	Clear();
   1.799 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.800 +	iCon->DrawRoundRect(iRect,rrsize);
   1.801 +	CheckRectOutsideL(iRect);
   1.802 +	CheckQuadInsideL(iRect);
   1.803 +	Clear();
   1.804 +	iCon->DrawRoundRect(iLargeRect,rrsize);
   1.805 +	CheckQuadInsideL(iRect);
   1.806 +	Clear();
   1.807 +	iCon->DrawRoundRect(iCentredRect,rrsize);
   1.808 +	CheckQuadInsideL(iCentredRect);
   1.809 +	CheckRectOutsideL(iCentredRect);
   1.810 +	Clear();
   1.811 +	iCon->DrawRoundRect(iUnNormRect,rrsize);
   1.812 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.813 +	iCon->DrawRoundRect(iLargeRect,rrsize);
   1.814 +	TInt count=0;
   1.815 +	for(;count<8;count++)
   1.816 +		iCon->DrawRoundRect(iOffScreenRects[count],rrsize);
   1.817 +	CheckClearL();
   1.818 +	#include "TGDIGEN.H"
   1.819 +	for(count=0;count<numellipses;count++)
   1.820 +		iCon->DrawRoundRect(ellrect[count],TSize((ellrect[count].iBr.iX-ellrect[count].iTl.iX)>>1,(ellrect[count].iBr.iY-ellrect[count].iTl.iY)>>1));
   1.821 +	TSize size=iBitmap.SizeInPixels();
   1.822 +	if(size.iWidth>iSize.iWidth)
   1.823 +		size.iWidth=iSize.iWidth;
   1.824 +	if(size.iHeight>iSize.iHeight)
   1.825 +		size.iHeight=iSize.iHeight;
   1.826 +	for(TInt yy=0;yy<size.iHeight>>1;yy++)
   1.827 +		{
   1.828 +		for(TInt xx=0;xx<size.iWidth>>1;xx++)
   1.829 +			{
   1.830 +			TPoint pt(xx,yy);
   1.831 +			TRgb bmprgb,scrrgb;
   1.832 +			iDev->GetPixel(scrrgb,pt);
   1.833 +			pt.iY+=size.iHeight>>1;
   1.834 +			iBitmap.GetPixel(bmprgb,pt);
   1.835 +			if(bmprgb==KRgbBlack)
   1.836 +				CheckL(scrrgb==KRgbBlack);
   1.837 +			}
   1.838 +		}
   1.839 +	}
   1.840 +
   1.841 +void TestGdi::DoPolygonArrayL()
   1.842 +	{
   1.843 +	*iSection = _L("Polygon array");
   1.844 +
   1.845 +	CArrayFixFlat<TPoint>* poly=new CArrayFixFlat<TPoint>(4);
   1.846 +	poly->AppendL(iRect.iTl);
   1.847 +	TPoint temp(iRect.iBr.iX-1,iRect.iTl.iY);
   1.848 +	poly->AppendL(temp);
   1.849 +	temp.SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1);
   1.850 +	poly->AppendL(temp);
   1.851 +	temp.SetXY(iRect.iTl.iX,iRect.iBr.iY-1);
   1.852 +	poly->AppendL(temp);
   1.853 +	Clear();
   1.854 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.855 +	iCon->DrawPolygon(poly);
   1.856 +	CheckRectOutsideL(iRect);
   1.857 +	Clear();
   1.858 +	iCon->DrawPolygon(poly);
   1.859 +	CheckRectOutsideL(iRect);
   1.860 +	CheckQuadInsideL(iRect);
   1.861 +	Clear();
   1.862 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.863 +	iCon->DrawPolygon(poly);
   1.864 +	delete poly;
   1.865 +	CheckRectOutsideL(iRect);
   1.866 +	CheckQuadInsideL(iRect);
   1.867 +	Clear();
   1.868 +
   1.869 +	poly=new CArrayFixFlat<TPoint>(4);
   1.870 +	poly->AppendL(iLargeRect.iTl);
   1.871 +	temp.SetXY(iLargeRect.iBr.iX-1,iLargeRect.iTl.iY);
   1.872 +	poly->AppendL(temp);
   1.873 +	temp.SetXY(iLargeRect.iBr.iX-1,iLargeRect.iBr.iY-1);
   1.874 +	poly->AppendL(temp);
   1.875 +	temp.SetXY(iLargeRect.iTl.iX,iLargeRect.iBr.iY-1);
   1.876 +	poly->AppendL(temp);
   1.877 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.878 +	iCon->DrawPolygon(poly);
   1.879 +	CheckClearL();
   1.880 +	Clear();
   1.881 +	iCon->DrawPolygon(poly);
   1.882 +	delete poly;
   1.883 +	CheckQuadInsideL(iRect);
   1.884 +	Clear();
   1.885 +
   1.886 +	poly=new CArrayFixFlat<TPoint>(4);
   1.887 +	temp.SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iTl.iY-1);
   1.888 +	poly->AppendL(temp);
   1.889 +	temp.SetXY(iUnNormRect.iBr.iX,iUnNormRect.iTl.iY-1);
   1.890 +	poly->AppendL(temp);
   1.891 +	poly->AppendL(iUnNormRect.iBr);
   1.892 +	temp.SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iBr.iY);
   1.893 +	poly->AppendL(temp);
   1.894 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.895 +	iCon->DrawPolygon(poly);
   1.896 +	CheckRectOutsideL(iRect);
   1.897 +	Clear();
   1.898 +	iCon->DrawPolygon(poly);
   1.899 +	delete poly;
   1.900 +	CheckRectOutsideL(iRect);
   1.901 +	CheckQuadInsideL(iRect);
   1.902 +	Clear();
   1.903 +
   1.904 +	poly=new CArrayFixFlat<TPoint>(4);
   1.905 +	poly->AppendL(iCentredRect.iTl);
   1.906 +	temp.SetXY(iCentredRect.iBr.iX-1,iCentredRect.iTl.iY);
   1.907 +	poly->AppendL(temp);
   1.908 +	temp.SetXY(iCentredRect.iBr.iX-1,iCentredRect.iBr.iY-1);
   1.909 +	poly->AppendL(temp);
   1.910 +	temp.SetXY(iCentredRect.iTl.iX,iCentredRect.iBr.iY-1);
   1.911 +	poly->AppendL(temp);
   1.912 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.913 +	iCon->DrawPolygon(poly);
   1.914 +	CheckRectOutsideL(iCentredRect);
   1.915 +	Clear();
   1.916 +	iCon->DrawPolygon(poly);
   1.917 +	delete poly;
   1.918 +	CheckRectOutsideL(iCentredRect);
   1.919 +	CheckQuadInsideL(iCentredRect);
   1.920 +	Clear();
   1.921 +
   1.922 +	for(TInt count=0;count<8;count++)
   1.923 +		{
   1.924 +		poly=new CArrayFixFlat<TPoint>(4);
   1.925 +		poly->AppendL(iOffScreenRects[count].iTl);
   1.926 +		temp.SetXY(iOffScreenRects[count].iBr.iX,iOffScreenRects[count].iTl.iY);
   1.927 +		poly->AppendL(temp);
   1.928 +		poly->AppendL(iOffScreenRects[count].iBr);
   1.929 +		temp.SetXY(iOffScreenRects[count].iTl.iX,iOffScreenRects[count].iBr.iY);
   1.930 +		poly->AppendL(temp);
   1.931 +		iCon->DrawPolygon(poly);
   1.932 +		delete poly;
   1.933 +		}
   1.934 +
   1.935 +	poly=new CArrayFixFlat<TPoint>(4);
   1.936 +	const TInt offset = 10000;
   1.937 +	const TInt size = 50;
   1.938 +	TRect ppRect(0,0,size + 1,size + 1);
   1.939 +	TPoint pp(offset,offset);
   1.940 +	poly->AppendL(pp);
   1.941 +	pp.iX += size;
   1.942 +	poly->AppendL(pp);
   1.943 +	pp.iY += size;
   1.944 +	poly->AppendL(pp);
   1.945 +	pp.iX -= size;
   1.946 +	poly->AppendL(pp);
   1.947 +	Clear();
   1.948 +	iCon->SetOrigin(TPoint(-offset,-offset));
   1.949 +	iCon->DrawPolygon(poly);
   1.950 +	iCon->SetOrigin(TPoint(0,0));
   1.951 +	delete poly;
   1.952 +	CheckRectOutsideL(ppRect);
   1.953 +	CheckQuadInsideL(ppRect);
   1.954 +	Clear();
   1.955 +
   1.956 +	CheckClearL();
   1.957 +	}
   1.958 +
   1.959 +void TestGdi::DoPolygonPtr0()
   1.960 +	{
   1.961 +	*iSection = _L("Polygon ptr 0 points");
   1.962 +
   1.963 +	TPoint poly[4];
   1.964 +	poly[0] = iRect.iTl;
   1.965 +	poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY);
   1.966 +	poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1);
   1.967 +	poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1);
   1.968 +	Clear();
   1.969 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.970 +	iCon->DrawPolygon(poly,0);
   1.971 +	iCon->DrawPolygon(poly,0);
   1.972 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
   1.973 +	iCon->DrawPolygon(poly,0);
   1.974 +
   1.975 +	poly[0] = iLargeRect.iTl;
   1.976 +	poly[1].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iTl.iY);
   1.977 +	poly[2].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iBr.iY-1);
   1.978 +	poly[3].SetXY(iLargeRect.iTl.iX,iLargeRect.iBr.iY-1);
   1.979 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.980 +	iCon->DrawPolygon(poly,0);
   1.981 +	iCon->DrawPolygon(poly,0);
   1.982 +
   1.983 +	poly[0].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iTl.iY-1);
   1.984 +	poly[1].SetXY(iUnNormRect.iBr.iX,iUnNormRect.iTl.iY-1);
   1.985 +	poly[2] = iUnNormRect.iBr;
   1.986 +	poly[3].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iBr.iY);
   1.987 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.988 +	iCon->DrawPolygon(poly,0);
   1.989 +	iCon->DrawPolygon(poly,0);
   1.990 +
   1.991 +	poly[0] = iCentredRect.iTl;
   1.992 +	poly[1].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iTl.iY);
   1.993 +	poly[2].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iBr.iY-1);
   1.994 +	poly[3].SetXY(iCentredRect.iTl.iX,iCentredRect.iBr.iY-1);
   1.995 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.996 +	iCon->DrawPolygon(poly,0);
   1.997 +	iCon->DrawPolygon(poly,0);
   1.998 +
   1.999 +	for(TInt count=0;count<8;count++)
  1.1000 +		{
  1.1001 +		poly[0] = iOffScreenRects[count].iTl;
  1.1002 +		poly[1].SetXY(iOffScreenRects[count].iBr.iX,iOffScreenRects[count].iTl.iY);
  1.1003 +		poly[2] = iOffScreenRects[count].iBr;
  1.1004 +		poly[3].SetXY(iOffScreenRects[count].iTl.iX,iOffScreenRects[count].iBr.iY);
  1.1005 +		iCon->DrawPolygon(poly,0);
  1.1006 +		}
  1.1007 +
  1.1008 +	const TInt offset = 10000;
  1.1009 +	const TInt size = 50;
  1.1010 +	TPoint pp(offset,offset);
  1.1011 +	poly[0] = pp;
  1.1012 +	pp.iX += size;
  1.1013 +	poly[1] = pp;
  1.1014 +	pp.iY += size;
  1.1015 +	poly[2] = pp;
  1.1016 +	pp.iX -= size;
  1.1017 +	poly[3] = pp;
  1.1018 +	iCon->SetOrigin(TPoint(-offset,-offset));
  1.1019 +	iCon->DrawPolygon(poly,0);
  1.1020 +	iCon->SetOrigin(TPoint(0,0));
  1.1021 +
  1.1022 +	poly[0] = iRect.iTl;
  1.1023 +	poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY);
  1.1024 +	poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1);
  1.1025 +	poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1);
  1.1026 +	iCon->DrawPolygon(NULL,4);
  1.1027 +	iCon->DrawPolygon(poly,0);
  1.1028 +	iCon->DrawPolygon(NULL,0);
  1.1029 +	TPoint *ptr=(TPoint *)0x1111;
  1.1030 +	iCon->DrawPolygon(ptr,0);
  1.1031 +	iCon->DrawPolygon(NULL,4,CGraphicsContext::EWinding	);
  1.1032 +	iCon->DrawPolygon(poly,0,CGraphicsContext::EWinding	);
  1.1033 +	iCon->DrawPolygon(NULL,0,CGraphicsContext::EWinding	);
  1.1034 +	iCon->DrawPolygon(ptr,0,CGraphicsContext::EWinding	);
  1.1035 +	}
  1.1036 +
  1.1037 +void TestGdi::DoPolygonPtrL()
  1.1038 +	{
  1.1039 +	*iSection = _L("Polygon ptr");
  1.1040 +
  1.1041 +	TPoint poly[4];
  1.1042 +	poly[0] = iRect.iTl;
  1.1043 +	poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY);
  1.1044 +	poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1);
  1.1045 +	poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1);
  1.1046 +	Clear();
  1.1047 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1048 +	iCon->DrawPolygon(poly,4);
  1.1049 +	CheckRectOutsideL(iRect);
  1.1050 +	Clear();
  1.1051 +	iCon->DrawPolygon(poly,4);
  1.1052 +	CheckRectOutsideL(iRect);
  1.1053 +	CheckQuadInsideL(iRect);
  1.1054 +	Clear();
  1.1055 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
  1.1056 +	iCon->DrawPolygon(poly,4);
  1.1057 +	CheckRectOutsideL(iRect);
  1.1058 +	CheckQuadInsideL(iRect);
  1.1059 +	Clear();
  1.1060 +
  1.1061 +	poly[0] = iLargeRect.iTl;
  1.1062 +	poly[1].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iTl.iY);
  1.1063 +	poly[2].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iBr.iY-1);
  1.1064 +	poly[3].SetXY(iLargeRect.iTl.iX,iLargeRect.iBr.iY-1);
  1.1065 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1066 +	iCon->DrawPolygon(poly,4);
  1.1067 +	CheckClearL();
  1.1068 +	Clear();
  1.1069 +	iCon->DrawPolygon(poly,4);
  1.1070 +	CheckQuadInsideL(iRect);
  1.1071 +	Clear();
  1.1072 +
  1.1073 +	poly[0].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iTl.iY-1);
  1.1074 +	poly[1].SetXY(iUnNormRect.iBr.iX,iUnNormRect.iTl.iY-1);
  1.1075 +	poly[2] = iUnNormRect.iBr;
  1.1076 +	poly[3].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iBr.iY);
  1.1077 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1078 +	iCon->DrawPolygon(poly,4);
  1.1079 +	CheckRectOutsideL(iRect);
  1.1080 +	Clear();
  1.1081 +	iCon->DrawPolygon(poly,4);
  1.1082 +	CheckRectOutsideL(iRect);
  1.1083 +	CheckQuadInsideL(iRect);
  1.1084 +	Clear();
  1.1085 +
  1.1086 +	poly[0] = iCentredRect.iTl;
  1.1087 +	poly[1].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iTl.iY);
  1.1088 +	poly[2].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iBr.iY-1);
  1.1089 +	poly[3].SetXY(iCentredRect.iTl.iX,iCentredRect.iBr.iY-1);
  1.1090 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1091 +	iCon->DrawPolygon(poly,4);
  1.1092 +	CheckRectOutsideL(iCentredRect);
  1.1093 +	Clear();
  1.1094 +	iCon->DrawPolygon(poly,4);
  1.1095 +	CheckRectOutsideL(iCentredRect);
  1.1096 +	CheckQuadInsideL(iCentredRect);
  1.1097 +	Clear();
  1.1098 +
  1.1099 +	for(TInt count=0;count<8;count++)
  1.1100 +		{
  1.1101 +		poly[0] = iOffScreenRects[count].iTl;
  1.1102 +		poly[1].SetXY(iOffScreenRects[count].iBr.iX,iOffScreenRects[count].iTl.iY);
  1.1103 +		poly[2] = iOffScreenRects[count].iBr;
  1.1104 +		poly[3].SetXY(iOffScreenRects[count].iTl.iX,iOffScreenRects[count].iBr.iY);
  1.1105 +		iCon->DrawPolygon(poly,4);
  1.1106 +		}
  1.1107 +
  1.1108 +	const TInt offset = 10000;
  1.1109 +	const TInt size = 50;
  1.1110 +	TRect ppRect(0,0,size + 1,size + 1);
  1.1111 +	TPoint pp(offset,offset);
  1.1112 +	poly[0] = pp;
  1.1113 +	pp.iX += size;
  1.1114 +	poly[1] = pp;
  1.1115 +	pp.iY += size;
  1.1116 +	poly[2] = pp;
  1.1117 +	pp.iX -= size;
  1.1118 +	poly[3] = pp;
  1.1119 +	Clear();
  1.1120 +	iCon->SetOrigin(TPoint(-offset,-offset));
  1.1121 +	iCon->DrawPolygon(poly,4);
  1.1122 +	iCon->SetOrigin(TPoint(0,0));
  1.1123 +	CheckRectOutsideL(ppRect);
  1.1124 +	CheckQuadInsideL(ppRect);
  1.1125 +	Clear();
  1.1126 +
  1.1127 +	poly[0] = iRect.iTl;
  1.1128 +	poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY);
  1.1129 +	poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1);
  1.1130 +	poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1);
  1.1131 +	iCon->DrawPolygon(NULL,4);
  1.1132 +	Clear();
  1.1133 +	iCon->DrawPolygon(poly,0);
  1.1134 +	Clear();
  1.1135 +	iCon->DrawPolygon(NULL,0);
  1.1136 +	Clear();
  1.1137 +	TPoint *ptr=(TPoint *)0x1111;
  1.1138 +	iCon->DrawPolygon(ptr,0);
  1.1139 +	Clear();
  1.1140 +	iCon->DrawPolygon(NULL,4,CGraphicsContext::EWinding	);
  1.1141 +	Clear();
  1.1142 +	iCon->DrawPolygon(poly,0,CGraphicsContext::EWinding	);
  1.1143 +	Clear();
  1.1144 +	iCon->DrawPolygon(NULL,0,CGraphicsContext::EWinding	);
  1.1145 +	Clear();
  1.1146 +	iCon->DrawPolygon(ptr,0,CGraphicsContext::EWinding	);
  1.1147 +	Clear();
  1.1148 +
  1.1149 +	CheckClearL();
  1.1150 +	}
  1.1151 +
  1.1152 +void TestGdi::DoText()
  1.1153 +	{
  1.1154 +	*iSection = _L("Text");
  1.1155 +	Clear();
  1.1156 +	iCon->DrawText(_L("Text printing..."),TPoint(0,iRect.iTl.iY));
  1.1157 +	iCon->DrawText(_L("Text printing..."),TPoint(0,iRect.iBr.iY));
  1.1158 +	Clear();
  1.1159 +	iCon->DrawText(_L("Out of bounds checking"),TPoint(-50,iRect.iBr.iY>>1));
  1.1160 +	iCon->DrawText(_L("Out of bounds checking"),TPoint(0,0));
  1.1161 +	iCon->DrawText(_L("Out of bounds checking"),TPoint(0,iRect.iBr.iY));
  1.1162 +	iCon->DrawText(_L("Out of bounds checking"),TPoint(iRect.iBr.iX,iRect.iBr.iY>>1));
  1.1163 +	}
  1.1164 +
  1.1165 +void TestGdi::DoBoxTextVertical()
  1.1166 +	{	
  1.1167 +	Clear(); 
  1.1168 +	
  1.1169 +	// Creates a font large enough to notice the text on screen
  1.1170 +	_LIT(KMyFontName,"Swiss");
  1.1171 +	CFont* myFont = NULL;
  1.1172 +	TFontSpec myFontSpec(KMyFontName,15);
  1.1173 +	User::LeaveIfError(iDev->GetNearestFontInPixels(myFont,myFontSpec));
  1.1174 +	iCon->UseFont(myFont);
  1.1175 +	
  1.1176 +	TInt boxWidth = iSize.iWidth/4;
  1.1177 +	TInt boxHeightOffset = iSize.iHeight-5;
  1.1178 +		
  1.1179 +	TRect box1 (5, 5, boxWidth-5, boxHeightOffset);
  1.1180 +	TRect box2 (boxWidth+5, 5, 2*boxWidth-5, boxHeightOffset);
  1.1181 +	TRect box3 (2*boxWidth+5, 5, 3*boxWidth-5, boxHeightOffset);
  1.1182 +	TRect box4 (3*boxWidth+5, 5, iSize.iWidth-25-2*myFont->HeightInPixels(), boxHeightOffset);
  1.1183 +	TRect box5 (iSize.iWidth-15-2*myFont->HeightInPixels(), 5, iSize.iWidth-15-myFont->HeightInPixels(), boxHeightOffset);
  1.1184 +	TRect box6 (iSize.iWidth-5-myFont->HeightInPixels(), 5, iSize.iWidth-5, boxHeightOffset);
  1.1185 +
  1.1186 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1187 +	iCon->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1188 +	iCon->DrawRect(box1);
  1.1189 +	iCon->DrawRect(box2);
  1.1190 +	iCon->DrawRect(box3);
  1.1191 +	iCon->DrawRect(box4);
  1.1192 +	iCon->DrawRect(box5);
  1.1193 +	iCon->DrawRect(box6);
  1.1194 +	
  1.1195 +	/* Text drawn when baseline = font ascent.
  1.1196 +	   Expected result: The top of the text will be aligned with the borders of the
  1.1197 +	   box.
  1.1198 +	*/
  1.1199 +	// Upper right corner of the box
  1.1200 +    iCon->SetPenColor(KRgbRed);
  1.1201 +    iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , EFalse, CGraphicsContext::ELeft);
  1.1202 +	// Lower right corner of the box
  1.1203 +    iCon->SetPenColor(KRgbBlue);
  1.1204 +    iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , EFalse, CGraphicsContext::ERight);
  1.1205 +	// Upper left corner of the box
  1.1206 +    iCon->SetPenColor(KRgbGreen);
  1.1207 +    iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , ETrue, CGraphicsContext::ERight);
  1.1208 +	// Lower right corner of the box
  1.1209 +    iCon->SetPenColor(KRgbBlack);
  1.1210 +    iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , ETrue, CGraphicsContext::ELeft);
  1.1211 +
  1.1212 +	/* Text drawn when baseline = 0.
  1.1213 +	   Expected result: The text will be hidden in this case as it is drawn outside 
  1.1214 +	   the borders of the box. Only the parts in the font descent will be shown. 
  1.1215 +	*/
  1.1216 +    iCon->SetPenColor(KRgbRed);
  1.1217 +    iCon->DrawTextVertical(_L("Testing"), box2, 0, EFalse, CGraphicsContext::ELeft);
  1.1218 +    iCon->SetPenColor(KRgbBlue);
  1.1219 +    iCon->DrawTextVertical(_L("Testing"), box2, 0, EFalse, CGraphicsContext::ERight);
  1.1220 +    iCon->SetPenColor(KRgbGreen);
  1.1221 +    iCon->DrawTextVertical(_L("Testing"), box2, 0, ETrue, CGraphicsContext::ERight);
  1.1222 +    iCon->SetPenColor(KRgbBlack);
  1.1223 +    iCon->DrawTextVertical(_L("Testing"), box2, 0, ETrue, CGraphicsContext::ELeft);
  1.1224 +
  1.1225 +	/* Text drawn when baseline = box width.
  1.1226 +	   Expected results: Text will be drawn on the side of the opposite edge and its
  1.1227 +	   descent part will be hidden.
  1.1228 +	*/
  1.1229 +    iCon->SetPenColor(KRgbRed);
  1.1230 +    iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), EFalse, CGraphicsContext::ELeft);
  1.1231 +    iCon->SetPenColor(KRgbBlue);
  1.1232 +    iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), EFalse, CGraphicsContext::ERight);
  1.1233 +    iCon->SetPenColor(KRgbGreen);
  1.1234 +    iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), ETrue, CGraphicsContext::ERight);
  1.1235 +    iCon->SetPenColor(KRgbBlack);
  1.1236 +    iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), ETrue, CGraphicsContext::ELeft);
  1.1237 +
  1.1238 +	/* Text drawn when baseline = box width + font ascent.
  1.1239 +	   Expected result: text will not be shown at all as it lies outside the box totally.
  1.1240 +	*/
  1.1241 +    iCon->SetPenColor(KRgbRed);
  1.1242 +    iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), EFalse, CGraphicsContext::ELeft);
  1.1243 +    iCon->SetPenColor(KRgbBlue);
  1.1244 +    iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), EFalse, CGraphicsContext::ERight);
  1.1245 +    iCon->SetPenColor(KRgbGreen);
  1.1246 +    iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), ETrue, CGraphicsContext::ERight);
  1.1247 +    iCon->SetPenColor(KRgbBlack);
  1.1248 +    iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), ETrue, CGraphicsContext::ELeft);
  1.1249 +
  1.1250 +	/* Text drawn when baseline = font ascent while the width of teh box = font height
  1.1251 +	   Expected result: text will be aligned in the center of the box
  1.1252 +	*/
  1.1253 +    iCon->SetPenColor(KRgbRed);
  1.1254 +    iCon->DrawTextVertical(_L("Testing"), box5, myFont->AscentInPixels(), EFalse, CGraphicsContext::ELeft);
  1.1255 +    iCon->SetPenColor(KRgbBlack);
  1.1256 +    iCon->DrawTextVertical(_L("Testing"), box5, myFont->AscentInPixels(), EFalse, CGraphicsContext::ERight);
  1.1257 +    iCon->SetPenColor(KRgbRed);
  1.1258 +    iCon->DrawTextVertical(_L("Testing"), box6, myFont->AscentInPixels(), ETrue, CGraphicsContext::ELeft);
  1.1259 +    iCon->SetPenColor(KRgbBlack);
  1.1260 +    iCon->DrawTextVertical(_L("Testing"), box6, myFont->AscentInPixels(), ETrue, CGraphicsContext::ERight);
  1.1261 +
  1.1262 +	iCon->DiscardFont();
  1.1263 +	iDev->ReleaseFont(myFont);
  1.1264 +	}
  1.1265 +	
  1.1266 +void TestGdi::DoPaintL()
  1.1267 +	{
  1.1268 +	*iSection = _L("Painting");
  1.1269 +	Clear();
  1.1270 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1271 +	iCon->DrawRect(iRect);
  1.1272 +	CheckRectInsideL(iRect);
  1.1273 +	CheckRectOutsideL(iRect);
  1.1274 +	Clear();
  1.1275 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1276 +	iCon->DrawRect(iCentredRect);
  1.1277 +	CheckRectInsideL(iCentredRect);
  1.1278 +	CheckRectOutsideL(iCentredRect);
  1.1279 +	Clear();
  1.1280 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1281 +	for(TInt count=0;count<8;count++)
  1.1282 +		iCon->DrawRect(iOffScreenRects[count]);
  1.1283 +	CheckClearL();
  1.1284 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1285 +	iCon->DrawEllipse(iRect);
  1.1286 +	CheckRectOutsideL(iRect);
  1.1287 +	CheckQuadInsideL(iRect);
  1.1288 +	Clear();
  1.1289 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1290 +	iCon->DrawRoundRect(iRect,TSize(20,10));
  1.1291 +	CheckRectOutsideL(iRect);
  1.1292 +	CheckQuadInsideL(iRect);
  1.1293 +	Clear();
  1.1294 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1295 +	iCon->DrawRect(iLargeRect);
  1.1296 +	CheckRectInsideL(TRect(TPoint(0,0),iSize));
  1.1297 +	CheckQuadInsideL(TRect(TPoint(0,0),iSize));
  1.1298 +	Clear();
  1.1299 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1300 +	iCon->DrawEllipse(iLargeRect);
  1.1301 +	CheckQuadInsideL(TRect(TPoint(0,0),iSize));
  1.1302 +	Clear();
  1.1303 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1304 +	iCon->DrawRoundRect(iLargeRect,TSize(20,10));
  1.1305 +	CheckQuadInsideL(TRect(TPoint(0,0),iSize));
  1.1306 +	Clear();
  1.1307 +	}
  1.1308 +
  1.1309 +void TestGdi::DoCopyL()
  1.1310 +	{
  1.1311 +	*iSection = _L("Copying");
  1.1312 +	Clear();
  1.1313 +	TInt a=iSize.iWidth;
  1.1314 +	TInt b=iSize.iHeight;
  1.1315 +	TInt c=a>>1;
  1.1316 +	TInt d=b>>1;
  1.1317 +	iCon->CopyRect(TPoint(-100,-100),TRect(-100,-100,-50,-50));
  1.1318 +	iCon->CopyRect(TPoint(100,100),TRect(-100,-100,-50,-50));
  1.1319 +	iCon->CopyRect(TPoint(100,100),TRect(-50,-50,50,50));
  1.1320 +	iCon->CopyRect(TPoint(-100,-100),TRect(-50,-50,50,50));
  1.1321 +	iCon->CopyRect(TPoint(-50,-50),TRect(0,0,50,50));
  1.1322 +	iCon->CopyRect(TPoint(1000,1000),TRect(0,0,50,50));
  1.1323 +	Clear();
  1.1324 +
  1.1325 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
  1.1326 +	iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1327 +	TRect center(c-10,d-10,c+10,d+10);
  1.1328 +	iCon->DrawRect(center);
  1.1329 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1330 +
  1.1331 +	iCon->CopyRect(TPoint(0,-25),center);
  1.1332 +	iCon->CopyRect(TPoint(25,-25),center);
  1.1333 +	iCon->CopyRect(TPoint(25,0),center);
  1.1334 +	iCon->CopyRect(TPoint(25,25),center);
  1.1335 +	iCon->CopyRect(TPoint(0,25),center);
  1.1336 +	iCon->CopyRect(TPoint(-25,25),center);
  1.1337 +	iCon->CopyRect(TPoint(-25,0),center);
  1.1338 +	iCon->CopyRect(TPoint(-25,-25),center);
  1.1339 +
  1.1340 +	for(TInt y=0;y<20;y++)
  1.1341 +		for(TInt x=0;x<20;x++)
  1.1342 +			{
  1.1343 +			TRgb pelcol;
  1.1344 +			iDev->GetPixel(pelcol,TPoint(c-10+x,d-10+y)); // centre
  1.1345 +			TRgb samplecol;
  1.1346 +			iDev->GetPixel(samplecol,TPoint(c-10+x,d-35+y)); // top
  1.1347 +			CheckL(samplecol==pelcol);
  1.1348 +			iDev->GetPixel(samplecol,TPoint(c+15+x,d-35+y)); // top right
  1.1349 +			CheckL(samplecol==pelcol);
  1.1350 +			iDev->GetPixel(samplecol,TPoint(c+15+x,d-10+y)); // right
  1.1351 +			CheckL(samplecol==pelcol);
  1.1352 +			iDev->GetPixel(samplecol,TPoint(c+15+x,d+15+y)); // bottom right
  1.1353 +			CheckL(samplecol==pelcol);
  1.1354 +			iDev->GetPixel(samplecol,TPoint(c-10+x,d+15+y)); // bottom
  1.1355 +			CheckL(samplecol==pelcol);
  1.1356 +			iDev->GetPixel(samplecol,TPoint(c-35+x,d+15+y)); // bottom left
  1.1357 +			CheckL(samplecol==pelcol);
  1.1358 +			iDev->GetPixel(samplecol,TPoint(c-35+x,d-10+y)); // left
  1.1359 +			CheckL(samplecol==pelcol);
  1.1360 +			iDev->GetPixel(samplecol,TPoint(c-35+x,d-35+y)); // top left
  1.1361 +			CheckL(samplecol==pelcol);
  1.1362 +			}
  1.1363 +	Clear();
  1.1364 +	}
  1.1365 +
  1.1366 +void TestGdi::DoBltL()
  1.1367 +	{
  1.1368 +	*iSection = _L("BitBlt");
  1.1369 +	TRect sample(0,0,8,8);
  1.1370 +	Clear();
  1.1371 +	TInt a=iSize.iWidth;
  1.1372 +	TInt b=iSize.iHeight;
  1.1373 +	TInt c=a>>1;
  1.1374 +	TInt d=b>>1;
  1.1375 +	iCon->BitBlt(TPoint(20,20),&iBitmap2,sample);
  1.1376 +	iCon->BitBlt(TPoint(c-20,20),&iBitmap2,sample);
  1.1377 +	iCon->BitBlt(TPoint(a-20,20),&iBitmap2,sample);
  1.1378 +	iCon->BitBlt(TPoint(a-20,d-20),&iBitmap2,sample);
  1.1379 +	iCon->BitBlt(TPoint(a-20,b-20),&iBitmap2,sample);
  1.1380 +	iCon->BitBlt(TPoint(c-20,b-20),&iBitmap2,sample);
  1.1381 +	iCon->BitBlt(TPoint(20,b-20),&iBitmap2,sample);
  1.1382 +	iCon->BitBlt(TPoint(20,d-20),&iBitmap2,sample);
  1.1383 +	iCon->SetBrushOrigin(TPoint(c-20,d-20));
  1.1384 +	iCon->DrawRect(TRect(c-20,d-20,c+20,d+20));
  1.1385 +	for(TInt y=0;y<8;y++)
  1.1386 +		for(TInt x=0;x<8;x++)
  1.1387 +			{
  1.1388 +			TRgb pelcol,samplecol;
  1.1389 +			iDev->GetPixel(pelcol,TPoint(c-20+x,d-20+y));
  1.1390 +			iDev->GetPixel(samplecol,TPoint(20+x,20+y));
  1.1391 +			CheckL(samplecol==pelcol);
  1.1392 +			iDev->GetPixel(samplecol,TPoint(c-20+x,20+y));
  1.1393 +			CheckL(samplecol==pelcol);
  1.1394 +			iDev->GetPixel(samplecol,TPoint(a-20+x,20+y));
  1.1395 +			CheckL(samplecol==pelcol);
  1.1396 +			iDev->GetPixel(samplecol,TPoint(a-20+x,d-20+y));
  1.1397 +			CheckL(samplecol==pelcol);
  1.1398 +			iDev->GetPixel(samplecol,TPoint(a-20+x,b-20+y));
  1.1399 +			CheckL(samplecol==pelcol);
  1.1400 +			iDev->GetPixel(samplecol,TPoint(c-20+x,b-20+y));
  1.1401 +			CheckL(samplecol==pelcol);
  1.1402 +			iDev->GetPixel(samplecol,TPoint(20+x,b-20+y));
  1.1403 +			CheckL(samplecol==pelcol);
  1.1404 +			iDev->GetPixel(samplecol,TPoint(20+x,d-20+y));
  1.1405 +			CheckL(samplecol==pelcol);
  1.1406 +			}
  1.1407 +	Clear();
  1.1408 +	for(TInt count=0;count<8;count++)
  1.1409 +		iCon->BitBlt(iOffScreenRects[count].iTl,&iBitmap2,sample);
  1.1410 +	CheckClearL();
  1.1411 +	}
  1.1412 +
  1.1413 +void TestGdi::DoBltMaskedL()
  1.1414 +	{
  1.1415 +	*iSection = _L("BitBltMasked");
  1.1416 +	TSize bmpsize(iBitmap.SizeInPixels());
  1.1417 +	TRect bmprect(bmpsize);
  1.1418 +	TInt x,y;
  1.1419 +	TRgb bmpcol,samplecol;
  1.1420 +
  1.1421 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
  1.1422 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1423 +	iCon->SetBrushColor(KRgbBlack);
  1.1424 +	iCon->Clear();
  1.1425 +	iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,ETrue);
  1.1426 +	for(y=0;y<bmprect.iBr.iY;y++)
  1.1427 +		{
  1.1428 +		for(x=0;x<bmprect.iBr.iX;x++)
  1.1429 +			{
  1.1430 +			iBitmap.GetPixel(bmpcol,TPoint(x,y));
  1.1431 +			iDev->GetPixel(samplecol,TPoint(x,y));
  1.1432 +			if(bmpcol.Gray2())
  1.1433 +				CheckL(samplecol.Gray2()==0);
  1.1434 +			else
  1.1435 +				CheckL(samplecol.Gray2()==bmpcol.Gray2());
  1.1436 +			}
  1.1437 +		}
  1.1438 +	iCon->Clear();
  1.1439 +	iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,EFalse);
  1.1440 +	for(y=0;y<bmprect.iBr.iY;y++)
  1.1441 +		{
  1.1442 +		for(x=0;x<bmprect.iBr.iX;x++)
  1.1443 +			{
  1.1444 +			iBitmap.GetPixel(bmpcol,TPoint(x,y));
  1.1445 +			iDev->GetPixel(samplecol,TPoint(x,y));
  1.1446 +			if(bmpcol.Gray2())
  1.1447 +				CheckL(samplecol.Gray2()==bmpcol.Gray2());
  1.1448 +			else
  1.1449 +				CheckL(samplecol.Gray2()==0);
  1.1450 +			}
  1.1451 +		}
  1.1452 +	iCon->SetBrushColor(KRgbWhite);
  1.1453 +	iCon->Clear();
  1.1454 +	iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,ETrue);
  1.1455 +	for(y=0;y<bmprect.iBr.iY;y++)
  1.1456 +		{
  1.1457 +		for(x=0;x<bmprect.iBr.iX;x++)
  1.1458 +			{
  1.1459 +			iBitmap.GetPixel(bmpcol,TPoint(x,y));
  1.1460 +			iDev->GetPixel(samplecol,TPoint(x,y));
  1.1461 +			if(bmpcol.Gray2())
  1.1462 +				CheckL(samplecol.Gray2()==1);
  1.1463 +			else
  1.1464 +				CheckL(samplecol.Gray2()==bmpcol.Gray2());
  1.1465 +			}
  1.1466 +		}
  1.1467 +	iCon->Clear();
  1.1468 +	iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,EFalse);
  1.1469 +	for(y=0;y<bmprect.iBr.iY;y++)
  1.1470 +		{
  1.1471 +		for(x=0;x<bmprect.iBr.iX;x++)
  1.1472 +			{
  1.1473 +			iBitmap.GetPixel(bmpcol,TPoint(x,y));
  1.1474 +			iDev->GetPixel(samplecol,TPoint(x,y));
  1.1475 +			if(bmpcol.Gray2())
  1.1476 +				CheckL(samplecol.Gray2()==bmpcol.Gray2());
  1.1477 +			else
  1.1478 +				CheckL(samplecol.Gray2()==1);
  1.1479 +			}
  1.1480 +		}
  1.1481 +	Clear();
  1.1482 +	CheckClearL();
  1.1483 +	TPoint offscreenpoint(0,iSize.iHeight<<1);
  1.1484 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1485 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1486 +	offscreenpoint.iX-=(bmpsize.iWidth<<1);
  1.1487 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1488 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1489 +	offscreenpoint.iX=(iSize.iWidth<<1);
  1.1490 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1491 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1492 +	offscreenpoint.SetXY(0,-(bmpsize.iHeight<<1));
  1.1493 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1494 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1495 +	offscreenpoint.iX-=(bmpsize.iWidth<<1);
  1.1496 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1497 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1498 +	offscreenpoint.iX=(iSize.iWidth<<1);
  1.1499 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1500 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1501 +	offscreenpoint.SetXY(0,0);
  1.1502 +	offscreenpoint.iX-=(bmpsize.iWidth<<1);
  1.1503 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1504 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1505 +	offscreenpoint.iX=(iSize.iWidth<<1);
  1.1506 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse);
  1.1507 +	iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue);
  1.1508 +	CheckClearL();
  1.1509 +	}
  1.1510 +
  1.1511 +void TestGdi::DoBltCompressedL()
  1.1512 +	{
  1.1513 +	//NOTE: max assumed screen size is 100x100 the same as EMbmTgdiDrawbitmap
  1.1514 +	
  1.1515 +	*iSection = _L("DoBltCompressedL");
  1.1516 +	CFbsBitmap bitmap;
  1.1517 +	TInt ret = bitmap.Load(_L("z:\\system\\data\\tgdi.mbm"),EMbmTgdiDrawbitmap,EFalse);
  1.1518 +	CFbsBitmap compressedBitmap;
  1.1519 +	ret = compressedBitmap.LoadAndCompress(_L("z:\\system\\data\\tgdi.mbm"),EMbmTgdiDrawbitmap,EFalse);
  1.1520 +	User::LeaveIfError(ret);
  1.1521 +	
  1.1522 +	//bitblt
  1.1523 +	*iSection = _L("DoBltCompressedL - bitblt first part of lines");
  1.1524 +	Clear();
  1.1525 +	TInt startx=20;
  1.1526 +	TInt starty=20;
  1.1527 +	TInt width=iSize.iWidth;
  1.1528 +	TInt height=iSize.iHeight;
  1.1529 +	TInt repeatx=width>>1;
  1.1530 +	TInt repeaty=height>>1;
  1.1531 +	TRect sample1(startx,0,repeatx-2*startx,repeaty);
  1.1532 +	TRgb pelcol,samplecol;
  1.1533 +	iCon->BitBlt(TPoint(startx,starty),&bitmap,sample1);
  1.1534 +	iCon->BitBlt(TPoint(repeatx-startx,starty),&compressedBitmap,sample1);
  1.1535 +	for(TInt y=0;y<repeaty;y++)
  1.1536 +		{
  1.1537 +		for(TInt x=startx;x<repeatx-2*startx;x++)
  1.1538 +			{
  1.1539 +			iDev->GetPixel(pelcol,TPoint(repeatx-startx+x,starty+y));
  1.1540 +			iDev->GetPixel(samplecol,TPoint(startx+x,starty+y));
  1.1541 +			CheckL(samplecol==pelcol);
  1.1542 +			}
  1.1543 +		}
  1.1544 +	*iSection = _L("DoBltCompressedL - bitblt multiple complete lines - columns");
  1.1545 +	Clear();
  1.1546 +	TRect sample2(0,0,bitmap.SizeInPixels().iWidth,50);
  1.1547 +	iCon->BitBlt(TPoint(0,0),&bitmap,sample2);
  1.1548 +	iCon->BitBlt(TPoint(0,50),&compressedBitmap,sample2);
  1.1549 +	for(TInt y=0;y<50;y++)
  1.1550 +		{
  1.1551 +		for(TInt x=0;x<bitmap.SizeInPixels().iWidth;x++)
  1.1552 +			{
  1.1553 +			iDev->GetPixel(pelcol,TPoint(x,y));
  1.1554 +			iDev->GetPixel(samplecol,TPoint(x,50+y));
  1.1555 +			CheckL(samplecol==pelcol);
  1.1556 +			}
  1.1557 +		}
  1.1558 +	
  1.1559 +	*iSection = _L("DoBltCompressedL - bitblt final part of lines");
  1.1560 +	Clear();
  1.1561 +	TRect sample3(0,0,50,100);
  1.1562 +	iCon->BitBlt(TPoint(0,0),&bitmap,sample3);
  1.1563 +	iCon->BitBlt(TPoint(50,0),&compressedBitmap,sample3);
  1.1564 +	for(TInt y=0;y<100;y++)
  1.1565 +		{
  1.1566 +		for(TInt x=0;x<50;x++)
  1.1567 +			{
  1.1568 +			iDev->GetPixel(pelcol,TPoint(x,y));
  1.1569 +			iDev->GetPixel(samplecol,TPoint(50+x,y));
  1.1570 +			CheckL(samplecol==pelcol);
  1.1571 +			}
  1.1572 +		}
  1.1573 +
  1.1574 +	*iSection = _L("DoBltCompressedL - bitbltmasked flickerv2");
  1.1575 +	Clear();
  1.1576 +	TRect sample4(0,0,50,100);
  1.1577 +	// Due to inconsistent handling of solid brushes between different colour modes, the
  1.1578 +	// screen or a bitmap, accelerated or non-accelerated do this test with a null brush.
  1.1579 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1580 +	iCon->BitBltMasked(TPoint(0,0),&bitmap,sample4,&iBitmap,ETrue);
  1.1581 +	iCon->BitBltMasked(TPoint(50,0),&compressedBitmap,sample4,&iBitmap,ETrue);
  1.1582 +	for(TInt y=0;y<100;y++)
  1.1583 +		{
  1.1584 +		for(TInt x=0;x<50;x++)
  1.1585 +			{
  1.1586 +			iDev->GetPixel(pelcol,TPoint(x,y));
  1.1587 +			iDev->GetPixel(samplecol,TPoint(50+x,y));
  1.1588 +			CheckL(samplecol==pelcol);
  1.1589 +			}
  1.1590 +		}
  1.1591 +
  1.1592 +	*iSection = _L("DoBltCompressedL - bitbltmasked needbitmaps of same mode");
  1.1593 +	Clear();
  1.1594 +	TRect sample5(0,0,50,100);
  1.1595 +	iCon->BitBltMasked(TPoint(0,0),&bitmap,sample5,&compressedBitmap,ETrue);
  1.1596 +	iCon->BitBltMasked(TPoint(50,0),&compressedBitmap,sample5,&bitmap,ETrue);
  1.1597 +	for(TInt y=0;y<100;y++)
  1.1598 +		{
  1.1599 +		for(TInt x=0;x<50;x++)
  1.1600 +			{
  1.1601 +			iDev->GetPixel(pelcol,TPoint(x,y));
  1.1602 +			iDev->GetPixel(samplecol,TPoint(50+x,y));
  1.1603 +			CheckL(samplecol==pelcol);
  1.1604 +			}
  1.1605 +		}
  1.1606 +
  1.1607 +	*iSection = _L("DoBltCompressedL - bitbltmasked same bitmap as mask");
  1.1608 +	Clear();
  1.1609 +	TRect target6(0,0,50,100);
  1.1610 +	TRect sample6(0,0,50,100);
  1.1611 +	iCon->DrawBitmapMasked(target6,&bitmap,sample6,&bitmap,ETrue);
  1.1612 +	target6.Move(50,0);
  1.1613 +	iCon->DrawBitmapMasked(target6,&compressedBitmap,sample6,&compressedBitmap,ETrue);
  1.1614 +	for(TInt y=0;y<100;y++)
  1.1615 +		{
  1.1616 +		for(TInt x=0;x<50;x++)
  1.1617 +			{
  1.1618 +			iDev->GetPixel(pelcol,TPoint(x,y));
  1.1619 +			iDev->GetPixel(samplecol,TPoint(50+x,y));
  1.1620 +			CheckL(samplecol==pelcol);
  1.1621 +			}
  1.1622 +		}
  1.1623 +	}
  1.1624 +
  1.1625 +void TestGdi::DoShadowL()
  1.1626 +	{
  1.1627 +	*iSection = _L("Shadow");
  1.1628 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
  1.1629 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1630 +	TInt halfwidth=iSize.iWidth>>1;
  1.1631 +	TRect lhs(TSize(halfwidth,iSize.iHeight));
  1.1632 +	TRect rhs(TPoint(halfwidth,0),TSize(iSize.iWidth,iSize.iHeight));
  1.1633 +	TRegionFix<1> area(lhs);
  1.1634 +	TPoint lhspt(halfwidth>>1,iSize.iHeight>>1);
  1.1635 +	TPoint rhspt(halfwidth+(halfwidth>>1),iSize.iHeight>>1);
  1.1636 +	TRgb lhsrgb,rhsrgb;
  1.1637 +
  1.1638 +	for (TInt count = 0; count < 32; count++)
  1.1639 +		{
  1.1640 +		TRgb brushColor;
  1.1641 +		if (count < 16)
  1.1642 +			brushColor = TRgb::Gray16(count);
  1.1643 +		else
  1.1644 +			brushColor = TRgb::Color16(count - 16);
  1.1645 +
  1.1646 +		iCon->DrawRect(lhs);
  1.1647 +		iCon->ShadowArea(&area);
  1.1648 +		iCon->SetShadowMode(ETrue);
  1.1649 +		iCon->DrawRect(rhs);
  1.1650 +		iDev->GetPixel(lhsrgb,lhspt);
  1.1651 +		iDev->GetPixel(rhsrgb,rhspt);
  1.1652 +		CheckL(lhsrgb==rhsrgb);
  1.1653 +		iCon->SetShadowMode(EFalse);
  1.1654 +		}
  1.1655 +	Clear();
  1.1656 +	}
  1.1657 +
  1.1658 +/**
  1.1659 + Auxiliary Fn to check the Pixel values 
  1.1660 +
  1.1661 + This method checks the pixel values with respective calculated values based on the call 
  1.1662 + from DoDrawBitmapMaskedL
  1.1663 +
  1.1664 +*/
  1.1665 +void TestGdi::CheckMaskedResultsL(CFbsBitmap* aBgBmp,CFbsBitmap* aSrcBmp,CFbsBitmap* aMaskBmp,TRect& aTarRect,TBool aInvertMask,TBool aAlphaBlend, TBool aSemiTransparentMask/*=EFalse*/)
  1.1666 +	{
  1.1667 +	TInt width=0;
  1.1668 +	TInt height=0;
  1.1669 +	TInt rowIndex=0;
  1.1670 +	TInt colIndex=0;
  1.1671 +	width=aTarRect.Width();
  1.1672 +	height=aTarRect.Height();
  1.1673 +	// Check the size of the target rectangle is negative or zero
  1.1674 +	if (width<0 || !width || height<0 || !height)
  1.1675 +		{
  1.1676 +		return;
  1.1677 +		}
  1.1678 +	// Check the size of the target rectangle falls out side the display screen size
  1.1679 +	if (width>iSize.iWidth)
  1.1680 +		{
  1.1681 +		width=iSize.iWidth;
  1.1682 +		}
  1.1683 +	if (height>iSize.iHeight)
  1.1684 +		{
  1.1685 +		height=iSize.iHeight;
  1.1686 +		}
  1.1687 +	// Rectangle used locally and it starts top left corner.(0,0)
  1.1688 +	TRect rect(0,0,width,height);
  1.1689 +	TSize size(rect.Size());
  1.1690 +	TDisplayMode devDisplayMode=iDev->DisplayMode();
  1.1691 +	//Create background bitmap with the size equal to target rectangle
  1.1692 +	CFbsBitmap* backgroundBmp = new (ELeave) CFbsBitmap;
  1.1693 +	CleanupStack::PushL(backgroundBmp);
  1.1694 +	User::LeaveIfError(backgroundBmp->Create(size,devDisplayMode));
  1.1695 +	//Create src bitmap with the size equal to target rectangle
  1.1696 +	CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap;
  1.1697 +	CleanupStack::PushL(srcBmp);
  1.1698 +	User::LeaveIfError(srcBmp->Create(size,iDev->DisplayMode()));
  1.1699 +	//Create mask bitmap with the size equal to target rectangle
  1.1700 +	CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap;
  1.1701 +	CleanupStack::PushL(maskBmp);
  1.1702 +	TDisplayMode maskDisplayMode;
  1.1703 +	if (aSrcBmp==aMaskBmp) // When the source and target are same
  1.1704 +		{
  1.1705 +		maskDisplayMode=devDisplayMode;
  1.1706 +		}
  1.1707 +	else if (aAlphaBlend) // display mode based on the aAlphablend flag
  1.1708 +		{
  1.1709 +		maskDisplayMode=EGray256;
  1.1710 +		}
  1.1711 +	else
  1.1712 +		{
  1.1713 +		maskDisplayMode=aMaskBmp->DisplayMode();
  1.1714 + 		}
  1.1715 +	User::LeaveIfError(maskBmp->Create(size,maskDisplayMode));
  1.1716 +	//Creating bitmap device for calculation and comparison
  1.1717 +	CFbsBitmapDevice *bgDevice=CFbsBitmapDevice::NewL(backgroundBmp);
  1.1718 +	CleanupStack::PushL(bgDevice);
  1.1719 +	CFbsBitGc* bgGc=NULL;
  1.1720 +	User::LeaveIfError(bgDevice->CreateContext(bgGc));
  1.1721 +	CleanupStack::PushL(bgGc);
  1.1722 +	if (width==iBitmapWidth && height==iBitmapHeight || aTarRect.Width()<=iSize.iWidth && aTarRect.Height()<=iSize.iHeight)
  1.1723 +		{
  1.1724 +		bgGc->DrawBitmap(rect,aBgBmp);
  1.1725 +		}
  1.1726 +	else
  1.1727 +		{
  1.1728 +		bgGc->DrawBitmap(aTarRect,aBgBmp);
  1.1729 +		}
  1.1730 +	CFbsBitmapDevice* maskDevice=CFbsBitmapDevice::NewL(maskBmp);	//For masked bitmap
  1.1731 +	CleanupStack::PushL(maskDevice);
  1.1732 +	CFbsBitGc* maskGc=NULL;
  1.1733 +	User::LeaveIfError(maskDevice->CreateContext(maskGc));
  1.1734 +	CleanupStack::PushL(maskGc);
  1.1735 +	if (width==iBitmapWidth && height==iBitmapHeight || aTarRect.Width()<=iSize.iWidth && aTarRect.Height()<=iSize.iHeight)
  1.1736 +		{
  1.1737 +		maskGc->DrawBitmap(rect,aMaskBmp);
  1.1738 +		}
  1.1739 +	else
  1.1740 +		{
  1.1741 +		maskGc->DrawBitmap(aTarRect,aMaskBmp);
  1.1742 +		}
  1.1743 +	CFbsBitmapDevice* srcDevice=CFbsBitmapDevice::NewL(srcBmp);	//For source bitmap
  1.1744 +	CleanupStack::PushL(srcDevice);
  1.1745 +	CFbsBitGc* srcGc=NULL;
  1.1746 +	User::LeaveIfError(srcDevice->CreateContext(srcGc));
  1.1747 +	CleanupStack::PushL(srcGc);
  1.1748 +	if (width==iBitmapWidth && height==iBitmapHeight || aTarRect.Width()<=iSize.iWidth && aTarRect.Height()<=iSize.iHeight)
  1.1749 +		{
  1.1750 +		srcGc->DrawBitmap(rect,aSrcBmp);
  1.1751 +		}
  1.1752 +	else
  1.1753 +		{
  1.1754 +		srcGc->DrawBitmap(aTarRect,aSrcBmp);
  1.1755 +		}
  1.1756 +
  1.1757 +	for (rowIndex=0;rowIndex<height;++rowIndex)
  1.1758 +		{
  1.1759 +		TInt redinversemask=0;
  1.1760 +		TInt redmaskvalue=0;
  1.1761 +		TInt greeninversemask=0;
  1.1762 +		TInt greenmaskvalue=0;
  1.1763 +		TInt blueinversemask=0;
  1.1764 +		TInt bluemaskvalue=0;
  1.1765 +		TRgb bmpcol;
  1.1766 +		TRgb samplecol;
  1.1767 +		TRgb maskcol;
  1.1768 +		for (colIndex=0;colIndex<width;++colIndex)
  1.1769 +			{
  1.1770 +			srcDevice->GetPixel(bmpcol,TPoint(colIndex,rowIndex));
  1.1771 +			iDev->GetPixel(samplecol,aTarRect.iTl+TPoint(colIndex,rowIndex));
  1.1772 +			TRgb backgroundcolor;
  1.1773 +			bgDevice->GetPixel(backgroundcolor,TPoint(colIndex,rowIndex));
  1.1774 +			maskDevice->GetPixel(maskcol,TPoint(colIndex,rowIndex));
  1.1775 +			if (aInvertMask && (maskDisplayMode!=EGray256 || aAlphaBlend))
  1.1776 +				{
  1.1777 +				redinversemask=maskcol.Red(); // green and blue should have the same value for gray-scale bitmap
  1.1778 +				redmaskvalue=MAXCOLORS-redinversemask;
  1.1779 +				blueinversemask=maskcol.Blue(); 
  1.1780 +				bluemaskvalue=MAXCOLORS-blueinversemask;
  1.1781 +				greeninversemask=maskcol.Green(); 
  1.1782 +				greenmaskvalue=MAXCOLORS-greeninversemask;
  1.1783 +				}
  1.1784 +			else
  1.1785 +				{
  1.1786 +				redmaskvalue=maskcol.Red();
  1.1787 +				redinversemask=MAXCOLORS-redmaskvalue;
  1.1788 +				bluemaskvalue=maskcol.Blue();
  1.1789 +				blueinversemask=MAXCOLORS-bluemaskvalue;
  1.1790 +				greenmaskvalue=maskcol.Green();
  1.1791 +				greeninversemask=MAXCOLORS-greenmaskvalue;
  1.1792 +				}
  1.1793 +			TInt red;
  1.1794 +			TInt green;
  1.1795 +			TInt blue;
  1.1796 +			if (aSemiTransparentMask && devDisplayMode!=EGray256)
  1.1797 +				{
  1.1798 +				if (devDisplayMode==EColor64K || devDisplayMode==EColor256 || devDisplayMode==EColor4K || devDisplayMode==EColor16M || aInvertMask)
  1.1799 +					{
  1.1800 +					red=(bmpcol.Red()*redmaskvalue+backgroundcolor.Red()*redinversemask)>>8;
  1.1801 +					green=(bmpcol.Green()*greenmaskvalue+backgroundcolor.Green()*greeninversemask)>>8;
  1.1802 +					blue=(bmpcol.Blue()*bluemaskvalue+backgroundcolor.Blue()*blueinversemask)>>8;
  1.1803 +					}
  1.1804 +				else
  1.1805 +					{
  1.1806 +					red=(bmpcol.Red()*(redmaskvalue+1))>>8;
  1.1807 +					red+=(backgroundcolor.Red()*(redinversemask+1))>>8;
  1.1808 +					green=(bmpcol.Green()*(greenmaskvalue+1))>>8;
  1.1809 +					green+=(backgroundcolor.Green()*(greeninversemask+1))>>8;
  1.1810 +					blue=(bmpcol.Blue()*(bluemaskvalue+1))>>8;
  1.1811 +					blue+=(backgroundcolor.Blue()*(blueinversemask+1))>>8;
  1.1812 +					}
  1.1813 +				}
  1.1814 +			else
  1.1815 +				{
  1.1816 +				red=((bmpcol.Red()*redmaskvalue)+(backgroundcolor.Red()*redinversemask));
  1.1817 +				green=((bmpcol.Green()*greenmaskvalue)+(backgroundcolor.Green()*greeninversemask));
  1.1818 +				blue=((bmpcol.Blue()*bluemaskvalue)+(backgroundcolor.Blue()*blueinversemask));
  1.1819 +				red   = red / MAXCOLORS;
  1.1820 +				green = green / MAXCOLORS;
  1.1821 +				blue  = blue / MAXCOLORS;
  1.1822 +				}
  1.1823 +
  1.1824 +			TRgb rgb(red,green,blue);
  1.1825 +			TRgb resultantColor;
  1.1826 +			TUint index;
  1.1827 +			switch(devDisplayMode)
  1.1828 +				{
  1.1829 +				case EGray2:
  1.1830 +					{
  1.1831 +					index = TRgb::Gray2(blue).Gray2();
  1.1832 +					resultantColor = TRgb::Gray2(index);
  1.1833 +					break;
  1.1834 +					}
  1.1835 +				case EGray256:
  1.1836 +					{
  1.1837 +					index = rgb.Gray256();
  1.1838 +					resultantColor = TRgb::Gray256(index);
  1.1839 +					break;
  1.1840 +					}
  1.1841 +				case EColor256:
  1.1842 +					{
  1.1843 +					index = rgb.Color256();
  1.1844 +					resultantColor = TRgb::Color256(index);
  1.1845 +					break;
  1.1846 +					}
  1.1847 +				case EColor4K:
  1.1848 +					{
  1.1849 +					index = rgb.Color4K();
  1.1850 +					resultantColor = TRgb::Color4K(index);
  1.1851 +					break;
  1.1852 +					}
  1.1853 +				case EColor64K:
  1.1854 +					{
  1.1855 +					index = rgb.Color64K();
  1.1856 +					resultantColor = TRgb::Color64K(index);
  1.1857 +					break;
  1.1858 +					}
  1.1859 +				case EColor16M:
  1.1860 +					{
  1.1861 +					index = rgb.Color16M();
  1.1862 +					resultantColor = TRgb::Color16M(index);
  1.1863 +					break;
  1.1864 +					}
  1.1865 +				case EColor16MU:
  1.1866 +					{
  1.1867 +					index = rgb.Color16MU();
  1.1868 +					resultantColor = TRgb::Color16MU(index);
  1.1869 +					break;
  1.1870 +					}
  1.1871 +				}
  1.1872 +			CheckL(samplecol.Red()==resultantColor.Red()); 
  1.1873 +			CheckL(samplecol.Green()==resultantColor.Green());
  1.1874 +			CheckL(samplecol.Blue()==resultantColor.Blue());
  1.1875 +			}
  1.1876 +		}
  1.1877 +	CleanupStack::PopAndDestroy(9,backgroundBmp);
  1.1878 +	}
  1.1879 +
  1.1880 +/**
  1.1881 + @SYMTestCaseID GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001
  1.1882 + 
  1.1883 + @SYMPREQ 642
  1.1884 + 
  1.1885 + @SYMREQ 
  1.1886 +   
  1.1887 + @SYMTestCaseDesc  Test DrawMaskedBitmap (Transperency Stretched Bitmap).\n
  1.1888 + Automated Tests to test DrawBitmapMasked with different display modes.
  1.1889 + 
  1.1890 + @SYMTestPriority High
  1.1891 +  
  1.1892 + @SYMTestStatus Implemented
  1.1893 +   
  1.1894 + @SYMTestActions Creates bitmaps programmatically and calls API DrawBitmapMasked() with respective parameters
  1.1895 + Drawn pixels value with calculated pixels and verified using CheckL(), All the test cases specified in \n
  1.1896 + test specifications are implemented(22 test cases).
  1.1897 +   
  1.1898 + @SYMTestExpectedResults KErrNone 
  1.1899 +   
  1.1900 + */
  1.1901 +void TestGdi::DoDrawBitmapMaskedL(TBool aColorMask)
  1.1902 +	{
  1.1903 +	_LIT(KBitmapMasked,"DrawBitmapMasked - Test Case ");
  1.1904 +	*iSection = KBitmapMasked;
  1.1905 +	TInt rowIndex;
  1.1906 +	TInt colIndex;
  1.1907 +	TSize rectSize(iBitmapWidth,iBitmapHeight);
  1.1908 +	TRect srcRect;
  1.1909 +	TRect tarRect;
  1.1910 +	
  1.1911 +	CFbsBitmap* backgroundBmp = new (ELeave) CFbsBitmap;
  1.1912 +	CleanupStack::PushL(backgroundBmp);
  1.1913 +	User::LeaveIfError(backgroundBmp->Create(rectSize,iDev->DisplayMode()));
  1.1914 +	srcRect.SetSize(rectSize);
  1.1915 +	TBitmapUtil bmpUtil(backgroundBmp);
  1.1916 +	bmpUtil.Begin(TPoint(0,0));
  1.1917 +	for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.1918 +		{
  1.1919 +		TInt red=0;
  1.1920 +		TInt blue=255;
  1.1921 +		if(iDev->DisplayMode()==EGray2)
  1.1922 +			{	
  1.1923 +			blue=0;
  1.1924 +			}	
  1.1925 +		TInt green=0;
  1.1926 +		bmpUtil.SetPos(TPoint(0,rowIndex));
  1.1927 +		for (colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.1928 +			{
  1.1929 +			TRgb rgb(red,green,blue);
  1.1930 +			switch(iDev->DisplayMode())
  1.1931 +				{
  1.1932 +				case EGray2:
  1.1933 +					{
  1.1934 +					bmpUtil.SetPixel(TRgb::Gray2(blue).Gray2());
  1.1935 +					bmpUtil.IncXPos();
  1.1936 +					if (colIndex%4==0)
  1.1937 +						{
  1.1938 +						blue=255-blue;
  1.1939 +						}
  1.1940 +					continue;
  1.1941 +					}
  1.1942 +				case EGray256:
  1.1943 +					{
  1.1944 +					bmpUtil.SetPixel(rgb.Gray256());
  1.1945 +					break;
  1.1946 +					}
  1.1947 +				case EColor256:
  1.1948 +					{
  1.1949 +					bmpUtil.SetPixel(rgb.Color256());
  1.1950 +					break;
  1.1951 +					}
  1.1952 +				case EColor4K:
  1.1953 +					{
  1.1954 +					bmpUtil.SetPixel(rgb.Color4K());
  1.1955 +					break;
  1.1956 +					}
  1.1957 +				case EColor64K:
  1.1958 +					{
  1.1959 +					bmpUtil.SetPixel(rgb.Color64K());
  1.1960 +					break;
  1.1961 +					}
  1.1962 +				case EColor16M:
  1.1963 +					{
  1.1964 +					bmpUtil.SetPixel(rgb.Color16M());
  1.1965 +					break;
  1.1966 +					}
  1.1967 +				case EColor16MU:
  1.1968 +					{
  1.1969 +					bmpUtil.SetPixel(rgb.Color16MU());
  1.1970 +					break;
  1.1971 +					}
  1.1972 +				}
  1.1973 +			bmpUtil.IncXPos();
  1.1974 +			red+=10;
  1.1975 +			blue-=30;
  1.1976 +			green+=20;
  1.1977 +			if(red > 255)
  1.1978 +				{
  1.1979 +				red-=255;
  1.1980 +				green+=1;
  1.1981 +				}
  1.1982 +			if(green > 255)
  1.1983 +				{
  1.1984 +				green-=255;
  1.1985 +				blue-=1;
  1.1986 +				}
  1.1987 +			if(blue < 0)
  1.1988 +				{
  1.1989 +				blue+=255;
  1.1990 +				}
  1.1991 +			}
  1.1992 +		}
  1.1993 +	bmpUtil.End();
  1.1994 +	//Create source bitmap with various color scale
  1.1995 +	CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap;
  1.1996 +	CleanupStack::PushL(srcBmp);
  1.1997 +	User::LeaveIfError(srcBmp->Create(rectSize,iDev->DisplayMode()));
  1.1998 +	TBitmapUtil bmpUtil1(srcBmp);
  1.1999 +	bmpUtil1.Begin(TPoint(0,0));
  1.2000 +	TInt gray2=0;
  1.2001 +	for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2002 +		{
  1.2003 +		TInt red=255;
  1.2004 +		TInt blue=0;
  1.2005 +		TInt green=255;
  1.2006 +		bmpUtil1.SetPos(TPoint(0,rowIndex));
  1.2007 +		gray2=!gray2?0:255;
  1.2008 +		for (colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2009 +			{
  1.2010 +			TRgb rgb(red,green,blue);
  1.2011 +			switch(iDev->DisplayMode())
  1.2012 +				{
  1.2013 +				case EGray2:
  1.2014 +					{
  1.2015 +					bmpUtil1.SetPixel(TRgb::Gray2(gray2).Gray2());
  1.2016 +					bmpUtil1.IncXPos(); 				
  1.2017 +					red=0;
  1.2018 +					green=0;
  1.2019 +					blue=!blue?255:0;
  1.2020 +					continue;
  1.2021 +					}
  1.2022 +				case EGray256:
  1.2023 +					{
  1.2024 +					bmpUtil1.SetPixel(rgb.Gray256());
  1.2025 +					break;
  1.2026 +					}
  1.2027 +				case EColor256:
  1.2028 +					{
  1.2029 +					bmpUtil1.SetPixel(rgb.Color256());
  1.2030 +					break;
  1.2031 +					}
  1.2032 +				case EColor4K:
  1.2033 +					{
  1.2034 +					bmpUtil1.SetPixel(rgb.Color4K());
  1.2035 +					break;
  1.2036 +					}
  1.2037 +				case EColor64K:
  1.2038 +					{
  1.2039 +					bmpUtil1.SetPixel(rgb.Color64K());
  1.2040 +					break;
  1.2041 +					}
  1.2042 +				case EColor16M:
  1.2043 +					{
  1.2044 +					bmpUtil1.SetPixel(rgb.Color16M());
  1.2045 +					break;
  1.2046 +					}
  1.2047 +				case EColor16MU:
  1.2048 +					{
  1.2049 +					bmpUtil1.SetPixel(rgb.Color16MU());
  1.2050 +					break;
  1.2051 +					}
  1.2052 +				}
  1.2053 +			bmpUtil1.IncXPos();
  1.2054 +			red-=10;
  1.2055 +			blue+=10;
  1.2056 +			green-=10;
  1.2057 +			if(red <= 0)
  1.2058 +				{
  1.2059 +				red+=255;
  1.2060 +				}
  1.2061 +			if(blue >= 255)
  1.2062 +				{
  1.2063 +				blue-=255;
  1.2064 +				}
  1.2065 +			if(green <= 0)
  1.2066 +				{
  1.2067 +				green+=255;
  1.2068 +				}
  1.2069 +			}
  1.2070 +		}
  1.2071 +	bmpUtil1.End();
  1.2072 +	//Masked bitmap with various color scale
  1.2073 +	CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap;
  1.2074 +	CleanupStack::PushL(maskBmp);
  1.2075 +	TBitmapUtil bmpUtil2(maskBmp);
  1.2076 +	if(iDev->DisplayMode() == EGray2)
  1.2077 +		{
  1.2078 +		User::LeaveIfError(maskBmp->Create(rectSize,EGray2));
  1.2079 +		bmpUtil2.Begin(TPoint(0,0));
  1.2080 +		for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2081 +			{
  1.2082 +			bmpUtil2.SetPos(TPoint(0,rowIndex));
  1.2083 +			TInt blue=0;
  1.2084 +			for(colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2085 +				{
  1.2086 +				bmpUtil2.SetPixel(blue);
  1.2087 +				bmpUtil2.IncXPos();
  1.2088 +				blue=!blue?255:0;
  1.2089 +				}
  1.2090 +			}
  1.2091 +		bmpUtil2.End();
  1.2092 +		}
  1.2093 +	else
  1.2094 +		{
  1.2095 +		User::LeaveIfError(maskBmp->Create(rectSize,aColorMask?EColor256:EGray256));
  1.2096 +		bmpUtil2.Begin(TPoint(0,0));
  1.2097 +		for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2098 +			{
  1.2099 +			bmpUtil2.SetPos(TPoint(0,rowIndex));
  1.2100 +			TInt red=0;
  1.2101 +			TInt blue=0;
  1.2102 +			TInt green=0;
  1.2103 +			for(colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2104 +				{
  1.2105 +				TRgb rgb(red,green,blue);
  1.2106 +				bmpUtil2.SetPixel(rgb.Color256());
  1.2107 +				bmpUtil2.IncXPos();
  1.2108 +				red=!red?255:0;
  1.2109 +				blue=!blue?255:0;
  1.2110 +				green=!green?255:0;
  1.2111 +				}
  1.2112 +			}
  1.2113 +		bmpUtil2.End();
  1.2114 +		}
  1.2115 +	
  1.2116 +	//Masked bitmap with various gray scale (For Alphablending)
  1.2117 +	CFbsBitmap* maskblendBmp = new (ELeave) CFbsBitmap;
  1.2118 +	CleanupStack::PushL(maskblendBmp);
  1.2119 +	if(iDev->DisplayMode() == EGray2)
  1.2120 +		{
  1.2121 +		User::LeaveIfError(maskblendBmp->Create(rectSize,EGray2));
  1.2122 +		TBitmapUtil bmpUtil3(maskblendBmp);
  1.2123 +		bmpUtil3.Begin(TPoint(0,0));
  1.2124 +		TInt blue=0;
  1.2125 +		for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2126 +			{
  1.2127 +			bmpUtil3.SetPos(TPoint(0,rowIndex));
  1.2128 +			blue=0;
  1.2129 +			for(colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2130 +				{
  1.2131 +				bmpUtil3.SetPixel(blue);
  1.2132 +				bmpUtil3.IncXPos();
  1.2133 +				blue=!blue?255:0;
  1.2134 +				}
  1.2135 +			}
  1.2136 +		bmpUtil3.End();	
  1.2137 +		}
  1.2138 +	else
  1.2139 +		{
  1.2140 +		User::LeaveIfError(maskblendBmp->Create(rectSize,EGray256));
  1.2141 +		TBitmapUtil bmpUtil3(maskblendBmp);
  1.2142 +		bmpUtil3.Begin(TPoint(0,0));
  1.2143 +		for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2144 +			{
  1.2145 +			bmpUtil3.SetPos(TPoint(0,rowIndex));
  1.2146 +			TInt red=0;
  1.2147 +			TInt blue=0;
  1.2148 +			TInt green=0;
  1.2149 +			for(colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2150 +				{
  1.2151 +				TRgb rgb(red,green,blue);
  1.2152 +				bmpUtil3.SetPixel(rgb.Gray256());
  1.2153 +				bmpUtil3.IncXPos();
  1.2154 +				red=!red?255:0;
  1.2155 +				blue=!blue?255:0;
  1.2156 +				green=!green?255:0;
  1.2157 +				}
  1.2158 +			}
  1.2159 +		bmpUtil3.End();
  1.2160 +		}	
  1.2161 +	/**
  1.2162 +	  Test Cases 1 to 10 	 (AlphaBlending)
  1.2163 +	 
  1.2164 +	  Test Case # 1
  1.2165 +
  1.2166 +	  Desc	  : Test the functionality of DrawBitmapMasked() without 
  1.2167 +	  Stretching or compressing and with a normal mask.
  1.2168 +	 */
  1.2169 +	iSection->AppendNum(1);
  1.2170 +	iCon->DrawBitmap(srcRect,backgroundBmp,srcRect);
  1.2171 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2172 +	iCon->DrawBitmapMasked(srcRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2173 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,srcRect,EFalse,ETrue);
  1.2174 +	/**
  1.2175 +	  Test Case # 2
  1.2176 +
  1.2177 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2178 +	  when it stretches the bitmap and with a normal mask.
  1.2179 +	 */
  1.2180 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2181 +	iSection->AppendNum(2);
  1.2182 +	iCon->Clear();
  1.2183 +	tarRect.iTl.SetXY(0,0);
  1.2184 +	tarRect.SetWidth(iBitmapWidth*2);
  1.2185 +	tarRect.SetHeight(iBitmapHeight*2);
  1.2186 +	if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height())
  1.2187 +		{
  1.2188 +		iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2189 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2190 +		iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);	
  1.2191 +		CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2192 +		}
  1.2193 +	/**
  1.2194 +	  Test Case # 3
  1.2195 +
  1.2196 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2197 +	  when it compresses the bitmap and with a normal mask.
  1.2198 +	 */
  1.2199 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2200 +	iSection->AppendNum(3);
  1.2201 +	iCon->Clear();
  1.2202 +	tarRect.iTl.SetXY(0,0);
  1.2203 +	tarRect.SetWidth(iBitmapWidth/2);
  1.2204 +	tarRect.SetHeight(iBitmapHeight/2);
  1.2205 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2206 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2207 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2208 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2209 +	/** 
  1.2210 +	  Test Case # 4
  1.2211 +	 
  1.2212 +	  Desc	  : To test the functionality of DrawBitmapMasked() with  Destination Rectangle as zero.
  1.2213 +	 */
  1.2214 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2215 +	iSection->AppendNum(4);
  1.2216 +	iCon->Clear();
  1.2217 +	tarRect.iTl.SetXY(0,0);
  1.2218 +	tarRect.SetWidth(0);
  1.2219 +	tarRect.SetHeight(0);
  1.2220 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2221 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2222 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2223 +	/**
  1.2224 +	  Test Case # 5
  1.2225 +
  1.2226 +	  Desc	  : To test the functionality of DrawBitmapMasked() 
  1.2227 +	  with  destination rectangle large in size. (more than test screen size)
  1.2228 +	 */
  1.2229 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2230 +	iSection->AppendNum(5);
  1.2231 +	iCon->Clear();
  1.2232 +	tarRect.iTl.SetXY(0,0);
  1.2233 +	tarRect.SetWidth(iBitmapWidth*5); 
  1.2234 +	tarRect.SetHeight(iBitmapHeight*4); 
  1.2235 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2236 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2237 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2238 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2239 +	/**
  1.2240 +	  Test Case # 6
  1.2241 +	  
  1.2242 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2243 +	  passing the target rectangle targeted to right top corner of the screen.
  1.2244 +	 */
  1.2245 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2246 +	iSection->AppendNum(6);
  1.2247 +	iCon->Clear();
  1.2248 +	tarRect.iTl.SetXY(0,0);
  1.2249 +	tarRect.SetWidth(iBitmapWidth);
  1.2250 +	tarRect.SetHeight(iBitmapHeight);
  1.2251 +	tarRect.Move(iSize.iWidth-iBitmapWidth,0);
  1.2252 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2253 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2254 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2255 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);	
  1.2256 +	/**
  1.2257 +	  Test Case # 7
  1.2258 +
  1.2259 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2260 +	  passing the target rectangle targeted to bottom left corner of the screen.
  1.2261 +	 */
  1.2262 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2263 +	iSection->AppendNum(7);
  1.2264 +	iCon->Clear();
  1.2265 +	tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position
  1.2266 +	tarRect.SetWidth(iBitmapWidth);
  1.2267 +	tarRect.SetHeight(iBitmapHeight);
  1.2268 +	tarRect.Move(0,(iSize.iHeight-iBitmapHeight));
  1.2269 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2270 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2271 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2272 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2273 +	/**
  1.2274 +	  Test Case # 8
  1.2275 +
  1.2276 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2277 +	  passing the target rectangle targeted to bottom right corner of the screen
  1.2278 +	 */
  1.2279 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2280 +	iSection->AppendNum(8);
  1.2281 +	iCon->Clear();
  1.2282 +	tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position
  1.2283 +	tarRect.SetWidth(iBitmapWidth);
  1.2284 +	tarRect.SetHeight(iBitmapHeight);
  1.2285 +	tarRect.Move((iSize.iWidth-iBitmapWidth),(iSize.iHeight-iBitmapHeight));
  1.2286 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2287 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2288 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2289 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2290 +	/**
  1.2291 +	  Test Case # 9
  1.2292 +
  1.2293 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2294 +	  passing the target rectangle has negative coordinates
  1.2295 +	 */
  1.2296 +	iSection->Delete(iSection->Length() - 1, 1);
  1.2297 +	iSection->AppendNum(9);
  1.2298 +	iCon->Clear();
  1.2299 +	tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position
  1.2300 +	tarRect.SetWidth(-iBitmapWidth);
  1.2301 +	tarRect.SetHeight(-iBitmapHeight);
  1.2302 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2303 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2304 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2305 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue);
  1.2306 +	/**
  1.2307 +	  Test Case # 10
  1.2308 +
  1.2309 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2310 +	  passing the same bitmap for both the source and mask
  1.2311 +	 */
  1.2312 +	if (iDev->DisplayMode()==EGray2 || iDev->DisplayMode()==EGray4 || iDev->DisplayMode()==EGray16)
  1.2313 +		{
  1.2314 +		iSection->Delete(iSection->Length() - 1, 1);
  1.2315 +		iSection->AppendNum(10);
  1.2316 +		iCon->Clear();
  1.2317 +		tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position
  1.2318 +		tarRect.SetWidth(iBitmapWidth);
  1.2319 +		tarRect.SetHeight(iBitmapHeight);
  1.2320 +		iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2321 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2322 +		iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,srcBmp,EFalse);
  1.2323 +		CheckMaskedResultsL(backgroundBmp,srcBmp,srcBmp,tarRect,EFalse,EFalse);
  1.2324 +		}
  1.2325 +	/**
  1.2326 +	  Test Cases: 11 - 22 (BitBltMasked)
  1.2327 +
  1.2328 +	  Test Case # 11
  1.2329 +
  1.2330 +	  Desc	  : Test the functionality of DrawBitmapMasked() without 
  1.2331 +	  Stretching or compressing and with a normal mask.
  1.2332 +	 */
  1.2333 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2334 +	iSection->AppendNum(11);
  1.2335 +	iCon->Clear();
  1.2336 +	tarRect.iTl.SetXY(0,0);
  1.2337 +	tarRect.SetWidth(iBitmapWidth);
  1.2338 +	tarRect.SetHeight(iBitmapHeight);
  1.2339 +	iCon->DrawBitmap(srcRect,backgroundBmp,srcRect);
  1.2340 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2341 +	iCon->DrawBitmapMasked(srcRect,srcBmp,srcRect,maskBmp,EFalse);
  1.2342 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,srcRect,EFalse,EFalse);
  1.2343 +	//  Test Case # 12 with a reverse mask.
  1.2344 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2345 +	iSection->AppendNum(12);
  1.2346 +	iCon->Clear();
  1.2347 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2348 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2349 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue);
  1.2350 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse);
  1.2351 +	/**
  1.2352 +	  Test Case # 13
  1.2353 +
  1.2354 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2355 +	  when it stretches the bitmap and with a normal mask.
  1.2356 +	 */
  1.2357 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2358 +	iSection->AppendNum(13);
  1.2359 +	iCon->Clear();
  1.2360 +	tarRect.iTl.SetXY(0,0);
  1.2361 +	tarRect.SetWidth(Min(iBitmapWidth*2,iSize.iWidth));
  1.2362 +	tarRect.SetHeight(Min(iBitmapHeight*2,iSize.iHeight));
  1.2363 +	if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height())
  1.2364 +		{
  1.2365 +		iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2366 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2367 +		iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse);
  1.2368 +		CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse);
  1.2369 +		}
  1.2370 +	//  Test Case # 14 with a reverse mask.
  1.2371 +	if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height())
  1.2372 +		{
  1.2373 +		iSection->Delete(iSection->Length() - 2, 2);
  1.2374 +		iSection->AppendNum(14);
  1.2375 +		iCon->Clear();
  1.2376 +		iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2377 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2378 +		iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue);
  1.2379 +		CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse);
  1.2380 +		}
  1.2381 +	/**
  1.2382 +	  Test Case # 15
  1.2383 +
  1.2384 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2385 +	  when it compresses the bitmap and with a normal mask.
  1.2386 +	 */
  1.2387 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2388 +	iSection->AppendNum(15);
  1.2389 +	iCon->Clear();
  1.2390 +	tarRect.iTl.SetXY(0,0);
  1.2391 +	tarRect.SetWidth(iBitmapWidth/2);
  1.2392 +	tarRect.SetHeight(iBitmapHeight/2);
  1.2393 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2394 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2395 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse);
  1.2396 +    CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse);
  1.2397 +    //  Test Case # 16 with a reverse mask.
  1.2398 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2399 +	iSection->AppendNum(16);
  1.2400 +	iCon->Clear();
  1.2401 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2402 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2403 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue);
  1.2404 +  	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse);
  1.2405 +	/**
  1.2406 +	  Test Case # 17
  1.2407 +
  1.2408 +	  Desc	  : To test the functionality of DrawBitmapMasked() 
  1.2409 +	  with  destination rectangle large in size. (more than test screen size)
  1.2410 +	 */
  1.2411 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2412 +	iSection->AppendNum(17);
  1.2413 +	iCon->Clear();
  1.2414 +	tarRect.iTl.SetXY(0,0);
  1.2415 +	tarRect.SetWidth(iBitmapWidth*5);  
  1.2416 +	tarRect.SetHeight(iBitmapHeight*4);
  1.2417 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2418 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2419 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse);
  1.2420 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse);
  1.2421 +	//  Test Case # 18  with a reverse mask.
  1.2422 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2423 +	iSection->AppendNum(18);	
  1.2424 +	iCon->Clear();
  1.2425 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2426 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2427 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue);
  1.2428 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse);	
  1.2429 +	/**
  1.2430 +	  Test Case # 19
  1.2431 +
  1.2432 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2433 +	  passing the target rectangle targeted to right top corner of the screen.
  1.2434 +	 */
  1.2435 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2436 +	iSection->AppendNum(19);
  1.2437 +	iCon->Clear();
  1.2438 +	tarRect.iTl.SetXY(0,0);
  1.2439 +	tarRect.SetWidth(iBitmapWidth);
  1.2440 +	tarRect.SetHeight(iBitmapHeight);
  1.2441 +	tarRect.Move(iSize.iWidth-iBitmapWidth,0);
  1.2442 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2443 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2444 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse);
  1.2445 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse);
  1.2446 +	//  Test Case # 20  with a reverse mask.
  1.2447 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2448 +	iSection->AppendNum(20);
  1.2449 +	iCon->Clear();
  1.2450 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2451 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2452 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue);
  1.2453 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse);
  1.2454 +	/**
  1.2455 +	  Test Case # 21
  1.2456 +
  1.2457 +	  Desc	  : To test the functionality of DrawBitmapMasked()
  1.2458 +	  passing the target rectangle targeted to bottom right corner of the screen
  1.2459 +	 */
  1.2460 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2461 +	iSection->AppendNum(21);
  1.2462 +	iCon->Clear();
  1.2463 +	tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position
  1.2464 +	tarRect.SetWidth(iBitmapWidth);
  1.2465 +	tarRect.SetHeight(iBitmapHeight);
  1.2466 +	tarRect.Move((iSize.iWidth-iBitmapWidth),(iSize.iHeight-iBitmapHeight));
  1.2467 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2468 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2469 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse);
  1.2470 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse);
  1.2471 +	//  Test Case # 22  with a reverse mask.
  1.2472 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2473 +	iSection->AppendNum(22);
  1.2474 +	iCon->Clear();
  1.2475 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2476 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2477 +	iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue);
  1.2478 +	CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse);
  1.2479 +	
  1.2480 +	/** 
  1.2481 +	  Test Case # 23
  1.2482 +	  
  1.2483 +	  Desc: To ensure that DEF064071 is fixed.  Test that drawing a scaled
  1.2484 +	  bitmap with a tiled mask gives the correct result.
  1.2485 +	*/
  1.2486 +	if(iSize.iWidth > 100 && iDev->DisplayMode() > EGray4)
  1.2487 +	// Only do this test for screen devices
  1.2488 +		{
  1.2489 +		iSection->Delete(iSection->Length() - 2, 2);
  1.2490 +		iSection->AppendNum(23);
  1.2491 +		Clear();
  1.2492 +		iCon->Clear();
  1.2493 +		// We need a bigger rect than the rect in other tests
  1.2494 +		TRect t23Rect(TSize(150,150));
  1.2495 +		// Open source bitmap and mask
  1.2496 +		CFbsBitmap* t23SrcBmp = new (ELeave) CFbsBitmap();
  1.2497 +		CleanupStack::PushL(t23SrcBmp);
  1.2498 +		User::LeaveIfError(t23SrcBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_sourcebitmap));
  1.2499 +		CFbsBitmap* t23SrcBmpMask = new (ELeave) CFbsBitmap();
  1.2500 +		CleanupStack::PushL(t23SrcBmpMask);
  1.2501 +		User::LeaveIfError(t23SrcBmpMask->Load(KT23BitmapFileName,EMbmTgdiDef064071_sourcebitmapmask));
  1.2502 +		
  1.2503 +		// Open bitmap that contains the expected result
  1.2504 +		CFbsBitmap* t23ExpectedBmp = new (ELeave) CFbsBitmap();
  1.2505 +		CleanupStack::PushL(t23ExpectedBmp);
  1.2506 +		switch(iDev->DisplayMode())
  1.2507 +			{
  1.2508 +			case EGray16:
  1.2509 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_egray16));
  1.2510 +				break;
  1.2511 +			case EGray256:
  1.2512 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_egray256));
  1.2513 +				break;
  1.2514 +			case EColor16:
  1.2515 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor16));
  1.2516 +				break;
  1.2517 +			case EColor256:
  1.2518 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor256));
  1.2519 +				break;
  1.2520 +			case EColor4K:
  1.2521 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor4k));
  1.2522 +				break;
  1.2523 +			case EColor64K:
  1.2524 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor64k));
  1.2525 +				break;
  1.2526 +			case EColor16M:
  1.2527 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor16m));
  1.2528 +				break;
  1.2529 +			case EColor16MU:
  1.2530 +				User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor16mu));
  1.2531 +				break;
  1.2532 +			}
  1.2533 +
  1.2534 +		// Draw masked bitmap to screen
  1.2535 +		iCon->DrawBitmapMasked(t23Rect,t23SrcBmp,t23SrcBmp->SizeInPixels(),t23SrcBmpMask,ETrue);
  1.2536 +		TRect miniTarRect(20,20,80,80);
  1.2537 +		// Draw small version of the bitmap
  1.2538 +		iCon->DrawBitmapMasked(miniTarRect,t23SrcBmp,t23SrcBmp->SizeInPixels(),t23SrcBmpMask,ETrue);
  1.2539 +		// Set the clipping region to draw either side of the small bitmap that we've just drawn
  1.2540 +		TRegionFix<2> t23Region;
  1.2541 +		t23Region.AddRect(TRect(t23Rect.iTl.iX,miniTarRect.iTl.iY,
  1.2542 +								miniTarRect.iTl.iX,miniTarRect.iBr.iY));
  1.2543 +		t23Region.AddRect(TRect(miniTarRect.iBr.iX,miniTarRect.iTl.iY,
  1.2544 +								t23Rect.iBr.iX,miniTarRect.iBr.iY));
  1.2545 +		iCon->SetClippingRegion(&t23Region);
  1.2546 +		iCon->Clear();
  1.2547 +		iCon->DrawBitmapMasked(t23Rect,t23SrcBmp,t23SrcBmp->SizeInPixels(),t23SrcBmpMask,ETrue);
  1.2548 +		iCon->SetClippingRect(iDev->SizeInPixels());
  1.2549 +		
  1.2550 +		// Compare pixels on device with those from the expected bitmap
  1.2551 +		TPoint pixel;
  1.2552 +		TRgb deviceRgb;
  1.2553 +		TRgb expectedRgb;
  1.2554 +		TSize t23RectSize(t23Rect.Size());
  1.2555 +		CheckL(t23ExpectedBmp->SizeInPixels() == t23RectSize);
  1.2556 +		for(pixel.iY = t23Rect.iTl.iY; pixel.iY < t23RectSize.iHeight; ++pixel.iY)
  1.2557 +			{
  1.2558 +			for(pixel.iX = t23Rect.iTl.iX; pixel.iX < t23RectSize.iWidth; ++pixel.iX)
  1.2559 +				{
  1.2560 +				iDev->GetPixel(deviceRgb,pixel);
  1.2561 +				t23ExpectedBmp->GetPixel(expectedRgb,pixel);
  1.2562 +				CheckL(deviceRgb == expectedRgb);
  1.2563 +				}
  1.2564 +			}
  1.2565 +		iCon->CancelClippingRect();
  1.2566 +		iCon->CancelClippingRegion();
  1.2567 +		
  1.2568 +		CleanupStack::PopAndDestroy(t23ExpectedBmp);
  1.2569 +		CleanupStack::PopAndDestroy(t23SrcBmpMask);
  1.2570 +		CleanupStack::PopAndDestroy(t23SrcBmp);
  1.2571 +		}
  1.2572 +
  1.2573 +	/**
  1.2574 +	  Test Case # 24 (PDEF118404, INC115741)
  1.2575 +
  1.2576 +	  Desc	  : To test the functionality of DrawBitmapMasked() 
  1.2577 +	  with  destination rectangle multiple of 256. 
  1.2578 +	  INC115741 issue with boundary conditions. CFbsBitGc::DoDrawBitmapMasked has KScanLineLength = 256.
  1.2579 +	  Tests fix for PDEF118404. If fix is not present, this test will fail with User Panic 21. 
  1.2580 +	 */
  1.2581 +	iSection->Delete(iSection->Length() - 2, 2);
  1.2582 +	iSection->AppendNum(24);	
  1.2583 +	iCon->Clear();
  1.2584 +	iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2585 +	iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2586 +
  1.2587 +	// This constant is associated to the value used in CFbsBitGc::DoDrawBitmapMasked.
  1.2588 +	// If that value is changed, then this one must be updated as well otherwise the test will no longer be valid.	
  1.2589 +	const TInt KScanLineLength = 256;
  1.2590 +
  1.2591 +	tarRect.iTl.SetXY(0,0);
  1.2592 +	tarRect.SetHeight(2);
  1.2593 +	for (TInt ii = 1; ii < 5; ++ii)
  1.2594 +		{
  1.2595 +		tarRect.SetWidth(KScanLineLength * ii); 
  1.2596 +		iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2597 +		}
  1.2598 +
  1.2599 +	CleanupStack::PopAndDestroy(4,backgroundBmp);
  1.2600 +	}
  1.2601 +
  1.2602 +// Used to fill the bitmap with a given color for the current display mode.
  1.2603 +void TestGdi::FillBitmap(CFbsBitmap* aBitmap, TRgb aRgb)
  1.2604 +	{
  1.2605 +	TBitmapUtil bmpUtil(aBitmap);
  1.2606 +	bmpUtil.Begin(TPoint(0,0));
  1.2607 +	for (TInt rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2608 +		{
  1.2609 +		bmpUtil.SetPos(TPoint(0,rowIndex));
  1.2610 +		for (TInt colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2611 +			{
  1.2612 +			switch(iDev->DisplayMode())
  1.2613 +				{
  1.2614 +				case EGray2:
  1.2615 +					{
  1.2616 +					bmpUtil.SetPixel(TRgb::Gray2(aRgb.Blue()).Gray2());
  1.2617 +					break;
  1.2618 +					}
  1.2619 +				case EGray256:
  1.2620 +					{
  1.2621 +					bmpUtil.SetPixel(aRgb.Gray256());
  1.2622 +					break;
  1.2623 +					}
  1.2624 +				case EColor256:
  1.2625 +					{
  1.2626 +					bmpUtil.SetPixel(aRgb.Color256());
  1.2627 +					break;
  1.2628 +					}
  1.2629 +				case EColor4K:
  1.2630 +					{
  1.2631 +					bmpUtil.SetPixel(aRgb.Color4K());
  1.2632 +					break;
  1.2633 +					}
  1.2634 +				case EColor64K:
  1.2635 +					{
  1.2636 +					bmpUtil.SetPixel(aRgb.Color64K());
  1.2637 +					break;
  1.2638 +					}
  1.2639 +				case EColor16M:
  1.2640 +					{
  1.2641 +					bmpUtil.SetPixel(aRgb.Color16M());
  1.2642 +					break;
  1.2643 +					}
  1.2644 +				case EColor16MU:
  1.2645 +					{
  1.2646 +					bmpUtil.SetPixel(aRgb.Color16MU());
  1.2647 +					break;
  1.2648 +					}
  1.2649 +				}
  1.2650 +			bmpUtil.IncXPos();
  1.2651 +			}
  1.2652 +		}
  1.2653 +	bmpUtil.End();
  1.2654 +	}
  1.2655 +
  1.2656 +/**
  1.2657 +This test function is added to reproduce the defect INC097853
  1.2658 +(CFbsBitGc::DoDrawBitmapMasked function) in which it 
  1.2659 + was drawing the first scanline twice.
  1.2660 + The steps to reproduce the defect are:
  1.2661 + 1) Create a Black Background bitmap
  1.2662 + 2) Create a White Source Bitmap and
  1.2663 + 3) Create a Gray Masked Bitmap (50% white).
  1.2664 + 4) Call the function DrawBitmap to draw the Background bitmap
  1.2665 + 5) Call the function DrawBitmapMasked to draw the Source bitmap with Masked Bitmap
  1.2666 + 6) Store the screen into a bitmap
  1.2667 + */
  1.2668 +void TestGdi::DoDrawBitmapSemiTransparentMaskedL()
  1.2669 +	{
  1.2670 +	Clear();
  1.2671 +	iCon->Clear();
  1.2672 +	_LIT(KBitmapMasked,"DrawBitmapSemiTransparentMasked");
  1.2673 +	*iSection = KBitmapMasked;
  1.2674 +	TInt rowIndex;
  1.2675 +	TInt colIndex;
  1.2676 +	TSize rectSize(iBitmapWidth,iBitmapHeight);
  1.2677 +	TRect srcRect;
  1.2678 +	TRect tarRect;
  1.2679 +
  1.2680 +	// Create a Black background bitmap
  1.2681 +	CFbsBitmap* backgroundBmp = new (ELeave) CFbsBitmap;
  1.2682 +	CleanupStack::PushL(backgroundBmp);
  1.2683 +	User::LeaveIfError(backgroundBmp->Create(rectSize,iDev->DisplayMode()));
  1.2684 +	srcRect.SetSize(rectSize);
  1.2685 +	FillBitmap(backgroundBmp, KRgbBlack);
  1.2686 +
  1.2687 +	//Create a White source bitmap
  1.2688 +	CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap;
  1.2689 +	CleanupStack::PushL(srcBmp);
  1.2690 +	User::LeaveIfError(srcBmp->Create(rectSize,iDev->DisplayMode()));
  1.2691 +	FillBitmap(srcBmp, KRgbWhite);
  1.2692 +
  1.2693 +	//Create a semi transparent Masked bitmap 
  1.2694 +	CFbsBitmap* maskblendBmp = new (ELeave) CFbsBitmap;
  1.2695 +	CleanupStack::PushL(maskblendBmp);
  1.2696 +
  1.2697 +	if(iDev->DisplayMode() == EGray2)
  1.2698 +		{
  1.2699 +		User::LeaveIfError(maskblendBmp->Create(rectSize,EGray2));
  1.2700 +		TBitmapUtil bmpUtil(maskblendBmp);
  1.2701 +		bmpUtil.Begin(TPoint(0,0));
  1.2702 +		for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2703 +			{
  1.2704 +			bmpUtil.SetPos(TPoint(0,rowIndex));
  1.2705 +			for(colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2706 +				{
  1.2707 +				bmpUtil.SetPixel(128);
  1.2708 +				bmpUtil.IncXPos();
  1.2709 +				}
  1.2710 +			}
  1.2711 +		bmpUtil.End();
  1.2712 +		}
  1.2713 +	else 
  1.2714 +		{
  1.2715 +		User::LeaveIfError(maskblendBmp->Create(rectSize,EGray256));
  1.2716 +		TRgb rgb(128,128,128);
  1.2717 +		TBitmapUtil bmpUtil(maskblendBmp);
  1.2718 +		bmpUtil.Begin(TPoint(0,0));
  1.2719 +		for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
  1.2720 +			{
  1.2721 +			bmpUtil.SetPos(TPoint(0,rowIndex));
  1.2722 +			for(colIndex=0;colIndex<iBitmapWidth;++colIndex)
  1.2723 +				{
  1.2724 +				bmpUtil.SetPixel(rgb.Gray256());
  1.2725 +				bmpUtil.IncXPos();
  1.2726 +				}
  1.2727 +			}
  1.2728 +		bmpUtil.End();
  1.2729 +		}
  1.2730 +
  1.2731 +	tarRect.iTl.SetXY(0,0);
  1.2732 +	tarRect.SetWidth(iBitmapWidth*2);
  1.2733 +	tarRect.SetHeight(iBitmapHeight*2);
  1.2734 +	if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height())
  1.2735 +		{
  1.2736 +		iCon->DrawBitmap(tarRect,backgroundBmp);
  1.2737 +		iCon->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2738 +		iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse);
  1.2739 +
  1.2740 +		CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue, ETrue);
  1.2741 +		}
  1.2742 +
  1.2743 +	CleanupStack::PopAndDestroy(3,backgroundBmp);
  1.2744 +	}
  1.2745 +
  1.2746 +void TestGdi::DoFadeL()
  1.2747 +	{
  1.2748 +	*iSection = _L("Fade");
  1.2749 +	iCon->SetPenStyle(CGraphicsContext::ENullPen);
  1.2750 +	iCon->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2751 +	TInt halfwidth=iSize.iWidth>>1;
  1.2752 +	TRect lhs(TSize(halfwidth,iSize.iHeight));
  1.2753 +	TRect rhs(TPoint(halfwidth,0),TSize(iSize.iWidth,iSize.iHeight));
  1.2754 +	TRegionFix<1> area(lhs);
  1.2755 +	TPoint lhspt(halfwidth>>1,iSize.iHeight>>1);
  1.2756 +	TPoint rhspt(halfwidth+(halfwidth>>1),iSize.iHeight>>1);
  1.2757 +	TRgb lhsrgb,rhsrgb;
  1.2758 +
  1.2759 +	for(TInt count=0;count<32;count++)
  1.2760 +		{
  1.2761 +		TRgb brushColor;
  1.2762 +		if (count < 16)
  1.2763 +			brushColor = TRgb::Gray16(count);
  1.2764 +		else
  1.2765 +			brushColor = TRgb::Color16(count - 16);
  1.2766 +
  1.2767 +		if (iDev->DisplayMode() == EGray4)
  1.2768 +			{
  1.2769 +			brushColor = TRgb::Gray4(brushColor.Gray4());
  1.2770 +			iCon->SetFadingParameters(255,0);
  1.2771 +			}
  1.2772 +
  1.2773 +		iCon->SetBrushColor(brushColor);
  1.2774 +		iCon->DrawRect(lhs);
  1.2775 +		iCon->FadeArea(&area);
  1.2776 +		iCon->SetFadeMode(ETrue);
  1.2777 +		iCon->DrawRect(rhs);
  1.2778 +		iDev->GetPixel(lhsrgb,lhspt);
  1.2779 +		iDev->GetPixel(rhsrgb,rhspt);
  1.2780 +		CheckL(lhsrgb==rhsrgb);
  1.2781 +		iCon->SetFadeMode(EFalse);
  1.2782 +		}
  1.2783 +	Clear();
  1.2784 +	}
  1.2785 +