sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include sl@0: #include "talphablend.h" sl@0: sl@0: const TInt KIterationsToTest = 100; sl@0: const TInt KDrawRectIterationsToTest = KIterationsToTest*5; // More as faster simpler drawing than bitblits sl@0: const TInt KDrawVertLineIterationsToTest = KIterationsToTest*5; sl@0: const TInt KDrawTextIterationsToTest = KIterationsToTest*2;// More as drawing fewer pixels than blits. sl@0: const TInt KDrawVertTextIterationsToTest = KIterationsToTest;// Slow, less iterations. sl@0: sl@0: _LIT(KFontTypeface,"DejaVu Sans Condensed"); sl@0: // sl@0: // We have two overloads of this test, the normal version that runs all tests except... sl@0: // sl@0: sl@0: CAlphaBlendTestNormal::CAlphaBlendTestNormal() sl@0: { sl@0: SetTestStepName(KAlphaBlendTest); sl@0: } sl@0: sl@0: TVerdict CAlphaBlendTestNormal::doTestStepL() sl@0: { sl@0: return(CAlphaBlendTest::doTestStepL(EFalse)); sl@0: } sl@0: sl@0: /* sl@0: ...the iType font variant, this needs the rom configured differently so can not be run with the other tests sl@0: to configure the rom for iType fonts you need to use: sl@0: sl@0: ..\iType\binaries\ityperast install sl@0: sl@0: and to remove them and swich back to normal sl@0: sl@0: ..\iType\binaries\ityperast uninstall sl@0: */ sl@0: sl@0: CAlphaBlendTestIType::CAlphaBlendTestIType() sl@0: { sl@0: SetTestStepName(KAlphaBlendTestIType); sl@0: } sl@0: sl@0: TVerdict CAlphaBlendTestIType::doTestStepL() sl@0: { sl@0: return(CAlphaBlendTest::doTestStepL(ETrue)); sl@0: } sl@0: sl@0: /** sl@0: Override of base class pure virtual sl@0: Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: not leave. That being the case, the current test result value will be EPass. sl@0: sl@0: @return - TVerdict code sl@0: */ sl@0: TVerdict CAlphaBlendTest::doTestStepL(TBool aIType) sl@0: { sl@0: RWsSession wsSession; sl@0: User::LeaveIfError(wsSession.Connect()); sl@0: CleanupClosePushL(wsSession); sl@0: sl@0: // sl@0: // Uncomment to debug WSERV redraw problems. sl@0: // wsSession.SetAutoFlush(ETrue); sl@0: sl@0: CWsScreenDevice* windowDevice = new (ELeave) CWsScreenDevice(wsSession); sl@0: CleanupStack::PushL(windowDevice); sl@0: User::LeaveIfError(windowDevice->Construct()); sl@0: CWindowGc* windowGc=NULL; sl@0: User::LeaveIfError(windowDevice->CreateContext(windowGc)); // create graphics context sl@0: CleanupStack::PushL(windowGc); sl@0: sl@0: RWindowGroup group; sl@0: group = RWindowGroup(wsSession); sl@0: CleanupClosePushL(group); sl@0: User::LeaveIfError(group.Construct(1, EFalse)); sl@0: sl@0: RWindow background; sl@0: background = RWindow(wsSession); sl@0: CleanupClosePushL(background); sl@0: User::LeaveIfError(background.Construct(group, 2)); sl@0: sl@0: RWindow window; sl@0: window = RWindow(wsSession); sl@0: CleanupClosePushL(window); sl@0: User::LeaveIfError(window.Construct(group, 3)); sl@0: sl@0: TSize windowSize = windowDevice->SizeInPixels(); sl@0: TDisplayMode windowMode = windowDevice->DisplayMode(); sl@0: sl@0: background.Activate(); sl@0: background.Invalidate(); sl@0: sl@0: ClearWindow(wsSession, background, windowGc, BLACK_SEMI_TRANSPARENT); sl@0: ClearWindow(wsSession, window, windowGc, BLACK_SEMI_TRANSPARENT); sl@0: sl@0: window.SetTransparencyAlphaChannel(); sl@0: window.Activate(); sl@0: window.Invalidate(); sl@0: if (aIType) sl@0: { sl@0: if (CheckMonoTypeInstalledL()) sl@0: DoDrawBlendedTestsL(EBlendTestDrawTextIType,wsSession, KDrawVertTextIterationsToTest); sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Monotype fonts not installed, skipping test")); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: /* sl@0: Test speed of blended draw rects on all modes supporting alpha blending sl@0: */ sl@0: DoDrawBlendedTestsL(EBlendTestDrawRect,wsSession, KDrawRectIterationsToTest); sl@0: /* sl@0: Test speed of blended draw vertical line calls on all modes supporting alpha blending sl@0: */ sl@0: DoDrawBlendedTestsL(EBlendTestVerticalLine,wsSession, KDrawVertLineIterationsToTest); sl@0: /* sl@0: Test speed of blended draw text calls on all modes supporting alpha blending sl@0: */ sl@0: DoDrawBlendedTestsL(EBlendTestDrawText,wsSession, KDrawTextIterationsToTest); sl@0: DoDrawBlendedTestsL(EBlendTestDrawTextAntiAliased,wsSession, KDrawVertTextIterationsToTest); sl@0: DoDrawBlendedTestsL(EBlendTestDrawVerticalText,wsSession, KDrawVertTextIterationsToTest); sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0022 sl@0: sl@0: @SYMTestCaseDesc sl@0: Alphablend test BITBLT with EColor16MA source and EColor16MU destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: RDebug::Printf("Alpha Tests: EColor16MU, EColor16MA"); sl@0: RDebug::Printf("Alpha Blend"); sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0022")); sl@0: DoAlphaBlendBitmapsBitmapTestL(EColor16MA, EColor16MU, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0023 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MA source and EColor16MU destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: RDebug::Printf("BitBlt Alpha"); sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0023")); sl@0: DoBitBltAlphaBitmapTestL(EColor16MA, EColor16MU, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0024 sl@0: sl@0: @SYMTestCaseDesc sl@0: Alpha blend test BITBLT with EColor16MA source and EColor16MA destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: RDebug::Printf("Alpha Tests: EColor16MA, EColor16MA"); sl@0: RDebug::Printf("Alpha Blend"); sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0024")); sl@0: DoAlphaBlendBitmapsBitmapTestL(EColor16MA,EColor16MA, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0025 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MA source and EColor16MA destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over time sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: RDebug::Printf("BitBlt Alpha"); sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0025")); sl@0: DoBitBltAlphaBitmapTestL(EColor16MA, EColor16MA, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0063 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MAP source and EColor16MAP destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0063")); sl@0: DoNormalBitBltL(EFalse, EColor16MAP,EColor16MAP, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0064 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MA source and EColor16MA destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0064")); sl@0: DoNormalBitBltL(EFalse, EColor16MA,EColor16MA, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0065 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MAP source and EColor16MA destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0065")); sl@0: DoNormalBitBltL(EFalse, EColor16MAP,EColor16MA, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0066 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MA source and EColor16MAP destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0066")); sl@0: DoNormalBitBltL(EFalse, EColor16MA,EColor16MAP, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0067 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MU source and EColor16MU destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0067")); sl@0: DoNormalBitBltL(EFalse, EColor16MU,EColor16MU, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0068 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MAP source and EColor16MU destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0068")); sl@0: DoNormalBitBltL(EFalse, EColor16MAP,EColor16MU, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0069 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor16MU source and EColor16MAP destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0069")); sl@0: DoNormalBitBltL(EFalse, EColor16MU,EColor16MAP, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0070 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test BITBLT with EColor64K source and EColor16MU destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0070")); sl@0: DoNormalBitBltL(ETrue, EColor64K,EColor16MU, wsSession, window, windowGc, KIterationsToTest); sl@0: sl@0: RecordTestResultL(); sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0071 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test DrawBitmap with different sizes (STRETCHED) with EColor16MAP source and EColor16MAP destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0071")); sl@0: DoDrawBitmapL(EFalse, EColor16MAP, EColor16MAP, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0072 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test DrawBitmap with different sizes (STRETCHED) with EColor16MA source and EColor16MA destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0072")); sl@0: DoDrawBitmapL(EFalse, EColor16MA, EColor16MA, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0073 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test DrawBitmap (using alpha mask) with different sizes (STRETCHED) with EColor16MU source and EColor16MU destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0073")); sl@0: DoDrawBitmapL(ETrue, EColor16MU, EColor16MU, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-UI-BENCH-0057 sl@0: sl@0: @SYMTestCaseDesc sl@0: Test DrawBitmap (using alpha mask) with different sizes (STRETCHED) with EColor16MAP source and EColor16MAP destination. sl@0: sl@0: @SYMTestActions sl@0: Compare the results over several iterations over time. sl@0: sl@0: @SYMTestExpectedResults sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-UI-BENCH-0057")); sl@0: DoDrawBitmapL(ETrue, EColor16MAP, EColor16MAP, wsSession, window, windowGc, KIterationsToTest); sl@0: RecordTestResultL(); sl@0: } sl@0: CleanupStack::PopAndDestroy(6, &wsSession); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void CAlphaBlendTest::DoDrawBlendedTestsL(TBlendTestFunc aTestFunc, RWsSession& aSession, TInt aNumIterations) sl@0: { sl@0: TDisplayMode blendModes[]={EColor16MAP,EColor16MA,EColor16MU,EColor64K}; sl@0: const TInt KNumBlendTestModes=sizeof(blendModes)/sizeof(TDisplayMode); sl@0: for(TInt modeIndex=0;modeIndexSizeInPixels(); sl@0: // For fair back to back tests of rotated mode we need graphics clipped to a square test area. sl@0: // Although if we aren't going to be comparing rotated results against each other it might be better sl@0: // to allow the tests to use the full available area. sl@0: TSize testSize; sl@0: testSize.iWidth=Min(devSize.iWidth,devSize.iHeight); sl@0: testSize.iHeight=testSize.iWidth; sl@0: sl@0: TFontSpec testFontSpec; sl@0: if (aTestFunc==EBlendTestDrawTextAntiAliased || aTestFunc==EBlendTestDrawTextIType) sl@0: { sl@0: testFontSpec.iTypeface.iName=KFontTypeface; sl@0: if (aTestFunc==EBlendTestDrawTextAntiAliased) sl@0: { sl@0: testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); sl@0: } sl@0: else sl@0: { sl@0: testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); sl@0: testFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); sl@0: testFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); sl@0: } sl@0: } sl@0: testFontSpec.iHeight=12; sl@0: // Set bold because sets more pixels, so tests blending code more sl@0: testFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); sl@0: _LIT(KTestBlendTextString,"BLENDTESTWITHBIGSOLIDCHARACTERS0123456789HAVEWERUNOUTOFSCREENYET?OKAFEWMORECHARACTERSJUSTTOMAKESURE"); sl@0: const TInt maxTextLen=KTestBlendTextString().Length(); sl@0: // sl@0: TBool orientations[4]; sl@0: iGc->OrientationsAvailable(orientations); sl@0: // Use for loop to test across multiple rotations, however the implementation hardly varies at the moment sl@0: // so very little point in testing the differences, if in future an optimised route is added for normal sl@0: // rotation this test would be worth switching back to looping upto EGraphicsOrientationRotated270. sl@0: // sl@0: // const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationRotated270; sl@0: const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationNormal; sl@0: for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= KMaxOrientation; orient++) sl@0: { sl@0: if (orientations[orient]) sl@0: { sl@0: iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient); sl@0: User::After(100000); // Let rotate sort itself out sl@0: iGc->Reset(); sl@0: iGc->SetClippingRect(TRect(testSize)); sl@0: iGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: iGc->SetBrushColor(TRgb(0x80,0x80,0xFF)); sl@0: iGc->Clear(); sl@0: iGc->SetBrushColor(TRgb(10,128,240,aAlpha)); sl@0: iGc->SetPenColor(TRgb(240,128,10,aAlpha)); sl@0: iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: aSession.Flush(); sl@0: sl@0: CFbsFont* font=NULL; sl@0: TInt fontHeight=0; sl@0: TInt testParam=0; sl@0: TSize orientatedTestSize=testSize; sl@0: TBuf <32> testName; sl@0: TGlyphBitmapType checkGlyphBitmapType=EDefaultGlyphBitmap; sl@0: TGlyphBitmapType actualGlyphBitmapType=EDefaultGlyphBitmap; sl@0: TPtrC textPtr; sl@0: switch(aTestFunc) sl@0: { sl@0: case EBlendTestVerticalLine: sl@0: _LIT(KDrawRectVerticalLine,"DrawRectVertLine"); sl@0: testName=KDrawRectVerticalLine; sl@0: break; sl@0: case EBlendTestDrawRect: sl@0: _LIT(KDrawRectAlpha,"DrawRectAlpha"); sl@0: testName=KDrawRectAlpha; sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: break; sl@0: case EBlendTestDrawTextIType: sl@0: _LIT(KDrawTextIType,"DrawTextIT"); sl@0: testName=KDrawTextIType; sl@0: testParam=testSize.iHeight; sl@0: checkGlyphBitmapType=EFourColourBlendGlyphBitmap; sl@0: goto drawTextTest; sl@0: case EBlendTestDrawTextAntiAliased: sl@0: _LIT(KDrawTextAA,"DrawTextAA"); sl@0: testName=KDrawTextAA; sl@0: testParam=testSize.iHeight; sl@0: checkGlyphBitmapType=EAntiAliasedGlyphBitmap; sl@0: goto drawTextTest; sl@0: case EBlendTestDrawVerticalText: sl@0: _LIT(KDrawTextVert,"DrawTextVert"); sl@0: orientatedTestSize.SetSize(orientatedTestSize.iHeight,orientatedTestSize.iWidth); sl@0: testName=KDrawTextVert; sl@0: testParam=testSize.iWidth; sl@0: checkGlyphBitmapType=EMonochromeGlyphBitmap; sl@0: goto drawTextTest; sl@0: case EBlendTestDrawText: sl@0: _LIT(KDrawText,"DrawText"); sl@0: testParam=testSize.iHeight; sl@0: testName=KDrawText; sl@0: checkGlyphBitmapType=EMonochromeGlyphBitmap; sl@0: drawTextTest: User::LeaveIfError(iScreenDevice->BitmapDevice().GetNearestFontInPixels((CFont* &)font,testFontSpec)); sl@0: fontHeight=font->HeightInPixels(); sl@0: iGc->UseFont(font); sl@0: actualGlyphBitmapType=font->FontSpecInTwips().iFontStyle.BitmapType(); sl@0: TInt displayLen=Min(font->TextCount(KTestBlendTextString,orientatedTestSize.iWidth)+1,maxTextLen); sl@0: textPtr.Set(KTestBlendTextString().Left(displayLen)); sl@0: iScreenDevice->BitmapDevice().ReleaseFont(font); sl@0: break; sl@0: } sl@0: if (checkGlyphBitmapType!=EDefaultGlyphBitmap) sl@0: { sl@0: if (actualGlyphBitmapType!=checkGlyphBitmapType) sl@0: { sl@0: INFO_PRINTF3(_L("Failed to load correct glyph type font, wanted %d, got %d"),checkGlyphBitmapType, actualGlyphBitmapType); sl@0: break; sl@0: } sl@0: } sl@0: _LIT(KAppendAlphaTxt,"[A=0x%02x]"); sl@0: testName.AppendFormat(KAppendAlphaTxt,aAlpha); sl@0: iProfiler->InitResults(); sl@0: for(TInt iter=0; iterDrawLine(TPoint(xpos,0),TPoint(xpos,testSize.iHeight)); sl@0: break; sl@0: case EBlendTestDrawRect: sl@0: iGc->DrawRect(TRect(testSize)); sl@0: break; sl@0: case EBlendTestDrawText: sl@0: case EBlendTestDrawVerticalText: sl@0: case EBlendTestDrawTextAntiAliased: sl@0: case EBlendTestDrawTextIType: sl@0: { sl@0: for(TInt pos=0;posDrawTextVertical(textPtr,TPoint(pos,0),EFalse); sl@0: else sl@0: iGc->DrawText(textPtr,TPoint(0,pos)); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: INFO_PRINTF3(_L("%S %S"), &testName, &ColorModeName(aDisplayMode)); sl@0: iProfiler->ResultsAnalysis(testName, orient, aDisplayMode, aDisplayMode, aNumIterations); sl@0: } sl@0: } sl@0: iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal); sl@0: } sl@0: sl@0: TBool CAlphaBlendTest::CheckMonoTypeInstalledL() sl@0: { sl@0: SetScreenModeL(EColor16MU); sl@0: // sl@0: TFontSpec fontSpec; sl@0: fontSpec.iTypeface.iName = KFontTypeface; sl@0: fontSpec.iHeight = 20; sl@0: fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); sl@0: fontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue); sl@0: fontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue); sl@0: CFont* font; sl@0: User::LeaveIfError(iScreenDevice->BitmapDevice().GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec)); sl@0: TBool monoTypeInstalled=font->FontSpecInTwips().iFontStyle.BitmapType()==EFourColourBlendGlyphBitmap; sl@0: iScreenDevice->BitmapDevice().ReleaseFont(font); sl@0: return(monoTypeInstalled); sl@0: } sl@0: sl@0: /** sl@0: Bitblt test sl@0: sl@0: @param aSrcMode is the source display mode sl@0: @param aDstMode is the destination display mode sl@0: @param aSession is the windows server session sl@0: @param aWindow is a reference to the window sl@0: @param aGc is the graphics context of the window sl@0: @param aNumIterations is the number of iterations to run the test sl@0: */ sl@0: void CAlphaBlendTest::DoBitBltAlphaBitmapTestL(TDisplayMode aSrcMode,TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations) sl@0: { sl@0: const TSize bitmapSize = aWindow.Size(); sl@0: sl@0: CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode); sl@0: CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget); sl@0: CleanupStack::PushL(bitmapDevice); sl@0: CFbsBitGc* bitmapGc = NULL; sl@0: User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc)); sl@0: CleanupStack::PushL(bitmapGc); sl@0: sl@0: CFbsBitmap* source = CreateSoftwareBitmapLC(bitmapSize, aSrcMode); sl@0: CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256); // match size to src sl@0: VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe)); sl@0: VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff)); sl@0: sl@0: TPoint point(0,0); sl@0: sl@0: bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: bitmapGc->SetBrushColor(TRANSPARENT_BLACK); sl@0: sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); sl@0: bitmapGc->Clear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: bitmapGc->BitBlt(point, source); sl@0: sl@0: aGc->Activate(aWindow); sl@0: aGc->BitBlt(point, bitmapTarget); sl@0: aGc->Deactivate(); sl@0: aSession.Flush(); sl@0: sl@0: iProfiler->InitResults(); sl@0: for(TInt i=0; iSetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); sl@0: bitmapGc->Clear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: bitmapGc->BitBlt(point, source); sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: sl@0: iProfiler->ResultsAnalysis(_L("DoBitBltAlphaBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations); sl@0: sl@0: // copy up to screen for sanity check sl@0: aGc->Activate(aWindow); sl@0: aGc->BitBlt(TPoint(), bitmapTarget); sl@0: aGc->Deactivate(); sl@0: CleanupStack::PopAndDestroy(5, bitmapTarget); //sourceAlpha, source, bitmapGc, bitmapDevice, bitmapTarget sl@0: } sl@0: sl@0: sl@0: /** sl@0: Clears the window to a colour sl@0: sl@0: @param aSession is the windows server session sl@0: @param aWindow is a reference to the window sl@0: @param aGc is the graphics context of the window sl@0: @param aColor is the colour to clear the window with sl@0: */ sl@0: void CAlphaBlendTest::ClearWindow(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TRgb aColor) sl@0: { sl@0: // clear so we can see bitmap version has completed sl@0: aWindow.Invalidate(); sl@0: aWindow.BeginRedraw(); sl@0: aGc->Activate(aWindow); sl@0: aGc->SetBrushColor(aColor); sl@0: aGc->Clear(); sl@0: aGc->Deactivate(); sl@0: aWindow.EndRedraw(); sl@0: aSession.Flush(); sl@0: } sl@0: sl@0: /** sl@0: BitBlts a bitmap to the windows GC. sl@0: sl@0: @param aSession is the windows server session sl@0: @param aWindow is a reference to the window sl@0: @param aGc is the graphics context of the window sl@0: @param aImage is the bitmap to bitblt sl@0: */ sl@0: void CAlphaBlendTest::BitBlt(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, CFbsBitmap& aImage) sl@0: { sl@0: aWindow.Invalidate(); sl@0: aWindow.BeginRedraw(); sl@0: aGc->Activate(aWindow); sl@0: aGc->BitBlt(TPoint(0,0), &aImage); sl@0: aGc->Deactivate(); sl@0: aWindow.EndRedraw(); sl@0: aSession.Flush(); sl@0: } sl@0: sl@0: /** sl@0: Alpha blends two bitmaps together sl@0: sl@0: @param aDisplayMode1 is the source display mode sl@0: @param aDisplayMode2 is the destination display mode sl@0: @param aSession is the windows server session sl@0: @param aWindow is a reference to the window sl@0: @param aGc is the graphics context of the window sl@0: @param aNumIterations is the number of iterations to run the test sl@0: */ sl@0: void CAlphaBlendTest::DoAlphaBlendBitmapsBitmapTestL(TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations) sl@0: { sl@0: const TSize bitmapSize = aWindow.Size(); sl@0: sl@0: CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode); sl@0: CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget); sl@0: CleanupStack::PushL(bitmapDevice); sl@0: sl@0: CFbsBitGc* bitmapGc=NULL; sl@0: User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc)); sl@0: CleanupStack::PushL(bitmapGc); sl@0: sl@0: CFbsBitmap* sourceUnder = CreateSoftwareBitmapLC(bitmapSize, aDstMode); sl@0: CFbsBitmap* sourceOver = CreateSoftwareBitmapLC(bitmapSize, aSrcMode); sl@0: CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256); sl@0: sl@0: VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe)); sl@0: VerticalGradientAlphaL(sourceUnder, TRgb(0xff000000), TRgb(0x00ffffff)); sl@0: VerticalGradientAlphaL(sourceOver, TRgb(0x00ffffff), TRgb(0xff000000)); sl@0: RDebug::Printf("DABBBT 2"); sl@0: sl@0: TPoint point(0,0); sl@0: TRect rect(bitmapSize); sl@0: sl@0: bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: bitmapGc->SetBrushColor(TRANSPARENT_BLACK); sl@0: sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); sl@0: bitmapGc->Clear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point); sl@0: sl@0: aGc->Activate(aWindow); sl@0: aGc->BitBlt(point, bitmapTarget); sl@0: aGc->Deactivate(); sl@0: aSession.Flush(); sl@0: sl@0: iProfiler->InitResults(); sl@0: // blend sourceUnder with sourceOver using alpha mask sl@0: for(TInt i=0; iSetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); sl@0: bitmapGc->Clear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point); sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations); sl@0: sl@0: // copy up to screen for sanity check sl@0: BitBlt(aSession, aWindow, aGc, *bitmapTarget); sl@0: CleanupStack::PopAndDestroy(6, bitmapTarget); // sourceAlpha, sourceOver, sourceUnder, bitmapGc, bitmapDevice, bitmapTarget sl@0: } sl@0: sl@0: /** sl@0: Draws a stretched bitmap with or without a mask. sl@0: sl@0: @param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha. sl@0: @param aSrcMode is the source display mode sl@0: @param aDstMode is the destination display mode sl@0: @param aSession is the windows server session sl@0: @param aWindow is a reference to the window sl@0: @param aGc is the graphics context of the window sl@0: @param aNumIterations is the number of iterations to run the test sl@0: */ sl@0: void CAlphaBlendTest::DoDrawBitmapL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations) sl@0: { sl@0: const TSize bitmapSize = aWindow.Size(); sl@0: sl@0: // Construct target bitmap. sl@0: CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode); sl@0: CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget); sl@0: CleanupStack::PushL(bitmapDevice); sl@0: sl@0: // Construct GC. sl@0: CFbsBitGc* bitmapGc = NULL; sl@0: User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc)); sl@0: CleanupStack::PushL(bitmapGc); sl@0: sl@0: // Construct source bitmap. sl@0: TSize smallerSize(bitmapSize.iWidth/2, bitmapSize.iHeight/2); sl@0: CFbsBitmap* source = CreateSoftwareBitmapLC(smallerSize, aSrcMode); sl@0: VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff)); sl@0: CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(smallerSize, EGray256); // match size to src sl@0: VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe)); sl@0: sl@0: bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: bitmapGc->SetBrushColor(TRANSPARENT_BLACK); sl@0: bitmapGc->Clear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: aGc->Activate(aWindow); sl@0: TPoint point(0,0); sl@0: bitmapGc->BitBlt(point, bitmapTarget); sl@0: aGc->Deactivate(); sl@0: aSession.Flush(); sl@0: sl@0: TBuf <20> testName; sl@0: if (!aUseMask) sl@0: { sl@0: testName=_L("DrawBitmap"); sl@0: iProfiler->InitResults(); sl@0: for(int i=0; iDrawBitmap(TRect(point, bitmapSize), source); sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: testName=_L("DrawBitmapMasked"); sl@0: iProfiler->InitResults(); sl@0: for(int i=0; iDrawBitmapMasked(TRect(point, bitmapSize), source,TRect(point, smallerSize), sourceAlpha, EFalse); sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: } sl@0: INFO_PRINTF4(_L("%S(Stretched) with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode)); sl@0: iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations); sl@0: // copy up to screen for sanity check sl@0: BitBlt(aSession, aWindow, aGc, *bitmapTarget); sl@0: CleanupStack::PopAndDestroy(5, bitmapTarget); sl@0: } sl@0: sl@0: /** sl@0: Performs a BitBlt with or without a mask sl@0: sl@0: @param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha. sl@0: @param aSrcMode is the source display mode sl@0: @param aDstMode is the destination display mode sl@0: @param aSession is the windows server session sl@0: @param aWindow is a reference to the window sl@0: @param aGc is the graphics context of the window sl@0: @param aNumIterations is the number of iterations to run the test sl@0: */ sl@0: void CAlphaBlendTest::DoNormalBitBltL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations) sl@0: { sl@0: const TSize bitmapSize = aWindow.Size(); sl@0: sl@0: // Construct target bitmap sl@0: CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode); sl@0: CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget); sl@0: CleanupStack::PushL(bitmapDevice); sl@0: sl@0: // Construct GC sl@0: CFbsBitGc* bitmapGc = NULL; sl@0: User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc)); sl@0: CleanupStack::PushL(bitmapGc); sl@0: sl@0: // Construct source bitmap sl@0: CFbsBitmap* source = CreateSoftwareBitmapLC(bitmapSize, aSrcMode); sl@0: VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff)); sl@0: CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256); // match size to src sl@0: VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe)); sl@0: sl@0: bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: bitmapGc->SetBrushColor(TRANSPARENT_BLACK); sl@0: bitmapGc->Clear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: TPoint point(0,0); sl@0: TRect rect(bitmapSize); sl@0: if (aUseMask) sl@0: bitmapGc->AlphaBlendBitmaps(point, source, rect, sourceAlpha, point); sl@0: else sl@0: bitmapGc->BitBlt(point, source); // BitBlt source to target bitmap sl@0: sl@0: aGc->Activate(aWindow); sl@0: aGc->BitBlt(point, bitmapTarget); // BitBlt bitmapTarget to screen sl@0: aGc->Deactivate(); sl@0: aSession.Flush(); sl@0: sl@0: TBuf <20> testName; sl@0: if (aUseMask) sl@0: { sl@0: testName=_L("AlphaBlendBitmaps"); sl@0: // blend sourceUnder with sourceOver using alpha mask sl@0: iProfiler->InitResults(); sl@0: for(TInt i=0; iClear(); sl@0: bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: bitmapGc->AlphaBlendBitmaps(point, source, rect, sourceAlpha, point); sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: testName=_L("Normal BitBlt"); sl@0: iProfiler->InitResults(); sl@0: for(TInt i=0; iBitBlt(point, source); sl@0: iProfiler->MarkResultSetL(); sl@0: } sl@0: } sl@0: sl@0: INFO_PRINTF4(_L("%S with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode)); sl@0: iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations); sl@0: // copy up to screen for sanity check sl@0: BitBlt(aSession, aWindow, aGc, *bitmapTarget); sl@0: CleanupStack::PopAndDestroy(5, bitmapTarget); sl@0: }