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