os/graphics/graphicstest/uibench/src/talphablend.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent - Internal Symbian test code 
    20 */
    21 
    22 #include <gdi.h>
    23 #include "talphablend.h"
    24 
    25 const TInt KIterationsToTest = 100;
    26 const TInt KDrawRectIterationsToTest = KIterationsToTest*5;	// More as faster simpler drawing than bitblits
    27 const TInt KDrawVertLineIterationsToTest = KIterationsToTest*5;
    28 const TInt KDrawTextIterationsToTest = KIterationsToTest*2;// More as drawing fewer pixels than blits.
    29 const TInt KDrawVertTextIterationsToTest = KIterationsToTest;// Slow, less iterations.
    30 
    31     _LIT(KFontTypeface,"DejaVu Sans Condensed");
    32 //
    33 // We have two overloads of this test, the normal version that runs all tests except...
    34 //
    35 
    36 CAlphaBlendTestNormal::CAlphaBlendTestNormal()
    37 	{
    38 	SetTestStepName(KAlphaBlendTest);
    39 	}
    40 
    41 TVerdict CAlphaBlendTestNormal::doTestStepL()
    42 	{	
    43 	return(CAlphaBlendTest::doTestStepL(EFalse));
    44 	}
    45 
    46 /*
    47 ...the iType font variant, this needs the rom configured differently so can not be run with the other tests
    48 to configure the rom for iType fonts you need to use:
    49 
    50 ..\iType\binaries\ityperast install
    51 
    52 and to remove them and swich back to normal
    53 
    54  ..\iType\binaries\ityperast uninstall
    55 */
    56 
    57 CAlphaBlendTestIType::CAlphaBlendTestIType()
    58 	{
    59 	SetTestStepName(KAlphaBlendTestIType);
    60 	}
    61 
    62 TVerdict CAlphaBlendTestIType::doTestStepL()
    63 	{	
    64 	return(CAlphaBlendTest::doTestStepL(ETrue));
    65 	}
    66 
    67 /**
    68 Override of base class pure virtual
    69 Our implementation only gets called if the base class doTestStepPreambleL() did
    70 not leave. That being the case, the current test result value will be EPass.
    71 
    72 @return - TVerdict code
    73 */
    74 TVerdict CAlphaBlendTest::doTestStepL(TBool aIType)
    75 	{	
    76 	RWsSession wsSession;
    77 	User::LeaveIfError(wsSession.Connect());
    78 	CleanupClosePushL(wsSession);
    79 
    80 	//
    81 	// Uncomment to debug WSERV redraw problems.
    82 	// wsSession.SetAutoFlush(ETrue); 
    83 	
    84 	CWsScreenDevice* windowDevice = new (ELeave) CWsScreenDevice(wsSession);
    85 	CleanupStack::PushL(windowDevice);
    86 	User::LeaveIfError(windowDevice->Construct());
    87 	CWindowGc* windowGc=NULL;	
    88 	User::LeaveIfError(windowDevice->CreateContext(windowGc)); // create graphics context	
    89 	CleanupStack::PushL(windowGc);	
    90 	
    91 	RWindowGroup group;	
    92 	group  = RWindowGroup(wsSession);
    93 	CleanupClosePushL(group);
    94 	User::LeaveIfError(group.Construct(1, EFalse));
    95 	
    96 	RWindow background;
    97 	background = RWindow(wsSession);
    98 	CleanupClosePushL(background);
    99 	User::LeaveIfError(background.Construct(group, 2));
   100 	
   101 	RWindow window;
   102 	window = RWindow(wsSession);
   103 	CleanupClosePushL(window);
   104 	User::LeaveIfError(window.Construct(group, 3));
   105 
   106 	TSize        windowSize = windowDevice->SizeInPixels();
   107 	TDisplayMode windowMode = windowDevice->DisplayMode();
   108 
   109 	background.Activate();
   110 	background.Invalidate();
   111 
   112 	ClearWindow(wsSession, background, windowGc, BLACK_SEMI_TRANSPARENT);	
   113 	ClearWindow(wsSession, window, windowGc, BLACK_SEMI_TRANSPARENT);
   114 	
   115 	window.SetTransparencyAlphaChannel();	
   116 	window.Activate();
   117 	window.Invalidate();
   118 	if (aIType)
   119 		{
   120 		if (CheckMonoTypeInstalledL())
   121 			DoDrawBlendedTestsL(EBlendTestDrawTextIType,wsSession, KDrawVertTextIterationsToTest);
   122 		else
   123 			{
   124 			INFO_PRINTF1(_L("Monotype fonts not installed, skipping test"));
   125 			}
   126 		}
   127 	else
   128 		{
   129 /*
   130 Test speed of blended draw rects on all modes supporting alpha blending
   131 */	
   132 		DoDrawBlendedTestsL(EBlendTestDrawRect,wsSession, KDrawRectIterationsToTest);
   133 /*
   134 Test speed of blended draw vertical line calls on all modes supporting alpha blending
   135 */	
   136 		DoDrawBlendedTestsL(EBlendTestVerticalLine,wsSession, KDrawVertLineIterationsToTest);
   137 /*
   138 Test speed of blended draw text calls on all modes supporting alpha blending
   139 */	
   140 		DoDrawBlendedTestsL(EBlendTestDrawText,wsSession, KDrawTextIterationsToTest);
   141 		DoDrawBlendedTestsL(EBlendTestDrawTextAntiAliased,wsSession, KDrawVertTextIterationsToTest);
   142 		DoDrawBlendedTestsL(EBlendTestDrawVerticalText,wsSession, KDrawVertTextIterationsToTest);
   143 /**
   144    @SYMTestCaseID
   145    GRAPHICS-UI-BENCH-0022
   146 
   147    @SYMTestCaseDesc
   148    Alphablend test BITBLT with EColor16MA source and EColor16MU destination.
   149 
   150    @SYMTestActions
   151    Compare the results over time
   152 
   153    @SYMTestExpectedResults
   154 */
   155 		RDebug::Printf("Alpha Tests: EColor16MU, EColor16MA");
   156 		RDebug::Printf("Alpha Blend");	
   157 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0022"));
   158 		DoAlphaBlendBitmapsBitmapTestL(EColor16MA, EColor16MU, wsSession, window, windowGc, KIterationsToTest);	
   159 		RecordTestResultL();
   160 
   161 /**
   162    @SYMTestCaseID
   163    GRAPHICS-UI-BENCH-0023
   164 
   165    @SYMTestCaseDesc
   166    Test BITBLT with EColor16MA source and EColor16MU destination.
   167 
   168    @SYMTestActions
   169    Compare the results over time
   170 
   171    @SYMTestExpectedResults
   172 */
   173 		RDebug::Printf("BitBlt Alpha");
   174 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0023"));
   175 		DoBitBltAlphaBitmapTestL(EColor16MA, EColor16MU, wsSession, window, windowGc, KIterationsToTest);
   176 		RecordTestResultL();
   177 	
   178 /**
   179    @SYMTestCaseID
   180    GRAPHICS-UI-BENCH-0024
   181 
   182    @SYMTestCaseDesc
   183    Alpha blend test BITBLT with EColor16MA source and EColor16MA destination.
   184 
   185    @SYMTestActions
   186    Compare the results over time
   187 
   188    @SYMTestExpectedResults
   189 */
   190 		RDebug::Printf("Alpha Tests: EColor16MA, EColor16MA");
   191 		RDebug::Printf("Alpha Blend");	
   192 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0024"));
   193 		DoAlphaBlendBitmapsBitmapTestL(EColor16MA,EColor16MA, wsSession, window, windowGc, KIterationsToTest);
   194 		RecordTestResultL();
   195 
   196 /**
   197    @SYMTestCaseID
   198    GRAPHICS-UI-BENCH-0025
   199 
   200    @SYMTestCaseDesc
   201    Test BITBLT with EColor16MA source and EColor16MA destination.
   202 
   203    @SYMTestActions
   204    Compare the results over time
   205 
   206    @SYMTestExpectedResults
   207 */
   208 		RDebug::Printf("BitBlt Alpha");
   209 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0025"));
   210 		DoBitBltAlphaBitmapTestL(EColor16MA, EColor16MA, wsSession, window, windowGc, KIterationsToTest);
   211 		RecordTestResultL();
   212 /**
   213 	@SYMTestCaseID
   214 	GRAPHICS-UI-BENCH-0063
   215 	
   216 	@SYMTestCaseDesc
   217 	Test BITBLT with EColor16MAP source and EColor16MAP destination.
   218 	
   219 	@SYMTestActions
   220 	Compare the results over several iterations over time.
   221 	
   222 	@SYMTestExpectedResults
   223 */
   224 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0063"));
   225 		DoNormalBitBltL(EFalse, EColor16MAP,EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
   226 		RecordTestResultL();
   227 	
   228 /**
   229 	@SYMTestCaseID
   230 	GRAPHICS-UI-BENCH-0064
   231 	
   232 	@SYMTestCaseDesc
   233 	Test BITBLT with EColor16MA source and EColor16MA destination.
   234 	
   235 	@SYMTestActions
   236 	Compare the results over several iterations over time.
   237 	
   238 	@SYMTestExpectedResults
   239 */
   240 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0064"));
   241 		DoNormalBitBltL(EFalse, EColor16MA,EColor16MA, wsSession, window, windowGc, KIterationsToTest);
   242 		RecordTestResultL();
   243 	
   244 /**
   245 	@SYMTestCaseID
   246 	GRAPHICS-UI-BENCH-0065
   247 	
   248 	@SYMTestCaseDesc
   249 	Test BITBLT with EColor16MAP source and EColor16MA destination.
   250 	
   251 	@SYMTestActions
   252 	Compare the results over several iterations over time.
   253 	
   254 	@SYMTestExpectedResults
   255 */
   256 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0065"));
   257 		DoNormalBitBltL(EFalse, EColor16MAP,EColor16MA, wsSession, window, windowGc, KIterationsToTest);
   258 		RecordTestResultL();
   259 	
   260 /**
   261 	@SYMTestCaseID
   262 	GRAPHICS-UI-BENCH-0066
   263 	
   264 	@SYMTestCaseDesc
   265 	Test BITBLT with EColor16MA source and EColor16MAP destination.
   266 	
   267 	@SYMTestActions
   268 	Compare the results over several iterations over time.
   269 	
   270 	@SYMTestExpectedResults
   271 */
   272 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0066"));
   273 		DoNormalBitBltL(EFalse, EColor16MA,EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
   274 		RecordTestResultL();
   275 	
   276 /**
   277 	@SYMTestCaseID
   278 	GRAPHICS-UI-BENCH-0067
   279 	
   280 	@SYMTestCaseDesc
   281 	Test BITBLT with EColor16MU source and EColor16MU destination.
   282 	
   283 	@SYMTestActions
   284 	Compare the results over several iterations over time.
   285 	
   286 	@SYMTestExpectedResults
   287 */
   288 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0067"));
   289 		DoNormalBitBltL(EFalse, EColor16MU,EColor16MU, wsSession, window, windowGc, KIterationsToTest);
   290 		RecordTestResultL();
   291 	
   292 /**
   293 	@SYMTestCaseID
   294 	GRAPHICS-UI-BENCH-0068
   295 	
   296 	@SYMTestCaseDesc
   297 	Test BITBLT with EColor16MAP source and EColor16MU destination.
   298 	
   299 	@SYMTestActions
   300 	Compare the results over several iterations over time.
   301 	
   302 	@SYMTestExpectedResults
   303 */
   304 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0068"));
   305 		DoNormalBitBltL(EFalse, EColor16MAP,EColor16MU, wsSession, window, windowGc, KIterationsToTest);
   306 		RecordTestResultL();
   307 	
   308 /**
   309 	@SYMTestCaseID
   310 	GRAPHICS-UI-BENCH-0069
   311 	
   312 	@SYMTestCaseDesc
   313 	Test BITBLT with EColor16MU source and EColor16MAP destination.
   314 	
   315 	@SYMTestActions
   316 	Compare the results over several iterations over time.
   317 	
   318 	@SYMTestExpectedResults
   319 */
   320 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0069"));
   321 		DoNormalBitBltL(EFalse, EColor16MU,EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
   322 		RecordTestResultL();
   323 	
   324 /**
   325 	@SYMTestCaseID
   326 	GRAPHICS-UI-BENCH-0070
   327 	
   328 	@SYMTestCaseDesc
   329 	Test BITBLT with EColor64K source and EColor16MU destination.
   330 	
   331 	@SYMTestActions
   332 	Compare the results over several iterations over time.
   333 	
   334 	@SYMTestExpectedResults
   335 */
   336 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0070"));
   337 		DoNormalBitBltL(ETrue, EColor64K,EColor16MU, wsSession, window, windowGc, KIterationsToTest);
   338 		
   339 		RecordTestResultL();
   340 /**
   341 	@SYMTestCaseID
   342 	GRAPHICS-UI-BENCH-0071
   343 	
   344 	@SYMTestCaseDesc
   345 	Test DrawBitmap with different sizes (STRETCHED) with EColor16MAP source and EColor16MAP destination.
   346 	
   347 	@SYMTestActions
   348 	Compare the results over several iterations over time.
   349 	
   350 	@SYMTestExpectedResults
   351 */
   352 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0071"));
   353 		DoDrawBitmapL(EFalse, EColor16MAP, EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
   354 		RecordTestResultL();
   355 	
   356 /**
   357 	@SYMTestCaseID
   358 	GRAPHICS-UI-BENCH-0072
   359 	
   360 	@SYMTestCaseDesc
   361 	Test DrawBitmap with different sizes (STRETCHED) with EColor16MA source and EColor16MA destination.
   362 	
   363 	@SYMTestActions
   364 	Compare the results over several iterations over time.
   365 	
   366 	@SYMTestExpectedResults
   367 */
   368 	
   369 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0072"));
   370 		DoDrawBitmapL(EFalse, EColor16MA, EColor16MA, wsSession, window, windowGc, KIterationsToTest);
   371 		RecordTestResultL();
   372 	
   373 /**
   374 	@SYMTestCaseID
   375 	GRAPHICS-UI-BENCH-0073
   376 	
   377 	@SYMTestCaseDesc
   378 	Test DrawBitmap (using alpha mask) with different sizes (STRETCHED) with EColor16MU source and EColor16MU destination.
   379 	
   380 	@SYMTestActions
   381 	Compare the results over several iterations over time.
   382 	
   383 	@SYMTestExpectedResults
   384 */	
   385 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0073"));
   386 		DoDrawBitmapL(ETrue, EColor16MU, EColor16MU, wsSession, window, windowGc, KIterationsToTest);
   387 		RecordTestResultL();
   388 	
   389 /**
   390 	@SYMTestCaseID
   391 	GRAPHICS-UI-BENCH-0057
   392 	
   393 	@SYMTestCaseDesc
   394 	Test DrawBitmap (using alpha mask) with different sizes (STRETCHED) with EColor16MAP source and EColor16MAP destination.
   395 	
   396 	@SYMTestActions
   397 	Compare the results over several iterations over time.
   398 	
   399 	@SYMTestExpectedResults
   400 */
   401 		SetTestStepID(_L("GRAPHICS-UI-BENCH-0057"));
   402 		DoDrawBitmapL(ETrue, EColor16MAP, EColor16MAP, wsSession, window, windowGc, KIterationsToTest);	
   403 		RecordTestResultL();
   404 		}
   405 	CleanupStack::PopAndDestroy(6, &wsSession);
   406 	return TestStepResult();
   407 	}
   408 
   409 void CAlphaBlendTest::DoDrawBlendedTestsL(TBlendTestFunc aTestFunc, RWsSession& aSession, TInt aNumIterations)
   410 	{
   411 	TDisplayMode blendModes[]={EColor16MAP,EColor16MA,EColor16MU,EColor64K};
   412 	const TInt KNumBlendTestModes=sizeof(blendModes)/sizeof(TDisplayMode);
   413 	for(TInt modeIndex=0;modeIndex<KNumBlendTestModes;modeIndex++)
   414 		{
   415 		DoDrawBlendedTestL(aTestFunc, 0x40, blendModes[modeIndex], aSession, aNumIterations);
   416 		DoDrawBlendedTestL(aTestFunc, 0xFF, blendModes[modeIndex], aSession, aNumIterations);
   417 		DoDrawBlendedTestL(aTestFunc, 0, blendModes[modeIndex], aSession, aNumIterations);
   418 		}
   419 	}
   420 
   421 void CAlphaBlendTest::DoDrawBlendedTestL(TBlendTestFunc aTestFunc, TInt aAlpha, TDisplayMode aDisplayMode, RWsSession& aSession, TInt aNumIterations)
   422 	{
   423 	SetScreenModeL(aDisplayMode);
   424 	const TSize devSize = iScreenDevice->SizeInPixels();
   425 	// For fair back to back tests of rotated mode we need graphics clipped to a square test area.
   426 	// Although if we aren't going to be comparing rotated results against each other it might be better
   427 	// to allow the tests to use the full available area.
   428 	TSize testSize;
   429 	testSize.iWidth=Min(devSize.iWidth,devSize.iHeight);
   430 	testSize.iHeight=testSize.iWidth;
   431 
   432 	TFontSpec testFontSpec; 
   433 	if (aTestFunc==EBlendTestDrawTextAntiAliased || aTestFunc==EBlendTestDrawTextIType)
   434 		{
   435 		testFontSpec.iTypeface.iName=KFontTypeface;
   436 		if (aTestFunc==EBlendTestDrawTextAntiAliased)
   437 			{
   438 			testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   439 			}
   440 		else
   441 			{
   442 			testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   443 			testFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
   444 			testFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
   445 			}
   446 		}
   447 	testFontSpec.iHeight=12;
   448 	// Set bold because sets more pixels, so tests blending code more
   449 	testFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   450 	_LIT(KTestBlendTextString,"BLENDTESTWITHBIGSOLIDCHARACTERS0123456789HAVEWERUNOUTOFSCREENYET?OKAFEWMORECHARACTERSJUSTTOMAKESURE");
   451 	const TInt maxTextLen=KTestBlendTextString().Length();
   452 //
   453 	TBool orientations[4];
   454 	iGc->OrientationsAvailable(orientations);
   455 // Use for loop to test across multiple rotations, however the implementation hardly varies at the moment
   456 // so very little point in testing the differences, if in future an optimised route is added for normal
   457 // rotation this test would be worth switching back to looping upto EGraphicsOrientationRotated270.
   458 //
   459 //	const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationRotated270;
   460 	const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationNormal;
   461 	for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= KMaxOrientation; orient++)
   462 		{
   463 		if (orientations[orient])
   464 			{
   465 			iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
   466 			User::After(100000);	// Let rotate sort itself out
   467 			iGc->Reset();
   468 			iGc->SetClippingRect(TRect(testSize));
   469 			iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   470 			iGc->SetBrushColor(TRgb(0x80,0x80,0xFF));
   471 			iGc->Clear();
   472 			iGc->SetBrushColor(TRgb(10,128,240,aAlpha));
   473 			iGc->SetPenColor(TRgb(240,128,10,aAlpha));
   474 			iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   475 			aSession.Flush();
   476 
   477 			CFbsFont* font=NULL;
   478 			TInt fontHeight=0;
   479 			TInt testParam=0;
   480 			TSize orientatedTestSize=testSize;
   481 			TBuf <32> testName;	
   482 			TGlyphBitmapType checkGlyphBitmapType=EDefaultGlyphBitmap;
   483 			TGlyphBitmapType actualGlyphBitmapType=EDefaultGlyphBitmap;
   484 			TPtrC textPtr;
   485 			switch(aTestFunc)
   486 				{
   487 			case EBlendTestVerticalLine:
   488 				_LIT(KDrawRectVerticalLine,"DrawRectVertLine");
   489 				testName=KDrawRectVerticalLine;
   490 				break;
   491 			case EBlendTestDrawRect:
   492 				_LIT(KDrawRectAlpha,"DrawRectAlpha");
   493 				testName=KDrawRectAlpha;
   494 				iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   495 				iGc->SetPenStyle(CGraphicsContext::ENullPen);
   496 				break;
   497 			case EBlendTestDrawTextIType:
   498 				_LIT(KDrawTextIType,"DrawTextIT");
   499 				testName=KDrawTextIType;
   500 				testParam=testSize.iHeight;
   501 				checkGlyphBitmapType=EFourColourBlendGlyphBitmap;
   502 				goto drawTextTest;
   503 			case EBlendTestDrawTextAntiAliased:
   504 				_LIT(KDrawTextAA,"DrawTextAA");
   505 				testName=KDrawTextAA;
   506 				testParam=testSize.iHeight;
   507 				checkGlyphBitmapType=EAntiAliasedGlyphBitmap;
   508 				goto drawTextTest;
   509 			case EBlendTestDrawVerticalText:
   510 				_LIT(KDrawTextVert,"DrawTextVert");
   511 				orientatedTestSize.SetSize(orientatedTestSize.iHeight,orientatedTestSize.iWidth);
   512 				testName=KDrawTextVert;
   513 				testParam=testSize.iWidth;
   514 				checkGlyphBitmapType=EMonochromeGlyphBitmap;
   515 				goto drawTextTest;
   516 			case EBlendTestDrawText:
   517 				_LIT(KDrawText,"DrawText");
   518 				testParam=testSize.iHeight;
   519 				testName=KDrawText;
   520 				checkGlyphBitmapType=EMonochromeGlyphBitmap;
   521 drawTextTest:	User::LeaveIfError(iScreenDevice->BitmapDevice().GetNearestFontInPixels((CFont* &)font,testFontSpec));
   522 				fontHeight=font->HeightInPixels();
   523 				iGc->UseFont(font);
   524 				actualGlyphBitmapType=font->FontSpecInTwips().iFontStyle.BitmapType();
   525 				TInt displayLen=Min(font->TextCount(KTestBlendTextString,orientatedTestSize.iWidth)+1,maxTextLen);
   526 				textPtr.Set(KTestBlendTextString().Left(displayLen));
   527 				iScreenDevice->BitmapDevice().ReleaseFont(font);
   528 				break;
   529 				}
   530 			if (checkGlyphBitmapType!=EDefaultGlyphBitmap)
   531 				{
   532 				if (actualGlyphBitmapType!=checkGlyphBitmapType)
   533 					{
   534 					INFO_PRINTF3(_L("Failed to load correct glyph type font, wanted %d, got %d"),checkGlyphBitmapType, actualGlyphBitmapType);
   535 					break;
   536 					}
   537 				}
   538 			_LIT(KAppendAlphaTxt,"[A=0x%02x]");
   539 			testName.AppendFormat(KAppendAlphaTxt,aAlpha);
   540 			iProfiler->InitResults();	
   541 			for(TInt iter=0; iter<aNumIterations; iter++)
   542 				{
   543 				switch(aTestFunc)
   544 					{
   545 				case EBlendTestVerticalLine:
   546 					for(TInt xpos=0; xpos<testSize.iWidth; xpos++)
   547 						iGc->DrawLine(TPoint(xpos,0),TPoint(xpos,testSize.iHeight));
   548 					break;
   549 				case EBlendTestDrawRect:
   550 					iGc->DrawRect(TRect(testSize));
   551 					break;
   552 				case EBlendTestDrawText:
   553 				case EBlendTestDrawVerticalText:
   554 				case EBlendTestDrawTextAntiAliased:
   555 				case EBlendTestDrawTextIType:
   556 					{
   557 					for(TInt pos=0;pos<testParam;pos+=fontHeight)
   558 						{
   559 						if (aTestFunc==EBlendTestDrawVerticalText)
   560 							iGc->DrawTextVertical(textPtr,TPoint(pos,0),EFalse);
   561 						else
   562 							iGc->DrawText(textPtr,TPoint(0,pos));
   563 						}
   564 					break;
   565 					}
   566 					}
   567 				iProfiler->MarkResultSetL();
   568 				}
   569 			INFO_PRINTF3(_L("%S %S"), &testName, &ColorModeName(aDisplayMode));
   570 			iProfiler->ResultsAnalysis(testName, orient, aDisplayMode, aDisplayMode, aNumIterations);
   571 			}
   572 		}
   573 	iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
   574 	}
   575 
   576 TBool CAlphaBlendTest::CheckMonoTypeInstalledL()
   577 	{
   578 	SetScreenModeL(EColor16MU);
   579 //
   580 	TFontSpec fontSpec;
   581 	fontSpec.iTypeface.iName = KFontTypeface;
   582 	fontSpec.iHeight = 20;
   583 	fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   584 	fontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
   585 	fontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
   586 	CFont* font;
   587 	User::LeaveIfError(iScreenDevice->BitmapDevice().GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec));
   588 	TBool monoTypeInstalled=font->FontSpecInTwips().iFontStyle.BitmapType()==EFourColourBlendGlyphBitmap;
   589 	iScreenDevice->BitmapDevice().ReleaseFont(font);
   590 	return(monoTypeInstalled);
   591 	}
   592 
   593 /**
   594 Bitblt test
   595 
   596 @param aSrcMode is the source display mode
   597 @param aDstMode is the destination display mode
   598 @param aSession is the windows server session
   599 @param aWindow is a reference to the window
   600 @param aGc is the graphics context of the window
   601 @param aNumIterations is the number of iterations to run the test
   602 */		
   603 void CAlphaBlendTest::DoBitBltAlphaBitmapTestL(TDisplayMode aSrcMode,TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
   604 	{	
   605 	const TSize bitmapSize = aWindow.Size();
   606 	
   607 	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
   608 	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
   609 	CleanupStack::PushL(bitmapDevice);
   610 	CFbsBitGc* bitmapGc = NULL;	
   611 	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));	
   612 	CleanupStack::PushL(bitmapGc);
   613 	
   614 	CFbsBitmap* source = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
   615 	CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256);	// match size to src
   616 	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
   617 	VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff));
   618 
   619 	TPoint point(0,0);
   620 	
   621 	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   622 	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
   623 
   624 	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   625 	bitmapGc->Clear();
   626 	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   627 	bitmapGc->BitBlt(point, source);
   628 
   629 	aGc->Activate(aWindow);
   630 	aGc->BitBlt(point, bitmapTarget);
   631 	aGc->Deactivate();
   632 	aSession.Flush();
   633 
   634 	iProfiler->InitResults();		
   635 	for(TInt i=0; i<aNumIterations; i++)
   636 	{
   637 		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   638 		bitmapGc->Clear();
   639 		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   640 		bitmapGc->BitBlt(point, source);
   641 		iProfiler->MarkResultSetL();
   642 	}
   643 	
   644 	iProfiler->ResultsAnalysis(_L("DoBitBltAlphaBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
   645 	
   646 	// copy up to screen for sanity check
   647 	aGc->Activate(aWindow);
   648 	aGc->BitBlt(TPoint(), bitmapTarget);
   649 	aGc->Deactivate();
   650 	CleanupStack::PopAndDestroy(5, bitmapTarget); //sourceAlpha, source, bitmapGc, bitmapDevice, bitmapTarget
   651 	}
   652 
   653 
   654 /**
   655 Clears the window to a colour
   656 
   657 @param aSession is the windows server session
   658 @param aWindow is a reference to the window
   659 @param aGc is the graphics context of the window
   660 @param aColor is the colour to clear the window with
   661 */
   662 void CAlphaBlendTest::ClearWindow(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TRgb aColor)
   663 {
   664 	// clear so we can see bitmap version has completed
   665 	aWindow.Invalidate();
   666 	aWindow.BeginRedraw();
   667 	aGc->Activate(aWindow);
   668 	aGc->SetBrushColor(aColor);
   669 	aGc->Clear();
   670 	aGc->Deactivate();
   671 	aWindow.EndRedraw();
   672 	aSession.Flush();
   673 }
   674 		
   675 /**
   676 BitBlts a bitmap to the windows GC.
   677 
   678 @param aSession is the windows server session
   679 @param aWindow is a reference to the window
   680 @param aGc is the graphics context of the window
   681 @param aImage is the bitmap to bitblt
   682 */		
   683 void CAlphaBlendTest::BitBlt(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, CFbsBitmap& aImage)
   684 	{
   685 	aWindow.Invalidate();
   686 	aWindow.BeginRedraw();
   687 	aGc->Activate(aWindow);
   688 	aGc->BitBlt(TPoint(0,0), &aImage);
   689 	aGc->Deactivate();
   690 	aWindow.EndRedraw();	
   691 	aSession.Flush();	
   692 	}
   693 
   694 /**
   695 Alpha blends two bitmaps together
   696 
   697 @param aDisplayMode1 is the source display mode
   698 @param aDisplayMode2 is the destination display mode
   699 @param aSession is the windows server session
   700 @param aWindow is a reference to the window
   701 @param aGc is the graphics context of the window
   702 @param aNumIterations is the number of iterations to run the test
   703 */	
   704 void CAlphaBlendTest::DoAlphaBlendBitmapsBitmapTestL(TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
   705 	{
   706 	const TSize bitmapSize = aWindow.Size();	
   707 
   708 	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
   709 	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
   710 	CleanupStack::PushL(bitmapDevice);
   711 	
   712 	CFbsBitGc* bitmapGc=NULL;
   713 	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));	
   714 	CleanupStack::PushL(bitmapGc);
   715 		
   716 	CFbsBitmap* sourceUnder  = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
   717 	CFbsBitmap* sourceOver   = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
   718 	CFbsBitmap* sourceAlpha  = CreateSoftwareBitmapLC(bitmapSize, EGray256);
   719 
   720 	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
   721 	VerticalGradientAlphaL(sourceUnder, TRgb(0xff000000), TRgb(0x00ffffff));
   722 	VerticalGradientAlphaL(sourceOver, TRgb(0x00ffffff), TRgb(0xff000000));
   723 	RDebug::Printf("DABBBT 2");
   724 
   725 	TPoint point(0,0);
   726 	TRect  rect(bitmapSize);
   727 	
   728 	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   729 	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
   730 
   731 	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   732 	bitmapGc->Clear();
   733 	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   734 	bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);		
   735 
   736 	aGc->Activate(aWindow);
   737 	aGc->BitBlt(point, bitmapTarget);
   738 	aGc->Deactivate();
   739 	aSession.Flush();
   740 
   741 	iProfiler->InitResults();
   742 	// blend sourceUnder with sourceOver using alpha mask
   743 	for(TInt i=0; i<aNumIterations; i++)
   744 	{
   745 		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   746 		bitmapGc->Clear();
   747 		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   748 		bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);
   749 		iProfiler->MarkResultSetL();
   750 	}
   751 	iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
   752 	
   753 	// copy up to screen for sanity check
   754 	BitBlt(aSession, aWindow, aGc, *bitmapTarget);	
   755 	CleanupStack::PopAndDestroy(6, bitmapTarget); // sourceAlpha, sourceOver, sourceUnder, bitmapGc, bitmapDevice, bitmapTarget
   756 	}	
   757 	
   758 /**
   759 Draws a stretched bitmap with or without a mask.
   760 
   761 @param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha.
   762 @param aSrcMode is the source display mode
   763 @param aDstMode is the destination display mode
   764 @param aSession is the windows server session
   765 @param aWindow is a reference to the window
   766 @param aGc is the graphics context of the window
   767 @param aNumIterations is the number of iterations to run the test
   768 */
   769 void CAlphaBlendTest::DoDrawBitmapL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
   770 	{		
   771 	const TSize bitmapSize = aWindow.Size();
   772 	
   773 	// Construct target bitmap.
   774 	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
   775 	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
   776 	CleanupStack::PushL(bitmapDevice);
   777 	
   778 	// Construct GC.
   779 	CFbsBitGc* bitmapGc = NULL;
   780 	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
   781 	CleanupStack::PushL(bitmapGc);
   782 	
   783 	// Construct source bitmap.	
   784 	TSize smallerSize(bitmapSize.iWidth/2,  bitmapSize.iHeight/2);
   785 	CFbsBitmap* source = CreateSoftwareBitmapLC(smallerSize, aSrcMode);
   786 	VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff));	
   787 	CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(smallerSize, EGray256);	// match size to src
   788 	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
   789 		
   790 	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   791 	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
   792 	bitmapGc->Clear();
   793 	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   794 	aGc->Activate(aWindow);
   795 	TPoint point(0,0);
   796 	bitmapGc->BitBlt(point, bitmapTarget);
   797 	aGc->Deactivate();
   798 	aSession.Flush();
   799 
   800 	TBuf <20> testName;
   801 	if (!aUseMask)
   802 		{
   803 		testName=_L("DrawBitmap");
   804 		iProfiler->InitResults();
   805 		for(int i=0; i<aNumIterations; i++)
   806 			{
   807 			bitmapGc->DrawBitmap(TRect(point, bitmapSize), source);
   808 			iProfiler->MarkResultSetL();
   809 			}
   810 		}
   811 	else
   812 		{
   813 		testName=_L("DrawBitmapMasked");
   814 		iProfiler->InitResults();
   815 		for(int i=0; i<aNumIterations; i++)
   816 			{
   817 			bitmapGc->DrawBitmapMasked(TRect(point, bitmapSize), source,TRect(point, smallerSize), sourceAlpha, EFalse);
   818 			iProfiler->MarkResultSetL();
   819 			}
   820 		}
   821 	INFO_PRINTF4(_L("%S(Stretched) with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode));
   822 	iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations);
   823 	// copy up to screen for sanity check
   824 	BitBlt(aSession, aWindow, aGc, *bitmapTarget);
   825 	CleanupStack::PopAndDestroy(5, bitmapTarget);
   826 	}
   827 
   828 /**
   829 Performs a BitBlt with or without a mask
   830 
   831 @param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha.
   832 @param aSrcMode is the source display mode
   833 @param aDstMode is the destination display mode
   834 @param aSession is the windows server session
   835 @param aWindow is a reference to the window
   836 @param aGc is the graphics context of the window
   837 @param aNumIterations is the number of iterations to run the test
   838 */
   839 void CAlphaBlendTest::DoNormalBitBltL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
   840 	{	
   841 	const TSize bitmapSize = aWindow.Size();
   842 	
   843 	// Construct target bitmap
   844 	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
   845 	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
   846 	CleanupStack::PushL(bitmapDevice);
   847 	
   848 	// Construct GC
   849 	CFbsBitGc* bitmapGc = NULL;	
   850 	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
   851 	CleanupStack::PushL(bitmapGc);
   852 	
   853 	// Construct source bitmap
   854 	CFbsBitmap* source = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
   855 	VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff));	
   856 	CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256);	// match size to src
   857 	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
   858 		
   859 	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   860 	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
   861 	bitmapGc->Clear();
   862 	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   863 	TPoint point(0,0);
   864 	TRect rect(bitmapSize);
   865 	if (aUseMask)		
   866 		bitmapGc->AlphaBlendBitmaps(point, source, rect, sourceAlpha, point);		
   867 	else
   868 		bitmapGc->BitBlt(point, source);	// BitBlt source to target bitmap		
   869 	
   870 	aGc->Activate(aWindow);
   871 	aGc->BitBlt(point, bitmapTarget);	// BitBlt bitmapTarget to screen
   872 	aGc->Deactivate();
   873 	aSession.Flush();	
   874 	
   875 	TBuf <20> testName;	
   876 	if (aUseMask)
   877 		{
   878 		testName=_L("AlphaBlendBitmaps");
   879 		// blend sourceUnder with sourceOver using alpha mask
   880 		iProfiler->InitResults();		
   881 		for(TInt i=0; i<aNumIterations; i++)
   882 			{
   883 			bitmapGc->Clear();
   884 			bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
   885 			bitmapGc->AlphaBlendBitmaps(point, source, rect, sourceAlpha, point);
   886 			iProfiler->MarkResultSetL();
   887 			}
   888 		}
   889 	else
   890 		{
   891 		testName=_L("Normal BitBlt");
   892 		iProfiler->InitResults();
   893 		for(TInt i=0; i<aNumIterations; i++)
   894 			{
   895 			bitmapGc->BitBlt(point, source);
   896 			iProfiler->MarkResultSetL();
   897 			}
   898 		}
   899 
   900 	INFO_PRINTF4(_L("%S with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode));
   901 	iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations);
   902 	// copy up to screen for sanity check
   903 	BitBlt(aSession, aWindow, aGc, *bitmapTarget);
   904 	CleanupStack::PopAndDestroy(5, bitmapTarget);
   905 	}