First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
23 #include "talphablend.h"
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.
31 _LIT(KFontTypeface,"DejaVu Sans Condensed");
33 // We have two overloads of this test, the normal version that runs all tests except...
36 CAlphaBlendTestNormal::CAlphaBlendTestNormal()
38 SetTestStepName(KAlphaBlendTest);
41 TVerdict CAlphaBlendTestNormal::doTestStepL()
43 return(CAlphaBlendTest::doTestStepL(EFalse));
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:
50 ..\iType\binaries\ityperast install
52 and to remove them and swich back to normal
54 ..\iType\binaries\ityperast uninstall
57 CAlphaBlendTestIType::CAlphaBlendTestIType()
59 SetTestStepName(KAlphaBlendTestIType);
62 TVerdict CAlphaBlendTestIType::doTestStepL()
64 return(CAlphaBlendTest::doTestStepL(ETrue));
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.
72 @return - TVerdict code
74 TVerdict CAlphaBlendTest::doTestStepL(TBool aIType)
77 User::LeaveIfError(wsSession.Connect());
78 CleanupClosePushL(wsSession);
81 // Uncomment to debug WSERV redraw problems.
82 // wsSession.SetAutoFlush(ETrue);
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);
92 group = RWindowGroup(wsSession);
93 CleanupClosePushL(group);
94 User::LeaveIfError(group.Construct(1, EFalse));
97 background = RWindow(wsSession);
98 CleanupClosePushL(background);
99 User::LeaveIfError(background.Construct(group, 2));
102 window = RWindow(wsSession);
103 CleanupClosePushL(window);
104 User::LeaveIfError(window.Construct(group, 3));
106 TSize windowSize = windowDevice->SizeInPixels();
107 TDisplayMode windowMode = windowDevice->DisplayMode();
109 background.Activate();
110 background.Invalidate();
112 ClearWindow(wsSession, background, windowGc, BLACK_SEMI_TRANSPARENT);
113 ClearWindow(wsSession, window, windowGc, BLACK_SEMI_TRANSPARENT);
115 window.SetTransparencyAlphaChannel();
120 if (CheckMonoTypeInstalledL())
121 DoDrawBlendedTestsL(EBlendTestDrawTextIType,wsSession, KDrawVertTextIterationsToTest);
124 INFO_PRINTF1(_L("Monotype fonts not installed, skipping test"));
130 Test speed of blended draw rects on all modes supporting alpha blending
132 DoDrawBlendedTestsL(EBlendTestDrawRect,wsSession, KDrawRectIterationsToTest);
134 Test speed of blended draw vertical line calls on all modes supporting alpha blending
136 DoDrawBlendedTestsL(EBlendTestVerticalLine,wsSession, KDrawVertLineIterationsToTest);
138 Test speed of blended draw text calls on all modes supporting alpha blending
140 DoDrawBlendedTestsL(EBlendTestDrawText,wsSession, KDrawTextIterationsToTest);
141 DoDrawBlendedTestsL(EBlendTestDrawTextAntiAliased,wsSession, KDrawVertTextIterationsToTest);
142 DoDrawBlendedTestsL(EBlendTestDrawVerticalText,wsSession, KDrawVertTextIterationsToTest);
145 GRAPHICS-UI-BENCH-0022
148 Alphablend test BITBLT with EColor16MA source and EColor16MU destination.
151 Compare the results over time
153 @SYMTestExpectedResults
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);
163 GRAPHICS-UI-BENCH-0023
166 Test BITBLT with EColor16MA source and EColor16MU destination.
169 Compare the results over time
171 @SYMTestExpectedResults
173 RDebug::Printf("BitBlt Alpha");
174 SetTestStepID(_L("GRAPHICS-UI-BENCH-0023"));
175 DoBitBltAlphaBitmapTestL(EColor16MA, EColor16MU, wsSession, window, windowGc, KIterationsToTest);
180 GRAPHICS-UI-BENCH-0024
183 Alpha blend test BITBLT with EColor16MA source and EColor16MA destination.
186 Compare the results over time
188 @SYMTestExpectedResults
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);
198 GRAPHICS-UI-BENCH-0025
201 Test BITBLT with EColor16MA source and EColor16MA destination.
204 Compare the results over time
206 @SYMTestExpectedResults
208 RDebug::Printf("BitBlt Alpha");
209 SetTestStepID(_L("GRAPHICS-UI-BENCH-0025"));
210 DoBitBltAlphaBitmapTestL(EColor16MA, EColor16MA, wsSession, window, windowGc, KIterationsToTest);
214 GRAPHICS-UI-BENCH-0063
217 Test BITBLT with EColor16MAP source and EColor16MAP destination.
220 Compare the results over several iterations over time.
222 @SYMTestExpectedResults
224 SetTestStepID(_L("GRAPHICS-UI-BENCH-0063"));
225 DoNormalBitBltL(EFalse, EColor16MAP,EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
230 GRAPHICS-UI-BENCH-0064
233 Test BITBLT with EColor16MA source and EColor16MA destination.
236 Compare the results over several iterations over time.
238 @SYMTestExpectedResults
240 SetTestStepID(_L("GRAPHICS-UI-BENCH-0064"));
241 DoNormalBitBltL(EFalse, EColor16MA,EColor16MA, wsSession, window, windowGc, KIterationsToTest);
246 GRAPHICS-UI-BENCH-0065
249 Test BITBLT with EColor16MAP source and EColor16MA destination.
252 Compare the results over several iterations over time.
254 @SYMTestExpectedResults
256 SetTestStepID(_L("GRAPHICS-UI-BENCH-0065"));
257 DoNormalBitBltL(EFalse, EColor16MAP,EColor16MA, wsSession, window, windowGc, KIterationsToTest);
262 GRAPHICS-UI-BENCH-0066
265 Test BITBLT with EColor16MA source and EColor16MAP destination.
268 Compare the results over several iterations over time.
270 @SYMTestExpectedResults
272 SetTestStepID(_L("GRAPHICS-UI-BENCH-0066"));
273 DoNormalBitBltL(EFalse, EColor16MA,EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
278 GRAPHICS-UI-BENCH-0067
281 Test BITBLT with EColor16MU source and EColor16MU destination.
284 Compare the results over several iterations over time.
286 @SYMTestExpectedResults
288 SetTestStepID(_L("GRAPHICS-UI-BENCH-0067"));
289 DoNormalBitBltL(EFalse, EColor16MU,EColor16MU, wsSession, window, windowGc, KIterationsToTest);
294 GRAPHICS-UI-BENCH-0068
297 Test BITBLT with EColor16MAP source and EColor16MU destination.
300 Compare the results over several iterations over time.
302 @SYMTestExpectedResults
304 SetTestStepID(_L("GRAPHICS-UI-BENCH-0068"));
305 DoNormalBitBltL(EFalse, EColor16MAP,EColor16MU, wsSession, window, windowGc, KIterationsToTest);
310 GRAPHICS-UI-BENCH-0069
313 Test BITBLT with EColor16MU source and EColor16MAP destination.
316 Compare the results over several iterations over time.
318 @SYMTestExpectedResults
320 SetTestStepID(_L("GRAPHICS-UI-BENCH-0069"));
321 DoNormalBitBltL(EFalse, EColor16MU,EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
326 GRAPHICS-UI-BENCH-0070
329 Test BITBLT with EColor64K source and EColor16MU destination.
332 Compare the results over several iterations over time.
334 @SYMTestExpectedResults
336 SetTestStepID(_L("GRAPHICS-UI-BENCH-0070"));
337 DoNormalBitBltL(ETrue, EColor64K,EColor16MU, wsSession, window, windowGc, KIterationsToTest);
342 GRAPHICS-UI-BENCH-0071
345 Test DrawBitmap with different sizes (STRETCHED) with EColor16MAP source and EColor16MAP destination.
348 Compare the results over several iterations over time.
350 @SYMTestExpectedResults
352 SetTestStepID(_L("GRAPHICS-UI-BENCH-0071"));
353 DoDrawBitmapL(EFalse, EColor16MAP, EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
358 GRAPHICS-UI-BENCH-0072
361 Test DrawBitmap with different sizes (STRETCHED) with EColor16MA source and EColor16MA destination.
364 Compare the results over several iterations over time.
366 @SYMTestExpectedResults
369 SetTestStepID(_L("GRAPHICS-UI-BENCH-0072"));
370 DoDrawBitmapL(EFalse, EColor16MA, EColor16MA, wsSession, window, windowGc, KIterationsToTest);
375 GRAPHICS-UI-BENCH-0073
378 Test DrawBitmap (using alpha mask) with different sizes (STRETCHED) with EColor16MU source and EColor16MU destination.
381 Compare the results over several iterations over time.
383 @SYMTestExpectedResults
385 SetTestStepID(_L("GRAPHICS-UI-BENCH-0073"));
386 DoDrawBitmapL(ETrue, EColor16MU, EColor16MU, wsSession, window, windowGc, KIterationsToTest);
391 GRAPHICS-UI-BENCH-0057
394 Test DrawBitmap (using alpha mask) with different sizes (STRETCHED) with EColor16MAP source and EColor16MAP destination.
397 Compare the results over several iterations over time.
399 @SYMTestExpectedResults
401 SetTestStepID(_L("GRAPHICS-UI-BENCH-0057"));
402 DoDrawBitmapL(ETrue, EColor16MAP, EColor16MAP, wsSession, window, windowGc, KIterationsToTest);
405 CleanupStack::PopAndDestroy(6, &wsSession);
406 return TestStepResult();
409 void CAlphaBlendTest::DoDrawBlendedTestsL(TBlendTestFunc aTestFunc, RWsSession& aSession, TInt aNumIterations)
411 TDisplayMode blendModes[]={EColor16MAP,EColor16MA,EColor16MU,EColor64K};
412 const TInt KNumBlendTestModes=sizeof(blendModes)/sizeof(TDisplayMode);
413 for(TInt modeIndex=0;modeIndex<KNumBlendTestModes;modeIndex++)
415 DoDrawBlendedTestL(aTestFunc, 0x40, blendModes[modeIndex], aSession, aNumIterations);
416 DoDrawBlendedTestL(aTestFunc, 0xFF, blendModes[modeIndex], aSession, aNumIterations);
417 DoDrawBlendedTestL(aTestFunc, 0, blendModes[modeIndex], aSession, aNumIterations);
421 void CAlphaBlendTest::DoDrawBlendedTestL(TBlendTestFunc aTestFunc, TInt aAlpha, TDisplayMode aDisplayMode, RWsSession& aSession, TInt aNumIterations)
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.
429 testSize.iWidth=Min(devSize.iWidth,devSize.iHeight);
430 testSize.iHeight=testSize.iWidth;
432 TFontSpec testFontSpec;
433 if (aTestFunc==EBlendTestDrawTextAntiAliased || aTestFunc==EBlendTestDrawTextIType)
435 testFontSpec.iTypeface.iName=KFontTypeface;
436 if (aTestFunc==EBlendTestDrawTextAntiAliased)
438 testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
442 testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
443 testFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
444 testFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
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();
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.
459 // const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationRotated270;
460 const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationNormal;
461 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= KMaxOrientation; orient++)
463 if (orientations[orient])
465 iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
466 User::After(100000); // Let rotate sort itself out
468 iGc->SetClippingRect(TRect(testSize));
469 iGc->SetPenStyle(CGraphicsContext::ESolidPen);
470 iGc->SetBrushColor(TRgb(0x80,0x80,0xFF));
472 iGc->SetBrushColor(TRgb(10,128,240,aAlpha));
473 iGc->SetPenColor(TRgb(240,128,10,aAlpha));
474 iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
480 TSize orientatedTestSize=testSize;
482 TGlyphBitmapType checkGlyphBitmapType=EDefaultGlyphBitmap;
483 TGlyphBitmapType actualGlyphBitmapType=EDefaultGlyphBitmap;
487 case EBlendTestVerticalLine:
488 _LIT(KDrawRectVerticalLine,"DrawRectVertLine");
489 testName=KDrawRectVerticalLine;
491 case EBlendTestDrawRect:
492 _LIT(KDrawRectAlpha,"DrawRectAlpha");
493 testName=KDrawRectAlpha;
494 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
495 iGc->SetPenStyle(CGraphicsContext::ENullPen);
497 case EBlendTestDrawTextIType:
498 _LIT(KDrawTextIType,"DrawTextIT");
499 testName=KDrawTextIType;
500 testParam=testSize.iHeight;
501 checkGlyphBitmapType=EFourColourBlendGlyphBitmap;
503 case EBlendTestDrawTextAntiAliased:
504 _LIT(KDrawTextAA,"DrawTextAA");
505 testName=KDrawTextAA;
506 testParam=testSize.iHeight;
507 checkGlyphBitmapType=EAntiAliasedGlyphBitmap;
509 case EBlendTestDrawVerticalText:
510 _LIT(KDrawTextVert,"DrawTextVert");
511 orientatedTestSize.SetSize(orientatedTestSize.iHeight,orientatedTestSize.iWidth);
512 testName=KDrawTextVert;
513 testParam=testSize.iWidth;
514 checkGlyphBitmapType=EMonochromeGlyphBitmap;
516 case EBlendTestDrawText:
517 _LIT(KDrawText,"DrawText");
518 testParam=testSize.iHeight;
520 checkGlyphBitmapType=EMonochromeGlyphBitmap;
521 drawTextTest: User::LeaveIfError(iScreenDevice->BitmapDevice().GetNearestFontInPixels((CFont* &)font,testFontSpec));
522 fontHeight=font->HeightInPixels();
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);
530 if (checkGlyphBitmapType!=EDefaultGlyphBitmap)
532 if (actualGlyphBitmapType!=checkGlyphBitmapType)
534 INFO_PRINTF3(_L("Failed to load correct glyph type font, wanted %d, got %d"),checkGlyphBitmapType, actualGlyphBitmapType);
538 _LIT(KAppendAlphaTxt,"[A=0x%02x]");
539 testName.AppendFormat(KAppendAlphaTxt,aAlpha);
540 iProfiler->InitResults();
541 for(TInt iter=0; iter<aNumIterations; iter++)
545 case EBlendTestVerticalLine:
546 for(TInt xpos=0; xpos<testSize.iWidth; xpos++)
547 iGc->DrawLine(TPoint(xpos,0),TPoint(xpos,testSize.iHeight));
549 case EBlendTestDrawRect:
550 iGc->DrawRect(TRect(testSize));
552 case EBlendTestDrawText:
553 case EBlendTestDrawVerticalText:
554 case EBlendTestDrawTextAntiAliased:
555 case EBlendTestDrawTextIType:
557 for(TInt pos=0;pos<testParam;pos+=fontHeight)
559 if (aTestFunc==EBlendTestDrawVerticalText)
560 iGc->DrawTextVertical(textPtr,TPoint(pos,0),EFalse);
562 iGc->DrawText(textPtr,TPoint(0,pos));
567 iProfiler->MarkResultSetL();
569 INFO_PRINTF3(_L("%S %S"), &testName, &ColorModeName(aDisplayMode));
570 iProfiler->ResultsAnalysis(testName, orient, aDisplayMode, aDisplayMode, aNumIterations);
573 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
576 TBool CAlphaBlendTest::CheckMonoTypeInstalledL()
578 SetScreenModeL(EColor16MU);
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);
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);
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
603 void CAlphaBlendTest::DoBitBltAlphaBitmapTestL(TDisplayMode aSrcMode,TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
605 const TSize bitmapSize = aWindow.Size();
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);
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));
621 bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
622 bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
624 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
626 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
627 bitmapGc->BitBlt(point, source);
629 aGc->Activate(aWindow);
630 aGc->BitBlt(point, bitmapTarget);
634 iProfiler->InitResults();
635 for(TInt i=0; i<aNumIterations; i++)
637 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
639 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
640 bitmapGc->BitBlt(point, source);
641 iProfiler->MarkResultSetL();
644 iProfiler->ResultsAnalysis(_L("DoBitBltAlphaBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
646 // copy up to screen for sanity check
647 aGc->Activate(aWindow);
648 aGc->BitBlt(TPoint(), bitmapTarget);
650 CleanupStack::PopAndDestroy(5, bitmapTarget); //sourceAlpha, source, bitmapGc, bitmapDevice, bitmapTarget
655 Clears the window to a colour
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
662 void CAlphaBlendTest::ClearWindow(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TRgb aColor)
664 // clear so we can see bitmap version has completed
665 aWindow.Invalidate();
666 aWindow.BeginRedraw();
667 aGc->Activate(aWindow);
668 aGc->SetBrushColor(aColor);
676 BitBlts a bitmap to the windows GC.
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
683 void CAlphaBlendTest::BitBlt(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, CFbsBitmap& aImage)
685 aWindow.Invalidate();
686 aWindow.BeginRedraw();
687 aGc->Activate(aWindow);
688 aGc->BitBlt(TPoint(0,0), &aImage);
695 Alpha blends two bitmaps together
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
704 void CAlphaBlendTest::DoAlphaBlendBitmapsBitmapTestL(TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
706 const TSize bitmapSize = aWindow.Size();
708 CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
709 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
710 CleanupStack::PushL(bitmapDevice);
712 CFbsBitGc* bitmapGc=NULL;
713 User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
714 CleanupStack::PushL(bitmapGc);
716 CFbsBitmap* sourceUnder = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
717 CFbsBitmap* sourceOver = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
718 CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256);
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");
726 TRect rect(bitmapSize);
728 bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
729 bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
731 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
733 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
734 bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);
736 aGc->Activate(aWindow);
737 aGc->BitBlt(point, bitmapTarget);
741 iProfiler->InitResults();
742 // blend sourceUnder with sourceOver using alpha mask
743 for(TInt i=0; i<aNumIterations; i++)
745 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
747 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
748 bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);
749 iProfiler->MarkResultSetL();
751 iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
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
759 Draws a stretched bitmap with or without a mask.
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
769 void CAlphaBlendTest::DoDrawBitmapL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
771 const TSize bitmapSize = aWindow.Size();
773 // Construct target bitmap.
774 CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
775 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
776 CleanupStack::PushL(bitmapDevice);
779 CFbsBitGc* bitmapGc = NULL;
780 User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
781 CleanupStack::PushL(bitmapGc);
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));
790 bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
791 bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
793 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
794 aGc->Activate(aWindow);
796 bitmapGc->BitBlt(point, bitmapTarget);
803 testName=_L("DrawBitmap");
804 iProfiler->InitResults();
805 for(int i=0; i<aNumIterations; i++)
807 bitmapGc->DrawBitmap(TRect(point, bitmapSize), source);
808 iProfiler->MarkResultSetL();
813 testName=_L("DrawBitmapMasked");
814 iProfiler->InitResults();
815 for(int i=0; i<aNumIterations; i++)
817 bitmapGc->DrawBitmapMasked(TRect(point, bitmapSize), source,TRect(point, smallerSize), sourceAlpha, EFalse);
818 iProfiler->MarkResultSetL();
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);
829 Performs a BitBlt with or without a mask
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
839 void CAlphaBlendTest::DoNormalBitBltL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
841 const TSize bitmapSize = aWindow.Size();
843 // Construct target bitmap
844 CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
845 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
846 CleanupStack::PushL(bitmapDevice);
849 CFbsBitGc* bitmapGc = NULL;
850 User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
851 CleanupStack::PushL(bitmapGc);
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));
859 bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
860 bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
862 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
864 TRect rect(bitmapSize);
866 bitmapGc->AlphaBlendBitmaps(point, source, rect, sourceAlpha, point);
868 bitmapGc->BitBlt(point, source); // BitBlt source to target bitmap
870 aGc->Activate(aWindow);
871 aGc->BitBlt(point, bitmapTarget); // BitBlt bitmapTarget to screen
878 testName=_L("AlphaBlendBitmaps");
879 // blend sourceUnder with sourceOver using alpha mask
880 iProfiler->InitResults();
881 for(TInt i=0; i<aNumIterations; i++)
884 bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
885 bitmapGc->AlphaBlendBitmaps(point, source, rect, sourceAlpha, point);
886 iProfiler->MarkResultSetL();
891 testName=_L("Normal BitBlt");
892 iProfiler->InitResults();
893 for(TInt i=0; i<aNumIterations; i++)
895 bitmapGc->BitBlt(point, source);
896 iProfiler->MarkResultSetL();
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);