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