os/graphics/graphicsdeviceinterface/bitgdi/tbit/TAccelerator.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/TAccelerator.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2414 @@
     1.4 +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <graphicsaccelerator.h>
    1.20 +#include "TAccelerator.h"
    1.21 +#include <graphics/fbsdefs.h>
    1.22 +
    1.23 +class TAcceleratedBitmapSpecTest : public TAcceleratedBitmapSpec
    1.24 +	{
    1.25 +// Provides public access to TAcceleratedBitmapSpec
    1.26 +public:
    1.27 +	inline TAcceleratedBitmapSpecTest() : TAcceleratedBitmapSpec() {}
    1.28 +	inline TAcceleratedBitmapSpecTest(CFbsBitmap* aBitmap) : TAcceleratedBitmapSpec(aBitmap) {}
    1.29 +	inline TAcceleratedBitmapSpecTest(RHardwareBitmap aBitmap) : TAcceleratedBitmapSpec(aBitmap) {}
    1.30 +	// 
    1.31 +	inline TInt GetInfo(TAcceleratedBitmapInfo& aInfo) const { return TAcceleratedBitmapSpec::GetInfo(aInfo); }
    1.32 +	inline void Lock(TBitmapLockCount& aCount) { TAcceleratedBitmapSpec::Lock(aCount); }
    1.33 +	inline void Lock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo) { TAcceleratedBitmapSpec::Lock(aCount,aInfo); }
    1.34 +	inline void	Unlock(TBitmapLockCount& aCount)  { TAcceleratedBitmapSpec::Unlock(aCount); }
    1.35 +	};
    1.36 +
    1.37 +const TInt KNumDisplayModes = 13;
    1.38 +static struct 
    1.39 +	{
    1.40 +	TDisplayMode iMode;
    1.41 +	TBool iEnabled;
    1.42 +	TInt iPixelShift;
    1.43 +	} TestDisplayModes[KNumDisplayModes] =	
    1.44 +   {  
    1.45 +		{EGray2,EFalse,0},
    1.46 +		{EGray4,EFalse,1},
    1.47 +		{EGray16,EFalse,2},
    1.48 +		{EGray256,EFalse,3},
    1.49 +		{EColor16,EFalse,2},
    1.50 +		{EColor256,EFalse,3},
    1.51 +		{EColor64K,EFalse,4},
    1.52 +		{EColor16M,EFalse,5},
    1.53 +		{ERgb,EFalse,5},
    1.54 +		{EColor4K,EFalse,4},
    1.55 +		{EColor16MU,EFalse,5},
    1.56 +		{EColor16MA,EFalse,5},
    1.57 +		{EColor16MAP,EFalse,5}
    1.58 +	};
    1.59 +
    1.60 +_LIT(KRam32BitmapOnZ, "z:\\system\\data\\32RAM.mbm");
    1.61 +_LIT(KRamC24BitmapOnZ, "z:\\system\\data\\24RAMC.mbm");
    1.62 +_LIT(KRomC24Bitmap, "z:\\system\\data\\24ROMC.mbm");
    1.63 +
    1.64 +//
    1.65 +// CTestBitmap
    1.66 +//
    1.67 +
    1.68 +TInt CTestBitmap::ConstructL(TDisplayMode aDisplayMode,TSize aSize,TBool aHWBitmap)
    1.69 +	{
    1.70 +	Reset();
    1.71 +
    1.72 +	iBitmap = new CFbsBitmap;
    1.73 +	if(iBitmap==NULL)
    1.74 +		User::Panic(_L("Bitmap not created"),KErrGeneral);
    1.75 +
    1.76 +	TInt ret;
    1.77 +	if(aHWBitmap)
    1.78 +		ret = iBitmap->CreateHardwareBitmap(aSize,aDisplayMode,TUid());
    1.79 +	else
    1.80 +		ret = iBitmap->Create(aSize,aDisplayMode);
    1.81 +
    1.82 +	if (ret == KErrNotSupported)
    1.83 +		{
    1.84 +		Reset();
    1.85 +		return ret;
    1.86 +		}
    1.87 +
    1.88 +	User::LeaveIfError(ret);
    1.89 +
    1.90 +	TRAPD(err,iDevice = CFbsBitmapDevice::NewL(iBitmap));
    1.91 +	if(err)
    1.92 +		User::Panic(_L("BitmapDevice not created"),err);
    1.93 +
    1.94 +	err = iDevice->CreateContext(iGc);
    1.95 +	if(err)
    1.96 +		User::Panic(_L("BitmapDevice not created"),err);
    1.97 +
    1.98 +	return KErrNone;
    1.99 +	}
   1.100 +
   1.101 +void CTestBitmap::Reset()
   1.102 +	{
   1.103 +	delete iGc;
   1.104 +	iGc = 0;
   1.105 +	delete iDevice;
   1.106 +	iDevice = 0;
   1.107 +	delete iBitmap;
   1.108 +	iBitmap = 0;
   1.109 +	}
   1.110 +
   1.111 +CTestBitmap::~CTestBitmap()
   1.112 +	{
   1.113 +	Reset();
   1.114 +	}
   1.115 +
   1.116 +TBool CTestBitmap::Compare(CTestBitmap* aBitmap2)
   1.117 +	{	
   1.118 +	TInt width=iBitmap->SizeInPixels().iWidth;
   1.119 +	TInt pitch = iBitmap->DataStride();
   1.120 +	TInt height=iBitmap->SizeInPixels().iHeight;
   1.121 +
   1.122 +	for(TInt yLoop=0;yLoop<height;yLoop++)
   1.123 +		{
   1.124 +		TInt offset=yLoop*pitch;
   1.125 +		TUint8* data1 = ((TUint8*)iBitmap->DataAddress())+offset;
   1.126 +		TUint8* data2 = ((TUint8*)aBitmap2->iBitmap->DataAddress())+offset;
   1.127 +		TUint8* dataLimit = data1 + CFbsBitmap::ScanLineLength(width, iBitmap->DisplayMode());
   1.128 +		while(data1<dataLimit)
   1.129 +			{
   1.130 +			if(*(data1++)!=*(data2++))
   1.131 +				{
   1.132 +				iBitmap->Save(_L("C:\\Compare1.mbm"));
   1.133 +				aBitmap2->iBitmap->Save(_L("C:\\Compare2.mbm"));
   1.134 +				return EFalse;
   1.135 +				}
   1.136 +			}
   1.137 +		}
   1.138 +	return(ETrue);
   1.139 +	}
   1.140 +
   1.141 +//
   1.142 +// CTAccelerator
   1.143 +//
   1.144 +
   1.145 +CTAccelerator::CTAccelerator(CTestStep* aStep):
   1.146 +	CTGraphicsBase(aStep), 
   1.147 +	iRandomSeed(1),
   1.148 +	iGraphicsAccelerator1(0),
   1.149 +	iGraphicsAccelerator2(0),
   1.150 +	iHwScreenDevice(0),
   1.151 +	iScreenGc(0)
   1.152 +	{
   1.153 +	TInt i;
   1.154 +	for(i=0;i<9;i++) 
   1.155 +		iFixedRegion.AddRect(TRect(i*16,i*8,i*16+32,i*8+32));
   1.156 +	for(i=0;i<9;i++) 
   1.157 +		iFixedRegion.AddRect(TRect(183-(i*16),i*8,199-(i*16),i*8+32));
   1.158 +
   1.159 +	iDefaultRegion.AddRect(TRect(0,0,199,99));
   1.160 +	INFO_PRINTF1(_L("Graphics Accelerator Testing"));
   1.161 +	}
   1.162 +
   1.163 +void CTAccelerator::Cleanup()
   1.164 +	{
   1.165 +	delete iGraphicsAccelerator1;
   1.166 +	iGraphicsAccelerator1 = 0;
   1.167 +	delete iGraphicsAccelerator2;
   1.168 +	iGraphicsAccelerator2 = 0;
   1.169 +	if(iHwScreenDevice)
   1.170 +		{
   1.171 +		delete iHwScreenDevice;
   1.172 +		iHwScreenDevice = 0;
   1.173 +		}
   1.174 +	if(iScreenGc)
   1.175 +		{
   1.176 +		delete iScreenGc;
   1.177 +		iScreenGc = 0;
   1.178 +		}
   1.179 +	iBitmap1.Reset();
   1.180 +	iBitmap2.Reset();
   1.181 +	iBitmap3.Reset();
   1.182 +	iBitmap4.Reset();
   1.183 +	iBitmap5.Reset();
   1.184 +	iBitmap6.Reset();
   1.185 +	iBitmap7.Reset();
   1.186 +	iTileBitmap.Reset();
   1.187 +	iAlphaBitmap.Reset();
   1.188 +	}
   1.189 +
   1.190 +TInt CTAccelerator::Random(TInt aMax)	// aMax <= 0xFFFF
   1.191 +	{
   1.192 +	iRandomSeed *= 69069;
   1.193 +	TUint r = ((iRandomSeed>>16)*aMax)>>16;
   1.194 +	return r;
   1.195 +	}
   1.196 +
   1.197 +void CTAccelerator::RunTestCaseL(TInt aCurTestCase)
   1.198 +	{
   1.199 +	TInt i;
   1.200 +	((CTAcceleratorStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.201 +	
   1.202 +	switch(aCurTestCase)
   1.203 +		{
   1.204 +	case 1:
   1.205 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0021"));
   1.206 +		INFO_PRINTF1(_L("Testing TAcceleratedBitmapSpec with software bitmaps."));
   1.207 +		for(i=0; i<KNumDisplayModes; i++)
   1.208 +			if (TestDisplayModes[i].iEnabled)
   1.209 +				{
   1.210 +				TestAcceleratedBitmapSpecL(TestDisplayModes[i].iMode,EFalse);
   1.211 +				}
   1.212 +		break;
   1.213 +	case 2:
   1.214 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0022"));
   1.215 +		INFO_PRINTF1(_L("Testing graphics operations with software bitmaps."));
   1.216 +		for(i=0; i<KNumDisplayModes; i++)
   1.217 +			if (TestDisplayModes[i].iEnabled)
   1.218 +				{
   1.219 +				TestGraphicsOperations(TestDisplayModes[i].iMode,EFalse);
   1.220 +				}
   1.221 +		break;
   1.222 +	case 3:
   1.223 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0021"));
   1.224 +		INFO_PRINTF1(_L("Testing TAcceleratedBitmapSpec with hardware bitmaps."));
   1.225 +		for(i=0; i<KNumDisplayModes; i++)
   1.226 +			if (TestDisplayModes[i].iEnabled)
   1.227 +				{
   1.228 +				TestAcceleratedBitmapSpecL(TestDisplayModes[i].iMode,ETrue);
   1.229 +				}
   1.230 +		break;
   1.231 +	case 4:
   1.232 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0022"));
   1.233 +		INFO_PRINTF1(_L("Testing graphics operations with hardware bitmaps."));
   1.234 +		for(i=0; i<KNumDisplayModes; i++)
   1.235 +			if (TestDisplayModes[i].iEnabled)
   1.236 +				{
   1.237 +				TestGraphicsOperations(TestDisplayModes[i].iMode,ETrue);
   1.238 +				}
   1.239 +		break;
   1.240 +	case 5:
   1.241 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0023"));
   1.242 +		INFO_PRINTF1(_L("Testing graphics operations with hardware bitmap as screen."));
   1.243 +		for(i=0; i<KNumDisplayModes; i++)
   1.244 +			if (TestDisplayModes[i].iEnabled)	
   1.245 +				{
   1.246 +				TestGraphicsOperationsWithScreenL(TestDisplayModes[i].iMode,ETrue);
   1.247 +				}
   1.248 +		break;
   1.249 +	case 6:
   1.250 +
   1.251 +/**
   1.252 + @SYMTestCaseID          GRAPHICS-BITGDI-0112
   1.253 +*/
   1.254 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0112"));
   1.255 +		INFO_PRINTF1(_L("Testing passing of compressed info to accelerator"));
   1.256 +		TestAcceleratorInfo();
   1.257 +		break;
   1.258 +	case 7:
   1.259 +/**
   1.260 + @SYMTestCaseID          GRAPHICS-BITGDI-0113
   1.261 +*/
   1.262 +		((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0113"));
   1.263 +		INFO_PRINTF1(_L("Testing GetInfo() with an extended bitmap"));
   1.264 +		TestAcceleratorInfoForExtendedBitmapL();
   1.265 +		break;
   1.266 +
   1.267 +	case 8:
   1.268 +		((CTAcceleratorStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.269 +		((CTAcceleratorStep*)iStep)->CloseTMSGraphicsStep();
   1.270 +		TestComplete();
   1.271 +		break;
   1.272 +		}
   1.273 +	((CTAcceleratorStep*)iStep)->RecordTestResultL();
   1.274 + 	}
   1.275 +
   1.276 +const TSize TestBitmapSize = TSize(199,99);
   1.277 +TSize TestScreenSize;
   1.278 +const TSize TestBitmapSize1 = TSize(165,53);
   1.279 +
   1.280 +
   1.281 +/**
   1.282 + @SYMTestCaseID          GRAPHICS-BITGDI-0021
   1.283 + @SYMCreationDate        21/11/2008
   1.284 + @SYMAuthor              douglashetherington
   1.285 + @SYMTestStatus          3. Released
   1.286 + @SYMTestPriority        High
   1.287 + @SYMTestCaseDesc        Checks that TAcceleratedBitmapSpec does not change the underlaying bitmaps data
   1.288 + @SYMTestExpectedResults The bitmap data is not changed
   1.289 + @SYMTestActions         Creates a bitmap, puts it into a TAcceleratedBitmapSpec then checks the pixel data is unchanged
   1.290 + @SYMDEF                 
   1.291 +*/
   1.292 +void CTAccelerator::TestAcceleratedBitmapSpecL(TDisplayMode aDisplayMode,TBool aHWBitmap)
   1.293 +	{
   1.294 +	TInt ret=0; 
   1.295 +	
   1.296 +	INFO_PRINTF2(_L("  DisplayMode=%d"),aDisplayMode);
   1.297 +
   1.298 +	// Create bitmap
   1.299 +	ret = iBitmap1.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap);
   1.300 +	INFO_PRINTF2(_L(" TestAcceleratedBitmapSpecL ret=%d"),ret);
   1.301 +	if(ret!=KErrNone)
   1.302 +		{
   1.303 +		WARN_PRINTF1(_L("  Not Supported."));
   1.304 +		return;
   1.305 +		}
   1.306 +
   1.307 +	TAcceleratedBitmapSpecTest bitmapSpec(iBitmap1.iBitmap);
   1.308 +	TAcceleratedBitmapInfo info;
   1.309 +
   1.310 +	// Check correct size	
   1.311 +	bitmapSpec.Lock(iBitmapLockCount);
   1.312 +	User::LeaveIfError(bitmapSpec.GetInfo(info));
   1.313 +	TEST(info.iSize==iBitmap1.iBitmap->SizeInPixels());
   1.314 +	INFO_PRINTF3(_L("Test Display Modes , Expected iPixelShift : %d, Actual iPixelShift: %d"),TestDisplayModes[aDisplayMode-1].iPixelShift,info.iPixelShift);
   1.315 +	TEST(info.iPixelShift == TestDisplayModes[aDisplayMode-1].iPixelShift);
   1.316 +	bitmapSpec.Unlock(iBitmapLockCount);
   1.317 +
   1.318 +	TInt scanLineLength = iBitmap1.iBitmap->ScanLineLength(TestBitmapSize.iWidth,aDisplayMode);
   1.319 +	HBufC8* scanLineBuffer = HBufC8::NewMaxLC(scanLineLength);
   1.320 +	TPtr8 scanLine(scanLineBuffer->Des());
   1.321 +
   1.322 +	TInt y,x;
   1.323 +
   1.324 +	// fill bitmap with test data
   1.325 +	for(y=info.iSize.iHeight-1; y>=0; y--)
   1.326 +		{
   1.327 +		TUint8* ptr = &(scanLine)[0];
   1.328 +		TUint8* ptrLimit = ptr+scanLineLength;
   1.329 +		x = 42;
   1.330 +		while(ptr<ptrLimit)
   1.331 +			*(ptr++) = (TUint8)(y^(x++));
   1.332 +		iBitmap1.iBitmap->SetScanLine(scanLine,y);
   1.333 +		}
   1.334 +	
   1.335 +	// use TAcceleratedBitmapSpec to check contents
   1.336 +	bitmapSpec.Lock(iBitmapLockCount,info);
   1.337 +	for(y=0; y<info.iSize.iHeight; y++)
   1.338 +		{
   1.339 +		TUint8* ptr = info.iAddress+y*info.iLinePitch;
   1.340 +		TUint8* ptrLimit = ptr+scanLineLength;
   1.341 +		x = 42;
   1.342 +		while(ptr<ptrLimit)
   1.343 +			if(*(ptr++) != (TUint8)(y^(x++)))
   1.344 +				{
   1.345 +				ERR_PRINTF2(_L("!!!  Failed at compare A, line %d"),y);
   1.346 +				User::Leave(KErrGeneral);
   1.347 +				}
   1.348 +		}
   1.349 +	bitmapSpec.Unlock(iBitmapLockCount);
   1.350 +
   1.351 +	// fill bitmap with test data (inverse of previous)
   1.352 +	for(y=info.iSize.iHeight-1; y>=0; y--)
   1.353 +		{
   1.354 +		TUint8* ptr = &(scanLine)[0];
   1.355 +		TUint8* ptrLimit = ptr+scanLineLength;
   1.356 +		x = 42;
   1.357 +		while(ptr<ptrLimit)
   1.358 +			*(ptr++) = (TUint8)~(y^(x++));
   1.359 +		iBitmap1.iBitmap->SetScanLine(scanLine,y);
   1.360 +		}
   1.361 +	
   1.362 +	// use TAcceleratedBitmapSpec to check contents
   1.363 +	bitmapSpec.Lock(iBitmapLockCount,info);
   1.364 +	for(y=0; y<info.iSize.iHeight; y++)
   1.365 +		{
   1.366 +		TUint8* ptr = info.iAddress+y*info.iLinePitch;
   1.367 +		TUint8* ptrLimit = ptr+scanLineLength;
   1.368 +		x = 42;
   1.369 +		while(ptr<ptrLimit)
   1.370 +			if(*(ptr++) != (TUint8)~(y^(x++)))
   1.371 +				{
   1.372 +				ERR_PRINTF2(_L("!!!  Failed at compare B, line %d"),y);
   1.373 +				User::Leave(KErrGeneral);
   1.374 +				}
   1.375 +		}
   1.376 +	bitmapSpec.Unlock(iBitmapLockCount);
   1.377 +
   1.378 +	// End
   1.379 +	CleanupStack::PopAndDestroy();	//scanLineBuffer
   1.380 +
   1.381 +	Cleanup();
   1.382 +
   1.383 +	INFO_PRINTF1(_L("  OK"));
   1.384 +	}
   1.385 +
   1.386 +class CTestFbsDevice : public CFbsDevice
   1.387 +	{
   1.388 +public:
   1.389 +	inline CGraphicsAccelerator* StealGraphicsAccelerator()
   1.390 +		{ CGraphicsAccelerator* acc = iGraphicsAccelerator; iGraphicsAccelerator = 0; return acc; };
   1.391 +	};
   1.392 +
   1.393 +
   1.394 +/**
   1.395 + @SYMTestCaseID          GRAPHICS-BITGDI-0022
   1.396 + @SYMCreationDate        21/11/2008
   1.397 + @SYMAuthor              douglashetherington
   1.398 + @SYMTestStatus          3. Released
   1.399 + @SYMTestPriority        High
   1.400 + @SYMTestCaseDesc        Tests various basic graphic operations
   1.401 + @SYMTestExpectedResults Tests should perform graphics operations succesfully.
   1.402 + @SYMTestActions         Creates a number of bitmaps then uses them in various graphic operations
   1.403 + @SYMDEF                 
   1.404 +*/
   1.405 +void CTAccelerator::TestGraphicsOperations(TDisplayMode aDisplayMode,TBool aHWBitmap)
   1.406 +	{
   1.407 +	TInt ret=0;
   1.408 +	
   1.409 +	INFO_PRINTF2(_L("  DisplayMode=%d"),aDisplayMode);
   1.410 +	TRAPD(errCode, ret = iBitmap1.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.411 +	if((ret!=KErrNone) || (errCode !=KErrNone) || (!iBitmap1.iDevice->GraphicsAccelerator()))
   1.412 +		{
   1.413 +		WARN_PRINTF1(_L("  Not Supported."));
   1.414 +		return;
   1.415 +		}
   1.416 +
   1.417 +	iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap1.iDevice)->StealGraphicsAccelerator();
   1.418 +	delete iGraphicsAccelerator1;
   1.419 +	iGraphicsAccelerator1 = 0;
   1.420 +	
   1.421 +	if(!iSubRegion.IsEmpty())
   1.422 +		iSubRegion.Clear();
   1.423 +	iSubRegion.AddRect(iBitmap1.iBitmap->SizeInPixels());
   1.424 +	iSubRegion.SubRegion(iFixedRegion);
   1.425 +	iSubRegionPtr = &iSubRegion;
   1.426 +	
   1.427 +	TRAP(errCode, ret = iBitmap2.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.428 +	TEST(errCode== KErrNone);
   1.429 +	if(ret!=KErrNone)
   1.430 +		User::Panic(_L("Bitmap not created"),ret);
   1.431 +
   1.432 +	TRAP(errCode, ret = iBitmap3.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.433 +	TEST(errCode== KErrNone);
   1.434 +	if(ret!=KErrNone)
   1.435 +		User::Panic(_L("Bitmap not created"),ret);
   1.436 +
   1.437 +	iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap3.iDevice)->StealGraphicsAccelerator();
   1.438 +
   1.439 +	TRAP(errCode, ret = iBitmap4.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.440 +	TEST(errCode== KErrNone);
   1.441 +	if(ret!=KErrNone)
   1.442 +		User::Panic(_L("Bitmap not created"),ret);
   1.443 +
   1.444 +	TRAP(errCode, ret = iBitmap5.ConstructL(aDisplayMode,TestBitmapSize1,aHWBitmap));
   1.445 +	TEST(errCode== KErrNone);
   1.446 +	if(ret!=KErrNone)
   1.447 +		User::Panic(_L("Bitmap not created"),ret);
   1.448 +
   1.449 +	TRAP(errCode, ret = iBitmap6.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.450 +	TEST(errCode== KErrNone);
   1.451 +	if(ret!=KErrNone)
   1.452 +		User::Panic(_L("Bitmap not created"),ret);
   1.453 +
   1.454 +	TRAP(errCode, ret = iBitmap7.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.455 +	TEST(errCode== KErrNone);
   1.456 +	if(ret!=KErrNone)
   1.457 +		User::Panic(_L("Bitmap not created"),ret);
   1.458 +	
   1.459 +	TRAP(errCode, ret = iBitmap8.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap));
   1.460 +	TEST(errCode== KErrNone);
   1.461 +	if(ret!=KErrNone)
   1.462 +		User::Panic(_L("Bitmap not created"),ret);
   1.463 +
   1.464 +	//BrushBitmap
   1.465 +    CFbsBitmap* iTile = new CFbsBitmap();
   1.466 +	TEST(iTile!=NULL);
   1.467 +	ret = iTile->Load(_L("z:\\system\\data\\tile.mbm"),0,aHWBitmap);
   1.468 +    TEST(ret==KErrNone);
   1.469 +
   1.470 +	TSize tileSize = iTile->SizeInPixels();
   1.471 +	TDisplayMode tileDisplayMode = iTile->DisplayMode();
   1.472 +
   1.473 +	TRAP(errCode, ret = iTileBitmap.ConstructL(tileDisplayMode,tileSize,aHWBitmap));
   1.474 +	TEST(errCode== KErrNone);
   1.475 +	if(ret== KErrNotSupported)
   1.476 +		{
   1.477 +		WARN_PRINTF1(_L("  Not Supported."));
   1.478 +		delete iTile;
   1.479 +		iTile = NULL;
   1.480 +		return;
   1.481 +		}
   1.482 +	iTileBitmap.iGc->BitBlt(TPoint(0,0),iTile);
   1.483 +	delete iTile;
   1.484 +	iTile = NULL;
   1.485 +
   1.486 +	//Alpha bitmap
   1.487 +	TRAP(errCode, ret = iAlphaBitmap.ConstructL(EGray256,TestBitmapSize,aHWBitmap));
   1.488 +	TEST(errCode== KErrNone);
   1.489 +	if(ret!=KErrNone)
   1.490 +		User::Panic(_L("Bitmap not created"),ret);
   1.491 +
   1.492 +	iGraphicsAccelerator2 = ((CTestFbsDevice*)iBitmap4.iDevice)->StealGraphicsAccelerator();
   1.493 +
   1.494 +	INFO_PRINTF1(_L("FilledRect"));
   1.495 +	TestFilledRect();
   1.496 +
   1.497 +	resetColorBitmaps();
   1.498 +
   1.499 +	INFO_PRINTF1(_L("FilledRectWithPattern "));
   1.500 +	TestFilledRectWithPattern();
   1.501 +	
   1.502 +	resetColorBitmaps();
   1.503 +
   1.504 +	INFO_PRINTF1(_L("InvertRect")); 
   1.505 +	TestInvertRect();
   1.506 +	
   1.507 +	resetColorBitmaps();
   1.508 +
   1.509 +	INFO_PRINTF1(_L("FadeRect "));
   1.510 +	TestFadeRect();
   1.511 +	
   1.512 +	resetColorBitmaps();
   1.513 +
   1.514 +	INFO_PRINTF1(_L("BitBlt "));
   1.515 +	TestBitBlt();
   1.516 +	
   1.517 +	resetColorBitmaps();
   1.518 +
   1.519 +	INFO_PRINTF1(_L("BitBltMasked "));
   1.520 +	TestBitBltMasked();
   1.521 +	
   1.522 +	resetColorBitmaps();
   1.523 +
   1.524 +	INFO_PRINTF1(_L("BitBltAlphaBitmap"));
   1.525 +	TestBitBltAlphaBitmap();
   1.526 +
   1.527 +	resetColorBitmaps();
   1.528 +	
   1.529 +	INFO_PRINTF1(_L("AlphaBlendTwoBitmaps "));
   1.530 +	TestAlphaBlendTwoBitmaps();
   1.531 +	
   1.532 +	resetColorBitmaps();
   1.533 +	
   1.534 +	INFO_PRINTF1(_L("AlphaBlendOneBitmap "));
   1.535 +	TestAlphaBlendOneBitmap();
   1.536 +	
   1.537 +	resetColorBitmaps();
   1.538 +
   1.539 +	Cleanup();
   1.540 +	}
   1.541 +
   1.542 +
   1.543 +/**
   1.544 + @SYMTestCaseID          GRAPHICS-BITGDI-0023
   1.545 + @SYMCreationDate        21/11/2008
   1.546 + @SYMAuthor              douglashetherington
   1.547 + @SYMTestStatus          3. Released
   1.548 + @SYMTestPriority        High
   1.549 + @SYMTestCaseDesc        Tests various basic graphic operations draw directly to the screen device
   1.550 + @SYMTestExpectedResults Tests should perform graphics operations succesfully.
   1.551 + @SYMTestActions         Creates a number of bitmaps then uses them in various graphic operations drawing directly to the screen gc
   1.552 + @SYMDEF                 
   1.553 +*/
   1.554 +void CTAccelerator::TestGraphicsOperationsWithScreenL(TDisplayMode aDisplayMode,TBool aHWBitmap)
   1.555 +	{
   1.556 +	TInt ret;
   1.557 +
   1.558 +	INFO_PRINTF2(_L("  DisplayMode=%d."),aDisplayMode);
   1.559 +
   1.560 +	ret = iBitmap1.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap);
   1.561 +	if((ret!=KErrNone) || (!iBitmap1.iDevice->GraphicsAccelerator()))
   1.562 +		{
   1.563 +		WARN_PRINTF1(_L("  Not Supported."));
   1.564 +		return;
   1.565 +		}
   1.566 +
   1.567 +	TRAPD(err,iHwScreenDevice = CFbsScreenDevice::NewL(_L(""),aDisplayMode));
   1.568 +	if(err)
   1.569 +		User::Panic(_L("BitmapDevice not created"),err);
   1.570 +	iHwScreenDevice->ChangeScreenDevice(NULL);
   1.571 +	err = iHwScreenDevice->CreateContext(iScreenGc);
   1.572 +	if(err)
   1.573 +		User::Panic(_L("BitmapDevice not created"),err);
   1.574 +
   1.575 +	TestScreenSize.SetSize(iHwScreenDevice->SizeInPixels().iWidth,iHwScreenDevice->SizeInPixels().iHeight);
   1.576 +	iDefaultScreenRegion.AddRect(TestScreenSize);
   1.577 +
   1.578 +	iBitmap1.Reset();
   1.579 +	iBitmap1.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap);
   1.580 +	iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap1.iDevice)->StealGraphicsAccelerator();
   1.581 +	delete iGraphicsAccelerator1;
   1.582 +	iGraphicsAccelerator1 = 0;
   1.583 +	
   1.584 +	if(!iSubRegion.IsEmpty())
   1.585 +		iSubRegion.Clear();
   1.586 +	iSubRegion.AddRect(iBitmap1.iBitmap->SizeInPixels());
   1.587 +	iSubRegion.SubRegion(iFixedRegion);
   1.588 +	iSubRegionPtr = &iSubRegion;
   1.589 +
   1.590 +	ret = iBitmap2.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap);
   1.591 +	if(ret!=KErrNone)
   1.592 +		User::Panic(_L("Bitmap not created"),ret);
   1.593 +
   1.594 +	ret = iBitmap3.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap);
   1.595 +	if(ret!=KErrNone)
   1.596 +		User::Panic(_L("Bitmap not created"),ret);
   1.597 +
   1.598 +	iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap3.iDevice)->StealGraphicsAccelerator();
   1.599 +
   1.600 +	ret = iBitmap4.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap);
   1.601 +	if(ret!=KErrNone)
   1.602 +		User::Panic(_L("Bitmap not created"),ret);
   1.603 +
   1.604 +	ret = iBitmap5.ConstructL(aDisplayMode,TestBitmapSize1,aHWBitmap);
   1.605 +	if(ret!=KErrNone)
   1.606 +		User::Panic(_L("Bitmap not created"),ret);
   1.607 +
   1.608 +	ret = iBitmap6.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap);
   1.609 +	if(ret!=KErrNone)
   1.610 +		User::Panic(_L("Bitmap not created"),ret);
   1.611 +
   1.612 +	ret = iBitmap7.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap);
   1.613 +	if(ret!=KErrNone)
   1.614 +		User::Panic(_L("Bitmap not created"),ret);
   1.615 +
   1.616 +	//BrushBitmap
   1.617 +    CFbsBitmap* iTile = new CFbsBitmap();
   1.618 +	TEST(iTile!=NULL);
   1.619 +	ret = iTile->Load(_L("z:\\system\\data\\tile.mbm"),0,aHWBitmap);
   1.620 +    TEST(ret==KErrNone);
   1.621 +
   1.622 +	TSize tileSize = iTile->SizeInPixels();
   1.623 +	TDisplayMode tileDisplayMode = iTile->DisplayMode();
   1.624 +
   1.625 +	ret= iTileBitmap.ConstructL(tileDisplayMode,tileSize,aHWBitmap);
   1.626 +	if(ret == KErrNotSupported)
   1.627 +		{
   1.628 +		WARN_PRINTF1(_L("  Not Supported."));
   1.629 +		delete iTile;
   1.630 +		iTile = NULL;
   1.631 +		return;
   1.632 +		}
   1.633 +	iTileBitmap.iGc->BitBlt(TPoint(0,0),iTile);
   1.634 +	delete iTile;
   1.635 +	iTile = NULL;
   1.636 +
   1.637 +	//Alpha bitmap
   1.638 +	ret = iAlphaBitmap.ConstructL(EGray256,TestBitmapSize,aHWBitmap);
   1.639 +	if(ret!=KErrNone)
   1.640 +		User::Panic(_L("Bitmap not created"),ret);
   1.641 +
   1.642 +	iGraphicsAccelerator2 = ((CTestFbsDevice*)iBitmap4.iDevice)->StealGraphicsAccelerator();
   1.643 +	resetColorBitmaps();
   1.644 +
   1.645 +	INFO_PRINTF1(_L("FilledRect in the screen"));
   1.646 +	TestScreenFilledRect();
   1.647 +
   1.648 +	resetColorBitmaps();
   1.649 +
   1.650 +	INFO_PRINTF1(_L("FilledRectWithPattern in the screen"));
   1.651 +	TestScreenFilledRectWithPattern();
   1.652 +	
   1.653 +	resetColorBitmaps();
   1.654 +
   1.655 +	INFO_PRINTF1(_L("InvertRect in the screen")); 
   1.656 +	TestScreenInvertRect();
   1.657 +	
   1.658 +	resetColorBitmaps();
   1.659 +
   1.660 +	INFO_PRINTF1(_L("FadeRect in the screen"));
   1.661 +	TestScreenFadeRect();
   1.662 +	
   1.663 +	resetColorBitmaps();
   1.664 +
   1.665 +	INFO_PRINTF1(_L("BitBlt in the screen"));
   1.666 +	TestScreenBitBlt();
   1.667 +	
   1.668 +	resetColorBitmaps();
   1.669 +
   1.670 +	INFO_PRINTF1(_L("BitBltMasked in the screen"));
   1.671 +	TestScreenBitBltMasked();
   1.672 +	
   1.673 +	resetColorBitmaps();
   1.674 +
   1.675 +	INFO_PRINTF1(_L("BitBltAlphaBitmap in the screen"));
   1.676 +	TestScreenBitBltAlphaBitmap();
   1.677 +
   1.678 +	resetColorBitmaps();
   1.679 +
   1.680 +	INFO_PRINTF1(_L("AlphaBlendTwoBitmaps in the screen"));
   1.681 +	TestScreenAlphaBlendTwoBitmaps();
   1.682 +
   1.683 +	resetColorBitmaps();
   1.684 +	
   1.685 +	
   1.686 +	INFO_PRINTF1(_L("AlphaBlendOneBitmap in the screen"));
   1.687 +	TestScreenAlphaBlendOneBitmap();
   1.688 +
   1.689 +	resetColorBitmaps();
   1.690 +	
   1.691 +	INFO_PRINTF1(_L("Rotating the screen"));
   1.692 +	TestScreenRotation();
   1.693 +
   1.694 +	resetColorBitmaps();
   1.695 +
   1.696 +	INFO_PRINTF1(_L("Changing user display mode"));
   1.697 +	TestUserDisplayMode();
   1.698 +
   1.699 +	resetColorBitmaps();
   1.700 +
   1.701 +	Cleanup();
   1.702 +	}
   1.703 +
   1.704 +void CTAccelerator::TestAcceleratorInfo()
   1.705 +	{
   1.706 +	TInt errCode;
   1.707 +	TInt ret=0;
   1.708 +
   1.709 +	iBitmap5.iBitmap=new CFbsBitmap();
   1.710 +	TRAP(errCode, ret=iBitmap5.iBitmap->Load(KRam32BitmapOnZ,0));
   1.711 +	TEST(errCode==KErrNone);
   1.712 +	TEST(ret==KErrNone);
   1.713 +	TAcceleratedBitmapSpec spec(iBitmap5.iBitmap);
   1.714 +	TAcceleratedBitmapInfo info;
   1.715 +	iBitmap5.iBitmap->LockHeap();
   1.716 +	spec.GetInfo(info);
   1.717 +	iBitmap5.iBitmap->UnlockHeap();
   1.718 +	TEST(info.iLinePitch==iBitmap5.iBitmap->Header().iSizeInPixels.iWidth*iBitmap5.iBitmap->Header().iBitsPerPixel/8);
   1.719 +
   1.720 +	TRAP(errCode, ret=iBitmap5.iBitmap->Compress());
   1.721 +	TEST(errCode==KErrNone);
   1.722 +	TEST(ret==KErrNone);
   1.723 +	iBitmap5.iBitmap->LockHeap();
   1.724 +	spec.GetInfo(info);
   1.725 +	iBitmap5.iBitmap->UnlockHeap();
   1.726 +	TEST(info.iLinePitch==-iBitmap5.iBitmap->Header().iCompression);
   1.727 +
   1.728 +	TUint32* romAddress = NULL;
   1.729 +	if(CFbsBitmap::IsFileInRom(KRomC24Bitmap, romAddress))
   1.730 +		{
   1.731 +		TRAP(errCode, ret=iBitmap5.iBitmap->Load(KRomC24Bitmap,0));
   1.732 +		TEST(errCode==KErrNone);
   1.733 +		TEST(ret==KErrNone);
   1.734 +		iBitmap5.iBitmap->LockHeap();
   1.735 +		spec.GetInfo(info);
   1.736 +		iBitmap5.iBitmap->UnlockHeap();
   1.737 +		TEST(info.iLinePitch==-iBitmap5.iBitmap->Header().iCompression);
   1.738 +		}
   1.739 +	else
   1.740 +		{
   1.741 +		INFO_PRINTF2(_L("Skipping ROM bitmap test since file \"%S\" is reported to not be a ROM bitmap."),
   1.742 +				&KRomC24Bitmap);
   1.743 +		INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported."));
   1.744 +		}
   1.745 +
   1.746 +	TRAP(errCode, ret=iBitmap5.iBitmap->LoadAndCompress(KRamC24BitmapOnZ,0));
   1.747 +	TEST(errCode==KErrNone);
   1.748 +	TEST(ret==KErrNone);
   1.749 +	iBitmap5.iBitmap->LockHeap();
   1.750 +	spec.GetInfo(info);
   1.751 +	iBitmap5.iBitmap->UnlockHeap();
   1.752 +	TEST(info.iLinePitch==-iBitmap5.iBitmap->Header().iCompression);
   1.753 +
   1.754 +	Cleanup();
   1.755 +	}
   1.756 +
   1.757 +void CTAccelerator::TestAcceleratorInfoForExtendedBitmapL()
   1.758 +	{	
   1.759 +	const TSize KSizeInPixels(64,65);
   1.760 +	const TDisplayMode KDisplayMode	= EColor64K;
   1.761 +	const TUid KExtendedBitmapUid = {0x87654321};
   1.762 +	const TUint8 KTestData[] = "Extended bitmap test data 123456";
   1.763 +	const TInt KTestDataSize = sizeof(KTestData);
   1.764 +	
   1.765 +	CFbsBitmap* exBmp = new (ELeave) CFbsBitmap;
   1.766 +	CleanupStack::PushL(exBmp);
   1.767 +	TInt err = exBmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KExtendedBitmapUid, KTestData, KTestDataSize);
   1.768 +	TEST(err == KErrNone);
   1.769 +	
   1.770 +	TAcceleratedBitmapSpec exSpec(exBmp);
   1.771 +	TAcceleratedBitmapInfo info;
   1.772 +	exBmp->LockHeap();
   1.773 +	err = exSpec.GetInfo(info);
   1.774 +	TEST(err == KErrNone);
   1.775 +	exBmp->UnlockHeap();
   1.776 +	
   1.777 +	TEST(info.iDisplayMode == KDisplayMode);	
   1.778 +	TEST(info.iSize == KSizeInPixels);
   1.779 +	TEST(info.iLinePitch == -EProprietaryCompression);
   1.780 +	TEST(info.iPixelShift == KExtendedBitmapUid.iUid);
   1.781 +	TEST(info.iDataSize == KTestDataSize);
   1.782 +	
   1.783 +	CleanupStack::PopAndDestroy(exBmp);
   1.784 +	}
   1.785 +
   1.786 +const TInt KNumTestFilledRect = 100;
   1.787 +const TInt KNumTestInvertRect = 100;
   1.788 +const TInt KNumTestBitBlt = 100;
   1.789 +const TInt KNumTestFadeRect= 1000;
   1.790 +const TInt KNumTestBitBltMasked= 100;
   1.791 +const TInt KNumTestBitBltAlphaBitmap= 100;
   1.792 +const TInt KNumTestAlphaBlendBitmaps= 100;
   1.793 +
   1.794 +void CTAccelerator::TestFilledRect()
   1.795 +	{
   1.796 +	TInt gopBufferSize = KNumTestFilledRect*sizeof(TGopFilledRect);
   1.797 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
   1.798 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
   1.799 +
   1.800 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
   1.801 +	TRect rect;
   1.802 +
   1.803 +	iFixedRegionPtr = &iFixedRegion;
   1.804 +
   1.805 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.806 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.807 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
   1.808 +
   1.809 +	iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.810 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.811 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
   1.812 +
   1.813 +	TRgb white;
   1.814 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.815 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.816 +	iBitmap3.iGc->SetBrushColor(white);
   1.817 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
   1.818 +
   1.819 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.820 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.821 +	iBitmap4.iGc->SetBrushColor(white);
   1.822 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
   1.823 +
   1.824 +	for(TInt n=0; n<100; n++)
   1.825 +		{
   1.826 +		rect.iTl.iX = Random(TestBitmapSize.iWidth+20)-10;
   1.827 +		rect.iTl.iY = Random(TestBitmapSize.iHeight+20)-10;
   1.828 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth+20);
   1.829 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight+20);
   1.830 +
   1.831 +		
   1.832 +		TRgb colorRect(Random(256),Random(256),Random(256));
   1.833 +
   1.834 +		iBitmap1.iGc->SetBrushColor(colorRect);
   1.835 +		iBitmap1.iGc->DrawRect(rect);
   1.836 +
   1.837 +		iBitmap2.iGc->SetBrushColor(colorRect);
   1.838 +		iBitmap2.iGc->DrawRect(rect);
   1.839 +
   1.840 +		TEST(iBitmap1.Compare(&iBitmap2));
   1.841 +
   1.842 +		rect.Intersection(bitmapRect);
   1.843 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
   1.844 +			{
   1.845 +			TGopFilledRect gop(rect,colorRect);
   1.846 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
   1.847 +			TInt error = iGraphicsAccelerator1->Operation(gop);
   1.848 +			if(error == KErrNotSupported)
   1.849 +				{
   1.850 +				delete gopBuffer;
   1.851 +				WARN_PRINTF1(_L("  Not Supported."));
   1.852 +				return;
   1.853 +				}
   1.854 +			}
   1.855 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
   1.856 +	
   1.857 +		TEST(iBitmap2.Compare(&iBitmap3));
   1.858 +		}
   1.859 +
   1.860 +	iGraphicsAccelerator2->Operation(gopDes);
   1.861 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
   1.862 +	TEST(iBitmap3.Compare(&iBitmap4));
   1.863 +	delete gopBuffer;
   1.864 +	}
   1.865 +
   1.866 +void CTAccelerator::TestFilledRectWithPattern()
   1.867 +	{
   1.868 +	TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopFilledRectWithPattern);
   1.869 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
   1.870 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
   1.871 +
   1.872 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
   1.873 +	TRect rect;
   1.874 +
   1.875 +	iFixedRegionPtr = &iFixedRegion;
   1.876 +
   1.877 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.878 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.879 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   1.880 +	iBitmap1.iGc->UseBrushPattern(iTileBitmap.iBitmap);
   1.881 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
   1.882 +	   
   1.883 +	iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.884 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.885 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   1.886 +	iBitmap2.iGc->UseBrushPattern(iTileBitmap.iBitmap);
   1.887 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
   1.888 +
   1.889 +	TRgb white;
   1.890 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.891 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.892 +	iBitmap3.iGc->SetBrushColor(white);
   1.893 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
   1.894 +
   1.895 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.896 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.897 +	iBitmap4.iGc->SetBrushColor(white);
   1.898 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
   1.899 +
   1.900 +	TAcceleratedBitmapSpec patternBitmapSpec(iTileBitmap.iBitmap);
   1.901 +	TGopFillPattern gopFillPattern;
   1.902 +	gopFillPattern.iBitmap = patternBitmapSpec;
   1.903 +
   1.904 +	for(TInt n=0; n<100; n++)
   1.905 +		{
   1.906 +		rect.iTl.iX = Random(TestBitmapSize.iWidth);
   1.907 +		rect.iTl.iY = Random(TestBitmapSize.iHeight);
   1.908 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth);
   1.909 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight);
   1.910 +
   1.911 +		TPoint brushOrigin(Random(TestBitmapSize.iWidth -5),Random(TestBitmapSize.iHeight-5));
   1.912 +
   1.913 +		iBitmap1.iGc->SetBrushOrigin(brushOrigin);
   1.914 +		iBitmap1.iGc->DrawRect(rect);
   1.915 +
   1.916 +		iBitmap2.iGc->SetBrushOrigin(brushOrigin);
   1.917 +		iBitmap2.iGc->DrawRect(rect);
   1.918 +
   1.919 +		TEST(iBitmap1.Compare(&iBitmap2));
   1.920 +		
   1.921 +		rect.Intersection(bitmapRect);
   1.922 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
   1.923 +			{
   1.924 +			gopFillPattern.iOrigin = brushOrigin;
   1.925 +			TGopFilledRectWithPattern gop(rect,gopFillPattern);
   1.926 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
   1.927 +			TInt error = iGraphicsAccelerator1->Operation(gop);
   1.928 +			if(error == KErrNotSupported)
   1.929 +				{
   1.930 +				delete gopBuffer;
   1.931 +				WARN_PRINTF1(_L("  Not Supported."));
   1.932 +				return;
   1.933 +				}
   1.934 +			}
   1.935 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
   1.936 +		TEST(iBitmap2.Compare(&iBitmap3));
   1.937 +		}
   1.938 +	iGraphicsAccelerator2->Operation(gopDes);
   1.939 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
   1.940 +	TEST(iBitmap3.Compare(&iBitmap4));
   1.941 +	iBitmap1.iGc->DiscardBrushPattern();
   1.942 +	delete gopBuffer;
   1.943 +	}
   1.944 +
   1.945 +void CTAccelerator::TestInvertRect()
   1.946 +	{
   1.947 +	TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopInvertRect);
   1.948 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
   1.949 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
   1.950 +
   1.951 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
   1.952 +	TRect rect;
   1.953 +
   1.954 +	iFixedRegionPtr = &iFixedRegion;
   1.955 +
   1.956 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.957 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.958 +    iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
   1.959 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
   1.960 +
   1.961 +	iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.962 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.963 +    iBitmap2.iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
   1.964 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
   1.965 +
   1.966 +	TRgb white;
   1.967 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.968 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.969 +	iBitmap3.iGc->SetBrushColor(white);
   1.970 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
   1.971 +
   1.972 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.973 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.974 +	iBitmap4.iGc->SetBrushColor(white);
   1.975 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
   1.976 +
   1.977 +	for(TInt n=0; n<100; n++)
   1.978 +		{
   1.979 +		rect.iTl.iX = Random(TestBitmapSize.iWidth+20)-10;
   1.980 +		rect.iTl.iY = Random(TestBitmapSize.iHeight+20)-10;
   1.981 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth+20);
   1.982 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight+20);
   1.983 +
   1.984 +		iBitmap1.iGc->DrawRect(rect);
   1.985 +		iBitmap2.iGc->DrawRect(rect);
   1.986 +
   1.987 +		TEST(iBitmap1.Compare(&iBitmap2));
   1.988 +
   1.989 +		rect.Intersection(bitmapRect);
   1.990 +		if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
   1.991 +			{
   1.992 +			TGopInvertRect gop(rect);
   1.993 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
   1.994 +			TInt error = iGraphicsAccelerator1->Operation(gop);
   1.995 +			if(error == KErrNotSupported)
   1.996 +				{
   1.997 +				delete gopBuffer;
   1.998 +				WARN_PRINTF1(_L("  Not Supported."));
   1.999 +				return;
  1.1000 +				}
  1.1001 +			}
  1.1002 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1003 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1004 +		}
  1.1005 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1006 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1007 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1008 +	delete gopBuffer;
  1.1009 +	}
  1.1010 +
  1.1011 +void CTAccelerator::TestFadeRect()
  1.1012 +	{
  1.1013 +	TInt gopBufferSize = KNumTestFadeRect*sizeof(TGopFadeRect);
  1.1014 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1015 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1016 +
  1.1017 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.1018 +    TRect rect;
  1.1019 +	
  1.1020 +	iFixedRegionPtr = &iFixedRegion;
  1.1021 +
  1.1022 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1023 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1024 +    iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1025 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1026 +
  1.1027 +	iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1028 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1029 +    iBitmap2.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1030 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1031 +
  1.1032 +	for(TInt n=0; n<100; n++)
  1.1033 +		{
  1.1034 +		rect.iTl.iX = Random(TestBitmapSize.iWidth);
  1.1035 +		rect.iTl.iY = Random(TestBitmapSize.iHeight);
  1.1036 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth);
  1.1037 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight);
  1.1038 +
  1.1039 +		TUint8 blackMap = (TUint8)Random(256);
  1.1040 +		TUint8 whiteMap = (TUint8)Random(256);
  1.1041 +
  1.1042 +		RRegion region(rect);
  1.1043 +
  1.1044 +		iBitmap1.iGc->SetFaded(ETrue);
  1.1045 +		iBitmap1.iGc->SetFadingParameters(blackMap,whiteMap);
  1.1046 +		iBitmap1.iGc->FadeArea((TRegion*)&region);
  1.1047 +
  1.1048 +		iBitmap2.iGc->SetFaded(ETrue);
  1.1049 +		iBitmap2.iGc->SetFadingParameters(blackMap,whiteMap);
  1.1050 +		iBitmap2.iGc->FadeArea((TRegion*)&region);
  1.1051 +
  1.1052 +		region.Close();
  1.1053 +
  1.1054 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1055 +		
  1.1056 +		TGopFadeParams fadeParams;
  1.1057 +		fadeParams.iScale = whiteMap - blackMap + 1;
  1.1058 +		fadeParams.iOffset = blackMap;
  1.1059 +		rect.Intersection(bitmapRect);
  1.1060 +
  1.1061 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1062 +			{
  1.1063 +			TGopFadeRect gop(rect,fadeParams);
  1.1064 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
  1.1065 +			TInt error = iGraphicsAccelerator1->Operation(gop);
  1.1066 +			if(error == KErrNotSupported)
  1.1067 +				{
  1.1068 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1069 +				goto quitFade2;
  1.1070 +				}
  1.1071 +			}
  1.1072 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1073 +		}
  1.1074 +
  1.1075 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1076 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1077 +quitFade2:
  1.1078 +	delete gopBuffer;
  1.1079 +	iBitmap1.iGc->SetFaded(EFalse);
  1.1080 +	iBitmap2.iGc->SetFaded(EFalse);
  1.1081 +	}
  1.1082 +
  1.1083 +void CTAccelerator::TestBitBlt()
  1.1084 +	{
  1.1085 +	TInt gopBufferSize = KNumTestBitBlt*sizeof(TGopBitBlt);
  1.1086 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1087 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1088 +
  1.1089 +	//dest bitmap has different size
  1.1090 +	TRect bitmapRect1(0,0,TestBitmapSize1.iWidth,TestBitmapSize1.iHeight);
  1.1091 +
  1.1092 +	TRect rect;
  1.1093 +	iFixedRegionPtr = &iFixedRegion;
  1.1094 +
  1.1095 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1096 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1097 +
  1.1098 +	TRgb white;
  1.1099 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1100 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1101 +	iBitmap3.iGc->SetBrushColor(white);
  1.1102 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1103 +
  1.1104 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1105 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1106 +	iBitmap4.iGc->SetBrushColor(white);
  1.1107 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1108 +
  1.1109 +	TRgb color1(Random(256),Random(256),Random(256));
  1.1110 +
  1.1111 +	iBitmap5.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1112 +	iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1113 +	iBitmap5.iGc->SetBrushColor(color1);
  1.1114 +	iBitmap5.iGc->DrawRect(bitmapRect1);
  1.1115 +
  1.1116 +
  1.1117 +	for(TInt n=0; n<100; n++)
  1.1118 +		{
  1.1119 +		rect.iTl.iX = Random(TestBitmapSize1.iWidth);
  1.1120 +		rect.iTl.iY = Random(TestBitmapSize1.iHeight);
  1.1121 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize1.iWidth);
  1.1122 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize1.iHeight);
  1.1123 +
  1.1124 +        TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.1125 +
  1.1126 +		//bitblt with GC
  1.1127 +		iBitmap1.iGc->BitBlt(pointDest,iBitmap5.iBitmap,rect);
  1.1128 +		iBitmap2.iGc->BitBlt(pointDest,iBitmap5.iBitmap,rect);
  1.1129 +
  1.1130 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1131 +
  1.1132 +		rect.Intersection(bitmapRect1);
  1.1133 +		TSize maxSize=TestBitmapSize-pointDest;
  1.1134 +		if (rect.Width()>maxSize.iWidth)
  1.1135 +			rect.iBr.iX=rect.iTl.iX+maxSize.iWidth;
  1.1136 +		if (rect.Height()>maxSize.iHeight)
  1.1137 +			rect.iBr.iY=rect.iTl.iY+maxSize.iHeight;
  1.1138 +		if(rect.IsEmpty())
  1.1139 +			continue;
  1.1140 +
  1.1141 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1142 +			{
  1.1143 +			TAcceleratedBitmapSpec bitmap5Spec(iBitmap5.iBitmap);
  1.1144 +			TGopBitBlt gopBitBlt(pointDest,bitmap5Spec,rect);
  1.1145 +			gopDes.Append((TUint8*)&gopBitBlt,sizeof(gopBitBlt));
  1.1146 +			TInt error = iGraphicsAccelerator1->Operation(gopBitBlt);
  1.1147 +			if(error == KErrNotSupported)
  1.1148 +				{
  1.1149 +				delete gopBuffer;
  1.1150 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1151 +				return;
  1.1152 +				}
  1.1153 +			}
  1.1154 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1155 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1156 +		}
  1.1157 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1158 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1159 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1160 +	delete gopBuffer;
  1.1161 +	}
  1.1162 +
  1.1163 +void CTAccelerator::TestBitBltMasked()
  1.1164 +	{
  1.1165 +	TInt gopBufferSize = KNumTestBitBltMasked*sizeof(TGopBitBltMasked);
  1.1166 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1167 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1168 +
  1.1169 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.1170 +
  1.1171 +	TRect rect;
  1.1172 +	iFixedRegionPtr = &iFixedRegion;
  1.1173 +
  1.1174 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1175 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1176 +
  1.1177 +	TRgb white;
  1.1178 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1179 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1180 +	iBitmap3.iGc->SetBrushColor(white);
  1.1181 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1182 +
  1.1183 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1184 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1185 +	iBitmap4.iGc->SetBrushColor(white);
  1.1186 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1187 +
  1.1188 +	//Mask bitmap
  1.1189 +	iBitmap6.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1190 +	iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1191 +
  1.1192 +	TRgb color1(Random(256),Random(256),Random(256));
  1.1193 +
  1.1194 +	//Source bitmap
  1.1195 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1196 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1197 +	iBitmap7.iGc->SetBrushColor(color1);
  1.1198 +	iBitmap7.iGc->DrawRect(bitmapRect);
  1.1199 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1200 +
  1.1201 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.1202 +	TAcceleratedBitmapSpec bitmap6Spec(iBitmap6.iBitmap);
  1.1203 +
  1.1204 +	TPoint dest;
  1.1205 +	TRect rectMask;
  1.1206 +
  1.1207 +	//clear the mask bitmap with white
  1.1208 +	iBitmap6.iGc->SetBrushColor(TRgb(255,255,255));
  1.1209 +	iBitmap6.iGc->DrawRect(bitmapRect);
  1.1210 +
  1.1211 +	//Put randomly in the Bitmap Mask a numbers of black rects
  1.1212 +	iBitmap6.iGc->SetBrushColor(TRgb(0,0,0));
  1.1213 +
  1.1214 +	for(TInt n=0; n<10; n++)
  1.1215 +		{
  1.1216 +		rectMask.iTl.iX = Random(TestBitmapSize1.iWidth);
  1.1217 +		rectMask.iTl.iY = Random(TestBitmapSize1.iHeight);
  1.1218 +		rectMask.iBr.iX = rectMask.iTl.iX+1+Random(TestBitmapSize1.iWidth);
  1.1219 +		rectMask.iBr.iY = rectMask.iTl.iY+1+Random(TestBitmapSize1.iHeight);
  1.1220 +		iBitmap6.iGc->DrawRect(rectMask);
  1.1221 +		}
  1.1222 +
  1.1223 +	for(TInt i=0; i<100; i++)
  1.1224 +		{
  1.1225 +	    //random rect to blit
  1.1226 +		rect.iTl.iX = Random(TestBitmapSize1.iWidth);
  1.1227 +		rect.iTl.iY = Random(TestBitmapSize1.iHeight);
  1.1228 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize1.iWidth);
  1.1229 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize1.iHeight);
  1.1230 +
  1.1231 +		//random point destination
  1.1232 +		dest.iX = Random(TestBitmapSize1.iWidth);
  1.1233 +		dest.iY = Random(TestBitmapSize1.iHeight);
  1.1234 +
  1.1235 +		//do BitBltMasked with graphics contex
  1.1236 +        iBitmap1.iGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue);
  1.1237 +        iBitmap2.iGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue);
  1.1238 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1239 +
  1.1240 +		rect.Intersection(bitmapRect);
  1.1241 +		if(rect.IsEmpty())
  1.1242 +			continue;
  1.1243 +
  1.1244 +		if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1245 +			{
  1.1246 +			TGopBitBltMasked gopBitBltMasked(dest,bitmap7Spec,rect,bitmap6Spec);
  1.1247 +			gopDes.Append((TUint8*)&gopBitBltMasked,sizeof(gopBitBltMasked));
  1.1248 +			TInt error = iGraphicsAccelerator1->Operation(gopBitBltMasked);
  1.1249 +			if(error == KErrNotSupported)
  1.1250 +				{
  1.1251 +				delete gopBuffer;
  1.1252 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1253 +				return;
  1.1254 +				}
  1.1255 +			}
  1.1256 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1257 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1258 +		}	
  1.1259 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1260 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1261 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1262 +	delete gopBuffer;
  1.1263 +	}
  1.1264 +
  1.1265 +void CTAccelerator::TestBitBltAlphaBitmap()
  1.1266 +	{
  1.1267 +	TInt gopBufferSize = KNumTestBitBltAlphaBitmap*sizeof(TGopBitBltAlphaBitmap);
  1.1268 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1269 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1270 +
  1.1271 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.1272 +
  1.1273 +    TRect rect;
  1.1274 +	iFixedRegionPtr = &iFixedRegion;
  1.1275 +	
  1.1276 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1277 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1278 +
  1.1279 +	TRgb white;
  1.1280 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1281 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1282 +	iBitmap3.iGc->SetBrushColor(white);
  1.1283 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1284 +
  1.1285 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1286 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1287 +	iBitmap4.iGc->SetBrushColor(white);
  1.1288 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1289 +
  1.1290 +	TRgb color = TRgb(Random(256),Random(256),Random(256));
  1.1291 +
  1.1292 +	//Source bitmap
  1.1293 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1294 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1295 +	iBitmap7.iGc->SetBrushColor(color);
  1.1296 +	iBitmap7.iGc->DrawRect(bitmapRect);
  1.1297 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1298 +
  1.1299 +	iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1300 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1301 +
  1.1302 +	//create 10 gray level for the alpha bitmap
  1.1303 +    for(TInt i=0; i<10;i++)
  1.1304 +		{
  1.1305 +		TRect tmpRect(0,10*i,200,10+10*i);
  1.1306 +		TInt index = 255-(20*i);
  1.1307 +		TRgb tmpRgb;
  1.1308 +        iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index));
  1.1309 +        iAlphaBitmap.iGc->DrawRect(tmpRect);
  1.1310 +		}
  1.1311 +    
  1.1312 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.1313 +	TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap);
  1.1314 +
  1.1315 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1316 +
  1.1317 +	for(TInt n=0; n<100; n++)
  1.1318 +		{
  1.1319 +		rect.iTl.iX = Random(TestBitmapSize.iWidth);
  1.1320 +		rect.iTl.iY = Random(TestBitmapSize.iHeight);
  1.1321 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth);
  1.1322 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight);
  1.1323 +
  1.1324 +		//Random destination point
  1.1325 +		TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.1326 +
  1.1327 +		//alpha blitting with Graphics Contex
  1.1328 +		iBitmap1.iGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue);
  1.1329 +		iBitmap2.iGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue);
  1.1330 +
  1.1331 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1332 +
  1.1333 +		rect.Intersection(bitmapRect);
  1.1334 +		//alpha blitting with Graphics accelerator
  1.1335 +		TGopBitBltAlphaBitmap gopBitBltAlphaBitmap(pointDest,bitmap7Spec,rect,alphaBitmapSpec);
  1.1336 +		gopDes.Append((TUint8*)&gopBitBltAlphaBitmap,sizeof(gopBitBltAlphaBitmap));
  1.1337 +		TInt error = iGraphicsAccelerator1->Operation(gopBitBltAlphaBitmap);
  1.1338 +		if(error == KErrNotSupported)
  1.1339 +			{
  1.1340 +			WARN_PRINTF1(_L("  Not Supported."));
  1.1341 +			goto done;
  1.1342 +			}
  1.1343 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1344 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1345 +		}
  1.1346 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1347 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1348 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1349 +done:
  1.1350 +	delete gopBuffer;
  1.1351 +	}
  1.1352 +	
  1.1353 +void CTAccelerator::TestAlphaBlendTwoBitmaps()
  1.1354 +	{
  1.1355 +	TInt gopBufferSize = KNumTestAlphaBlendBitmaps*sizeof(TGopAlphaBlendTwoBitmaps);
  1.1356 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1357 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1358 +
  1.1359 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.1360 +
  1.1361 +	TRect rect;
  1.1362 +	iFixedRegionPtr = &iFixedRegion;
  1.1363 +	
  1.1364 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1365 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1366 +
  1.1367 +	TRgb white;
  1.1368 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1369 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1370 +	iBitmap3.iGc->SetBrushColor(white);
  1.1371 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1372 +
  1.1373 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1374 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1375 +	iBitmap4.iGc->SetBrushColor(white);
  1.1376 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1377 +
  1.1378 +	TRgb color = TRgb(Random(256),Random(256),Random(256));
  1.1379 +
  1.1380 +	// First Source bitmap
  1.1381 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1382 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1383 +	iBitmap7.iGc->SetBrushColor(color);
  1.1384 +	iBitmap7.iGc->DrawRect(bitmapRect);
  1.1385 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1386 +	
  1.1387 +	// Get a new random color
  1.1388 +	color = TRgb(Random(256),Random(256),Random(256));
  1.1389 +	
  1.1390 +	// Second Source bitmap
  1.1391 +	iBitmap8.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1392 +	iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1393 +	iBitmap8.iGc->SetBrushColor(color);
  1.1394 +	iBitmap8.iGc->DrawRect(bitmapRect);
  1.1395 +	iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1396 +
  1.1397 +	iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1398 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1399 +
  1.1400 +	//create 10 gray level for the alpha bitmap
  1.1401 +	for(TInt i=0; i<10;i++)
  1.1402 +		{
  1.1403 +		TRect tmpRect(0,10*i,200,10+10*i);
  1.1404 +		TInt index = 255-(20*i);
  1.1405 +		TRgb tmpRgb;
  1.1406 +		iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index));
  1.1407 +		iAlphaBitmap.iGc->DrawRect(tmpRect);
  1.1408 +		}
  1.1409 +    
  1.1410 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.1411 +	TAcceleratedBitmapSpec bitmap8Spec(iBitmap8.iBitmap);
  1.1412 +	TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap);
  1.1413 +
  1.1414 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1415 +
  1.1416 +	for(TInt n=0; n<100; n++)
  1.1417 +		{
  1.1418 +		rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); 
  1.1419 +		rect.iTl.iY = Random(TestBitmapSize.iHeight - 1);
  1.1420 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX);
  1.1421 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY);
  1.1422 +
  1.1423 +		TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.1424 +		TPoint pointSource(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.1425 +		TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width() - 1),Random(TestBitmapSize.iHeight - rect.Height() - 1));
  1.1426 +
  1.1427 +		//alpha blending Graphics Context - invalid parameter causes skip to next test
  1.1428 +		TInt rc = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha);
  1.1429 +		if(rc!=KErrNone)
  1.1430 +			{
  1.1431 +			continue;
  1.1432 +			}
  1.1433 +		iBitmap2.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha);
  1.1434 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1435 +
  1.1436 +		rect.Intersection(bitmapRect);
  1.1437 +		//alpha blending with Graphics accelerator
  1.1438 +		TGopAlphaBlendTwoBitmaps gopAlphaBlendTwoBitmaps(pointDest,bitmap7Spec,bitmap8Spec,rect,pointSource,alphaBitmapSpec,pointAlpha);
  1.1439 +		gopDes.Append((TUint8*)&gopAlphaBlendTwoBitmaps,sizeof(gopAlphaBlendTwoBitmaps));
  1.1440 +		TInt error = iGraphicsAccelerator1->Operation(gopAlphaBlendTwoBitmaps);
  1.1441 +		if(error == KErrNotSupported)
  1.1442 +			{
  1.1443 +			WARN_PRINTF1(_L("  Not Supported."));
  1.1444 +			goto done;
  1.1445 +			}
  1.1446 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1447 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1448 +		}
  1.1449 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1450 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1451 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1452 +done:
  1.1453 +	delete gopBuffer;
  1.1454 +	}
  1.1455 +	
  1.1456 +void CTAccelerator::TestAlphaBlendOneBitmap()
  1.1457 +	{
  1.1458 +	TInt gopBufferSize = KNumTestAlphaBlendBitmaps*sizeof(TGopAlphaBlendOneBitmap);
  1.1459 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1460 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1461 +
  1.1462 +	TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.1463 +
  1.1464 +	TRect rect;
  1.1465 +	iFixedRegionPtr = &iFixedRegion;
  1.1466 +	
  1.1467 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1468 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1469 +
  1.1470 +	TRgb white;
  1.1471 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1472 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1473 +	iBitmap3.iGc->SetBrushColor(white);
  1.1474 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1475 +
  1.1476 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1477 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1478 +	iBitmap4.iGc->SetBrushColor(white);
  1.1479 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1480 +
  1.1481 +	TRgb color = TRgb(Random(256),Random(256),Random(256));
  1.1482 +
  1.1483 +	// First Source bitmap
  1.1484 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1485 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1486 +	iBitmap7.iGc->SetBrushColor(color);
  1.1487 +	iBitmap7.iGc->DrawRect(bitmapRect);
  1.1488 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1489 +	
  1.1490 +	// Get a new random color
  1.1491 +	color = TRgb(Random(256),Random(256),Random(256));
  1.1492 +
  1.1493 +	iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1494 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1495 +
  1.1496 +	//create 10 gray level for the alpha bitmap
  1.1497 +	for(TInt i=0; i<10;i++)
  1.1498 +		{
  1.1499 +		TRect tmpRect(0,10*i,200,10+10*i);
  1.1500 +		TInt index = 255-(20*i);
  1.1501 +		TRgb tmpRgb;
  1.1502 +		iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index));
  1.1503 +		iAlphaBitmap.iGc->DrawRect(tmpRect);
  1.1504 +		}
  1.1505 +		  
  1.1506 + 	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.1507 +	TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap);
  1.1508 +
  1.1509 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1510 +
  1.1511 +	for(TInt n=0; n<100; n++)
  1.1512 +		{
  1.1513 +		rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); 
  1.1514 +		rect.iTl.iY = Random(TestBitmapSize.iHeight - 1);
  1.1515 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX);
  1.1516 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY);
  1.1517 +
  1.1518 +		TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.1519 +		TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width()),Random(TestBitmapSize.iHeight - rect.Height()));
  1.1520 +		
  1.1521 +		iBitmap1.iGc->DrawRect(iBitmap1.iBitmap->SizeInPixels());
  1.1522 +		//alpha blending Graphics Context - wrong argument cause skip to next test
  1.1523 +		TInt rc = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha);
  1.1524 +		if(rc!=KErrNone)
  1.1525 +			{
  1.1526 +			continue;
  1.1527 +			}
  1.1528 +		iBitmap2.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha);
  1.1529 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1530 +
  1.1531 +		rect.Intersection(bitmapRect);
  1.1532 +		//alpha blending with Graphics accelerator
  1.1533 +		TGopAlphaBlendOneBitmap gopAlphaBlendOneBitmap(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha);
  1.1534 +		gopDes.Append((TUint8*)&gopAlphaBlendOneBitmap,sizeof(gopAlphaBlendOneBitmap));
  1.1535 +		TInt error = iGraphicsAccelerator1->Operation(gopAlphaBlendOneBitmap);
  1.1536 +		if(error == KErrNotSupported)
  1.1537 +			{
  1.1538 +			WARN_PRINTF1(_L("  Not Supported."));
  1.1539 +			goto done;
  1.1540 +			}
  1.1541 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1542 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1543 +		}
  1.1544 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1545 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1546 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1547 +done:
  1.1548 +	delete gopBuffer;
  1.1549 +	}
  1.1550 +
  1.1551 +void CTAccelerator::TestScreenFilledRect()
  1.1552 +	{
  1.1553 +	TInt gopBufferSize = KNumTestFilledRect*sizeof(TGopFilledRect);
  1.1554 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1555 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1556 +
  1.1557 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.1558 +
  1.1559 +	TRect rect;
  1.1560 +	iFixedRegionPtr = &iFixedRegion;
  1.1561 +
  1.1562 +	//used with GC
  1.1563 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1564 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1565 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1566 +
  1.1567 +	iScreenGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1568 +	iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1569 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.1570 +
  1.1571 +	TRgb white;
  1.1572 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1573 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1574 +	iBitmap3.iGc->SetBrushColor(white);
  1.1575 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1576 +
  1.1577 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1578 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1579 +	iBitmap4.iGc->SetBrushColor(white);
  1.1580 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1581 +
  1.1582 +	for(TInt n=0; n<100; n++)
  1.1583 +		{
  1.1584 +		rect.iTl.iX = Random(TestScreenSize.iWidth+20)-10;
  1.1585 +		rect.iTl.iY = Random(TestScreenSize.iHeight+20)-10;
  1.1586 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth+20);
  1.1587 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight+20);
  1.1588 +
  1.1589 +		TRgb colorRect(Random(256),Random(256),Random(256));
  1.1590 +
  1.1591 +		iBitmap1.iGc->SetBrushColor(colorRect);
  1.1592 +		iBitmap1.iGc->DrawRect(rect);
  1.1593 +
  1.1594 +		iScreenGc->SetBrushColor(colorRect);
  1.1595 +		iScreenGc->DrawRect(rect);
  1.1596 +
  1.1597 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.1598 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1599 +
  1.1600 +		rect.Intersection(screenRect);
  1.1601 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1602 +			{
  1.1603 +			TGopFilledRect gop(rect,colorRect);
  1.1604 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
  1.1605 +			TInt error = iGraphicsAccelerator1->Operation(gop);
  1.1606 +			if(error == KErrNotSupported)
  1.1607 +				{
  1.1608 +				delete gopBuffer;
  1.1609 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1610 +				return;
  1.1611 +				}
  1.1612 +			}
  1.1613 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());	
  1.1614 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1615 +		}
  1.1616 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1617 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1618 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1619 +	delete gopBuffer;
  1.1620 +	}
  1.1621 +
  1.1622 +void CTAccelerator::TestScreenFilledRectWithPattern()
  1.1623 +	{
  1.1624 +	TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopFilledRectWithPattern);
  1.1625 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1626 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1627 +
  1.1628 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.1629 +
  1.1630 +	TRect rect;
  1.1631 +	iFixedRegionPtr = &iFixedRegion;
  1.1632 +
  1.1633 +	//used with GC
  1.1634 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1635 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1636 +	iBitmap1.iGc->UseBrushPattern(iTileBitmap.iBitmap);
  1.1637 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1638 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1639 +	   
  1.1640 +	iScreenGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1641 +	iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1642 +	iScreenGc->UseBrushPattern(iTileBitmap.iBitmap);
  1.1643 +	iScreenGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
  1.1644 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.1645 +
  1.1646 +	TRgb white;
  1.1647 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1648 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1649 +	iBitmap3.iGc->SetBrushColor(white);
  1.1650 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1651 +
  1.1652 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1653 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1654 +	iBitmap4.iGc->SetBrushColor(white);
  1.1655 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1656 +
  1.1657 +	TAcceleratedBitmapSpec patternBitmapSpec(iTileBitmap.iBitmap);
  1.1658 +	TGopFillPattern gopFillPattern;
  1.1659 +	gopFillPattern.iBitmap = patternBitmapSpec;
  1.1660 +
  1.1661 +	for(TInt n=0; n<100; n++)
  1.1662 +		{
  1.1663 +		rect.iTl.iX = Random(TestScreenSize.iWidth);
  1.1664 +		rect.iTl.iY = Random(TestScreenSize.iHeight);
  1.1665 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth);
  1.1666 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight);
  1.1667 +
  1.1668 +		TPoint brushOrigin(Random(TestScreenSize.iWidth -5),Random(TestScreenSize.iHeight-5));
  1.1669 +
  1.1670 +		iBitmap1.iGc->SetBrushOrigin(brushOrigin);
  1.1671 +		iBitmap1.iGc->DrawRect(rect);
  1.1672 +
  1.1673 +		iScreenGc->SetBrushOrigin(brushOrigin);
  1.1674 +		iScreenGc->DrawRect(rect);
  1.1675 +
  1.1676 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.1677 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1678 +
  1.1679 +		rect.Intersection(screenRect);
  1.1680 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1681 +			{
  1.1682 +			gopFillPattern.iOrigin = brushOrigin;
  1.1683 +			TGopFilledRectWithPattern gop(rect,gopFillPattern);
  1.1684 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
  1.1685 +			TInt error = iGraphicsAccelerator1->Operation(gop);
  1.1686 +			if(error == KErrNotSupported)
  1.1687 +				{
  1.1688 +				delete gopBuffer;
  1.1689 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1690 +				return;
  1.1691 +				}
  1.1692 +			}
  1.1693 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1694 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1695 +		}
  1.1696 +
  1.1697 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1698 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1699 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1700 +	iBitmap1.iGc->DiscardBrushPattern();
  1.1701 +	delete gopBuffer;
  1.1702 +	}
  1.1703 +
  1.1704 +void CTAccelerator::TestScreenInvertRect()
  1.1705 +	{
  1.1706 +	TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopInvertRect);
  1.1707 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1708 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1709 +
  1.1710 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.1711 +
  1.1712 +	TRect rect;
  1.1713 +	iFixedRegionPtr = &iFixedRegion;
  1.1714 +
  1.1715 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1716 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1717 +    iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
  1.1718 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1719 +
  1.1720 +	iScreenGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1721 +	iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1722 +    iScreenGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
  1.1723 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.1724 +
  1.1725 +	TRgb white;
  1.1726 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1727 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1728 +	iBitmap3.iGc->SetBrushColor(white);
  1.1729 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1730 +
  1.1731 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1732 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1733 +	iBitmap4.iGc->SetBrushColor(white);
  1.1734 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1735 +
  1.1736 +	for(TInt n=0; n<100; n++)
  1.1737 +		{
  1.1738 +		rect.iTl.iX = Random(TestScreenSize.iWidth+20)-10;
  1.1739 +		rect.iTl.iY = Random(TestScreenSize.iHeight+20)-10;
  1.1740 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth+20);
  1.1741 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight+20);
  1.1742 +
  1.1743 +		iBitmap1.iGc->DrawRect(rect);
  1.1744 +		iScreenGc->DrawRect(rect);
  1.1745 +
  1.1746 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.1747 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1748 +
  1.1749 +		rect.Intersection(screenRect);
  1.1750 +		if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1751 +			{
  1.1752 +			TGopInvertRect gop(rect);
  1.1753 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
  1.1754 +			TInt error = iGraphicsAccelerator1->Operation(gop);
  1.1755 +			if(error == KErrNotSupported)
  1.1756 +				{
  1.1757 +				delete gopBuffer;
  1.1758 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1759 +				return;
  1.1760 +				}
  1.1761 +			}
  1.1762 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1763 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1764 +		}
  1.1765 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1766 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1767 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1768 +	delete gopBuffer;
  1.1769 +	}
  1.1770 +
  1.1771 +void CTAccelerator::TestScreenFadeRect()
  1.1772 +	{
  1.1773 +	TInt gopBufferSize = KNumTestFadeRect*sizeof(TGopFadeRect);
  1.1774 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1775 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1776 +
  1.1777 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.1778 +
  1.1779 +	TRect rect;
  1.1780 +	iFixedRegionPtr = &iFixedRegion;
  1.1781 +
  1.1782 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1783 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1784 +    iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1785 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1786 +
  1.1787 +	iScreenGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1788 +	iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1789 +    iScreenGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.1790 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.1791 +
  1.1792 +	for(TInt n=0; n<100; n++)
  1.1793 +		{
  1.1794 +		rect.iTl.iX = Random(TestScreenSize.iWidth);
  1.1795 +		rect.iTl.iY = Random(TestScreenSize.iHeight);
  1.1796 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth);
  1.1797 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight);
  1.1798 +
  1.1799 +		TUint8 blackMap = (TUint8)Random(256);
  1.1800 +		TUint8 whiteMap = (TUint8)Random(256);
  1.1801 +
  1.1802 +		RRegion region(rect);
  1.1803 +
  1.1804 +		iBitmap1.iGc->SetFaded(ETrue);
  1.1805 +		iBitmap1.iGc->SetFadingParameters(blackMap,whiteMap);
  1.1806 +		iBitmap1.iGc->FadeArea((TRegion*)&region);
  1.1807 +
  1.1808 +		iScreenGc->SetFaded(ETrue);
  1.1809 +		iScreenGc->SetFadingParameters(blackMap,whiteMap);
  1.1810 +		iScreenGc->FadeArea((TRegion*)&region);
  1.1811 +
  1.1812 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.1813 +
  1.1814 +		region.Close();
  1.1815 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1816 +
  1.1817 +		TGopFadeParams fadeParams;
  1.1818 +		fadeParams.iScale = whiteMap - blackMap + 1;
  1.1819 +		fadeParams.iOffset = blackMap;
  1.1820 +		rect.Intersection(screenRect);
  1.1821 +
  1.1822 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1823 +			{
  1.1824 +			TGopFadeRect gop(rect,fadeParams);
  1.1825 +			gopDes.Append((TUint8*)&gop,sizeof(gop));
  1.1826 +			TInt error = iGraphicsAccelerator1->Operation(gop);
  1.1827 +			if(error == KErrNotSupported)
  1.1828 +				{
  1.1829 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1830 +				goto quitFade;
  1.1831 +				}
  1.1832 +			}
  1.1833 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1834 +		}
  1.1835 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1836 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1837 +quitFade:
  1.1838 +	delete gopBuffer;
  1.1839 +	iBitmap1.iGc->SetFaded(EFalse);
  1.1840 +	iScreenGc->SetFaded(EFalse);
  1.1841 +	}
  1.1842 +
  1.1843 +void CTAccelerator::TestScreenBitBlt()
  1.1844 +	{
  1.1845 +	TInt gopBufferSize = KNumTestBitBlt*sizeof(TGopBitBlt);
  1.1846 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1847 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1848 +
  1.1849 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.1850 +	//dest bitmap has different size
  1.1851 +	TRect bitmapRect1(0,0,TestBitmapSize1.iWidth,TestBitmapSize1.iHeight);
  1.1852 +
  1.1853 +	TRect rect;
  1.1854 +	iFixedRegionPtr = &iFixedRegion;
  1.1855 +
  1.1856 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1857 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.1858 +
  1.1859 +	TRgb white;
  1.1860 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1861 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1862 +	iBitmap3.iGc->SetBrushColor(white);
  1.1863 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1864 +
  1.1865 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1866 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1867 +	iBitmap4.iGc->SetBrushColor(white);
  1.1868 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1869 +
  1.1870 +	TRgb color1(Random(256),Random(256),Random(256));
  1.1871 +
  1.1872 +	iBitmap5.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1873 +	iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1874 +	iBitmap5.iGc->SetBrushColor(color1);
  1.1875 +	iBitmap5.iGc->DrawRect(bitmapRect1);
  1.1876 +
  1.1877 +
  1.1878 +	for(TInt n=0; n<100; n++)
  1.1879 +		{
  1.1880 +		rect.iTl.iX = Random(TestBitmapSize1.iWidth);
  1.1881 +		rect.iTl.iY = Random(TestBitmapSize1.iHeight);
  1.1882 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize1.iWidth);
  1.1883 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize1.iHeight);
  1.1884 +
  1.1885 +        TPoint pointDest(Random(TestScreenSize.iWidth),Random(TestScreenSize.iHeight));
  1.1886 +
  1.1887 +		//bitblt with GC
  1.1888 +		iBitmap1.iGc->BitBlt(pointDest,iBitmap5.iBitmap,rect);
  1.1889 +		iScreenGc->BitBlt(pointDest,iBitmap5.iBitmap,rect);
  1.1890 +
  1.1891 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.1892 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.1893 +
  1.1894 +		TInt extraWidth=(pointDest.iX+rect.Width())-TestScreenSize.iWidth;
  1.1895 +		if (extraWidth>0)
  1.1896 +			rect.iBr.iX-=extraWidth;
  1.1897 +		TInt extraHeight=(pointDest.iY+rect.Height())-TestScreenSize.iHeight;
  1.1898 +		if (extraHeight>0)
  1.1899 +			rect.iBr.iY-=extraHeight;
  1.1900 +		rect.Intersection(bitmapRect1);
  1.1901 +		TSize maxSize=TestBitmapSize-pointDest;
  1.1902 +		if (rect.Width()>maxSize.iWidth)
  1.1903 +			rect.iBr.iX=rect.iTl.iX+maxSize.iWidth;
  1.1904 +		if (rect.Height()>maxSize.iHeight)
  1.1905 +			rect.iBr.iY=rect.iTl.iY+maxSize.iHeight;
  1.1906 +		if(rect.IsEmpty())
  1.1907 +			continue;
  1.1908 +
  1.1909 +		if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.1910 +			{
  1.1911 +			TAcceleratedBitmapSpec bitmap5Spec(iBitmap5.iBitmap);
  1.1912 +			TGopBitBlt gopBitBlt(pointDest,bitmap5Spec,rect);
  1.1913 +			gopDes.Append((TUint8*)&gopBitBlt,sizeof(gopBitBlt));
  1.1914 +			TInt error = iGraphicsAccelerator1->Operation(gopBitBlt);
  1.1915 +			if(error == KErrNotSupported)
  1.1916 +				{
  1.1917 +				delete gopBuffer;
  1.1918 +				WARN_PRINTF1(_L("  Not Supported."));
  1.1919 +				return;
  1.1920 +				}
  1.1921 +			}
  1.1922 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.1923 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.1924 +		}
  1.1925 +	iGraphicsAccelerator2->Operation(gopDes);
  1.1926 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.1927 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.1928 +	delete gopBuffer;
  1.1929 +	}
  1.1930 +
  1.1931 +void CTAccelerator::TestScreenBitBltMasked()
  1.1932 +	{
  1.1933 +	TInt gopBufferSize = KNumTestBitBltMasked*sizeof(TGopBitBltMasked);
  1.1934 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.1935 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.1936 +
  1.1937 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.1938 +
  1.1939 +	TRect rect;
  1.1940 +	iFixedRegionPtr = &iFixedRegion;
  1.1941 +
  1.1942 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.1943 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.1944 +
  1.1945 +	TRgb white;
  1.1946 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1947 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1948 +	iBitmap3.iGc->SetBrushColor(white);
  1.1949 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.1950 +
  1.1951 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1952 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1953 +	iBitmap4.iGc->SetBrushColor(white);
  1.1954 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.1955 +
  1.1956 +	//Mask bitmap
  1.1957 +	iBitmap6.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1958 +	iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1959 +
  1.1960 +	TRgb color1(Random(256),Random(256),Random(256));
  1.1961 +
  1.1962 +	//Source bitmap
  1.1963 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1964 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1965 +	iBitmap7.iGc->SetBrushColor(color1);
  1.1966 +	iBitmap7.iGc->DrawRect(iBitmap7.iBitmap->SizeInPixels());
  1.1967 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1968 +
  1.1969 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.1970 +	TAcceleratedBitmapSpec bitmap6Spec(iBitmap6.iBitmap);
  1.1971 +
  1.1972 +	TPoint dest;
  1.1973 +	TRect rectMask;
  1.1974 +
  1.1975 +	//Put randomly in the Bitmap Mask a numbers of black rects
  1.1976 +	iBitmap6.iGc->SetBrushColor(TRgb(0,0,0));
  1.1977 +
  1.1978 +	for(TInt n=0; n<3; n++)
  1.1979 +		{
  1.1980 +		rectMask.iTl.iX = Random(TestScreenSize.iWidth);
  1.1981 +		rectMask.iTl.iY = Random(TestScreenSize.iHeight);
  1.1982 +		rectMask.iBr.iX = rectMask.iTl.iX+1+Random(TestScreenSize.iWidth);
  1.1983 +		rectMask.iBr.iY = rectMask.iTl.iY+1+Random(TestScreenSize.iHeight);
  1.1984 +		iBitmap6.iGc->DrawRect(rectMask);
  1.1985 +		}
  1.1986 +
  1.1987 +	for(TInt i=0; i<100; i++)
  1.1988 +		{
  1.1989 +	    //random rect to blit
  1.1990 +		rect.iTl.iX = Random(TestScreenSize.iWidth);
  1.1991 +		rect.iTl.iY = Random(TestScreenSize.iHeight);
  1.1992 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth);
  1.1993 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight);
  1.1994 +
  1.1995 +		//random point destination
  1.1996 +		dest.iX = Random(TestScreenSize.iWidth);
  1.1997 +		dest.iY = Random(TestScreenSize.iHeight);
  1.1998 +
  1.1999 +        iBitmap1.iGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue);
  1.2000 +        iScreenGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue);
  1.2001 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.2002 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.2003 +
  1.2004 +		rect.Intersection(screenRect);
  1.2005 +		if(rect.IsEmpty())
  1.2006 +			continue;
  1.2007 +
  1.2008 +		if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY))
  1.2009 +			{
  1.2010 +			TGopBitBltMasked gopBitBltMasked(dest,bitmap7Spec,rect,bitmap6Spec);
  1.2011 +			gopDes.Append((TUint8*)&gopBitBltMasked,sizeof(gopBitBltMasked));
  1.2012 +			TInt error = iGraphicsAccelerator1->Operation(gopBitBltMasked);
  1.2013 +			if(error == KErrNotSupported)
  1.2014 +				{
  1.2015 +				delete gopBuffer;
  1.2016 +				WARN_PRINTF1(_L("  Not Supported."));
  1.2017 +				return;
  1.2018 +				}
  1.2019 +			}
  1.2020 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.2021 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.2022 +		}	
  1.2023 +	iGraphicsAccelerator2->Operation(gopDes);
  1.2024 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.2025 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.2026 +	delete gopBuffer;
  1.2027 +	}
  1.2028 +
  1.2029 +void CTAccelerator::TestScreenBitBltAlphaBitmap()
  1.2030 +	{
  1.2031 +	TInt gopBufferSize = KNumTestBitBltAlphaBitmap*sizeof(TGopBitBltAlphaBitmap);
  1.2032 +	TUint8* gopBuffer = new TUint8[gopBufferSize];
  1.2033 +	TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize);
  1.2034 +
  1.2035 +	TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight);
  1.2036 +
  1.2037 +    TRect rect;
  1.2038 +	iFixedRegionPtr = &iFixedRegion;
  1.2039 +	
  1.2040 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2041 +	iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.2042 +
  1.2043 +	TRgb white;
  1.2044 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2045 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2046 +	iBitmap3.iGc->SetBrushColor(white);
  1.2047 +	iBitmap3.iGc->SetClippingRegion(iSubRegionPtr);
  1.2048 +
  1.2049 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2050 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2051 +	iBitmap4.iGc->SetBrushColor(white);
  1.2052 +	iBitmap4.iGc->SetClippingRegion(iSubRegionPtr);
  1.2053 +
  1.2054 +	TRgb color = TRgb(Random(256),Random(256),Random(256));
  1.2055 +
  1.2056 +	//Source bitmap
  1.2057 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2058 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2059 +	iBitmap7.iGc->SetBrushColor(color);
  1.2060 +	iBitmap7.iGc->DrawRect(iBitmap7.iBitmap->SizeInPixels());
  1.2061 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2062 +
  1.2063 +	
  1.2064 +	iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2065 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2066 +
  1.2067 +
  1.2068 +    //create 10 gray level for the alpha bitmap
  1.2069 +    for(TInt i=0; i<10;i++)
  1.2070 +		{
  1.2071 +		TRect tmpRect(0,10*i,200,10+10*i);
  1.2072 +		TInt index = 255-(20*i);
  1.2073 +		TRgb tmpRgb;
  1.2074 +        iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index));
  1.2075 +        iAlphaBitmap.iGc->DrawRect(tmpRect);
  1.2076 +		}
  1.2077 +
  1.2078 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.2079 +	TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap);
  1.2080 +
  1.2081 +   	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2082 +
  1.2083 +	for(TInt n=0; n<100; n++)
  1.2084 +		{
  1.2085 +		rect.iTl.iX = Random(TestBitmapSize.iWidth);
  1.2086 +		rect.iTl.iY = Random(TestBitmapSize.iHeight);
  1.2087 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth);
  1.2088 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight);
  1.2089 +
  1.2090 +		//Random destination point
  1.2091 +		TPoint pointDest(Random(TestScreenSize.iWidth),Random(TestScreenSize.iHeight));
  1.2092 +
  1.2093 +		//alpha blitting with Graphics Contex
  1.2094 +		iBitmap1.iGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue);
  1.2095 +		iScreenGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue);
  1.2096 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.2097 +
  1.2098 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.2099 +
  1.2100 +		rect.Intersection(screenRect);
  1.2101 +		//alpha blitting with Graphics accelerator
  1.2102 +		TGopBitBltAlphaBitmap gopBitBltAlphaBitmap(pointDest,bitmap7Spec,rect,alphaBitmapSpec);
  1.2103 +		gopDes.Append((TUint8*)&gopBitBltAlphaBitmap,sizeof(gopBitBltAlphaBitmap));
  1.2104 +		TInt error = iGraphicsAccelerator1->Operation(gopBitBltAlphaBitmap);
  1.2105 +		if(error == KErrNotSupported)
  1.2106 +			{
  1.2107 +			WARN_PRINTF1(_L("  Not Supported."));
  1.2108 +			goto done;
  1.2109 +			}
  1.2110 +		iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels());
  1.2111 +		TEST(iBitmap2.Compare(&iBitmap3));
  1.2112 +		}
  1.2113 +	iGraphicsAccelerator2->Operation(gopDes);
  1.2114 +	iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels());
  1.2115 +	TEST(iBitmap3.Compare(&iBitmap4));
  1.2116 +done:
  1.2117 +	delete gopBuffer;
  1.2118 +	}
  1.2119 +	
  1.2120 +void CTAccelerator::TestScreenAlphaBlendTwoBitmaps()
  1.2121 +	{
  1.2122 +	TRect screenRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.2123 +
  1.2124 +	TRect rect;
  1.2125 +	iFixedRegionPtr = &iFixedRegion;
  1.2126 +	
  1.2127 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2128 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2129 +
  1.2130 +	TRgb color = TRgb(Random(256),Random(256),Random(256));
  1.2131 +
  1.2132 +	// First Source bitmap
  1.2133 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2134 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2135 +	iBitmap7.iGc->SetBrushColor(color);
  1.2136 +	iBitmap7.iGc->DrawRect(screenRect);
  1.2137 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2138 +	
  1.2139 +	// Get a new random color
  1.2140 +	color = TRgb(Random(256),Random(256),Random(256));
  1.2141 +	
  1.2142 +	// Second Source bitmap
  1.2143 +	iBitmap8.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2144 +	iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2145 +	iBitmap8.iGc->SetBrushColor(color);
  1.2146 +	iBitmap8.iGc->DrawRect(screenRect);
  1.2147 +	iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2148 +
  1.2149 +	iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2150 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2151 +
  1.2152 +	//create 10 gray level for the alpha bitmap
  1.2153 +	for(TInt i=0; i<10;i++)
  1.2154 +		{
  1.2155 +		TRect tmpRect(0,10*i,200,10+10*i);
  1.2156 +		TInt index = 255-(20*i);
  1.2157 +		TRgb tmpRgb;
  1.2158 +		iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index));
  1.2159 +		iAlphaBitmap.iGc->DrawRect(tmpRect);
  1.2160 +		}
  1.2161 +    
  1.2162 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.2163 +	TAcceleratedBitmapSpec bitmap8Spec(iBitmap8.iBitmap);
  1.2164 +	TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap);
  1.2165 +
  1.2166 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2167 +
  1.2168 +	for(TInt n=0; n<100; n++)
  1.2169 +		{
  1.2170 +		rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); 
  1.2171 +		rect.iTl.iY = Random(TestBitmapSize.iHeight - 1);
  1.2172 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX);
  1.2173 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY);
  1.2174 +
  1.2175 +		TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.2176 +		TPoint pointSource(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.2177 +		TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width()),Random(TestBitmapSize.iHeight - rect.Height()));
  1.2178 +
  1.2179 +		//alpha blending Graphics Context - wrong argument cause skip to next test
  1.2180 +		TInt error = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha);
  1.2181 +		// AlphaBlendBitmaps can return KErrArgument based on the input data - in that case, continue
  1.2182 +		if(error!=KErrNone)
  1.2183 +			{
  1.2184 +			continue;
  1.2185 +			}
  1.2186 +		iScreenGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha);
  1.2187 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.2188 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.2189 +		}
  1.2190 +	}
  1.2191 +
  1.2192 +void CTAccelerator::TestScreenAlphaBlendOneBitmap()
  1.2193 +	{
  1.2194 +	TRect screenRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight);
  1.2195 +
  1.2196 +	TRect rect;
  1.2197 +	iFixedRegionPtr = &iFixedRegion;
  1.2198 +	
  1.2199 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2200 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2201 +
  1.2202 +	TRgb color = TRgb(Random(256),Random(256),Random(256));
  1.2203 +
  1.2204 +	// First Source bitmap
  1.2205 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2206 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2207 +	iBitmap7.iGc->SetBrushColor(color);
  1.2208 +	iBitmap7.iGc->DrawRect(screenRect);
  1.2209 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2210 +	
  1.2211 +	// Get a new random color
  1.2212 +	color = TRgb(Random(256),Random(256),Random(256));
  1.2213 +
  1.2214 +	iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2215 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2216 +
  1.2217 +	//create 10 gray level for the alpha bitmap
  1.2218 +	for(TInt i=0; i<10;i++)
  1.2219 +		{
  1.2220 +		TRect tmpRect(0,10*i,200,10+10*i);
  1.2221 +		TInt index = 255-(20*i);
  1.2222 +		TRgb tmpRgb;
  1.2223 +		iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index));
  1.2224 +		iAlphaBitmap.iGc->DrawRect(tmpRect);
  1.2225 +		}
  1.2226 +    
  1.2227 +	TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap);
  1.2228 +	TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap);
  1.2229 +
  1.2230 +	iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2231 +
  1.2232 +	for(TInt n=0; n<100; n++)
  1.2233 +		{
  1.2234 +		if(n==0) continue;
  1.2235 +		rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); 
  1.2236 +		rect.iTl.iY = Random(TestBitmapSize.iHeight - 1);
  1.2237 +		rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX);
  1.2238 +		rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY);
  1.2239 +
  1.2240 +		TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight));
  1.2241 +		TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width() - 1),Random(TestBitmapSize.iHeight - rect.Height() - 1));
  1.2242 +
  1.2243 +		//alpha blending Graphics Context - wrong argument cause skip to next test
  1.2244 +		TInt rc = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha);
  1.2245 +		if(rc!=KErrNone)
  1.2246 +			{
  1.2247 +			continue;
  1.2248 +			}
  1.2249 +		iScreenGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha);
  1.2250 +		iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect);
  1.2251 +		TEST(iBitmap1.Compare(&iBitmap2));
  1.2252 +		}
  1.2253 +	}
  1.2254 +
  1.2255 +void CTAccelerator::resetColorBitmaps()
  1.2256 +	{
  1.2257 +	TRgb color;
  1.2258 +	iFixedRegionPtr = &iDefaultRegion;
  1.2259 +
  1.2260 +	if(iHwScreenDevice)
  1.2261 +		{
  1.2262 +		iFixedRegionPtr = &iDefaultScreenRegion;
  1.2263 +		iScreenGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2264 +		iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2265 +		iScreenGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2266 +		iScreenGc->SetClippingRegion(iFixedRegionPtr);
  1.2267 +		iScreenGc->SetBrushColor(color);
  1.2268 +		iScreenGc->DrawRect(TestScreenSize);
  1.2269 +		iScreenGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2270 +		}
  1.2271 +
  1.2272 +	iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2273 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2274 +    iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2275 +	iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2276 +	iBitmap1.iGc->SetBrushColor(color);
  1.2277 +	TRect rect1(iBitmap1.iBitmap->SizeInPixels());
  1.2278 +	iBitmap1.iGc->DrawRect(rect1);
  1.2279 +	iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2280 +
  1.2281 +	iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2282 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2283 +	iBitmap2.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2284 +	iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2285 +	iBitmap2.iGc->SetBrushColor(color);
  1.2286 +	TRect rect2(iBitmap2.iBitmap->SizeInPixels());
  1.2287 +	iBitmap2.iGc->DrawRect(rect2);
  1.2288 +	iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2289 +
  1.2290 +	//GA1
  1.2291 +	iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2292 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2293 +    iBitmap3.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2294 +	iBitmap3.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2295 +	iBitmap3.iGc->SetBrushColor(color);
  1.2296 +	TRect rect3(iBitmap3.iBitmap->SizeInPixels());
  1.2297 +	iBitmap3.iGc->DrawRect(rect3);
  1.2298 +	iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2299 +
  1.2300 +	//GA2
  1.2301 +	iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2302 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2303 +    iBitmap4.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2304 +	iBitmap4.iGc->SetClippingRegion(iFixedRegionPtr);
  1.2305 +	iBitmap4.iGc->SetBrushColor(color);
  1.2306 +	TRect rect4(iBitmap4.iBitmap->SizeInPixels());
  1.2307 +	iBitmap4.iGc->DrawRect(rect4);
  1.2308 +	iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2309 +
  1.2310 +	iBitmap5.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2311 +	iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2312 +    iBitmap5.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2313 +	iBitmap5.iGc->SetBrushColor(color);
  1.2314 +	TRect rect5(iBitmap5.iBitmap->SizeInPixels());
  1.2315 +	iBitmap5.iGc->DrawRect(rect5);
  1.2316 +	iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2317 +
  1.2318 +	iBitmap6.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2319 +	iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2320 +    iBitmap6.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2321 +	iBitmap6.iGc->SetBrushColor(color);
  1.2322 +	TRect rect6(iBitmap6.iBitmap->SizeInPixels());
  1.2323 +	iBitmap6.iGc->DrawRect(rect6);
  1.2324 +	iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2325 +
  1.2326 +	iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2327 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2328 +    iBitmap7.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2329 +	iBitmap7.iGc->SetBrushColor(color);
  1.2330 +	TRect rect7(iBitmap7.iBitmap->SizeInPixels());
  1.2331 +	iBitmap7.iGc->DrawRect(rect7);
  1.2332 +	iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2333 +	
  1.2334 +	iBitmap8.iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.2335 +	iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2336 +	iBitmap8.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
  1.2337 +	iBitmap8.iGc->SetBrushColor(color);
  1.2338 +	TRect rect8(iBitmap8.iBitmap->SizeInPixels());
  1.2339 +	iBitmap8.iGc->DrawRect(rect8);
  1.2340 +	iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.2341 +	}
  1.2342 +
  1.2343 +void CTAccelerator::TestScreenRotation()
  1.2344 +	{
  1.2345 +	// Checks that clearing a rotated screen doesn't blow-up
  1.2346 +	iScreenGc->SetOrientation(CFbsBitGc::EGraphicsOrientationRotated90);
  1.2347 +
  1.2348 +	iScreenGc->Reset();
  1.2349 +	// fill screen using graphics accelerator
  1.2350 +	iScreenGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1.2351 +	iScreenGc->SetPenStyle(CFbsBitGc::ENullPen);
  1.2352 +	iScreenGc->DrawRect(TRect(0,0,KMaxTInt/2,KMaxTInt/2));
  1.2353 +
  1.2354 +	// restore orientation
  1.2355 +	iScreenGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
  1.2356 +	iScreenGc->Reset();
  1.2357 +	}
  1.2358 +
  1.2359 +void CTAccelerator::TestUserDisplayMode()
  1.2360 +	{
  1.2361 +	iScreenGc->Reset();
  1.2362 +	// Change to Gray4 mode
  1.2363 +	iScreenGc->SetUserDisplayMode(EGray4);
  1.2364 +	// fill screen using graphics accelerator
  1.2365 +	iScreenGc->SetBrushStyle(CFbsBitGc::ESolidBrush);
  1.2366 +	iScreenGc->SetBrushColor(TRgb(0x44,0x44,0x44)); // should get 'rounded up' to 0x55,0x55,0x55 when drawn
  1.2367 +	iScreenGc->SetPenStyle(CFbsBitGc::ENullPen);
  1.2368 +	iScreenGc->DrawRect(TRect(0,0,KMaxTInt/2,KMaxTInt/2));
  1.2369 +
  1.2370 +	TRgb pixel;
  1.2371 +	iHwScreenDevice->GetPixel(pixel,TPoint(0,0));
  1.2372 +	TRgb checkValue(0x555555,0xff);
  1.2373 +	if (iHwScreenDevice->DisplayMode()==EColor64K)
  1.2374 +		checkValue=TRgb::Color64K(checkValue.Color64K());
  1.2375 +	TEST(pixel==checkValue);  // check pixel color is that of a Gray4 one
  1.2376 +
  1.2377 +	// Restore user display mode
  1.2378 +	iScreenGc->Reset();
  1.2379 +	}
  1.2380 +
  1.2381 +static void CheckDisplayMode()
  1.2382 +	{
  1.2383 +	TInt i;
  1.2384 +	for(i=0; i<KNumDisplayModes; ++i)
  1.2385 +		{
  1.2386 +		TDisplayMode mode = TestDisplayModes[i].iMode;
  1.2387 +		CFbsScreenDevice* device = NULL;
  1.2388 +		TInt err = KErrNone;
  1.2389 +		TRAP(err, device = CFbsScreenDevice::NewL(_L("scdv"), mode));
  1.2390 +		if (err == KErrNone)
  1.2391 +			{
  1.2392 +			TestDisplayModes[i].iEnabled = ETrue;
  1.2393 +			delete device;
  1.2394 +			}
  1.2395 +		}
  1.2396 +	}
  1.2397 +	
  1.2398 +//--------------
  1.2399 +__CONSTRUCT_STEP__(Accelerator)
  1.2400 +
  1.2401 +void CTAcceleratorStep::TestSetupL()
  1.2402 +	{
  1.2403 +	FbsStartup();
  1.2404 +	User::LeaveIfError(RFbsSession::Connect());
  1.2405 +	
  1.2406 +	CheckDisplayMode();
  1.2407 +	}
  1.2408 +	
  1.2409 +void CTAcceleratorStep::TestClose()
  1.2410 +	{
  1.2411 +	RFbsSession::Disconnect();
  1.2412 +	}
  1.2413 +
  1.2414 +
  1.2415 +
  1.2416 +
  1.2417 +