sl@0: // Copyright (c) 1997-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: #include sl@0: #include sl@0: #include sl@0: #include "Tlld.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "BMDRAW.H" sl@0: sl@0: GLREF_C TInt ByteSize(TDisplayMode aDisplayMode,TInt aWidth); sl@0: sl@0: TInt KNumberDisplayModes1 = sizeof (TestDisplayMode1) / sizeof (TestDisplayMode1[0]); sl@0: sl@0: #if defined(SYMBIAN_USE_FAST_FADING) sl@0: const TBool KFastFading = ETrue; sl@0: #else sl@0: const TBool KFastFading = EFalse; sl@0: #endif sl@0: sl@0: //these are for EColor16MAP testing sl@0: const TInt KInaccuracyLimit = 15; sl@0: const TInt KUserDispModes = 2; sl@0: //The array below is used in CTLowLevel::TestWriteRGBAlpha() to step through display modes, sl@0: //to ensure adequate test coverage. sl@0: const TDisplayMode UserDisplayModes[KUserDispModes] = sl@0: { sl@0: ENone, sl@0: EColor16MAP, sl@0: }; sl@0: const TInt KMaskFill =3; sl@0: const TUint32 MaskFill[KMaskFill] = sl@0: { sl@0: 0x00, sl@0: 0xff, sl@0: 0x3A, sl@0: }; sl@0: sl@0: TInt DisplayMode2Index(TDisplayMode aMode) sl@0: { sl@0: TInt i; sl@0: for(i=0;iSetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(aCurTestCase) sl@0: { sl@0: case 1: sl@0: INFO_PRINTF1(_L("Bitmap device EGray2")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0004 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0004")); sl@0: TestBitmapDraw(EGray2,TSize(128,100)); sl@0: break; sl@0: case 2: sl@0: INFO_PRINTF1(_L("Bitmap device EGray4")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0005 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0005")); sl@0: TestBitmapDraw(EGray4,TSize(112,100)); sl@0: break; sl@0: case 3: sl@0: INFO_PRINTF1(_L("Bitmap device EGray16")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0006 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0006")); sl@0: TestBitmapDraw(EGray16,TSize(104,100)); sl@0: break; sl@0: case 4: sl@0: INFO_PRINTF1(_L("Bitmap device EGray256")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0007 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0007")); sl@0: TestBitmapDraw(EGray256,TSize(104,100)); sl@0: break; sl@0: case 5: sl@0: INFO_PRINTF1(_L("Bitmap device EColor16")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0008 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0008")); sl@0: TestBitmapDraw(EColor16,TSize(104,100)); sl@0: break; sl@0: case 6: sl@0: INFO_PRINTF1(_L("Bitmap device EColor256")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0009 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0009")); sl@0: TestBitmapDraw(EColor256,TSize(102,100)); sl@0: break; sl@0: case 7: sl@0: INFO_PRINTF1(_L("Bitmap device EColor4K")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0010 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0010")); sl@0: TestBitmapDraw(EColor4K,TSize(100,100)); sl@0: break; sl@0: case 8: sl@0: INFO_PRINTF1(_L("Bitmap device EColor64K")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0011 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0011")); sl@0: TestBitmapDraw(EColor64K,TSize(100,100)); sl@0: break; sl@0: case 9: sl@0: INFO_PRINTF1(_L("Bitmap device EColor16M")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0012 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0012")); sl@0: TestBitmapDraw(EColor16M,TSize(102,100)); sl@0: break; sl@0: case 10: sl@0: INFO_PRINTF1(_L("Bitmap device EColor16MU")); sl@0: iFuzzyMatch=ETrue; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0013 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0013")); sl@0: TestBitmapDraw(EColor16MU,TSize(102,100)); sl@0: iFuzzyMatch=EFalse; sl@0: break; sl@0: case 11: sl@0: INFO_PRINTF1(_L("Bitmap device EColor16MA")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0014 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0014")); sl@0: TestBitmapDraw(EColor16MA,TSize(102,100)); sl@0: break; sl@0: case 12: sl@0: INFO_PRINTF1(_L("Bitmap device EColor16MAP")); sl@0: iFuzzyMatch=ETrue; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0015 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0015")); sl@0: TestBitmapDraw(EColor16MAP,TSize(102,100)); sl@0: iFuzzyMatch=EFalse; sl@0: break; sl@0: case 13: sl@0: INFO_PRINTF1(_L("User display mode mapping")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0016 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0016")); sl@0: TestUserDisplayModeMapping(); sl@0: ((CTLowLevelStep*)iStep)->RecordTestResultL(); sl@0: break; sl@0: default: sl@0: if(iOrientation <= iOrientationEnd) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0017 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0017")); sl@0: INFO_PRINTF2(_L("Screen device : %S"), &DisplayModeNames1[iCurScreenDeviceModeIndex]); sl@0: TDisplayMode display = TestDisplayMode1[iCurScreenDeviceModeIndex++]; sl@0: TestScreenDrawL(display); sl@0: if(iCurScreenDeviceModeIndex >= KNumberDisplayModes1) sl@0: { sl@0: iCurScreenDeviceModeIndex = 0; sl@0: iOrientation ++; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTLowLevelStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: ((CTLowLevelStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: sl@0: /* this function is used for likeness matching, using a fixed inaccuracy */ sl@0: void CTLowLevel::CheckMatch(TUint32 aFirst,TUint32 aSecond) sl@0: { sl@0: TBool fail=EFalse; sl@0: if (iFuzzyMatch==EFalse) sl@0: fail|=Check(aFirst==aSecond); sl@0: else sl@0: { sl@0: TUint8* val1=static_cast(static_cast(&aFirst)); sl@0: TUint8* val2=static_cast(static_cast(&aSecond)); sl@0: fail|=Check(AbsDiff(*val1,*val2) 0 && size.iHeight > 0 && address != NULL); sl@0: sl@0: TPckgBuf info; sl@0: info().iScreenAddressValid = ETrue; sl@0: info().iScreenAddress = REINTERPRET_CAST(TAny*,address); sl@0: info().iScreenSize = size; sl@0: sl@0: TRAPD(ret,iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(info(),aDisplayMode)); sl@0: sl@0: if (ret == KErrNotSupported) sl@0: { sl@0: INFO_PRINTF1(_L("Not supported\r\n")); sl@0: return; sl@0: } sl@0: else if (ret != KErrNone) sl@0: User::Panic(_L("Draw device create"),ret); sl@0: sl@0: iDrawDevice->InitScreen(); sl@0: iDrawDevice->SetDisplayMode(iDrawDevice); sl@0: iDrawDevice->SetAutoUpdate(EFalse); sl@0: TBool orientation[4]; sl@0: iDrawDevice->OrientationsAvailable(orientation); sl@0: sl@0: TBool orientationSupported = iDrawDevice->SetOrientation(CFbsDrawDevice::TOrientation(iOrientation)); sl@0: if (orientationSupported) sl@0: { sl@0: Check(orientation[iOrientation]); sl@0: if (iOrientation & 1) sl@0: iSize = TSize(size.iHeight,size.iWidth); sl@0: else sl@0: iSize = size; sl@0: iLongWidth = LongWidth(iSize.iWidth,aDisplayMode); sl@0: Test(); sl@0: } sl@0: else sl@0: { sl@0: Check(!orientation[iOrientation]); sl@0: INFO_PRINTF1(_L("Orientation not supported\r\n")); sl@0: } sl@0: sl@0: INFO_PRINTF2(_L("Testing time=%d"), (User::TickCount() - startTime) * 100 / 64); sl@0: } sl@0: sl@0: void CTLowLevel::TestBitmapDraw(TDisplayMode aDisplayMode,const TSize& aSize) sl@0: { sl@0: TUint startTime=User::TickCount(); sl@0: Reset(); sl@0: iDispMode = aDisplayMode; sl@0: iSize = aSize; sl@0: iLongWidth = LongWidth(aSize.iWidth,aDisplayMode); sl@0: TSize size(0,0); sl@0: INFO_PRINTF1(KNullDesC); sl@0: sl@0: const TInt byteSize=ByteSize()*iSize.iHeight; sl@0: _LIT(KNoMem,"Not enough memory for bitmap bits"); sl@0: iBits = new TUint8[byteSize]; sl@0: if(!iBits) sl@0: { sl@0: User::Panic(KNoMem,KErrNoMemory); sl@0: } sl@0: sl@0: iBuf = new TUint32[byteSize]; sl@0: if(!iBuf) sl@0: { sl@0: User::Panic(KNoMem,KErrNoMemory); sl@0: } sl@0: sl@0: TPckgBuf info; sl@0: info().iScreenSize = aSize; sl@0: info().iScreenAddress = NULL; sl@0: info().iScreenAddressValid = ETrue; sl@0: sl@0: TRAPD(ret, iDrawDevice = CFbsDrawDevice::NewBitmapDeviceL(info(), aDisplayMode, ByteSize() )); sl@0: if (ret == KErrNotSupported) sl@0: { sl@0: INFO_PRINTF1(_L("Not supported\r\n")); sl@0: return; sl@0: } sl@0: else if (ret != KErrNone) sl@0: { sl@0: User::Panic(_L("Draw device create"),ret); sl@0: } sl@0: iDrawDevice->SetAutoUpdate(EFalse); sl@0: //Initialize the iDrowDevice object, if successful val=KErrNone sl@0: TInt val=iDrawDevice->InitScreen(); sl@0: TEST(val==KErrNone); sl@0: iDrawDevice->CFbsDrawDevice::SetBits(iBits); sl@0: iDrawDevice->CFbsDrawDevice::ShadowBuffer(10,iBuf); sl@0: iDrawDevice->CFbsDrawDevice::SetUserDisplayMode(iDispMode); sl@0: iDrawDevice->SetDisplayMode(iDrawDevice); sl@0: iDrawDevice->Update(); sl@0: iDrawDevice->SetUserDisplayMode(iDispMode); sl@0: iDrawDevice->SetBits(iBits); sl@0: Test(); sl@0: TBool orientation[4]; sl@0: iDrawDevice->OrientationsAvailable(orientation); sl@0: TBool orientationSupported = iDrawDevice->SetOrientation(CFbsDrawDevice::TOrientation(iOrientation)); sl@0: if (orientationSupported) sl@0: { sl@0: Check(orientation[iOrientation]); sl@0: if (iOrientation & 1) sl@0: iSize = TSize(size.iHeight,size.iWidth); sl@0: else sl@0: iSize = size; sl@0: iLongWidth = LongWidth(iSize.iWidth,aDisplayMode); sl@0: } sl@0: else sl@0: { sl@0: Check(!orientation[iOrientation]); sl@0: INFO_PRINTF1(_L("Orientation not supported\r\n")); sl@0: } sl@0: INFO_PRINTF2(_L("Testing time=%d"), (User::TickCount() - startTime) * 100 / 64); sl@0: } sl@0: sl@0: TInt RgbComponent(TRgb aRgb, TInt aRgbIndex) sl@0: { sl@0: return(aRgbIndex==0?aRgb.Red():(aRgbIndex==1?aRgb.Green():aRgb.Blue())); sl@0: } sl@0: sl@0: TBool CheckNormalizedValue(TRgb aReadCol, TRgb aNormalizedCol1, TRgb aNormalizedCol2, TRgb aNormalizedCol3, TRgb aNormalizedCol4, TInt aRgbIndex) sl@0: { sl@0: sl@0: const TInt KErrorMargin=5; sl@0: TInt minCol=Min(RgbComponent(aNormalizedCol1,aRgbIndex), sl@0: Min(RgbComponent(aNormalizedCol2,aRgbIndex), sl@0: Min(RgbComponent(aNormalizedCol3,aRgbIndex),RgbComponent(aNormalizedCol4,aRgbIndex))))-KErrorMargin; sl@0: TInt maxCol=Max(RgbComponent(aNormalizedCol1,aRgbIndex), sl@0: Max(RgbComponent(aNormalizedCol2,aRgbIndex), sl@0: Max(RgbComponent(aNormalizedCol3,aRgbIndex),RgbComponent(aNormalizedCol4,aRgbIndex))))+KErrorMargin; sl@0: TInt readComponent=RgbComponent(aReadCol,aRgbIndex); sl@0: return(readComponent>=minCol && readComponent<=maxCol); sl@0: } sl@0: sl@0: void CTLowLevel::CheckNormalizedRgb(TRgb aReadRgb, TRgb aCheckRgb, TDisplayMode aDevDisplayMode, TDisplayMode aUserDisplayMode, TBool aWriteRgbAlphaLine) sl@0: { sl@0: TRgb normalized1=aCheckRgb; sl@0: Normalize(normalized1,aUserDisplayMode); sl@0: if (aDevDisplayMode==EColor16MAP) sl@0: { sl@0: const TInt KNormalizeErrorMargin=3; sl@0: TRgb normalizedPMA1=aCheckRgb; sl@0: // Allow error margin for blending errors before calculating value normalized to user display mode sl@0: normalizedPMA1.SetRed(Min(0xFF,normalizedPMA1.Red()+KNormalizeErrorMargin)); sl@0: normalizedPMA1.SetGreen(Min(0xFF,normalizedPMA1.Green()+KNormalizeErrorMargin)); sl@0: normalizedPMA1.SetBlue(Min(0xFF,normalizedPMA1.Blue()+KNormalizeErrorMargin)); sl@0: // sl@0: Normalize(normalizedPMA1,aUserDisplayMode); sl@0: TRgb normalizedPMA3=normalizedPMA1; sl@0: normalizedPMA1=TRgb::Color16MAP(normalizedPMA1.Color16MAP()); sl@0: TRgb normalizedPMA2=aCheckRgb; sl@0: normalizedPMA2=TRgb::Color16MAP(normalizedPMA2.Color16MAP()); sl@0: normalizedPMA2.SetRed(Max(0,normalizedPMA2.Red()-KNormalizeErrorMargin)); sl@0: normalizedPMA2.SetGreen(Max(0,normalizedPMA2.Green()-KNormalizeErrorMargin)); sl@0: normalizedPMA2.SetBlue(Max(0,normalizedPMA2.Blue()-KNormalizeErrorMargin)); sl@0: Normalize(normalizedPMA2,aUserDisplayMode); sl@0: TEST(CheckNormalizedValue(aReadRgb,normalizedPMA1,normalizedPMA2,normalizedPMA3,normalized1,0) && sl@0: CheckNormalizedValue(aReadRgb,normalizedPMA1,normalizedPMA2,normalizedPMA3,normalized1,1) && sl@0: CheckNormalizedValue(aReadRgb,normalizedPMA1,normalizedPMA2,normalizedPMA3,normalized1,2)); sl@0: } sl@0: else sl@0: { sl@0: if (aDevDisplayMode==EColor64K && aWriteRgbAlphaLine) sl@0: { sl@0: // In EColor64K the WriteRgbAlphaLine code maps to native display mode first, before mapping to sl@0: // user mode then back again to device display mode. So use normalized2 to check for that case sl@0: TRgb normalized2=aCheckRgb; sl@0: Normalize(normalized2,aDevDisplayMode); sl@0: Normalize(normalized2,aUserDisplayMode); sl@0: Normalize(normalized2,aDevDisplayMode); sl@0: TEST(aReadRgb.Color16MU()==normalized2.Color16MU()); sl@0: } sl@0: else sl@0: { sl@0: Normalize(normalized1,aDevDisplayMode); sl@0: TEST(aReadRgb.Color16MU()==normalized1.Color16MU()); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::PrepareDestPixel(TDisplayMode aDevDisplayMode, TRgb& aRgb, TInt aDstAlpha) sl@0: { sl@0: CGraphicsContext::TDrawMode drawMode; sl@0: if (aDevDisplayMode==EColor16MAP) sl@0: { sl@0: aRgb.SetAlpha(aDstAlpha); sl@0: drawMode=CGraphicsContext::EDrawModeWriteAlpha; sl@0: } sl@0: else sl@0: { sl@0: aRgb.SetAlpha(0xFF); sl@0: drawMode=CGraphicsContext::EDrawModePEN; sl@0: } sl@0: iDrawDevice->WriteRgbMulti(0,0,1,1,aRgb,drawMode); sl@0: } sl@0: sl@0: void CTLowLevel::CheckMappedRgb(TDisplayMode aDevDisplayMode, TDisplayMode aUserDisplayMode, TRgb aRgb) sl@0: { sl@0: const TInt KMaxAlphaModes=5; sl@0: TInt alphaModeValues[KMaxAlphaModes]={0xFF,0xC0,0x80,0x40,0}; sl@0: TInt dstAlphaModeCount=aDevDisplayMode==EColor16MAP?KMaxAlphaModes:1; sl@0: for(TInt dstAlphaMode=0;dstAlphaModeWriteRgb(0,0,aRgb,CGraphicsContext::EDrawModePEN); sl@0: TRgb readRgb=iDrawDevice->ReadPixel(0,0); sl@0: CheckNormalizedRgb(readRgb,aRgb,aDevDisplayMode,aUserDisplayMode,EFalse); sl@0: // sl@0: PrepareDestPixel(aDevDisplayMode,aRgb,dstAlpha); sl@0: iDrawDevice->WriteRgbMulti(0,0,1,1,aRgb,CGraphicsContext::EDrawModePEN); sl@0: readRgb=iDrawDevice->ReadPixel(0,0); sl@0: CheckNormalizedRgb(readRgb,aRgb,aDevDisplayMode,aUserDisplayMode,EFalse); sl@0: // sl@0: PrepareDestPixel(aDevDisplayMode,aRgb,dstAlpha); sl@0: TUint32 writeBuffer[1]; sl@0: writeBuffer[0]=aRgb.Internal(); sl@0: TUint8 mask[1]={0xFF}; sl@0: iDrawDevice->WriteRgbAlphaLine(0,0,1,(TUint8*)writeBuffer,mask,CGraphicsContext::EDrawModePEN); sl@0: readRgb=iDrawDevice->ReadPixel(0,0); sl@0: CheckNormalizedRgb(readRgb,aRgb,aDevDisplayMode,aUserDisplayMode,ETrue); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::TestUserDisplayModeMapping() sl@0: { sl@0: TInt address = NULL; sl@0: TSize size; sl@0: User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress,address)); sl@0: User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels,size.iWidth)); sl@0: User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels,size.iHeight)); sl@0: ASSERT(size.iWidth > 0 && size.iHeight > 0 && address != NULL); sl@0: sl@0: TPckgBuf info; sl@0: info().iScreenAddressValid = ETrue; sl@0: info().iScreenAddress = REINTERPRET_CAST(TAny*,address); sl@0: info().iScreenSize = size; sl@0: // sl@0: for (TInt nDispModeDev = 0; nDispModeDev < KNumDispModes; nDispModeDev++) sl@0: { sl@0: TDisplayMode dispModeDev = TestDisplayMode[nDispModeDev]; sl@0: if (!TDisplayModeUtils::IsDisplayModeColor(dispModeDev) || TDisplayModeUtils::NumDisplayModeColors(dispModeDev)<65536) sl@0: continue; // Older modes have their quirks we don't want to mess with sl@0: Reset(); sl@0: TRAPD(ret,iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(info(),dispModeDev)); sl@0: if (ret == KErrNotSupported) sl@0: continue; sl@0: for (TInt nDispMode = 0; nDispMode < KNumDispModes; nDispMode++) sl@0: { sl@0: TDisplayMode userDispMode = TestDisplayMode[nDispMode]; sl@0: INFO_PRINTF3(_L("Testing devMode=%d, userMode=%d"), dispModeDev, userDispMode); sl@0: iDrawDevice->SetUserDisplayMode(userDispMode); sl@0: TUint rgbVal=0; sl@0: FOREVER sl@0: { sl@0: CheckMappedRgb(dispModeDev,userDispMode,rgbVal); sl@0: if (rgbVal==0xFFFFFF) sl@0: break; sl@0: rgbVal+=0x010305; sl@0: if (rgbVal>0xFFFFFF) // We want to make sure we test 0xFFFFFF as a special case sl@0: rgbVal=0xFFFFFF; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::Test() sl@0: { sl@0: _LIT(KOrientation,"Orientation: %S"); sl@0: TBuf<32> buf; sl@0: buf.Format(KOrientation,&RotationName(iOrientation)); sl@0: INFO_PRINTF1(buf); sl@0: sl@0: iTestNo = 1; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = 1; sl@0: TestParams(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = KNumDispModes; sl@0: TestReadLine(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = KNumShadowModes * KNumDrawModes; sl@0: if(KFastFading && (iDispMode == EColor64K ||iDispMode == EColor16MU || iDispMode == EColor16MA || iDispMode == EColor16MAP)) sl@0: { sl@0: iUseFastFade = ETrue; sl@0: } sl@0: TestWriteRgb(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: TestWriteLine(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: TestWriteBinary(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = 4; sl@0: TestWriteRGBAlpha(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = KNumShadowModes; sl@0: TestShadow(); sl@0: if(KFastFading && (iDispMode == EColor64K|| iDispMode == EColor16MU || iDispMode == EColor16MA || iDispMode == EColor16MAP)) sl@0: { sl@0: iUseFastFade = EFalse; sl@0: } sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = 1; sl@0: TestWriteAlphaLineEx(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = 1; sl@0: TestWriteAlphaLineNoShadowEx(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = 1; sl@0: TestWriteMaskLineNoShadowEx(); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = 1; sl@0: TRAPD(err,((CTLowLevelStep*)iStep)->RecordTestResultL();); sl@0: if (err!=KErrNone) sl@0: INFO_PRINTF1(_L("Failed to record test result")); sl@0: sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0003")); sl@0: TestFastBlendBitmapMasked(); sl@0: TRAPD(err1,((CTLowLevelStep*)iStep)->RecordTestResultL();); sl@0: if (err1!=KErrNone) sl@0: INFO_PRINTF1(_L("Failed to record test result")); sl@0: sl@0: iTestNo++; sl@0: iIteration = 0; sl@0: iReportIteration = 1; sl@0: iTotalReportIterations = KNumBlendingColors; sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0002")); sl@0: //TestWriteRgbOutlineAndShadow(); // commented out pending case resolution #327407 sl@0: TRAP(err,((CTLowLevelStep*)iStep)->RecordTestResultL();); sl@0: if (err!=KErrNone) sl@0: INFO_PRINTF1(_L("Failed to record test result")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0001 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0001")); sl@0: } sl@0: sl@0: void CTLowLevel::TestParams() sl@0: { sl@0: Check(iDrawDevice->SizeInPixels()==iSize); sl@0: Check(iDrawDevice->DisplayMode()==iDispMode); sl@0: Check(iDrawDevice->LongWidth()==iLongWidth); sl@0: Check(iDrawDevice->ScanLineBuffer()!=NULL); sl@0: Check(iLongWidth%(iDrawDevice->ScanLineBytes())==0 sl@0: || iDrawDevice->ScanLineBytes() == iLongWidth * 2 sl@0: || iDrawDevice->ScanLineBytes() == iLongWidth * 3 sl@0: || iDrawDevice->ScanLineBytes() == iLongWidth * 4); sl@0: TInt hT = iDrawDevice->HorzTwipsPerThousandPixels(); sl@0: Check(hT >= 0); sl@0: TInt vT = iDrawDevice->VertTwipsPerThousandPixels(); sl@0: Check(vT >= 0); sl@0: Report(); sl@0: } sl@0: sl@0: void CTLowLevel::TestReadLine() sl@0: { sl@0: TInt byteSize = ByteSize(); sl@0: TUint8* writeBuffer = new TUint8[byteSize]; sl@0: TUint8* readBuffer = new TUint8[iSize.iWidth * sizeof(TRgb)]; sl@0: Check(writeBuffer != NULL); sl@0: Check(readBuffer != NULL); sl@0: sl@0: for (TInt nDispMode = 0; nDispMode < KNumDispModes; nDispMode++) sl@0: { sl@0: TDisplayMode dispMode = TestDisplayMode[nDispMode]; sl@0: iDrawDevice->SetUserDisplayMode(dispMode); sl@0: sl@0: if (dispMode == EColor16MU || dispMode == EColor16MAP || iDispMode == EColor16MU || iDispMode == EColor16MAP) sl@0: iFuzzyMatch=ETrue; sl@0: else sl@0: iFuzzyMatch=EFalse; sl@0: for (TInt cnt=0;cnt<2;cnt++) sl@0: { sl@0: if (cnt==0) //first time sl@0: iDrawDevice->SetUserDisplayMode(dispMode); sl@0: else sl@0: iDrawDevice->SetUserDisplayMode(iDispMode); sl@0: sl@0: for (TInt nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: TRect rect = TestRect[nRect]; sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: Clear(KRgbWhite); sl@0: sl@0: FillBuffer(writeBuffer, byteSize, iDispMode, ETrue); sl@0: Mem::FillZ(readBuffer,byteSize); sl@0: sl@0: //we select EDrawModeWriteAlpha because do not test blending here sl@0: iDrawDevice->WriteLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)writeBuffer,CGraphicsContext::EDrawModeWriteAlpha); sl@0: iDrawDevice->ReadLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)readBuffer,dispMode); sl@0: sl@0: CheckBuffer(writeBuffer,iDispMode,readBuffer,dispMode,rect.Width()); sl@0: sl@0: Mem::FillZ(readBuffer,byteSize); sl@0: sl@0: //we select EDrawModeWriteAlpha because do not test blending here sl@0: iDrawDevice->WriteLine(iSize.iWidth-rect.Width(),yy,rect.Width(),(TUint32*)writeBuffer,CGraphicsContext::EDrawModeWriteAlpha); sl@0: iDrawDevice->ReadLine(iSize.iWidth-rect.Width(),yy,rect.Width(),(TUint32*)readBuffer,dispMode); sl@0: sl@0: CheckBuffer(writeBuffer,iDispMode,readBuffer,dispMode,rect.Width()); sl@0: iIteration++; sl@0: } sl@0: } sl@0: } sl@0: if (iDispMode != EColor16MU && iDispMode != EColor16MAP) sl@0: iFuzzyMatch=EFalse; sl@0: Report(); sl@0: } sl@0: delete [] writeBuffer; sl@0: delete [] readBuffer; sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteRgb() sl@0: { sl@0: for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++) sl@0: { sl@0: for (TInt nMode = 0; nMode < KNumDrawModes; nMode++) sl@0: { sl@0: for (TInt nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: sl@0: //for modes other than EColor16MAP skip the new colours which have alpha, and cause sl@0: //test failures. There are two types of colours which need to be skipped, nColor, sl@0: //and nBackColor. The additional colours were added specificially to test EColor16MAP mode, sl@0: //so the test coverage compared to previously is not reduced for non EColor16MAP modes. sl@0: if (((nColor>=KMaxNon16Colours)|| (nBackColor>=KMaxNon16BackColours)) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: Clear(bakCol); sl@0: sl@0: CGraphicsContext::TDrawMode dMode = TestDrawMode[nMode]; sl@0: sl@0: if ((iDispMode==EColor16MAP)&&(dMode!=CGraphicsContext::EDrawModePEN)) sl@0: continue; sl@0: sl@0: sl@0: TRect rect = TestRect[nRect]; sl@0: TRgb col = TestColor[nColor]; sl@0: sl@0: iDrawDevice->CFbsDrawDevice::SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->CFbsDrawDevice::SetFadingParameters(100,200); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->WriteRgb(rect.iTl.iX,rect.iTl.iY,col,dMode); sl@0: sl@0: CheckRgb(rect.iTl,col,bakCol,dMode,shadowMode); sl@0: CheckBackground(TRect(rect.iTl,TSize(1,1)),bakCol); sl@0: sl@0: Clear(bakCol); sl@0: sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->WriteRgbMulti(rect.iTl.iX,rect.iTl.iY,rect.Width(),rect.Height(),col,dMode); sl@0: sl@0: CheckRgb(rect,col,bakCol,dMode,shadowMode); sl@0: CheckBackground(rect,bakCol); sl@0: iIteration++; sl@0: } sl@0: } sl@0: } sl@0: Report(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteLine() sl@0: { sl@0: TInt byteSize = ByteSize(); sl@0: TUint8* backBuffer = new TUint8[byteSize]; sl@0: TUint8* writeBuffer = new TUint8[byteSize]; sl@0: TUint8* copyBuffer = new TUint8[byteSize]; sl@0: TUint8* readBuffer = new TUint8[byteSize]; sl@0: Check(backBuffer != NULL); sl@0: Check(writeBuffer != NULL); sl@0: Check(copyBuffer != NULL); sl@0: Check(readBuffer != NULL); sl@0: sl@0: for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++) sl@0: { sl@0: for (TInt nMode = 0; nMode < KNumDrawModes; nMode++) sl@0: { sl@0: CGraphicsContext::TDrawMode dMode = TestDrawMode[nMode]; sl@0: for (TInt nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: //skip over new colours with alpha for modes other than EColor16MAP sl@0: //these were causing test failures sl@0: if ((nBackColor>=KMaxNon16BackColours) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: Clear(bakCol); sl@0: TRect rect = TestRect[nRect]; sl@0: /*TBuf<128> buf; //Some extra logging that might be useful if this test fails sl@0: _LIT(KLog1,"Shadow=%d, DrawMode=%d, Rect=(%d,%d,%d,%d), Color=%d"); sl@0: buf.Format(KLog1,shadowMode,dMode,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY,nBackColor); sl@0: INFO_PRINTF1(buf);*/ sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: iDrawDevice->CFbsDrawDevice::SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->CFbsDrawDevice::SetFadingParameters(100,200); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->ReadLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)backBuffer,iDispMode); sl@0: sl@0: if (nRect != 7) sl@0: { sl@0: // make sure the alpha value is 0xFF when not blending the buffer into 16MU destination sl@0: TBool noAlpha16MU = dMode != CGraphicsContext::EDrawModePEN; sl@0: FillBuffer(writeBuffer, byteSize, iDispMode, noAlpha16MU); sl@0: } sl@0: else // Special check for losing leading 0s in 1 bpp mode at 31 pixel offset sl@0: { sl@0: Mem::Fill(writeBuffer,byteSize,0xff); sl@0: writeBuffer[0] = 0xfe; sl@0: } sl@0: Mem::Copy(copyBuffer,writeBuffer,byteSize); sl@0: iDrawDevice->WriteLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)writeBuffer,dMode); sl@0: Shadow(copyBuffer,byteSize,shadowMode); sl@0: sl@0: Mem::FillZ(readBuffer,byteSize); sl@0: iDrawDevice->ReadLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)readBuffer,iDispMode); sl@0: CheckLine(copyBuffer,readBuffer,backBuffer,rect.Width(),dMode,iDispMode); sl@0: sl@0: iIteration++; sl@0: } sl@0: CheckBackground(rect,bakCol); sl@0: } sl@0: } sl@0: Report(); sl@0: } sl@0: } sl@0: delete [] backBuffer; sl@0: delete [] writeBuffer; sl@0: delete [] copyBuffer; sl@0: delete [] readBuffer; sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteBinary() sl@0: { sl@0: TInt byteSize = ByteSize(); sl@0: TInt wordSize = (byteSize + 3) / 4; sl@0: TUint32* writeBuffer = new TUint32[wordSize]; sl@0: Check(writeBuffer != NULL); sl@0: sl@0: for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++) sl@0: { sl@0: for (TInt nMode = 0; nMode < KNumDrawModes; nMode++) sl@0: { sl@0: for (TInt nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: if (((nColor>=KMaxNon16Colours)|| (nBackColor>=KMaxNon16BackColours)) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRect rect = TestRect[nRect]; sl@0: if (rect.Width() > 32) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + 32; sl@0: } sl@0: if (rect.Width() < 1) sl@0: rect.iBr.iX = rect.iTl.iX + 1; sl@0: sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: TRgb col = TestColor[nColor]; sl@0: CGraphicsContext::TDrawMode dMode = TestDrawMode[nMode]; sl@0: sl@0: if ((iDispMode==EColor16MAP)&&(dMode!=CGraphicsContext::EDrawModePEN)) sl@0: continue; sl@0: sl@0: Clear(bakCol); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: FillBuffer((TUint8*)writeBuffer, byteSize, EGray2); sl@0: iDrawDevice->WriteBinary(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),rect.Height(),col,dMode); sl@0: CheckBinary(rect,writeBuffer,col,bakCol,dMode,shadowMode,ETrue,EFalse); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: Clear(bakCol); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: FillBuffer((TUint8*)writeBuffer, byteSize, EGray2); sl@0: iDrawDevice->WriteBinaryLine(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),col,dMode); sl@0: CheckBinary(TRect(rect.iTl,TSize(rect.Width(),1)),writeBuffer,col,bakCol,dMode,shadowMode,EFalse,EFalse); sl@0: CheckBackground(TRect(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iTl.iY + 1),bakCol); sl@0: sl@0: Clear(bakCol); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: FillBuffer((TUint8*)writeBuffer, byteSize, EGray2); sl@0: iDrawDevice->WriteBinaryLineVertical(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Height(),col,dMode,EFalse); sl@0: CheckBinary(TRect(rect.iTl,TSize(1,rect.Height())),writeBuffer,col,bakCol,dMode,shadowMode,EFalse,EFalse); sl@0: CheckBackground(TRect(rect.iTl.iX,rect.iTl.iY,rect.iTl.iX + 1,rect.iBr.iY),bakCol); sl@0: sl@0: Clear(bakCol); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: FillBuffer((TUint8*)writeBuffer, byteSize, EGray2); sl@0: iDrawDevice->WriteBinaryLineVertical(rect.iTl.iX,rect.iBr.iY - 1,writeBuffer,rect.Height(),col,dMode,ETrue); sl@0: CheckBinary(TRect(rect.iTl,TSize(1,rect.Height())),writeBuffer,col,bakCol,dMode,shadowMode,EFalse,ETrue); sl@0: CheckBackground(TRect(rect.iTl.iX,rect.iTl.iY,rect.iTl.iX + 1,rect.iBr.iY),bakCol); sl@0: sl@0: iIteration++; sl@0: } sl@0: } sl@0: } sl@0: Report(); sl@0: } sl@0: } sl@0: delete [] writeBuffer; sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteAlphaLineEx() sl@0: { sl@0: TAny* interface = NULL; sl@0: TInt err = iDrawDevice->GetInterface(KFastBlitInterfaceID, interface); sl@0: if(err == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("START ---->TestWriteAlphaLineEx")); sl@0: TSize size = TSize(30,30); sl@0: TRect rect = TRect(size); sl@0: sl@0: TUint16* writeBuffer = new TUint16[size.iWidth]; sl@0: TUint8* maskBuffer = new TUint8[size.iWidth]; sl@0: sl@0: TInt nOffset = sizeof(TUint16)*size.iWidth/2; sl@0: sl@0: Mem::Fill(writeBuffer,nOffset,0xff); sl@0: Mem::Fill((((TUint8*)writeBuffer)+nOffset),nOffset,0x00); sl@0: Mem::Fill(maskBuffer,size.iWidth/2,0x00); sl@0: Mem::Fill((maskBuffer+size.iWidth/2),size.iWidth/2,0xff); sl@0: sl@0: MFastBlit* fastBlit = reinterpret_cast(interface); sl@0: Clear(KRgbFadedBlack); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::EFade); sl@0: sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: fastBlit->WriteAlphaLineEx(rect.iTl.iX,yy,rect.Width(),0,(TUint32*)writeBuffer,EColor64K,0,(TUint32*)maskBuffer,MAlphaBlend::EShdwBefore); sl@0: iIteration++; sl@0: } sl@0: CheckRgb(rect,KRgbBlack,KRgbFadedBlack,CGraphicsContext::EDrawModePEN,2); sl@0: CheckBackground(rect,KRgbFadedBlack); sl@0: sl@0: Report(); sl@0: INFO_PRINTF1(_L("END ---->TestWriteAlphaLineEx")); sl@0: delete [] writeBuffer; sl@0: delete [] maskBuffer; sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteAlphaLineNoShadowEx() sl@0: { sl@0: TAny* interface = NULL; sl@0: TInt err = iDrawDevice->GetInterface(KFastBlitInterfaceID, interface); sl@0: if(err == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("START ---->TestWriteAlphaLineNoShadowEx")); sl@0: TSize size = TSize(30,30); sl@0: TRect rect = TRect(size); sl@0: sl@0: TUint16* writeBuffer = new TUint16[size.iWidth]; sl@0: Check(writeBuffer != NULL); sl@0: TUint8* maskBuffer = new TUint8[size.iWidth]; sl@0: Check(maskBuffer != NULL); sl@0: TInt nOffset = sizeof(TUint16) * size.iWidth; sl@0: sl@0: Mem::Fill(writeBuffer,nOffset,0xff); sl@0: Mem::Fill(maskBuffer,size.iWidth/2,0x8e); sl@0: Mem::Fill((maskBuffer+size.iWidth/2),size.iWidth/2,0xff); sl@0: sl@0: MFastBlit* fastBlit = reinterpret_cast(interface); sl@0: sl@0: Clear(KRgbWhite); sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: fastBlit->WriteAlphaLineEx(rect.iTl.iX,yy,rect.Width(),0,(TUint32*)writeBuffer,EColor64K,0,(TUint32*)maskBuffer,MAlphaBlend::EShdwBefore); sl@0: iIteration++; sl@0: } sl@0: CheckRgb(rect,KRgbWhite,KRgbWhite,CGraphicsContext::EDrawModePEN,0); sl@0: sl@0: Report(); sl@0: INFO_PRINTF1(_L("END ---->TestWriteAlphaLineNoShadowEx")); sl@0: delete [] writeBuffer; sl@0: delete [] maskBuffer; sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteMaskLineNoShadowEx() sl@0: { sl@0: TAny* interface = NULL; sl@0: TInt err = iDrawDevice->GetInterface(KFastBlitInterfaceID, interface); sl@0: if(err == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("START ---->TestWriteMaskLineNoShadowEx")); sl@0: TSize size = TSize(30,30); sl@0: TRect rect = TRect(size); sl@0: sl@0: TUint16* writeBuffer = new TUint16[size.iWidth]; sl@0: Check(writeBuffer != NULL); sl@0: TUint8* maskBuffer = new TUint8[size.iWidth]; sl@0: Check(maskBuffer != NULL); sl@0: sl@0: TInt nOffset = sizeof(TUint16) * size.iWidth; sl@0: sl@0: Mem::Fill(writeBuffer,nOffset,0xff); sl@0: Mem::Fill(maskBuffer,size.iWidth/2,0x8e); sl@0: Mem::Fill((maskBuffer+size.iWidth/2),size.iWidth/2,0xff); sl@0: sl@0: MFastBlit* fastBlit = reinterpret_cast(interface); sl@0: sl@0: Clear(KRgbWhite); sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: fastBlit->WriteMaskLineEx(rect.iTl.iX,yy,rect.Width(),0,(TUint32*)writeBuffer,EColor64K,0,(TUint32*)maskBuffer,EFalse); sl@0: iIteration++; sl@0: } sl@0: CheckRgb(rect,KRgbWhite,KRgbWhite,CGraphicsContext::EDrawModePEN,0); sl@0: sl@0: Report(); sl@0: INFO_PRINTF1(_L("END ---->TestWriteMaskLineNoShadowEx")); sl@0: delete [] writeBuffer; sl@0: delete [] maskBuffer; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Overwrite the pixel in the buffer with a given mode with a value already in that sl@0: mode. sl@0: @param aX The offset in pixels from the start of the buffer. sl@0: @param aPtr The start of the buffer. sl@0: @param aMode The display mode of the buffer. sl@0: @param aValue The new pixel value. sl@0: */ sl@0: void CTLowLevel::WriteBinaryValue(TUint32 aX, TAny* const aPtr, sl@0: TDisplayMode aMode, TUint32 aValue) const sl@0: { sl@0: TUint32* buffer32 = (TUint32*)aPtr; sl@0: TInt shift; sl@0: TUint32 mask; sl@0: sl@0: switch (aMode) sl@0: { sl@0: case EGray2: sl@0: buffer32 += aX >> 5; sl@0: shift = aX & 0x1F; sl@0: mask = 0x1; sl@0: break; sl@0: case EGray4: sl@0: buffer32 += aX >> 4; sl@0: shift = (aX & 0xF) << 1; sl@0: mask = 0x3; sl@0: break; sl@0: case EGray16: sl@0: case EColor16: sl@0: buffer32 += aX >> 3; sl@0: shift = (aX & 0x7) << 2; sl@0: mask = 0xF; sl@0: break; sl@0: case EGray256: sl@0: case EColor256: sl@0: buffer32 += aX >> 2; sl@0: shift = (aX & 0x3) << 3; sl@0: mask = 0xFF; sl@0: break; sl@0: case EColor4K: sl@0: buffer32 += aX >> 1; sl@0: shift = (aX & 0x1) << 4; sl@0: mask = 0xFFF; sl@0: break; sl@0: case EColor64K: sl@0: buffer32 += aX >> 1; sl@0: shift = (aX & 0x1) << 4; sl@0: mask = 0xFFFF; sl@0: break; sl@0: case EColor16M: sl@0: { sl@0: // This mode requires special handling, because shifts and masks sl@0: // won't work. sl@0: TUint8* buffer8 = ((TUint8*)aPtr) + (aX * 3); sl@0: *buffer8++ = aValue & 0xFF; sl@0: *buffer8++ = (aValue >> 8) & 0xFF; sl@0: *buffer8++ = (aValue >> 16) & 0xFF; sl@0: // Return early as the buffer has been updated. sl@0: return; sl@0: } sl@0: case EColor16MU: sl@0: buffer32 += aX; sl@0: shift = 0; sl@0: mask = 0xFFFFFFFF; sl@0: aValue |= 0xFF000000; // Force alpha to opaque. sl@0: break; sl@0: default: sl@0: buffer32 += aX; sl@0: shift = 0; sl@0: mask = 0xFFFFFFFF; sl@0: break; sl@0: }; sl@0: sl@0: // Write pixel value into right part of word. sl@0: *buffer32 = (*buffer32 & ~(mask << shift)) | ((aValue & mask) << shift); sl@0: } sl@0: sl@0: /** sl@0: Copy contents of one buffer over another, depending on a per-pixel mask bit. sl@0: @param aSrc Source pixel buffer sl@0: @param aSrcMode Display mode of source sl@0: @param aDst Destination pixel buffer sl@0: @param aDstMode Display mode of destination sl@0: @param aMsk Mask buffer. Must be in EGray2 format sl@0: @param aWidth Number of pixels to copy sl@0: @param aInvert If ETrue, copy source where mask bit is clear, else copy where sl@0: it is set. sl@0: */ sl@0: void CTLowLevel::MaskedBlendBuffer(TAny* aSrc, TDisplayMode aSrcMode, TAny* aDst, sl@0: TDisplayMode aDstMode, TUint32* aMsk, TInt aWidth, TBool aInvert) sl@0: { sl@0: TColorConvertor& srcConvertor = ColorConvertor(aSrcMode); sl@0: TColorConvertor& dstConvertor = ColorConvertor(aDstMode); sl@0: sl@0: for (TInt xx = 0; xx < aWidth; xx++) sl@0: { sl@0: TUint32 pixelMask = ExtractBinaryValue(xx, aMsk, EGray2); sl@0: if (aInvert) sl@0: { sl@0: pixelMask = !pixelMask; sl@0: } sl@0: sl@0: if (pixelMask) sl@0: { sl@0: TUint32 dst32 = ExtractBinaryValue(xx, (TUint32*)aDst, aDstMode); sl@0: TUint32 src32 = ExtractBinaryValue(xx, (TUint32*)aSrc, aSrcMode); sl@0: sl@0: switch (aSrcMode) sl@0: { sl@0: // Only blend for source modes with alpha sl@0: case EColor16MAP: sl@0: case EColor16MA: sl@0: { sl@0: // Convert source and destination pixel values to 16MAP sl@0: if (aDstMode != EColor16MAP) sl@0: { sl@0: dst32 = dstConvertor.Color(dst32).Color16MAP(); sl@0: } sl@0: if (aSrcMode != EColor16MAP) sl@0: { sl@0: src32 = srcConvertor.Color(src32).Color16MAP(); sl@0: } sl@0: // Both params must be 16MAP, output is likewise sl@0: dst32 = PMAPixelBlend(dst32, src32); sl@0: // Convert 16MAP to final format sl@0: dst32 = dstConvertor.Index(TRgb::Color16MAP(dst32)); sl@0: } sl@0: break; sl@0: // Anything else is a copy (with format conversion) sl@0: default: sl@0: dst32 = dstConvertor.Index(srcConvertor.Color(src32)); sl@0: break; sl@0: } sl@0: sl@0: WriteBinaryValue(xx, aDst, aDstMode, dst32); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Returns the minimum number of bytes to hold the given number of pixels, sl@0: rounded up to the next word boundary. sl@0: @param aPixels Number of pixels sl@0: @param aMode Display mode of pixels sl@0: @return Number of bytes to hold pixels sl@0: */ sl@0: TUint32 CTLowLevel::BytesForPixels(TUint32 aPixels, TDisplayMode aMode) sl@0: { sl@0: TUint32 bytes = LongWidth(aPixels, aMode); sl@0: sl@0: switch (aMode) sl@0: { sl@0: case EGray2: sl@0: bytes /= 8; sl@0: break; sl@0: case EGray4: sl@0: bytes /= 4; sl@0: break; sl@0: case EGray16: sl@0: case EColor16: sl@0: bytes /= 2; sl@0: break; sl@0: case EColor4K: sl@0: case EColor64K: sl@0: bytes *= 2; sl@0: break; sl@0: case EColor16M: sl@0: bytes *= 3; sl@0: break; sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: bytes *= 4; sl@0: break; sl@0: } sl@0: return bytes; sl@0: } sl@0: sl@0: /** sl@0: Compare the actual blend results with the expected ones, allowing for some sl@0: blending errors. Both buffers must be in aMode format sl@0: @param aActual Start of actual results sl@0: @param aExpected Start of expected results sl@0: @param aWidth Number of pixels to check sl@0: @param aMode Display mode of the pixels in the buffers sl@0: @param aBlended ETrue if pixels were blended, EFalse if they were opaque sl@0: @return ETrue if buffers compared OK, EFalse if there was a mismatch. sl@0: */ sl@0: TBool CTLowLevel::CompareBlendMaskResults(TAny* aActual, TAny* aExpected, sl@0: TUint32 aWidth, TDisplayMode aMode, TBool aBlended, TDisplayMode aSrcMode) sl@0: { sl@0: if (aBlended) sl@0: { sl@0: // There can be blending rounding errors, so allow for these. In general sl@0: // allow for one bit of error, taking into account the precision of sl@0: // each component. sl@0: TInt maxRBErr; sl@0: TInt maxGErr; sl@0: switch (aMode) sl@0: { sl@0: case EColor4K: sl@0: // All components are four bits sl@0: maxRBErr = maxGErr = 17; sl@0: break; sl@0: case EColor64K: sl@0: // Six bits for green, five for the others, so error sl@0: // varies. sl@0: maxRBErr = 9; sl@0: maxGErr = 5; sl@0: break; sl@0: default: sl@0: // For 16MAP, it will be dependent on the alpha value. sl@0: maxRBErr = maxGErr = 1; sl@0: break; sl@0: } sl@0: sl@0: // Compare each pixel, allowing for the error in each component. sl@0: for (TInt xx = 0; xx < aWidth; xx++) sl@0: { sl@0: TRgb exp = ExtractRgbValue(xx, (TUint8*)aExpected, aMode); sl@0: TRgb act = ExtractRgbValue(xx, (TUint8*)aActual, aMode); sl@0: sl@0: if (aMode == EColor16MAP) sl@0: { sl@0: // Take into account that components have been premultiplied sl@0: TInt alpha = exp.Alpha(); sl@0: if (alpha > 0) sl@0: { sl@0: maxRBErr = maxGErr = (0xFF + alpha - 1) / alpha; sl@0: } sl@0: if (aSrcMode == EColor16MA && (maxGErr < 3 || maxRBErr < 3)) sl@0: { sl@0: maxGErr = 3; sl@0: maxRBErr = 3; sl@0: } sl@0: } sl@0: sl@0: if (AbsDiff(exp.Red(), act.Red()) > maxRBErr || sl@0: AbsDiff(exp.Green(), act.Green()) > maxGErr || sl@0: AbsDiff(exp.Blue(), act.Blue()) > maxRBErr || sl@0: exp.Alpha() != act.Alpha()) sl@0: { sl@0: INFO_PRINTF4(_L("At %d, expected 0x%08.8x, got 0x%08.8x"), sl@0: xx, exp.Internal(), act.Internal()); sl@0: return EFalse; sl@0: } sl@0: } sl@0: return ETrue; sl@0: } sl@0: else sl@0: { sl@0: // For non-alpha sources there is no blending, so results sl@0: // should be exact. sl@0: TUint32 stride = BytesForPixels(aWidth, aMode); sl@0: return (Mem::Compare((TUint8*)aActual, stride, (TUint8*)aExpected, stride) == 0); sl@0: } sl@0: } sl@0: sl@0: class TFunctionThread sl@0: { sl@0: protected: sl@0: TFunctionThread():iExitHow(ENotStarted) sl@0: {} sl@0: TInt LaunchThreadFunction(const TDesC& aName); sl@0: private: sl@0: static TInt TheThreadFunction(TAny*); sl@0: virtual TInt ThreadFunctionL()=0; sl@0: public: sl@0: enum { sl@0: ENotStarted, sl@0: ERunning, //should never see this sl@0: EReturn, sl@0: ELeave, sl@0: EPanic, sl@0: ETerminate, sl@0: }; sl@0: TInt iExitHow; sl@0: TInt iExitCode; //Currently don't store the panic category string. sl@0: }; sl@0: sl@0: TInt TFunctionThread::LaunchThreadFunction(const TDesC& aName) sl@0: { sl@0: RThread thrd; sl@0: TRequestStatus stat; sl@0: enum { //8kb to 2mb sl@0: KMinHeapSize=0x2000, sl@0: KMaxHeapSize=0x200000 sl@0: }; sl@0: TInt created=thrd.Create(aName,TheThreadFunction,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,this); sl@0: if (creatediExitHow=thisThis->ERunning; sl@0: TInt returnErr = KErrNone; sl@0: TRAPD(leaveErr,returnErr=thisThis->ThreadFunctionL()); sl@0: if (leaveErr) sl@0: { sl@0: thisThis->iExitHow=ELeave; sl@0: thisThis->iExitCode=leaveErr; sl@0: return leaveErr; sl@0: } sl@0: else sl@0: { sl@0: thisThis->iExitHow=EReturn; sl@0: thisThis->iExitCode=returnErr; sl@0: return returnErr; sl@0: } sl@0: } sl@0: sl@0: /** This thread verifies whether a range of memory is accessible sl@0: The range is read sequentially until it panics, or the range is completed. sl@0: It is useful to input a range of addresses where some are valid and some fail sl@0: in order to demonstrate an edge against which an algorithm that performs illegal reads can subsequently be tested. sl@0: The FailOffset() returned index indicates the offset from the start at which the memory access caused a panic. sl@0: **/ sl@0: class TTestMemThread:public TFunctionThread sl@0: { sl@0: public: sl@0: TTestMemThread(TUint32* aStartAddress,TUint32* aEndAddress); sl@0: TInt FailOffset(); sl@0: private: sl@0: virtual TInt ThreadFunctionL(); sl@0: private: sl@0: TUint32* iStartAddress; sl@0: TUint32* iEndAddress; sl@0: volatile TUint32* iLastAddressTried; sl@0: volatile TUint32 iCopyValueHere; sl@0: sl@0: }; sl@0: sl@0: TTestMemThread::TTestMemThread(TUint32* aStartAddress,TUint32* aEndAddress): sl@0: iStartAddress(aStartAddress), sl@0: iEndAddress(aEndAddress), sl@0: iLastAddressTried(NULL) sl@0: { sl@0: ASSERT(aStartAddress); sl@0: ASSERT(aEndAddress); sl@0: LaunchThreadFunction(_L("MemTest")); sl@0: } sl@0: sl@0: /** sl@0: * Returns the number of successful memory reads before a panic occurred sl@0: * Or various error codes if the test didn't run or didn't panic. sl@0: * sl@0: **/ sl@0: TInt TTestMemThread::FailOffset() sl@0: { sl@0: if (iExitHow==EReturn) sl@0: { sl@0: return KErrCompletion; sl@0: } sl@0: else sl@0: { sl@0: if (iExitHow==EPanic) sl@0: { sl@0: if (iLastAddressTried) sl@0: { sl@0: TInt retval=iLastAddressTried-iStartAddress; sl@0: if (iEndAddress-iStartAddress<0) sl@0: { sl@0: retval=-retval; sl@0: } sl@0: if (retval<0) sl@0: { sl@0: return KErrCorrupt; sl@0: } sl@0: else sl@0: { sl@0: return retval; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: } sl@0: } sl@0: /* sl@0: * This thread function allows a test to verify that a particular address range sl@0: * is actually inaccessable. sl@0: * I.e. that attempting to read from the given address range causes a panic. sl@0: */ sl@0: TInt TTestMemThread::ThreadFunctionL() sl@0: { sl@0: if (iStartAddress && iEndAddress) sl@0: { sl@0: TInt delta=1; sl@0: if (iStartAddress>iEndAddress) sl@0: { sl@0: delta=-1; sl@0: } sl@0: for (TUint32 volatile* tryAddress=iStartAddress;tryAddress!=iEndAddress;tryAddress+=delta) sl@0: { sl@0: iLastAddressTried=tryAddress; sl@0: iCopyValueHere=*tryAddress; sl@0: } sl@0: return 0; sl@0: } sl@0: return KErrArgument; sl@0: } sl@0: sl@0: void CTLowLevel::ClosePanicDialogs() sl@0: { sl@0: RWsSession session; sl@0: TInt err = session.Connect(); sl@0: TEST(err == KErrNone); sl@0: TInt idFocus = session.GetFocusWindowGroup(); sl@0: TWsEvent event; sl@0: event.SetType(EEventKey); //EEventKeyDown sl@0: TKeyEvent* keyEvent = event.Key(); sl@0: keyEvent->iCode = EKeyEscape; sl@0: keyEvent->iScanCode = EStdKeyEscape; sl@0: keyEvent->iModifiers = 0; sl@0: TInt theLimit = 50; sl@0: while(idFocus != NULL && (theLimit-- > 0)) sl@0: { sl@0: session.SendEventToAllWindowGroups(event); sl@0: TInt idNewFocus = session.GetFocusWindowGroup(); sl@0: idFocus=idNewFocus; sl@0: } sl@0: session.Flush(); sl@0: session.Close(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0003 sl@0: @SYMTestCaseDesc Test that FastBlendBitmapMasked masking works correctly sl@0: @SYMDEF INC120146 PDEF120693 PDEF120680 INC120742 PDEF121725 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test actions are: sl@0: Create pseudorandom initial contents, source and mask lines. sl@0: Set a line of the screen to the initial contents. sl@0: Use FastBlendBitmapMasked, with and without inverted bitmask, to write sl@0: source to target. sl@0: Read line contents back. sl@0: Check each pixel is either the initial value, or the source or a blend, sl@0: depending on corresponding mask pixel. sl@0: Repeat this whole sequence with supported source display modes. sl@0: NOTE - wrapped in memory check for edge case defect INC120742 sl@0: @SYMTestExpectedResults The correct pixel values are set, based on the mask. sl@0: */ sl@0: void CTLowLevel::TestFastBlendBitmapMasked(const TInt aRetry) sl@0: { sl@0: const TInt KRetryAmount = 10; sl@0: sl@0: TAny* interface = NULL; sl@0: TInt err = iDrawDevice->GetInterface(KFastBlendInterfaceID, interface); sl@0: if(err == KErrNone) sl@0: { sl@0: if (aRetry == 0) sl@0: { sl@0: INFO_PRINTF1(_L("START ---->TestFastBlendBitmapMasked")); sl@0: } sl@0: sl@0: MFastBlend* fastBlend = reinterpret_cast(interface); sl@0: TInt yPos = iSize.iHeight / 2; sl@0: TPoint pt(0,yPos); sl@0: TSize lineSize(iSize.iWidth, 1); sl@0: TRect lineRect(lineSize); sl@0: sl@0: TInt destStride = iDrawDevice->ScanLineBytes(); sl@0: TInt maskStride = (iSize.iWidth + 7) / 8; sl@0: TInt maskPages = (maskStride/4096+1); sl@0: maskPages+=20; sl@0: // Allocate large enough buffers for all modes sl@0: TAny* source = User::Alloc(iSize.iWidth * 4); sl@0: TAny* expected = User::Alloc(destStride); sl@0: CFbsBitmap testBitmap; sl@0: testBitmap.Create(TSize(1024,maskPages),EColor16MA); sl@0: TUint32* mask = testBitmap.DataAddress()+1024-(maskStride%4096)/4; sl@0: TUint32* slb = iDrawDevice->ScanLineBuffer(); sl@0: sl@0: Check(source != NULL && expected != NULL && mask != NULL); sl@0: sl@0: TUint32* bitmapData=testBitmap.DataAddress(); sl@0: SEpocBitmapHeader header1 = testBitmap.Header(); sl@0: TUint32* pastBitmapData=bitmapData+((header1.iBitmapSize-header1.iStructSize)>>2); sl@0: mask = pastBitmapData- (maskStride+3)/4; sl@0: sl@0: TBool canGenerateDefectScenario = EFalse; sl@0: TTestMemThread memThread(pastBitmapData-2,pastBitmapData+2); sl@0: TInt failAt=memThread.FailOffset(); sl@0: if (failAt<0) sl@0: { sl@0: INFO_PRINTF2(_L("Error generated by test thread! %i - BAD"),failAt); sl@0: } sl@0: else if (failAt<=1) sl@0: { sl@0: INFO_PRINTF1(_L("Bitmap memory is inaccessable - BAD")); sl@0: } sl@0: else if (failAt>2) sl@0: { sl@0: INFO_PRINTF1(_L("Memory after bitmap is accessable - BAD")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Memory after bitmap is inaccessable - GOOD")); sl@0: canGenerateDefectScenario=ETrue; sl@0: } sl@0: ClosePanicDialogs(); sl@0: sl@0: if (!canGenerateDefectScenario) sl@0: { sl@0: //if this doesn't work out then the memory allocator is not like it was when the defect was raised! sl@0: //so the test is no longer any good. sl@0: if (aRetry == KRetryAmount) sl@0: { sl@0: INFO_PRINTF2(_L("Failed %d times - Overall test failure"),KRetryAmount); sl@0: Check(EFalse); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("RETRYING - attempt %d"),aRetry+2); sl@0: TestFastBlendBitmapMasked(aRetry+1); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Performing test")); sl@0: for (TInt sourceModeIndex = 0; sourceModeIndex < KNumberDisplayModes1; sourceModeIndex++) sl@0: { sl@0: for (TInt invert = 0; invert < 2; invert++) sl@0: { sl@0: TDisplayMode sourceMode = TestDisplayMode1[sourceModeIndex]; sl@0: TInt sourceStride = BytesForPixels(iSize.iWidth, sourceMode); sl@0: TBool blended = (sourceMode == EColor16MA || sourceMode == EColor16MAP); sl@0: sl@0: // Initialise (randomise) the buffers for this iteration sl@0: FillBuffer((TUint8*)source, sourceStride, sourceMode, ETrue); sl@0: FillBuffer((TUint8*)expected, destStride, iDispMode, ETrue); sl@0: FillBuffer((TUint8*)mask, maskStride, EGray2, ETrue); sl@0: sl@0: // Write out the initial contents sl@0: iDrawDevice->WriteLine(0, yPos, iSize.iWidth, (TUint32*)expected, sl@0: CGraphicsContext::EDrawModeWriteAlpha); sl@0: sl@0: // Fast, masked overwrite, with or without mask inversion sl@0: TInt result = fastBlend->FastBlendBitmapMasked(pt, sl@0: (TUint32*)source, sourceStride, lineSize, lineRect, sl@0: sourceMode, mask, maskStride, EGray2, lineSize, sl@0: TPoint(), invert, CGraphicsContext::EDrawModePEN, sl@0: CFbsDrawDevice::ENoShadow); sl@0: sl@0: if (result == KErrNotSupported) sl@0: { sl@0: // Unsupported combination of parameters, move on. sl@0: continue; sl@0: } sl@0: sl@0: // Use mask to blend source with 'expected' to get the expected sl@0: // output sl@0: MaskedBlendBuffer(source, sourceMode, expected, iDispMode, sl@0: mask, iSize.iWidth, invert); sl@0: sl@0: // Read back actual output and compare with expected. sl@0: iDrawDevice->ReadLine(0, yPos, iSize.iWidth, slb, iDispMode); sl@0: sl@0: if (!CompareBlendMaskResults(slb, expected, iSize.iWidth, sl@0: iDispMode, blended, sourceMode)) sl@0: { sl@0: INFO_PRINTF3(_L("Output mismatch: source mode %S, invert=%d"), sl@0: &DisplayModeNames1[sourceModeIndex], invert); sl@0: // Report other details, plus fail the overall test. sl@0: Check(EFalse); sl@0: } sl@0: iIteration++; sl@0: } sl@0: sl@0: } sl@0: TTestMemThread memThreadAfter(pastBitmapData-2,pastBitmapData+2); sl@0: failAt=memThreadAfter.FailOffset(); sl@0: if (failAt != 2) sl@0: { sl@0: INFO_PRINTF1(_L("Memory after bitmap is accessable - BAD")); sl@0: if (aRetry >= KRetryAmount) sl@0: { sl@0: INFO_PRINTF2(_L("Failed %d times - Overall test failure"),KRetryAmount); sl@0: Check(EFalse); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("RETRYING - attempt %d"),aRetry+2); sl@0: TestFastBlendBitmapMasked(aRetry+1); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Memory after bitmap is inaccessable - GOOD")); sl@0: } sl@0: ClosePanicDialogs(); sl@0: } sl@0: if (aRetry == 0) sl@0: { sl@0: INFO_PRINTF1(_L("END ---->TestFastBlendBitmapMasked")); sl@0: Report(); sl@0: } sl@0: sl@0: User::Free(source); sl@0: User::Free(expected); sl@0: testBitmap.Reset(); sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::TestWriteRGBAlpha() sl@0: { sl@0: TUint8* writeBuffer = new TUint8[iSize.iWidth * 4]; sl@0: TUint8* writeBuffer2 = new TUint8[iSize.iWidth * 4]; sl@0: TUint8* maskBuffer = new TUint8[iSize.iWidth]; sl@0: Check(writeBuffer != NULL); sl@0: Check(maskBuffer != NULL); sl@0: sl@0: TInt nRect; sl@0: sl@0: //special test for EColor16MAP sl@0: if (iDispMode == EColor16MAP) sl@0: { sl@0: //mask fill has vaues 0x00, 0xff, and 0x3A. The mask is used for blending sl@0: for (TInt maskFillCount=0; maskFillCountSetUserDisplayMode(UserDisplayModes[userDispMode]); sl@0: iUserDispMode = UserDisplayModes[userDispMode]; sl@0: if (iUserDispMode == EColor16MA) sl@0: i16MAUserDispMode = ETrue; sl@0: else sl@0: i16MAUserDispMode = EFalse; sl@0: sl@0: TRgb col = TestColor[nColor]; sl@0: TUint32 internal = col.Internal(); sl@0: TUint32 *writeBuf32 = (TUint32*)writeBuffer; sl@0: TInt cnt; sl@0: //fill the buffer with colour sl@0: for (cnt=0;cntCFbsDrawDevice::SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->CFbsDrawDevice::SetFadingParameters(100,200); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: sl@0: TInt yy; sl@0: for (yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),writeBuffer,maskBuffer,CGraphicsContext::EDrawModePEN); sl@0: iIteration++; sl@0: } sl@0: sl@0: //ensure the colour has the 0xff mask value sl@0: TRgb checkColor; sl@0: //use a combined alpha for the check colour sl@0: TUint32 combinedAlpha = MaskFill[maskFillCount]*((internal&0xff000000)>>24); sl@0: combinedAlpha = ((combinedAlpha <<16) & 0xff000000); sl@0: checkColor.SetInternal((internal&0x00ffffff)|combinedAlpha); sl@0: //check colour is not a PMA colour, but has alpha sl@0: CheckRgb(rect,checkColor,bakCol,CGraphicsContext::EDrawModePEN,CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: //the other WriteRgbAlpha line uses the other shadow mode sl@0: TUint32 *writeBuf2 = (TUint32*)writeBuffer2; sl@0: TUint32 buf2val= NonPMA2PMAPixel(bakCol.Internal()); sl@0: //fill the buffer with colour sl@0: for (cnt=0;cntCFbsDrawDevice::SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->CFbsDrawDevice::SetFadingParameters(100,200); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: sl@0: for (yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(), sl@0: writeBuffer, sl@0: writeBuffer2, sl@0: maskBuffer, sl@0: CGraphicsContext::EDrawModeWriteAlpha); sl@0: iIteration++; sl@0: } sl@0: //require to Shadow After the checkColor, no shadow with a zero mask sl@0: TBool shadowModeChanged = EFalse; sl@0: if (MaskFill[maskFillCount]) sl@0: { sl@0: iPostBlendShadow = (TPostShadowMode) shadowMode; sl@0: shadowMode = 0; sl@0: shadowModeChanged = ETrue; sl@0: } sl@0: CheckRgb(rect,checkColor,bakCol,CGraphicsContext::EDrawModePEN,shadowMode); sl@0: if(shadowModeChanged) shadowMode = iPostBlendShadow; sl@0: iPostBlendShadow = ENoPostShadow; sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: Clear(bakCol); sl@0: sl@0: iDrawDevice->CFbsDrawDevice::SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->CFbsDrawDevice::SetFadingParameters(100,200); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: sl@0: for (TInt yy2 = rect.iTl.iY; yy2 < rect.iBr.iY; yy2++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaMulti(rect.iTl.iX,yy2,rect.Width(),col,maskBuffer); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,checkColor,bakCol,CGraphicsContext::EDrawModePEN,CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: CheckBackground(rect,bakCol); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: Report(); sl@0: iDrawDevice->SetUserDisplayMode(iDispMode); sl@0: i16MAUserDispMode = EFalse; sl@0: iUserDispMode = ENone; sl@0: Mem::Fill(writeBuffer,iSize.iWidth * 4,0xff); sl@0: Mem::Fill(maskBuffer,iSize.iWidth,0xff); sl@0: sl@0: for (nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: if ((nBackColor>=KMaxNon16BackColours) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: Clear(bakCol); sl@0: TRect rect = TestRect[nRect]; sl@0: sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),writeBuffer,maskBuffer,CGraphicsContext::EDrawModePEN); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,KRgbWhite,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: Clear(bakCol); sl@0: sl@0: for (TInt yy2 = rect.iTl.iY; yy2 < rect.iBr.iY; yy2++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaMulti(rect.iTl.iX,yy2,rect.Width(),KRgbWhite,maskBuffer); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,KRgbWhite,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: } sl@0: } sl@0: Report(); sl@0: sl@0: Mem::FillZ(writeBuffer,iSize.iWidth * 3); sl@0: sl@0: for (nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: if ((nBackColor>=KMaxNon16BackColours) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: //need to fill with 0xff alpha, so blending takes place sl@0: if (iDispMode== EColor16MAP) sl@0: { sl@0: const TUint32 black = 0xff000000; sl@0: TUint32 *writeBuf32 = (TUint32*) writeBuffer; sl@0: for (TInt cnt=0;cntWriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),writeBuffer,maskBuffer,CGraphicsContext::EDrawModePEN); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,KRgbBlack,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: Clear(bakCol); sl@0: sl@0: for (TInt yy2 = rect.iTl.iY; yy2 < rect.iBr.iY; yy2++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaMulti(rect.iTl.iX,yy2,rect.Width(),KRgbBlack,maskBuffer); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,KRgbBlack,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: } sl@0: } sl@0: Report(); sl@0: sl@0: Mem::FillZ(maskBuffer,iSize.iWidth); sl@0: sl@0: for (nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: if ((nBackColor>=KMaxNon16BackColours) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: Clear(bakCol); sl@0: TRect rect = TestRect[nRect]; sl@0: sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),writeBuffer,maskBuffer,CGraphicsContext::EDrawModePEN); sl@0: iIteration++; sl@0: } sl@0: sl@0: TRgb checkColor2=bakCol; sl@0: if (iDispMode == EColor16MAP) sl@0: checkColor2.SetInternal (0); sl@0: sl@0: CheckRgb(rect,checkColor2,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: Clear(bakCol); sl@0: sl@0: for (TInt yy2 = rect.iTl.iY; yy2 < rect.iBr.iY; yy2++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaMulti(rect.iTl.iX,yy2,rect.Width(),KRgbBlack,maskBuffer); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,checkColor2,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: } sl@0: } sl@0: Report(); sl@0: sl@0: Mem::Fill(writeBuffer,iSize.iWidth * 3,0xff); sl@0: sl@0: for (nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: if ((nBackColor>=KMaxNon16BackColours) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: Clear(bakCol); sl@0: TRect rect = TestRect[nRect]; sl@0: sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaLine(rect.iTl.iX,yy,rect.Width(),writeBuffer,maskBuffer,CGraphicsContext::EDrawModePEN); sl@0: iIteration++; sl@0: } sl@0: TRgb checkColor3=bakCol; sl@0: if (iDispMode == EColor16MAP) sl@0: checkColor3.SetInternal (0xffffff); sl@0: sl@0: CheckRgb(rect,checkColor3,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: sl@0: Clear(bakCol); sl@0: sl@0: for (TInt yy2 = rect.iTl.iY; yy2 < rect.iBr.iY; yy2++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaMulti(rect.iTl.iX,yy2,rect.Width(),KRgbWhite,maskBuffer); sl@0: iIteration++; sl@0: } sl@0: sl@0: CheckRgb(rect,checkColor3,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: } sl@0: } sl@0: Report(); sl@0: sl@0: //Extra test for DEF082251 sl@0: if (iDispMode==EColor16MU) sl@0: { sl@0: Mem::Fill(maskBuffer,iSize.iWidth,0x7f); sl@0: sl@0: for (nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: TRgb bakCol = TestBackground[nBackColor]; sl@0: Clear(bakCol); sl@0: TRect rect=TestRect[nRect]; sl@0: sl@0: const TInt red = 50; sl@0: const TInt green = 60; sl@0: const TInt blue = 70; sl@0: const TInt alpha = 80; sl@0: sl@0: for (TInt yy2 = rect.iTl.iY; yy2 < rect.iBr.iY; yy2++) sl@0: { sl@0: iDrawDevice->WriteRgbAlphaMulti(rect.iTl.iX,yy2,rect.Width(), sl@0: TRgb(red,green,blue,alpha),maskBuffer); sl@0: iIteration++; sl@0: } sl@0: sl@0: //work out the color - based on OptimizedBlend32 in the sl@0: //screendriver bmdraw32.cpp sl@0: TInt combinedAlpha = (alpha * 0x7f)>>8; sl@0: sl@0: const TUint32 alphaValue = (combinedAlpha << 8) + combinedAlpha; sl@0: TUint32 secondary= bakCol.Value(); sl@0: sl@0: const TInt r2 = secondary & 0x000000ff; sl@0: const TInt g2 = (secondary & 0x0000ff00) >> 8; sl@0: const TInt b2 = (secondary & 0x00ff0000) >> 16; sl@0: sl@0: const TInt r3 = ((alphaValue * (red - r2)) >> 16) + r2; sl@0: const TInt g3 = ((alphaValue * (green - g2)) >> 16) + g2; sl@0: const TInt b3 = ((alphaValue * (blue - b2)) >> 16) + b2; sl@0: sl@0: TInt result= (b3 & 0xFF) | ((g3<<8) & 0xFF00) | ((r3<<16) & 0xFF0000) | 0xFF000000; sl@0: TRgb resultColor = TRgb(result,0); sl@0: sl@0: CheckRgb(rect,resultColor,bakCol,CGraphicsContext::EDrawModePEN,0); sl@0: CheckBackground(rect,bakCol); sl@0: } sl@0: } sl@0: Report(); sl@0: } sl@0: delete [] writeBuffer; sl@0: delete [] maskBuffer; sl@0: delete [] writeBuffer2; sl@0: } sl@0: sl@0: void CTLowLevel::TestShadow() sl@0: { sl@0: for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++) sl@0: { sl@0: for (TInt nRect = 0; nRect < KNumTestRects; nRect++) sl@0: { sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: if ((nColor>=KMaxNon16Colours) && (iDispMode!= EColor16MAP)) sl@0: continue; sl@0: sl@0: TRgb col = TestColor[nColor]; sl@0: Clear(col); sl@0: sl@0: TRect rect = TestRect[nRect]; sl@0: sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->ShadowArea(rect); sl@0: sl@0: CheckShadowRgb(rect,col,shadowMode); sl@0: sl@0: TRgb checkColor=col; sl@0: if (iDispMode == EColor16MAP) sl@0: { sl@0: checkColor.SetInternal (0); //only want contribution from one colour sl@0: } sl@0: sl@0: TRect outside(0,0,iSize.iWidth,rect.iTl.iY); sl@0: if (!outside.IsEmpty()) sl@0: CheckRgb(outside,checkColor,col,CGraphicsContext::EDrawModePEN,0); sl@0: outside.SetRect(0,rect.iBr.iY,iSize.iWidth,iSize.iHeight); sl@0: if (!outside.IsEmpty()) sl@0: CheckRgb(outside,checkColor,col,CGraphicsContext::EDrawModePEN,0); sl@0: outside.SetRect(0,rect.iTl.iY,rect.iTl.iX,rect.iBr.iY); sl@0: if (!outside.IsEmpty()) sl@0: CheckRgb(outside,checkColor,col,CGraphicsContext::EDrawModePEN,0); sl@0: outside.SetRect(rect.iBr.iX,rect.iTl.iY,iSize.iWidth,rect.iBr.iY); sl@0: if (!outside.IsEmpty()) sl@0: CheckRgb(outside,checkColor,col,CGraphicsContext::EDrawModePEN,0); sl@0: iIteration++; sl@0: } sl@0: } sl@0: Report(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0002 sl@0: sl@0: @SYMPREQ PREQ1543 sl@0: sl@0: @SYMTestCaseDesc This test code tests WriteRgbOutlineAndShadow() which blends the four colours. sl@0: Colours used for blending are outline, shadow, foreground and background. sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions It compares the colour written by WriteRgbOutlineAndShadow() with colour sl@0: calculated using lookup table provided by Monotype. sl@0: API Calls: sl@0: CDrawBitmap::GetInterface() sl@0: MOutlineAndShadowBlend::WriteRgbOutlineAndShadow() sl@0: CDrawBitmap::ReadLine() sl@0: sl@0: @SYMTestExpectedResults Test should pass and colour written by WriteRgbOutlineAndShadow should sl@0: match with the colour calculated through lookup table. sl@0: */ sl@0: void CTLowLevel::TestWriteRgbOutlineAndShadow() sl@0: { sl@0: MOutlineAndShadowBlend* outlineAndShadow = NULL; sl@0: TInt byteSize = ByteSize(); sl@0: TUint8* writeBuffer = new TUint8[iSize.iWidth * sizeof(TRgb)]; sl@0: TUint8* readBuffer = new TUint8[iSize.iWidth * sizeof(TRgb)]; sl@0: TColorConvertor& colorConvertor = ColorConvertor(iDispMode); sl@0: Check(writeBuffer != NULL); sl@0: Check(readBuffer != NULL); sl@0: TInt err = iDrawDevice->GetInterface(KOutlineAndShadowInterfaceID, reinterpret_cast (outlineAndShadow)); sl@0: Check(err == KErrNone); sl@0: sl@0: TRect rect = TestRect[0]; sl@0: for (TInt nBlendingColors = 0; nBlendingColors < KNumBlendingColors; nBlendingColors++) sl@0: { sl@0: // Select different combinations of colours for testing from the array sl@0: TRgb outlinePenColor = TestOSFBColorsForBlending[nBlendingColors][0]; sl@0: TRgb shadowColor = TestOSFBColorsForBlending[nBlendingColors][1]; sl@0: TRgb fillColor = TestOSFBColorsForBlending[nBlendingColors][2]; sl@0: TRgb backgroundColor = colorConvertor.Color(colorConvertor.Index(TestOSFBColorsForBlending[nBlendingColors][3])); sl@0: Clear(backgroundColor); sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: // Run the test for values from 0 to 255 so that it will cover all the entries sl@0: // of lookup table provided by Monotype sl@0: for (TInt index = 0; index < 256; index++) sl@0: { sl@0: // In case alpha is supported and if alpha value is less than 255 then the colour drawn will be different sl@0: // than the colour specified as it blends with the existing background pixel colour. sl@0: TRgb backgroundColorDrawn= iDrawDevice->ReadPixel(rect.iTl.iX, yy); sl@0: sl@0: // Fill zeroes in the readBuffer so that we can make sure that there is no garbage value. sl@0: Mem::FillZ(readBuffer, iSize.iWidth * 3); sl@0: sl@0: // We are writing index in writeBuffer to simulate the buffer provided by rasterizer sl@0: // This index should be a value between 0-255, It would be corresponding the entries of lookup table sl@0: Mem::Fill(writeBuffer, iSize.iWidth * 3, index); sl@0: sl@0: // Below function blends outline, shadow, foreground and background colours, and writes aLength pixels with new colour sl@0: // starting from aX, aY. sl@0: err = outlineAndShadow->WriteRgbOutlineAndShadow(rect.iTl.iX, yy , rect.Width(), outlinePenColor.Internal(), sl@0: shadowColor.Internal(),fillColor.Internal(),writeBuffer); sl@0: Check(err == KErrNone); sl@0: sl@0: // Read the whole line which has been written by WriteRgbOutlineAndShadow() sl@0: iDrawDevice->ReadLine(rect.iTl.iX, yy, rect.Width(), (TUint32*)readBuffer, iDispMode); sl@0: sl@0: // Check colour of each pixel, it should be same as the colour which is calulated manually in CheckBlendedOutlineAndShadow() sl@0: TBool result = CheckBlendedOutlineAndShadow(outlinePenColor, shadowColor, fillColor, backgroundColorDrawn, index, rect.Width(), readBuffer); sl@0: Check(result); sl@0: if (!result) sl@0: { sl@0: Report(); sl@0: delete [] writeBuffer; sl@0: delete [] readBuffer; sl@0: return; sl@0: } sl@0: sl@0: iIteration++; sl@0: } sl@0: } sl@0: Report(); sl@0: } sl@0: delete [] writeBuffer; sl@0: delete [] readBuffer; sl@0: } sl@0: sl@0: inline TInt CTLowLevel::ByteSize() sl@0: { sl@0: return ::ByteSize(iDispMode,iSize.iWidth); sl@0: } sl@0: sl@0: TInt CTLowLevel::LongWidth(TInt aWidth,TDisplayMode aDispMode) sl@0: { sl@0: switch (aDispMode) sl@0: { sl@0: case EGray2: sl@0: return (aWidth + 31) & ~31; sl@0: case EGray4: sl@0: return (aWidth + 15) & ~15; sl@0: case EGray16: sl@0: case EColor16: sl@0: return (aWidth + 7) & ~7; sl@0: case EGray256: sl@0: case EColor256: sl@0: return (aWidth + 3) & ~3; sl@0: case EColor4K: sl@0: case EColor64K: sl@0: return (aWidth + 1) & ~1; sl@0: case EColor16M: sl@0: return (((aWidth * 3) + 11) / 12) * 4; sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: return aWidth; sl@0: default: sl@0: break; sl@0: }; sl@0: return 0; sl@0: } sl@0: sl@0: void CTLowLevel::Clear(TRgb aColor) sl@0: { sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow); sl@0: iDrawDevice->WriteRgbMulti(0,0,iSize.iWidth,iSize.iHeight,aColor,CGraphicsContext::EDrawModeWriteAlpha); sl@0: } sl@0: sl@0: /* sl@0: Fill aBuffer with aByteSize random bytes in such a way that the result is a sl@0: valid scan line buffer for a driver of which the display mode is aDispMode. sl@0: If aDispMode is EColor16MU, the alpha bytes will be 0xFF if aNoAlpha16MU is ETrue, sl@0: or random bytes if aNoAlpha16MU is EFalse. sl@0: */ sl@0: void CTLowLevel::FillBuffer(TUint8* aBuffer, TInt aByteSize, TDisplayMode aDispMode, TBool aNoAlpha16MU) sl@0: { sl@0: TUint8* bufferLimit = aBuffer + aByteSize; sl@0: TUint8* buffer=aBuffer; sl@0: sl@0: TInt64 seed = TInt64(TInt(aBuffer) * aByteSize * aDispMode * User::TickCount()); sl@0: sl@0: if (aDispMode != EColor16MU || !aNoAlpha16MU) sl@0: { sl@0: while (aBuffer < bufferLimit) sl@0: { sl@0: *aBuffer++ = (TUint8)Math::Rand(seed); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: while (aBuffer < bufferLimit) sl@0: { sl@0: if (TInt(aBuffer) & 3 == 3) sl@0: *aBuffer++ = 0xFF; sl@0: else sl@0: *aBuffer++ = (TUint8)Math::Rand(seed); sl@0: } sl@0: } sl@0: if (aDispMode == EColor16MU && !aNoAlpha16MU || aDispMode == EColor16MAP) sl@0: { sl@0: //need to do the premultiply alpha to ensure that all the colours are valid sl@0: //in the colour space sl@0: for (;buffer < (bufferLimit-3);buffer+=4) sl@0: { sl@0: TUint alpha=*(buffer+3); sl@0: *(buffer)=((*(buffer))* alpha)/255; //do a pre multiply alpha operation sl@0: *(buffer+1)=((*(buffer+1))* alpha)/255; sl@0: *(buffer+2)=((*(buffer+2))* alpha)/255; sl@0: } sl@0: } sl@0: sl@0: } sl@0: sl@0: void CTLowLevel::CheckBuffer(TUint8* aWriteBuffer,TDisplayMode aWriteDispMode,TUint8* aReadBuffer,TDisplayMode aReadDispMode,TInt aPixelLength) sl@0: { sl@0: switch (aWriteDispMode) sl@0: { sl@0: case EGray2: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: break; sl@0: case EGray4: sl@0: if (aReadDispMode == EGray2) sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: else sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: break; sl@0: case EGray16: sl@0: if (aReadDispMode == EGray2) sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: else if (aReadDispMode == EGray4) sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: else if (aReadDispMode == EColor16) sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor16); sl@0: else sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray16); sl@0: break; sl@0: case EGray256: sl@0: switch (aReadDispMode) sl@0: { sl@0: case EGray2: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: break; sl@0: case EGray4: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: break; sl@0: case EGray16: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray16); sl@0: break; sl@0: case EGray256: sl@0: case EColor16M: sl@0: case ERgb: sl@0: case EColor16MU: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray256); sl@0: break; sl@0: case EColor16: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor16); sl@0: break; sl@0: case EColor256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor256); sl@0: break; sl@0: case EColor4K: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor4K); sl@0: break; sl@0: case EColor64K: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor64K); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: break; sl@0: case EColor16: sl@0: switch (aReadDispMode) sl@0: { sl@0: case EGray2: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: break; sl@0: case EGray4: sl@0: case EGray16: sl@0: case EGray256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: break; sl@0: case EColor16: sl@0: case EColor256: sl@0: case EColor4K: sl@0: case EColor64K: sl@0: case EColor16M: sl@0: case ERgb: sl@0: case EColor16MU: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor16); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: break; sl@0: case EColor256: sl@0: switch (aReadDispMode) sl@0: { sl@0: case EGray2: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: break; sl@0: case EGray4: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: break; sl@0: case EGray16: sl@0: case EGray256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray16); sl@0: break; sl@0: case EColor16: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor16); sl@0: break; sl@0: case EColor256: sl@0: case EColor4K: sl@0: case EColor64K: sl@0: case EColor16M: sl@0: case ERgb: sl@0: case EColor16MU: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor256); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: break; sl@0: case EColor4K: sl@0: switch (aReadDispMode) sl@0: { sl@0: case EGray2: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: break; sl@0: case EGray4: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: break; sl@0: case EGray16: sl@0: case EGray256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray16); sl@0: break; sl@0: case EColor16: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor16); sl@0: break; sl@0: case EColor256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor256); sl@0: break; sl@0: case EColor4K: sl@0: case EColor64K: sl@0: case EColor16M: sl@0: case ERgb: sl@0: case EColor16MU: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor4K); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: break; sl@0: case EColor64K: sl@0: switch (aReadDispMode) sl@0: { sl@0: case EGray2: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray2); sl@0: break; sl@0: case EGray4: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray4); sl@0: break; sl@0: case EGray16: sl@0: case EGray256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EGray16); sl@0: break; sl@0: case EColor16: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor16); sl@0: break; sl@0: case EColor256: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor256); sl@0: break; sl@0: case EColor4K: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor4K); sl@0: break; sl@0: case EColor64K: sl@0: case EColor16M: sl@0: case ERgb: sl@0: case EColor16MU: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,EColor64K); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: break; sl@0: case EColor16M: sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: CheckPixel(aWriteBuffer,aWriteDispMode,aReadBuffer,aReadDispMode,aPixelLength,aReadDispMode); sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: void CTLowLevel::CheckPixel(TUint8* aWriteBuffer,TDisplayMode aWriteDispMode,TUint8* aReadBuffer,TDisplayMode aReadDispMode,TInt aPixelLength,TDisplayMode aCompareDispMode) sl@0: { sl@0: TColorConvertor& colorConvertor = ColorConvertor(aCompareDispMode); sl@0: sl@0: for (TInt count = 0; count < aPixelLength; count++) sl@0: { sl@0: TRgb writeValue = ExtractRgbValue(count,aWriteBuffer,aWriteDispMode); sl@0: TRgb readValue = ExtractRgbValue(count,aReadBuffer,aReadDispMode); sl@0: CheckMatch(colorConvertor.Index(writeValue),colorConvertor.Index(readValue)); sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::CheckRgb(const TPoint& aPoint,TRgb aColor,TRgb aBackgroundColor,CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode) sl@0: { sl@0: TRect rect(aPoint,TSize(1,1)); sl@0: iDrawDevice->CFbsDrawDevice::SetDitherOrigin(aPoint); sl@0: CheckRgb(rect,aColor,aBackgroundColor,aDrawMode,aShadowMode); sl@0: } sl@0: sl@0: void CTLowLevel::CheckRgb(const TRect& aRect,TRgb aColor,TRgb aBackgroundColor,CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode) sl@0: { sl@0: Shadow(aColor,aShadowMode); sl@0: sl@0: if (aDrawMode == CGraphicsContext::EDrawModeNOTPEN) sl@0: aColor = ~aColor; sl@0: sl@0: TRgb foreColor[4]; sl@0: Normalize(aColor,foreColor); sl@0: sl@0: TRgb backColor[4]; sl@0: Normalize(aBackgroundColor,backColor); sl@0: sl@0: TRgb fore11 = foreColor[0]; sl@0: TRgb fore21 = foreColor[1]; sl@0: TRgb back11 = backColor[0]; sl@0: TRgb back21 = backColor[1]; sl@0: TRgb fore12 = foreColor[2]; sl@0: TRgb fore22 = foreColor[3]; sl@0: TRgb back12 = backColor[2]; sl@0: TRgb back22 = backColor[3]; sl@0: sl@0: TInt startY = aRect.iTl.iY; sl@0: TInt endY = aRect.iBr.iY - 1; sl@0: sl@0: if (startY & 1) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,startY,aRect.Width(),fore12,fore22,back12,back22,aDrawMode); sl@0: startY++; sl@0: } sl@0: sl@0: for (TInt yy = startY; yy < endY; yy += 2) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,yy,aRect.Width(),fore11,fore21,back11,back21,aDrawMode); sl@0: CheckScanline(aRect.iTl.iX,yy + 1,aRect.Width(),fore12,fore22,back12,back22,aDrawMode); sl@0: } sl@0: sl@0: if (aRect.iBr.iY & 1) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,endY,aRect.Width(),fore11,fore21,back11,back21,aDrawMode); sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::CheckShadowRgb(const TRect& aRect,TRgb aColor,TInt aShadowMode) sl@0: { sl@0: TRgb foreColor[4]; sl@0: Normalize(aColor,foreColor); sl@0: sl@0: TRgb fore11 = foreColor[0]; sl@0: TRgb fore21 = foreColor[1]; sl@0: TRgb fore12 = foreColor[2]; sl@0: TRgb fore22 = foreColor[3]; sl@0: sl@0: Shadow(fore11,aShadowMode & 2); sl@0: Shadow(fore21,aShadowMode & 2); sl@0: Shadow(fore12,aShadowMode & 2); sl@0: Shadow(fore22,aShadowMode & 2); sl@0: sl@0: Normalize(fore11); sl@0: Normalize(fore21); sl@0: Normalize(fore12); sl@0: Normalize(fore22); sl@0: sl@0: Shadow(fore11,aShadowMode & 1); sl@0: Shadow(fore21,aShadowMode & 1); sl@0: Shadow(fore12,aShadowMode & 1); sl@0: Shadow(fore22,aShadowMode & 1); sl@0: sl@0: Normalize(fore11); sl@0: Normalize(fore21); sl@0: Normalize(fore12); sl@0: Normalize(fore22); sl@0: sl@0: TInt startY = aRect.iTl.iY; sl@0: TInt endY = aRect.iBr.iY - 1; sl@0: sl@0: iDrawDevice->CFbsDrawDevice::ShadowArea(aRect); sl@0: sl@0: if (iDispMode== EColor16MAP) sl@0: { sl@0: //No dithering, no blending, just checking for a solid colour sl@0: fore12.SetAlpha(0);//do not want any blending to take place sl@0: fore22.SetAlpha(0);//do not want any blending to take place sl@0: for (TInt yy = startY; yy < endY; yy ++) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,yy,aRect.Width(),fore11,fore11,fore22,fore22,CGraphicsContext::EDrawModePEN); sl@0: } sl@0: return; sl@0: } sl@0: sl@0: if (startY & 1) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,startY,aRect.Width(),fore12,fore22,fore12,fore22,CGraphicsContext::EDrawModePEN); sl@0: startY++; sl@0: } sl@0: sl@0: for (TInt yy = startY; yy < endY; yy += 2) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,yy,aRect.Width(),fore11,fore21,fore11,fore21,CGraphicsContext::EDrawModePEN); sl@0: CheckScanline(aRect.iTl.iX,yy + 1,aRect.Width(),fore12,fore22,fore12,fore22,CGraphicsContext::EDrawModePEN); sl@0: } sl@0: sl@0: if (aRect.iBr.iY & 1) sl@0: { sl@0: CheckScanline(aRect.iTl.iX,endY,aRect.Width(),fore11,fore21,fore11,fore21,CGraphicsContext::EDrawModePEN); sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::CheckScanline(TInt aX,TInt aY,TInt aLength,TRgb aFore1,TRgb aFore2,TRgb aBack1,TRgb aBack2,CGraphicsContext::TDrawMode aDrawMode) sl@0: { sl@0: iDrawDevice->ReadLine(aX,aY,aLength,iDrawDevice->ScanLineBuffer(),iDispMode); sl@0: sl@0: TUint32 binaryPixel1 = BinaryValue(aFore1,aBack1,aDrawMode); sl@0: TUint32 binaryPixel2 = BinaryValue(aFore2,aBack2,aDrawMode); sl@0: if (aX & 1) sl@0: { sl@0: TUint32 spare = binaryPixel1; sl@0: binaryPixel1 = binaryPixel2; sl@0: binaryPixel2 = spare; sl@0: } sl@0: sl@0: TInt extra = aLength & 1; sl@0: aLength &= ~1; sl@0: TInt x = 0; sl@0: sl@0: if (iPostBlendShadow) sl@0: { sl@0: PostBlendShadow(binaryPixel1); sl@0: PostBlendShadow(binaryPixel2); sl@0: } sl@0: if (i16MAUserDispMode) sl@0: { sl@0: binaryPixel1 = PMA2NonPMAPixel(binaryPixel1,PtrTo16BitNormalisationTable()); sl@0: binaryPixel2 = PMA2NonPMAPixel(binaryPixel1,PtrTo16BitNormalisationTable()); sl@0: } sl@0: while (x < aLength) sl@0: { sl@0: TUint32 binaryValue = ExtractBinaryValue(x,iDrawDevice->ScanLineBuffer(),iDispMode); sl@0: CheckMatch(binaryPixel1,binaryValue); sl@0: x++; sl@0: sl@0: binaryValue = ExtractBinaryValue(x,iDrawDevice->ScanLineBuffer(),iDispMode); sl@0: CheckMatch(binaryPixel2,binaryValue); sl@0: x++; sl@0: } sl@0: if (extra) sl@0: { sl@0: TUint32 binaryValue = ExtractBinaryValue(x,iDrawDevice->ScanLineBuffer(),iDispMode); sl@0: CheckMatch(binaryPixel1,binaryValue); sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::CheckLine(TUint8* aWriteBuffer,TUint8* aReadBuffer,TUint8* aBackBuffer,TInt aPixelLength,CGraphicsContext::TDrawMode aDrawMode,TDisplayMode aDispMode) sl@0: { sl@0: TInt wholeBytes = 0; sl@0: TInt extraBits = 0; sl@0: sl@0: switch (aDispMode) sl@0: { sl@0: case EGray2: sl@0: wholeBytes = aPixelLength / 8; sl@0: extraBits = aPixelLength & 7; sl@0: break; sl@0: case EGray4: sl@0: wholeBytes = aPixelLength / 4; sl@0: extraBits = (aPixelLength & 3) * 2; sl@0: break; sl@0: case EGray16: sl@0: case EColor16: sl@0: wholeBytes = aPixelLength / 2; sl@0: extraBits = (aPixelLength & 1) * 4; sl@0: break; sl@0: case EGray256: sl@0: case EColor256: sl@0: wholeBytes = aPixelLength; sl@0: break; sl@0: case EColor4K: sl@0: case EColor64K: sl@0: wholeBytes = aPixelLength * 2; sl@0: break; sl@0: case EColor16M: sl@0: wholeBytes = aPixelLength * 3; sl@0: break; sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: wholeBytes = aPixelLength * 4; sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: sl@0: TUint8* readLimit = aReadBuffer + wholeBytes; sl@0: TUint8 mask = TUint8(0xff >> (8 - extraBits)); sl@0: TInt byteCounter = 0; sl@0: sl@0: switch (aDrawMode) sl@0: { sl@0: case CGraphicsContext::EDrawModeAND: sl@0: if (iDispMode==EColor16MAP) sl@0: break; //logical opeations not supported for premultiplied alpha sl@0: for (; aReadBuffer < readLimit; aReadBuffer++, aWriteBuffer++, aBackBuffer++) sl@0: { sl@0: if(!((aDispMode == EColor16MU || aDispMode == EColor16MA || aDispMode == EColor16MAP) sl@0: && ++byteCounter % 4 == 0)) sl@0: Check(*aReadBuffer == (*aWriteBuffer & *aBackBuffer)); sl@0: } sl@0: if (extraBits > 0) sl@0: Check((*aReadBuffer & mask) == (*aWriteBuffer & *aBackBuffer & mask)); sl@0: break; sl@0: case CGraphicsContext::EDrawModePEN: sl@0: if(aDispMode == EColor16MU || aDispMode == EColor16MA || aDispMode == EColor16MAP) sl@0: { sl@0: for (; aReadBuffer(aReadBuffer),*reinterpret_cast(aWriteBuffer),iFuzzyMatch,KInaccuracyLimit,aReadBuffer,aWriteBuffer); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: for (; aReadBuffer < readLimit; aReadBuffer++, aWriteBuffer++) sl@0: { sl@0: if (Check(*aReadBuffer == *aWriteBuffer)) sl@0: { sl@0: _LIT(KLog,"The values 0x%x and 0x%x don't match, memory 0x%x 0x%x"); sl@0: INFO_PRINTF5(KLog,*aReadBuffer,*aWriteBuffer,aReadBuffer,aWriteBuffer); sl@0: } sl@0: } sl@0: if (extraBits > 0) sl@0: Check((*aReadBuffer & mask) == (*aWriteBuffer & mask)); sl@0: } sl@0: break; sl@0: case CGraphicsContext::EDrawModeNOTPEN: sl@0: if (iDispMode==EColor16MAP) sl@0: break; //logical opeations not supported for premultiplied alpha sl@0: if(aDispMode == EColor16MU || aDispMode == EColor16MA ) sl@0: { sl@0: for (; aReadBuffer < readLimit; aReadBuffer +=4, aWriteBuffer+=4) sl@0: { sl@0: *aWriteBuffer ^= 0xff; sl@0: *(aWriteBuffer+1) ^= 0xff; sl@0: *(aWriteBuffer+2) ^= 0xff; sl@0: sl@0: Blend(aWriteBuffer,aBackBuffer,aDispMode); sl@0: sl@0: if (!iFuzzyMatch) sl@0: { sl@0: Check(AbsDiff(*aReadBuffer, *aWriteBuffer) < 2); sl@0: Check(AbsDiff(*(aReadBuffer+1), *(aWriteBuffer+1)) < 2); sl@0: Check(AbsDiff(*(aReadBuffer+2), *(aWriteBuffer+2)) < 2); sl@0: Check(AbsDiff(*(aReadBuffer+3), *(aWriteBuffer+3)) < 2); sl@0: } sl@0: else sl@0: { sl@0: Check(AbsDiff(*aReadBuffer, *aWriteBuffer) < KInaccuracyLimit); sl@0: Check(AbsDiff(*(aReadBuffer+1), *(aWriteBuffer+1)) < KInaccuracyLimit); sl@0: Check(AbsDiff(*(aReadBuffer+2), *(aWriteBuffer+2)) < KInaccuracyLimit); sl@0: Check(AbsDiff(*(aReadBuffer+3), *(aWriteBuffer+3)) < KInaccuracyLimit); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: sl@0: for (; aReadBuffer < readLimit; aReadBuffer++, aWriteBuffer++) sl@0: { sl@0: if(!((aDispMode == EColor16MU || aDispMode == EColor16MA || aDispMode == EColor16MAP) && ++byteCounter % 4 == 0)) sl@0: Check(*aReadBuffer == (*aWriteBuffer ^ 0xff)); sl@0: } sl@0: if (extraBits > 0) sl@0: Check((*aReadBuffer & mask) == ((*aWriteBuffer ^ 0xff) & mask)); sl@0: } sl@0: break; sl@0: case CGraphicsContext::EDrawModeXOR: sl@0: if (iDispMode==EColor16MAP) sl@0: break;//logical opeations not supported for premultiplied alpha sl@0: for (; aReadBuffer < readLimit; aReadBuffer++, aWriteBuffer++, aBackBuffer++) sl@0: { sl@0: if(!((aDispMode == EColor16MU || aDispMode == EColor16MA || aDispMode == EColor16MAP) && ++byteCounter % 4 == 0)) sl@0: Check(*aReadBuffer == (*aWriteBuffer ^ *aBackBuffer)); sl@0: } sl@0: if (extraBits > 0) sl@0: Check((*aReadBuffer & mask) == ((*aWriteBuffer ^ *aBackBuffer) & mask)); sl@0: break; sl@0: case CGraphicsContext::EDrawModeOR: sl@0: if (iDispMode==EColor16MAP) sl@0: break;//logical opeations not supported for premultiplied alpha sl@0: for (; aReadBuffer < readLimit; aReadBuffer++, aWriteBuffer++, aBackBuffer++) sl@0: { sl@0: if(!((aDispMode == EColor16MU || aDispMode == EColor16MA || aDispMode == EColor16MAP) && ++byteCounter % 4 == 0)) sl@0: Check(*aReadBuffer == (*aWriteBuffer | *aBackBuffer)); sl@0: } sl@0: if (extraBits > 0) sl@0: Check((*aReadBuffer & mask) == ((*aWriteBuffer | *aBackBuffer) & mask)); sl@0: break; sl@0: case CGraphicsContext::EDrawModeNOTSCREEN: sl@0: if (iDispMode==EColor16MAP) sl@0: break;//logical opeations not supported for premultiplied alpha sl@0: if (aDispMode != EColor4K) sl@0: { sl@0: for (; aReadBuffer < readLimit; aReadBuffer++, aBackBuffer++) sl@0: { sl@0: if(!((aDispMode == EColor16MU || aDispMode == EColor16MA || aDispMode == EColor16MAP) && ++byteCounter % 4 == 0)) sl@0: { sl@0: if (iFuzzyMatch==EFalse) sl@0: Check(*aReadBuffer == (*aBackBuffer ^ 0xff)); sl@0: else sl@0: { sl@0: TUint8 vals[3]; sl@0: vals[0]=*aReadBuffer; sl@0: //put in some tolerance values, try with +/- 1, to begin with sl@0: if (vals[0]<255) sl@0: vals[1]=vals[0]+1; sl@0: else sl@0: vals[1]=vals[0]; sl@0: if (vals[0]>0) sl@0: vals[2]=vals[0]-1; sl@0: else sl@0: vals[2]=vals[0]; sl@0: Check((vals[0] == (*aBackBuffer ^ 0xff))|| sl@0: (vals[1] == (*aBackBuffer ^ 0xff))|| sl@0: (vals[2] == (*aBackBuffer ^ 0xff))); sl@0: } sl@0: } sl@0: } sl@0: if (extraBits > 0) sl@0: Check((*aReadBuffer & mask) == ((*aBackBuffer ^ 0xff) & mask)); sl@0: } sl@0: else sl@0: { sl@0: while (aReadBuffer < readLimit) sl@0: { sl@0: if (TInt(aReadBuffer) & 1) sl@0: Check(*aReadBuffer++ == (*aBackBuffer++ ^ 0x0f)); sl@0: else sl@0: Check(*aReadBuffer++ == (*aBackBuffer++ ^ 0xff)); sl@0: } sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: void CTLowLevel::CheckBinary(const TRect& aRect,TUint32* aBuffer,TRgb aForeColor,TRgb aBackColor,CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode,TBool aWrapDataWords,TBool aUp) sl@0: { sl@0: Shadow(aForeColor,aShadowMode); sl@0: sl@0: if (aDrawMode == CGraphicsContext::EDrawModeNOTPEN) sl@0: aForeColor = ~aForeColor; sl@0: sl@0: TRgb foreColor[4]; sl@0: Normalize(aForeColor,foreColor); sl@0: sl@0: TRgb backColor[4]; sl@0: Normalize(aBackColor,backColor); sl@0: sl@0: foreColor[0] = RgbValue(foreColor[0],backColor[0],aDrawMode); sl@0: foreColor[1] = RgbValue(foreColor[1],backColor[1],aDrawMode); sl@0: foreColor[2] = RgbValue(foreColor[2],backColor[2],aDrawMode); sl@0: foreColor[3] = RgbValue(foreColor[3],backColor[3],aDrawMode); sl@0: sl@0: sl@0: if (iDispMode==EColor16MAP) sl@0: { sl@0: //pre-multiply and unpremultiply sl@0: TInt count; sl@0: for (count=0;count<4;count++) sl@0: { sl@0: TUint32 tempInt; sl@0: tempInt = backColor[count].Color16MAP(); //Now premultiplied sl@0: backColor[count] = TRgb::Color16MAP(tempInt); sl@0: } sl@0: } sl@0: sl@0: TUint32 data = *aBuffer++; sl@0: TUint32 mask = 1; sl@0: sl@0: TInt yy = (aUp) ? aRect.iBr.iY - 1 : aRect.iTl.iY; sl@0: TInt ylimit = (aUp) ? aRect.iTl.iY - 1 : aRect.iBr.iY; sl@0: TInt yinc = (aUp) ? -1 : 1; sl@0: sl@0: TRgb pixelBuffer[KCheckBinaryPixelBufferSize]; sl@0: __ASSERT_ALWAYS(aRect.Width() <= KCheckBinaryPixelBufferSize,User::Panic(_L("CheckBinary buffer"),KErrOverflow)); sl@0: sl@0: for (; yy != ylimit; yy += yinc) sl@0: { sl@0: TInt yoffset = 2 * (yy & 1); sl@0: sl@0: iDrawDevice->ReadLine(aRect.iTl.iX,yy,aRect.Width(),pixelBuffer,ERgb); sl@0: TRgb* color = pixelBuffer; sl@0: sl@0: for (TInt xx = aRect.iTl.iX; xx < aRect.iBr.iX; xx++) sl@0: { sl@0: if (!mask) sl@0: { sl@0: mask = 1; sl@0: data = *aBuffer++; sl@0: } sl@0: sl@0: if (data & mask) sl@0: CheckMatch((*color).Internal(), foreColor[(xx & 1) + yoffset].Internal()); sl@0: else sl@0: CheckMatch((*color).Internal(), backColor[(xx & 1) + yoffset].Internal()); sl@0: sl@0: color++; sl@0: mask <<= 1; sl@0: } sl@0: sl@0: if (aWrapDataWords) sl@0: mask = 0; sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::CheckBackground(const TRect& aRect,TRgb aBackgroundColor) sl@0: { sl@0: iBlendTestColors= EFalse; sl@0: if (aRect.iTl.iX > 0) sl@0: CheckRgb(TRect(aRect.iTl.iX - 1,aRect.iTl.iY,aRect.iTl.iX,aRect.iBr.iY),aBackgroundColor,aBackgroundColor,CGraphicsContext::EDrawModePEN,0); sl@0: if (aRect.iTl.iY > 0) sl@0: CheckRgb(TRect(aRect.iTl.iX,aRect.iTl.iY - 1,aRect.iBr.iX,aRect.iTl.iY),aBackgroundColor,aBackgroundColor,CGraphicsContext::EDrawModePEN,0); sl@0: if (aRect.iBr.iX < iSize.iWidth - 1) sl@0: CheckRgb(TRect(aRect.iBr.iX,aRect.iTl.iY,aRect.iBr.iX + 1,aRect.iBr.iY),aBackgroundColor,aBackgroundColor,CGraphicsContext::EDrawModePEN,0); sl@0: if (aRect.iBr.iY < iSize.iHeight - 1) sl@0: CheckRgb(TRect(aRect.iTl.iX,aRect.iBr.iY,aRect.iBr.iX,aRect.iBr.iY + 1),aBackgroundColor,aBackgroundColor,CGraphicsContext::EDrawModePEN,0); sl@0: iBlendTestColors= ETrue; sl@0: } sl@0: /** sl@0: This function is copied as it is from BMDRAW32A.CPP which is used to test WriteRgbOutlineAndShadow for EColor16MA. sl@0: It is used in CTLowLevel::CheckBlendedOutlineAndShadow. sl@0: @param aBeneath The background pixel colour value sl@0: @param aSrcColor The source pixel colour value sl@0: @param aAlpha The alpha value sl@0: */ sl@0: FORCEINLINE TUint32 OptimizedBlend32A(TUint32 aBeneath,TUint32 aSrcColor,TUint8 aAlpha) sl@0: { sl@0: if(aAlpha) sl@0: { sl@0: if(aAlpha == 0xff) // opaque, so unchanged sl@0: { sl@0: //Still need to convert source to destination from non-multiplied to pre-multiplied sl@0: //But this code resolves to a copy. The ARM optimiser prefers shifts over big constants. sl@0: return (aSrcColor|(aAlpha<<24)); sl@0: } sl@0: else sl@0: { sl@0: //0, 1, 2, 3 sl@0: //b, g, rect, alpha sl@0: sl@0: const TUint32 srcMult = aAlpha; sl@0: TUint32 destMult = ((255 - aAlpha) * ((aBeneath >> 24))); sl@0: //This gives a slightly more accurate result than ((aBeneath >> 24)+1) sl@0: destMult=destMult+(destMult>>8); sl@0: destMult+= 0x0080; sl@0: destMult >>= 8; sl@0: sl@0: TUint32 rb =(((aSrcColor&0x00ff00ff)*srcMult)) + (((aBeneath&0x00ff00ff)*destMult)); sl@0: rb = rb+((rb>>8)&0x00ff00ff); sl@0: rb+=0x00800080; sl@0: rb>>=8; sl@0: TUint32 ag = (((aSrcColor&0x0000ff00)*srcMult)) + (((aBeneath&0x0000ff00)*destMult)); sl@0: ag>>=8; //Note that if alpha is processed here, this shift must be performed before the multiplies sl@0: ag = ag+((ag>>8)&0x00ff00ff); sl@0: ag+=0x00800080; sl@0: TUint32 aa = srcMult+destMult; sl@0: return (rb&0x00ff00ff) | (ag&0x0000ff00) | (aa << 24); sl@0: sl@0: } sl@0: } sl@0: else // completely transparent sl@0: { sl@0: return aBeneath; sl@0: } sl@0: sl@0: } sl@0: sl@0: /** sl@0: Helper function for TestWriteRgbOutlineAndShadow(). Creates the final colour, blending the outline, shadow, sl@0: fill and background colour using lookup table provided by Monotype and compares with the sl@0: pixel colour drawn using WriteRgbOutlineAndShadow. sl@0: sl@0: @param aOutlinePenColor Colour used for drawing outline of font sl@0: @param aShadowColor Colour used for drawing shadow of font sl@0: @param aFillColor Colour used for filling of font sl@0: @param aBackgroundColor Background colour of the pixel sl@0: @param aLookupIndex Index of the lookup table to be used for generating final colour sl@0: @param aLength Number of pixels to compare the pixel colour with the generated colour sl@0: @param aReadBuffer Buffer containing the colours drawn using WriteRgbOutlineAndShadow.This will be used for comparing sl@0: @return EFalse if pixel colour doesnt match with the calculated colour, otherwise ETrue on success. sl@0: */ sl@0: TBool CTLowLevel::CheckBlendedOutlineAndShadow(TRgb aOutlinePenColor, TRgb aShadowColor, TRgb aFillColor, sl@0: TRgb aBackgroundColor, TInt aLookupIndex, TInt aLength, TUint8* aReadBuffer) sl@0: { sl@0: TRgb finalColor; sl@0: TInt alpha = aOutlinePenColor.Internal() >> 24; sl@0: sl@0: if (255 == FourColorBlendLookup[aLookupIndex][3]) sl@0: { sl@0: //background colour sl@0: finalColor.SetInternal(aBackgroundColor.Internal()); sl@0: sl@0: /*Reset the alpha with background colour alpha as in product code in case of 255 == FourColorBlendLookup[aLookupIndex][3] sl@0: it doesnt draw and leaves the background colour as it is. So the alpha to be checked should be of background colour alpha*/ sl@0: alpha = aBackgroundColor.Alpha(); sl@0: } sl@0: else if (255 == FourColorBlendLookup[aLookupIndex][2]) sl@0: { sl@0: //fill colour sl@0: finalColor.SetInternal(aFillColor.Internal()); sl@0: } sl@0: else if (255 == FourColorBlendLookup[aLookupIndex][1]) sl@0: { sl@0: //Shadow colour sl@0: finalColor.SetInternal(aShadowColor.Internal()); sl@0: } sl@0: else if (255 == FourColorBlendLookup[aLookupIndex][0]) sl@0: { sl@0: //Outline colour sl@0: finalColor.SetInternal(aOutlinePenColor.Internal()); sl@0: } sl@0: else sl@0: { sl@0: TInt blendedRedColor = (aOutlinePenColor.Red() * FourColorBlendLookup[aLookupIndex][0] + sl@0: aShadowColor.Red() * FourColorBlendLookup[aLookupIndex][1] + sl@0: aFillColor.Red() * FourColorBlendLookup[aLookupIndex][2] + sl@0: aBackgroundColor.Red() * FourColorBlendLookup[aLookupIndex][3]) >> 8; sl@0: sl@0: TInt blendedGreenColor = (aOutlinePenColor.Green() * FourColorBlendLookup[aLookupIndex][0] + sl@0: aShadowColor.Green() * FourColorBlendLookup[aLookupIndex][1] + sl@0: aFillColor.Green() * FourColorBlendLookup[aLookupIndex][2] + sl@0: aBackgroundColor.Green() * FourColorBlendLookup[aLookupIndex][3]) >> 8; sl@0: sl@0: TInt blendedBlueColor = (aOutlinePenColor.Blue() * FourColorBlendLookup[aLookupIndex][0] + sl@0: aShadowColor.Blue() * FourColorBlendLookup[aLookupIndex][1] + sl@0: aFillColor.Blue() * FourColorBlendLookup[aLookupIndex][2] + sl@0: aBackgroundColor.Blue() * FourColorBlendLookup[aLookupIndex][3]) >> 8; sl@0: sl@0: finalColor = TRgb(blendedRedColor, blendedGreenColor, blendedBlueColor); sl@0: } sl@0: sl@0: //Set the alpha in the final colour sl@0: finalColor.SetAlpha(alpha); sl@0: sl@0: //Alpha blending is not supported for display modes below EColor64K. sl@0: switch(iDispMode) sl@0: { sl@0: case EColor64K: sl@0: case EColor16M: sl@0: case EColor16MU: sl@0: if (alpha != 0xff) sl@0: { sl@0: finalColor = AlphaBlend(finalColor.Red(), finalColor.Green(), finalColor.Blue(), aBackgroundColor.Red(), aBackgroundColor.Green(), aBackgroundColor.Blue(), alpha); sl@0: } sl@0: break; sl@0: case EColor16MA: sl@0: //Just use the background color to draw in case 255 == FourColorBlendLookup[aLookupIndex][3] sl@0: if (255 != FourColorBlendLookup[aLookupIndex][3]) sl@0: { sl@0: finalColor.SetInternal(OptimizedBlend32A(aBackgroundColor.Internal(), finalColor.Internal(), alpha)); sl@0: } sl@0: break; sl@0: case EColor16MAP: sl@0: //Just use the background color to draw in case 255 == FourColorBlendLookup[aLookupIndex][3] sl@0: if (255 != FourColorBlendLookup[aLookupIndex][3]) sl@0: { sl@0: TUint32 color16MAP = finalColor.Internal(); sl@0: Convert2PMA(color16MAP); sl@0: finalColor.SetInternal(PMAPixelBlend(aBackgroundColor.Internal(), color16MAP)); sl@0: } sl@0: break; sl@0: }; sl@0: sl@0: Normalize(finalColor); sl@0: TColorConvertor& colorConvertor = ColorConvertor(iDispMode); sl@0: // Check each pixel of the line, it should match with the calculated blended color. sl@0: for (TInt count = 0; count < aLength; count++) sl@0: { sl@0: TRgb readValue = ExtractRgbValue(count, aReadBuffer, iDispMode); sl@0: if (colorConvertor.Index(finalColor) != colorConvertor.Index(readValue)) sl@0: { sl@0: return EFalse; sl@0: } sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: TRgb CTLowLevel::RgbValue(TRgb aFore,TRgb aBack,CGraphicsContext::TDrawMode aDrawMode) sl@0: { sl@0: TUint32 value = BinaryValue(aFore,aBack,aDrawMode); sl@0: sl@0: switch (iDispMode) sl@0: { sl@0: case EGray2: sl@0: return TRgb::Gray2(value); sl@0: case EGray4: sl@0: return TRgb::Gray4(value); sl@0: case EGray16: sl@0: return TRgb::Gray16(value); sl@0: case EGray256: sl@0: return TRgb::Gray256(value); sl@0: case EColor16: sl@0: return TRgb::Color16(value); sl@0: case EColor256: sl@0: return TRgb::Color256(value); sl@0: case EColor4K: sl@0: return TRgb::Color4K(value); sl@0: case EColor64K: sl@0: return TRgb::Color64K(value); sl@0: case EColor16M: sl@0: return TRgb::Color16M(value); sl@0: case EColor16MU: sl@0: return TRgb::Color16MU(value); sl@0: case EColor16MA: sl@0: return TRgb::Color16MA(value); sl@0: case EColor16MAP: sl@0: return TRgb::Color16MAP(value); sl@0: default: sl@0: break; sl@0: }; sl@0: return KRgbBlack; sl@0: } sl@0: sl@0: TUint32 CTLowLevel::BinaryValue(TRgb aFore,TRgb aBack,CGraphicsContext::TDrawMode aDrawMode) sl@0: { sl@0: TUint32 f = 0; sl@0: TUint32 b = 0; sl@0: TUint32 notVal = 0; sl@0: sl@0: switch (iDispMode) sl@0: { sl@0: case EGray2: sl@0: f = aFore.Gray2(); sl@0: b = aBack.Gray2(); sl@0: notVal = 1; sl@0: break; sl@0: case EGray4: sl@0: f = aFore.Gray4(); sl@0: b = aBack.Gray4(); sl@0: notVal = 3; sl@0: break; sl@0: case EGray16: sl@0: f = aFore.Gray16(); sl@0: b = aBack.Gray16(); sl@0: notVal = 0xf; sl@0: break; sl@0: case EGray256: sl@0: f = aFore.Gray256(); sl@0: b = aBack.Gray256(); sl@0: notVal = 0xff; sl@0: break; sl@0: case EColor16: sl@0: f = aFore.Color16(); sl@0: b = aBack.Color16(); sl@0: notVal = 0xf; sl@0: break; sl@0: case EColor256: sl@0: f = aFore.Color256(); sl@0: b = aBack.Color256(); sl@0: notVal = 0xff; sl@0: break; sl@0: case EColor4K: sl@0: f = aFore.Color4K(); sl@0: b = aBack.Color4K(); sl@0: notVal = 0xfff; sl@0: break; sl@0: case EColor64K: sl@0: f = aFore.Color64K(); sl@0: b = aBack.Color64K(); sl@0: notVal = 0xffff; sl@0: break; sl@0: case EColor16M: sl@0: f = aFore.Color16M(); sl@0: b = aBack.Color16M(); sl@0: notVal = 0xffffff; sl@0: break; sl@0: case EColor16MU: sl@0: f = aFore.Color16MU(); sl@0: b = aBack.Color16MU(); sl@0: notVal = 0x00ffffff; sl@0: break; sl@0: case EColor16MA: sl@0: f = aFore.Color16MA(); sl@0: b = aBack.Color16MA(); sl@0: notVal = 0xffffffff; sl@0: break; sl@0: case EColor16MAP: sl@0: f = aFore.Color16MAP(); sl@0: b = aBack.Color16MAP(); sl@0: sl@0: //do not want to blend backgound colours for testing sl@0: if (iBlendTestColors && (aDrawMode&CGraphicsContext::EDrawModePEN)) sl@0: { sl@0: Blend((TUint8*)(&f),(TUint8*)(&b),iDispMode); sl@0: } sl@0: notVal = 0xffffffff; sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: sl@0: switch (aDrawMode) sl@0: { sl@0: case CGraphicsContext::EDrawModeAND: return f & b; sl@0: case CGraphicsContext::EDrawModePEN: return f; sl@0: case CGraphicsContext::EDrawModeWriteAlpha: return f; sl@0: case CGraphicsContext::EDrawModeXOR: return f ^ b; sl@0: case CGraphicsContext::EDrawModeOR: return f | b; sl@0: case CGraphicsContext::EDrawModeNOTSCREEN: return b ^ notVal; sl@0: case CGraphicsContext::EDrawModeNOTPEN: return f; sl@0: default: sl@0: break; sl@0: }; sl@0: return 0; sl@0: } sl@0: sl@0: TRgb CTLowLevel::ExtractRgbValue(TInt aX,TUint8* aBuffer,TDisplayMode aDispMode) sl@0: { sl@0: TUint32 value = ExtractBinaryValue(aX,(TUint32*)aBuffer,aDispMode); sl@0: sl@0: switch (aDispMode) sl@0: { sl@0: case EGray2: sl@0: return TRgb::Gray2(value); sl@0: case EGray4: sl@0: return TRgb::Gray4(value); sl@0: case EGray16: sl@0: return TRgb::Gray16(value); sl@0: case EGray256: sl@0: return TRgb::Gray256(value); sl@0: case EColor16: sl@0: return TRgb::Color16(value); sl@0: case EColor256: sl@0: return TRgb::Color256(value); sl@0: case EColor4K: sl@0: return TRgb::Color4K(value); sl@0: case EColor64K: sl@0: return TRgb::Color64K(value); sl@0: case EColor16M: sl@0: return TRgb::Color16M(value); sl@0: case ERgb: sl@0: return TRgb(value, value>>24); sl@0: case EColor16MU: sl@0: return TRgb::Color16MU(value); sl@0: case EColor16MA: sl@0: return TRgb::Color16MA(value); sl@0: case EColor16MAP: sl@0: return TRgb::Color16MAP(value); sl@0: default: sl@0: break; sl@0: }; sl@0: return KRgbBlack; sl@0: } sl@0: sl@0: TUint32 CTLowLevel::ExtractBinaryValue(TInt aX,TUint32* aBuffer,TDisplayMode aDispMode) sl@0: { sl@0: switch (aDispMode) sl@0: { sl@0: case EGray2: sl@0: return ((*(aBuffer + (aX >> 5))) >> (aX & 0x1f)) & 1; sl@0: case EGray4: sl@0: return ((*(aBuffer + (aX >> 4))) >> ((aX & 0xf) * 2)) & 3; sl@0: case EGray16: sl@0: case EColor16: sl@0: return ((*(aBuffer + (aX >> 3))) >> ((aX & 7) * 4)) & 0xf; sl@0: case EGray256: sl@0: case EColor256: sl@0: return ((*(aBuffer + (aX >> 2))) >> ((aX & 3) * 8)) & 0xff; sl@0: case EColor4K: sl@0: return ((*(aBuffer + (aX >> 1))) >> ((aX & 1) * 16)) & 0xfff; sl@0: case EColor64K: sl@0: return ((*(aBuffer + (aX >> 1))) >> ((aX & 1) * 16)) & 0xffff; sl@0: case EColor16M: sl@0: { sl@0: TUint8* buffer = ((TUint8*)aBuffer) + (aX * 3); sl@0: return *buffer | (*(buffer + 1) << 8) | (*(buffer + 2) << 16); sl@0: } sl@0: case ERgb: sl@0: return *(aBuffer + aX); sl@0: case EColor16MU: sl@0: return *(aBuffer + aX) & 0x00FFFFFF; sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: return *(aBuffer + aX); sl@0: default: sl@0: break; sl@0: }; sl@0: return 0; sl@0: } sl@0: sl@0: void CTLowLevel::Normalize(TRgb& aColor) sl@0: { sl@0: return(Normalize(aColor,iDispMode)); sl@0: } sl@0: sl@0: void CTLowLevel::Normalize(TRgb& aColor, TDisplayMode aDispMode) sl@0: { sl@0: switch (aDispMode) sl@0: { sl@0: case EGray2: sl@0: aColor = TRgb::Gray2(aColor.Gray2()); sl@0: break; sl@0: case EGray4: sl@0: aColor = TRgb::Gray4(aColor.Gray4()); sl@0: break; sl@0: case EGray16: sl@0: aColor = TRgb::Gray16(aColor.Gray16()); sl@0: break; sl@0: case EGray256: sl@0: aColor = TRgb::Gray256(aColor.Gray256()); sl@0: break; sl@0: case EColor16: sl@0: aColor = TRgb::Color16(aColor.Color16()); sl@0: break; sl@0: case EColor256: sl@0: aColor = TRgb::Color256(aColor.Color256()); sl@0: break; sl@0: case EColor4K: sl@0: aColor = TRgb::Color4K(aColor.Color4K()); sl@0: break; sl@0: case EColor64K: sl@0: aColor = TRgb::Color64K(aColor.Color64K()); sl@0: break; sl@0: case EColor16M: sl@0: aColor = TRgb::Color16M(aColor.Color16M()); sl@0: break; sl@0: case EColor16MU: sl@0: aColor = TRgb::Color16MU(aColor.Color16MU()); sl@0: break; sl@0: case EColor16MA: sl@0: aColor = TRgb::Color16MA(aColor.Color16MA()); sl@0: break; sl@0: case EColor16MAP: sl@0: //do nothing, because TRGb is already unpremultiplied sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: void CTLowLevel::Normalize(TRgb& aColor,TRgb aDitherColors[4]) sl@0: { sl@0: switch (iDispMode) sl@0: { sl@0: case EGray2: sl@0: FillArray(TRgb::Gray2(aColor.Gray2()),aDitherColors); sl@0: break; sl@0: case EGray4: sl@0: if (iUserDispMode == EGray2) sl@0: FillArray(TRgb::Gray2(aColor.Gray2()),aDitherColors); sl@0: else sl@0: { sl@0: TInt gray16 = aColor.Gray16(); sl@0: aDitherColors[0] = TRgb::Gray4(ditherlutab[gray16][0]); sl@0: aDitherColors[1] = TRgb::Gray4(ditherlutab[gray16][1]); sl@0: aDitherColors[2] = TRgb::Gray4(ditherlutab[gray16][2]); sl@0: aDitherColors[3] = TRgb::Gray4(ditherlutab[gray16][3]); sl@0: } sl@0: break; sl@0: case EGray16: sl@0: if (iUserDispMode == EGray2) sl@0: FillArray(TRgb::Gray2(aColor.Gray2()),aDitherColors); sl@0: else if (iUserDispMode == EGray4) sl@0: { sl@0: TInt gray16 = aColor.Gray16(); sl@0: aDitherColors[0] = TRgb::Gray4(ditherlutab[gray16][0]); sl@0: aDitherColors[1] = TRgb::Gray4(ditherlutab[gray16][1]); sl@0: aDitherColors[2] = TRgb::Gray4(ditherlutab[gray16][2]); sl@0: aDitherColors[3] = TRgb::Gray4(ditherlutab[gray16][3]); sl@0: } sl@0: else sl@0: FillArray(TRgb::Gray16(aColor.Gray16()),aDitherColors); sl@0: break; sl@0: case EGray256: sl@0: FillArray(TRgb::Gray256(aColor.Gray256()),aDitherColors); sl@0: break; sl@0: case EColor16: sl@0: FillArray(TRgb::Color16(aColor.Color16()),aDitherColors); sl@0: break; sl@0: case EColor256: sl@0: FillArray(TRgb::Color256(aColor.Color256()),aDitherColors); sl@0: break; sl@0: case EColor4K: sl@0: FillArray(TRgb::Color4K(aColor.Color4K()),aDitherColors); sl@0: break; sl@0: case EColor64K: sl@0: FillArray(TRgb::Color64K(aColor.Color64K()),aDitherColors); sl@0: break; sl@0: case EColor16M: sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: FillArray(aColor,aDitherColors); sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: void CTLowLevel::FillArray(TRgb aColor,TRgb aArray[4]) sl@0: { sl@0: aArray[0] = aColor; sl@0: aArray[1] = aColor; sl@0: aArray[2] = aColor; sl@0: aArray[3] = aColor; sl@0: } sl@0: sl@0: sl@0: void CTLowLevel::PostBlendShadow(TUint32 &aPmaColor) sl@0: { sl@0: //this function should only be called for PMA colours sl@0: const TInt alpha = aPmaColor >> 24; sl@0: TUint32 value = aPmaColor & 0x00ffffff; sl@0: sl@0: if (iPostBlendShadow & CFbsDrawDevice::EFade) sl@0: { sl@0: #if defined(SYMBIAN_USE_FAST_FADING) sl@0: TUint32 fast_fade_offset = ((SYMBIAN_USE_FAST_FADING & 0xff) * alpha) >>8; sl@0: fast_fade_offset = fast_fade_offset | (fast_fade_offset << 8) | (fast_fade_offset <<16); sl@0: value = ((value >> 1) & ~0x00808080) + (fast_fade_offset); sl@0: value = value | (((TUint32)alpha)<<24); sl@0: #else sl@0: /* sl@0: here blackmap = 200, sl@0: whitemap = 100 sl@0: iFadeMapFactor = aWhiteMap - aBlackMap + 1; sl@0: iFadeMapOffset = aBlackMap; sl@0: */ sl@0: sl@0: const TInt fadeMapOffset = ((alpha * 0x7f) >> 8) & 0xff; sl@0: const TInt wordFadeMapOffset = ((fadeMapOffset) << 16) | (fadeMapOffset); sl@0: const TInt rb = ((((value & 0x00ff00ff) * 0x7f) >> 8) + wordFadeMapOffset) & 0x00ff00ff; sl@0: const TInt g = ((((value & 0x0000ff00) * 0x7f) >> 16) + fadeMapOffset) << 8; sl@0: value = rb | g | (((TUint32)alpha)<<24); sl@0: #endif sl@0: } sl@0: sl@0: if (iPostBlendShadow & CFbsDrawDevice::EShadow) sl@0: { sl@0: TInt alpha = (aPmaColor>>24); sl@0: TInt red = (value>>16)&0xff; sl@0: TInt green = (value>>8)&0xff; sl@0: TInt blue = value &0xff; sl@0: sl@0: TInt shadow= (alpha*0x40)>>8; sl@0: red = Max(0,red-shadow); sl@0: green = Max (0,green-shadow); sl@0: blue = Max (0,blue-shadow); sl@0: value = (((TUint32)alpha)<<24)|(((TUint32)red)<<16)|(((TUint32)green)<<8)|((TUint32)blue); sl@0: } sl@0: aPmaColor = value; sl@0: } sl@0: sl@0: void CTLowLevel::Shadow(TRgb& aColor,TInt aShadowMode) sl@0: { sl@0: if (aShadowMode & 2) sl@0: { sl@0: switch (iDrawDevice->DisplayMode()) sl@0: { sl@0: case EGray2: sl@0: aColor = TRgb::Gray256(FadeGray(aColor.Gray2() * 255)); sl@0: break; sl@0: case EGray4: sl@0: case EGray16: sl@0: aColor = TRgb::Gray256(FadeGray(aColor.Gray16() * 17)); sl@0: break; sl@0: case EGray256: sl@0: aColor = TRgb::Gray256(FadeGray(aColor.Gray256())); sl@0: break; sl@0: case EColor16: sl@0: aColor = FadeRgb(TRgb::Color16(aColor.Color16())); sl@0: break; sl@0: case EColor256: sl@0: aColor = FadeRgb(TRgb::Color256(aColor.Color256())); sl@0: break; sl@0: case EColor4K: sl@0: aColor = FadeRgb(TRgb::Color4K(aColor.Color4K())); sl@0: break; sl@0: case EColor64K: sl@0: aColor = FadeRgb(TRgb::Color64K(aColor.Color64K()),KFastFading && iUseFastFade); sl@0: break; sl@0: case EColor16M: sl@0: aColor = FadeRgb(TRgb::Color16M(aColor.Color16M())); sl@0: break; sl@0: case EColor16MU: sl@0: aColor = FadeRgb(TRgb::Color16MU(aColor.Color16MU()),KFastFading && iUseFastFade); sl@0: break; sl@0: case EColor16MA: sl@0: aColor = FadeRgb(TRgb::Color16MA(aColor.Color16MA()),KFastFading && iUseFastFade); sl@0: break; sl@0: case EColor16MAP: sl@0: aColor = FadeRgb(TRgb::Color16MAP(aColor.Color16MAP()),KFastFading && iUseFastFade); sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: if (aShadowMode & 1) sl@0: { sl@0: switch (iDrawDevice->DisplayMode()) sl@0: { sl@0: case EGray2: sl@0: aColor = KRgbBlack; sl@0: break; sl@0: case EGray4: sl@0: case EGray16: sl@0: aColor = TRgb::Gray16(Max(0,aColor.Gray16()-5)); sl@0: break; sl@0: case EGray256: sl@0: aColor = TRgb::Gray256(Max(0,aColor.Gray256()-85)); sl@0: break; sl@0: case EColor16: sl@0: { sl@0: TInt color = aColor.Color16(); sl@0: if (color == 15) color--; sl@0: else if (color == 14) color = 1; sl@0: else if (color > 7) color += 3; sl@0: else if (color > 4) color -= 3; sl@0: else color = 0; sl@0: aColor = TRgb::Color16(color); sl@0: } sl@0: break; sl@0: case EColor256: sl@0: { sl@0: aColor = TRgb::Color256(aColor.Color256()); sl@0: TInt red = aColor.Red(); sl@0: TInt green = aColor.Green(); sl@0: TInt blue = aColor.Blue(); sl@0: red = Max(0,red-0x33); sl@0: green = Max(0,green-0x33); sl@0: blue = Max(0,blue-0x33); sl@0: aColor = TRgb(red,green,blue); sl@0: } sl@0: break; sl@0: case EColor4K: sl@0: { sl@0: TInt color = aColor.Color4K(); sl@0: TInt red = (color & 0xf00) >> 8; sl@0: TInt green = (color & 0x0f0) >> 4; sl@0: TInt blue = color & 0x00f; sl@0: sl@0: red = Max(0,red-5); sl@0: green = Max(0,green-5); sl@0: blue = Max(0,blue-5); sl@0: sl@0: aColor = TRgb::Color4K((red << 8) | (green << 4) | blue); sl@0: } sl@0: break; sl@0: case EColor64K: sl@0: { sl@0: TInt color = aColor.Color64K(); sl@0: TInt red = (color & 0xf800) >> 11; sl@0: TInt green = (color & 0x07e0) >> 5; sl@0: TInt blue = color & 0x001f; sl@0: sl@0: red = Max(0,red-8); sl@0: green = Max(0,green-16); sl@0: blue = Max(0,blue-8); sl@0: sl@0: aColor = TRgb::Color64K((red << 11) | (green << 5) | blue); sl@0: } sl@0: break; sl@0: case EColor16M: sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: case EColor16MAP: sl@0: { sl@0: TInt red = aColor.Red(); sl@0: TInt green = aColor.Green(); sl@0: TInt blue = aColor.Blue(); sl@0: red = Max(0,red-0x40); sl@0: green = Max(0,green-0x40); sl@0: blue = Max(0,blue-0x40); sl@0: aColor = TRgb(red,green,blue,aColor.Alpha()); sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::Blend(TUint8* aBuffer,TUint8* aBufferDest, TDisplayMode aDispMode) sl@0: { sl@0: TUint32* buffer = reinterpret_cast (aBuffer); sl@0: TUint32* bufferDest = reinterpret_cast (aBufferDest); sl@0: TInt mask = (*buffer & 0xff000000) >> 24; sl@0: TRgb rgbDest; sl@0: sl@0: switch(aDispMode) sl@0: { sl@0: case EColor16MU: sl@0: { sl@0: // src + ((255 - mask) * dest) / 255 sl@0: if(mask!=255) sl@0: { sl@0: rgbDest=TRgb::Color16MU(*bufferDest); sl@0: if(mask) sl@0: { sl@0: TRgb rgbSrc=TRgb::Color16MU(*buffer); sl@0: rgbDest.SetRed(rgbSrc.Red() + ((255 - mask) * rgbDest.Red()) / 255); sl@0: rgbDest.SetGreen(rgbSrc.Green() + ((255 - mask) * rgbDest.Green()) / 255); sl@0: rgbDest.SetBlue(rgbSrc.Blue() + ((255 - mask) * rgbDest.Blue()) / 255); sl@0: } sl@0: *buffer=rgbDest.Internal(); sl@0: } sl@0: } sl@0: break; sl@0: case EColor16MA: sl@0: { sl@0: // (mask * src + (255 - mask) * dest) / 255 sl@0: if(mask!=255) sl@0: { sl@0: rgbDest=TRgb::Color16MA(*bufferDest); sl@0: if(mask) sl@0: { sl@0: TRgb rgbSrc=TRgb::Color16MA(*buffer); sl@0: rgbDest.SetRed((mask * rgbSrc.Red() + (255 - mask) * rgbDest.Red()) / 255); sl@0: rgbDest.SetGreen((mask * rgbSrc.Green() + (255 - mask) * rgbDest.Green()) / 255); sl@0: rgbDest.SetBlue((mask * rgbSrc.Blue() + (255 - mask) * rgbDest.Blue()) / 255); sl@0: } sl@0: *buffer=rgbDest.Internal(); sl@0: } sl@0: } sl@0: break; sl@0: case EColor16MAP: sl@0: { sl@0: /* sl@0: * Blend function uses the Porter Duff composition equation sl@0: * This blends two pixels with alphas: sl@0: * Ar = As + Ad * (1 - As) (Blended Alpha) sl@0: * Cr = Cs + Cd(1 - As) (Blended Colour) sl@0: * Cr = Cs + Cd(255-As)/255 : for alpha 0-255 sl@0: * where Ar = alpha result sl@0: * where Cr = colour result sl@0: * where Cs = source colour sl@0: * where Cd = destination colour sl@0: * The function assumes that the mask buffer is the alpha value of the source pixel. sl@0: */ sl@0: if(mask!=255) sl@0: { sl@0: rgbDest=TRgb::Color16MA(*bufferDest); sl@0: if(mask) sl@0: { sl@0: TInt destAlpha = (*bufferDest & 0xff000000) >> 24; sl@0: TInt sourceAlpha = (*buffer & 0xff000000) >> 24; sl@0: TRgb rgbSrc; sl@0: rgbSrc.SetInternal(*buffer); sl@0: rgbDest.SetInternal(*bufferDest); sl@0: TInt resultAlpha = sourceAlpha +((255-sourceAlpha)*destAlpha)/255; sl@0: rgbDest.SetRed(rgbSrc.Red() + ((255 - sourceAlpha) * rgbDest.Red()) / 255); sl@0: rgbDest.SetGreen(rgbSrc.Green() + ((255 - sourceAlpha) * rgbDest.Green()) / 255); sl@0: rgbDest.SetBlue(rgbSrc.Blue() + ((255 - sourceAlpha) * rgbDest.Blue())/ 255); sl@0: rgbDest.SetAlpha(resultAlpha); sl@0: } sl@0: *buffer=rgbDest.Internal(); sl@0: } sl@0: } sl@0: break; sl@0: default: break; sl@0: } sl@0: } sl@0: sl@0: void CTLowLevel::Shadow(TUint8* aBuffer,TInt aByteLength,TInt aShadowMode) sl@0: { sl@0: TUint8* buffer = aBuffer; sl@0: const TUint8* bufferLimit = aBuffer + aByteLength; sl@0: sl@0: if (aShadowMode & 2) sl@0: { sl@0: switch (iDrawDevice->DisplayMode()) sl@0: { sl@0: case EGray2: sl@0: while (buffer < bufferLimit) sl@0: *buffer++ = 0xff; sl@0: break; sl@0: case EGray4: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt first = FadeGray((buffer[0] & 0x03) * 85) >> 6; sl@0: TInt second = FadeGray(((buffer[0] >> 2) & 0x03) * 85) >> 6; sl@0: TInt third = FadeGray(((buffer[0] >> 4) & 0x03) * 85) >> 6; sl@0: TInt fourth = FadeGray(((buffer[0] >> 6) & 0x03) * 85) >> 6; sl@0: *buffer++ = TUint8(first | (second << 2) | (third << 4) | (fourth << 6)); sl@0: } sl@0: break; sl@0: case EGray16: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt low = FadeGray((buffer[0] & 0x0f) * 17) >> 4; sl@0: TInt high = FadeGray((buffer[0] >> 4) * 17) >> 4; sl@0: *buffer++ = TUint8((high << 4) | low); sl@0: } sl@0: break; sl@0: case EGray256: sl@0: while (buffer < bufferLimit) sl@0: *buffer++ = FadeGray(*buffer); sl@0: break; sl@0: case EColor16: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt low = FadeRgb(TRgb::Color16(buffer[0] & 0x0f)).Color16(); sl@0: TInt high = FadeRgb(TRgb::Color16(buffer[0] >> 4)).Color16(); sl@0: *buffer++ = TUint8((high << 4) | low); sl@0: } sl@0: break; sl@0: case EColor256: sl@0: while (buffer < bufferLimit) sl@0: *buffer++ = TUint8(FadeRgb(TRgb::Color256(buffer[0])).Color256()); sl@0: break; sl@0: case EColor4K: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt color4K = FadeRgb(TRgb::Color4K(buffer[0] | (buffer[1] << 8))).Color4K(); sl@0: buffer[0] = TUint8(color4K); sl@0: buffer[1] = TUint8(color4K >> 8); sl@0: buffer += 2; sl@0: } sl@0: break; sl@0: case EColor64K: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt color64K = FadeRgb(TRgb::Color64K(buffer[0] | (buffer[1] << 8)),ETrue).Color64K(); sl@0: buffer[0] = TUint8(color64K); sl@0: buffer[1] = TUint8(color64K >> 8); sl@0: buffer += 2; sl@0: } sl@0: break; sl@0: case EColor16M: sl@0: { sl@0: while (buffer < bufferLimit) sl@0: *buffer++ = FadeGray(buffer[0]); sl@0: } sl@0: break; sl@0: case EColor16MU: sl@0: { sl@0: TUint32* buffer32 = reinterpret_cast (buffer); sl@0: TUint32* bufferLimit32 = buffer32 + aByteLength / 4; sl@0: while (buffer32 < bufferLimit32) sl@0: { sl@0: // scanline buffer for 16MU driver is pre-multiplied sl@0: TRgb color = FadeRgb(TRgb::Color16MAP(*buffer32),ETrue); sl@0: // avoid rounding errors with EDrawModeAND etc. sl@0: *buffer32++ = color.Alpha() == 255 ? color.Internal() : color.Color16MAP(); sl@0: } sl@0: } sl@0: break; sl@0: case EColor16MA: sl@0: { sl@0: TUint32* buffer32 = reinterpret_cast (buffer); sl@0: TUint32* bufferLimit32 = buffer32 + aByteLength / 4; sl@0: while (buffer32 < bufferLimit32) sl@0: { sl@0: TRgb color = FadeRgb(TRgb::Color16MA(*buffer32),ETrue); sl@0: *buffer32++ = color.Color16MA(); sl@0: } sl@0: } sl@0: break; sl@0: case EColor16MAP: sl@0: { sl@0: TUint32* buffer32 = reinterpret_cast (buffer); sl@0: TUint32* bufferLimit32 = buffer32 + aByteLength / 4; sl@0: while (buffer32 < bufferLimit32) sl@0: { sl@0: TRgb color = FadeRgb(TRgb::Color16MAP(*buffer32),ETrue); sl@0: *buffer32++ = color.Color16MAP(); sl@0: } sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: buffer = aBuffer; sl@0: sl@0: if (aShadowMode & 1) sl@0: { sl@0: switch (iDrawDevice->DisplayMode()) sl@0: { sl@0: case EGray2: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: *buffer++ = 0; sl@0: } sl@0: break; sl@0: case EGray4: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt first = buffer[0] & 0x03; sl@0: TInt second = buffer[0] & 0x0c; sl@0: TInt third = buffer[0] & 0x30; sl@0: TInt fourth = buffer[0] & 0xc0; sl@0: first = Max(0,first-1); sl@0: second = Max(0,second-4); sl@0: third = Max(0,third-16); sl@0: fourth = Max(0,fourth-64); sl@0: *buffer++ = TUint8(fourth | third | second | first); sl@0: } sl@0: break; sl@0: case EGray16: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt low = buffer[0] & 0x0f; sl@0: TInt high = buffer[0] >> 4; sl@0: low = Max(0,low-5); sl@0: high = Max(0,high-5); sl@0: *buffer++ = TUint8((high << 4) | low); sl@0: } sl@0: break; sl@0: case EGray256: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: buffer[0] = TUint8(Max(0,buffer[0]-85)); sl@0: buffer++; sl@0: } sl@0: break; sl@0: case EColor16: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt low = buffer[0] & 0x0f; sl@0: TInt high = buffer[0] >> 4; sl@0: if (low == 15) low = 14; sl@0: else if (low == 14) low = 1; sl@0: else if (low >= 11) low = 0; sl@0: else if (low >= 8) low += 3; sl@0: else if (low >= 5) low -= 3; sl@0: else low = 0; sl@0: if (high == 15) high = 14; sl@0: else if (high == 14) high = 1; sl@0: else if (high >= 11) high = 0; sl@0: else if (high >= 8) high += 3; sl@0: else if (high >= 5) high -= 3; sl@0: else high = 0; sl@0: *buffer++ = TUint8((high << 4) | low); sl@0: } sl@0: break; sl@0: case EColor256: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TRgb color(TRgb::Color256(buffer[0])); sl@0: TInt red = color.Red(); sl@0: TInt green = color.Green(); sl@0: TInt blue = color.Blue(); sl@0: red = Max(0,red-0x33); sl@0: green = Max(0,green-0x33); sl@0: blue = Max(0,blue-0x33); sl@0: *buffer++ = TUint8(TRgb(red,green,blue).Color256()); sl@0: } sl@0: break; sl@0: case EColor4K: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt data = (buffer[1] << 8) | buffer[0]; sl@0: TInt red = (data & 0xf00) >> 8; sl@0: TInt green = (data & 0x0f0) >> 4; sl@0: TInt blue = data & 0x00f; sl@0: red = Max(0,red-5); sl@0: green = Max(0,green-5); sl@0: blue = Max(0,blue-5); sl@0: data = (red << 8) | (green << 4) | blue; sl@0: buffer[0] = TUint8(data); sl@0: buffer[1] = TUint8(data >> 8); sl@0: buffer += 2; sl@0: } sl@0: break; sl@0: case EColor64K: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: TInt data = (buffer[1] << 8) | buffer[0]; sl@0: TInt red = (data & 0xf800) >> 11; sl@0: TInt green = (data & 0x07e0) >> 5; sl@0: TInt blue = data & 0x001f; sl@0: red = Max(0,red-8); sl@0: green = Max(0,green-16); sl@0: blue = Max(0,blue-8); sl@0: data = (red << 11) | (green << 5) | blue; sl@0: buffer[0] = TUint8(data); sl@0: buffer[1] = TUint8(data >> 8); sl@0: buffer += 2; sl@0: } sl@0: break; sl@0: case EColor16M: sl@0: while (buffer < bufferLimit) sl@0: { sl@0: buffer[0] = TUint8(Max(0,buffer[0]-0x40)); sl@0: buffer++; sl@0: } sl@0: break; sl@0: case EColor16MU: sl@0: { sl@0: TUint32* buffer32 = reinterpret_cast (buffer); sl@0: TUint32* bufferLimit32 = buffer32 + aByteLength / 4; sl@0: while (buffer32 < bufferLimit32) sl@0: { sl@0: // scanline buffer for 16MU driver is pre-multiplied sl@0: TRgb color = TRgb::Color16MAP(*buffer32); sl@0: color = TRgb(Max(0,color.Red()-0x40),Max(0,color.Green()-0x40),Max(0,color.Blue()-0x40), color.Alpha()); sl@0: // avoid rounding errors with EDrawModeAND etc. sl@0: *buffer32++ = color.Alpha() == 255 ? color.Internal() : color.Color16MAP(); sl@0: } sl@0: } sl@0: break; sl@0: case EColor16MA: sl@0: { sl@0: TUint32* buffer32 = reinterpret_cast (buffer); sl@0: TUint32* bufferLimit32 = buffer32 + aByteLength / 4; sl@0: while (buffer32 < bufferLimit32) sl@0: { sl@0: TRgb color = TRgb::Color16MA(*buffer32); sl@0: color = TRgb(Max(0,color.Red()-0x40),Max(0,color.Green()-0x40),Max(0,color.Blue()-0x40), color.Alpha()); sl@0: *buffer32++ = color.Color16MA(); sl@0: } sl@0: } sl@0: break; sl@0: case EColor16MAP: sl@0: { sl@0: TUint32* buffer32 = reinterpret_cast (buffer); sl@0: TUint32* bufferLimit32 = buffer32 + aByteLength / 4; sl@0: while (buffer32 < bufferLimit32) sl@0: { sl@0: TRgb color = TRgb::Color16MAP(*buffer32); sl@0: color = TRgb(Max(0,color.Red()-0x40),Max(0,color.Green()-0x40),Max(0,color.Blue()-0x40), color.Alpha()); sl@0: *buffer32++ = color.Color16MAP(); sl@0: } sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: TUint8 CTLowLevel::FadeGray(TInt aGray256) sl@0: { sl@0: return TUint8((aGray256 >> 1) + 128); sl@0: } sl@0: sl@0: /** sl@0: A test code function for Fading colour values. sl@0: @param aColor Colour value for which faded colour is needed. sl@0: @param aFastFade Used to check whether Fast Fading method is required or not. sl@0: aFastFade flag should be true only when there is a corresponding Fast Fading sl@0: implementation in product code and the fading method uses the Fast Fading method. sl@0: @return TRgb Faded colour value. sl@0: */ sl@0: TRgb CTLowLevel::FadeRgb(TRgb aColor, TBool aFastFade/*=EFalse*/) sl@0: { sl@0: if(aFastFade) sl@0: { sl@0: #if defined(SYMBIAN_USE_FAST_FADING) sl@0: TUint32 value = ((aColor.Internal() >> 1) & ~0x00808080) + SYMBIAN_USE_FAST_FADING; sl@0: TInt alpha = aColor.Alpha(); sl@0: return TRgb(value, alpha); sl@0: #endif sl@0: } sl@0: TInt red = (aColor.Red() >> 1) + 128; sl@0: TInt green = (aColor.Green() >> 1) + 128; sl@0: TInt blue = (aColor.Blue() >> 1) + 128; sl@0: TInt alpha = aColor.Alpha(); sl@0: return TRgb(red,green,blue,alpha); sl@0: } sl@0: sl@0: TColorConvertor& CTLowLevel::ColorConvertor(TDisplayMode aDisplayMode) sl@0: { sl@0: return *iColorConvertor[aDisplayMode]; sl@0: } sl@0: sl@0: void CTLowLevel::Report() sl@0: { sl@0: INFO_PRINTF4(_L("Test %d: %d/%d"),iTestNo,iReportIteration,iTotalReportIterations); sl@0: if (iReportIteration < iTotalReportIterations) sl@0: iReportIteration++; sl@0: } sl@0: sl@0: inline TBool CTLowLevel::Check(TBool aValue) sl@0: { sl@0: if (iLastFailTestNo!=iIteration) sl@0: { sl@0: if (!aValue) sl@0: { sl@0: _LIT(KLog,"Test %d, iteration %d failed iDispMode %d iUserDispMode %d iOrientation %d"); sl@0: INFO_PRINTF6(KLog,iTestNo,iIteration,iDispMode,iUserDispMode,iOrientation); sl@0: iLastFailTestNo=iIteration; sl@0: } sl@0: TEST(aValue); sl@0: } sl@0: return !aValue; sl@0: } sl@0: sl@0: //----------- sl@0: CTLowLevel1::CTLowLevel1(CTestStep* aStep): sl@0: CTLowLevel(aStep) sl@0: { sl@0: iOrientation = CFbsDrawDevice::EOrientationRotated180; sl@0: iOrientationEnd = CFbsDrawDevice::EOrientationRotated270; sl@0: } sl@0: sl@0: void CTLowLevel1::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: if(iOrientation <= iOrientationEnd) sl@0: { sl@0: INFO_PRINTF2(_L("Screen device : %S"), &DisplayModeNames1[iCurScreenDeviceModeIndex]); sl@0: TDisplayMode display = TestDisplayMode1[iCurScreenDeviceModeIndex++]; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-SCREENDRIVER-0018 sl@0: */ sl@0: ((CTLowLevelStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0018")); sl@0: TestScreenDrawL(display); sl@0: if(iCurScreenDeviceModeIndex >= KNumberDisplayModes1) sl@0: { sl@0: iCurScreenDeviceModeIndex = 0; sl@0: iOrientation ++; sl@0: } sl@0: ((CTLowLevelStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: else sl@0: { sl@0: ((CTLowLevelStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: } sl@0: } sl@0: sl@0: //-------------- sl@0: __CONSTRUCT_STEP__(LowLevel) sl@0: sl@0: __CONSTRUCT_STEP__(LowLevel1)