os/graphics/graphicsdeviceinterface/directgdi/test/tbitblt.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-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
#include "tbitblt.h"
sl@0
    17
#include <e32const.h>
sl@0
    18
sl@0
    19
CTBitBlt::CTBitBlt()
sl@0
    20
	{
sl@0
    21
	SetTestStepName(KTDirectGdiBitBltStep);
sl@0
    22
	}
sl@0
    23
sl@0
    24
CTBitBlt::~CTBitBlt()
sl@0
    25
	{
sl@0
    26
	}
sl@0
    27
sl@0
    28
/**
sl@0
    29
Override of base class pure virtual
sl@0
    30
Lists the tests to be run
sl@0
    31
*/
sl@0
    32
void CTBitBlt::RunTestsL()
sl@0
    33
	{
sl@0
    34
	if(iUseDirectGdi && !iUseSwDirectGdi)
sl@0
    35
		{
sl@0
    36
		// In the event that a test leaves after a BitBlt() or DrawBitmap() has occurred
sl@0
    37
		// the vgimage cache will need to be reset.
sl@0
    38
		// This needs to be the first item on the cleanupstack, 
sl@0
    39
		// as some tests perform pushes and pops of bitmaps.
sl@0
    40
		CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
sl@0
    41
		}
sl@0
    42
	
sl@0
    43
	if(!iLargeTarget)
sl@0
    44
		{
sl@0
    45
		iTestParams.iDoCompressed = ETrue;
sl@0
    46
		SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0001"));
sl@0
    47
		TestBasicL();
sl@0
    48
		RecordTestResultL();
sl@0
    49
		iTestParams.iDoCompressed = EFalse;
sl@0
    50
		SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0003"));
sl@0
    51
		TestInvalidParametersL();
sl@0
    52
		RecordTestResultL();
sl@0
    53
		SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0004"));
sl@0
    54
		TestSourceBitmapCloningL();
sl@0
    55
		RecordTestResultL();
sl@0
    56
		SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0005"));
sl@0
    57
		TestDrawModeL();
sl@0
    58
		RecordTestResultL();
sl@0
    59
		SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0006"));
sl@0
    60
		TestSetOriginL();
sl@0
    61
		RecordTestResultL();
sl@0
    62
		}
sl@0
    63
	else
sl@0
    64
		{
sl@0
    65
		SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLT-0002"));
sl@0
    66
		TestPositioningL();
sl@0
    67
		RecordTestResultL();
sl@0
    68
		}
sl@0
    69
sl@0
    70
	if(iUseDirectGdi && !iUseSwDirectGdi)
sl@0
    71
		{
sl@0
    72
		CleanupStack::PopAndDestroy(iVgImageCache);
sl@0
    73
		}
sl@0
    74
	}
sl@0
    75
sl@0
    76
/**
sl@0
    77
@SYMTestCaseID  	
sl@0
    78
	GRAPHICS-DIRECTGDI-BITBLT-0001
sl@0
    79
	
sl@0
    80
@SYMPREQ 			
sl@0
    81
	PREQ39
sl@0
    82
	
sl@0
    83
@SYMREQ 			
sl@0
    84
	REQ9197
sl@0
    85
	REQ9204 
sl@0
    86
	REQ9195 
sl@0
    87
	REQ9201 
sl@0
    88
	REQ9202 
sl@0
    89
	REQ9222 
sl@0
    90
	REQ9223 
sl@0
    91
	REQ9236 
sl@0
    92
	REQ9237 
sl@0
    93
	
sl@0
    94
@SYMTestCaseDesc	
sl@0
    95
	Bit blitting basic functionality.
sl@0
    96
	
sl@0
    97
@SYMTestPriority	
sl@0
    98
	Critical
sl@0
    99
	
sl@0
   100
@SYMTestStatus 		
sl@0
   101
	Implemented
sl@0
   102
	
sl@0
   103
@SYMTestActions 	
sl@0
   104
	Test bit blitting with basic and valid parameters. The test sets an origin that is not 0,0
sl@0
   105
	and does a single BitBlt() to a position offscreen that will be moved back onscreen due to the previously
sl@0
   106
	set origin. The image should appear at 20,20.
sl@0
   107
	
sl@0
   108
@SYMTestExpectedResults 
sl@0
   109
	Source bitmap should be copied into target area. Valid bitmap should be created. 
sl@0
   110
	This bitmap should be the same as a reference bitmap.
sl@0
   111
*/
sl@0
   112
