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