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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "tbitbltmasked.h"
18 CTBitBltMasked::CTBitBltMasked()
20 SetTestStepName(KTDirectGdiBitBltMaskedStep);
23 CTBitBltMasked::~CTBitBltMasked()
28 Override of base class pure virtual
29 Lists the tests to be run
31 void CTBitBltMasked::RunTestsL()
33 if(iUseDirectGdi && !iUseSwDirectGdi)
35 // In the event that a test leaves after a BitBlt() or DrawBitmap() has occurred
36 // the vgimage cache will need to be reset.
37 // This needs to be the first item on the cleanupstack,
38 // as some tests perform pushes and pops of bitmaps.
39 CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
43 // to minimize tests call number these tests are processed only for one mask
46 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0003"));
47 TestInvalidParametersL();
49 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0004"));
50 TestSourceBitmapCloningL();
52 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0005"));
60 iTestParams.iDoCompressed = ETrue;
61 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0001"));
64 iTestParams.iDoCompressed = EFalse;
65 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0006"));
68 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0007"));
69 TestWithSameBitmapsL();
71 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0008"));
77 SetTestStepID(_L("GRAPHICS-DIRECTGDI-BITBLTMASKED-0002"));
82 while(NextMaskIteration());
84 if(iUseDirectGdi && !iUseSwDirectGdi)
86 CleanupStack::PopAndDestroy(iVgImageCache);
92 GRAPHICS-DIRECTGDI-BITBLTMASKED-0001
109 Bit blitting with masking basic functionality.
118 Test bit blitting with masking for basic and valid parameters.
120 @SYMTestExpectedResults
121 Source bitmap should be copied into target area. Basic or inverted
122 masking should be considered. Valid bitmap should be created. This
123 bitmap should be the same as a reference bitmap.
125 void CTBitBltMasked::TestBasicL()
127 _LIT(KTestName, "BitBltMasked-Basic");
128 _LIT(KTestNameNegative, "BitBltMasked-Basic-NegativeMaskPosition");
129 if(!iRunningOomTests)
131 INFO_PRINTF1(KTestName);
137 if(iTestParams.iDoCompressed)
139 bitmap = iCompressedBitmap;
140 mask = iCompressedMaskL8;
144 bitmap = iCheckedBoardBitmap2;
145 mask = iCurrentMask1;
148 TRect bmpRect(TPoint(0, 0), bitmap->SizeInPixels());
149 if(iMaskPixelFormat == EUidPixelFormatL_1)
151 iGc->BitBltMasked(TPoint(20, 20), *bitmap, bmpRect, *mask, iInvertMask);
152 iGc->BitBltMasked(TPoint(20, 20), *bitmap, bmpRect, *mask, ETrue);
156 iGc->BitBltMasked(TPoint(20, 20), *bitmap, bmpRect, *mask, TPoint(0, 0));
158 TESTNOERROR(iGc->GetError());
159 if(!iTestParams.iDoCompressed)
160 WriteTargetOutput(KTestName());
162 // negative mask position
163 iGc->BitBltMasked(TPoint(-35, 180), *bitmap, bmpRect, *iMask1L8, TPoint(-1, -1));
164 TESTNOERROR(iGc->GetError());
166 // mask position greater than mask size
167 iGc->BitBltMasked(TPoint(-35, 200), *bitmap, bmpRect, *iMask1L8, iMask1L8->SizeInPixels().AsPoint());
168 CheckErrorsL(KErrNone, KErrArgument, (TText8*)__FILE__, __LINE__);
170 if(!iTestParams.iDoCompressed)
171 TESTNOERRORL(WriteTargetOutput(KTestNameNegative()));
176 GRAPHICS-DIRECTGDI-BITBLTMASKED-0002
194 Various combinations of destination positions, source position and size
195 of a bitmap are tested. Test also covers mask alignment, tiling and boundary
205 Covers the whole target bitmap starting from TPoint(-30,-30) with staggered blits of a small 8x8 bitmap.
206 Test positioning functionality of BitBltMasked() methods. Test boundary
207 conditions, tiling and clipping to surface area.
209 @SYMTestExpectedResults
211 void CTBitBltMasked::TestPositioningL()
213 _LIT(KTestName, "BitBltMasked-Positioning");
214 if(!iRunningOomTests)
216 INFO_PRINTF1(KTestName);
218 iTestParams.iDoCompressed = ETrue;
219 TestPositioningBaseL(KTestName(), EBitBltMasked);
220 iTestParams.iDoCompressed = EFalse;
221 TestPositioningBaseL(KTestName(), EBitBltMasked);
226 GRAPHICS-DIRECTGDI-BITBLTMASKED-0003
242 Calling BitBltMasked() method with invalid parameters
252 - TRect(-30, -30, -10, -10);
253 - TRect(bmpWidth+10, bmpHeight+10, bmpWidth+20, bmpHeight+20);
254 - TRect(bmpWidth, bmpHeight, 0, 0);
255 - TRect(-10, -10, -30, -30);
257 Invalid mask (aMaskBitmap):
259 - not initialized mask
260 Mask position greater than mask size: aMaskPt = TPoint(mask_width, mask_height)
261 Invalid source bitmap:
263 - not initialised bitmap
265 @SYMTestExpectedResults
266 Function should detect invalid parameters and return. Nothing should be drawn
269 void CTBitBltMasked::TestInvalidParametersL()
271 _LIT(KTestName, "BitBltMasked-InvalidParameters");
272 if(!iRunningOomTests)
274 INFO_PRINTF1(KTestName);
276 TestInvalidParametersBaseL(KTestName(), EBitBltMasked);
281 GRAPHICS-DIRECTGDI-BITBLTMASKED-0004
298 Tests that masked bitmaps are drawn correctly if they
299 are deleted immediately after BitBltMasked() is called, but before Finish() is called.
308 Set valid mask parameters (see BitBltMasked-Basic).
309 For test description see BitBlt-SourceBitmapCloning.
311 @SYMTestExpectedResults
312 Source bitmap should be copied into target area. Memory leaks should not
313 be created. Valid bitmap should be created. This bitmap should be
314 the same as a reference bitmap.
316 void CTBitBltMasked::TestSourceBitmapCloningL()
318 _LIT(KTestName, "BitBltMasked-SourceBitmapCloning");
319 if(!iRunningOomTests)
321 INFO_PRINTF1(KTestName);
323 iTestParams.iDoCompressed = ETrue;
324 TestSourceBitmapCloningBaseL(KTestName(), EBitBltMasked);
325 iTestParams.iDoCompressed = EFalse;
326 TestSourceBitmapCloningBaseL(KTestName(), EBitBltMasked);
331 GRAPHICS-DIRECTGDI-BITBLTMASKED-0005
348 Tests that masked bitmaps are drawn correctly if the mask
349 is deleted immediately after BitBltMasked() is called, but before Finish() is called.
358 1. Invoke the BitBltMasked() method with valid parameters (see BitBltMasked-Basic).
359 2. Right after returning from BitBltMasked() call, destroy the source mask (aMaskBitmap).
360 3. Call the BitBltMasked() method again with the same mask parameter.
361 Repeat p. 1-3 a few times.
363 @SYMTestExpectedResults
364 Source bitmap should be copied into target area and should be correctly masked.
365 Memory leaks should not be created. Valid bitmap should be created. This bitmap
366 should be the same as a reference bitmap.
368 void CTBitBltMasked::TestMaskCloningL()
370 _LIT(KTestName, "BitBltMasked-MaskCloning");
371 if(!iRunningOomTests)
373 INFO_PRINTF1(KTestName);
375 iTestParams.iDoCompressed = ETrue;
376 TestMaskCloningBaseL(KTestName(), EBitBltMasked);
377 iTestParams.iDoCompressed = EFalse;
378 TestMaskCloningBaseL(KTestName(), EBitBltMasked);
383 GRAPHICS-DIRECTGDI-BITBLTMASKED-0006
400 Test correctness of bit blitting with mask in all possible draw modes.
409 Set valid parameters (see BitBltMasked-Basic).
410 Use the semi-transparent source bitmap (iCheckedBoardWithAlphaBitmap).
411 Set drawmode to EDrawModePEN and call the methods.
412 Set drawmode to EDrawModeWriteAlpha and call the methods.
414 @SYMTestExpectedResults
415 Semi-transparent (for EDrawModePEN) and opaque (for EDrawModeWriteAlpha)
416 should be copied into rendering target. Valid bitmap should be created.
417 This bitmap should be the same as a reference bitmap.
419 void CTBitBltMasked::TestDrawModeL()
421 _LIT(KTestName, "BitBltMasked-DrawMode");
422 if(!iRunningOomTests)
424 INFO_PRINTF1(KTestName);
428 TSize bmpSize(iCheckedBoardWithAlphaBitmap->SizeInPixels());
430 TInt halfHeight = (bmpSize.iHeight >> 1);
431 TInt quarterWidth = (bmpSize.iWidth >> 2);
432 TInt y1 = halfHeight - (bmpSize.iHeight >> 2);
433 TSize vertRectSize (quarterWidth, bmpSize.iHeight);
434 TSize horizRectSize (bmpSize.iWidth, halfHeight);
436 // EDrawModeWriteAlpha is not supported in the following modes
437 // This is tested under invalid parameter tests.
438 if (!((iMaskPixelFormat == EUidPixelFormatL_8) &&
439 ((iTestParams.iSourcePixelFormat == EUidPixelFormatARGB_8888) ||
440 (iTestParams.iSourcePixelFormat == EUidPixelFormatARGB_8888_PRE))))
442 // Render column to left
443 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
446 *iCheckedBoardWithAlphaBitmap,
447 TRect(TPoint(0, 0), vertRectSize),
452 // Render row in center
453 iGc->SetDrawMode(DirectGdi::EDrawModePEN);
456 *iCheckedBoardWithAlphaBitmap,
457 TRect(TPoint(0, 0), horizRectSize),
461 // EDrawModeWriteAlpha is not supported in the following modes
462 // This is tested under invalid parameter tests.
463 if (!((iMaskPixelFormat == EUidPixelFormatL_8) &&
464 ((iTestParams.iSourcePixelFormat == EUidPixelFormatARGB_8888) ||
465 (iTestParams.iSourcePixelFormat == EUidPixelFormatARGB_8888_PRE))))
467 // Render column to right
468 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
470 TPoint(bmpSize.iWidth - quarterWidth, 0),
471 *iCheckedBoardWithAlphaBitmap,
472 TRect(TPoint(0, 0), vertRectSize),
477 TESTNOERRORL(iGc->GetError());
479 TESTNOERRORL(WriteTargetOutput(KTestName()));
484 GRAPHICS-DIRECTGDI-BITBLTMASKED-0007
501 Test the basic functionality of bit blitting with masking.
510 Test bit blitting with masking for same source and mask bitmaps.
512 @SYMTestExpectedResults
513 Source bitmap should be copied into target area. Basic or inverted
514 masking should be considered. Valid bitmap should be created. This
515 bitmap should be the same as a reference bitmap.
517 void CTBitBltMasked::TestWithSameBitmapsL()
519 _LIT(KTestName, "BitBltMasked-SameBitmaps");
521 TRect bmpRect1(TPoint(0, 0), iBlackWhiteBitmap->SizeInPixels());
522 iGc->SetOrigin(TPoint(30, 30));
523 iGc->BitBltMasked(TPoint(0, 0), *iBlackWhiteBitmap, bmpRect1, *iBlackWhiteBitmap, ETrue);
524 iGc->BitBltMasked(TPoint(0, 0), *iBlackWhiteBitmap, bmpRect1, *iBlackWhiteBitmap, EFalse);
525 TESTNOERRORL(iGc->GetError());
526 //Write target only if image is not empty. BitGDI is producing white images when Mask pixel format is EUidPixelFormatL_8
527 TBool pass = TestTargetL(KRgbWhite);
530 TESTNOERRORL(WriteTargetOutput(KTestName()));
536 GRAPHICS-DIRECTGDI-BITBLTMASKED-0008
553 Test that BitBltMasked() performs correctly when it is called after SetOrigin().
565 @SYMTestExpectedResults
566 Source bitmap should be copied into target area. Basic or inverted
567 masking should be considered. Valid bitmap should be created. This
568 bitmap should be the same as a reference bitmap.
570 void CTBitBltMasked::TestSetOriginL()
572 _LIT(KTestName, "BitBltMasked-SetOrigin");
573 _LIT(KTestNameNegative, "BitBltMasked-SetOrigin-NegativeMaskPosition");
575 // Only do test for one pixel format to cut down on the number of images produced
576 // as this is just a positional test and we don't need to test for all pixel formats.
577 if (!((iTestParams.iTargetPixelFormat == EUidPixelFormatRGB_565) && (iTestParams.iSourcePixelFormat == EUidPixelFormatRGB_565)))
582 if(!iRunningOomTests)
584 INFO_PRINTF1(KTestName);
588 CFbsBitmap* bitmap = iCheckedBoardBitmap2;
589 CFbsBitmap* mask = iCurrentMask1;
591 TRect bmpRect(TPoint(0, 0), bitmap->SizeInPixels());
592 iGc->SetOrigin(TPoint(-35, 80));
593 if(iMaskPixelFormat == EUidPixelFormatL_1)
595 iGc->BitBltMasked(TPoint(55, -60), *bitmap, bmpRect, *mask, iInvertMask);
596 iGc->BitBltMasked(TPoint(55, -60), *bitmap, bmpRect, *mask, ETrue);
600 iGc->BitBltMasked(TPoint(55, -60), *bitmap, bmpRect, *mask, TPoint(0, 0));
602 TESTNOERROR(iGc->GetError());
603 TESTNOERRORL(WriteTargetOutput(KTestName()));
605 // negative mask position
606 iGc->BitBltMasked(TPoint(0, 100), *bitmap, bmpRect, *iMask1L8, TPoint(-1, -1));
607 TESTNOERROR(iGc->GetError());
609 // mask position greater than mask size
610 iGc->BitBltMasked(TPoint(0, 120), *bitmap, bmpRect, *iMask1L8, iMask1L8->SizeInPixels().AsPoint());
611 CheckErrorsL(KErrNone, KErrArgument, (TText8*)__FILE__, __LINE__);
613 TESTNOERRORL(WriteTargetOutput(KTestNameNegative()));