void CTBitBlt::TestBasicL()
sl@0
   113
	{	
sl@0
   114
	_LIT(KTestName, "BitBlt-Basic"); 	
sl@0
   115
	
sl@0
   116
	// Only do the compressed version of this test for one pixel format
sl@0
   117
	// to cut down on the number of images produced.
sl@0
   118
	TBool writeOutCompressed = (iTestParams.iDoCompressed && (iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565));	
sl@0
   119
					
sl@0
   120
	if(!iRunningOomTests)
sl@0
   121
		{		
sl@0
   122
		INFO_PRINTF1(KTestName);		
sl@0
   123
		}
sl@0
   124
sl@0
   125
	ResetGc();
sl@0
   126
sl@0
   127
	CFbsBitmap* bitmap;
sl@0
   128
	if(iTestParams.iDoCompressed)
sl@0
   129
		{
sl@0
   130
		bitmap = iCompressedBitmap;
sl@0
   131
		}
sl@0
   132
	else
sl@0
   133
		{
sl@0
   134
		bitmap = iCheckedBoardBitmap2;
sl@0
   135
		}
sl@0
   136
	
sl@0
   137
	iGc->BitBlt(TPoint(20, 20), *bitmap);
sl@0
   138
	TESTNOERRORL(iGc->GetError());	
sl@0
   139
	
sl@0
   140
	if (!iTestParams.iDoCompressed || writeOutCompressed)
sl@0
   141
		WriteTargetOutput(KTestName());
sl@0
   142
	}
sl@0
   143
sl@0
   144
/**
sl@0
   145
@SYMTestCaseID  	
sl@0
   146
	GRAPHICS-DIRECTGDI-BITBLT-0002
sl@0
   147
	
sl@0
   148
@SYMPREQ 			
sl@0
   149
	PREQ39
sl@0
   150
sl@0
   151
@SYMREQ 			
sl@0
   152
	REQ9197
sl@0
   153
	REQ9198
sl@0
   154
	REQ9204 
sl@0
   155
	REQ9195 
sl@0
   156
	REQ9201 
sl@0
   157
	REQ9202 
sl@0
   158
	REQ9222 
sl@0
   159
	REQ9223 
sl@0
   160
	REQ9236 
sl@0
   161
	REQ9237	
sl@0
   162
	
sl@0
   163
@SYMTestCaseDesc	
sl@0
   164
	Various combinations of destination positions, source position and size 
sl@0
   165
	of a bitmap are tested. This test also covers boundary position and size.
sl@0
   166
	
sl@0
   167
@SYMTestPriority	
sl@0
   168
	Critical
sl@0
   169
	
sl@0
   170
@SYMTestStatus 		
sl@0
   171
	Implemented
sl@0
   172
	
sl@0
   173
@SYMTestActions 	
sl@0
   174
	Bitmap positioning in a target area, for boundary position, and for clipping 
sl@0
   175
	to target area.
sl@0
   176
	
sl@0
   177
@SYMTestExpectedResults 
sl@0
   178
	Various parts of source bitmap should be copied into target area at
sl@0
   179
	various positions. Parts of source bitmap that go beyond a target area
sl@0
   180
	should be clipped. Valid bitmap should be created. This bitmap should
sl@0
   181
	be the same as a reference bitmap.
sl@0
   182
*/
sl@0
   183
void CTBitBlt::TestPositioningL()
sl@0
   184
	{	
sl@0
   185
	_LIT(KTestName, "BitBlt-Positioning"); 
sl@0
   186
	if(!iRunningOomTests)
sl@0
   187
		{
sl@0
   188
		INFO_PRINTF1(KTestName);
sl@0
   189
		}
sl@0
   190
	iTestParams.iDoCompressed = ETrue;
sl@0
   191
	TestPositioningBaseL(KTestName(), EBitBlt);
sl@0
   192
	iTestParams.iDoCompressed = EFalse;
sl@0
   193
	TestPositioningBaseL(KTestName(), EBitBlt);
sl@0
   194
	}
sl@0
   195
sl@0
   196
