os/graphics/graphicsdeviceinterface/bitgdi/tbit/TDefect.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/TDefect.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,3374 @@
     1.4 +// Copyright (c) 2003-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 <hal.h>
    1.20 +#include <bautils.h>
    1.21 +#include <bitdraw.h>
    1.22 +#include <s32mem.h>
    1.23 +#include "TDefect.h"
    1.24 +#include <graphics/bitmap.inl>
    1.25 +#include <graphics/gdi/gdiconsts.h>
    1.26 +
    1.27 +_LIT(KRamBitmapOnZ, "z:\\system\\data\\16RAM.mbm");
    1.28 +_LIT(KRamCBitmapOnZ, "z:\\system\\data\\16RAMC.mbm");
    1.29 +
    1.30 +_LIT(KRamBitmap, "c:\\16RAM.mbm");
    1.31 +_LIT(KRamCBitmap, "c:\\16RAMC.mbm");
    1.32 +
    1.33 +_LIT(KZeroSizeMbmRam, "c:\\ZeroSizeRam.mbm");
    1.34 +_LIT(KZeroSizeMbmZ, "z:\\system\\data\\ZeroSizeRam.mbm");
    1.35 +
    1.36 +_LIT(KRomBitmap, "z:\\system\\data\\16ROM.mbm");
    1.37 +_LIT(KRomCBitmap, "z:\\system\\data\\16ROMC.mbm");
    1.38 +
    1.39 +_LIT(KRomRsc_RomMbm, "z:\\system\\data\\RomRsc_RomMbm.rsc");
    1.40 +_LIT(KRomRsc_RomMbm2, "z:\\system\\data\\RomRsc_RomMbm2.rsc");
    1.41 +_LIT(KRamRsc_RamMbmOnZ, "z:\\system\\data\\RamRsc_RamMbm.rsc");
    1.42 +_LIT(KRamRsc_RamMbm2OnZ, "z:\\system\\data\\RamRsc_RamMbm2.rsc");
    1.43 +_LIT(KRamRsc_RamMbm, "c:\\RamRsc_RamMbm.rsc");
    1.44 +_LIT(KRamRsc_RamMbm2, "c:\\RamRsc_RamMbm2.rsc");
    1.45 +_LIT(KRscFileHeader, "z:\\system\\data\\RscHeader2.bin");
    1.46 +_LIT(KRscFileData, "z:\\system\\data\\DummyRscFile.rsc");
    1.47 +_LIT(KRomRsc_RamMbm, "z:\\system\\data\\RomRsc_RamMbm.rsc");
    1.48 +_LIT(KRamRsc_RomMbmOnZ, "z:\\system\\data\\RamRsc_RomMbm.rsc");
    1.49 +_LIT(KRamRsc_RomMbm, "c:\\RamRsc_RomMbm.rsc");
    1.50 +_LIT(KRamRsc_RomMbm2OnZ, "z:\\system\\data\\RamRsc_RomMbm2.rsc");
    1.51 +_LIT(KRamRsc_RomMbm2, "c:\\RamRsc_RomMbm2.rsc");
    1.52 +_LIT(KRomRsc_RamMbm2, "z:\\system\\data\\RomRsc_RamMbm2.rsc");
    1.53 +
    1.54 +_LIT(KComprRamBitmap16, "z:\\system\\data\\paint16ramc.mbm");
    1.55 +_LIT(KComprRomBitmap16, "z:\\system\\data\\paint16romc.mbm");
    1.56 +_LIT(KComprRamBitmap24, "z:\\system\\data\\paint24ramc.mbm");
    1.57 +_LIT(KComprRomBitmap24, "z:\\system\\data\\paint24romc.mbm");
    1.58 +
    1.59 +_LIT(KComprRamBitmap8, "z:\\system\\data\\8ramc.mbm");
    1.60 +_LIT(KComprRomBitmap8, "z:\\system\\data\\8romc.mbm");
    1.61 +_LIT(KComprRamBitmap12, "z:\\system\\data\\12ramc.mbm");
    1.62 +_LIT(KComprRomBitmap12, "z:\\system\\data\\12romc.mbm");
    1.63 +
    1.64 +_LIT(KTestBmp, "z:\\system\\data\\BmCTest.mbm");
    1.65 +
    1.66 +_LIT(KBitBltSrcBmp, "z:\\system\\data\\BitBltSrc.mbm");
    1.67 +_LIT(KBitBltMaskedBmp, "z:\\system\\data\\BitBltMasked.mbm");
    1.68 +
    1.69 +_LIT(KBmpCompr12, "z:\\system\\data\\compr12_2.mbm");
    1.70 +_LIT(KBmpCompr16, "z:\\system\\data\\compr16_2.mbm");
    1.71 +_LIT(KBmpZCompr12, "z:\\system\\data\\racompr12_2.mbm");
    1.72 +_LIT(KBmpZCompr16, "z:\\system\\data\\racompr16_2.mbm");
    1.73 +_LIT(KBmpCCompr12, "c:\\racompr12_2.mbm");
    1.74 +_LIT(KBmpCCompr16, "c:\\racompr16_2.mbm");
    1.75 +
    1.76 +_LIT(KBmp16_1, "c:\\Mbm16_1.mbm");
    1.77 +_LIT(KBmp16_2, "c:\\Mbm16_2.mbm");
    1.78 +_LIT(KBmp16_3, "c:\\Mbm16_3.mbm");
    1.79 +
    1.80 +_LIT(KRam24BitmapOnZ, "z:\\system\\data\\24RAM.mbm");
    1.81 +_LIT(KRamC24BitmapOnZ, "z:\\system\\data\\24RAMC.mbm");
    1.82 +
    1.83 +_LIT(KRam24Bitmap, "c:\\24RAM.mbm");
    1.84 +_LIT(KRamC24Bitmap, "c:\\24RAMC.mbm");
    1.85 +
    1.86 +_LIT(KRom24Bitmap, "z:\\system\\data\\24ROM.mbm");
    1.87 +_LIT(KRomC24Bitmap, "z:\\system\\data\\24ROMC.mbm");
    1.88 +
    1.89 +//Note: Do not name functions with Defect numbers, instead give a meaningful name.
    1.90 +
    1.91 +//
    1.92 +//
    1.93 +//Note: Some display modes will be scaled - see 
    1.94 +//CTDefect::CreateScreenDeviceL(TDisplayMode aDisplayMode, TAllowScaling aScaling),
    1.95 +//SetScalingFactor() call
    1.96 +
    1.97 +//
    1.98 +//
    1.99 +//If we have to handle RAM located file with an embedded ROM mbm file section - 
   1.100 +//KRomMBMInRamRSC should be ETrue.
   1.101 +//If it is not allowed to do that - KRomMBMInRamRSC should be EFalse.
   1.102 +//#pragma warning(disable : 4127)   //conditional expression is constant
   1.103 +//Constant KRomMBMInRamRSc removed temporarily due to invalid test scenario
   1.104 +//LOCAL_D const TBool KRomMBMInRamRSC = EFalse;
   1.105 +
   1.106 +//
   1.107 +//
   1.108 +
   1.109 +//
   1.110 +//
   1.111 +//Globals
   1.112 +LOCAL_D RFs		TheFs;
   1.113 +//Delay time in microseconds, used at the end of some test methods
   1.114 +const TInt		KDelayTime = 1;//1500000;
   1.115 +
   1.116 +//
   1.117 +//
   1.118 +//Create/Destroy test environment global functions
   1.119 +
   1.120 +//Delete "aFullName" file.
   1.121 +LOCAL_C void DeleteDataFile(const TDesC& aFullName)
   1.122 +	{
   1.123 +	RFs fsSession;
   1.124 +	TInt err = fsSession.Connect();
   1.125 +	if(err == KErrNone)
   1.126 +		{
   1.127 +		TEntry entry;
   1.128 +		if(fsSession.Entry(aFullName, entry) == KErrNone)
   1.129 +			{
   1.130 +			RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
   1.131 +			err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
   1.132 +			if(err != KErrNone) 
   1.133 +				{
   1.134 +				RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
   1.135 +				}
   1.136 +			err = fsSession.Delete(aFullName);
   1.137 +			if(err != KErrNone) 
   1.138 +				{
   1.139 +				RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
   1.140 +				}
   1.141 +			}
   1.142 +		fsSession.Close();
   1.143 +		}
   1.144 +	else
   1.145 +		{
   1.146 +		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   1.147 +		}
   1.148 +	}
   1.149 +
   1.150 +//Copy test bitmaps from Z: to C: drive. RFs::Connect() had to be called already 
   1.151 +//on "TheFs" object.
   1.152 +LOCAL_C void CopyDataFiles()
   1.153 +	{
   1.154 +	BaflUtils::CopyFile(TheFs, KRamBitmapOnZ, KRamBitmap);
   1.155 +	BaflUtils::CopyFile(TheFs, KRamCBitmapOnZ, KRamCBitmap);
   1.156 +	BaflUtils::CopyFile(TheFs, KRamRsc_RamMbmOnZ, KRamRsc_RamMbm);
   1.157 +	BaflUtils::CopyFile(TheFs, KRamRsc_RamMbm2OnZ, KRamRsc_RamMbm2);
   1.158 +	BaflUtils::CopyFile(TheFs, KRamRsc_RomMbmOnZ, KRamRsc_RomMbm);
   1.159 +	BaflUtils::CopyFile(TheFs, KRamRsc_RomMbm2OnZ, KRamRsc_RomMbm2);
   1.160 +	BaflUtils::CopyFile(TheFs, KZeroSizeMbmZ, KZeroSizeMbmRam);
   1.161 +	BaflUtils::CopyFile(TheFs, KBmpZCompr12, KBmpCCompr12);
   1.162 +	BaflUtils::CopyFile(TheFs, KBmpZCompr16, KBmpCCompr16);
   1.163 +	BaflUtils::CopyFile(TheFs, KRamBitmap, KBmp16_1);
   1.164 +	BaflUtils::CopyFile(TheFs, KRamBitmap, KBmp16_2);
   1.165 +	BaflUtils::CopyFile(TheFs, KRamBitmap, KBmp16_3);
   1.166 +	BaflUtils::CopyFile(TheFs, KRam24BitmapOnZ, KRam24Bitmap);
   1.167 +	BaflUtils::CopyFile(TheFs, KRamC24BitmapOnZ, KRamC24Bitmap);
   1.168 +	}
   1.169 +
   1.170 +//Delete data files used by the test
   1.171 +LOCAL_C void DeleteDataFiles()
   1.172 +	{
   1.173 +	DeleteDataFile(KRamBitmap);
   1.174 +	DeleteDataFile(KRamCBitmap);
   1.175 +	DeleteDataFile(KRamRsc_RamMbm);
   1.176 +	DeleteDataFile(KRamRsc_RamMbm2);
   1.177 +	DeleteDataFile(KRamRsc_RomMbm);
   1.178 +	DeleteDataFile(KRamRsc_RomMbm2);
   1.179 +	DeleteDataFile(KRam24Bitmap);
   1.180 +	DeleteDataFile(KRamC24Bitmap);
   1.181 +	DeleteDataFile(_L("c:\\temp.mbm"));
   1.182 +	DeleteDataFile(_L("c:\\temp2.mbm"));
   1.183 +	DeleteDataFile(KZeroSizeMbmRam );
   1.184 +	DeleteDataFile(KBmpCCompr12);
   1.185 +	DeleteDataFile(KBmpCCompr16);
   1.186 +	DeleteDataFile(KBmp16_1);
   1.187 +	DeleteDataFile(KBmp16_2);
   1.188 +	DeleteDataFile(KBmp16_3);
   1.189 +	}
   1.190 +
   1.191 +//
   1.192 +//
   1.193 +//Global functions
   1.194 +
   1.195 +//Return file size in bytes of "aFileName" file.
   1.196 +LOCAL_C TInt FileSizeL(const TDesC& aFileName)
   1.197 +	{
   1.198 +	RFile file;
   1.199 +	User::LeaveIfError(file.Open(TheFs, aFileName, EFileRead));
   1.200 +	CleanupClosePushL(file);
   1.201 +	TInt size = 0;
   1.202 +	User::LeaveIfError(file.Size(size));
   1.203 +	CleanupStack::PopAndDestroy(&file);
   1.204 +	return size;
   1.205 +	}
   1.206 +
   1.207 +//Creates CFbsBitGcBitmap instance and loads it with bitmap N#0 from "aFileName" file.
   1.208 +//CFbsBitGcBitmap instance will be pushed in the cleanup stack.
   1.209 +CFbsBitGcBitmap* LoadBitmapLC(const TDesC& aFileName)
   1.210 +	{
   1.211 +	CFbsBitGcBitmap* bmp = new (ELeave) CFbsBitGcBitmap;
   1.212 +	CleanupStack::PushL(bmp);
   1.213 +	User::LeaveIfError(bmp->Load(aFileName, 0));
   1.214 +	return bmp;
   1.215 +	}
   1.216 +
   1.217 +//Creates "SIZE" CFbsBitGcBitmap instance and loads them with bitmap N#0 from "aBmpFiles" 
   1.218 +//files. CFbsBitGcBitmap instances will be pushed in the cleanup stack.
   1.219 +template <TInt SIZE> void LoadBitmapsLC(CFbsBitGcBitmap* (*aBmp)[SIZE], TPtrC aBmpFiles[])
   1.220 +	{
   1.221 +	for(TInt ii=0;ii<SIZE;ii++)
   1.222 +		{
   1.223 +		(*aBmp)[ii] = LoadBitmapLC(aBmpFiles[ii]);
   1.224 +		}
   1.225 +	}
   1.226 +
   1.227 +//Displays "aBmp" array of bitmaps.
   1.228 +template <TInt SIZE> void DisplayBitmaps(CFbsBitGcBitmap* (*aBmp)[SIZE], 
   1.229 +										 CFbsScreenDevice* aDevice, 
   1.230 +										 CFbsBitGc* aGc)
   1.231 +	{
   1.232 +	for(TInt ii=0;ii<SIZE;ii++)
   1.233 +		{
   1.234 +		TSize size = (*aBmp)[ii]->SizeInPixels();
   1.235 +		aGc->Clear();
   1.236 +		aGc->DrawBitmap(TRect(size), (*aBmp)[ii]);
   1.237 +		aDevice->Update();
   1.238 +		User::After(KDelayTime);
   1.239 +		}
   1.240 +	}
   1.241 +
   1.242 +//Destroys "aBmp" array of bitmaps.
   1.243 +template <TInt SIZE> void DestroyBitmaps(CFbsBitGcBitmap* (*aBmp)[SIZE])
   1.244 +	{
   1.245 +	for(TInt ii=(SIZE-1);ii>-1;ii--)
   1.246 +		{
   1.247 +		CleanupStack::PopAndDestroy((*aBmp)[ii]);
   1.248 +		}
   1.249 +	}
   1.250 +
   1.251 +//Compares 2 bitmaps from "aBmp" array.
   1.252 +//The first bitmap index is aBmp1, the second bitmap index is aBmp2.
   1.253 +//The function compares bitmaps line by line and asserts their pixel values.
   1.254 +template <TInt SIZE, TInt MAXLEN> void CompareBitmaps(CFbsBitGcBitmap* (*aBmp)[SIZE], 
   1.255 +													  TDisplayMode aDispMode,
   1.256 +													  TInt aBmp1, 
   1.257 +													  TInt aBmp2,
   1.258 +													  CTGraphicsBase *aTest)
   1.259 +	{
   1.260 +	TUint8 line1[MAXLEN];
   1.261 +	TUint8 line2[MAXLEN];
   1.262 +	TPtr8 p1(line1, MAXLEN, MAXLEN);
   1.263 +	TPtr8 p2(line2, MAXLEN, MAXLEN);
   1.264 +	TSize size1 = (*aBmp)[aBmp1]->SizeInPixels();
   1.265 +	TSize size2 = (*aBmp)[aBmp2]->SizeInPixels();
   1.266 +	TInt minHeight = Min(size1.iHeight, size2.iHeight);
   1.267 +	TInt minWidth = Min(size1.iWidth, size2.iWidth);
   1.268 +	for(TInt ii=0;ii<minHeight;ii++)
   1.269 +		{
   1.270 +		(*aBmp)[aBmp1]->GetScanLine(p1, TPoint(0,ii), minWidth, aDispMode);
   1.271 +		(*aBmp)[aBmp2]->GetScanLine(p2, TPoint(0,ii), minWidth, aDispMode);
   1.272 +		aTest->TEST(p1.Length() == p2.Length());
   1.273 +		for(TInt j=0;j<p1.Length();j++)
   1.274 +			{
   1.275 +			aTest->TEST(line1[j] == line2[j]);
   1.276 +			}
   1.277 +		}
   1.278 +	}
   1.279 +
   1.280 +//Compares the Alpha Channel Values of the First Pixel in the two bitmaps.
   1.281 +//The pixel value is obtained from DataAddress().
   1.282 +TBool CompareFirstPixelAlphaChannel(CFbsBitmap* aBmp1, CFbsBitmap* aBmp2)
   1.283 +	{
   1.284 +	return ( (*aBmp1->DataAddress() & 0xff000000) == (*aBmp2->DataAddress() & 0xff000000) );
   1.285 +	}
   1.286 +
   1.287 +//
   1.288 +//
   1.289 +
   1.290 +CTDefect::CTDefect(CTestStep* aStep) :
   1.291 +	CTGraphicsBase(aStep), 
   1.292 +	iDevice(NULL),
   1.293 +	iBmpDevice(NULL),
   1.294 +	iGc(NULL),
   1.295 +	iBitmap(NULL),
   1.296 +	iSize(0, 0),
   1.297 +	iCurrentMode(ENone)
   1.298 +	{
   1.299 +	}
   1.300 +
   1.301 +CTDefect::~CTDefect()
   1.302 +	{
   1.303 +	DestroyFont();
   1.304 +	DeleteBitmap();
   1.305 +	DeleteGraphicsContext();
   1.306 +	DeleteBitmapDevice();
   1.307 +	DeleteScreenDevice();
   1.308 +	}
   1.309 +
   1.310 +void CTDefect::ConstructL()
   1.311 +	{
   1.312 +	INFO_PRINTF1(_L("Create screen device"));
   1.313 +	CreateScreenDeviceL();
   1.314 +
   1.315 +	TUint32* romAddress = NULL;
   1.316 +	if(!CFbsBitmap::IsFileInRom(KRomBitmap, romAddress)) //check any rom bitmap
   1.317 +		{
   1.318 +		INFO_PRINTF2(_L("Skipping tests of ROM bitmaps since file \"%S\" is reported to not be a ROM bitmap."),
   1.319 +				&KRomBitmap);
   1.320 +		INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported."));
   1.321 +		iSkipRomBitmapTests = ETrue;
   1.322 +		}
   1.323 +	}
   1.324 +
   1.325 +void CTDefect::CreateScreenDeviceL(TAllowScaling aScaling)
   1.326 +	{
   1.327 +	DeleteGraphicsContext();
   1.328 +	DeleteScreenDevice();
   1.329 +	TDisplayMode mode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, 
   1.330 +						   EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP};
   1.331 +	TInt ii;
   1.332 +	TInt err = KErrNotSupported;
   1.333 +	for(ii=0;(ii<TInt(sizeof(mode)/sizeof(mode[0]))) && (err == KErrNotSupported);++ii)
   1.334 +		{
   1.335 +		err = CreateScreenDeviceL(mode[ii], aScaling);
   1.336 +		}
   1.337 +	if (err==KErrNone)
   1.338 +		{
   1.339 +		_LIT(KLog,"Sucessfully created screen device %S");
   1.340 +		INFO_PRINTF2(KLog,&ColorModeName(mode[ii]));
   1.341 +		}
   1.342 +	TEST(err == KErrNone);
   1.343 +	}
   1.344 +
   1.345 +TInt CTDefect::CreateScreenDeviceL(TDisplayMode aDisplayMode, TAllowScaling aScaling)
   1.346 +	{
   1.347 +	DeleteGraphicsContext();
   1.348 +	DeleteScreenDevice();
   1.349 +	TRAPD(err, iDevice=CFbsScreenDevice::NewL(KNullDesC,aDisplayMode));
   1.350 +	if(err == KErrNotSupported)
   1.351 +		{
   1.352 +		return err;
   1.353 +		}
   1.354 +	if (err!=KErrNone)
   1.355 +		{
   1.356 +		_LIT(KLog,"Failed to create screen device %S return value %d");
   1.357 +		INFO_PRINTF3(KLog,&ColorModeName(aDisplayMode),err);
   1.358 +		}
   1.359 +	else
   1.360 +		{
   1.361 +		_LIT(KLog,"Created Screen Device  iDevice=0x%x");
   1.362 +		INFO_PRINTF2(KLog,iDevice);
   1.363 +		}
   1.364 +	TEST(err == KErrNone);
   1.365 +	err = iDevice->CreateContext((CGraphicsContext*&)iGc);
   1.366 +	TEST(err == KErrNone);
   1.367 +	if(aScaling == EScalingAllowed)
   1.368 +		{
   1.369 +		iDevice->SetScalingFactor(TPoint(31, 11), 2, 2, 1, 1);
   1.370 +		iGc->Activate(iDevice);
   1.371 +		}
   1.372 +	iGc->SetUserDisplayMode(aDisplayMode);
   1.373 +	iDevice->ChangeScreenDevice(NULL);
   1.374 +	iDevice->SetAutoUpdate(EFalse);
   1.375 +	iSize = iDevice->SizeInPixels();
   1.376 +	iCurrentMode = aDisplayMode;
   1.377 +	return err;
   1.378 +	}
   1.379 +
   1.380 +void CTDefect::RunTestCaseL(TInt aCurTestCase)
   1.381 +	{
   1.382 +	((CTDefectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.383 +	switch(aCurTestCase)
   1.384 +		{
   1.385 +	case 1:
   1.386 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0045"));
   1.387 +		INFO_PRINTF1(_L("DEF014364"));
   1.388 +		DEF014364L();
   1.389 +		INFO_PRINTF1(_L("Cleared DEF014364\n"));
   1.390 +		break;
   1.391 +	case 2:
   1.392 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0046"));
   1.393 +		INFO_PRINTF1(_L("DEF017758"));
   1.394 +		DEF017758();
   1.395 +		INFO_PRINTF1(_L("Cleared DEF017758\n"));
   1.396 +		break;
   1.397 +	case 3:
   1.398 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0047"));
   1.399 +		INFO_PRINTF1(_L("16 bpp bitmap comperssion"));
   1.400 +		BitmapCompressionL(E16BppBmpType);
   1.401 +		break;
   1.402 +	case 4:
   1.403 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0047"));
   1.404 +		INFO_PRINTF1(_L("24 bpp bitmap comperssion"));
   1.405 +		BitmapCompressionL(E24BppBmpType);
   1.406 +		break;
   1.407 +	case 5:
   1.408 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0048"));
   1.409 +		INFO_PRINTF1(_L("New RSC file format"));
   1.410 +		NewRscFormatL();
   1.411 +		break;
   1.412 +	case 6:
   1.413 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0049"));
   1.414 +		INFO_PRINTF1(_L("INC031920 - 16 bpp bitmaps"));
   1.415 +		INC031920L(E16BppBmpType, ETrue);
   1.416 +		INC031920L(E16BppBmpType, EFalse);
   1.417 +		break;
   1.418 +	case 7:
   1.419 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0049"));
   1.420 +		INFO_PRINTF1(_L("INC031920 - 24 bpp bitmaps"));
   1.421 +		INC031920L(E24BppBmpType, ETrue);
   1.422 +		INC031920L(E24BppBmpType, EFalse);
   1.423 +		break;
   1.424 +	case 8:
   1.425 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0050"));
   1.426 +		INFO_PRINTF1(_L("8 bit bitmap compression - ROM"));
   1.427 +		Test8bitBmpComressionL();
   1.428 +		break;
   1.429 +	case 9:
   1.430 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0051"));
   1.431 +		INFO_PRINTF1(_L("12 bit bitmap compression - ROM"));
   1.432 +		Test12bitBmpComressionL();
   1.433 +		break;
   1.434 +	case 10:
   1.435 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0044"));
   1.436 +		INFO_PRINTF1(_L("ZeroSizeBitmap"));
   1.437 +		ZeroSizeBitmap();
   1.438 +		break;
   1.439 +	case 11:
   1.440 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0052"));
   1.441 +		INFO_PRINTF1(_L("DEF034134"));
   1.442 +		DEF034134L();
   1.443 +		break;
   1.444 +	case 12:
   1.445 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0053"));
   1.446 +		INFO_PRINTF1(_L("Test tiling occurs correctly"));
   1.447 +		TestTilingHorizontalAndVerticalL();
   1.448 +		break;
   1.449 +	case 13:
   1.450 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0054"));
   1.451 +		INFO_PRINTF1(_L("Borderline cases for DrawPie"));
   1.452 +		DrawPieBorderlineCasesL();
   1.453 +		break;
   1.454 +	case 14:
   1.455 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0055"));
   1.456 +		INFO_PRINTF1(_L("INC037380"));
   1.457 +		INC037380L();
   1.458 +		break;
   1.459 +	case 15:
   1.460 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0056"));
   1.461 +		INFO_PRINTF1(_L("INC037474"));
   1.462 +		INC037474L();
   1.463 +		break;
   1.464 +	case 16:
   1.465 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0058"));
   1.466 +		INFO_PRINTF1(_L("CFbsBitmap::SetDisplayMode() test"));
   1.467 +		TestSettingDisplayModeL();
   1.468 +		break;
   1.469 +	case 17:
   1.470 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0059"));
   1.471 +		INFO_PRINTF1(_L("CFbsBitmap::SetDisplayMode() test 2"));
   1.472 +		TestSettingDisplayMode2L();
   1.473 +		break;
   1.474 +	case 18:
   1.475 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0060"));
   1.476 +		INFO_PRINTF1(_L("CFbsBitmap::SwappingWidthAndHeight() test"));
   1.477 +		TestSwappingWidthAndHeightL();
   1.478 +		break;
   1.479 +	case 19:
   1.480 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0057"));
   1.481 +		INFO_PRINTF1(_L("INC037370"));
   1.482 +		INC037370L();
   1.483 +		break;
   1.484 +	case 20:
   1.485 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0061"));
   1.486 +		INFO_PRINTF1(_L("DEF038774"));
   1.487 +		DEF038774L();
   1.488 +		break;
   1.489 +	case 21:
   1.490 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0062"));
   1.491 +		INFO_PRINTF1(_L("INC070043L"));
   1.492 +		INC070043L();		
   1.493 +		break;
   1.494 +	case 22:
   1.495 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0043"));
   1.496 +		INFO_PRINTF1(_L("OOM test"));
   1.497 +		TestOom();	
   1.498 +		break;
   1.499 +	case 23:
   1.500 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0063"));
   1.501 +		INFO_PRINTF1(_L("Bitmaps Swapping Test"));
   1.502 +		BitmapsSwappingTest();
   1.503 +		break;
   1.504 +	case 24:
   1.505 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0064"));
   1.506 +		INFO_PRINTF1(_L("INC093055"));
   1.507 +		INC093055L();
   1.508 +		break;
   1.509 +	case 25:
   1.510 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0016"));
   1.511 +		INFO_PRINTF1(_L("PDEF103809"));
   1.512 +		PDEF103809L();
   1.513 +		break;
   1.514 +	case 26:
   1.515 +/**
   1.516 +@SYMTestCaseID		GRAPHICS-BITGDI-0018
   1.517 +
   1.518 +@SYMDEF             DEF104856
   1.519 +
   1.520 +@SYMTestCaseDesc    Test that the bitmap and mask are drawn correctly testing
   1.521 +	CFbsBitGc::DoBitBltMaskedFlicker in order to test the DEF104856 fix
   1.522 +	introduced in CFbsBitGc::DoBitBltMaskedFlicker method
   1.523 +
   1.524 +@SYMTestPriority    High
   1.525 +
   1.526 +@SYMTestStatus      Implemented
   1.527 +
   1.528 +@SYMTestActions     Create compressed EColor64K bitmap and mask and draw bitmap calling
   1.529 +	CFbsBitGc::BitBltMasked with an offscreen bitmap device
   1.530 +
   1.531 +@SYMTestExpectedResults The resulting bitmap is not altered or corrupted by the code module
   1.532 +**/
   1.533 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0018"));
   1.534 +		INFO_PRINTF1(_L("BitBltMasked Flicker Test - DEF104856"));
   1.535 +		TestDoBltMaskedL(EColor64K, EColor64K, EColor64K, TSize(16,16), EFalse, ETrue);
   1.536 +		break;
   1.537 +	case 27:
   1.538 +/**
   1.539 +@SYMTestCaseID		GRAPHICS-BITGDI-0019
   1.540 +
   1.541 +@SYMDEF             DEF104856
   1.542 +
   1.543 +@SYMTestCaseDesc    Test that the bitmap and mask are drawn correctly testing
   1.544 +	CFbsBitGc::DoBitBltMaskedNonFlicker in order to test the DEF104856 fix
   1.545 +	introduced in CFbsBitGc::DoBitBltMaskedNonFlicker method
   1.546 +
   1.547 +@SYMTestPriority    High
   1.548 +
   1.549 +@SYMTestStatus      Implemented
   1.550 +
   1.551 +@SYMTestActions     Create compressed EColor64K bitmap and mask and draw bitmap calling
   1.552 +	CFbsBitGc::BitBltMasked with a screen device and brush style EVerticalHatchBrush
   1.553 +
   1.554 +@SYMTestExpectedResults The resulting bitmap is not altered or corrupted by the code module
   1.555 +**/
   1.556 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0019"));
   1.557 +		INFO_PRINTF1(_L("BitBltMasked non Flicker Test - DEF104856"));
   1.558 +		TestDoBltMaskedL(EColor64K, EColor64K, EColor64K, TSize(16,16), ETrue, ETrue);
   1.559 +		break;
   1.560 +	case 28:
   1.561 +/**
   1.562 +@SYMTestCaseID		GRAPHICS-BITGDI-0092
   1.563 + 
   1.564 +@SYMDEF             DEF108338
   1.565 +
   1.566 +@SYMTestCaseDesc    Test that the bitmap is drawn correctly by testing
   1.567 +					that the correct area of the mask is used for masking.
   1.568 +					CFbsBitGc::DoBitBltMaskedFlicker is called in this case.
   1.569 +
   1.570 +@SYMTestPriority    High
   1.571 +
   1.572 +@SYMTestStatus      Implemented
   1.573 +
   1.574 +@SYMTestActions     Create compressed EColor64K bitmap and EGray2 mask and draw bitmap calling
   1.575 +					CFbsBitGc::BitBltMasked with a screen device. The drawing is done in a loop
   1.576 +					to simulate the scrolling effect as in a browser.
   1.577 +
   1.578 +@SYMTestExpectedResults All the stripes should pass the integrity check.
   1.579 +**/
   1.580 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0092"));
   1.581 +		INFO_PRINTF1(_L("BitBltMasked Flicker - DEF108338"));
   1.582 +		TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), EFalse, EFalse);
   1.583 +		break;
   1.584 +	case 29:
   1.585 +/**
   1.586 +@SYMTestCaseID		GRAPHICS-BITGDI-0093
   1.587 +
   1.588 +@SYMDEF             DEF108338
   1.589 +
   1.590 +@SYMTestCaseDesc    Test that the bitmap is drawn correctly by testing
   1.591 +					that the correct area of the mask is used for masking.
   1.592 +					CFbsBitGc::DoBitBltMaskedNonFlicker is called in this case.
   1.593 +
   1.594 +@SYMTestPriority    High
   1.595 +
   1.596 +@SYMTestStatus      Implemented
   1.597 +
   1.598 +@SYMTestActions     Create compressed EColor64K bitmap and EGray2 mask and draw bitmap calling
   1.599 +					CFbsBitGc::BitBltMasked with a screen device. The drawing is done in a loop
   1.600 +					to simulate the scrolling effect as in a browser.
   1.601 +
   1.602 +@SYMTestExpectedResults All the stripes should pass the integrity check.
   1.603 +**/
   1.604 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0093"));
   1.605 +		INFO_PRINTF1(_L("BitBltMasked Non Flicker - DEF108338"));
   1.606 +		//skip the test if the screen does not have a fast blit interface.
   1.607 +		if(CFbsDrawDevice::DisplayMode16M() == ENone)
   1.608 +			{
   1.609 +			INFO_PRINTF1(_L("Test skipped - The screen does not have a fast blit interface!"));
   1.610 +			break;
   1.611 +			}
   1.612 +		TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), ETrue, EFalse);
   1.613 +		break;
   1.614 +	case 30:
   1.615 +/**
   1.616 +@SYMTestCaseID		GRAPHICS-BITGDI-0020
   1.617 +
   1.618 +@SYMDEF             DEF103736
   1.619 +
   1.620 +@SYMTestCaseDesc   	Test to check that EColor16MAP mode correctly draws bitmaps when using a EColor16MAP mask
   1.621 +
   1.622 +@SYMTestPriority    Normal
   1.623 +
   1.624 +@SYMTestStatus      Implemented
   1.625 +
   1.626 +@SYMTestActions     Create compressed EColor16MAP bitmap and mask and draw bitmap calling
   1.627 +					CFbsBitGc::BitBltMasked with an offscreen bitmap device
   1.628 +
   1.629 +@SYMTestExpectedResults The resulting bitmap is not altered or corrupted by the code module
   1.630 +**/
   1.631 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0020"));
   1.632 +		INFO_PRINTF1(_L("BitBltMasked non Flicker Test ECOLOR16MAP - DEF103736"));
   1.633 +		TestDoBltMaskedL(EColor16MAP, EColor16MAP, EColor16MAP, TSize(16,16), EFalse, ETrue);
   1.634 +		break;
   1.635 +	case 31:
   1.636 +/**
   1.637 +@SYMTestCaseID		GRAPHICS-BITGDI-0094
   1.638 +
   1.639 +@SYMDEF             PDEF108863
   1.640 +
   1.641 +@SYMTestCaseDesc    Test that CFbsBitGc::DoBitBltAlpha() function behaves correctly
   1.642 +                    when source is EColor16MU, mask is EGray256, both source and mask are compressed
   1.643 +                    and the screen driver has no MFastBlit interface.
   1.644 +
   1.645 +@SYMTestPriority    High
   1.646 +
   1.647 +@SYMTestStatus      Implemented
   1.648 +
   1.649 +@SYMTestActions     Create compressed EColor16MU bitmap and EGray256 mask and draw bitmap calling
   1.650 +                    CFbsBitGc::BitBltMasked with a screen device. Where screen driver has no MFastBlit interface.
   1.651 +
   1.652 +@SYMTestExpectedResults All the stripes should pass the integrity check.
   1.653 +**/
   1.654 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0094"));
   1.655 +		INFO_PRINTF1(_L("PDEF108863 - DoBitBltAlpha for EColor16MU source, EGray256 mask and no MFastBlit interface"));
   1.656 +		TestDoBltMaskedL(EColor16MU, EGray256, EColor16MA, TSize(96,96), EFalse, EFalse);
   1.657 +		break;
   1.658 +	case 32:
   1.659 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0095"));
   1.660 +		INFO_PRINTF1(_L("PDEF110934 - DoBitBltMasked for mask height is less/greater than the bitmap height")); 
   1.661 +		TestDoBitBltMaskedSizeL();
   1.662 +		break;
   1.663 +	case 33: 
   1.664 +/** 
   1.665 +@SYMTestCaseID      GRAPHICS-BITGDI-0096
   1.666 +
   1.667 +@SYMDEF             PDEF114309
   1.668 +
   1.669 +@SYMTestCaseDesc    Test to check that EColor16MU mode correctly BitBltMasks when source and mask are of EColor16MA
   1.670 +
   1.671 +@SYMTestPriority    Normal
   1.672 +
   1.673 +@SYMTestStatus      Implemented
   1.674 +
   1.675 +@SYMTestActions     Create source, mask and destination bitmaps of EColor16MA, EColor16MA and EColor16MU respectively
   1.676 +                    Call BitBltMaksed on the destination device and check the output
   1.677 +
   1.678 +@SYMTestExpectedResults The resulting bitmap contents should match the calculated value
   1.679 +**/
   1.680 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0096"));
   1.681 +        INFO_PRINTF1(_L("BitBltMasked for EColor16MU with source and mask of EColor16MA - PDEF114309"));
   1.682 +        TestBitBltMaskedEColor16MUL();
   1.683 +        break;
   1.684 +	case 34:
   1.685 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0102"));
   1.686 +		INFO_PRINTF1(_L("Externalize()/Internalize() of CFbsBitGcExtraData in CFbsBitmap - DEF120360"));
   1.687 +		ExternalizeInternalizeCFbsBitGCExtraData();
   1.688 +		break;
   1.689 +	case 35:
   1.690 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0086"));
   1.691 +        INFO_PRINTF1(_L("Test BitBlt with 16MU source & target copies rather than overwrites alpha channel - DEF121299"));
   1.692 +        TestBitBltOperationsOn16muUndefinedByteL();
   1.693 +        break;
   1.694 +	case 36:
   1.695 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0107"));
   1.696 +		INFO_PRINTF1(_L("Test DrawBitmap() with clipping and scaling - DEF126160"));
   1.697 +		TestClippedScaledBitmapL();
   1.698 +		break;
   1.699 +	case 37:
   1.700 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0109"));
   1.701 +		INFO_PRINTF1(_L("Test TestDrawBitmapTwipsNotSet() - DEF128522"));
   1.702 +		TestDrawBitmapTwipsNotSet();
   1.703 +		break;
   1.704 +	case 38:
   1.705 +		((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0119"));
   1.706 +		INFO_PRINTF1(_L("Test DrawBitmapMasked() with compressed bitmaps"));
   1.707 +		TestDrawBitmapMaskedL();
   1.708 +		break;    
   1.709 +	case 39:
   1.710 +		((CTDefectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.711 +		((CTDefectStep*)iStep)->CloseTMSGraphicsStep();
   1.712 +		TestComplete();		
   1.713 +		break;				
   1.714 +		}
   1.715 +	((CTDefectStep*)iStep)->RecordTestResultL();
   1.716 +	}
   1.717 +
   1.718 +void CTDefect::TestBitBltMaskedEColor16MUL() 
   1.719 +    { 
   1.720 +    TInt width = 128; 
   1.721 +    TInt height = 178; 
   1.722 + 
   1.723 +    TSize size(width, height); 
   1.724 +    TInt transpFactor = 100; 
   1.725 + 
   1.726 +    // Create a destination bitmap of EColro16MU and fill some color in it 
   1.727 +    CFbsBitmap* destBitmap = new CFbsBitmap(); 
   1.728 +    CleanupStack::PushL(destBitmap); 
   1.729 +    User::LeaveIfError(destBitmap->Create(size, EColor16MU)); 
   1.730 +    CFbsBitmapDevice* destDev = CFbsBitmapDevice::NewL(destBitmap); 
   1.731 +    CleanupStack::PushL(destDev); 
   1.732 +    CFbsBitGc* destGc = NULL; 
   1.733 +    User::LeaveIfError(destDev->CreateContext(destGc)); 
   1.734 +    CleanupStack::PushL(destGc); 
   1.735 + 
   1.736 +    destGc->SetPenStyle(CGraphicsContext::ENullPen); 
   1.737 +    destGc->SetBrushStyle(CGraphicsContext::ESolidBrush); 
   1.738 +    destGc->SetBrushColor(KRgbRed); 
   1.739 +    destGc->DrawRect(TRect(TPoint(), size)); 
   1.740 + 
   1.741 +    // Create a source bitmap fill it with some color and then draw it with some color with transparency on it 
   1.742 +    CFbsBitmap* srcBitmap = new (ELeave) CFbsBitmap; 
   1.743 +    CleanupStack::PushL(srcBitmap); 
   1.744 +    User::LeaveIfError(srcBitmap->Create(size, EColor16MA)); 
   1.745 +    CFbsBitmapDevice* srcDev = CFbsBitmapDevice::NewL(srcBitmap); 
   1.746 +    CleanupStack::PushL(srcDev); 
   1.747 +    CFbsBitGc* srcGc = NULL; 
   1.748 +    User::LeaveIfError(srcDev->CreateContext(srcGc)); 
   1.749 +    CleanupStack::PushL(srcGc); 
   1.750 + 
   1.751 +    srcGc->SetPenStyle(CGraphicsContext::ENullPen); 
   1.752 +    srcGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); 
   1.753 +    srcGc->SetBrushStyle(CGraphicsContext::ESolidBrush); 
   1.754 +    srcGc->SetBrushColor(TRgb(0xff,0xff,0xff,transpFactor)); 
   1.755 +    srcGc->DrawRect(TRect(TPoint(), size)); 
   1.756 + 
   1.757 +    // Create a mask bitmap and fill with TRgb(30,30,30) 
   1.758 +    CFbsBitmap* maskBitmap = new (ELeave) CFbsBitmap; 
   1.759 +    CleanupStack::PushL(maskBitmap); 
   1.760 +    User::LeaveIfError(maskBitmap->Create(size, EColor16MA)); 
   1.761 +    CFbsBitmapDevice* maskDev = CFbsBitmapDevice::NewL(maskBitmap); 
   1.762 +    CleanupStack::PushL(maskDev); 
   1.763 +    CFbsBitGc* maskGc = NULL; 
   1.764 +    User::LeaveIfError(maskDev->CreateContext(maskGc)); 
   1.765 +    CleanupStack::PushL(maskGc); 
   1.766 + 
   1.767 +    maskGc->SetPenStyle(CGraphicsContext::ENullPen); 
   1.768 +    maskGc->SetBrushStyle(CGraphicsContext::ESolidBrush); 
   1.769 +    maskGc->SetBrushColor(TRgb( 30, 30, 30 )); 
   1.770 +    maskGc->DrawRect(size); 
   1.771 + 
   1.772 +    // Then call BitBltMaksed() on it 
   1.773 +    destGc->SetDrawMode(CGraphicsContext::EDrawModePEN); 
   1.774 +    destGc->SetBrushStyle(CGraphicsContext::ENullBrush); 
   1.775 +    destGc->BitBltMasked(TPoint(), srcBitmap, TRect(size), maskBitmap, ETrue); 
   1.776 + 
   1.777 +    // These are the values that we gave for source bitmaps 
   1.778 +    TUint32 srcPixel = 0x64FFFFFF;  // i,e TRgb(0xff,0xff,0xff,transpFactor) 
   1.779 +    TUint8 srcMask = 0x64;          // transpFactor 
   1.780 +    TUint32 destPixel = 0xFFFFFFFF; // White becasue nothing has drawn on it 
   1.781 + 
   1.782 +    // When we draw source bitmap with transparency, it actually alpha blends  
   1.783 +    // with the above parameters 
   1.784 +    srcPixel = AlphaBlendWithDestAlphaFF(srcPixel, srcMask, destPixel); 
   1.785 + 
   1.786 +    // For displaymode which has alpha, mask is inverted i,e 255-30 = 225 or 0xE1 
   1.787 +    srcMask = 0xE1;                 // mask bitmap's TRgb( 30, 30, 30 ) 
   1.788 +    destPixel = 0xFFFF0000;         // KRgbRed of destination bitmap 
   1.789 +    destPixel = AlphaBlendWithDestAlphaFF(srcPixel, srcMask, destPixel); 
   1.790 + 
   1.791 +    // Function to check the contents of the destination bitmap,  
   1.792 +    // if the INC111510 fix is not applied then this function will fail 
   1.793 +    CheckBitmapContents(destDev, width, height, destPixel); 
   1.794 + 
   1.795 +    CleanupStack::PopAndDestroy(9, destBitmap);  
   1.796 +    } 
   1.797 + 
   1.798 +// This function is for alpha blending when the destination alpha is FF 
   1.799 +TUint32 CTDefect::AlphaBlendWithDestAlphaFF(const TUint32 aSrcPixel, const TUint8 aMask, TUint32 aDestPixel) 
   1.800 +    { 
   1.801 +    if(aMask) 
   1.802 +        { 
   1.803 +        if(aMask == 0xFF) 
   1.804 +            return 0xff000000|aSrcPixel; 
   1.805 +         
   1.806 +        // This is the formula used for alpha blending 
   1.807 +        // (a)  (mask * src + (255 - mask) * dest) / 255           This is the ideal formula 
   1.808 +        // (b)  ((mask * (src - dest)) >> 8) + dest                A faster approximation to (a) 
   1.809 +        // (c)  ((mask * (256 + src - dest) >> 8) + dest - mask    Equivalent to (b) but can be used on multiple colors at a time 
   1.810 +         
   1.811 +        const TUint32 s_rb = aSrcPixel & 0x00FF00FF; 
   1.812 +        const TUint32 d_rb = aDestPixel & 0x00FF00FF; 
   1.813 +        const TUint32 mask2 = aMask | (aMask << 16); 
   1.814 +        const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; 
   1.815 + 
   1.816 +        const TInt s_g = (aSrcPixel & 0xFF00) >> 8; 
   1.817 +        const TInt d_g = (aDestPixel & 0xFF00) >> 8; 
   1.818 +        const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g; 
   1.819 + 
   1.820 +        return(rb | (g<<8) | 0xff000000); 
   1.821 +        } 
   1.822 + 
   1.823 +    return aDestPixel; 
   1.824 +    } 
   1.825 + 
   1.826 +// This function is to check each pixel of the given bitmap 
   1.827 +void CTDefect::CheckBitmapContents(CFbsDevice* aDevice, TInt aWidth, TInt aHeight, TUint32 aExpectedValue) 
   1.828 +    { 
   1.829 +    TRgb color; 
   1.830 +    for(TInt y = 0; y < aHeight; ++y) 
   1.831 +        { 
   1.832 +        for(TInt x = 0; x < aWidth; ++x) 
   1.833 +            { 
   1.834 +            aDevice->GetPixel(color, TPoint(x, y)); 
   1.835 +            if(aExpectedValue != color.Internal()) 
   1.836 +                { 
   1.837 +                TEST(EFalse); 
   1.838 +                return; 
   1.839 +                } 
   1.840 +            } 
   1.841 +        } 
   1.842 +    }
   1.843 +
   1.844 +/**
   1.845 +  @SYMTestCaseID GRAPHICS-BITGDI-0043
   1.846 + 
   1.847 +  @SYMDEF INC042156L             
   1.848 +
   1.849 +  @SYMTestCaseDesc Out of memory test
   1.850 +   
   1.851 +  @SYMTestPriority High
   1.852 +
   1.853 +  @SYMTestStatus Implemented
   1.854 +
   1.855 +  @SYMTestActions Sets the next heap allocation to fail before attempting various bitmaps operations
   1.856 + 
   1.857 +  @SYMTestExpectedResults Allocation  should fail gracefullly
   1.858 +*/
   1.859 +void CTDefect::TestOom()
   1.860 +	{
   1.861 +	TInt err, tryCount = 0;
   1.862 +
   1.863 +	INFO_PRINTF1(_L("INC042156L"));
   1.864 +
   1.865 +	do
   1.866 +		{
   1.867 +		User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, ++tryCount);
   1.868 +		User::__DbgMarkStart(RHeap::EUser);
   1.869 +		{
   1.870 +		TRAP(err, INC042156L());
   1.871 +		}
   1.872 +		User::__DbgMarkEnd(RHeap::EUser, 0);
   1.873 +		} 
   1.874 +	while(err == KErrNoMemory);
   1.875 +
   1.876 +	if(err == KErrNone)
   1.877 +		{
   1.878 +		// Reset
   1.879 +		User::__DbgSetAllocFail(RHeap::EUser,RHeap::ENone,1);
   1.880 +		}
   1.881 +	else
   1.882 +		{
   1.883 +		TEST(err == KErrNone);
   1.884 +		}
   1.885 +
   1.886 +	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i"), tryCount);
   1.887 +	User::After(3000000);
   1.888 +	}
   1.889 +
   1.890 +
   1.891 +/**
   1.892 +  @SYMTestCaseID GRAPHICS-BITGDI-0044
   1.893 + 
   1.894 +  @SYMDEF             
   1.895 +
   1.896 +  @SYMTestCaseDesc tests that CBitwiseBitmap::SizeOfByteDataCompressed, SizeOfTwelveBitDataCompressed, SizeOfSixteenBitDataCompressed & 
   1.897 +  SizeOfTwentyFourBitDataCompressed can handle zero size bitmaps 
   1.898 +   
   1.899 +  @SYMTestPriority High
   1.900 +
   1.901 +  @SYMTestStatus Implemented
   1.902 +
   1.903 +  @SYMTestActions Loads a zerosize bitmap the compresses it
   1.904 + 
   1.905 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.906 +*/
   1.907 +void CTDefect::ZeroSizeBitmap()
   1.908 +{
   1.909 +	DeleteBitmap();
   1.910 +	iBitmap = new (ELeave) CFbsBitmap;
   1.911 +	
   1.912 +	TInt err = iBitmap->Load(KZeroSizeMbmRam);
   1.913 +	TEST(err == KErrCorrupt);
   1.914 +	if(err != KErrCorrupt)
   1.915 +		{
   1.916 +		err =iBitmap->Compress();
   1.917 +		TEST(err == KErrNone);	
   1.918 +		}
   1.919 +}
   1.920 +
   1.921 +/**
   1.922 +  @SYMTestCaseID GRAPHICS-BITGDI-0045
   1.923 + 
   1.924 +  @SYMDEF DEF014364            
   1.925 +
   1.926 +  @SYMTestCaseDesc Tests opening of a corrupt bitmap and resizing to (0,0)
   1.927 +   
   1.928 +  @SYMTestPriority High
   1.929 +
   1.930 +  @SYMTestStatus Implemented
   1.931 +
   1.932 +  @SYMTestActions tries to open a corrupt bitmap then attempts to resize a new bitmap to (0,0) size
   1.933 + 
   1.934 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.935 +*/
   1.936 +void CTDefect::DEF014364L()
   1.937 +	{
   1.938 +	DeleteBitmap();
   1.939 +	iBitmap = new (ELeave) CFbsBitmap;
   1.940 +	TInt err = iBitmap->Load(_L("z:\\system\\data\\Corrupt000.wbmp"));
   1.941 +	//It should not be possible to open corrupted bitmap file.
   1.942 +	if (err!=KErrNotSupported)
   1.943 +		{
   1.944 +		_LIT(KLog,"Corrupt bitmap Corrupt000.wbmp gave wrong error code when opening  err=%d");
   1.945 +		INFO_PRINTF2(KLog,err);
   1.946 +		}
   1.947 +	TEST(err == KErrNotSupported);
   1.948 +	err = iBitmap->Create(TSize(20, 20), iCurrentMode);
   1.949 +	if (err!=KErrNone)
   1.950 +		{
   1.951 +		_LIT(KLog,"Failed to create bitmap  err=%d");
   1.952 +		INFO_PRINTF2(KLog,err);
   1.953 +		}
   1.954 +	TEST(err == KErrNone);
   1.955 +	DeleteBitmapDevice();
   1.956 +	TRAP(err, iBmpDevice = CFbsBitmapDevice::NewL(iBitmap));
   1.957 +	if (err!=KErrNone)
   1.958 +		{
   1.959 +		_LIT(KLog,"Failed to create bitmap device  err=%d");
   1.960 +		INFO_PRINTF2(KLog,err);
   1.961 +		}
   1.962 +	TEST(err == KErrNone);
   1.963 +	//It should not be possible to resize bitmap device to (0, 0) size.
   1.964 +	//Yes it should, setting size to 0,0 is necessary to maintain
   1.965 +	//6.1 application compatibility with 7.0s.
   1.966 +	err = iBmpDevice->Resize(TSize(0, 0));
   1.967 +	if (err!=KErrNone)
   1.968 +		{
   1.969 +		_LIT(KLog,"Failed to resize bitmap  err=%d");
   1.970 +		INFO_PRINTF2(KLog,err);
   1.971 +		}
   1.972 +	TEST(err == KErrNone);
   1.973 +	//It should be possible to resize bitmap to (0, 0) size.
   1.974 +	err = iBitmap->Resize(TSize(0, 0));
   1.975 +	if (err!=KErrNone)
   1.976 +		{
   1.977 +		_LIT(KLog,"Failed to resize bitmap2  err=%d");
   1.978 +		INFO_PRINTF2(KLog,err);
   1.979 +		}
   1.980 +	TEST(err == KErrNone);
   1.981 +	//The next call should not fail with "Divide by Zero" exception on WINS platform.
   1.982 +	iGc->DrawBitmap(TRect(0, 0, 10, 10), iBitmap, TRect(0, 0, 10, 10));
   1.983 +	}
   1.984 +
   1.985 +//DEF023605 - Panic when bmp file is opened using Paint.
   1.986 +void CTDefect::DEF023605L()
   1.987 +	{
   1.988 +	DeleteBitmap();
   1.989 +	iBitmap = new (ELeave) CFbsBitmap;
   1.990 +	TInt err = iBitmap->Create(iSize, iCurrentMode);
   1.991 +	TEST(err == KErrNone);
   1.992 +	//It should not be possible to resize bitmap to (max_int, ...) size.
   1.993 +	err = iBitmap->Resize(TSize(0x7FFFFFFF, 16));
   1.994 +	TEST(err == KErrNone);
   1.995 +	}
   1.996 +
   1.997 +/**
   1.998 +  @SYMTestCaseID GRAPHICS-BITGDI-0046
   1.999 + 
  1.1000 +  @SYMDEF DEF017758             
  1.1001 +
  1.1002 +  @SYMTestCaseDesc Memory leak detected on target when using DirectScreenAccess
  1.1003 +   
  1.1004 +  @SYMTestPriority High
  1.1005 +
  1.1006 +  @SYMTestStatus Implemented
  1.1007 +
  1.1008 +  @SYMTestActions 
  1.1009 +  
  1.1010 +  	//
  1.1011 +	//The statement between __UHEAP_MARK and __UHEAP_END can cause memory leak!
  1.1012 +	//Obviously we have some kind of first time memory allocation when the
  1.1013 +	//method is called for the first time. Exactly the same method is called from
  1.1014 +	//CFbsScreenDevice::ConstructL() method.
  1.1015 +	//
  1.1016 +	//To see the problem:
  1.1017 +	//1. Comment HAL::Get() call into E32Main().
  1.1018 +	//2. Build ARM4 UDEB version of TDefect and make sure it is used into rom image build
  1.1019 +	//3. Build textshell rom image:
  1.1020 +	//   buildrom assabet textshell_70s graphics_70s.iby graphicstests_70s.iby
  1.1021 +	//4. Run TDefect app on the assabet.
  1.1022 +	//   You will see a memory leak. If you uncomment HAL::Get() call into E32Main() and repeat 
  1.1023 +	//   steps 1..4 - everything is OK.
  1.1024 +	//PS: If you don't want to build all graphics test app, you may have to comment
  1.1025 +	//    some IBY file includes into graphicstests_70s.iby file.
  1.1026 +	//    If there is a memory leak - the test will still report status "OK", but you
  1.1027 +	//    can see the memory leak message on the assabet. That's happening because 
  1.1028 +	//    the memory leak appears after the last __UHEAP_MARKEND macro in E32Main().
  1.1029 +	//
  1.1030 + 
  1.1031 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1032 +*/
  1.1033 +void CTDefect::DEF017758()
  1.1034 +	{
  1.1035 +	TRAPD(err, DEF017758L());
  1.1036 +	TEST(err == KErrNone);
  1.1037 +	}
  1.1038 +
  1.1039 +void CTDefect::DEF017758L()
  1.1040 +	{
  1.1041 +	RDebug::Print(_L("Getting video memory address\r\n"));
  1.1042 +	RDebug::Print(_L("Start\r\n"));
  1.1043 +	TInt address = 0;
  1.1044 +
  1.1045 +	__UHEAP_MARK;
  1.1046 +	User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress, address));
  1.1047 +	__UHEAP_MARKEND;
  1.1048 +	RDebug::Print(_L("End\n"));
  1.1049 +	}
  1.1050 +
  1.1051 +/**
  1.1052 +  @SYMTestCaseID GRAPHICS-BITGDI-0047
  1.1053 + 
  1.1054 +  @SYMDEF             
  1.1055 +
  1.1056 +  @SYMTestCaseDesc The main purpose of this method is to test RAM/ROM bitmap compression.
  1.1057 +   
  1.1058 +  @SYMTestPriority High
  1.1059 +
  1.1060 +  @SYMTestStatus Implemented
  1.1061 +
  1.1062 +  @SYMTestActions 
  1.1063 +
  1.1064 +	 - loads and displays ROM compressed bitmap.
  1.1065 +	 - loads and displays ROM bitmap - no compression.
  1.1066 +	 - loads and displays RAM compressed bitmap.
  1.1067 +	 - loads and displays RAM bitmap - no compression.
  1.1068 +	 - loads, compress and displays RAM bitmap.
  1.1069 +	 - stretches, moves and resizes RAM compressed bitmap.
  1.1070 +	 - compares byte by byte compressed and uncompressed bitmap images.
  1.1071 +	 Note: if you want to have better visibility of the bitmaps shown on
  1.1072 +	 the screen - change "KDelayTime" constant to be 1500000.
  1.1073 +	 @param  TBitmapType aBitmapType - tested bitmaps type - 16 bpp, 24 bpp, ...
  1.1074 +	 @return None
  1.1075 + 
  1.1076 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1077 +*/
  1.1078 +void CTDefect::BitmapCompressionL(TBitmapType aBitmapType)
  1.1079 +	{
  1.1080 +	CreateScreenDeviceL();
  1.1081 +	CreateFontL();
  1.1082 +
  1.1083 +	TRect rc(10, 20, 610, 220);
  1.1084 +	TBuf<100> text;
  1.1085 +	TInt mbm_offset = 0;
  1.1086 +	TInt err;
  1.1087 +	TPtrC BitmapTypeName[ELastBmpType] = {_L("16 bpp"), _L("24 bpp")};
  1.1088 +	typedef enum {ERAMFileType, ERAMCFileType, EROMFileType, EROMCFileType, ELastBmpFileType} TBitmapFileType;
  1.1089 +	TPtrC BitmapFile[ELastBmpFileType][ELastBmpType] = 
  1.1090 +		{
  1.1091 +		{KRamBitmap(), KRam24Bitmap()},
  1.1092 +		{KRamCBitmap(), KRamC24Bitmap()},
  1.1093 +		{KRomBitmap(), KRom24Bitmap()},
  1.1094 +		{KRomCBitmap(), KRomC24Bitmap()}
  1.1095 +		};
  1.1096 +
  1.1097 +	if(!iSkipRomBitmapTests)
  1.1098 +		{
  1.1099 +		//ROM compressed bitmap.
  1.1100 +		text = BitmapTypeName[aBitmapType];
  1.1101 +		text += _L(" ROM compressed bitmap.");
  1.1102 +		DisplayBitmapL(BitmapFile[EROMCFileType][aBitmapType], 0, mbm_offset, text, rc);
  1.1103 +	
  1.1104 +		//ROM bitmap - no compression.
  1.1105 +		text = BitmapTypeName[aBitmapType];
  1.1106 +		text += _L(" ROM bitmap - no compression.");
  1.1107 +		DisplayBitmapL(BitmapFile[EROMFileType][aBitmapType], 0, mbm_offset, text, rc);
  1.1108 +		}
  1.1109 +
  1.1110 +	//RAM compressed bitmap.
  1.1111 +	text = BitmapTypeName[aBitmapType];
  1.1112 +	text += _L(" RAM compressed bitmap.");
  1.1113 +	DisplayBitmapL(BitmapFile[ERAMCFileType][aBitmapType], 0, mbm_offset, text, rc);
  1.1114 +
  1.1115 +	//RAM bitmap - no compression.
  1.1116 +	text = BitmapTypeName[aBitmapType];
  1.1117 +	text += _L(" RAM bitmap - no compression.");
  1.1118 +	DisplayBitmapL(BitmapFile[ERAMFileType][aBitmapType], 0, mbm_offset, text, rc);
  1.1119 +
  1.1120 +	//RAM bitmap - no compression. Compress it!
  1.1121 +	err = iBitmap->Compress();
  1.1122 +	TEST(err == KErrNone);
  1.1123 +	TEST(iBitmap->IsCompressedInRAM());
  1.1124 +	text = BitmapTypeName[aBitmapType];
  1.1125 +	text += _L(" RAM bitmap - compressed now.");
  1.1126 +	DisplayBitmap(text, rc);
  1.1127 +	err = iBitmap->Save(_L("c:\\temp.mbm"));
  1.1128 +	TEST(err == KErrNone);
  1.1129 +
  1.1130 +	//RAM compressed bitmap - stretch the bitmap.
  1.1131 +	text = BitmapTypeName[aBitmapType];
  1.1132 +	text += _L(" RAM compressed bitmap - stretch the bitmap.");
  1.1133 +	TRect rc2(10, 20, 410, 150);
  1.1134 +	DisplayBitmap(text, rc2);
  1.1135 +
  1.1136 +	//RAM compressed bitmap - move the bitmap.
  1.1137 +	text = BitmapTypeName[aBitmapType];
  1.1138 +	text += _L(" RAM compressed bitmap - move the bitmap.");
  1.1139 +	for(TInt j=0;j<10;j++)
  1.1140 +		{
  1.1141 +		TRect rc2(10 + j * 10, 20 + j * 5, 410 + j * 10, 150 + j * 5);
  1.1142 +		DisplayBitmap(text, rc2);
  1.1143 +		}
  1.1144 +
  1.1145 +	//RAM compressed bitmap - resize the bitmap.
  1.1146 +	iGc->Clear();
  1.1147 +	err = iBitmap->Save(_L("c:\\temp2.mbm"));
  1.1148 +	TEST(err == KErrNone);
  1.1149 +	CFbsBitmap* resizedBitmap = new (ELeave) CFbsBitmap;
  1.1150 +	CleanupStack::PushL(resizedBitmap);
  1.1151 +	err = resizedBitmap->Load(_L("c:\\temp2.mbm"));
  1.1152 +	TEST(err == KErrNone);
  1.1153 +	err = resizedBitmap->Resize(TSize(300, 100));
  1.1154 +	TEST(err == KErrNone);
  1.1155 +	iGc->DrawBitmap(TRect(10, 20, 310, 120), resizedBitmap);
  1.1156 +	text = BitmapTypeName[aBitmapType];
  1.1157 +	text += _L(" RAM compressed bitmap - resize the bitmap.");
  1.1158 +	iGc->DrawText(text, TPoint(10, 15));
  1.1159 +	iDevice->Update();
  1.1160 +	User::After(KDelayTime);
  1.1161 +	CleanupStack::PopAndDestroy(resizedBitmap);
  1.1162 +
  1.1163 +	iGc->Clear();
  1.1164 +	iGc->DrawText(_L("Compare compressed and uncompressed bitmap data."), TPoint(10, 15));
  1.1165 +	iDevice->Update();
  1.1166 +
  1.1167 +	DestroyFont();
  1.1168 +
  1.1169 +	CFbsBitmap* compressedBitmap = new (ELeave) CFbsBitmap;
  1.1170 +	CleanupStack::PushL(compressedBitmap);
  1.1171 +	err = compressedBitmap->Load(_L("c:\\temp.mbm"));
  1.1172 +	TEST(err == KErrNone);
  1.1173 +
  1.1174 +	CFbsBitmap* uncompressedBitmap = new (ELeave) CFbsBitmap;
  1.1175 +	CleanupStack::PushL(uncompressedBitmap);
  1.1176 +	err = uncompressedBitmap->Load(BitmapFile[ERAMFileType][aBitmapType]);
  1.1177 +	TEST(err == KErrNone);
  1.1178 +
  1.1179 +	//Compare compressed and uncompressed bitmaps.
  1.1180 +	TEST(compressedBitmap->SizeInPixels() == uncompressedBitmap->SizeInPixels());
  1.1181 +	TSize sizeInPixels = compressedBitmap->SizeInPixels();
  1.1182 +	TInt BitmapBytesPerPixel[ELastBmpType] = {2, 3};
  1.1183 +	HBufC8* compressedLine = HBufC8::NewLC(sizeInPixels.iWidth * BitmapBytesPerPixel[aBitmapType]);
  1.1184 +	TPtr8 p1 = compressedLine->Des();
  1.1185 +	HBufC8* uncompressedLine = HBufC8::NewLC(sizeInPixels.iWidth * BitmapBytesPerPixel[aBitmapType]);
  1.1186 +	TPtr8 p2 = uncompressedLine->Des();
  1.1187 +	TDisplayMode BitmapScreenMode[ELastBmpType] = {EColor64K, EColor16M};
  1.1188 +	for(TInt ii=0;ii<sizeInPixels.iHeight;ii++)
  1.1189 +		{
  1.1190 +		compressedBitmap->GetScanLine(p1, TPoint(0,ii), sizeInPixels.iWidth, BitmapScreenMode[aBitmapType]);
  1.1191 +		uncompressedBitmap->GetScanLine(p2, TPoint(0,ii), sizeInPixels.iWidth, BitmapScreenMode[aBitmapType]);
  1.1192 +		TEST(p1 == p2);
  1.1193 +		}
  1.1194 +
  1.1195 +	CleanupStack::PopAndDestroy(uncompressedLine);
  1.1196 +	CleanupStack::PopAndDestroy(compressedLine);
  1.1197 +	CleanupStack::PopAndDestroy(uncompressedBitmap);
  1.1198 +	CleanupStack::PopAndDestroy(compressedBitmap);
  1.1199 +
  1.1200 +	User::After(KDelayTime);
  1.1201 +	}
  1.1202 +
  1.1203 +/**
  1.1204 +  @SYMTestCaseID GRAPHICS-BITGDI-0048
  1.1205 + 
  1.1206 +  @SYMDEF             
  1.1207 +
  1.1208 +  @SYMTestCaseDesc The main purpose of this method is to test new resource files format.
  1.1209 +   
  1.1210 +  @SYMTestPriority High
  1.1211 +
  1.1212 +  @SYMTestStatus Implemented
  1.1213 +
  1.1214 +  @SYMTestActions  The new resoure files format is: RSC file header + RSC file section + MBM file section.
  1.1215 + The method consequently does:
  1.1216 + - loads and displays new RSC file format: RSC file in ROM. MBM file in ROM.
  1.1217 + - loads and displays new RSC file format: RSC file in RAM. MBM file in RAM.
  1.1218 + - loads and displays new RSC file format: RSC file in ROM. MBM file in ROM. 2 bitmaps.
  1.1219 + - loads and displays new RSC file format: RSC file in RAM. MBM file in RAM. 2 bitmaps.
  1.1220 + - loads and displays new RSC file format: RSC file in ROM. MBM file in RAM.
  1.1221 + Note: if you want to have better visibility of the bitmaps shown on
  1.1222 + the screen - change "KDelayTime" constant to be 1500000.
  1.1223 + 
  1.1224 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1225 +*/
  1.1226 +void CTDefect::NewRscFormatL()
  1.1227 +	{
  1.1228 +	CreateScreenDeviceL();
  1.1229 +	CreateFontL();
  1.1230 +
  1.1231 +	TRect rc(10, 20, 610, 220);
  1.1232 +	TPtrC text(_L("RSC file in ROM. MBM file in ROM."));
  1.1233 +	TInt mbm_offset = ::FileSizeL(KRscFileHeader) + ::FileSizeL(KRscFileData);
  1.1234 +
  1.1235 +	//RSC file in ROM. MBM file in ROM.
  1.1236 +	if(!iSkipRomBitmapTests)
  1.1237 +		DisplayBitmapL(KRomRsc_RomMbm, 0, mbm_offset, text, rc);
  1.1238 +	
  1.1239 +	//RSC file in RAM. MBM file in RAM.
  1.1240 +	text.Set(_L("RSC file in RAM. MBM file in RAM."));
  1.1241 +	DisplayBitmapL(KRamRsc_RamMbm, 0, mbm_offset, text, rc);
  1.1242 +	
  1.1243 +	TInt ii;
  1.1244 +	TRect rect[] = {TRect(10, 20, 170, 100), TRect(10, 20, 35, 94)};
  1.1245 +
  1.1246 +	//RSC file in ROM. MBM file in ROM. Multiple bitmaps.
  1.1247 +	if(!iSkipRomBitmapTests)
  1.1248 +		{
  1.1249 +		text.Set(_L("RSC file in ROM. MBM file in ROM. Multiple bitmaps."));
  1.1250 +		for(ii=0;ii<TInt(sizeof(rect)/sizeof(rect[0]));ii++)
  1.1251 +			{
  1.1252 +			DisplayBitmapL(KRomRsc_RomMbm2, ii, mbm_offset, text, rect[ii]);
  1.1253 +			}
  1.1254 +		}
  1.1255 +
  1.1256 +	//RSC file in RAM. MBM file in RAM. Multiple bitmaps.
  1.1257 +	text.Set(_L("RSC file in RAM. MBM file in RAM. Multiple bitmaps."));
  1.1258 +	for(ii=0;ii<TInt(sizeof(rect)/sizeof(rect[0]));ii++)
  1.1259 +		{
  1.1260 +		DisplayBitmapL(KRamRsc_RamMbm2, ii, mbm_offset, text, rect[ii]);
  1.1261 +		}
  1.1262 +
  1.1263 +	//RSC file in ROM. MBM file in RAM.
  1.1264 +	text.Set(_L("RSC file in ROM. MBM file in RAM."));
  1.1265 +	DisplayBitmapL(KRomRsc_RamMbm, 0, mbm_offset, text, rc);
  1.1266 +	
  1.1267 +	//RSC file in ROM. MBM file in RAM. Multiple bitmaps.
  1.1268 +	text.Set(_L("RSC file in ROM. MBM file in RAM. Multiple bitmaps."));
  1.1269 +	for(ii=0;ii<TInt(sizeof(rect)/sizeof(rect[0]));ii++)
  1.1270 +		{
  1.1271 +		DisplayBitmapL(KRomRsc_RamMbm2, ii, mbm_offset, text, rect[ii]);
  1.1272 +		}
  1.1273 +
  1.1274 +	DestroyFont();
  1.1275 +	}
  1.1276 +
  1.1277 +/**
  1.1278 +  @SYMTestCaseID GRAPHICS-BITGDI-0049
  1.1279 + 
  1.1280 +  @SYMDEF             
  1.1281 +
  1.1282 +  @SYMTestCaseDesc tests that 16bpp/24bpp bitmap compression works correctly
  1.1283 +   
  1.1284 +  @SYMTestPriority High
  1.1285 +
  1.1286 +  @SYMTestStatus Implemented
  1.1287 +
  1.1288 +  @SYMTestActions Creates a compress bitmap and mask and draws to it
  1.1289 + 
  1.1290 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1291 +*/
  1.1292 +void CTDefect::INC031920L(TBitmapType aBitmapType, TBool aRomBitmap)
  1.1293 +	{
  1.1294 +	if(iSkipRomBitmapTests && aRomBitmap)
  1.1295 +		return;
  1.1296 +	
  1.1297 +	CreateScreenDeviceL();
  1.1298 +	CreateFontL();
  1.1299 +
  1.1300 +	TPtrC filename;
  1.1301 +	switch(aBitmapType)
  1.1302 +		{
  1.1303 +	case E16BppBmpType:
  1.1304 +		filename.Set(aRomBitmap ? KComprRomBitmap16() : KComprRamBitmap16());
  1.1305 +		break;
  1.1306 +	case E24BppBmpType:
  1.1307 +		filename.Set(aRomBitmap ? KComprRomBitmap24() : KComprRamBitmap24());
  1.1308 +		break;
  1.1309 +	default:
  1.1310 +		TEST(EFalse); //should never get here
  1.1311 +		}
  1.1312 +
  1.1313 +	CFbsBitmap* brush_bitmap = new (ELeave) CFbsBitmap;
  1.1314 +	CleanupStack::PushL(brush_bitmap);
  1.1315 +	TInt err = brush_bitmap->Load(filename, 10);
  1.1316 +	TEST(err == KErrNone);
  1.1317 +	iGc->UseBrushPattern(brush_bitmap);
  1.1318 +
  1.1319 +	TInt brush_style = CGraphicsContext::ENullBrush;
  1.1320 +	for(TInt ii=0;ii<25;ii++)
  1.1321 +		{
  1.1322 +		if(++brush_style == CGraphicsContext::EDiamondCrossHatchBrush)
  1.1323 +			{
  1.1324 +			brush_style = CGraphicsContext::ESolidBrush;
  1.1325 +			}
  1.1326 +		iGc->SetBrushStyle(static_cast <CGraphicsContext::TBrushStyle> (brush_style));
  1.1327 +
  1.1328 +		DeleteBitmap();
  1.1329 +		iBitmap = new (ELeave) CFbsBitmap;
  1.1330 +		err = iBitmap->Load(filename, ii);
  1.1331 +		TEST(err == KErrNone);
  1.1332 +		TSize size = iBitmap->SizeInPixels();
  1.1333 +
  1.1334 +		CFbsBitmap* mask_bitmap = new (ELeave) CFbsBitmap;
  1.1335 +		CleanupStack::PushL(mask_bitmap);
  1.1336 +		err = mask_bitmap->Load(filename, (ii+3)<25 ? (ii+3) : (ii-3));
  1.1337 +		TEST(err == KErrNone);
  1.1338 +
  1.1339 +		TPoint pt(0, 0);
  1.1340 +		TRect rc(0, 0, size.iWidth, size.iHeight);
  1.1341 +		//If there is a problem with BitBltMasked - it can fail with "Access violation"
  1.1342 +		//exception on the emulator.
  1.1343 +		iGc->BitBltMasked(pt, iBitmap, rc, mask_bitmap, ETrue);
  1.1344 +		iGc->DrawRect(rc);
  1.1345 +		iDevice->Update();
  1.1346 +		User::After(KDelayTime);
  1.1347 +
  1.1348 +		CleanupStack::PopAndDestroy(mask_bitmap);
  1.1349 +		}
  1.1350 +
  1.1351 +	CleanupStack::PopAndDestroy(brush_bitmap);
  1.1352 +	DestroyFont();
  1.1353 +	}
  1.1354 +
  1.1355 +/**
  1.1356 +  @SYMTestCaseID GRAPHICS-BITGDI-0050
  1.1357 + 
  1.1358 +  @SYMDEF             
  1.1359 +
  1.1360 +  @SYMTestCaseDesc 8 bit bitmap compression - ROM
  1.1361 +   
  1.1362 +  @SYMTestPriority High
  1.1363 +
  1.1364 +  @SYMTestStatus Implemented
  1.1365 +
  1.1366 +  @SYMTestActions Creates and draws to an 8bbp compressed bitmap
  1.1367 + 
  1.1368 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1369 +*/
  1.1370 +void CTDefect::Test8bitBmpComressionL()
  1.1371 +	{
  1.1372 +	CreateScreenDeviceL();
  1.1373 +	CreateFontL();
  1.1374 +
  1.1375 +	TRect rc(10, 20, 610, 220);
  1.1376 +	TPtrC text(_L("8 bpp RAM compressed bitmap."));
  1.1377 +	DisplayBitmapL(KComprRamBitmap8, 0, 0, text, rc);
  1.1378 +
  1.1379 +	if(!iSkipRomBitmapTests)
  1.1380 +		{
  1.1381 +		text.Set(_L("8 bpp ROM compressed bitmap."));
  1.1382 +		DisplayBitmapL(KComprRomBitmap8, 0, 0, text, rc);
  1.1383 +		}
  1.1384 +
  1.1385 +	DestroyFont();
  1.1386 +	}
  1.1387 +
  1.1388 +/**
  1.1389 +  @SYMTestCaseID GRAPHICS-BITGDI-0051
  1.1390 + 
  1.1391 +  @SYMDEF             
  1.1392 +
  1.1393 +  @SYMTestCaseDesc 12 bpp ROM compressed bitmap
  1.1394 +   
  1.1395 +  @SYMTestPriority High
  1.1396 +
  1.1397 +  @SYMTestStatus Implemented
  1.1398 +
  1.1399 +  @SYMTestActions Creates and draws to an 12bbp compressed bitmap
  1.1400 + 
  1.1401 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1402 +*/
  1.1403 +void CTDefect::Test12bitBmpComressionL()
  1.1404 +	{
  1.1405 +	CreateScreenDeviceL();
  1.1406 +	CreateFontL();
  1.1407 +
  1.1408 +	TRect rc(10, 20, 610, 220);
  1.1409 +	TPtrC text(_L("12 bpp RAM compressed bitmap."));
  1.1410 +	DisplayBitmapL(KComprRamBitmap12, 0, 0, text, rc);
  1.1411 +
  1.1412 +	if(!iSkipRomBitmapTests)
  1.1413 +		{
  1.1414 +		text.Set(_L("12 bpp ROM compressed bitmap."));
  1.1415 +		DisplayBitmapL(KComprRomBitmap12, 0, 0, text, rc);
  1.1416 +		}
  1.1417 +
  1.1418 +	DestroyFont();
  1.1419 +	}
  1.1420 +
  1.1421 +/**
  1.1422 +  @SYMTestCaseID GRAPHICS-BITGDI-0052
  1.1423 + 
  1.1424 +  @SYMDEF DEF034134           
  1.1425 +
  1.1426 +  @SYMTestCaseDesc BMCONV has a limitation on the number of bitmaps it can use.
  1.1427 +   
  1.1428 +  @SYMTestPriority High
  1.1429 +
  1.1430 +  @SYMTestStatus Implemented
  1.1431 +
  1.1432 +  @SYMTestActions Loads up a mbm contaiing 8 bitmaps and draws them
  1.1433 + 
  1.1434 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1435 +*/
  1.1436 + void CTDefect::DEF034134L()
  1.1437 +	{
  1.1438 +	CreateScreenDeviceL();
  1.1439 +	CreateFontL();
  1.1440 +
  1.1441 +	TBuf<64> text;
  1.1442 +	for(TInt ii=0;ii<8;ii++)
  1.1443 +	//8 - it is the number of bitmaps in mbm file - see GenBitmaps.mk where this mbm file is generated
  1.1444 +		{
  1.1445 +		text.Format(_L("Bitmap %d"), ii+1);
  1.1446 +		DeleteBitmap();
  1.1447 +		iBitmap = new (ELeave) CFbsBitmap;
  1.1448 +		TInt err = iBitmap->Load(KTestBmp, ii);
  1.1449 +		TEST(err == KErrNone);
  1.1450 +		TSize size = iBitmap->SizeInPixels();
  1.1451 +		DisplayBitmap(text, TRect(20, 20, 20 + size.iWidth, 20 + size.iHeight));
  1.1452 +		}
  1.1453 +
  1.1454 +	DestroyFont();
  1.1455 +	}
  1.1456 +
  1.1457 +/**
  1.1458 +  @SYMTestCaseID GRAPHICS-BITGDI-0053
  1.1459 + 
  1.1460 +  @SYMDEF  DEF036156         
  1.1461 +
  1.1462 +  @SYMTestCaseDesc When using a mask that's smaller than the bitmap being blitted, 
  1.1463 +  the mask should be tiled horizontally and vertically until it's the correct size and then applied to the bitmap.
  1.1464 +   
  1.1465 +  @SYMTestPriority High
  1.1466 +
  1.1467 +  @SYMTestStatus Implemented
  1.1468 +
  1.1469 +  @SYMTestActions Creates bitmap, mask and brush and tests that tiling occurs correctly
  1.1470 + 
  1.1471 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1472 +*/
  1.1473 +void CTDefect::TestTilingHorizontalAndVerticalL()
  1.1474 +	{
  1.1475 +	TDisplayMode mode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, 
  1.1476 +						   EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP};
  1.1477 +	TInt err;
  1.1478 +
  1.1479 +	//Create&load source bitmap
  1.1480 +	CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap;
  1.1481 +	CleanupStack::PushL(srcBmp);
  1.1482 +	err = srcBmp->Load(KBitBltSrcBmp, 0);
  1.1483 +	TEST(err == KErrNone);
  1.1484 +	TSize size1 = srcBmp->SizeInPixels();
  1.1485 +	TPoint pt1(10, 20);
  1.1486 +	TRect rc1(pt1.iX, pt1.iY, pt1.iX + size1.iWidth, pt1.iY + size1.iHeight);
  1.1487 +
  1.1488 +	//Create&load mask bitmap
  1.1489 +	CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap;
  1.1490 +	CleanupStack::PushL(maskBmp);
  1.1491 +	err = maskBmp->Load(KBitBltMaskedBmp, 0);
  1.1492 +	TEST(err == KErrNone);
  1.1493 +	TSize size2 = maskBmp->SizeInPixels();
  1.1494 +	TInt offset = 40;
  1.1495 +	TPoint pt2(pt1.iX, pt1.iY + size1.iHeight + offset);
  1.1496 +	TRect rc2(pt2.iX, pt2.iY, pt2.iX + size2.iWidth, pt2.iY + size2.iHeight);
  1.1497 +
  1.1498 +	//Create&load brush bitmap
  1.1499 +	CFbsBitmap* brush_bitmap = new (ELeave) CFbsBitmap;
  1.1500 +	CleanupStack::PushL(brush_bitmap);
  1.1501 +	err = brush_bitmap->Load(KComprRamBitmap16, 10);
  1.1502 +	TEST(err == KErrNone);
  1.1503 +
  1.1504 +	for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));++ii)
  1.1505 +		{
  1.1506 +		err = CreateScreenDeviceL(mode[ii]);
  1.1507 +		if(err == KErrNotSupported)
  1.1508 +			{
  1.1509 +			continue;
  1.1510 +			}
  1.1511 +		TEST(err == KErrNone);
  1.1512 +
  1.1513 +		CreateFontL();
  1.1514 +
  1.1515 +		iGc->Clear();
  1.1516 +
  1.1517 +		iGc->DrawText(_L("Src bitmap"), TPoint(pt1.iX, pt1.iY - 2));
  1.1518 +		iGc->DrawBitmap(rc1, srcBmp);
  1.1519 +
  1.1520 +		iGc->DrawText(_L("Mask bitmap"), TPoint(pt2.iX, pt2.iY - 2));
  1.1521 +		iGc->DrawBitmap(rc2, maskBmp);
  1.1522 +
  1.1523 +		TBuf<64> text2;
  1.1524 +		_LIT(KMaskMode,"BitBltMasked, Mode: E%S");
  1.1525 +		text2.Format(KMaskMode, &ColorModeName(ii));
  1.1526 +		iGc->DrawText(text2, TPoint(150, pt2.iY-2));
  1.1527 +
  1.1528 +		TPoint pt(pt1.iX + size1.iWidth + offset, pt1.iY);
  1.1529 +		TRect rc(0, 0, size1.iWidth, size1.iHeight);
  1.1530 +
  1.1531 +		CGraphicsContext::TBrushStyle brushStyle[] = 
  1.1532 +			{
  1.1533 +			CGraphicsContext::ENullBrush,
  1.1534 +			CGraphicsContext::ESolidBrush,
  1.1535 +			CGraphicsContext::EPatternedBrush
  1.1536 +			};
  1.1537 +
  1.1538 +		TBuf<32> text[sizeof(brushStyle)/sizeof(brushStyle[0])] = 
  1.1539 +			{
  1.1540 +			_L("NonFlicker"),
  1.1541 +			_L("NonFlickerSolid"),
  1.1542 +			_L("NonFlickerPatterned")
  1.1543 +			};
  1.1544 +
  1.1545 +		iGc->UseBrushPattern(brush_bitmap);
  1.1546 +
  1.1547 +		for(TInt j=0;j<TInt(sizeof(brushStyle)/sizeof(brushStyle[0]));pt.iX+=150,j++)
  1.1548 +			{
  1.1549 +			iGc->DrawText(text[j], TPoint(pt.iX, pt.iY - 2));
  1.1550 +			iGc->SetBrushStyle(brushStyle[j]);
  1.1551 +			iGc->BitBltMasked(pt, srcBmp, rc, maskBmp, ETrue);
  1.1552 +			}
  1.1553 +
  1.1554 +		iDevice->Update();
  1.1555 +		User::After(500000);
  1.1556 +
  1.1557 +		DestroyFont();
  1.1558 +		}//end of - for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));++ii)
  1.1559 +
  1.1560 +	CleanupStack::PopAndDestroy(brush_bitmap);
  1.1561 +	CleanupStack::PopAndDestroy(maskBmp);
  1.1562 +	CleanupStack::PopAndDestroy(srcBmp);
  1.1563 +	DestroyFont();
  1.1564 +	}
  1.1565 +
  1.1566 +/**
  1.1567 +  @SYMTestCaseID GRAPHICS-BITGDI-0054
  1.1568 + 
  1.1569 +  @SYMDEF INC036348 + DEF081298            
  1.1570 +
  1.1571 +  @SYMTestCaseDesc Pie drawing is incorrect in some borderline cases 
  1.1572 +   
  1.1573 +  @SYMTestPriority High
  1.1574 +
  1.1575 +  @SYMTestStatus Implemented
  1.1576 +
  1.1577 +  @SYMTestActions draws pie charts with boundry values and tests it is drawn correctly
  1.1578 + 
  1.1579 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1580 +*/
  1.1581 +void CTDefect::DrawPieBorderlineCasesL()
  1.1582 +	{
  1.1583 +	CreateScreenDeviceL();
  1.1584 +	CreateFontL();
  1.1585 +
  1.1586 +	DrawPie(_L("INC036348 - Missing points"),			TRect(0, 0, 100, 100), TPoint(346, -462),	TPoint( 50, -462));
  1.1587 +	DrawPie(_L("INC036348 - Extra points"),				TRect(0, 0, 100, 100), TPoint(562, -462),	TPoint(187, -462));
  1.1588 +	DrawPie(_L("INC036348 - Draws different range 1"),	TRect(0, 0, 100, 100), TPoint(187, -462),	TPoint( 50, -462));
  1.1589 +	DrawPie(_L("INC036348 - Draws different range 2"),	TRect(0, 0, 100, 100), TPoint( 50, 562),	TPoint(186, 562));
  1.1590 +
  1.1591 +	const TInt rectLength = 300;
  1.1592 +	const TInt rectWidth = 100;
  1.1593 +	for (TInt y = 0; y <= rectWidth; y++)
  1.1594 +		{
  1.1595 +		DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(0, y));
  1.1596 +		}
  1.1597 +	for (TInt x = 0; x <= rectLength; x++)
  1.1598 +		{
  1.1599 +		DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(x, rectWidth));
  1.1600 +		}
  1.1601 +	for (TInt y = rectWidth; y >= 0; y--)
  1.1602 +		{
  1.1603 +		DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(rectLength, y));
  1.1604 +		}
  1.1605 +	for (TInt x = rectLength; x >= 0; x--)
  1.1606 +		{
  1.1607 +		DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(x, 0));
  1.1608 +		}
  1.1609 +
  1.1610 +	DestroyFont();
  1.1611 +	}
  1.1612 +
  1.1613 +/**
  1.1614 +  @SYMTestCaseID GRAPHICS-BITGDI-0055
  1.1615 + 
  1.1616 +  @SYMDEF Panic in bitgdi in Typhoon 30.            
  1.1617 +
  1.1618 +  @SYMTestCaseDesc INC037380
  1.1619 +   
  1.1620 +  @SYMTestPriority normal
  1.1621 +
  1.1622 +  @SYMTestStatus Implemented
  1.1623 +
  1.1624 +  @SYMTestActions Test BitBltMasked works correctly with 64K bitmaps and EGray256 masks
  1.1625 + 
  1.1626 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1627 +*/
  1.1628 +void CTDefect::INC037380L()
  1.1629 +	{
  1.1630 +	TInt ii;
  1.1631 +	TInt err;
  1.1632 +	//Create the screen device
  1.1633 +	err = CreateScreenDeviceL(EColor64K);
  1.1634 +	if (err == KErrNotSupported)
  1.1635 +		err = CreateScreenDeviceL(EColor16MA);
  1.1636 +	if (err == KErrNotSupported)
  1.1637 +		err = CreateScreenDeviceL(EColor16MAP);
  1.1638 +	if (err == KErrNotSupported)
  1.1639 +		return;
  1.1640 +	User::LeaveIfError(err);
  1.1641 +	//Create source bitmap
  1.1642 +	CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap;
  1.1643 +	CleanupStack::PushL(srcBmp);
  1.1644 +	User::LeaveIfError(srcBmp->Create(TSize(500, 1), EColor16M));
  1.1645 +	TBitmapUtil bmpUtil1(srcBmp);
  1.1646 +	bmpUtil1.Begin(TPoint(0, 0));
  1.1647 +	for(ii=0;ii<500;ii++)
  1.1648 +		{
  1.1649 +		bmpUtil1.SetPos(TPoint(ii,0));
  1.1650 +		bmpUtil1.SetPixel(ii);
  1.1651 +		}
  1.1652 +	bmpUtil1.End();
  1.1653 +	//Create mask bitmap
  1.1654 +	CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap;
  1.1655 +	CleanupStack::PushL(maskBmp);
  1.1656 +	User::LeaveIfError(maskBmp->Create(TSize(20, 1), EGray256));
  1.1657 +	TBitmapUtil bmpUtil2(maskBmp);
  1.1658 +	bmpUtil2.Begin(TPoint(0, 0));
  1.1659 +	for(ii=0;ii<20;ii++)
  1.1660 +		{
  1.1661 +		bmpUtil1.SetPos(TPoint(ii,0));
  1.1662 +		bmpUtil2.SetPixel(100 + ii);
  1.1663 +		}
  1.1664 +	bmpUtil2.End();
  1.1665 +	//Create brush bitmap
  1.1666 +	CFbsBitmap* brush_bitmap = new (ELeave) CFbsBitmap;
  1.1667 +	CleanupStack::PushL(brush_bitmap);
  1.1668 +	User::LeaveIfError(brush_bitmap->Create(TSize(20, 1), EColor64K));
  1.1669 +	TBitmapUtil bmpUtil3(brush_bitmap);
  1.1670 +	bmpUtil3.Begin(TPoint(0, 0));
  1.1671 +	for(ii=0;ii<20;ii++)
  1.1672 +		{
  1.1673 +		bmpUtil1.SetPos(TPoint(ii,0));
  1.1674 +		bmpUtil3.SetPixel(200 + ii);
  1.1675 +		}
  1.1676 +	bmpUtil3.End();
  1.1677 +
  1.1678 +	iGc->Clear();
  1.1679 +	iGc->DrawBitmap(TRect(0, 20, 500, 21), srcBmp);
  1.1680 +	iGc->DrawBitmap(TRect(0, 22, 20, 23), maskBmp);
  1.1681 +	iGc->UseBrushPattern(brush_bitmap);
  1.1682 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1683 +
  1.1684 +	//The following call panics if the fix doesn't exist.
  1.1685 +	iGc->BitBltMasked(TPoint(0, 0), srcBmp, TRect(0, 0, 500, 1), maskBmp, ETrue);
  1.1686 +
  1.1687 +	iDevice->Update();
  1.1688 +
  1.1689 +	CleanupStack::PopAndDestroy(brush_bitmap);
  1.1690 +	CleanupStack::PopAndDestroy(maskBmp);
  1.1691 +	CleanupStack::PopAndDestroy(srcBmp);
  1.1692 +	}
  1.1693 +
  1.1694 +/**
  1.1695 +  @SYMTestCaseID GRAPHICS-BITGDI-0056
  1.1696 + 
  1.1697 +  @SYMDEF INC037474        
  1.1698 +
  1.1699 +  @SYMTestCaseDesc CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData() is very slow
  1.1700 +   
  1.1701 +  @SYMTestPriority High
  1.1702 +
  1.1703 +  @SYMTestStatus Implemented
  1.1704 +
  1.1705 +  @SYMTestActions measures the time the GenerateLineFromCompressedSixteenBitData method takes with different target modes
  1.1706 + 
  1.1707 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1708 +*/
  1.1709 +void CTDefect::INC037474L()
  1.1710 +	{
  1.1711 +	TPtrC bmpFile[] =
  1.1712 +		{
  1.1713 +		KBmpCompr12(),
  1.1714 +		KBmpCompr16(),
  1.1715 +		KBmpCCompr12(),
  1.1716 +		KBmpCCompr16()
  1.1717 +		};
  1.1718 +	TPtrC tt[] = {_L("rom"), _L("rom"), _L("ram"), _L("ram")};
  1.1719 +	TBool inRam[] = {EFalse, EFalse, ETrue, ETrue};
  1.1720 +	TInt bpp[] = {12, 16, 12, 16};
  1.1721 +	TDisplayMode targetMode[] = {EColor4K, EColor64K, EColor4K, EColor64K};
  1.1722 +	const TInt KMaxScanLineLen = 800;
  1.1723 +	TBuf8<KMaxScanLineLen> scanLineBuf;
  1.1724 +	for(TInt ii=0;ii<TInt(sizeof(bmpFile)/sizeof(bmpFile[0]));ii++)
  1.1725 +		{
  1.1726 +		if(iSkipRomBitmapTests && !inRam[ii])
  1.1727 +			continue;
  1.1728 +		
  1.1729 +		CFbsBitGcBitmap* bmp = ::LoadBitmapLC(bmpFile[ii]);
  1.1730 +		if(inRam[ii])
  1.1731 +			{
  1.1732 +			User::LeaveIfError(bmp->Compress());
  1.1733 +			}
  1.1734 +		//
  1.1735 +		TDesC& des = tt[ii];
  1.1736 +		INFO_PRINTF3(_L("%d bpp %S compressed bitmap, GetScanLine test"), bpp[ii], &des);
  1.1737 +		TSize size = bmp->SizeInPixels();
  1.1738 +		TEST(TInt(size.iWidth * sizeof(TInt16)) <= KMaxScanLineLen);
  1.1739 +		bmp->LockHeap();
  1.1740 +		CBitwiseBitmap* bmp2 = bmp->Address();
  1.1741 +		TUint32* dataAddr = bmp->DataAddress();
  1.1742 +		TLineScanningPosition scanLinePos(dataAddr);
  1.1743 +		TPoint pt00(0, 0);
  1.1744 +		TUint timeStart = User::TickCount();
  1.1745 +		for(TInt j=0;j<100;j++)
  1.1746 +			{
  1.1747 +			TPoint startPixel(0, 0);
  1.1748 +			for(TInt k=0;k<size.iHeight;k++)
  1.1749 +				{
  1.1750 +				startPixel.iY = k;
  1.1751 +				bmp2->GetScanLine(scanLineBuf, startPixel, size.iWidth,
  1.1752 +								  EFalse, pt00, targetMode[ii],
  1.1753 +								  dataAddr, scanLinePos);
  1.1754 +				}
  1.1755 +			}
  1.1756 +		TUint timeEnd = User::TickCount();
  1.1757 +		INFO_PRINTF4(_L("%d bpp %S compressed bitmap, time = %d"), bpp[ii], &des, timeEnd - timeStart);
  1.1758 +		bmp->UnlockHeap();
  1.1759 +		//
  1.1760 +		CleanupStack::PopAndDestroy(bmp);
  1.1761 +		}
  1.1762 +	}
  1.1763 +
  1.1764 +/**
  1.1765 +  @SYMTestCaseID GRAPHICS-BITGDI-0057
  1.1766 + 
  1.1767 +  @SYMDEF INC037370            
  1.1768 +
  1.1769 +  @SYMTestCaseDesc Corrupted compressed images 
  1.1770 +   
  1.1771 +  @SYMTestPriority normal
  1.1772 +
  1.1773 +  @SYMTestStatus Implemented
  1.1774 +
  1.1775 +  @SYMTestActions Creates some compressed bitmaps, resizes them and compares results
  1.1776 + 
  1.1777 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1778 +*/
  1.1779 +//INC037370 - Corrupted compressed images 
  1.1780 +void CTDefect::INC037370L()
  1.1781 +	{
  1.1782 +	CreateScreenDeviceL();
  1.1783 +	TPtrC bmpFile[] = {KBmp16_1(), KBmp16_2(), KBmp16_3()};
  1.1784 +	CFbsBitGcBitmap* bmp[] = {NULL, NULL, NULL};
  1.1785 +	const TInt bmpArrSize = sizeof(bmp) / sizeof(bmp[0]);
  1.1786 +	//Load the bitmaps
  1.1787 +	::LoadBitmapsLC<bmpArrSize>(&bmp, bmpFile);
  1.1788 +	TInt ii;
  1.1789 +	//Compress the bitmaps
  1.1790 +	for(ii=0;ii<bmpArrSize;ii++)
  1.1791 +		{
  1.1792 +		bmp[ii]->Compress();
  1.1793 +		}
  1.1794 +	//Display the bitmaps
  1.1795 +	::DisplayBitmaps<bmpArrSize>(&bmp, iDevice, iGc);
  1.1796 +	//Resize bitmap[0]
  1.1797 +	const TInt KResize = 100;
  1.1798 +	TSize size = bmp[0]->SizeInPixels();
  1.1799 +	size.iWidth -= KResize;
  1.1800 +	size.iHeight -= KResize;
  1.1801 +	bmp[0]->Resize(size);
  1.1802 +	//Display the bitmaps again. If the defect is not fixed - bmp[0] image is corrupted!
  1.1803 +	::DisplayBitmaps<bmpArrSize>(&bmp, iDevice, iGc);
  1.1804 +	//Compare bmp[0] and bmp[1]. If the defect is not fixed - the test will fail!
  1.1805 +	::CompareBitmaps<bmpArrSize, 1000>(&bmp, EColor64K, 0, 1, this);
  1.1806 +	//Resize bitmap[1]
  1.1807 +	size = bmp[1]->SizeInPixels();
  1.1808 +	size.iWidth += KResize;
  1.1809 +	size.iHeight += KResize;
  1.1810 +	bmp[1]->Resize(size);
  1.1811 +	//Display the bitmaps again. If the defect is not fixed - bmp[1] image is corrupted!
  1.1812 +	::DisplayBitmaps<bmpArrSize>(&bmp, iDevice, iGc);
  1.1813 +	//Compare bmp[1] and bmp[2]. If the defect is not fixed - the test will fail!
  1.1814 +	::CompareBitmaps<bmpArrSize, 1000>(&bmp, EColor64K, 1, 2, this);
  1.1815 +	//Destroy the bitmaps
  1.1816 +	::DestroyBitmaps<bmpArrSize>(&bmp);
  1.1817 +	}
  1.1818 +
  1.1819 +/**
  1.1820 +  @SYMTestCaseID GRAPHICS-BITGDI-0058
  1.1821 + 
  1.1822 +  @SYMDEF             
  1.1823 +
  1.1824 +  @SYMTestCaseDesc Tests setting of various display modes
  1.1825 +   
  1.1826 +  @SYMTestPriority High
  1.1827 +
  1.1828 +  @SYMTestStatus Implemented
  1.1829 +
  1.1830 +  @SYMTestActions Sets display modes then displays bitmaps 
  1.1831 + 
  1.1832 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1833 +*/
  1.1834 +//Test CFbsBitmap::SetDisplayMode()
  1.1835 +void CTDefect::TestSettingDisplayModeL()
  1.1836 +	{
  1.1837 +	TDisplayMode mode[] = {ENone, EGray2, EGray4, EGray16, EGray256, EColor16, EColor256,
  1.1838 +						   EColor64K, EColor16M, ERgb, EColor4K, EColor16MU, EColor16MA, EColor16MAP};
  1.1839 +	_LIT(KLog,"Running test with display mode %S (index=%d)");
  1.1840 +	for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));ii++)
  1.1841 +		{
  1.1842 +		if(mode[ii] == ENone || mode[ii] == ERgb || CreateScreenDeviceL(mode[ii]) != KErrNone)
  1.1843 +			{
  1.1844 +			continue;
  1.1845 +			}
  1.1846 +		INFO_PRINTF3(KLog,&ColorModeName(mode[ii]),ii);
  1.1847 +		DestroyFont();
  1.1848 +		CreateFontL();
  1.1849 +
  1.1850 +		TRect rc(10, 20, 610, 220);
  1.1851 +
  1.1852 +		DeleteBitmap();
  1.1853 +		iBitmap = new (ELeave) CFbsBitmap;
  1.1854 +		TInt err = iBitmap->Load(KRamBitmap, 0);
  1.1855 +		TEST(err == KErrNone);
  1.1856 +		TDisplayMode initialDisplayMode = iBitmap->InitialDisplayMode();
  1.1857 +		TInt bmpMode;
  1.1858 +		//From the initial display mode to EGray2 mode.
  1.1859 +		for(bmpMode=initialDisplayMode;bmpMode!=ENone;bmpMode--)
  1.1860 +			{
  1.1861 +			DisplayBitmap(rc, mode[ii], TDisplayMode(bmpMode));
  1.1862 +			}
  1.1863 +		//From EGray2 mode to the initial display mode
  1.1864 +		for(bmpMode=EGray2;bmpMode<=initialDisplayMode;bmpMode++)
  1.1865 +			{
  1.1866 +			DisplayBitmap(rc, mode[ii], TDisplayMode(bmpMode));
  1.1867 +			}
  1.1868 +		}
  1.1869 +	}
  1.1870 +
  1.1871 +/**
  1.1872 +  @SYMTestCaseID GRAPHICS-BITGDI-0059
  1.1873 + 
  1.1874 +  @SYMDEF             
  1.1875 +
  1.1876 +  @SYMTestCaseDesc Tests setting of various display modes
  1.1877 +   
  1.1878 +  @SYMTestPriority High
  1.1879 +
  1.1880 +  @SYMTestStatus Implemented
  1.1881 +
  1.1882 +  @SYMTestActions tests display modes are set correctly by checking scanline data wlan
  1.1883 +  
  1.1884 + 
  1.1885 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1886 +*/
  1.1887 +void CTDefect::TestSettingDisplayMode2L()
  1.1888 +	{
  1.1889 +	// Try color mode 64K, 256 and 16MA
  1.1890 +	TInt err=CreateScreenDeviceL(EColor64K);
  1.1891 +	if (err!=KErrNone)
  1.1892 +		err=CreateScreenDeviceL(EColor256);
  1.1893 +	if (err!=KErrNone)
  1.1894 +		err=CreateScreenDeviceL(EColor16MA);
  1.1895 +	if (err!=KErrNone)
  1.1896 +		err=CreateScreenDeviceL(EColor16MAP);
  1.1897 +	User::LeaveIfError(err);
  1.1898 +	DeleteBitmap();
  1.1899 +	const TInt KBmpWidth = 100;
  1.1900 +	//The bitmap data - for EColor16MU - the pixel with the largest width in bits
  1.1901 +	const TInt bytePerPixel = 4;
  1.1902 +	TUint8 srcBmpData[KBmpWidth * bytePerPixel];
  1.1903 +	Mem::Fill(srcBmpData, sizeof(srcBmpData) / 2, 0xFF); //First half is white colored
  1.1904 +	Mem::Fill(srcBmpData + sizeof(srcBmpData) / 2, sizeof(srcBmpData) / 2, 0x00);//Second half is black colored
  1.1905 +	//The bitmap
  1.1906 +	iBitmap = new (ELeave) CFbsBitmap;
  1.1907 +	User::LeaveIfError(iBitmap->Create(TSize(KBmpWidth, 1), EColor16MU));
  1.1908 +	const TSize KSize = iBitmap->SizeInPixels();
  1.1909 +	TPtr8 p(srcBmpData, KBmpWidth * bytePerPixel, KBmpWidth * bytePerPixel);
  1.1910 +	iBitmap->SetScanLine(p, 0);
  1.1911 +	TDisplayMode mode[] = {EColor16MAP, EColor16MA, EColor16MU, EColor16M, EColor64K,
  1.1912 +						   EColor4K, EColor256, EGray256, EColor16,
  1.1913 +						   EGray16, EGray4, EGray2};
  1.1914 +	TInt ii;
  1.1915 +	for(ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));ii++)
  1.1916 +		{
  1.1917 +		SetAndCheckDisplayMode(mode[ii], KSize);
  1.1918 +		}
  1.1919 +	for(ii=((sizeof(mode)/sizeof(mode[0]))-1);ii!=-1;ii--)
  1.1920 +		{
  1.1921 +		SetAndCheckDisplayMode(mode[ii], KSize);
  1.1922 +		}
  1.1923 +	}
  1.1924 +
  1.1925 +void CTDefect::SetAndCheckDisplayMode(TDisplayMode aMode, const TSize& aInitialSize)
  1.1926 +	{
  1.1927 +	TInt err = iBitmap->SetDisplayMode(aMode);
  1.1928 +	TEST(err == KErrNone);
  1.1929 +	TSize size = iBitmap->SizeInPixels();
  1.1930 +	TEST(aInitialSize == size);
  1.1931 +	TEST(iBitmap->DisplayMode() == aMode);
  1.1932 +	INFO_PRINTF2(_L("Check scanline in display mode: %d"), aMode);
  1.1933 +	CheckScanLine();
  1.1934 +	}
  1.1935 +
  1.1936 +void CTDefect::CheckScanLine()
  1.1937 +	{
  1.1938 +	TSize size = iBitmap->SizeInPixels();
  1.1939 +	TInt j;
  1.1940 +	TRgb whiteColor(0xFF, 0xFF, 0xFF);
  1.1941 +	TPoint pt(0, 0);
  1.1942 +	for(j=0;j<(size.iWidth/2);j++)
  1.1943 +		{
  1.1944 +		TRgb color;
  1.1945 +		pt.iX = j;
  1.1946 +		iBitmap->GetPixel(color, pt);
  1.1947 +		TEST(color == whiteColor);
  1.1948 +		}
  1.1949 +	TRgb blackColor(0x00, 0x00, 0x00);
  1.1950 +	for(j=(size.iWidth/2);j<size.iWidth;j++)
  1.1951 +		{
  1.1952 +		TRgb color;
  1.1953 +		pt.iX = j;
  1.1954 +		iBitmap->GetPixel(color, pt);
  1.1955 +		if(color != blackColor)
  1.1956 +			{
  1.1957 +			ERR_PRINTF1(_L("Scan line error"));
  1.1958 +			}
  1.1959 +		TEST(color == blackColor);
  1.1960 +		}
  1.1961 +	}
  1.1962 +
  1.1963 +/**
  1.1964 +  @SYMTestCaseID GRAPHICS-BITGDI-0060
  1.1965 + 
  1.1966 +  @SYMDEF             
  1.1967 +
  1.1968 +  @SYMTestCaseDesc tests swapping a bitmaps width and height
  1.1969 +   
  1.1970 +  @SYMTestPriority High
  1.1971 +
  1.1972 +  @SYMTestStatus Implemented
  1.1973 +
  1.1974 +  @SYMTestActions Creates a bitmap, swaps its width and height and tests for correct size
  1.1975 + 
  1.1976 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1977 +*/
  1.1978 +void CTDefect::TestSwappingWidthAndHeightL()
  1.1979 +	{
  1.1980 +	// Try color mode 64K, 256 and 16MA
  1.1981 +	TInt err=CreateScreenDeviceL(EColor64K);
  1.1982 +	if (err!=KErrNone)
  1.1983 +		err=CreateScreenDeviceL(EColor256);
  1.1984 +	if (err!=KErrNone)
  1.1985 +		err = CreateScreenDeviceL(EColor16MA);
  1.1986 +	if (err!=KErrNone)
  1.1987 +		err = CreateScreenDeviceL(EColor16MAP);
  1.1988 +	User::LeaveIfError(err);
  1.1989 +	DestroyFont();
  1.1990 +	CreateFontL();
  1.1991 +
  1.1992 +	DeleteBitmap();
  1.1993 +	iBitmap = new (ELeave) CFbsBitmap;
  1.1994 +	err = iBitmap->Load(KRamBitmap, 0);
  1.1995 +	TEST(err == KErrNone);
  1.1996 +
  1.1997 +	TSize size1_1 = iBitmap->SizeInPixels();
  1.1998 +	TSize size1_2 = iBitmap->SizeInTwips();
  1.1999 +	TRect rc(10, 20, 610, 220);
  1.2000 +	TPtrC text(_L("Before swapping"));
  1.2001 +	DisplayBitmap(text, rc);
  1.2002 +
  1.2003 +	iBitmap->SwapWidthAndHeight();
  1.2004 +	TSize size2_1 = iBitmap->SizeInPixels();
  1.2005 +	TSize size2_2 = iBitmap->SizeInTwips();
  1.2006 +	TEST(size1_1.iWidth == size2_1.iHeight && size1_1.iHeight == size2_1.iWidth);
  1.2007 +	TEST(size1_2.iWidth == size2_2.iHeight && size1_2.iHeight == size2_2.iWidth);
  1.2008 +
  1.2009 +	text.Set(_L("After swapping"));
  1.2010 +	DisplayBitmap(text, rc);
  1.2011 +	rc = TRect(10, 20, 210, 620);
  1.2012 +	DisplayBitmap(text, rc);
  1.2013 +
  1.2014 +	DeleteBitmap();
  1.2015 +	iBitmap = new (ELeave) CFbsBitmap;
  1.2016 +	iBitmap->Create(TSize(17, 1), EGray2);
  1.2017 +
  1.2018 +	DeleteBitmap();
  1.2019 +	iBitmap = new (ELeave) CFbsBitmap;
  1.2020 +	iBitmap->Create(TSize(1, 17), EGray2);
  1.2021 +	}
  1.2022 +
  1.2023 +/**
  1.2024 +  @SYMTestCaseID GRAPHICS-BITGDI-0061
  1.2025 + 
  1.2026 +  @SYMDEF DEF038774             
  1.2027 +
  1.2028 +  @SYMTestCaseDesc Buffer overflow when using CFbsBitmapDevice::GetScanLine and EGray2 disp.mode 
  1.2029 +  					EGray4, EGray16, EColor16 modes also tested.
  1.2030 +   
  1.2031 +  @SYMTestPriority High
  1.2032 +
  1.2033 +  @SYMTestStatus Implemented
  1.2034 +
  1.2035 +  @SYMTestActions Creates bitmap of various width depending on the colour mode and checks that its buffer 
  1.2036 +  					does not get an overflow when written to
  1.2037 + 
  1.2038 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.2039 +*/
  1.2040 +void CTDefect::DEF038774L()
  1.2041 +	{
  1.2042 +	enum {KHeight = 1};//Bitmaps height - in pixels
  1.2043 +	TDisplayMode testMode[] =  {EGray2, EGray4, EGray16, EColor16, EColor4K, EColor64K, EColor16M, EColor16MU, EColor16MA, EColor16MAP};//tested display modes
  1.2044 +	const TInt pixelPerByte[] ={8,      4,      2,       2,        0,        0,         0,         0,		0};
  1.2045 +	const TInt bytePerPixel[] ={0,      0,      0,       0,        2,        2,         3,         4,		4};
  1.2046 +	const TInt bitmapWidth[] = {22,     7,      11,      11,       3,        3,         1,         1,		1};//bitmaps width
  1.2047 +	const TUint8 KTestVal1 = 0xA3;//test value
  1.2048 +	const TUint8 KTestVal2 = 0xF7;//test value
  1.2049 +	TUint8 scanLineData[100];//100 should be enough for all possible modes which are tested
  1.2050 +	for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
  1.2051 +		{
  1.2052 +		TSize size(bitmapWidth[ii], KHeight);//bitmap size - in pixels
  1.2053 +		CreateBitmapL(size, testMode[ii]);
  1.2054 +		//Initialize the bitmap scanline
  1.2055 +		TInt scanLineLen = 0;
  1.2056 +		if(pixelPerByte[ii])
  1.2057 +			{
  1.2058 +			scanLineLen = bitmapWidth[ii] / pixelPerByte[ii];
  1.2059 +			}
  1.2060 +		else
  1.2061 +			{
  1.2062 +			scanLineLen = bitmapWidth[ii] * bytePerPixel[ii];
  1.2063 +			}
  1.2064 +		Mem::Fill(scanLineData, scanLineLen, KTestVal1);
  1.2065 +		TPtr8 p(scanLineData, scanLineLen, scanLineLen);
  1.2066 +		iBitmap->SetScanLine(p, 0);
  1.2067 +		//Create bitmap device (KWidth, KHeight) size
  1.2068 +		DeleteBitmapDevice();
  1.2069 +		iBmpDevice = CFbsBitmapDevice::NewL(iBitmap);
  1.2070 +		//Fill the scanLineData with control values
  1.2071 +		Mem::Fill(scanLineData, sizeof(scanLineData), KTestVal2);
  1.2072 +		//GetScanLine test - check the (scanLineLen + 1) byte
  1.2073 +		iBmpDevice->GetScanLine(p, TPoint(), bitmapWidth[ii], testMode[ii]);
  1.2074 +		TEST(scanLineData[scanLineLen + 1] == KTestVal2);
  1.2075 +		}
  1.2076 +	}
  1.2077 +
  1.2078 +/**
  1.2079 +  @SYMTestCaseID	GRAPHICS-BITGDI-0086
  1.2080 +
  1.2081 +  @SYMDEF DEF121299             
  1.2082 +
  1.2083 +  @SYMTestCaseDesc Ensure alpha channel is not overwritten in 16MU BitBlt/DrawBitmap Operations.
  1.2084 +   
  1.2085 +  @SYMTestPriority High
  1.2086 +
  1.2087 +  @SYMTestStatus Implemented
  1.2088 +
  1.2089 +  @SYMTestActions Creates 1x1 or 2x2 pixel Bitmaps with non 0x00/0xFF alpha channel to test BitBlt/DrawBitmap operations.
  1.2090 + 
  1.2091 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.2092 +*/
  1.2093 +void CTDefect::TestBitBltOperationsOn16muUndefinedByteL()
  1.2094 +	{
  1.2095 +	//Create a source bitmap and set the Alpha channel to a Non 0xFF/0x00 value.
  1.2096 +	CFbsBitmap* srcbmp = new(ELeave) CFbsBitmap();
  1.2097 +	CleanupStack::PushL(srcbmp);
  1.2098 +	User::LeaveIfError(srcbmp->Create(TSize(1,1), EColor16MU));
  1.2099 +	
  1.2100 +	*(srcbmp->DataAddress()) = 0x55000000;
  1.2101 +	
  1.2102 +	CFbsBitmap* destbmp = new(ELeave) CFbsBitmap();
  1.2103 +	CleanupStack::PushL(destbmp);
  1.2104 +	//Create this one as 2x2 so DrawBitmap tests will work.
  1.2105 +	User::LeaveIfError(destbmp->Create(TSize(2,2), EColor16MU));
  1.2106 +
  1.2107 +	//Create Bitmap Device & Gc to perform BitBlt/DrawBmp operations.
  1.2108 +	CFbsBitmapDevice* bmpdev = CFbsBitmapDevice::NewL(destbmp);
  1.2109 +	CleanupStack::PushL(bmpdev);
  1.2110 +	CFbsBitGc* bmpgc;
  1.2111 +	User::LeaveIfError(bmpdev->CreateContext(bmpgc));
  1.2112 +	CleanupStack::PushL(bmpgc);
  1.2113 +	bmpgc->Activate(bmpdev);
  1.2114 +	
  1.2115 +	//Create Extra Mask Bitmap
  1.2116 +	CFbsBitmap* bmpmask16mu = new(ELeave)CFbsBitmap();
  1.2117 +	CleanupStack::PushL(bmpmask16mu);
  1.2118 +	User::LeaveIfError(bmpmask16mu->Create(TSize(2,2), EColor16MU));
  1.2119 +	
  1.2120 +	//BitBlt
  1.2121 +	INFO_PRINTF1(_L("Performing BitBlt() Test"));
  1.2122 +	bmpgc->BitBlt(TPoint(0,0), srcbmp);
  1.2123 +	TEST(CompareFirstPixelAlphaChannel(srcbmp, destbmp));
  1.2124 +	
  1.2125 +	//BitBltMasked
  1.2126 +	INFO_PRINTF1(_L("Performing BitBltMasked() Test"));
  1.2127 +	bmpgc->BitBltMasked(TPoint(0,0), srcbmp, TRect(TPoint(0,0), TSize(1,1)), srcbmp, EFalse);
  1.2128 +	TEST(CompareFirstPixelAlphaChannel(srcbmp, destbmp));
  1.2129 +		
  1.2130 +	CleanupStack::PopAndDestroy(5, srcbmp);
  1.2131 +	}
  1.2132 +
  1.2133 +
  1.2134 +void CTDefect::DeleteBitmap()
  1.2135 +	{
  1.2136 +	if(iBitmap)
  1.2137 +		{
  1.2138 +		iBitmap->Reset();
  1.2139 +		}
  1.2140 +	delete iBitmap;
  1.2141 +	iBitmap = NULL;
  1.2142 +	}
  1.2143 +
  1.2144 +void CTDefect::DeleteBitmapDevice()
  1.2145 +	{
  1.2146 +	delete iBmpDevice;
  1.2147 +	iBmpDevice = NULL;
  1.2148 +	}
  1.2149 +
  1.2150 +void CTDefect::DeleteScreenDevice()
  1.2151 +	{
  1.2152 +	delete iDevice;
  1.2153 +	iDevice = NULL;
  1.2154 +	}
  1.2155 +
  1.2156 +void CTDefect::DeleteGraphicsContext()
  1.2157 +	{
  1.2158 +	delete iGc;
  1.2159 +	iGc = NULL;
  1.2160 +	}
  1.2161 +
  1.2162 +void CTDefect::DisplayBitmapL(const TDesC& aFileName, TInt aBitmapNo, TInt aBitmapOffset, const TDesC& aText, const TRect& aRc)
  1.2163 +	{
  1.2164 +	DeleteBitmap();
  1.2165 +	iBitmap = new (ELeave) CFbsBitmap;
  1.2166 +	TInt err = iBitmap->Load(aFileName, aBitmapNo, EFalse, aBitmapOffset);
  1.2167 +	if(err)
  1.2168 +		INFO_PRINTF3(_L("Error (%d) while loading bitmap (%S)"), err, &aFileName);
  1.2169 +	TEST(err == KErrNone);
  1.2170 +	DisplayBitmap(aText, aRc);
  1.2171 +	}
  1.2172 +
  1.2173 +void CTDefect::DisplayBitmap(const TDesC& aText, const TRect& aRc)
  1.2174 +	{
  1.2175 +	iGc->Clear();
  1.2176 +	iGc->DrawBitmap(aRc, iBitmap);
  1.2177 +	iGc->DrawText(aText, TPoint(10, 15));
  1.2178 +	iDevice->Update();
  1.2179 +	User::After(KDelayTime);
  1.2180 +	}
  1.2181 +
  1.2182 +void CTDefect::DisplayBitmap(const TRect& aRc, TDisplayMode aScreenMode, TDisplayMode aBmpMode)
  1.2183 +	{
  1.2184 +	if (aBmpMode==ENone || aBmpMode==ERgb)
  1.2185 +		{
  1.2186 +		return;
  1.2187 +		}
  1.2188 +	_LIT(KLog,"ScreenMode: %S, SetDisplayMode: %S");
  1.2189 +	TBuf<128> text;
  1.2190 +	text.Format(KLog,&ColorModeName(aScreenMode),&ColorModeName(aBmpMode));
  1.2191 +	INFO_PRINTF1(text);
  1.2192 +	TInt err = iBitmap->SetDisplayMode(aBmpMode);
  1.2193 +	TEST(err == KErrNone);
  1.2194 +	DisplayBitmap(text, aRc);
  1.2195 +	}
  1.2196 +
  1.2197 +void CTDefect::CreateFontL()
  1.2198 +	{
  1.2199 +	CFbsFont* font = NULL;
  1.2200 +	TFontSpec fs(_L("Swiss"), 12);
  1.2201 +	User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInPixels(font, fs));
  1.2202 +	iGc->UseFont(font);
  1.2203 +	}
  1.2204 +
  1.2205 +void CTDefect::DestroyFont()
  1.2206 +	{
  1.2207 +	if(iGc)
  1.2208 +		{
  1.2209 +		iGc->DiscardFont();
  1.2210 +		}
  1.2211 +	}
  1.2212 +
  1.2213 +void CTDefect::DrawPie(const TDesC& aText, const TRect& aRc, const TPoint& aPtStart, const TPoint& aPtEnd)
  1.2214 +	{
  1.2215 +	const TRgb green(0x00, 0xFF, 0x00);
  1.2216 +	const TRgb red(0xFF, 0x00, 0x00);
  1.2217 +	const TRgb blue(0x00, 0x00, 0xFF);
  1.2218 +	const TRgb white(0xFF, 0xFF, 0xFF);
  1.2219 +
  1.2220 +	iGc->SetBrushColor(white);
  1.2221 +	iGc->Clear();
  1.2222 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2223 +	iGc->SetBrushColor(green);
  1.2224 +	iGc->DrawRect(aRc);
  1.2225 +	iGc->SetPenColor(blue);
  1.2226 +	iGc->SetBrushColor(red);
  1.2227 +	iGc->DrawPie(aRc, aPtStart, aPtEnd);
  1.2228 +	iGc->SetBrushColor(blue);
  1.2229 +	iGc->DrawLine(
  1.2230 +		TPoint(aRc.iTl.iX, aRc.iTl.iY + aRc.Height() / 2),
  1.2231 +		TPoint(aRc.iTl.iX + aRc.Width(), aRc.iTl.iY + aRc.Height() / 2));
  1.2232 +	iGc->DrawLine(
  1.2233 +		TPoint(aRc.iTl.iX + aRc.Width() / 2, aRc.iTl.iY),
  1.2234 +		TPoint(aRc.iTl.iX + aRc.Width() / 2, aRc.iTl.iY + aRc.Height()));
  1.2235 +	iGc->DrawText(
  1.2236 +		aText,
  1.2237 +		TPoint(aRc.iTl.iX, aRc.iTl.iY + aRc.Height() + 15));
  1.2238 +	iDevice->Update();
  1.2239 +	User::After(10000);
  1.2240 +	}
  1.2241 +
  1.2242 +void CTDefect::CreateBitmapL(const TSize& aSize, TDisplayMode aMode)
  1.2243 +	{
  1.2244 +	DeleteBitmap();
  1.2245 +	iBitmap = new (ELeave) CFbsBitmap;
  1.2246 +	User::LeaveIfError(iBitmap->Create(aSize, aMode));
  1.2247 +	}
  1.2248 +
  1.2249 +
  1.2250 +static void DisconnectFbsSession(TAny*)
  1.2251 +	{
  1.2252 +	RFbsSession::Disconnect();
  1.2253 +	}
  1.2254 +
  1.2255 +void CTDefect::INC042156L()
  1.2256 +	{
  1.2257 +	User::LeaveIfError(RFbsSession::Connect());
  1.2258 +	CleanupStack::PushL(TCleanupItem(DisconnectFbsSession, NULL));
  1.2259 +
  1.2260 +	TInt mbm_offset = 0;
  1.2261 +	TBuf<100> text;
  1.2262 +	TPtrC BitmapTypeName[ELastBmpType] = {_L("16 bpp"), _L("24 bpp")};
  1.2263 +	typedef enum {ERAMFileType, ERAMCFileType, EROMFileType, EROMCFileType, ELastBmpFileType} TBitmapFileType;
  1.2264 +	TPtrC BitmapFile[ELastBmpFileType][ELastBmpType] = 
  1.2265 +		{
  1.2266 +		{KRamBitmap(), KRam24Bitmap()},
  1.2267 +		{KRamCBitmap(), KRamC24Bitmap()},
  1.2268 +		{KRomBitmap(), KRom24Bitmap()},
  1.2269 +		{KRomCBitmap(), KRomC24Bitmap()}
  1.2270 +		};
  1.2271 +
  1.2272 +	text = BitmapTypeName[E24BppBmpType];
  1.2273 +	text += _L(" ROM compressed bitmap.");
  1.2274 +
  1.2275 +	const TInt KWidth = 20;
  1.2276 +	const TInt KHeight = 20;
  1.2277 +	const TInt KAddLength = 10;
  1.2278 +	CFbsBitmap* fbsBmp = NULL;
  1.2279 +
  1.2280 +	//Create and compress RAM bitmap
  1.2281 +	//The compression allows us to use the scanline buffer
  1.2282 +	fbsBmp = new (ELeave) CFbsBitmap;
  1.2283 +	CleanupStack::PushL(fbsBmp);
  1.2284 +	User::LeaveIfError(fbsBmp->Create(TSize(KWidth, KHeight), EColor64K));
  1.2285 +	User::LeaveIfError(fbsBmp->Compress());
  1.2286 +	TSize size = fbsBmp->SizeInPixels();
  1.2287 +
  1.2288 +	TUint32* slptr=NULL;
  1.2289 +	TPoint coord(0,0);
  1.2290 +	TLineScanningPosition lineScanPos(fbsBmp->DataAddress());
  1.2291 +	CFbsBitGcBitmap* srce = (CFbsBitGcBitmap*) fbsBmp; // CFbsBitmap
  1.2292 +	CBitwiseBitmap* bmp = srce->Address();
  1.2293 +
  1.2294 +	//Test GetScanLinePtr()
  1.2295 +	User::LeaveIfError(bmp->GetScanLinePtr(slptr, size.iWidth, coord, fbsBmp->DataAddress(), lineScanPos));
  1.2296 +
  1.2297 +	//Resize the RAM bitmap
  1.2298 +	//The scanline buffer will be reallocated
  1.2299 +	User::LeaveIfError(fbsBmp->Resize(TSize(KWidth + KAddLength, KHeight + KAddLength)));
  1.2300 +	size = fbsBmp->SizeInPixels();
  1.2301 +
  1.2302 +	slptr = NULL;
  1.2303 +	lineScanPos.iSrcDataPtr = (TUint8*)fbsBmp->DataAddress();
  1.2304 +	lineScanPos.iCursorPos = 0;
  1.2305 +	lineScanPos.iScanLineBuffer = 0;
  1.2306 +	srce = (CFbsBitGcBitmap*) fbsBmp; // CFbsBitmap
  1.2307 +	bmp = srce->Address();
  1.2308 +
  1.2309 +	//Test GetScanLinePtr()
  1.2310 +	User::LeaveIfError(bmp->GetScanLinePtr(slptr, size.iWidth, coord, fbsBmp->DataAddress(), lineScanPos));
  1.2311 +	//Destroy RAM bitmap internal data
  1.2312 +	fbsBmp->Reset();
  1.2313 +
  1.2314 +	//Load RAM compressed bitmap
  1.2315 +	//The RAM bitmap is bigger than the previous one, so
  1.2316 +	//the scanline buffer will be reallocated
  1.2317 +	User::LeaveIfError(fbsBmp->Load(BitmapFile[ERAMCFileType][E24BppBmpType], 0, EFalse, mbm_offset));
  1.2318 +	size = fbsBmp->SizeInPixels();
  1.2319 +	TEST(size.iWidth > (KWidth + KAddLength));
  1.2320 +
  1.2321 +	slptr = NULL;
  1.2322 +	lineScanPos.iSrcDataPtr = (TUint8*)fbsBmp->DataAddress();
  1.2323 +	lineScanPos.iCursorPos = 0;
  1.2324 +	lineScanPos.iScanLineBuffer = 0;
  1.2325 +	srce = (CFbsBitGcBitmap*) fbsBmp; // CFbsBitmap
  1.2326 +	bmp = srce->Address();
  1.2327 +
  1.2328 +	//Test GetScanLinePtr()
  1.2329 +	User::LeaveIfError(bmp->GetScanLinePtr(slptr, size.iWidth, coord, fbsBmp->DataAddress(), lineScanPos));
  1.2330 +
  1.2331 +	CleanupStack::PopAndDestroy(fbsBmp);
  1.2332 +	CleanupStack::PopAndDestroy();//cleanupItem
  1.2333 +	}
  1.2334 +
  1.2335 +/**
  1.2336 +  @SYMTestCaseID GRAPHICS-BITGDI-0062
  1.2337 + 
  1.2338 +  @SYMDEF INC070043            
  1.2339 +
  1.2340 +  @SYMTestCaseDesc DrawBitmap() assumes always that source is of type EColor16MA
  1.2341 +   
  1.2342 +  @SYMTestPriority High
  1.2343 +
  1.2344 +  @SYMTestStatus Implemented
  1.2345 +
  1.2346 +  @SYMTestActions Tests that drawing 16MU to 16MU uses the correct alpha values when required and not assume a transparent alpha
  1.2347 + 
  1.2348 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.2349 +*/
  1.2350 +void CTDefect::INC070043L()
  1.2351 +	{
  1.2352 +	const TInt KWidth = 100;
  1.2353 +	const TInt KHeight = 100;
  1.2354 +	const TInt KWidth11 = KWidth + 20;
  1.2355 +	const TInt KHeight11 = KHeight + 20;
  1.2356 +
  1.2357 +	//source bitmap
  1.2358 +	CFbsBitmap* fbsSourceBmp = new (ELeave) CFbsBitmap;
  1.2359 +	CleanupStack::PushL(fbsSourceBmp);
  1.2360 +	User::LeaveIfError(fbsSourceBmp->Create(TSize(KWidth, KHeight), EColor16MU));
  1.2361 +	fbsSourceBmp->SetSizeInTwips(TSize(KWidth, KHeight));
  1.2362 +
  1.2363 +	CFbsBitGc* theBitmapContextSrc = NULL;
  1.2364 +	CFbsBitmapDevice* theBitmapDeviceSrc = CFbsBitmapDevice::NewL(fbsSourceBmp);
  1.2365 +	CleanupStack::PushL(theBitmapDeviceSrc);
  1.2366 +	theBitmapDeviceSrc->CreateContext(theBitmapContextSrc);
  1.2367 +	CleanupStack::PushL(theBitmapContextSrc);
  1.2368 +	
  1.2369 +		//make a drawing
  1.2370 +	theBitmapContextSrc -> SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2371 +	theBitmapContextSrc -> SetPenColor(TRgb(0, 0, 255));
  1.2372 +	theBitmapContextSrc -> DrawRect(TRect(0, 0, KWidth, KHeight));
  1.2373 +
  1.2374 +	//destination bitmap
  1.2375 +	CFbsBitmap* fbsDestBmp = new (ELeave) CFbsBitmap;
  1.2376 +	CleanupStack::PushL(fbsDestBmp);
  1.2377 +	User::LeaveIfError(fbsDestBmp->Create(TSize(KWidth, KHeight), EColor16MU));
  1.2378 +	fbsDestBmp->SetSizeInTwips(TSize(KWidth, KHeight));
  1.2379 +
  1.2380 +	CFbsBitGc* theBitmapContextDest = NULL;
  1.2381 +	CFbsBitmapDevice* theBitmapDeviceDest = CFbsBitmapDevice::NewL(fbsDestBmp);
  1.2382 +	CleanupStack::PushL(theBitmapDeviceDest);
  1.2383 +	theBitmapDeviceDest->CreateContext(theBitmapContextDest);
  1.2384 +	CleanupStack::PushL(theBitmapContextDest);
  1.2385 +
  1.2386 +	//bigger destination bitmap
  1.2387 +	CFbsBitmap* fbsDestBmp1 = new (ELeave) CFbsBitmap;
  1.2388 +	CleanupStack::PushL(fbsDestBmp1);
  1.2389 +	User::LeaveIfError(fbsDestBmp1->Create(TSize(KWidth11, KHeight11), EColor16MU));
  1.2390 +	fbsDestBmp1->SetSizeInTwips(TSize(KWidth11, KHeight11));
  1.2391 +
  1.2392 +	CFbsBitGc* theBitmapContextDest1 = NULL;
  1.2393 +	CFbsBitmapDevice* theBitmapDeviceDest1 = CFbsBitmapDevice::NewL(fbsDestBmp1);
  1.2394 +	CleanupStack::PushL(theBitmapDeviceDest1);
  1.2395 +	theBitmapDeviceDest1->CreateContext(theBitmapContextDest1);
  1.2396 +	CleanupStack::PushL(theBitmapContextDest1);
  1.2397 +
  1.2398 +	
  1.2399 +	//make a drawing
  1.2400 +	INFO_PRINTF1(_L("Drawing from 16MU to 16MU memory bitmap"));
  1.2401 +	theBitmapContextDest-> SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2402 +	theBitmapContextDest -> SetPenColor(TRgb(0, 255, 0));
  1.2403 +	theBitmapContextDest -> DrawRect(TRect(0, 0, KWidth, KHeight));
  1.2404 +	
  1.2405 +	
  1.2406 +	theBitmapContextDest->DrawBitmap(TPoint(0, 0), fbsSourceBmp);
  1.2407 +
  1.2408 +	CFbsBitGcBitmap* bmp1 = (CFbsBitGcBitmap*)fbsDestBmp;
  1.2409 +	CFbsBitGcBitmap* bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp;
  1.2410 +	CFbsBitGcBitmap* bmp[] = {bmp1, bmp2};
  1.2411 +	const TInt bmpArrSize = sizeof(bmp) / sizeof(bmp[0]);
  1.2412 +	::CompareBitmaps<bmpArrSize, 1000>(&bmp, EColor16MU, 0, 1, this);
  1.2413 +
  1.2414 +//	load from the file
  1.2415 +	CFbsBitmap* fbsSourceBmp1 = new (ELeave) CFbsBitmap;
  1.2416 +	CleanupStack::PushL(fbsSourceBmp1);
  1.2417 +	TInt err = fbsSourceBmp1->Load(_L("z:\\system\\data\\DrawBitmap16MU.MBM"));
  1.2418 +	fbsSourceBmp1->SetSizeInTwips(TSize(KWidth, KHeight));
  1.2419 +	
  1.2420 +	//with compression
  1.2421 +	CFbsBitmap* fbsSourceBmp2 = new (ELeave) CFbsBitmap;
  1.2422 +	CleanupStack::PushL(fbsSourceBmp2);
  1.2423 +	err = fbsSourceBmp2->Load(_L("z:\\system\\data\\DrawBitmapComp16MU.MBM"));
  1.2424 +	fbsSourceBmp2->SetSizeInTwips(TSize(KWidth, KHeight));
  1.2425 +	
  1.2426 +	INFO_PRINTF1(_L("Drawing from 16MU to 16MU bitmap"));
  1.2427 +	theBitmapContextDest->DrawBitmap(TPoint(0, 0), fbsSourceBmp1);
  1.2428 +	bmp1 = (CFbsBitGcBitmap*)fbsDestBmp;
  1.2429 +	bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp1;
  1.2430 +	CFbsBitGcBitmap* bmp11[] = {bmp1, bmp2};
  1.2431 +	const TInt bmpArrSize1 = sizeof(bmp11) / sizeof(bmp11[0]);
  1.2432 +	::CompareBitmaps<bmpArrSize1, 1000>(&bmp11, EColor16MU, 0, 1, this);
  1.2433 +	
  1.2434 +//	drawing to the bigger destination
  1.2435 +	INFO_PRINTF1(_L("Drawing from 16MU to 16MU bitmap, where source and distination bitmaps have a different size"));
  1.2436 +	theBitmapContextDest1-> SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2437 +	theBitmapContextDest1 -> SetPenColor(TRgb(0, 255, 0));
  1.2438 +	theBitmapContextDest1 -> DrawRect(TRect(0, 0, KWidth11, KHeight11));
  1.2439 +	theBitmapContextDest1->DrawBitmap(TPoint(0, 0), fbsSourceBmp1);
  1.2440 +	bmp1 = (CFbsBitGcBitmap*)fbsDestBmp1;
  1.2441 +	bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp1;
  1.2442 +	CFbsBitGcBitmap* bmp22[] = {bmp1, bmp2};
  1.2443 +	const TInt bmpArrSize2 = sizeof(bmp22) / sizeof(bmp22[0]);
  1.2444 +	::CompareBitmaps<bmpArrSize2, 1000>(&bmp22, EColor16MU, 0, 1, this);
  1.2445 +	
  1.2446 +	// drawing to the compressed bitmap	
  1.2447 +	INFO_PRINTF1(_L("Drawing from 16MU to 16MU bitmap, where source bitmap is compressed"));
  1.2448 +	theBitmapContextDest -> DrawRect(TRect(0, 0, KWidth, KHeight));
  1.2449 +	theBitmapContextDest->DrawBitmap(TPoint(0, 0), fbsSourceBmp2);
  1.2450 +	bmp1 = (CFbsBitGcBitmap*)fbsDestBmp;
  1.2451 +	bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp2;
  1.2452 +	CFbsBitGcBitmap* bmp33[] = {bmp1, bmp2};
  1.2453 +	const TInt bmpArrSize3 = sizeof(bmp33) / sizeof(bmp33[0]);
  1.2454 +	::CompareBitmaps<bmpArrSize3, 1000>(&bmp33, EColor16MU, 0, 1, this);
  1.2455 +	
  1.2456 +	
  1.2457 +	CleanupStack::PopAndDestroy(fbsSourceBmp2);
  1.2458 +	CleanupStack::PopAndDestroy(fbsSourceBmp1);
  1.2459 +
  1.2460 +	CleanupStack::PopAndDestroy(theBitmapContextDest1);
  1.2461 +	CleanupStack::PopAndDestroy(theBitmapDeviceDest1);
  1.2462 +	CleanupStack::PopAndDestroy(fbsDestBmp1);
  1.2463 +
  1.2464 +	CleanupStack::PopAndDestroy(theBitmapContextDest);
  1.2465 +	CleanupStack::PopAndDestroy(theBitmapDeviceDest);
  1.2466 +	CleanupStack::PopAndDestroy(fbsDestBmp);
  1.2467 +
  1.2468 +	CleanupStack::PopAndDestroy(theBitmapContextSrc);
  1.2469 +	CleanupStack::PopAndDestroy(theBitmapDeviceSrc);
  1.2470 +	CleanupStack::PopAndDestroy(fbsSourceBmp);
  1.2471 +	}
  1.2472 +	
  1.2473 +	
  1.2474 +/**
  1.2475 +  @SYMTestCaseID GRAPHICS-BITGDI-0063
  1.2476 + 
  1.2477 +  @SYMDEF             
  1.2478 +
  1.2479 +  @SYMTestCaseDesc The behaviour of SwapWidthAndHeight() is different for both Create()
  1.2480 +					and Load() functions. This might be a defect but needs no bother unless 
  1.2481 +					a solution is requested by clients.
  1.2482 +
  1.2483 +					Lets suppose we have a bitmap of size (40, 12) and a CFbsBitmap object 
  1.2484 +					contructed to hold it. When we use Create() and EColor16 for color depth 
  1.2485 +					as in the following:
  1.2486 +							iBitmap = new (ELeave) CFbsBitmap;
  1.2487 +							iBitmap->Create(iSize, EColor16);
  1.2488 +					the size of the bitmap internally will be 240bytes for EColor16. THE SIZE WILL
  1.2489 +					BE DIFFERENT FOR EACH COLOR DEPTH.
  1.2490 +
  1.2491 +					When applying SwapWidthAndHeight() the function finds that the size available
  1.2492 +					(240Bytes) is less than the one needed after the swap (360Byes). This applies 
  1.2493 +					to EColor16, EGray16, EGray4, EGray2 colors modes always and to the rest when 
  1.2494 +					the dimenssions of the bitmap are irrelative (width too much bigger than height).
  1.2495 +					Before the fix is added SwapWidthAndHeight() used to leave without applying the 
  1.2496 +					swapping. The fix however reallocates memory to fit the new swapped bitmap.
  1.2497 +
  1.2498 +					Now if we use Load() without Create() as in the following:
  1.2499 +							iBitmap = new (ELeave) CFbsBitmap;
  1.2500 +							iBitmap->Load(KBmp16_2, 0);
  1.2501 +					the color depth of the system that best matches the bitmap's will be used. In 
  1.2502 +					our case here it is EColor64K.So the size of the bitmap will be 960Bytes.Changing 
  1.2503 +					the color depth via SetDisplayMode(...) will limit the modification to color 
  1.2504 +					depths that are less than the one used for the bitmap, ie EColor64K. ONLY THE 
  1.2505 +					COLOR DEPTH WILL CHANGE BUT THE SIZE OF THE BITMAP WILL NOT BE RECALCULATED. 
  1.2506 +					This means that the size of the new swapped bitmap will always be less than the 
  1.2507 +					original one with 960Bytes. That why SwapWidthAndHeight() will always pass with 
  1.2508 +					Load() function, unlike using Create() which recalulates the new size.
  1.2509 +   
  1.2510 +  @SYMTestPriority High
  1.2511 +
  1.2512 +  @SYMTestStatus Implemented
  1.2513 +
  1.2514 +  @SYMTestActions Creates bitmaps in various colour modes and blits 
  1.2515 + 
  1.2516 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.2517 +*/
  1.2518 +void CTDefect::BitmapsSwappingTest()
  1.2519 +	{
  1.2520 +	CreateScreenDeviceL();	
  1.2521 +	// All color depths are to be tested. Before the fix EColor16, EGray16, EGray4, EGray2 
  1.2522 +	// used to fail the swapping.
  1.2523 +	TDisplayMode testMode[] =  {EColor4K, EColor64K, EColor16M, EColor16MU, EColor256, EGray256,
  1.2524 +								/**/ EColor16, EGray16, EGray4, EGray2 /**/};
  1.2525 +
  1.2526 +	for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
  1.2527 +		{
  1.2528 +		DeleteBitmap();
  1.2529 +		iBitmap = new (ELeave) CFbsBitmap;
  1.2530 +		User::LeaveIfError(iBitmap->Create(iSize, testMode[ii]));
  1.2531 +
  1.2532 +		iGc->Clear();
  1.2533 +		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2534 +		iGc->SetBrushColor(TRgb(0x00, 0x00, 0x00));
  1.2535 +		// Apply the swap for the created bitmap with the specified color depth
  1.2536 +		User::LeaveIfError(iBitmap->SwapWidthAndHeight());
  1.2537 +		iGc->BitBlt(TPoint(0, 0), iBitmap);
  1.2538 +		iDevice->Update();
  1.2539 +		}
  1.2540 +	}
  1.2541 +	
  1.2542 +/**
  1.2543 +  @SYMTestCaseID GRAPHICS-BITGDI-0064
  1.2544 + 
  1.2545 +  @SYMDEF INC093055            
  1.2546 +
  1.2547 +  @SYMTestCaseDesc BitGdi causes buffer overflow in WServ
  1.2548 +   
  1.2549 +  @SYMTestPriority High
  1.2550 +
  1.2551 +  @SYMTestStatus Implemented
  1.2552 +
  1.2553 +  @SYMTestActions tests the rotation of the screen and bitbltmasked. 
  1.2554 + 
  1.2555 +  @SYMTestExpectedResults Test should perform graphics operations succesfully and no overflow should occur. 
  1.2556 +*/	
  1.2557 +
  1.2558 +void CTDefect::INC093055L()
  1.2559 +	{
  1.2560 +	TInt si;
  1.2561 +	TInt sj;
  1.2562 +	TInt err;
  1.2563 +	//Create the screen device
  1.2564 +	err = CreateScreenDeviceL(EColor64K);
  1.2565 +	if(err == KErrNotSupported)
  1.2566 +		{
  1.2567 +		return;
  1.2568 +		}
  1.2569 +	TSize bmpSize(700,700);
  1.2570 +	User::LeaveIfError(err);
  1.2571 +	//Create source bitmap
  1.2572 +	CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap;
  1.2573 +	CleanupStack::PushL(srcBmp);
  1.2574 +	User::LeaveIfError(srcBmp->Create(bmpSize, EColor16M));
  1.2575 +	TBitmapUtil bmpUtil1(srcBmp);
  1.2576 +	bmpUtil1.Begin(TPoint(0, 0));
  1.2577 +	for(si=0;si<bmpSize.iWidth; ++si)
  1.2578 +		{
  1.2579 +		for(sj=0; sj < bmpSize.iHeight; ++sj)
  1.2580 +			{
  1.2581 +			bmpUtil1.SetPos(TPoint(si, sj));
  1.2582 +			bmpUtil1.SetPixel(0xffff00);
  1.2583 +			}
  1.2584 +		}
  1.2585 +	bmpUtil1.End();
  1.2586 +	//Create mask bitmap
  1.2587 +	CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap;
  1.2588 +	CleanupStack::PushL(maskBmp);
  1.2589 +	User::LeaveIfError(maskBmp->Create(bmpSize, EGray256));
  1.2590 +	TBitmapUtil bmpUtil2(maskBmp);
  1.2591 +	bmpUtil2.Begin(TPoint(0, 0));
  1.2592 +	for(si=0;si<bmpSize.iWidth; ++si)
  1.2593 +		{
  1.2594 +		for(sj=0; sj < bmpSize.iHeight; ++sj)
  1.2595 +			{
  1.2596 +			bmpUtil2.SetPos(TPoint(si, sj));
  1.2597 +			bmpUtil2.SetPixel(0xff00ff);
  1.2598 +			}
  1.2599 +		}
  1.2600 +	bmpUtil2.End();
  1.2601 +	CFbsDrawDevice *pDev;
  1.2602 +
  1.2603 +	pDev = CFbsDrawDevice::NewScreenDeviceL(0, EColor64K);
  1.2604 +	CleanupStack::PushL(pDev);
  1.2605 +	pDev->InitScreen();
  1.2606 +	TRect rect(TPoint(20,20), srcBmp->SizeInPixels());
  1.2607 +	iGc->Clear();
  1.2608 +	iGc->SetClippingRect(rect);
  1.2609 +	iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, maskBmp, ETrue);
  1.2610 +	iGc->CancelClippingRect();
  1.2611 +	iDevice->Update();	
  1.2612 +	User::After(2000000);
  1.2613 +	pDev->SetOrientation(CFbsDrawDevice::EOrientationRotated90);
  1.2614 +	iGc->Clear();
  1.2615 +	iGc->SetClippingRect(rect);
  1.2616 +	iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, srcBmp, ETrue);
  1.2617 +	iGc->CancelClippingRect();
  1.2618 +	iDevice->Update();
  1.2619 +	User::After(2000000);
  1.2620 +	pDev->SetOrientation(CFbsDrawDevice::EOrientationRotated180);
  1.2621 +	iGc->Clear();
  1.2622 +	iGc->SetClippingRect(rect);
  1.2623 +	iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, maskBmp, ETrue);
  1.2624 +	iGc->CancelClippingRect();
  1.2625 +	iDevice->Update();
  1.2626 +	User::After(2000000);
  1.2627 +	pDev->SetOrientation(CFbsDrawDevice::EOrientationRotated270);	
  1.2628 +	iGc->Clear();
  1.2629 +	iGc->SetClippingRect(rect);
  1.2630 +	iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, maskBmp, ETrue);
  1.2631 +	iGc->CancelClippingRect();
  1.2632 +	iDevice->Update();
  1.2633 +	User::After(2000000);
  1.2634 +	pDev->SetOrientation(CFbsDrawDevice::EOrientationNormal);
  1.2635 +	CleanupStack::PopAndDestroy(pDev);
  1.2636 +	CleanupStack::PopAndDestroy(maskBmp);
  1.2637 +	CleanupStack::PopAndDestroy(srcBmp);
  1.2638 +	}
  1.2639 +
  1.2640 +/**
  1.2641 +  @SYMTestCaseID GRAPHICS-BITGDI-0016
  1.2642 + 
  1.2643 +  @SYMDEF PDEF103809            
  1.2644 +
  1.2645 +  @SYMTestCaseDesc Test externalize/internalize of CFbsBitGc
  1.2646 +   
  1.2647 +  @SYMTestPriority Medium
  1.2648 +
  1.2649 +  @SYMTestStatus Implemented
  1.2650 +
  1.2651 +  @SYMTestActions Create CFbsBitGc but do not associate a font with it - externalize it - internalize it - check whether font has been created
  1.2652 +@SYMTestExpectedResults no font created
  1.2653 + 
  1.2654 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.2655 +*/
  1.2656 +
  1.2657 +void CTDefect::PDEF103809L()
  1.2658 +	{
  1.2659 +	RFbsSession::Connect();
  1.2660 +
  1.2661 +	CFbsScreenDevice* scr=NULL;		//To stop a warning
  1.2662 +	TDisplayMode mode[] = {EColor64K, EColor16MA, EColor16MAP};
  1.2663 +	TInt ii;
  1.2664 +	TInt err = KErrNotSupported;
  1.2665 +	for(ii=0;(ii<TInt(sizeof(mode)/sizeof(mode[0]))) && (err == KErrNotSupported);++ii)
  1.2666 +		{
  1.2667 +		TRAP(err,scr=CFbsScreenDevice::NewL(KDefaultScreenNo,mode[ii]));
  1.2668 +		}
  1.2669 +	if (err!=KErrNone)
  1.2670 +		{
  1.2671 +		if (err==KErrNotSupported)
  1.2672 +			{
  1.2673 +			_LIT(KLog,"Hardware doesn't support mode Color64K, Color16MA or EColor16MAP");
  1.2674 +			INFO_PRINTF1(KLog);
  1.2675 +			}
  1.2676 +		else
  1.2677 +			{
  1.2678 +			_LIT(KLog,"Failed to created Screen Device %S, err=%d");
  1.2679 +			INFO_PRINTF3(KLog,&ColorModeName(mode[ii]),err);
  1.2680 +			}
  1.2681 +		User::Leave(err);
  1.2682 +		}
  1.2683 +	_LIT(KLog,"Created Screen Device with mode %S");
  1.2684 +	INFO_PRINTF2(KLog,&ColorModeName(mode[ii]));
  1.2685 +	scr->SetAutoUpdate(ETrue);
  1.2686 +	CleanupStack::PushL(scr);
  1.2687 +
  1.2688 +	CFbsBitGc* gc = NULL;
  1.2689 +	User::LeaveIfError(scr->CreateContext(gc));
  1.2690 +	CleanupStack::PushL(gc);
  1.2691 +
  1.2692 +	// before 
  1.2693 +	TBool before = gc->IsFontUsed();
  1.2694 +	INFO_PRINTF2(_L("before: %d"),before);
  1.2695 +	TEST(before==EFalse); 
  1.2696 +	
  1.2697 +	// create buffer for save/restore
  1.2698 +	CBufFlat* buf = CBufFlat::NewL(256);
  1.2699 +	CleanupStack::PushL(buf);
  1.2700 +	
  1.2701 +	// save and then restore
  1.2702 +	RBufWriteStream ws(*buf,0);
  1.2703 +	gc->ExternalizeL(ws);
  1.2704 +	ws.Close();
  1.2705 +	RBufReadStream rs(*buf,0);	
  1.2706 +	gc->InternalizeL(rs);
  1.2707 +	rs.Close();
  1.2708 +
  1.2709 +	// after
  1.2710 +	TBool after = gc->IsFontUsed();
  1.2711 +	INFO_PRINTF2(_L("after: %d"),after);
  1.2712 +	TEST(after==EFalse);
  1.2713 +
  1.2714 +	CleanupStack::PopAndDestroy(3, scr);
  1.2715 +	RFbsSession::Disconnect();
  1.2716 +	}
  1.2717 +
  1.2718 +//Method Initialising src and mask bitmap for DEF104856, DEF108338, DEF103736, PDEF108863 and PDEF110934
  1.2719 +void CTDefect::InitialiseSourceAndMaskLC(CFbsBitmap*& aSrc, TDisplayMode aSrcDispMode, CFbsBitmap*& aMask, TDisplayMode aMaskDispMode, TSize aPicSize, TInt aNumMaskBars, TInt aMaskBarHeight, TSize* aMaskSize)
  1.2720 +	{
  1.2721 +	TInt err;
  1.2722 +    // create src bitmap object
  1.2723 +	aSrc = new(ELeave) CFbsBitmap;
  1.2724 +	CleanupStack::PushL(aSrc);
  1.2725 +	err = aSrc->Create(aPicSize, aSrcDispMode);
  1.2726 +
  1.2727 +	// create mask bitmap object
  1.2728 +	aMask = new(ELeave) CFbsBitmap;
  1.2729 +	CleanupStack::PushL(aMask);
  1.2730 +	if(aMaskSize == NULL )
  1.2731 +		{
  1.2732 +		err = aMask->Create(aPicSize, aMaskDispMode);
  1.2733 +		}
  1.2734 +	else
  1.2735 +		{
  1.2736 +		err = aMask->Create(*aMaskSize, aMaskDispMode);
  1.2737 +		}
  1.2738 +	TEST(err == KErrNone);
  1.2739 +	
  1.2740 +	// initialise source
  1.2741 +	TBitmapUtil srcUtil(aSrc);
  1.2742 +	srcUtil.Begin(TPoint(0, 0));
  1.2743 +	for(TInt y = 0; y < aPicSize.iHeight; ++y)
  1.2744 +		{
  1.2745 +		for(TInt x = 0; x < aPicSize.iWidth; ++x)
  1.2746 +			{
  1.2747 +			srcUtil.SetPos(TPoint(x, y));
  1.2748 +			srcUtil.SetPixel(Color(KRgbRed, aSrcDispMode));
  1.2749 +			}
  1.2750 +		}
  1.2751 +	srcUtil.End();
  1.2752 +	err = aSrc->Compress();
  1.2753 +	TEST(err == KErrNone);
  1.2754 +
  1.2755 +    // initialise mask
  1.2756 +    TBitmapUtil maskUtil(aMask);
  1.2757 +    maskUtil.Begin(TPoint(0, 0));
  1.2758 +	TUint32 maskColor;
  1.2759 +    if(aMaskSize != NULL)
  1.2760 +	    {
  1.2761 +	    aPicSize = *aMaskSize;
  1.2762 +	    }
  1.2763 +	for(TInt y = 0; y < aPicSize.iHeight; ++y)
  1.2764 +		{
  1.2765 +		for(TInt x = 0; x < aPicSize.iWidth; ++x)
  1.2766 +			{
  1.2767 +			maskUtil.SetPos(TPoint(x, y));
  1.2768 + 			if (((x / (aPicSize.iWidth / aNumMaskBars)) & 1) ^ ((y / aMaskBarHeight) & 1))
  1.2769 + 				{
  1.2770 +				maskColor = Color(KRgbWhite, aMaskDispMode);
  1.2771 + 				}
  1.2772 + 			else
  1.2773 + 				{
  1.2774 +				maskColor = Color(KRgbBlack, aMaskDispMode);
  1.2775 + 				}
  1.2776 +			maskUtil.SetPixel(maskColor);
  1.2777 +			}
  1.2778 +		}
  1.2779 +	maskUtil.End();
  1.2780 +	err = aMask->Compress();
  1.2781 +	TEST(err == KErrNone);
  1.2782 +	}
  1.2783 +
  1.2784 +/**
  1.2785 +Method to check images drawn for TestDoDrawBitmapMaskedL() and TestDoBitBltMaskedL() against expected images drawn.
  1.2786 +This method will start checking from point (0,0) of the device drawn to.
  1.2787 +@param aDevice Device drawn to
  1.2788 +@param aWidth Width of area to check
  1.2789 +@param aHeight Height of area to check
  1.2790 +@param aPattern Pattern to determine which colour to start checking against
  1.2791 +@param aBarHeight Expected height of alternating bars in pixels
  1.2792 +*/
  1.2793 +void CTDefect::CheckResults(CFbsDevice* aDevice, TInt aWidth, TInt aHeight, TInt aPattern, TInt aBarHeight)
  1.2794 +	{
  1.2795 +	TRgb color;
  1.2796 +	TRgb checkColor = aPattern == 1? KRgbGreen : KRgbRed;
  1.2797 +	
  1.2798 +	for(TInt y = 0; y < aHeight; ++y)
  1.2799 +		{
  1.2800 +		for(TInt x = 0; x < aWidth; ++x)
  1.2801 +			{
  1.2802 +			aDevice->GetPixel(color, TPoint(x, y));
  1.2803 +			if(color != checkColor)
  1.2804 +				{
  1.2805 +				TEST(EFalse);
  1.2806 +				return;
  1.2807 +				}
  1.2808 +			}
  1.2809 +		if (y % aBarHeight == aBarHeight - 1)
  1.2810 +			{
  1.2811 +			checkColor = checkColor == KRgbGreen ? KRgbRed : KRgbGreen;
  1.2812 +			}
  1.2813 +		}
  1.2814 +	}
  1.2815 +
  1.2816 +void CTDefect::TestDoBltMaskedL(TDisplayMode aSrcDispMode, TDisplayMode aMaskDispMode, TDisplayMode aDeviceDispMode, TSize aPicSize, TBool aUseScreenDevice, TBool aInvertMask, TSize* aMaskSize)
  1.2817 +	{
  1.2818 +	// create and initialise source and mask bitmap
  1.2819 +	CFbsBitmap* src = NULL;
  1.2820 +	CFbsBitmap* mask = NULL;
  1.2821 +	// Number of vertical changes to mask colour in a row
  1.2822 +	const TInt KNumMaskBars = 4;
  1.2823 +	// Height of each bar in pixels
  1.2824 +	const TInt KMaskBarHeight = 1;
  1.2825 +
  1.2826 +	InitialiseSourceAndMaskLC(src, aSrcDispMode, mask, aMaskDispMode, aPicSize, KNumMaskBars, KMaskBarHeight, aMaskSize);
  1.2827 +	TInt err;
  1.2828 +	CFbsDevice* fbsDevice = NULL;
  1.2829 +	if (aUseScreenDevice)
  1.2830 +		{
  1.2831 +		// create screen device
  1.2832 +		TRAPD(err, fbsDevice = CFbsScreenDevice::NewL(KNullDesC, aDeviceDispMode));
  1.2833 +		if (err == KErrNotSupported)
  1.2834 +			{
  1.2835 +			INFO_PRINTF1(_L("Display mode is not supported by scdv"));
  1.2836 +			CleanupStack::PopAndDestroy(2, src);
  1.2837 +			return;
  1.2838 +			}
  1.2839 +		}
  1.2840 +	else
  1.2841 +		{
  1.2842 +	    // create device bitmap
  1.2843 +		CFbsBitmap* deviceBitmap = new(ELeave) CFbsBitmap;
  1.2844 +		err = deviceBitmap->Create(aPicSize, aDeviceDispMode);
  1.2845 +		TEST(err == KErrNone);
  1.2846 +		CleanupStack::PushL(deviceBitmap);
  1.2847 +		// create bitmap device
  1.2848 +		fbsDevice = CFbsBitmapDevice::NewL(deviceBitmap);
  1.2849 +		}
  1.2850 +	CleanupStack::PushL(fbsDevice);
  1.2851 +	// create graphics context
  1.2852 +	CFbsBitGc* gcContext = NULL;
  1.2853 +	err = fbsDevice->CreateContext(gcContext);
  1.2854 +	TEST(err == KErrNone);
  1.2855 +	TEST(gcContext != NULL);
  1.2856 +	CleanupStack::PushL(gcContext);
  1.2857 +	gcContext->SetBrushColor(KRgbGreen);
  1.2858 +	
  1.2859 +	TInt barwidth = aPicSize.iWidth/KNumMaskBars;
  1.2860 +	TSize barSize(barwidth, aPicSize.iHeight);
  1.2861 +	TInt currentPattern = aInvertMask ? 0 : 1;
  1.2862 +	for(TInt x = 0; x < aPicSize.iWidth; x += barwidth)
  1.2863 +		{
  1.2864 +		gcContext->Clear();
  1.2865 +		gcContext->BitBltMasked(TPoint(0, 0), src, TRect(TPoint(x, 0), barSize), mask, aInvertMask);
  1.2866 +		CheckResults(fbsDevice, barwidth, aPicSize.iHeight, currentPattern, KMaskBarHeight);
  1.2867 +		currentPattern ^= 1;
  1.2868 +		}
  1.2869 +	if (aUseScreenDevice)
  1.2870 +		{
  1.2871 +		CleanupStack::PopAndDestroy(4, src); //  gcContext, fbsDevice, mask, src
  1.2872 +		}
  1.2873 +	else
  1.2874 +		{
  1.2875 +		CleanupStack::PopAndDestroy(5, src); // gcContext, fbsDevice, deviceBitmap, mask, src	
  1.2876 +		}
  1.2877 +	}
  1.2878 +
  1.2879 +/**
  1.2880 +@SYMTestCaseID		GRAPHICS-BITGDI-0095
  1.2881 +
  1.2882 +@SYMDEF             PDEF110934
  1.2883 +
  1.2884 +@SYMTestCaseDesc    Test that the bitmap is drawn correctly by testing
  1.2885 +					mask size less or greater than the bitmap size. Three optimized calls tested for this
  1.2886 +					CFbsBitGc::DoBitBltMaskedNonFlicker
  1.2887 +					CFbsBitGc::DoBitBltMaskedFlicker
  1.2888 +					CFbsBitGc::DoBitBltAlpha
  1.2889 +
  1.2890 +@SYMTestPriority    High
  1.2891 +
  1.2892 +@SYMTestStatus      Implemented
  1.2893 +
  1.2894 +@SYMTestActions     Create compressed EColor64K bitmap and EGray2 mask and draw bitmap calling
  1.2895 +					CFbsBitGc::BitBltMasked with a screen device. The drawing is done in a loop
  1.2896 +					to simulate the scrolling effect as in a browser.
  1.2897 +
  1.2898 +@SYMTestExpectedResults All the stripes should pass the integrity check.
  1.2899 +**/
  1.2900 +void CTDefect::TestDoBitBltMaskedSizeL()
  1.2901 +	{
  1.2902 +	TSize maskSize(96,48);
  1.2903 +
  1.2904 +	// Tests DoBitBltMaskedFlicker for which mask height is less than the source bitmap height
  1.2905 +	TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize);
  1.2906 +	
  1.2907 +	if(CFbsDrawDevice::DisplayMode16M() != ENone)
  1.2908 +		{
  1.2909 +		// Tests DoBitBltMaskedNonFlicker for which mask height is less than the source bitmap height
  1.2910 +		TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), ETrue, EFalse, &maskSize);
  1.2911 +		}
  1.2912 +	
  1.2913 +	// Tests DoBitBltAlpha for which mask height is less than the source bitmap height
  1.2914 +	TestDoBltMaskedL(EColor16MU, EGray256, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize);
  1.2915 +	
  1.2916 +	//Change the mask height and check the optimization for maximum height of the source bitmap
  1.2917 +	maskSize.SetSize(96,144);
  1.2918 +	// Tests DoBitBltMaskedFlicker for which mask height is greater than the source bitmap height
  1.2919 +	TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize);
  1.2920 +
  1.2921 +	if(CFbsDrawDevice::DisplayMode16M() != ENone)
  1.2922 +		{
  1.2923 +		// Tests DoBitBltMaskedNonFlicker for which mask height is greater than the source bitmap height
  1.2924 +		TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), ETrue, EFalse, &maskSize);
  1.2925 +		}
  1.2926 +	
  1.2927 +	// Tests DoBitBltAlpha for which mask height is greater than the source bitmap height
  1.2928 +	TestDoBltMaskedL(EColor16MU, EGray256, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize);
  1.2929 +	}
  1.2930 +
  1.2931 +TUint32 CTDefect::Color(const TRgb& aColor, const TDisplayMode& aDisplayMode)
  1.2932 +	{
  1.2933 +	switch (aDisplayMode)
  1.2934 +		{
  1.2935 +	case EGray2:
  1.2936 +		return aColor.Gray2();
  1.2937 +	case EGray4:
  1.2938 +		return aColor.Gray4();
  1.2939 +	case EGray16:
  1.2940 +		return aColor.Gray16();
  1.2941 +	case EGray256:
  1.2942 +		return aColor.Gray256();
  1.2943 +	case EColor16:
  1.2944 +		return aColor.Color16();
  1.2945 +	case EColor256:
  1.2946 +		return aColor.Color256();
  1.2947 +	case EColor64K:
  1.2948 +		return aColor.Color64K();
  1.2949 +	case EColor16M:
  1.2950 +		return aColor.Color16M();
  1.2951 +	case EColor16MU:
  1.2952 +		return aColor.Color16MU();
  1.2953 +	case EColor16MA:
  1.2954 +		return aColor.Color16MA();
  1.2955 +	case EColor16MAP:
  1.2956 +		return aColor.Color16MAP();
  1.2957 +	default:
  1.2958 +		__ASSERT_DEBUG(EFalse, User::Invariant());
  1.2959 +		return 0;
  1.2960 +		}
  1.2961 +	}
  1.2962 +
  1.2963 +/**
  1.2964 +  @SYMTestCaseID GRAPHICS-BITGDI-0102
  1.2965 + 
  1.2966 +  @SYMDEF ExternalizeInternalizeCFbsBitGCExtraData          
  1.2967 +
  1.2968 +  @SYMTestCaseDesc Test externalize/internalize of shadow color in CFbsBitGc
  1.2969 +   
  1.2970 +  @SYMTestPriority Medium
  1.2971 +
  1.2972 +  @SYMTestStatus Implemented
  1.2973 +
  1.2974 +  @SYMTestActions Create CFbsBitGc and set the shadow color by calling SetShadowColor(). 
  1.2975 +   Now - externalize it - internalize it - check the shadow color value matches the one that was set
  1.2976 +   before externalize/internalize.
  1.2977 +   
  1.2978 +@SYMTestExpectedResults Shadow color value should be same after externalize/internalize.
  1.2979 + 
  1.2980 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.2981 +*/
  1.2982 +
  1.2983 +void CTDefect::ExternalizeInternalizeCFbsBitGCExtraData()
  1.2984 +	{
  1.2985 +	RFbsSession::Connect();
  1.2986 +
  1.2987 +	TInt err;
  1.2988 +	err = CreateScreenDeviceL(EColor64K);
  1.2989 +	if (err == KErrNotSupported)
  1.2990 +		err = CreateScreenDeviceL(EColor16MA);
  1.2991 +	if (err == KErrNotSupported)
  1.2992 +		err = CreateScreenDeviceL(EColor16MAP);
  1.2993 +	if (err == KErrNotSupported)
  1.2994 +		return;
  1.2995 +	User::LeaveIfError(err);
  1.2996 +	_LIT(KLog1,"Created %S Screen Device");
  1.2997 +	INFO_PRINTF2(KLog1,&ColorModeName(iDevice->DisplayMode()));
  1.2998 +	iDevice->SetAutoUpdate(ETrue);
  1.2999 +
  1.3000 +	CFbsBitGc* gc = NULL;
  1.3001 +	User::LeaveIfError(iDevice->CreateContext(gc));
  1.3002 +	CleanupStack::PushL(gc);
  1.3003 +
  1.3004 +	// before 
  1.3005 +	const TRgb color = TRgb(10,20,30);
  1.3006 +	gc->SetShadowColor(color);
  1.3007 +
  1.3008 +	// create buffer for save/restore
  1.3009 +	CBufFlat* buf = CBufFlat::NewL(256);
  1.3010 +	CleanupStack::PushL(buf);
  1.3011 +	
  1.3012 +	// save and then restore
  1.3013 +	RBufWriteStream ws(*buf,0);
  1.3014 +	gc->ExternalizeL(ws);
  1.3015 +	ws.Close();
  1.3016 +	gc->SetShadowColor(TRgb(0,0,0));
  1.3017 +	RBufReadStream rs(*buf,0);	
  1.3018 +	gc->InternalizeL(rs);
  1.3019 +
  1.3020 +	// after
  1.3021 +	TRgb shadowColor;
  1.3022 +	gc->GetShadowColor(shadowColor);
  1.3023 +	TEST(color == shadowColor);
  1.3024 +	rs.Close();
  1.3025 +
  1.3026 +	CleanupStack::PopAndDestroy(2,gc);
  1.3027 +	RFbsSession::Disconnect();
  1.3028 +	}
  1.3029 +
  1.3030 +/**
  1.3031 +  @SYMTestCaseID GRAPHICS-BITGDI-0107
  1.3032 + 
  1.3033 +  @SYMDEF DEF126160 Clipped scaled-down bitmaps drawn incorrectly using CFbsBitmap::DrawBitmap()          
  1.3034 +
  1.3035 +  @SYMTestCaseDesc Test bitmap scaling when drawn with a clip rect applied.
  1.3036 +   
  1.3037 +  @SYMTestPriority High
  1.3038 +
  1.3039 +  @SYMTestStatus Implemented
  1.3040 +
  1.3041 +  @SYMTestActions - Create a CFbsBitmap and draw three horozontal stripes to it.
  1.3042 +  - Draw the bitmap scaled down on the left of the screen using DrawBitmap(), and scaled down in the 
  1.3043 +  same way but with a clip rect applied on the right of the screen.
  1.3044 +  - Compare what is drawn on the left with what is drawn on the right (in the appropraite clip rect area only).
  1.3045 +  - Repeat but with the bitmap scaled up.
  1.3046 +  - Repeat with no scaling.
  1.3047 +   
  1.3048 +  @SYMTestExpectedResults What is drawn on the left should match what is drawn on the right 
  1.3049 +  (in the appropraite clip rect area only).
  1.3050 +  If this test was run without the fix for DEF126160, what is drawn clipped on the right when the bitmap is
  1.3051 +  scaled down would not match what is drawn on the left.
  1.3052 +*/
  1.3053 +void CTDefect::TestClippedScaledBitmapL()
  1.3054 +	{	
  1.3055 +	const TDisplayMode KBitmapMode = EColor64K;
  1.3056 +	const TDisplayMode KDisplayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, 
  1.3057 +						   EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP};
  1.3058 +	// Create a screen device and gc for drawing the test bitmap to
  1.3059 +	TInt ii = 0;
  1.3060 +	TInt err = KErrNotSupported;
  1.3061 +	CFbsScreenDevice* scrDev = NULL;
  1.3062 +	for(;(ii<TInt(sizeof(KDisplayMode)/sizeof(KDisplayMode[0]))) && (err == KErrNotSupported);++ii)
  1.3063 +		{
  1.3064 +		TRAP(err, scrDev = CFbsScreenDevice::NewL(0,KDisplayMode[ii]));
  1.3065 +		}
  1.3066 +	if (err != KErrNone)
  1.3067 +		{
  1.3068 +		_LIT(KLog,"Failed to create screen device %S return value %d");
  1.3069 +		INFO_PRINTF3(KLog,&ColorModeName(KDisplayMode[ii]),err);
  1.3070 +		User::Leave(err);
  1.3071 +		}
  1.3072 +	else
  1.3073 +		{
  1.3074 +		_LIT(KLog,"Created Screen Device with mode %S");
  1.3075 +		INFO_PRINTF2(KLog,&ColorModeName(KDisplayMode[ii]));
  1.3076 +		}
  1.3077 +	
  1.3078 +	User::LeaveIfNull(scrDev);
  1.3079 +	scrDev->SetAutoUpdate(EFalse);
  1.3080 +	CleanupStack::PushL(scrDev);
  1.3081 +	
  1.3082 +	// Set the bitmap size as one quarter of the screen
  1.3083 +	TSize bmpSize(scrDev->SizeInPixels().iWidth/2, scrDev->SizeInPixels().iHeight/2); 
  1.3084 +
  1.3085 +	CFbsBitGc* scrGc = NULL;
  1.3086 +	User::LeaveIfError(scrDev->CreateContext(scrGc));
  1.3087 +	CleanupStack::PushL(scrGc);
  1.3088 +	
  1.3089 +	// Create the test bitmap
  1.3090 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
  1.3091 +	CleanupStack::PushL(bmp);
  1.3092 +	User::LeaveIfError(bmp->Create(bmpSize, KBitmapMode));	
  1.3093 +	
  1.3094 +	CFbsBitmapDevice* bmpDev = CFbsBitmapDevice::NewL(bmp);
  1.3095 +	User::LeaveIfNull(bmpDev);
  1.3096 +	CleanupStack::PushL(bmpDev);
  1.3097 +	
  1.3098 +	CFbsBitGc* bmpGc;
  1.3099 +	User::LeaveIfError(bmpDev->CreateContext(bmpGc));
  1.3100 +	CleanupStack::PushL(bmpGc);
  1.3101 +	
  1.3102 +	// Draw a series of diagonal lines across the bitmap
  1.3103 +	const TInt KNumTestColors = 7;
  1.3104 +	const TRgb KTestColors[KNumTestColors] = {KRgbRed, KRgbBlue, KRgbGreen, KRgbYellow, KRgbMagenta, KRgbDarkGreen, KRgbDarkYellow};
  1.3105 +	const TInt KPenSize = 20;	
  1.3106 +	bmpGc->SetPenSize(TSize(KPenSize,KPenSize));	
  1.3107 +	for (TInt i = -KPenSize; i < bmpSize.iWidth+bmpSize.iHeight; i += KPenSize)
  1.3108 +		{
  1.3109 +		bmpGc->SetPenColor(KTestColors[i%KNumTestColors]);
  1.3110 +		bmpGc->DrawLine(TPoint(i,0), TPoint(0,i));
  1.3111 +		}	
  1.3112 +	
  1.3113 +	TRect lhsRect;
  1.3114 +	TRect rhsRect;
  1.3115 +	TRect lhsCompareRect;
  1.3116 +	TRect rhsClipRect;
  1.3117 +	scrGc->Clear();
  1.3118 +	
  1.3119 +	// Scale down - this is the case that would fail without the fix for DEF126160
  1.3120 +	INFO_PRINTF1(_L("- Scaling Down"));
  1.3121 +	lhsRect.SetRect(TPoint(0,0), TSize(bmpSize.iWidth, bmpSize.iHeight/2));
  1.3122 +	rhsRect = lhsRect;
  1.3123 +	rhsRect.Move(scrDev->SizeInPixels().iWidth/2, 0);				
  1.3124 +	lhsCompareRect.SetRect(TPoint(0,lhsRect.Height()/2), TSize(lhsRect.Width(), lhsRect.Height()/2));
  1.3125 +	rhsClipRect = lhsCompareRect;
  1.3126 +	rhsClipRect.Move(scrDev->SizeInPixels().iWidth/2, 0);				
  1.3127 +	scrGc->DrawBitmap(lhsRect, bmp);
  1.3128 +	scrGc->SetClippingRect(rhsClipRect);
  1.3129 +	scrGc->DrawBitmap(rhsRect, bmp);
  1.3130 +	scrDev->Update();
  1.3131 +	TEST(scrDev->RectCompare(lhsCompareRect, *scrDev, rhsClipRect));
  1.3132 +	
  1.3133 +	scrGc->CancelClippingRect();
  1.3134 +	scrGc->Clear();
  1.3135 +	
  1.3136 +	// Scale up
  1.3137 +	INFO_PRINTF1(_L("- Scaling Up"));
  1.3138 +	lhsRect.SetRect(TPoint(0,0), TSize(bmpSize.iWidth, bmpSize.iHeight*2));
  1.3139 +	rhsRect = lhsRect;
  1.3140 +	rhsRect.Move(scrDev->SizeInPixels().iWidth/2, 0);				
  1.3141 +	lhsCompareRect.SetRect(TPoint(0,lhsRect.Height()/2), TSize(lhsRect.Width(), lhsRect.Height()/2));
  1.3142 +	rhsClipRect = lhsCompareRect;
  1.3143 +	rhsClipRect.Move(scrDev->SizeInPixels().iWidth/2, 0);				
  1.3144 +	scrGc->DrawBitmap(lhsRect, bmp);
  1.3145 +	scrGc->SetClippingRect(rhsClipRect);
  1.3146 +	scrGc->DrawBitmap(rhsRect, bmp);
  1.3147 +	scrDev->Update();
  1.3148 +	TEST(scrDev->RectCompare(lhsCompareRect, *scrDev, rhsClipRect));
  1.3149 +	
  1.3150 +	scrGc->CancelClippingRect();
  1.3151 +	scrGc->Clear();
  1.3152 +	
  1.3153 +	// No scaling
  1.3154 +	INFO_PRINTF1(_L("- No Scaling"));
  1.3155 +	lhsRect.SetRect(TPoint(0,0), bmpSize);
  1.3156 +	rhsRect = lhsRect;
  1.3157 +	rhsRect.Move(scrDev->SizeInPixels().iWidth/2, 0);				
  1.3158 +	lhsCompareRect.SetRect(TPoint(0,lhsRect.Height()/2), TSize(lhsRect.Width(), lhsRect.Height()/2));
  1.3159 +	rhsClipRect = lhsCompareRect;
  1.3160 +	rhsClipRect.Move(scrDev->SizeInPixels().iWidth/2, 0);
  1.3161 +	scrGc->DrawBitmap(lhsRect, bmp);
  1.3162 +	scrGc->SetClippingRect(rhsClipRect);
  1.3163 +	scrGc->DrawBitmap(rhsRect, bmp);
  1.3164 +	scrDev->Update();
  1.3165 +	TEST(scrDev->RectCompare(lhsCompareRect, *scrDev, rhsClipRect));	
  1.3166 +	
  1.3167 +	CleanupStack::PopAndDestroy(5, scrDev);
  1.3168 +	}
  1.3169 +
  1.3170 +/**
  1.3171 +  @SYMTestCaseID GRAPHICS-BITGDI-0109
  1.3172 + 
  1.3173 +  @SYMDEF DEF128522 EndDataAccess() not called when CFbsBitGc::DrawBitmap() returns          
  1.3174 +
  1.3175 +  @SYMTestCaseDesc Test that EndDataAccess() is called correctly when a bitmap is drawn
  1.3176 +  using CFbsBitGc::DrawBitmap(const TPoint&, const CFbsBitmap*) with twips not set.
  1.3177 +   
  1.3178 +  @SYMTestPriority High
  1.3179 +
  1.3180 +  @SYMTestStatus Implemented
  1.3181 +
  1.3182 +  @SYMTestActions 
  1.3183 +  - Create a CFbsBitmap.
  1.3184 +  - Draw using CFbsBitGc::DrawBitmap(const TPoint&, const CFbsBitmap*) without setting the twips.
  1.3185 +  - Call CFbsBitmap::DataAddress() on the bitmap, this should mark the bitmap
  1.3186 +  as volatile as DataAddress() was called outside a BeginDataAccess()/EndDataAccess() pair.
  1.3187 +  - Call CFbsBitmap::IsVolatile() and check the result.
  1.3188 +   
  1.3189 +  @SYMTestExpectedResults 
  1.3190 +  CFbsBitmap::IsVolatile() should return ETrue
  1.3191 +*/
  1.3192 +void CTDefect::TestDrawBitmapTwipsNotSet()
  1.3193 +	{
  1.3194 +	const TDisplayMode KBitmapMode = EColor64K;
  1.3195 +		
  1.3196 +	// Create a screen device and gc for drawing the test bitmap to
  1.3197 +	const TDisplayMode KDisplayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, 
  1.3198 +						   EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP};
  1.3199 +	// Create a screen device and gc for drawing the test bitmap to
  1.3200 +	TInt ii = 0;
  1.3201 +	TInt err = KErrNotSupported;
  1.3202 +	CFbsScreenDevice* scrDev = NULL;
  1.3203 +	for(;(ii<TInt(sizeof(KDisplayMode)/sizeof(KDisplayMode[0]))) && (err == KErrNotSupported);++ii)
  1.3204 +		{
  1.3205 +		TRAP(err, scrDev = CFbsScreenDevice::NewL(0,KDisplayMode[ii]));
  1.3206 +		}
  1.3207 +	if (err != KErrNone)
  1.3208 +		{
  1.3209 +		_LIT(KLog,"Failed to create screen device %S return value %d");
  1.3210 +		INFO_PRINTF3(KLog,&ColorModeName(KDisplayMode[ii]),err);
  1.3211 +		User::Leave(err);
  1.3212 +		}
  1.3213 +	else
  1.3214 +		{
  1.3215 +		_LIT(KLog,"Created Screen Device with mode %S");
  1.3216 +		INFO_PRINTF2(KLog,&ColorModeName(KDisplayMode[ii]));
  1.3217 +		}
  1.3218 +	
  1.3219 +	User::LeaveIfNull(scrDev);
  1.3220 +	CleanupStack::PushL(scrDev);		
  1.3221 +
  1.3222 +	CFbsBitGc* scrGc = NULL;
  1.3223 +	User::LeaveIfError(scrDev->CreateContext(scrGc));
  1.3224 +	CleanupStack::PushL(scrGc);
  1.3225 +	
  1.3226 +	// Create a test bitmap
  1.3227 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
  1.3228 +	CleanupStack::PushL(bmp);
  1.3229 +	User::LeaveIfError(bmp->Create(TSize(100,100), KBitmapMode));		
  1.3230 +		
  1.3231 +	// Draw the bitmap, note that twips have not been set so that DrawBitmap() returns
  1.3232 +	// directly after the check for twips being set
  1.3233 +	scrGc->DrawBitmap(TPoint(0,0), bmp);
  1.3234 +	
  1.3235 +	// Get the data address of the bitmap. If EndDataAccess() was called correctly
  1.3236 +	// when DrawBitmap() returned, the bitmap will now be marked as volatile as DataAddress()
  1.3237 +	// has been called outside a BeginDataAccess()/EndDataAccess() pair. If the bitmap is not
  1.3238 +	// marked as volatile then EndDataAccess() was not called correctly in DrawBitmap() when
  1.3239 +	// it returned.
  1.3240 +	TUint32* data = bmp->DataAddress();
  1.3241 +	TBool isVolatile = bmp->IsVolatile();	
  1.3242 +	TEST(isVolatile);
  1.3243 +	
  1.3244 +	CleanupStack::PopAndDestroy(3, scrDev);
  1.3245 +	}
  1.3246 +
  1.3247 +
  1.3248 +/**
  1.3249 +  @SYMTestCaseID GRAPHICS-BITGDI-0119
  1.3250 + 
  1.3251 +  @SYMDEF INC138992
  1.3252 +
  1.3253 +  @SYMTestCaseDesc Test CFbsBitGC:: DrawBitmapMasked() with compressed source and mask bitmaps,
  1.3254 +   where the target area is larger or smaller than source bitmap's size.
  1.3255 +   
  1.3256 +  @SYMTestPriority High
  1.3257 +
  1.3258 +  @SYMTestStatus Implemented
  1.3259 +
  1.3260 +  @SYMTestActions For each configuration:
  1.3261 +	Create a compressed source and a compressed mask bitmap.
  1.3262 +	Draw the bitmaps to the device, once with the target area smaller than the size of the source bitmap,
  1.3263 +	once with the target area larger than the source bitmap.
  1.3264 +	Compare the actual image drawn with that expected.
  1.3265 +	
  1.3266 +	All combinations of following configurations tested :
  1.3267 +		Mask with display modes EGray2 and EGray256
  1.3268 +		Device with display modes EColor64K and EColor16MAP
  1.3269 +		Mask with sizes same as source bitmap and smaller than source bitmap	
  1.3270 + 
  1.3271 +  @SYMTestExpectedResults Images drawn should be as expected. 
  1.3272 +*/	
  1.3273 +void CTDefect::TestDrawBitmapMaskedL()
  1.3274 +	{
  1.3275 +	// Mask size is same as source bitmap size.  This covers same code paths as those using a larger mask size.
  1.3276 +	INFO_PRINTF1(_L(" - with EGray2 mask, EColor64K source and EColor64K display"));
  1.3277 +	TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor64K, TSize(96,48));
  1.3278 +
  1.3279 +	INFO_PRINTF1(_L(" - with EGray256 mask, EColor64K source and EColor64K display"));
  1.3280 +	TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor64K, TSize(96,48));
  1.3281 +
  1.3282 +	INFO_PRINTF1(_L(" - with EGray2 mask, EColor64K source and EColor16MAP display"));
  1.3283 +	TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor16MAP, TSize(96,48));
  1.3284 +
  1.3285 +	INFO_PRINTF1(_L(" - with EGray256 mask, EColor64K source and EColor16MAP display"));
  1.3286 +	TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor16MAP, TSize(96,48));
  1.3287 +
  1.3288 +	// Mask size is smaller than source bitmap size.
  1.3289 +	// This covers different code paths to above.
  1.3290 +	TSize maskSize(48,24);
  1.3291 +
  1.3292 +	INFO_PRINTF1(_L(" - with small EGray2 mask, EColor64K source and EColor64K display"));
  1.3293 +	TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor64K, TSize(96,48), &maskSize);
  1.3294 +
  1.3295 +	INFO_PRINTF1(_L(" - with small EGray256 mask, EColor64K source and EColor64K display"));
  1.3296 +	TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor64K, TSize(96,48), &maskSize);
  1.3297 +
  1.3298 +	INFO_PRINTF1(_L(" - with small EGray2 mask, EColor64K source and EColor16MAP display"));
  1.3299 +	TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor16MAP, TSize(96,48), &maskSize);
  1.3300 +
  1.3301 +	INFO_PRINTF1(_L(" - with small EGray256 mask, EColor64K source and EColor16MAP display"));
  1.3302 +	TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor16MAP, TSize(96,48), &maskSize);
  1.3303 +	}
  1.3304 +
  1.3305 +/**
  1.3306 +Tests drawing masked bitmaps with both stretched (twice original size) and squashed (half original size) destination rectangles
  1.3307 +*/
  1.3308 +void CTDefect::TestDoDrawBitmapMaskedL(TDisplayMode aSrcDispMode, TDisplayMode aMaskDispMode, TDisplayMode aDeviceDispMode, TSize aPicSize, TSize* aMaskSize)
  1.3309 +	{
  1.3310 +	// create and initialise source and mask bitmap
  1.3311 +	CFbsBitmap* src = NULL;
  1.3312 +	CFbsBitmap* mask = NULL;
  1.3313 +	// Number of vertical changes to mask colour in a row
  1.3314 +	const TInt KNumMaskBars = 2;
  1.3315 +	// Height of each bar in pixels
  1.3316 +	const TInt KMaskBarHeight = 2;
  1.3317 +
  1.3318 +	InitialiseSourceAndMaskLC(src, aSrcDispMode, mask, aMaskDispMode, aPicSize, KNumMaskBars, KMaskBarHeight, aMaskSize);
  1.3319 +	
  1.3320 +	TInt err;
  1.3321 +	CFbsScreenDevice* fbsDevice = NULL;
  1.3322 +	// create screen device
  1.3323 +	TRAP(err, fbsDevice = CFbsScreenDevice::NewL(KNullDesC, aDeviceDispMode));
  1.3324 +	if (err == KErrNotSupported)
  1.3325 +		{
  1.3326 +		WARN_PRINTF1(_L("Display mode is not supported by scdv"));
  1.3327 +		CleanupStack::PopAndDestroy(2, src);
  1.3328 +		return;
  1.3329 +		}
  1.3330 +	CleanupStack::PushL(fbsDevice);
  1.3331 +	// create graphics context
  1.3332 +	CFbsBitGc* gcContext = NULL;
  1.3333 +	err = fbsDevice->CreateContext(gcContext);
  1.3334 +	TEST(err == KErrNone);
  1.3335 +	TEST(gcContext != NULL);
  1.3336 +	CleanupStack::PushL(gcContext);
  1.3337 +	gcContext->SetBrushColor(KRgbGreen);
  1.3338 +
  1.3339 +	const TInt KNumScales = 2;
  1.3340 +	// Scale ratios for destination rects.
  1.3341 +	const TReal32 KScale[KNumScales] = {0.5, 2.0};
  1.3342 +
  1.3343 +	TInt barwidth = (aMaskSize ? aMaskSize->iWidth : aPicSize.iWidth)/KNumMaskBars;
  1.3344 +	TSize barSize(barwidth, aPicSize.iHeight);
  1.3345 +
  1.3346 +	for (TInt ii = 0; ii < KNumScales; ++ii)
  1.3347 +		{
  1.3348 +		TSize scaledBarSize(barwidth*KScale[ii], aPicSize.iHeight*KScale[ii]);
  1.3349 +		TInt currentPattern = 1; //i.e. mask not inverted
  1.3350 +		TRect scaledDestRect(TPoint(0,0),scaledBarSize);
  1.3351 +		for(TInt x = 0; x < aPicSize.iWidth; x += barwidth)
  1.3352 +			{
  1.3353 +			gcContext->Clear();
  1.3354 +			gcContext->DrawBitmapMasked(scaledDestRect,src,TRect(TPoint(x, 0), barSize), mask, EFalse);
  1.3355 +			fbsDevice->Update();
  1.3356 +			CheckResults(fbsDevice, scaledBarSize.iWidth, scaledBarSize.iHeight, currentPattern, KMaskBarHeight*KScale[ii]);
  1.3357 +			currentPattern ^= 1;
  1.3358 +			}
  1.3359 +		}
  1.3360 +
  1.3361 +	CleanupStack::PopAndDestroy(4, src); //  gcContext, fbsDevice, mask, src
  1.3362 +	}
  1.3363 +
  1.3364 +//--------------
  1.3365 +__CONSTRUCT_STEP__(Defect)
  1.3366 +
  1.3367 +void CTDefectStep::TestSetupL()
  1.3368 +	{
  1.3369 +	TheFs.Connect();
  1.3370 +	::CopyDataFiles();
  1.3371 +	}
  1.3372 +	
  1.3373 +void CTDefectStep::TestClose()
  1.3374 +	{
  1.3375 +	::DeleteDataFiles();	
  1.3376 +	TheFs.Close();
  1.3377 +	}