graphicstest/uibench/src/tfbsfonthandleperf.cpp
changeset 0 5d03bc08d59c
child 41 de3d5b6102ac
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // fbsfonthandleperf.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code 
       
    22 */
       
    23 
       
    24 #include "tfbsfonthandleperf.h"
       
    25 #include <linkedfonts.h>
       
    26 
       
    27 const TInt KIterationsToTest = 150;
       
    28 const TInt KShortIterationsToTest = 100;
       
    29 const TInt KMinimumIterations = 51;
       
    30 const TInt KEqual = 0;
       
    31 
       
    32 // Define font typefaces to test  
       
    33 _LIT(KTestOpenFontName,"DejaVu Sans Condensed");
       
    34 _LIT(KTestFontTypefaceFnt,"fnt");
       
    35 _LIT(KTestInvalidFontName,"Invalid");
       
    36 _LIT(KHindiFontName,"Devanagari OT Eval");
       
    37 _LIT(KHindiShort,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020"); // 9 characters
       
    38 _LIT(KEnglishShort,"The quick"); //9 characters
       
    39 _LIT(K4thFontText,"HALGEBICK"); //9 characters from LinkedFont1
       
    40 _LIT(KWithoutlinkedfont,"Withoutlinkedfont");
       
    41 
       
    42 // hindi sample text - these have repeat characters - alternative phrases - use number 9 since it is the longest
       
    43 // sample 1
       
    44 #if 0
       
    45 _LIT16(KHindi1,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020\x0909\x0926\x094D\x0926\x0947\x0936\x094D\x0020\x0915\x094D\x0937\x093F\x092A\x094D\x0930");
       
    46 _LIT16(KHindi2,"\x092d\x0942\x0930\x094d\x092d\x0941\x0935\x0903\x0020\x0938\x094d\x0935\x0903\x0020\x0924\x0924\x094d\x0938\x0935\x093f\x0924\x0941\x0930\x094d\x0935\x0930\x0947\x0923\x094d\x092f\x0902");
       
    47 _LIT16(KHindi3,"\x092d\x0930\x094d\x0917\x094b\x0020\x0926\x0947\x0935\x0938\x094d\x092f\x0020\x0927\x0940\x092e\x0939\x093f\x0020\x0927\x093f\x092f\x094b\x0020\x092f\x094b\x0928\x0903\x0020\x092a\x094d\x0930\x091a\x094b\x0926\x092f\x093e\x0924\x094d\x0020");
       
    48 
       
    49 // sample 2
       
    50 _LIT16(KHindi4,"\x092f\x0924\x094d\x0930\x0020\x092f\x094b\x0917\x0947\x0936\x094d\x0935\x0930\x0020\x0915\x0943\x0937\x094d\x0923\x094b\x0020\x092f\x0924\x094d\x0930\x0020\x092a\x093e\x0930\x094d\x0925\x094b\x0020\x0927\x0930\x094d\x0928\x0941\x0927\x0930\x0903");
       
    51 _LIT16(KHindi5,"\x0924\x0924\x094d\x0930\x0020\x0936\x094d\x0930\x0940\x0930\x094d\x0935\x093f\x091c\x092f\x094b\x0020\x092d\x0942\x0924\x093f\x0930\x094d\x0927\x0941\x0935\x093e\x0020\x0928\x0940\x0924\x093f\x0930\x094d\x092e\x0924\x093f\x0930\x094d\x092e\x092e");
       
    52 _LIT16(KHindi6,"\x0915\x0941\x0924\x0938\x094d\x0924\x094d\x0935\x093e\x0020\x0915\x0936\x094d\x092e\x0932\x092e\x093f\x0926\x0902\x0020\x0935\x093f\x0936\x092e\x0947\x0020\x0938\x092e\x0941\x092a\x0938\x094d\x0925\x093f\x0924\x092e\x094d");
       
    53 
       
    54 // sample 3
       
    55 _LIT16(KHindi7,"\x0905\x0928\x093e\x0930\x094d\x092f\x091c\x0941\x0937\x094d\x091f\x092e\x0938\x094d\x0935\x0930\x094d\x0917\x094d\x092f\x092e\x0915\x0940\x0930\x094d\x0924\x093f\x0915\x0930\x092e\x0930\x094d\x091c\x0941\x0928");
       
    56 _LIT16(KHindi8,"\x0915\x094d\x0932\x0948\x092c\x094d\x092f\x0902\x0020\x092e\x0020\x0938\x094d\x092e\x0020\x0917\x092e\x0903\x0020\x092a\x093e\x0930\x094d\x0925\x0928\x0948\x0924\x0924\x094d\x0924\x094d\x0935\x092f\x094d\x092f\x0941\x092a\x092a\x0926\x094d\x092f\x0924\x0947");
       
    57 #endif
       
    58 
       
    59 _LIT16(KHindi9,"\x0915\x094d\x0937\x0941\x0926\x094d\x0930\x0902\x0020\x0939\x0943\x0926\x092f\x0926\x094c\x0930\x094d\x092c\x0932\x094d\x092f\x0902\x0020\x0924\x094d\x092f\x0915\x094d\x0924\x094d\x0935\x094b\x0924\x094d\x0924\x093f\x0937\x094d\x091f\x0020\x092a\x0930\x0902\x0924\x092a");//45 characters
       
    60 _LIT(KEnglishLong,"The quick brown fox jumped over the lazy dog.");//45 characters
       
    61 
       
    62 
       
    63 /** Information about linked fonts
       
    64 TLinkedFont1.gdr
       
    65 Typeface name: LinkedFont1
       
    66 This will be the dominant font. It contains 177 characters.
       
    67 Some of the characters (13) are deleted from this file and separated in to other three files.
       
    68 Characters missing are F, D, J, M, P, S, V, X, Z, a, n, l, y.
       
    69 
       
    70 TLinkedFont2.gdr
       
    71 Typeface name: LinkedFont2
       
    72 Characters available (7):	F, J, M, S, Z, a, y.
       
    73 
       
    74 TLinkedFont3.gdr
       
    75 Typeface name: LinkedFont3
       
    76 Characters available (4):	D, P, x, l
       
    77 
       
    78 TLinkedFont4.gdr
       
    79 Typeface name: LinkedFont4
       
    80 Characters available (2):	V, n
       
    81 
       
    82 Withoutlinkedfont.gdr
       
    83 Typeface name: Withoutlinkedfont
       
    84 Characters available:	It contains all 190 characters
       
    85 */
       
    86 //Define fonts to test
       
    87 _LIT(KDummy, "Dummy");
       
    88 _LIT(KDummyBold, "Dummy Bold");
       
    89 _LIT(KDummyItalic, "Dummy Italic");
       
    90 _LIT(KDummyBoldItalic, "Dummy Bold Italic");
       
    91 
       
    92 //Define font paths to test
       
    93 _LIT(KFontDummy,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummyFont");
       
    94 _LIT(KFontDummy_b,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummyFont_b");
       
    95 _LIT(KFontDummy_i,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummyFont_i");
       
    96 _LIT(KFontDummy_bi,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummyFont_bi");
       
    97 _LIT(KBitmapFont,"z:\\PlatTest\\Graphics\\TestData\\ceurope.gdr");
       
    98 
       
    99 //Define Test case names
       
   100 _LIT(KAddRemoveOpenFontFiles, "Add-and-remove-'OpenFont'-files");
       
   101 _LIT(KAddOpenedOpenFontFiles, "Add-opened-'OpenFont'-files");
       
   102 _LIT(KAddRemoveBitmapFontFiles, "Add-and-remove-bitmap-font-files");
       
   103 _LIT(KAddOpenedBitmapFontFiles, "Add-opened-bitmap-font-files");
       
   104 _LIT(KFindFontSize, "FontSize");
       
   105 _LIT(KAliasedFont,"PerftestAliasedFont");
       
   106 _LIT(KFontSansSerif,"DejaVu Sans Condensed");
       
   107 _LIT(KFontCreationSansSerif,"FontCreationSansSerif");
       
   108 _LIT(KFontCreationAliasedFont,"FontCreationAliasedFont");
       
   109 
       
   110 //*********** DummyFontFile *****************//
       
   111 /* DummyFontFile class is used to create the Dummy Font File without actually
       
   112 creating the Font.  It is used in AddAndRemoveFilesL() testcase.
       
   113 */
       
   114 CDummyFontFile::CDummyFontFile(TInt aUid, const TDesC& aFileName):
       
   115 	COpenFontFile(aUid, aFileName)
       
   116 	{
       
   117 	}
       
   118 
       
   119 CDummyFontFile* CDummyFontFile::NewL(TInt aUid, const TDesC& aFileName)
       
   120 	{
       
   121 	CDummyFontFile* f = new(ELeave)CDummyFontFile(aUid, aFileName);
       
   122 	CleanupStack::PushL(f);
       
   123 	f->ConstructL();
       
   124 	CleanupStack::Pop();
       
   125 	return f;
       
   126 	}
       
   127 
       
   128 CDummyFontFile::~CDummyFontFile()
       
   129 	{
       
   130 	iFile.Close();
       
   131 	iFs.Close();
       
   132 	}
       
   133 
       
   134 //*********** Pure Virtual Functions of COpenFontFile **********//
       
   135 void CDummyFontFile::GetNearestFontInPixelsL(RHeap* aHeap,
       
   136                                              COpenFontSessionCacheList* aSessionCacheList,
       
   137                                              const TOpenFontSpec& aDesiredFontSpec,
       
   138                                              TInt aPixelWidth,
       
   139                                              TInt aPixelHeight,
       
   140                                              COpenFont*& aFont,
       
   141                                              TOpenFontSpec& aActualFontSpec)
       
   142 
       
   143 	{
       
   144 	aFont = NULL;
       
   145 	TInt face_index = 0;
       
   146 	if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec))
       
   147 		{
       
   148 		aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height());
       
   149 		}
       
   150 	}
       
   151 
       
   152 TBool CDummyFontFile::HasUnicodeCharacterL(TInt /*aFaceIndex*/, TInt /*aCode*/) const
       
   153 	{
       
   154 	return EFalse; // this dummy font has no characters
       
   155 	}
       
   156 
       
   157 //---------------------------------------------Pure Virtual Functions---------//
       
   158 void CDummyFontFile::ConstructL()
       
   159 	{
       
   160 	const TDesC& filename = FileName();
       
   161 
       
   162 	// for comparative benchmarking at least open the file
       
   163 	User::LeaveIfError(iFs.Connect());
       
   164 	const TInt openError = iFile.Open(iFs, filename, EFileRead | EFileShareReadersOnly);
       
   165 	User::LeaveIfError(openError);
       
   166 
       
   167 	// check that file is > 0 bytes
       
   168 	TInt fontFileSize = 0;
       
   169 	User::LeaveIfError(iFile.Size(fontFileSize));
       
   170 	if (fontFileSize == 0)
       
   171 		{
       
   172 		User::Leave(KErrEof);
       
   173 		}
       
   174 
       
   175 	TOpenFontFaceAttrib attrib;
       
   176 
       
   177 	if (KEqual == filename.CompareF(KFontDummy))
       
   178 		attrib.SetFullName(KDummy);
       
   179 	else if (KEqual == filename.CompareF(KFontDummy_b))
       
   180 		{
       
   181 		attrib.SetFullName(KDummyBold);
       
   182 		attrib.SetBold(TRUE);
       
   183 		}
       
   184 	else if (KEqual == filename.CompareF(KFontDummy_i))
       
   185 		{
       
   186 		attrib.SetFullName(KDummyItalic);
       
   187 		attrib.SetItalic(TRUE);
       
   188 		}
       
   189 	else if (KEqual == filename.CompareF(KFontDummy_bi))
       
   190 		{
       
   191 		attrib.SetFullName(KDummyBoldItalic);
       
   192 		attrib.SetBold(TRUE);
       
   193 		attrib.SetItalic(TRUE);
       
   194 		}
       
   195 	attrib.SetFamilyName(KDummy);
       
   196 	attrib.SetLocalFullName(attrib.FullName());
       
   197 	attrib.SetCoverage(TOpenFontFaceAttrib::ELatinSet);
       
   198 	attrib.SetMinSizeInPixels(8);
       
   199 	
       
   200 	AddFaceL(attrib);
       
   201 	}
       
   202 
       
   203 //*------------------------------------DummyFontFile--*/
       
   204 
       
   205 //************ DummyRasterizer***************//
       
   206 /* DummyRasterizer class is used in AddAndRemoveFilesL() Test case to use the
       
   207 Dummy Rasterizer without actually installing the system rasterizer.
       
   208 */
       
   209 CDummyRasterizer* CDummyRasterizer::NewL()
       
   210 	{
       
   211 	return new(ELeave) CDummyRasterizer;
       
   212 	}
       
   213 
       
   214 COpenFontFile* CDummyRasterizer::NewFontFileL(TInt aUid,
       
   215                                               const TDesC& aFileName,
       
   216                                               RFs& /*aFileSession*/)
       
   217 	{
       
   218 	// Allow 'dummy' 'dummy_bold' 'dummy_italic' 'dummy_bold_italic'. 
       
   219 	//Don't actually open a file; just create a dummy font.
       
   220 	if (KEqual == aFileName.CompareF(KFontDummy)||
       
   221 		KEqual == aFileName.CompareF(KFontDummy_b)||
       
   222 		KEqual == aFileName.CompareF(KFontDummy_i)||
       
   223 		KEqual == aFileName.CompareF(KFontDummy_bi))
       
   224 		{
       
   225 		return CDummyFontFile::NewL(aUid,aFileName);
       
   226 		}
       
   227 	return NULL;
       
   228 	}
       
   229 //*------------------------------------DummyRasterizer--*//
       
   230 
       
   231 //************ DummyFont***************//
       
   232 /*
       
   233 DummyFont is used to create a Dummy Font without actually installing it.
       
   234 It is used by AddAndRemoveFilesL() Testcase.
       
   235 */
       
   236 CDummyFont* CDummyFont::NewL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
       
   237 							 CDummyFontFile* aFontFile,TInt aSizeInPixels)
       
   238 	{
       
   239 	CDummyFont* f = reinterpret_cast<CDummyFont*>(aHeap->AllocL(sizeof(CDummyFont)));
       
   240 	new(f) CDummyFont(aHeap,aSessionCacheList,aFontFile,aSizeInPixels);
       
   241 	return f;
       
   242 	}
       
   243 
       
   244 CDummyFont::CDummyFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile,
       
   245 					   TInt aSizeInPixels):
       
   246 	COpenFont(aHeap,aSessionCacheList,aFontFile)
       
   247 	{
       
   248 	iMetrics.SetSize(aSizeInPixels);
       
   249 	iMetrics.SetAscent(aSizeInPixels * 3 / 4);
       
   250 	iMetrics.SetDescent(aSizeInPixels - iMetrics.Ascent());
       
   251 	iMetrics.SetMaxHeight(iMetrics.Ascent());
       
   252 	iMetrics.SetMaxDepth(iMetrics.Descent());
       
   253 	iMetrics.SetMaxWidth(aSizeInPixels * 2);
       
   254 	}
       
   255 
       
   256 void CDummyFont::RasterizeL(TInt /*aCode*/,TOpenFontGlyphData* /*aGlyphData*/)
       
   257 	{
       
   258 	User::Leave(KErrNotSupported); // this dummy font has no glyphs
       
   259 	}
       
   260 
       
   261 //*------------------------------------DummyFont--*//
       
   262 
       
   263 CTFbsFontHandlePerf::CTFbsFontHandlePerf()
       
   264 	{
       
   265 	SetTestStepName(KTFbsFontHandlePerfName);
       
   266 	}
       
   267 
       
   268 TVerdict CTFbsFontHandlePerf::doTestStepPreambleL()
       
   269 	{
       
   270 	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
       
   271 	SetScreenModeL(EColor16MU);
       
   272 	iDevice = &iScreenDevice->BitmapDevice();
       
   273 	return TestStepResult();
       
   274 	}
       
   275 
       
   276 /**
       
   277 Override of base class pure virtual
       
   278 Our implementation only gets called if the base class doTestStepPreambleL() did
       
   279 not leave. That being the case, the current test result value will be EPass.
       
   280 
       
   281 @return - TVerdict code
       
   282 */
       
   283 TVerdict CTFbsFontHandlePerf::doTestStepL()
       
   284 	{	
       
   285 	// Created Linked font with only one typeface
       
   286 	_LIT(KLinkedTypeface,"LinkedTypefaceTest");
       
   287 	CLinkedTypefaceSpecification *typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedTypeface);
       
   288 
       
   289 	const TInt KGroup1Id = 1;	
       
   290 	CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(KGroup1Id);
       
   291 	typefaceSpec->AddLinkedTypefaceGroupL(*group1);
       
   292 	CleanupStack::Pop(group1);
       
   293 		
       
   294 	CLinkedTypefaceElementSpec* element1 = CLinkedTypefaceElementSpec::NewLC(KTestOpenFontName, KGroup1Id);
       
   295 	element1->SetCanonical(ETrue);
       
   296 	
       
   297 	typefaceSpec->AddTypefaceAtIndexL(*element1, 0);
       
   298 	CleanupStack::Pop(element1);
       
   299 	
       
   300 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(iDevice);
       
   301 	CleanupStack::PushL(ts);
       
   302 	TInt ret;
       
   303 	ret = ts->RegisterLinkedTypeface(*typefaceSpec);
       
   304 	CleanupStack::PopAndDestroy(2, typefaceSpec);
       
   305 	if (ret == KErrNotSupported)
       
   306 		{
       
   307 		//If the rasterizer does not support the linked fonts feature do not continue the test:
       
   308 		//log and do not fail test.
       
   309 		INFO_PRINTF1(_L("Linked fonts feature is not supported by rasterizer"));
       
   310 		}
       
   311 	else
       
   312 		{
       
   313 		TEST(ret == KErrNone);
       
   314 
       
   315 		_LIT(KLinkedTypefaceHindi,"HindiLinked");
       
   316 		typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedTypefaceHindi);
       
   317 
       
   318 		group1 = CLinkedTypefaceGroup::NewLC(KGroup1Id);
       
   319 		typefaceSpec->AddLinkedTypefaceGroupL(*group1);
       
   320 		CleanupStack::Pop(group1);
       
   321 		
       
   322 		element1 = CLinkedTypefaceElementSpec::NewLC(KHindiFontName, KGroup1Id);
       
   323 		element1->SetCanonical(ETrue);
       
   324 		typefaceSpec->AddTypefaceAtBackL(*element1);
       
   325 		CleanupStack::Pop(element1);
       
   326 		
       
   327 		ts = CFbsTypefaceStore::NewL(iDevice);
       
   328 		CleanupStack::PushL(ts);
       
   329 		ret = ts->RegisterLinkedTypeface(*typefaceSpec);
       
   330 		TEST(ret == KErrNone);
       
   331 		CleanupStack::PopAndDestroy(2, typefaceSpec);
       
   332 		
       
   333 		//register a linked typeface with four fonts.
       
   334         _LIT(KFourLinked,"FourBitmapLinked");
       
   335         _LIT(KLinkedTypeFace1, "DejaVu Sans Condensed");
       
   336         _LIT(KLinkedTypeFace2, "Devanagari OT Eval");
       
   337         _LIT(KLinkedTypeFace3, "TBKomachiG-R");
       
   338         _LIT(KLinkedTypeFace4, "DejaVu Serif Condensed");
       
   339 
       
   340 		typefaceSpec = CLinkedTypefaceSpecification::NewLC(KFourLinked);
       
   341 
       
   342 		group1 = CLinkedTypefaceGroup::NewLC(KGroup1Id);
       
   343 		typefaceSpec->AddLinkedTypefaceGroupL(*group1);
       
   344 		CleanupStack::Pop(group1);
       
   345 		
       
   346 		const TInt KGroup2Id = 4;	
       
   347 		CLinkedTypefaceGroup* group2 = CLinkedTypefaceGroup::NewLC(KGroup2Id);
       
   348 		typefaceSpec->AddLinkedTypefaceGroupL(*group2);
       
   349 		CleanupStack::Pop(group2);
       
   350 		
       
   351 		const TInt KGroup3Id = 4;	
       
   352 		CLinkedTypefaceGroup* group3 = CLinkedTypefaceGroup::NewLC(KGroup3Id);
       
   353 		typefaceSpec->AddLinkedTypefaceGroupL(*group3);
       
   354 		CleanupStack::Pop(group3);
       
   355 		
       
   356 		element1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypeFace1, KGroup1Id);
       
   357 		element1->SetCanonical(ETrue);
       
   358 		typefaceSpec->AddTypefaceAtBackL(*element1);
       
   359 		CleanupStack::Pop(element1);
       
   360 		
       
   361 		CLinkedTypefaceElementSpec* element2 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypeFace2, KGroup2Id);
       
   362 		typefaceSpec->AddTypefaceAtBackL(*element2);
       
   363 		CleanupStack::Pop(element2);
       
   364 		
       
   365 		CLinkedTypefaceElementSpec* element3 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypeFace3, KGroup3Id);
       
   366 		typefaceSpec->AddTypefaceAtBackL(*element3);
       
   367 		CleanupStack::Pop(element3);
       
   368 		
       
   369 		CLinkedTypefaceElementSpec* element4 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypeFace4, KGroup3Id);
       
   370 		typefaceSpec->AddTypefaceAtBackL(*element4);
       
   371 		CleanupStack::Pop(element4);
       
   372 
       
   373 		ts = CFbsTypefaceStore::NewL(iDevice);
       
   374 		CleanupStack::PushL(ts);
       
   375 		ret = ts->RegisterLinkedTypeface(*typefaceSpec);
       
   376 		TEST(ret == KErrNone);
       
   377 		CleanupStack::PopAndDestroy(2, typefaceSpec);
       
   378 		
       
   379 		_LIT(KOneLinked,"OneLinked");
       
   380 		typefaceSpec = CLinkedTypefaceSpecification::NewLC(KOneLinked);
       
   381 		
       
   382 		group1 = CLinkedTypefaceGroup::NewLC(KGroup1Id);
       
   383 		typefaceSpec->AddLinkedTypefaceGroupL(*group1);
       
   384 		CleanupStack::Pop(group1);
       
   385 		
       
   386 		element1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypeFace1, KGroup1Id);
       
   387 		element1->SetCanonical(ETrue);
       
   388 		typefaceSpec->AddTypefaceAtBackL(*element1);
       
   389 		CleanupStack::Pop(element1);
       
   390 		
       
   391 		ts = CFbsTypefaceStore::NewL(iDevice);
       
   392 		CleanupStack::PushL(ts);
       
   393 		TRAP(ret, typefaceSpec->RegisterLinkedTypefaceL(*ts));
       
   394 		TEST(ret == KErrNone);
       
   395 		
       
   396 		TEST(typefaceSpec->RemoveTypeface(3) == KErrNone);
       
   397 		
       
   398 		TRAP(ret, typefaceSpec->UpdateLinkedTypefaceL(*ts));
       
   399 		
       
   400 		TEST(ret == KErrNone);
       
   401 		
       
   402 		CleanupStack::PopAndDestroy(2, typefaceSpec);
       
   403 
       
   404 	/**
       
   405 	@SYMTestCaseID
       
   406 	GRAPHICS-UI-BENCH-0052
       
   407 
       
   408 	@SYMTestType UT
       
   409 
       
   410 	@SYMTestPriority Critical
       
   411 
       
   412 	@SYMPREQ PREQ1431
       
   413 
       
   414 	@SYMTestCaseDesc 
       
   415 	Test performance timing of linked font creation
       
   416 
       
   417 	@SYMTestActions 
       
   418 	Create a linked font from linked typeface with 1 component font. 
       
   419 
       
   420 	@SYMTestExpectedResults 
       
   421 	Measure performance compared with non-linked font
       
   422 	*/
       
   423 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0052"));
       
   424 	
       
   425 	FontGetNearestFontToDesignHeightInPixelsL(KLinkedTypeface, _L("Font-GetNearest-1stLinkedTypeface-Open"));
       
   426 	TInt getNearestFont1stLinkedTime = iProfiler->GetTrimedMean();
       
   427 
       
   428 	FontGetNearestFontToDesignHeightInPixelsL(KFourLinked, _L("Font-GetNearest-4LinkedTypeface-Bitmap"));
       
   429 	TInt getNearestFont4thLinkedTime = iProfiler->GetTrimedMean();
       
   430 	
       
   431 	FontGetNearestFontToDesignHeightInPixelsL(KOneLinked, _L("Font-GetNearest-1LinkedTypeface-Bitmap"));
       
   432 	TInt getNearestFont1stBitmapLinkedTime = iProfiler->GetTrimedMean();
       
   433 	RecordTestResultL();
       
   434 	/**
       
   435 	@SYMTestCaseID
       
   436 	GRAPHICS-UI-BENCH-0053
       
   437 
       
   438 	@SYMTestType UT
       
   439 
       
   440 	@SYMTestPriority Critical
       
   441 
       
   442 	@SYMPREQ PREQ1431
       
   443 
       
   444 	@SYMTestCaseDesc 
       
   445 	Test performance timing of linked font character access without glyph cache
       
   446 
       
   447 	@SYMTestActions 
       
   448 	Check performance on first access to character in first font of linked font where same character in component font has not yet been accessed
       
   449 
       
   450 	@SYMTestExpectedResults 
       
   451 	Measure performance compared with non-linked font access
       
   452 	*/
       
   453 		// These must be first to avoid using glyph cache
       
   454 		FontDrawStringWithoutGlyphCacheL(KLinkedTypeface, _L("Font-Drawtext-NoCache-1stLinkedTypeface-Open"), 10, KEnglishShort);
       
   455 		TInt drawText1stLinkedWithoutGlyphCacheTime = iProfiler->GetTrimedMean();
       
   456 		
       
   457 		FontDrawStringWithoutGlyphCacheL(KTestOpenFontName, _L("Font-Drawtext-NoCache-Non-LinkedTypeface-Open"), 11, KEnglishShort);
       
   458 		TInt drawTextNonLinkedWithoutGlyphCacheTime = iProfiler->GetTrimedMean();	
       
   459 
       
   460 		INFO_PRINTF2(_L("--Font linking DrawText without glyph cache performance compared with non-linked font: %d percent"), iProfiler->PercentageChange(drawTextNonLinkedWithoutGlyphCacheTime, drawText1stLinkedWithoutGlyphCacheTime));
       
   461 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0053"));
       
   462 
       
   463 		//now testing complex fonts.	
       
   464 		INFO_PRINTF1(_L("Hindi Text output - without Glyph cache"));
       
   465 		FontDrawStringWithoutGlyphCacheL(KLinkedTypefaceHindi, _L("Font-Drawtext-NoCache-Complex-Linked-Open"), 10, KHindiShort);
       
   466 		TInt drawTextHindiLinkedWithoutGlyphCacheTime = iProfiler->GetTrimedMean();
       
   467 		
       
   468 		FontDrawStringWithoutGlyphCacheL(KHindiFontName, _L("Font-Drawtext-NoCache-Non-Linked-Complex-Open"), 11, KHindiShort);
       
   469 		TInt drawTextHindiNonLinkedWithoutGlyphCacheTime = iProfiler->GetTrimedMean();	
       
   470 		INFO_PRINTF2(_L("--Complex Font linking DrawText without glyph cache performance compared with non-linked font: %d percent"), iProfiler->PercentageChange(drawTextHindiNonLinkedWithoutGlyphCacheTime, drawTextHindiLinkedWithoutGlyphCacheTime));
       
   471 
       
   472 		//Compare the difference of complex and normal fonts.	
       
   473 		INFO_PRINTF2(_L("Time difference between complex font and regular font (non linked) %d percent"), iProfiler->PercentageChange(drawTextNonLinkedWithoutGlyphCacheTime,drawTextHindiLinkedWithoutGlyphCacheTime));
       
   474 
       
   475 		//try drawing text with bitmap fonts
       
   476 		FontDrawStringWithoutGlyphCacheL(KFourLinked, _L("Font-Drawtext-NoCache-Linked Typeface 4th Bitmap"), 11, K4thFontText);
       
   477 		TInt drawTextWithoutGlyphCacheTime4thBitmap = iProfiler->GetTrimedMean();
       
   478 		
       
   479 		//for comparision - without any linking
       
   480 		FontDrawStringWithoutGlyphCacheL(KWithoutlinkedfont, _L("Font-Drawtext-No Cache-Non Linked Typeface"), 11, K4thFontText);
       
   481 		TInt drawTextWithoutGlyphCacheTimeAllBitmap = iProfiler->GetTrimedMean();	
       
   482 		
       
   483 		//for comparision - linked, with one linked font
       
   484 		FontDrawStringWithoutGlyphCacheL(KOneLinked, _L("Font-Drawtext-No Cache Linked Typeface 1st Bitmap"), 11, K4thFontText);
       
   485 		TInt drawTextWithoutGlyphCacheTime1stBitmap = iProfiler->GetTrimedMean();
       
   486 		
       
   487 		//Compare the difference of linked and non linked fonts.	
       
   488 		INFO_PRINTF2(_L("Non cached Time difference between non linked font and 4th font down (bitmap) %d percent"), iProfiler->PercentageChange(drawTextWithoutGlyphCacheTimeAllBitmap,drawTextWithoutGlyphCacheTime4thBitmap));
       
   489 
       
   490 		//Compare the difference of linked and lined 4th font down.	
       
   491 		INFO_PRINTF2(_L("Non cached Time difference between 1st linked font and 4th font down (bitmap) %d percent"), iProfiler->PercentageChange(drawTextWithoutGlyphCacheTime1stBitmap,drawTextWithoutGlyphCacheTime4thBitmap));
       
   492 
       
   493 		RecordTestResultL();
       
   494 	/**
       
   495 	@SYMTestCaseID
       
   496 	GRAPHICS-UI-BENCH-0054
       
   497 
       
   498 	@SYMTestType UT
       
   499 
       
   500 	@SYMTestPriority Critical
       
   501 
       
   502 	@SYMPREQ PREQ1431
       
   503 
       
   504 	@SYMTestCaseDesc 
       
   505 	Test performance timing of linked font character access with glyph cache
       
   506 
       
   507 	@SYMTestActions 
       
   508 	Check performance on access to character in first font of linked font where same character in component font has been already accessed and stored in the glyph cache
       
   509 
       
   510 	@SYMTestExpectedResults 
       
   511 	Measure performance compared with non-linked font access
       
   512 	*/	
       
   513 		// Non-Linked font DrawText
       
   514 		FontDrawTextGlyphCacheL(KLinkedTypeface, _L("Font-Drawtext-Cache-1stLinkedTypeface-Open"),KEnglishLong);
       
   515 		TInt drawText1stLinkedWithGlyphCacheTime = iProfiler->GetTrimedMean();	
       
   516 
       
   517 	// Linked font DrawText
       
   518 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0054"));
       
   519 		FontDrawTextGlyphCacheL(KTestOpenFontName, _L("Font-Drawtext-Cache-NonLinked-Open"),KEnglishLong);
       
   520 		TInt drawTextNonLinkedWithGlyphCacheTime = iProfiler->GetTrimedMean();	
       
   521 		INFO_PRINTF2(_L("--Font linking DrawText with glyph cache performance compared with non-linked font: %d percent"), iProfiler->PercentageChange(drawTextNonLinkedWithGlyphCacheTime, drawText1stLinkedWithGlyphCacheTime));
       
   522 
       
   523 		//Now Hindi with and without
       
   524 		FontDrawTextGlyphCacheL(KLinkedTypefaceHindi, _L("Font-Drawtext-Cache-1stLinkedTypeface-Complex-Open"),KHindi9);
       
   525 		TInt drawText1stComplexLinkedWithGlyphCacheTime = iProfiler->GetTrimedMean();	
       
   526 
       
   527 		// Non-Linked font DrawText
       
   528 		FontDrawTextGlyphCacheL(KHindiFontName, _L("Font-Drawtext-Cache-NonLinked-Complex-Open"),KHindi9);
       
   529 		TInt drawTextComplexNonLinkedWithGlyphCacheTime = iProfiler->GetTrimedMean();	
       
   530 		INFO_PRINTF2(_L("--Font complex font linking DrawText with glyph cache performance compared with non-linked font: %d percent"), iProfiler->PercentageChange(drawTextComplexNonLinkedWithGlyphCacheTime, drawText1stComplexLinkedWithGlyphCacheTime));
       
   531 
       
   532 		//Compare Difference between complex font and normal font
       
   533 		INFO_PRINTF2(_L("--Font complex font not linked DrawText with glyph cache performance compared with non-complex font non linked: %d percent"), iProfiler->PercentageChange(drawTextNonLinkedWithGlyphCacheTime, drawTextComplexNonLinkedWithGlyphCacheTime));
       
   534 		
       
   535 		//try drawing text with bitmap fonts
       
   536 		FontDrawTextGlyphCacheL(KFourLinked, _L("Font-Drawtext-Cache-Linked Typeface 4th Bitmap"), K4thFontText);
       
   537 		TInt drawTextWithGlyphCacheTime4thBitmap = iProfiler->GetTrimedMean();
       
   538 		
       
   539 		//for comparision - non linked
       
   540 		FontDrawTextGlyphCacheL(KWithoutlinkedfont, _L("Font-Drawtext-Cache-Non Linked Typeface text as for 4th Bitmap"), K4thFontText);
       
   541 		TInt drawTextWithGlyphCacheTimeAllBitmap = iProfiler->GetTrimedMean();	
       
   542 		
       
   543 		//for comparision - linked at 1st position
       
   544 		FontDrawTextGlyphCacheL(KOneLinked, _L("Font-Drawtext-Cache- Linked Typeface 1st Linked text as for 4th Bitmap"), K4thFontText);
       
   545 		TInt drawTextWithGlyphCacheTime1stBitmap = iProfiler->GetTrimedMean();
       
   546 		
       
   547 		//Compare the difference of non linked 4th font in stack.	
       
   548 		INFO_PRINTF2(_L("Cached Time difference between non linked and 4th font down (bitmap) %d percent"), iProfiler->PercentageChange(drawTextWithGlyphCacheTimeAllBitmap,drawTextWithGlyphCacheTime4thBitmap));
       
   549 
       
   550 		//Compare the difference of 1st font in stack and 4th font in stack
       
   551 		INFO_PRINTF2(_L("Cached Time difference between 1st linked font and 4th font down (bitmap) %d percent"), iProfiler->PercentageChange(drawTextWithGlyphCacheTime1stBitmap,drawTextWithGlyphCacheTime4thBitmap));
       
   552 		
       
   553 		//Compare the difference of non linked and 1st linked in stack	
       
   554 		INFO_PRINTF2(_L("Cached Time difference between non linked and 1st font down (bitmap) %d percent"), iProfiler->PercentageChange(drawTextWithGlyphCacheTimeAllBitmap,drawTextWithGlyphCacheTime1stBitmap));
       
   555 
       
   556 		RecordTestResultL();
       
   557 				
       
   558 /**
       
   559 @SYMTestCaseID
       
   560 GRAPHICS-UI-BENCH-0008
       
   561 
       
   562 @SYMTestCaseDesc
       
   563 Fetches a font with a valid typeface
       
   564 
       
   565 @SYMTestActions
       
   566 Fetch a valid font using FontGetNearestFontToDesignHeightInPixels
       
   567 
       
   568 @SYMTestExpectedResults
       
   569 Measures performance of finding the font speicified
       
   570 */	
       
   571 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0008"));
       
   572 	FontGetNearestFontToDesignHeightInPixelsL(KTestOpenFontName, _L("Font-GetNearest-ValidFont"));
       
   573 	TInt getNearestFontNonLinkedTime = iProfiler->GetTrimedMean();
       
   574 	INFO_PRINTF2(_L("--Font linking GetNearestFont compared with non-linked font: %d percent"), iProfiler->PercentageChange(getNearestFontNonLinkedTime, getNearestFont1stLinkedTime));
       
   575 	INFO_PRINTF2(_L("--Font linking GetNearestFont 1 linked font compared with linked 4 fonts: %d percent"), iProfiler->PercentageChange(getNearestFont1stBitmapLinkedTime, getNearestFont4thLinkedTime));
       
   576 	RecordTestResultL();
       
   577 		}
       
   578 /**
       
   579 @SYMTestCaseID
       
   580 GRAPHICS-UI-BENCH-0009
       
   581 
       
   582 @SYMTestCaseDesc
       
   583 Fetches a font with an invalid typeface. 
       
   584 
       
   585 @SYMTestActions
       
   586 Fetch a invalid font using FontGetNearestFontToDesignHeightInPixels, this will find the nearest match.
       
   587 On Techview this by default will give back a bitmap font which is much faster than an Open Font
       
   588 
       
   589 @SYMTestExpectedResults
       
   590 Measures performance of finding a font
       
   591 */			
       
   592 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0009"));
       
   593 	FontGetNearestFontToDesignHeightInPixelsL(KTestInvalidFontName, _L("Font-GetNearest-InvalidFont"));	
       
   594 	RecordTestResultL();
       
   595 
       
   596 /**
       
   597 @SYMTestCaseID
       
   598 GRAPHICS-UI-BENCH-0010
       
   599 
       
   600 @SYMREQ REQ6158
       
   601 
       
   602 @SYMTestCaseDesc
       
   603 Time to find nearest font when specifying a blank font with no default system typeface name specified
       
   604 
       
   605 @SYMTestActions
       
   606 Ensure no default system typeface name is set and measure time to fetch a blank font typeface name
       
   607 On Techview this by default will give back a bitmap font "fnt"
       
   608 
       
   609 @SYMTestExpectedResults
       
   610 The time to fetch typeface name
       
   611 */					
       
   612 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0010"));
       
   613 	FontGetNearestFontToDesignHeightInPixelsL(KNullDesC, _L("Font-GetNearest-SystemDefaultNoDefault"));
       
   614 	RecordTestResultL();
       
   615 
       
   616 /**
       
   617 @SYMTestCaseID
       
   618 GRAPHICS-UI-BENCH-0011
       
   619 
       
   620 @SYMREQ REQ6158
       
   621 
       
   622 @SYMTestCaseDesc
       
   623 Time to find the nearest font when specifying a blank font with a default system typeface name specified
       
   624 
       
   625 @SYMTestActions
       
   626 Set default system typeface name and measure time to fetch a blank font typeface name
       
   627 Find a nesrest match font using FontGetNearestFontToDesignHeightInPixels
       
   628 
       
   629 @SYMTestExpectedResults
       
   630 The time to fetch typeface name
       
   631 */						
       
   632 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0011"));
       
   633 	ts = CFbsTypefaceStore::NewL(NULL);
       
   634 	CleanupStack::PushL(ts);
       
   635 	ts->SetSystemDefaultTypefaceNameL(KTestFontTypefaceFnt);			
       
   636 	FontGetNearestFontToDesignHeightInPixelsL(KNullDesC, _L("Font-GetNearest-SystemDefaultSetDefault"));	
       
   637 	// Set system default font back to an emtpy descriptor i.e. turn it off
       
   638 	ts->SetSystemDefaultTypefaceNameL(KNullDesC);
       
   639 	CleanupStack::PopAndDestroy(ts);
       
   640 	
       
   641 	RecordTestResultL();
       
   642 /**
       
   643 @SYMTestCaseID
       
   644 GRAPHICS-UI-BENCH-0012
       
   645 
       
   646 @SYMTestCaseDesc
       
   647 Duplicated a font
       
   648 
       
   649 @SYMTestActions
       
   650 Duplicate a font
       
   651 
       
   652 @SYMTestExpectedResults
       
   653 Measures performance of duplicating a font
       
   654 */								
       
   655 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0012"));
       
   656 	FontDuplicateL();	
       
   657 	RecordTestResultL();
       
   658 
       
   659 /**
       
   660 @SYMTestCaseID
       
   661 GRAPHICS-UI-BENCH-0048
       
   662 
       
   663 @SYMDEF DEF091107
       
   664 
       
   665 @SYMTestCaseDesc
       
   666 Measure performance of adding and removing Bitmap font files from a font store.
       
   667 
       
   668 @SYMTestActions
       
   669 Measure the time to add a font file and remove the added font file, repeated 4 times.
       
   670 
       
   671 @SYMTestExpectedResults
       
   672 The time to add and remove a bitmap font file to the font store.
       
   673 */
       
   674 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0048"));
       
   675 	AddAndRemoveFilesL(EFalse);
       
   676 	RecordTestResultL();
       
   677  	
       
   678 /**
       
   679 @SYMTestCaseID
       
   680 GRAPHICS-UI-BENCH-0049
       
   681 
       
   682 @SYMDEF DEF091107
       
   683 
       
   684 @SYMTestCaseDesc
       
   685 Measure performance of adding an already opened Bitmap font file to a font store.
       
   686 
       
   687 @SYMTestActions
       
   688 A Bitmap font is loaded into the Font Store.
       
   689 Measure the time to add the same Bitmap font file again.
       
   690 
       
   691 @SYMTestExpectedResults
       
   692 The time to add an already opened Bitmap font file to the font store.
       
   693 */
       
   694 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0049"));
       
   695 	AddingOpenedFontFilesL(EFalse);
       
   696 	RecordTestResultL();
       
   697 
       
   698 /**
       
   699 @SYMTestCaseID
       
   700 GRAPHICS-UI-BENCH-0050
       
   701 
       
   702 @SYMDEF DEF091107
       
   703 
       
   704 @SYMTestCaseDesc
       
   705 Measure performance of adding and removing Open Font files from a font store.
       
   706 
       
   707 @SYMTestActions
       
   708 Measure the time to add a (dummy) Open Font file and remove the added font file, repeated 4 times.
       
   709 
       
   710 @SYMTestExpectedResults
       
   711 The time to add and remove a dummy Open Font file to the font store.
       
   712 */
       
   713 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0050"));
       
   714 	AddAndRemoveFilesL(ETrue);
       
   715 	RecordTestResultL();
       
   716  	
       
   717 /**
       
   718 @SYMTestCaseID
       
   719 GRAPHICS-UI-BENCH-0051
       
   720  
       
   721 @SYMDEF DEF091107
       
   722  
       
   723 @SYMTestCaseDesc
       
   724 Measure performance of adding an already opened Open Font file to a font store.
       
   725 
       
   726 @SYMTestActions
       
   727 A dummy Open Font is loaded into the Font Store.
       
   728 Measure the time to add the same Open Font file again.
       
   729  	
       
   730 @SYMTestExpectedResults
       
   731 The time to add an already opened Open Font file to the font store.
       
   732 */
       
   733 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0051"));
       
   734 	AddingOpenedFontFilesL(ETrue);
       
   735 	RecordTestResultL();
       
   736 	
       
   737 /**
       
   738 @SYMTestCaseID
       
   739 GRAPHICS-UI-BENCH-0055
       
   740 
       
   741 @SYMDEF DEF095589
       
   742 
       
   743 @SYMTestCaseDesc
       
   744 Measure performance of finding the fontsize.
       
   745 
       
   746 @SYMTestActions
       
   747 Measure the time to add 4 font files, find the fontsize and remove the 4 added font files.
       
   748 
       
   749 @SYMTestExpectedResults
       
   750 The time to add, find fontsize and remove a dummy font file to the font store.
       
   751 */
       
   752 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0055"));
       
   753 	FindFontSizeL();
       
   754 	RecordTestResultL();
       
   755 
       
   756 /**
       
   757 @SYMTestCaseID
       
   758 GRAPHICS-UI-BENCH-0138
       
   759 
       
   760 @SYMDEF INC127988
       
   761 
       
   762 @SYMTestCaseDesc
       
   763 Measure performance of creating a non aliased font.
       
   764 
       
   765 @SYMTestActions
       
   766 Measure the time it takes to create a non-aliased font.
       
   767 
       
   768 @SYMTestExpectedResults
       
   769 The time to create a non aliased font is obtained.
       
   770 */	
       
   771 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0138"));
       
   772 	NonAliasedFontCreationL();
       
   773 	RecordTestResultL();
       
   774 
       
   775 /**
       
   776 @SYMTestCaseID
       
   777 GRAPHICS-UI-BENCH-0140
       
   778 
       
   779 @SYMDEF INC127988
       
   780 
       
   781 @SYMTestCaseDesc
       
   782 Measure performance of creating an aliased font.
       
   783 
       
   784 @SYMTestActions
       
   785 Measure the time it takes to create an aliased font (aliased to KFontSansSerif).
       
   786 
       
   787 @SYMTestExpectedResults
       
   788 The time to create an aliased font is obtained.
       
   789 */
       
   790 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0140"));
       
   791 	AliasedFontCreationL();
       
   792 	RecordTestResultL();
       
   793 	return TestStepResult();
       
   794 	}
       
   795 
       
   796 // Measure performance for font duplication
       
   797 void CTFbsFontHandlePerf::FontDuplicateL()
       
   798 	{		
       
   799 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
       
   800 	CleanupStack::PushL(ts);
       
   801 	CFbsFont* font;
       
   802 	TInt err=ts->GetNearestFontToDesignHeightInPixels((CFont*&)font, TFontSpec(KTestOpenFontName,15));
       
   803 	User::LeaveIfError(err);
       
   804 	
       
   805 	iProfiler->InitResults();
       
   806 	for(TInt count=KIterationsToTest; count>=0; --count)
       
   807 		{
       
   808 		CFbsBitGcFont* duplicateFont=new (ELeave) CFbsBitGcFont;
       
   809 		CleanupStack::PushL(duplicateFont);
       
   810 		err=duplicateFont->Duplicate(font->Handle());
       
   811 		User::LeaveIfError(err);
       
   812 		CleanupStack::PopAndDestroy(duplicateFont);
       
   813 		iProfiler->MarkResultSetL();
       
   814 		}
       
   815 	TInt64 duration=iProfiler->GetTrimedMean();
       
   816 	iProfiler->ResultsAnalysis(_L("Font-Duplicate"), 0, 0, 0, KIterationsToTest);	
       
   817 	ts->ReleaseFont(font);
       
   818 	CleanupStack::PopAndDestroy(ts);
       
   819 	}
       
   820 	
       
   821 // Measure performance using get nearest font
       
   822 void CTFbsFontHandlePerf::FontGetNearestFontToDesignHeightInPixelsL(const TDesC& aFontName, const TDesC& aTestName)
       
   823 	{	
       
   824 	CFbsFont* font;
       
   825 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
       
   826 	CleanupStack::PushL(ts);
       
   827 	
       
   828 	iProfiler->InitResults();
       
   829 	for(TInt count=KIterationsToTest; count>=0; --count)
       
   830 		{
       
   831 		TInt err=ts->GetNearestFontToDesignHeightInPixels((CFont*&)font,TFontSpec(aFontName, 15));
       
   832 		User::LeaveIfError(err);
       
   833 		ts->ReleaseFont(font);	// Release font 
       
   834 		iProfiler->MarkResultSetL();
       
   835 		}
       
   836 	TInt64 duration=iProfiler->GetTrimedMean();
       
   837 	iProfiler->ResultsAnalysis(aTestName, 0, 0, 0, KIterationsToTest);	
       
   838 	CleanupStack::PopAndDestroy(ts);
       
   839 	}
       
   840 
       
   841 // Add and remove files.
       
   842 void CTFbsFontHandlePerf::AddAndRemoveFilesL(TBool aTestOpenFont)
       
   843 	{
       
   844 	RHeap* heap = UserHeap::ChunkHeap(NULL,0x10000,0x10000);
       
   845 	if (NULL == heap)
       
   846 		{
       
   847 		_LIT(KLog,"Not enough memory to create heap for test");
       
   848 		INFO_PRINTF1(KLog);
       
   849 		User::Leave(KErrGeneral);
       
   850 		}
       
   851 
       
   852 	CFontStore* fontStore = CFontStore::NewL(heap);
       
   853 	CleanupStack::PushL(fontStore);
       
   854 
       
   855 	// Install the dummy rasterizer.
       
   856 	COpenFontRasterizer* dummyRasterizer = CDummyRasterizer::NewL();
       
   857 	CleanupStack::PushL(dummyRasterizer);
       
   858 	fontStore->InstallRasterizerL(dummyRasterizer);
       
   859 	CleanupStack::Pop();
       
   860 
       
   861 	iProfiler->InitResults();
       
   862 	for(TInt count=KIterationsToTest; count>=0; --count)
       
   863 		{
       
   864 		if (aTestOpenFont)
       
   865 			{
       
   866 			//Add font files to fontstore
       
   867 			TUid id1 = fontStore->AddFileL(KFontDummy);
       
   868 			TUid id2 = fontStore->AddFileL(KFontDummy_b);
       
   869 			TUid id3 = fontStore->AddFileL(KFontDummy_i);
       
   870 			TUid id4 = fontStore->AddFileL(KFontDummy_bi);
       
   871 			//Remove font files from fontstore
       
   872 			fontStore->RemoveFile(id1);
       
   873 			fontStore->RemoveFile(id2);
       
   874 			fontStore->RemoveFile(id3);
       
   875 			fontStore->RemoveFile(id4);
       
   876 			}
       
   877 		else
       
   878 			{
       
   879 			//Add & remove font file to fontstore
       
   880 			TUid id1=TUid::Null();
       
   881 			TRAPD(err,id1=fontStore->AddFileL(KBitmapFont));
       
   882 			if (err!=KErrNone)
       
   883 				{
       
   884 				_LIT(KLog,"Loading font file %S gave error %d");
       
   885 				INFO_PRINTF3(KLog,&KBitmapFont,err);
       
   886 				User::Leave(err);
       
   887 				}
       
   888 			fontStore->RemoveFile(id1);
       
   889 			// total of 4 times, for comparison with Open Font test
       
   890 			TUid id2 = fontStore->AddFileL(KBitmapFont);
       
   891 			fontStore->RemoveFile(id2);
       
   892 			TUid id3 = fontStore->AddFileL(KBitmapFont);
       
   893 			fontStore->RemoveFile(id3);
       
   894 			TUid id4 = fontStore->AddFileL(KBitmapFont);
       
   895 			fontStore->RemoveFile(id4);
       
   896 			}
       
   897 
       
   898 		iProfiler->MarkResultSetL();
       
   899 		}
       
   900 	TInt64 duration=iProfiler->GetTrimedMean();
       
   901 	if (aTestOpenFont)
       
   902 		{
       
   903 		iProfiler->ResultsAnalysis(KAddRemoveOpenFontFiles, 0, 0, 0, KIterationsToTest);
       
   904 		}
       
   905 	else
       
   906 		{
       
   907 		iProfiler->ResultsAnalysis(KAddRemoveBitmapFontFiles, 0, 0, 0, KIterationsToTest);
       
   908 		}
       
   909 	CleanupStack::PopAndDestroy(fontStore);
       
   910 
       
   911 	heap->Close();
       
   912 	}
       
   913 
       
   914 // Add fontfile that is already opened.
       
   915 void CTFbsFontHandlePerf::AddingOpenedFontFilesL(TBool aTestOpenFont)
       
   916 	{
       
   917 	RHeap* heap = UserHeap::ChunkHeap(NULL,0x10000,0x10000);
       
   918 	if (NULL == heap )
       
   919 		{
       
   920 		User::Leave(KErrGeneral);
       
   921 		}
       
   922 
       
   923 	CFontStore* fontStore = CFontStore::NewL(heap);
       
   924 	CleanupStack::PushL(fontStore);
       
   925 
       
   926 	// Install the dummy rasterizer.
       
   927 	COpenFontRasterizer* dummyRasterizer = CDummyRasterizer::NewL();
       
   928 	CleanupStack::PushL(dummyRasterizer);
       
   929 	fontStore->InstallRasterizerL(dummyRasterizer);
       
   930 	CleanupStack::Pop();
       
   931 
       
   932 	// initial load of font file
       
   933 	TUid id = KNullUid;
       
   934 	if (aTestOpenFont)
       
   935 		{
       
   936 		id = fontStore->AddFileL(KFontDummy);
       
   937 		}
       
   938 	else
       
   939 		{
       
   940 		id = fontStore->AddFileL(KBitmapFont);
       
   941 		}
       
   942 	
       
   943 	iProfiler->InitResults();
       
   944 	for(TInt count=KIterationsToTest; count>=0; --count)
       
   945 		{
       
   946 		//Add font file to fontstore again
       
   947 		if (aTestOpenFont)
       
   948 			{
       
   949 			(void) fontStore->AddFileL(KFontDummy);
       
   950 			}
       
   951 		else
       
   952 			{
       
   953 			(void) fontStore->AddFileL(KBitmapFont);
       
   954 			}
       
   955 
       
   956 		iProfiler->MarkResultSetL();
       
   957 		}
       
   958 	TInt64 duration=iProfiler->GetTrimedMean();
       
   959 	if (aTestOpenFont)
       
   960 		{
       
   961 		iProfiler->ResultsAnalysis(KAddOpenedOpenFontFiles, 0, 0, 0, KIterationsToTest);
       
   962 		}
       
   963 	else
       
   964 		{
       
   965 		iProfiler->ResultsAnalysis(KAddOpenedBitmapFontFiles, 0, 0, 0, KIterationsToTest);
       
   966 		}
       
   967 	CleanupStack::PopAndDestroy(fontStore);
       
   968 
       
   969 	heap->Close();
       
   970 	}
       
   971 
       
   972 // Measure performance for DrawText without glyph cache
       
   973 // In order to avoid using the glyph cache a different character must be drawn each time
       
   974 void CTFbsFontHandlePerf::FontDrawStringWithoutGlyphCacheL(const TDesC& aFontName, const TDesC& aTestName, TInt aFontHeight,const TDesC& aOutputText)
       
   975 	{
       
   976 	CFbsFont* font;
       
   977 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
       
   978 	CleanupStack::PushL(ts);
       
   979 	
       
   980 	TInt loopCount;
       
   981 	for (loopCount=0;loopCount<KMinimumIterations;loopCount++)
       
   982 		{
       
   983 		TInt err=ts->GetNearestFontToDesignHeightInPixels((CFont*&)font,TFontSpec(aFontName, aFontHeight));
       
   984 		aFontHeight+=2;
       
   985 		TEST(err == KErrNone);
       
   986 		iGc->UseFont(font);
       
   987 
       
   988 		// Construct a descriptor with increasing character codes so that we do not fetch glyphs from the glpyh cache
       
   989 		if (loopCount==0)
       
   990 		    iProfiler->InitResults();
       
   991 		else
       
   992 		    iProfiler->StartTimer();
       
   993 		iGc->DrawText(aOutputText,TPoint(10,100));
       
   994 		iProfiler->MarkResultSetL();
       
   995 		ts->ReleaseFont(font);
       
   996 		}
       
   997 
       
   998 	TInt64 duration=iProfiler->GetTrimedMean();
       
   999 	iProfiler->ResultsAnalysis(aTestName, 0, 0, 0, KShortIterationsToTest);	
       
  1000 	CleanupStack::PopAndDestroy(ts);
       
  1001 	}
       
  1002 
       
  1003 
       
  1004 
       
  1005 // Measure performance for DrawText using glyph cache
       
  1006 void CTFbsFontHandlePerf::FontDrawTextGlyphCacheL(const TDesC& aFontName, const TDesC& aTestName, const TDesC& aOutputText)
       
  1007 	{
       
  1008 	CFbsFont* font;
       
  1009 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
       
  1010 	CleanupStack::PushL(ts);
       
  1011 	
       
  1012 	TInt err=ts->GetNearestFontToDesignHeightInPixels((CFont*&)font,TFontSpec(aFontName, 15));	
       
  1013 	TEST(err == KErrNone);
       
  1014 	iGc->UseFont(font);
       
  1015 	
       
  1016 	iGc->DrawText(aOutputText,TPoint(10,100));
       
  1017 	iProfiler->InitResults();
       
  1018 	for(TInt count=KIterationsToTest; count>=0; --count)
       
  1019 		{
       
  1020 		iGc->DrawText(aOutputText,TPoint(10,100));
       
  1021 		iProfiler->MarkResultSetL();
       
  1022 		}
       
  1023 		
       
  1024 	TInt64 duration=iProfiler->GetTrimedMean();
       
  1025 	iProfiler->ResultsAnalysis(aTestName, 0, 0, 0, KIterationsToTest);	
       
  1026 	ts->ReleaseFont(font);	// Release font 
       
  1027 	CleanupStack::PopAndDestroy(ts);
       
  1028 	}
       
  1029 
       
  1030 	
       
  1031 // Create and release fonts.
       
  1032 void CTFbsFontHandlePerf::FindFontSizeL()
       
  1033 	{
       
  1034 	RHeap* heap = UserHeap::ChunkHeap(NULL,0x10000,0x10000);
       
  1035 	if (NULL == heap )
       
  1036 		{
       
  1037 		User::Leave(KErrGeneral);
       
  1038 		}
       
  1039 
       
  1040 	CFontStore* fontStore = CFontStore::NewL(heap);
       
  1041 	CleanupStack::PushL(fontStore);
       
  1042 
       
  1043 	// Install the dummy rasterizer.
       
  1044 	COpenFontRasterizer* dummyRasterizer = CDummyRasterizer::NewL();
       
  1045 	CleanupStack::PushL(dummyRasterizer);
       
  1046 	fontStore->InstallRasterizerL(dummyRasterizer);
       
  1047 	CleanupStack::Pop();
       
  1048 	
       
  1049 	iProfiler->InitResults();
       
  1050 	for(TInt count=KIterationsToTest; count>=0; --count)
       
  1051 		{		
       
  1052 		//Add font files to fontstore
       
  1053 		TUid id1 = fontStore->AddFileL(KFontDummy);
       
  1054 		TUid id2 = fontStore->AddFileL(KFontDummy_b);
       
  1055 		TUid id3 = fontStore->AddFileL(KFontDummy_i);
       
  1056 		TUid id4 = fontStore->AddFileL(KFontDummy_bi);
       
  1057 		TInt typefaces = fontStore->NumTypefaces();
       
  1058 		for (TInt typeface = typefaces - 1; typeface >= 0 ; --typeface)
       
  1059 			{
       
  1060 			TTypefaceSupport support;
       
  1061 			fontStore->TypefaceSupport(support,typeface);
       
  1062 			TFontSpec fs;
       
  1063 			fs.iTypeface = support.iTypeface;
       
  1064 			for (int height = 0; height < support.iNumHeights; height++)
       
  1065 				{
       
  1066 				fs.iHeight = fontStore->FontHeightInTwips(typeface,height);
       
  1067 				}
       
  1068 			}		
       
  1069 		//Remove font files from fontstore
       
  1070 		fontStore->RemoveFile(id1);
       
  1071 		fontStore->RemoveFile(id2);
       
  1072 		fontStore->RemoveFile(id3);
       
  1073 		fontStore->RemoveFile(id4);
       
  1074 			
       
  1075 		iProfiler->MarkResultSetL();
       
  1076 	}
       
  1077 		
       
  1078 	TInt64 duration=iProfiler->GetTrimedMean();
       
  1079 	iProfiler->ResultsAnalysis(KFindFontSize, 0, 0, 0, KIterationsToTest);
       
  1080 
       
  1081 
       
  1082 	CleanupStack::PopAndDestroy(fontStore);
       
  1083 	heap->Close();
       
  1084 	}
       
  1085 
       
  1086 void CTFbsFontHandlePerf::NonAliasedFontCreationL()
       
  1087 	{
       
  1088 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
       
  1089 	CleanupStack::PushL(ts);
       
  1090 	FontCreationPerformanceL(ts, KFontSansSerif, KFontCreationSansSerif);
       
  1091 	CleanupStack::PopAndDestroy(ts);
       
  1092 	}
       
  1093 
       
  1094 void CTFbsFontHandlePerf::AliasedFontCreationL()
       
  1095 	{
       
  1096 	CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL);
       
  1097 	CleanupStack::PushL(ts);
       
  1098 	ts->SetFontNameAliasL(KAliasedFont, KFontSansSerif);
       
  1099 	FontCreationPerformanceL(ts, KAliasedFont, KFontCreationAliasedFont);
       
  1100 	CleanupStack::PopAndDestroy(ts);
       
  1101 	}
       
  1102 
       
  1103 /** Function which is used to measure font creation performance.  This is a helper function
       
  1104 and not a stand alone test.  The font name is expected to be KFontSansSerif or aliased 
       
  1105 to KFontSansSerif.
       
  1106 
       
  1107 @param aTs the CFbsTypefaceStore to be used
       
  1108 @param aFontName the name of the font to be created
       
  1109 @param aTestDescription the description of the test used in logging
       
  1110 */  
       
  1111 void CTFbsFontHandlePerf::FontCreationPerformanceL(CFbsTypefaceStore* aTs, const TDesC& aFontName, const TDesC& aTestDescription)
       
  1112 	{
       
  1113 	iProfiler->InitResults();
       
  1114 	CFont* font = NULL;
       
  1115 	TFontSpec spec(aFontName, 0);
       
  1116 	for(TInt count=KIterationsToTest; count>=0; --count)
       
  1117 		{
       
  1118 		iProfiler->StartTimer();
       
  1119 		TInt ret = aTs->GetNearestFontToDesignHeightInPixels(font, spec);
       
  1120 		iProfiler->MarkResultSetL();
       
  1121 		TEST(ret == KErrNone);
       
  1122 		TFontSpec returnedSpecs = font->FontSpecInTwips();
       
  1123 		TEST(returnedSpecs.iTypeface.iName == KFontSansSerif);
       
  1124 		aTs->ReleaseFont(font);
       
  1125 		}
       
  1126 	TInt64 duration=iProfiler->GetTrimedMean();
       
  1127 	iProfiler->ResultsAnalysis(aTestDescription, 0, 0, 0, KIterationsToTest);
       
  1128 	}