/**
sl@0
   197
@SYMTestCaseID  	
sl@0
   198
	GRAPHICS-DIRECTGDI-BITBLT-0003
sl@0
   199
	
sl@0
   200
@SYMPREQ 			
sl@0
   201
	PREQ39
sl@0
   202
sl@0
   203
@SYMREQ 			
sl@0
   204
	REQ9197
sl@0
   205
	REQ9198
sl@0
   206
	REQ9204 
sl@0
   207
	REQ9195 
sl@0
   208
	REQ9222 
sl@0
   209
	REQ9223 
sl@0
   210
	REQ9236 
sl@0
   211
	REQ9237
sl@0
   212
	
sl@0
   213
@SYMTestCaseDesc	
sl@0
   214
	Calling BitBlt() method with invalid parameters
sl@0
   215
	
sl@0
   216
@SYMTestPriority	
sl@0
   217
	Critical
sl@0
   218
	
sl@0
   219
@SYMTestStatus 		
sl@0
   220
	Implemented
sl@0
   221
	
sl@0
   222
@SYMTestActions 	
sl@0
   223
	Set valid parameters (see BitBlt-Basic). Invoke the BitBlt() method replacing valid parameters with invalid equivalent. Create separate tests for horizontal and vertical coordinates.
sl@0
   224
	Invalid parameters:
sl@0
   225
	    Invalid source rectangles:
sl@0
   226
			- TRect(-30, -30, -10, -10);
sl@0
   227
			- TRect(bmpWidth+10, bmpHeight+10, bmpWidth+20, bmpHeight+20));
sl@0
   228
			- TRect(bmpWidth, bmpHeight, 0, 0));
sl@0
   229
			- TRect(-10, -10, -30, -30);
sl@0
   230
			- TRect(0, 0, 0, 0));    
sl@0
   231
	    Invalid source bitmaps:
sl@0
   232
			- zero size bitmap
sl@0
   233
			- not initialized bitmap
sl@0
   234
sl@0
   235
			
sl@0
   236
@SYMTestExpectedResults 
sl@0
   237
	Function should detect invalid parameters and return.
sl@0
   238
	Nothing should be drawn in a target area.
sl@0
   239
*/
sl@0
   240
void CTBitBlt::TestInvalidParametersL()
sl@0
   241
	{	
sl@0
   242
	_LIT(KTestName, "BitBlt-InvalidParameters"); 
sl@0
   243
	if(!iRunningOomTests)
sl@0
   244
		{
sl@0
   245
		INFO_PRINTF1(KTestName);
sl@0
   246
		}
sl@0
   247
	TestInvalidParametersBaseL(KTestName(), EBitBlt);
sl@0
   248
	}
sl@0
   249
sl@0
   250
/**
sl@0
   251
@SYMTestCaseID  	
sl@0
   252
	GRAPHICS-DIRECTGDI-BITBLT-0004
sl@0
   253
	
sl@0
   254
@SYMPREQ 			
sl@0
   255
	PREQ39
sl@0
   256
sl@0
   257
@SYMREQ 			
sl@0
   258
	REQ9197
sl@0
   259
	REQ9204 
sl@0
   260
	REQ9195 
sl@0
   261
	REQ9201 
sl@0
   262
	REQ9202 
sl@0
   263
	REQ9222 
sl@0
   264
	REQ9223 
sl@0
   265
	REQ9236 
sl@0
   266
	REQ9237
sl@0
   267
	
sl@0
   268
@SYMTestCaseDesc	
sl@0
   269
	Tests that the source bitmap is drawn correctly if it is deleted in the 
sl@0
   270
	test code right after BitBlt() is called, but before Finish() is called and 
sl@0
   271
	the image is actually drawn by the engine.
sl@0
   272
	
sl@0
   273
@SYMTestPriority	
sl@0
   274
	Critical
sl@0
   275
	
sl@0
   276
@SYMTestStatus 		
sl@0
   277
	Implemented
sl@0
   278
	
sl@0
   279
@SYMTestActions 	
sl@0
   280
	1. Invoke the BitBlt() method with valid parameters (see BitBlt-Basic). 
sl@0
   281
	2. Right after returning from BitBlt() call, destroy the source Bitmap (aBitmap).
sl@0
   282
	3. Call the BitBlt() method again with the same bitmap parameter.
sl@0
   283
	Repeat p. 1-3 a few times.#
sl@0
   284
	
sl@0
   285
@SYMTestExpectedResults 
sl@0
   286
	Source bitmap should be copied into target area. Memory leaks should not be
sl@0
   287
	created. Valid bitmap should be created. This bitmap should be the same as
sl@0
   288
	a reference bitmap.
sl@0
   289
*/
sl@0
   290
void CTBitBlt::TestSourceBitmapCloningL()
sl@0
   291
	{
sl@0
   292
	_LIT(KTestName, "BitBlt-SourceBitmapCloning"); 
sl@0
   293
	if(!iRunningOomTests)
sl@0
   294
		{
sl@0
   295
		INFO_PRINTF1(KTestName);
sl@0
   296
		}
sl@0
   297
	iTestParams.iDoCompressed = ETrue;
sl@0
   298
	TestSourceBitmapCloningBaseL(KTestName(), EBitBlt);
sl@0
   299
	iTestParams.iDoCompressed = EFalse;
sl@0
   300
	TestSourceBitmapCloningBaseL(KTestName(), EBitBlt);
sl@0
   301
	}
sl@0
   302
sl@0
   303
/**
sl@0
   304
@SYMTestCaseID  	
sl@0
   305
	GRAPHICS-DIRECTGDI-BITBLT-0005
sl@0
   306
	
sl@0
   307
@SYMPREQ 			
sl@0
   308
	PREQ39
sl@0
   309
sl@0
   310
@SYMREQ 			
sl@0
   311
	REQ9198
sl@0
   312
	REQ9204 
sl@0
   313
	REQ9195 
sl@0
   314
	REQ9201 
sl@0
   315
	REQ9202 
sl@0
   316
	REQ9222 
sl@0
   317
	REQ9223 
sl@0
   318
	REQ9236 
sl@0
   319
	REQ9237
sl@0
   320
	
sl@0
   321
@SYMTestCaseDesc	
sl@0
   322
	Test correctness of bit blitting in all possible draw modes.
sl@0
   323
	
sl@0
   324
@SYMTestPriority	
sl@0
   325
	Critical
sl@0
   326
	
sl@0
   327
@SYMTestStatus 		
sl@0
   328
	Implemented
sl@0
   329
	
sl@0
   330
@SYMTestActions 	
sl@0
   331
	Set valid parameters (see BitBlt-Basic).
sl@0
   332
	Use the semi-transparent source bitmap (aBitmap).
sl@0
   333
	Set drawmode to EDrawModeWriteAlpha and call the methods.
sl@0
   334
	Set drawmode to EDrawModePEN and call the methods.
sl@0
   335
	Set drawmode to EDrawModeWriteAlpha and call the methods.
sl@0
   336
	
sl@0
   337
@SYMTestExpectedResults 
sl@0
   338
	Semi-transparent (for EDrawModePEN) and opaque (for EDrawModeWriteAlpha)
sl@0
   339
	should be copied into rendering target, that is, the left and the right 
sl@0
   340
	bitmaps in the test should be drawn opaque, and the center bitmap in the 
sl@0
   341
	test should be draw blended. Valid bitmap should be created.
sl@0
   342
	This bitmap should be the same as a reference bitmap.
sl@0
   343
*/
sl@0
   344
void CTBitBlt::TestDrawModeL()
sl@0
   345
	{
sl@0
   346
	_LIT(KTestName, "BitBlt-DrawMode"); 
sl@0
   347
	if(!iRunningOomTests)
sl@0
   348
		{
sl@0
   349
		INFO_PRINTF1(KTestName);
sl@0
   350
		}
sl@0
   351
	ResetGc();
sl@0
   352
sl@0
   353
	TSize bmpSize(iCheckedBoardWithAlphaBitmap->SizeInPixels());
sl@0
   354
sl@0
   355
	TInt halfHeight = (bmpSize.iHeight  >> 1);	
sl@0
   356
	TInt quaterWidth  = (bmpSize.iWidth  >> 2);
sl@0
   357
	TInt y1 = halfHeight - (bmpSize.iHeight >> 2);
sl@0
   358
	TSize vertRectSize  (quaterWidth, bmpSize.iHeight);
sl@0
   359
	TSize horizRectSize (bmpSize.iWidth, halfHeight);
sl@0
   360
	
sl@0
   361
	// Render column to left
sl@0
   362
	iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
sl@0
   363
	iGc->BitBlt(
sl@0
   364
		TPoint(0, 0), 
sl@0
   365
		*iCheckedBoardWithAlphaBitmap, 
sl@0
   366
		TRect(TPoint(0, 0), vertRectSize));
sl@0
   367
sl@0
   368
	// Render row in center
sl@0
   369
	iGc->SetDrawMode(DirectGdi::EDrawModePEN);
sl@0
   370
	iGc->BitBlt(
sl@0
   371
		TPoint(0, y1),
sl@0
   372
		*iCheckedBoardWithAlphaBitmap,
sl@0
   373
		TRect(TPoint(0, 0), horizRectSize));
sl@0
   374
sl@0
   375
	// Render column to right
sl@0
   376
	iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
sl@0
   377
	iGc->BitBlt(
sl@0
   378
		TPoint(bmpSize.iWidth - quaterWidth, 0),  
sl@0
   379
		*iCheckedBoardWithAlphaBitmap, 
sl@0
   380
		TRect(TPoint(0, 0), vertRectSize));
sl@0
   381
	
sl@0
   382
	TESTNOERRORL(iGc->GetError());
sl@0
   383
sl@0
   384
	WriteTargetOutput(KTestName());
sl@0
   385
	}
sl@0
   386
sl@0
   387
/**
sl@0
   388
@SYMTestCaseID  	
sl@0
   389
	GRAPHICS-DIRECTGDI-BITBLT-0006
sl@0
   390
	
sl@0
   391
@SYMPREQ 			
sl@0
   392
	PREQ39
sl@0
   393
sl@0
   394
@SYMREQ
sl@0
   395
	REQ9199 
sl@0
   396
	REQ9204 
sl@0
   397
	REQ9195
sl@0
   398
	REQ9201 
sl@0
   399
	REQ9202 
sl@0
   400
	REQ9222 
sl@0
   401
	REQ9223 
sl@0
   402
	REQ9236 
sl@0
   403
	REQ9237
sl@0
   404
	
sl@0
   405
@SYMTestCaseDesc	
sl@0
   406
	Test that a bitmap is drawn at the correct position when SetOrigin() is called before
sl@0
   407
	the bitmap is blitted.
sl@0
   408
	
sl@0
   409
@SYMTestPriority	
sl@0
   410
	Critical
sl@0
   411
	
sl@0
   412
@SYMTestStatus 		
sl@0
   413
	Implemented
sl@0
   414
	
sl@0
   415
@SYMTestActions 	
sl@0
   416
	Call SetOrigin().
sl@0
   417
	Call BitBlt().
sl@0
   418
	
sl@0
   419
@SYMTestExpectedResults 
sl@0
   420
	Source bitmap should be drawn at the correct position (TPoint(20,20)). Valid bitmap 
sl@0
   421
	should be created. This bitmap shall be compared to a reference bitmap.
sl@0
   422
*/
sl@0
   423
void CTBitBlt::TestSetOriginL()
sl@0
   424
	{	
sl@0
   425
	_LIT(KTestName, "BitBlt-SetOrigin");
sl@0
   426
	
sl@0
   427
	// Only do test for one pixel format to cut down on the number of images produced
sl@0
   428
	// as this is just a positional test and we don't need to test for all pixel formats.
sl@0
   429
	if (!((iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565) && (iTestParams.iSourcePixelFormat == EUidPixelFormatRGB_565)))
sl@0
   430
		{
sl@0
   431
		return;
sl@0
   432
		}
sl@0
   433
	
sl@0
   434
	if(!iRunningOomTests)
sl@0
   435
		{		
sl@0
   436
		INFO_PRINTF1(KTestName);		
sl@0
   437
		}
sl@0
   438
sl@0
   439
	ResetGc();
sl@0
   440
sl@0
   441
	CFbsBitmap* bitmap = iCheckedBoardBitmap2;	
sl@0
   442
	
sl@0
   443
	iGc->SetOrigin(TPoint(-35, 80));
sl@0
   444
	iGc->BitBlt(TPoint(55, -60), *bitmap);
sl@0
   445
	TESTNOERRORL(iGc->GetError());	
sl@0
   446
		
sl@0
   447
	WriteTargetOutput(KTestName());
sl@0
   448
	}