sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: #include "t_cfbsdrawdevicedata.h" sl@0: #include sl@0: #include sl@0: sl@0: _LIT(KDisplayMode, "displayMode"); sl@0: _LIT(KDrawMode, "drawMode"); sl@0: _LIT(KOrientationMode, "orientationMode"); sl@0: _LIT(KShadowMode, "shadowMode"); sl@0: _LIT(KBackColor, "backColor"); sl@0: _LIT(KNumRect, "numRect"); sl@0: _LIT(KRectangles, "rectangles"); sl@0: _LIT(KRectangleSection, "RECTANGLES"); sl@0: _LIT(KNumTestRect, "numTestRect"); sl@0: _LIT(KAutoUpdate, "autoUpdate"); sl@0: _LIT(KCmdNewScreenDeviceL, "NewScreenDeviceL"); sl@0: _LIT(KCmdDestructor, "~"); sl@0: _LIT(KCmdInitScreen, "InitScreen"); sl@0: _LIT(KCmdSetDisplayMode, "SetDisplayMode"); sl@0: _LIT(KCmdSetAutoUpdate, "SetAutoUpdate"); sl@0: _LIT(KCmdOrientationsAvailable, "OrientationsAvailable"); sl@0: _LIT(KCmdSetOrientation, "SetOrientation"); sl@0: _LIT(KCmdWriteRgb, "WriteRgb"); sl@0: _LIT(KCmdWriteLine, "WriteLine"); sl@0: _LIT(KCmdWriteBinaryLine, "WriteBinaryLine"); sl@0: _LIT(KCmdWriteRgbMulti, "WriteRgbMulti"); sl@0: _LIT(KCmdReadLine, "ReadLine"); sl@0: _LIT(KCmdWriteRGBAlphaLine, "WriteRGBAlphaLine"); sl@0: _LIT(KCmdSetShadowMode, "SetShadowMode"); sl@0: _LIT(KCmdShadowArea, "ShadowArea"); sl@0: _LIT(KCmdWriteBinary, "WriteBinary"); sl@0: _LIT(KCmdWriteBinaryLineVertical, "WriteBinaryLineVertical"); sl@0: _LIT(KNoShadow, "ENoShadow"); sl@0: _LIT(KShadow, "EShadow"); sl@0: _LIT(KFade, "EFade"); sl@0: _LIT(KShadowFade, "EShadowFade"); sl@0: _LIT(KNone, "ENone"); sl@0: _LIT(KGray2, "EGray2"); sl@0: _LIT(KGray4, "EGray4"); sl@0: _LIT(KGray16, "EGray16"); sl@0: _LIT(KGray256, "EGray256"); sl@0: _LIT(KColor16, "EColor16"); sl@0: _LIT(KColor256, "EColor256"); sl@0: _LIT(KColor64K, "EColor64K"); sl@0: _LIT(KColor16M, "EColor16M"); sl@0: _LIT(KRgb, "ERgb"); sl@0: _LIT(KColor4K, "EColor4K"); sl@0: _LIT(KColor16MU, "EColor16MU"); sl@0: _LIT(KColor16MA, "EColor16MA"); sl@0: _LIT(KColor16MAP, "EColor16MAP"); sl@0: _LIT(KColorLast, "EColorLast"); sl@0: _LIT(KDrawModePEN, "EDrawModePEN"); sl@0: _LIT(KDrawModeAND, "EDrawModeAND"); sl@0: _LIT(KDrawModeXOR, "EDrawModeXOR"); sl@0: _LIT(KDrawModeOR, "EDrawModeOR"); sl@0: _LIT(KDrawModeNOTSCREEN, "EDrawModeNOTSCREEN"); sl@0: _LIT(KDrawModeNOTPEN, "EDrawModeNOTPEN"); sl@0: _LIT(KDelay, "delay"); sl@0: _LIT(KOrientationNormal, "EOrientationNormal"); sl@0: _LIT(KOrientationRotated90, "EOrientationRotated90"); sl@0: _LIT(KOrientationRotated180, "EOrientationRotated180"); sl@0: _LIT(KOrientationRotated270, "EOrientationRotated270"); sl@0: sl@0: /** sl@0: * Shadow modes sl@0: */ sl@0: const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumShadowModes[] = sl@0: { sl@0: KNoShadow, 1, sl@0: KShadow, 2, sl@0: KFade, 3, sl@0: KShadowFade, 4 sl@0: }; sl@0: sl@0: /** sl@0: *Display Modes sl@0: */ sl@0: const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumDisplayModes[] = sl@0: { sl@0: KNone, ENone, sl@0: KGray2, EGray2, sl@0: KGray4, EGray4, sl@0: KGray16, EGray16, sl@0: KGray256, EGray256, sl@0: KColor16, EColor16, sl@0: KColor256, EColor256, sl@0: KColor64K, EColor64K, sl@0: KColor16M, EColor16M, sl@0: KRgb, ERgb, sl@0: KColor4K, EColor4K, sl@0: KColor16MU, EColor16MU, sl@0: KColor16MA, EColor16MA, sl@0: KColor16MA, EColorLast, sl@0: KColor16MAP, EColor16MAP, sl@0: KColorLast, EColor64K sl@0: }; sl@0: sl@0: /** sl@0: * Draw modes sl@0: */ sl@0: const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumDrawModes[] = sl@0: { sl@0: KDrawModePEN, CGraphicsContext::EDrawModePEN, sl@0: KDrawModeAND, CGraphicsContext::EDrawModeAND, sl@0: KDrawModeXOR, CGraphicsContext::EDrawModeXOR, sl@0: KDrawModeOR, CGraphicsContext::EDrawModeOR, sl@0: KDrawModeNOTSCREEN, CGraphicsContext::EDrawModeNOTSCREEN, sl@0: KDrawModeNOTPEN, CGraphicsContext::EDrawModeNOTPEN sl@0: }; sl@0: sl@0: const CDataWrapperBase::TEnumEntryTable CT_CFbsDrawDeviceData::iEnumOrientationModes[] = sl@0: { sl@0: KOrientationNormal, CFbsDrawDevice::EOrientationNormal, sl@0: KOrientationRotated90, CFbsDrawDevice::EOrientationRotated90, sl@0: KOrientationRotated180, CFbsDrawDevice::EOrientationRotated180, sl@0: KOrientationRotated270, CFbsDrawDevice::EOrientationRotated270 sl@0: }; sl@0: sl@0: CT_CFbsDrawDeviceData* CT_CFbsDrawDeviceData::NewL() sl@0: { sl@0: CT_CFbsDrawDeviceData* ret = new (ELeave) CT_CFbsDrawDeviceData(); sl@0: CleanupStack::PushL(ret); sl@0: ret->ConstructL(); sl@0: CleanupStack::Pop(ret); sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: CT_CFbsDrawDeviceData::CT_CFbsDrawDeviceData() sl@0: : iDrawDevice(NULL), sl@0: iDMode(CGraphicsContext::EDrawModePEN), sl@0: iDispMode(EColor64K), sl@0: iOrientation(0), sl@0: iSize(0,0), sl@0: iPostBlendShadow(ENoPostShadow), sl@0: iTestRect(), sl@0: iNumTestRects(0) sl@0: { sl@0: } sl@0: sl@0: sl@0: void CT_CFbsDrawDeviceData::ConstructL() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Public destructor sl@0: */ sl@0: CT_CFbsDrawDeviceData::~CT_CFbsDrawDeviceData() sl@0: { sl@0: DestroyData(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * Return a pointer to the object that the data wraps sl@0: * sl@0: * @return pointer to the object that the data wraps sl@0: */ sl@0: TAny* CT_CFbsDrawDeviceData::GetObject() sl@0: { sl@0: return iDrawDevice; sl@0: } sl@0: sl@0: /** sl@0: * Command for Destructor sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdDestructor() sl@0: { sl@0: DestroyData(); sl@0: } sl@0: sl@0: /** sl@0: * Destroys used objects sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DestroyData() sl@0: { sl@0: iTestRect.Reset(); sl@0: iTestRect.Close(); sl@0: iDispMode = ENone; sl@0: iSize.SetSize(0,0); sl@0: sl@0: if(iDrawDevice) sl@0: { sl@0: delete iDrawDevice; sl@0: iDrawDevice = NULL; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * Process a command read from the ini file sl@0: * sl@0: * @param aCommand The command to process sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @param aAsyncErrorIndex Command index for async calls to return errors to sl@0: * sl@0: * @return ETrue if the command is processed sl@0: * sl@0: * @leave System wide error sl@0: */ sl@0: TBool CT_CFbsDrawDeviceData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, sl@0: const TInt/* aAsyncErrorIndex*/) sl@0: { sl@0: TBool ret = ETrue; sl@0: sl@0: if ( aCommand==KCmdInitScreen ) sl@0: { sl@0: DoCmdInitScreen(); sl@0: } sl@0: else if ( aCommand==KCmdSetDisplayMode ) sl@0: { sl@0: DoCmdSetDisplayMode(); sl@0: } sl@0: else if ( aCommand==KCmdSetAutoUpdate ) sl@0: { sl@0: DoCmdSetAutoUpdate(aSection); sl@0: } sl@0: else if ( aCommand==KCmdOrientationsAvailable ) sl@0: { sl@0: DoCmdOrientationsAvailable(); sl@0: } sl@0: else if ( aCommand==KCmdSetOrientation ) sl@0: { sl@0: DoCmdSetOrientation(aSection); sl@0: } sl@0: else if ( aCommand==KCmdNewScreenDeviceL ) sl@0: { sl@0: DoCmdNewScreenDeviceL(aSection); sl@0: } sl@0: else if ( aCommand==KCmdDestructor ) sl@0: { sl@0: DoCmdDestructor(); sl@0: } sl@0: else if ( aCommand==KCmdWriteLine ) sl@0: { sl@0: DoCmdWriteLineL(aSection); sl@0: } sl@0: else if ( aCommand==KCmdWriteBinaryLine ) sl@0: { sl@0: DoCmdWriteBinaryLineL(aSection); sl@0: } sl@0: else if ( aCommand==KCmdWriteRgb ) sl@0: { sl@0: DoCmdWriteRgb(aSection); sl@0: } sl@0: else if( aCommand==KCmdWriteRgbMulti ) sl@0: { sl@0: DoCmdWriteRgbMulti(aSection); sl@0: } sl@0: else if( aCommand==KCmdReadLine ) sl@0: { sl@0: DoCmdReadLineL(aSection); sl@0: } sl@0: else if( aCommand==KCmdWriteRGBAlphaLine ) sl@0: { sl@0: DoCmdWriteRGBAlphaLineL(aSection); sl@0: } sl@0: else if( aCommand==KCmdSetShadowMode ) sl@0: { sl@0: DoCmdSetShadowMode(aSection); sl@0: } sl@0: else if( aCommand==KCmdShadowArea ) sl@0: { sl@0: DoCmdShadowArea(aSection); sl@0: } sl@0: else if( aCommand==KCmdWriteBinary ) sl@0: { sl@0: DoCmdWriteBinaryL(aSection); sl@0: } sl@0: else if( aCommand==KCmdWriteBinaryLineVertical ) sl@0: { sl@0: DoCmdWriteBinaryLineVerticalL(aSection); sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: /** sl@0: * Tests WriteRgbMulti method from CFbsDrawDevice sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti")); sl@0: TInt drawMode; sl@0: TInt delay=0; sl@0: TInt nRect = 0; sl@0: TBool dataOk=ETrue; sl@0: sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: if ( !GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes, drawMode) ) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: INFO_PRINTF2(_L("Change draw mode to: %d"), drawMode); sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: TRgb backColor = TestColor[nBackColor]; sl@0: Clear(backColor); sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: TInt shadowMode = EPostFade; sl@0: TRect rect = iTestRect[nRect]; sl@0: TRgb color = TestColor[nColor]; sl@0: SetShadowAndFadingMode(shadowMode,100, 200); sl@0: iDrawDevice->WriteRgbMulti(rect.iTl.iX,rect.iTl.iY,rect.Width(),rect.Height(),color,iDMode); sl@0: sl@0: User::After(delay); sl@0: } sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRgbMulti")); sl@0: } sl@0: sl@0: /** sl@0: * Tests WriteRgb method from CFbsDrawDevice sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteRgb(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRgb")); sl@0: TInt drawMode; sl@0: TInt nRect = 0; sl@0: TInt delay; sl@0: TBool dataOk=ETrue; sl@0: sl@0: if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: if (dataOk) sl@0: { sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: for (TInt nBackColor = 0; nBackColor < KNumTestBackgrounds; nBackColor++) sl@0: { sl@0: TRgb backColor = TestBackground[nBackColor]; sl@0: Clear(backColor); sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: TInt shadowMode = ENoPostShadow; sl@0: TRect rect = iTestRect[nRect]; sl@0: TRgb color = TestColor[nColor]; sl@0: SetShadowAndFadingMode(shadowMode,100, 200); sl@0: iDrawDevice->WriteRgb(rect.iTl.iX,rect.iTl.iY,color,iDMode); sl@0: User::After(delay); sl@0: } sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRgb")); sl@0: } sl@0: sl@0: /** sl@0: * Validates the received parameters and handles errors returned from TestScreenDrawL sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL")); sl@0: sl@0: if(iDrawDevice) sl@0: { sl@0: delete iDrawDevice; sl@0: iDrawDevice=NULL; sl@0: } sl@0: TInt drawMode; sl@0: TBool dataOk = ETrue; sl@0: if (!GetEnumFromConfig(aSection, KDisplayMode(), iEnumDisplayModes, drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDisplayMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: TDisplayMode displayMode = TDisplayMode(drawMode); sl@0: iDispMode = displayMode; sl@0: TInt ScreenNo = 0; sl@0: sl@0: User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels,iSize.iWidth)); sl@0: User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels,iSize.iHeight)); sl@0: INFO_PRINTF3(_L("WIDTH from HAL %i \nHEIGHT from HAL %i"),iSize.iWidth,iSize.iHeight); sl@0: ASSERT(iSize.iWidth > 0 && iSize.iHeight > 0); sl@0: sl@0: sl@0: TRAPD(ret,iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(ScreenNo,displayMode)); sl@0: sl@0: // check error code sl@0: if(ret != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CFbsDrawDevice creation error: %d"), ret); sl@0: SetError(ret); sl@0: } sl@0: else sl@0: { sl@0: GETFROMCONFIGMANDATORY(Int, KRectangleSection(), KNumTestRect(),iNumTestRects,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: if (!InitRectangles()) sl@0: { sl@0: SetBlockResult(EFail); sl@0: ERR_PRINTF1(_L("Error: Test Rectangles NOT set!")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Test Rectangles are now set!")); sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("** DoCmdNewScreenDeviceL succeded!")); sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdNewScreenDeviceL")); sl@0: } sl@0: sl@0: /** sl@0: * Inits Screen sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdInitScreen() sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdInitScreen")); sl@0: TInt err = iDrawDevice->InitScreen(); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("InitScreen error: %d"), err); sl@0: SetError(err); sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdInitScreen")); sl@0: } sl@0: sl@0: /** sl@0: * Sets Display Mode sl@0: * */ sl@0: void CT_CFbsDrawDeviceData::DoCmdSetDisplayMode() sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetDisplayMode")); sl@0: iDrawDevice->SetDisplayMode(iDrawDevice); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetDisplayMode")); sl@0: } sl@0: sl@0: /** sl@0: * Sets or unsets auto-update for the screen. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate")); sl@0: TBool autoUpdate=ETrue; sl@0: GETFROMCONFIGOPTIONAL(Bool, aSection, KAutoUpdate(),autoUpdate,_L("Error in getting parameter %S from INI file")); sl@0: iDrawDevice->SetAutoUpdate(autoUpdate); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetAutoUpdate")); sl@0: } sl@0: sl@0: /** sl@0: * checks for Available Orientations sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable() sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable")); sl@0: TBool orientation[4]; sl@0: iDrawDevice->OrientationsAvailable(orientation); sl@0: INFO_PRINTF2(_L("Orientation Normal : %i"),orientation[CFbsDrawDevice::EOrientationNormal]); sl@0: INFO_PRINTF2(_L("Orientation Rotated 90 : %i"),orientation[CFbsDrawDevice::EOrientationRotated90]); sl@0: INFO_PRINTF2(_L("Orientation Rotated 180 : %i"),orientation[CFbsDrawDevice::EOrientationRotated180]); sl@0: INFO_PRINTF2(_L("Orientation Rotated 270 : %i"),orientation[CFbsDrawDevice::EOrientationRotated270]); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdOrientationsAvailable")); sl@0: } sl@0: sl@0: /** sl@0: * Sets orientation sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdSetOrientation(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetOrientation")); sl@0: TBool dataOk = ETrue; sl@0: sl@0: sl@0: if ( !GetEnumFromConfig(aSection, KOrientationMode(), iEnumOrientationModes, iOrientation) ) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOrientationMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: if(dataOk) sl@0: { sl@0: sl@0: TBool orientationSupported = iDrawDevice->SetOrientation(CFbsDrawDevice::TOrientation(iOrientation)); sl@0: sl@0: if (orientationSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Orientation was set to: %d"), iOrientation); sl@0: if (iOrientation & 1) sl@0: { sl@0: iSize.SetSize(iSize.iHeight, iSize.iWidth); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Orientation not Supported")); sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetOrientation")); sl@0: } sl@0: sl@0: /** sl@0: * Tests WriteLine method from CFbsDrawDevice sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteLineL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteLineL")); sl@0: TInt byteSize = (ByteSize() / iSize.iHeight); sl@0: TInt delay; sl@0: TBool dataOk = ETrue; sl@0: sl@0: INFO_PRINTF2(_L("After setting bytesize %d"),byteSize); sl@0: TUint8* backBuffer = new(ELeave) TUint8[byteSize]; sl@0: CleanupStack::PushL(backBuffer); sl@0: TUint8* writeBuffer = new(ELeave) TUint8[byteSize]; sl@0: CleanupStack::PushL(writeBuffer); sl@0: TUint8* copyBuffer = new(ELeave) TUint8[byteSize]; sl@0: CleanupStack::PushL(copyBuffer); sl@0: TUint8* readBuffer = new(ELeave) TUint8[byteSize]; sl@0: CleanupStack::PushL(readBuffer); sl@0: sl@0: INFO_PRINTF1(_L("after setting buffers")); sl@0: sl@0: TInt drawMode; sl@0: if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: INFO_PRINTF1(_L("Test Rectangles are now set!")); sl@0: TInt nRect = 0; sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KNumRect(),nRect,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: TRect rect = iTestRect[nRect]; sl@0: TInt nBackColor = 0; sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KBackColor(),nBackColor,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: if(dataOk) sl@0: { sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: TRgb b = TestBackground[nBackColor]; sl@0: Clear(b); sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: FillBuffer(writeBuffer,byteSize,iDispMode); sl@0: sl@0: Mem::Copy(copyBuffer,writeBuffer,byteSize); sl@0: iDrawDevice->WriteLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)writeBuffer,iDMode); sl@0: Mem::FillZ(readBuffer,byteSize); sl@0: User::After(delay); sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("Deleting buffers")); sl@0: CleanupStack::PopAndDestroy(4); sl@0: INFO_PRINTF1(_L("Buffers deleted")); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteLineL")); sl@0: } sl@0: sl@0: /** sl@0: * Tests WriteBinaryLine from CFbsDrawDevice sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL")); sl@0: TInt drawMode; sl@0: TInt nRect = 0; sl@0: TInt delay; sl@0: TBool dataOk = ETrue; sl@0: sl@0: if (!GetEnumFromConfig(aSection, KDrawMode(),iEnumDrawModes, drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: if (!GetIntFromConfig(aSection, KNumRect(), nRect)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: TInt nBackColor = 0; sl@0: if (!GetIntFromConfig(aSection, KBackColor(), nBackColor)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBackColor()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: TInt shadowMode = ENoPostShadow; sl@0: if (!GetEnumFromConfig(aSection, KShadowMode(), iEnumShadowModes, shadowMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KShadowMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: if(dataOk) sl@0: { sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: sl@0: TInt byteSize = ByteSize() / iSize.iHeight; sl@0: TInt wordSize = (byteSize + 3) / 4; sl@0: TUint32* writeBuffer = new(ELeave) TUint32[wordSize]; sl@0: CleanupStack::PushL(writeBuffer); sl@0: INFO_PRINTF1(_L("Test Rectangles are now set!")); sl@0: sl@0: sl@0: TRect rect = iTestRect[nRect]; sl@0: sl@0: sl@0: sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: if (rect.Width() > KRectWidth) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + KRectWidth; sl@0: } sl@0: if (rect.Width() < 1) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + 1; sl@0: } sl@0: sl@0: TRgb backgroundColor = TestBackground[nBackColor]; sl@0: Clear(backgroundColor); sl@0: TRgb testColor = TestColor[nColor]; sl@0: sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode); sl@0: iDrawDevice->WriteBinaryLine(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),testColor,iDMode); sl@0: User::After(delay); sl@0: } sl@0: CleanupStack::PopAndDestroy(); sl@0: writeBuffer = NULL; sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineL")); sl@0: } sl@0: sl@0: /** sl@0: * Tests ReadLine from CFbsDrawDevice sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdReadLineL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdReadLineL")); sl@0: TInt byteSize = ByteSize() / iSize.iHeight; sl@0: TUint8* writeBuffer = new(ELeave) TUint8[byteSize]; sl@0: CleanupStack::PushL(writeBuffer); sl@0: TUint8* readBuffer = new(ELeave) TUint8[iSize.iWidth * sizeof(TRgb)]; sl@0: CleanupStack::PushL(readBuffer); sl@0: sl@0: FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode); sl@0: FillBuffer((TUint8*)readBuffer,byteSize,iDispMode); sl@0: sl@0: TInt nBackColor = 0; sl@0: if (!GetIntFromConfig(aSection, KBackColor(), nBackColor)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBackColor()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: TRgb b = TestColor[nBackColor]; sl@0: Clear(b); sl@0: sl@0: for (TInt nDispMode = 0; nDispMode < KNumDispModes; nDispMode++) sl@0: { sl@0: TDisplayMode dispMode = TestDisplayMode[nDispMode]; sl@0: sl@0: for (TInt cnt=0;cnt<2;cnt++) sl@0: { sl@0: if (cnt==0) //first time sl@0: { sl@0: iDrawDevice->SetUserDisplayMode(dispMode); sl@0: } sl@0: else sl@0: { sl@0: iDrawDevice->SetUserDisplayMode(iDispMode); sl@0: } sl@0: sl@0: for (TInt nRect = 0; nRect < iNumTestRects; nRect++) sl@0: { sl@0: TRect rect = iTestRect[nRect]; sl@0: for (TInt yy = rect.iTl.iY; yy < rect.iBr.iY; yy++) sl@0: { sl@0: FillBuffer(writeBuffer,byteSize,iDispMode); sl@0: Mem::FillZ(readBuffer,byteSize); sl@0: iDrawDevice->ReadLine(rect.iTl.iX,yy,rect.Width(),(TUint32*)readBuffer,dispMode); sl@0: Mem::FillZ(readBuffer,byteSize); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(2); sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdReadLineL")); sl@0: } sl@0: sl@0: /** sl@0: * Tests RGBAlphaLine from CFbsDrawDevice sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL")); sl@0: TInt drawMode; sl@0: sl@0: if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: TInt byteSize = ByteSize() / iSize.iHeight; sl@0: INFO_PRINTF1(_L("In TestWriteRGBAlphaLine")); sl@0: sl@0: TUint8* writeBuffer = new(ELeave) TUint8[iSize.iWidth * 4]; sl@0: CleanupStack::PushL(writeBuffer); sl@0: TUint8* writeBuffer2 = new(ELeave) TUint8[iSize.iWidth * 4]; sl@0: CleanupStack::PushL(writeBuffer2); sl@0: TUint8* maskBuffer = new(ELeave) TUint8[iSize.iWidth * 4]; sl@0: CleanupStack::PushL(maskBuffer); sl@0: sl@0: FillBuffer(writeBuffer,byteSize,iDispMode); sl@0: FillBuffer(writeBuffer2,byteSize,iDispMode); sl@0: FillBuffer(maskBuffer,byteSize,iDispMode); sl@0: sl@0: TInt nRect; sl@0: for (TInt maskFillCount=0; maskFillCount>24); sl@0: combinedAlpha = ((combinedAlpha <<16) & 0xff000000); sl@0: checkColor.SetInternal((internal&0x00ffffff)|combinedAlpha); sl@0: SetShadowAndFadingMode(shadowMode,100, 200); 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: iDMode); 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: if(shadowModeChanged) sl@0: { sl@0: shadowMode = iPostBlendShadow; sl@0: } sl@0: iPostBlendShadow = ENoPostShadow; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("** delete buffers")); sl@0: CleanupStack::PopAndDestroy(3); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteRGBAlphaLineL")); sl@0: } sl@0: sl@0: /** sl@0: * Tests ShadowArea from CFbsDrawDevice sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdShadowArea(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdShadowArea")); sl@0: TInt delay=0; sl@0: TBool dataOk = ETrue; sl@0: sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: sl@0: if(dataOk) sl@0: { sl@0: INFO_PRINTF1(_L("In TestShadow()")); sl@0: TInt nBackColor = 1; sl@0: TRgb testColor = TestColor[nBackColor]; sl@0: Clear(testColor); sl@0: sl@0: for (TInt shadowMode = 0; shadowMode < KNumShadowModes; shadowMode++) sl@0: { sl@0: for (TInt nRect = 0; nRect < iNumTestRects; nRect++) sl@0: { sl@0: for (TInt nColor = 0; nColor < KNumTestColors; nColor++) sl@0: { sl@0: TRect rect = iTestRect[nRect]; sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: iDrawDevice->ShadowArea(rect); sl@0: sl@0: User::After(delay); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdShadowArea")); sl@0: sl@0: } sl@0: sl@0: /** sl@0: * Tests WriteBinaryLineVertical from CFbsDrawDevice sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL")); sl@0: TInt drawMode; sl@0: TInt delay; sl@0: TBool dataOk = ETrue; sl@0: if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: TInt nRect = 0; sl@0: if (!GetIntFromConfig(aSection, KNumRect(), nRect)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: if(dataOk) sl@0: { sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: sl@0: TInt byteSize = ByteSize() / iSize.iHeight; sl@0: TInt wordSize = (byteSize + 3) / 4; sl@0: TUint32* writeBuffer = new(ELeave) TUint32[wordSize]; sl@0: TInt nBackColor = 1; sl@0: TInt nColor = 4; sl@0: sl@0: TRect rect = iTestRect[nRect]; sl@0: if (rect.Width() > KRectWidth) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + KRectWidth; sl@0: } sl@0: if (rect.Width() < 1) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + 1; sl@0: } sl@0: sl@0: TRgb b = TestBackground[nBackColor]; sl@0: TRgb c = TestColor[nColor]; sl@0: Clear(b); sl@0: sl@0: sl@0: //NOTE Call Command within script: SetShadowmode sl@0: FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode); sl@0: iDrawDevice->WriteBinaryLineVertical(rect.iTl.iX,rect.iBr.iY - 1,writeBuffer,rect.Height(),c,iDMode,ETrue); sl@0: sl@0: User::After(delay); sl@0: delete [] writeBuffer; sl@0: writeBuffer = NULL; sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryLineVerticalL")); sl@0: } sl@0: sl@0: /** sl@0: * Sets the current shadowing mode sl@0: * @param aSection The section in the ini containing data for the command sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdSetShadowMode(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdSetShadowMode")); sl@0: TInt shadowMode = ENoPostShadow; sl@0: if(!GetEnumFromConfig(aSection, KShadowMode(), iEnumShadowModes, shadowMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KShadowMode()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdSetShadowMode")); sl@0: } sl@0: sl@0: /** sl@0: * Tests WriteBinary method from CFbsDrawDevice sl@0: * @param aSection The section in the ini containing data for the command sl@0: * @return KErrNone if no error found. sl@0: */ sl@0: void CT_CFbsDrawDeviceData::DoCmdWriteBinaryL(const TTEFSectionName& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::DoCmdWriteBinaryL")); sl@0: TInt drawMode; sl@0: TInt delay; sl@0: TBool dataOk = ETrue; sl@0: if (!GetEnumFromConfig(aSection, KDrawMode(), iEnumDrawModes,drawMode)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDrawMode()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: GETFROMCONFIGMANDATORY(Int, aSection, KDelay(),delay,_L("Error in getting parameter %S from INI file"),dataOk); sl@0: TInt nRect = 0; sl@0: if (!GetIntFromConfig(aSection, KNumRect(), nRect)) sl@0: { sl@0: ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumRect()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: iDMode=CGraphicsContext::TDrawMode(drawMode); sl@0: TInt byteSize = ByteSize() / iSize.iHeight; sl@0: TInt wordSize = (byteSize + 3) / 4; sl@0: TUint32* writeBuffer = new (ELeave)TUint32[wordSize]; sl@0: sl@0: TRect rect = iTestRect[nRect]; sl@0: TInt nBackColor = 0; sl@0: TInt nColor = 4; sl@0: sl@0: if (rect.Width() > KRectWidth) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + KRectWidth; sl@0: } sl@0: if (rect.Width() < 1) sl@0: { sl@0: rect.iBr.iX = rect.iTl.iX + 1; sl@0: } sl@0: sl@0: TRgb b = TestBackground[nBackColor]; sl@0: Clear(b); sl@0: TRgb c = TestColor[nColor]; sl@0: //NOTE Call Command within script: SetShadowmode sl@0: FillBuffer((TUint8*)writeBuffer,byteSize,iDispMode); sl@0: iDrawDevice->WriteBinary(rect.iTl.iX,rect.iTl.iY,writeBuffer,rect.Width(),rect.Height(),c,iDMode); sl@0: sl@0: User::After(delay); sl@0: delete [] writeBuffer; sl@0: writeBuffer = NULL; sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::DoCmdWriteBinaryL")); sl@0: } sl@0: sl@0: /** sl@0: * Clears screen with specified color sl@0: */ sl@0: void CT_CFbsDrawDeviceData::Clear(TRgb aColor) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::Clear")); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow); sl@0: iDrawDevice->WriteRgbMulti(0,0,iSize.iWidth,iSize.iHeight,aColor,CGraphicsContext::EDrawModeWriteAlpha); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::Clear")); sl@0: } sl@0: /** sl@0: * Sets Shadow and fading modes sl@0: * @param one of the supported shadow modes ENoShadow,EShadow,EFade,EShadowFade sl@0: * @param a black point sl@0: * @param a white point sl@0: */ sl@0: void CT_CFbsDrawDeviceData::SetShadowAndFadingMode(TInt shadowMode,TInt blackPoint, TInt whitePoint) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::SetShadowAndFadingMode")); sl@0: iDrawDevice->SetFadingParameters(blackPoint,whitePoint); sl@0: iDrawDevice->SetShadowMode(CFbsDrawDevice::TShadowMode(shadowMode)); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::SetShadowAndFadingMode")); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * Fills a buffer to be displayed on screen sl@0: * sl@0: * @param aBuffer sl@0: * @param aByteSize sl@0: * @param aDispMode sl@0: */ sl@0: void CT_CFbsDrawDeviceData::FillBuffer(TUint8* aBuffer,TInt aByteSize,TDisplayMode aDispMode) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::FillBuffer")); sl@0: TUint8* bufferLimit = aBuffer + aByteSize; sl@0: sl@0: TInt64 seed = TInt64(TInt(aBuffer) * aByteSize * aDispMode * User::TickCount()); sl@0: sl@0: if (aDispMode != EColor4K) 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: { sl@0: *aBuffer++ = 0; sl@0: } sl@0: else sl@0: { sl@0: *aBuffer++ = (TUint8)Math::Rand(seed); sl@0: } sl@0: } sl@0: } sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::FillBuffer")); sl@0: } sl@0: sl@0: /** sl@0: * Sets the Byte Size based on screen Width and Height sl@0: */ sl@0: TInt CT_CFbsDrawDeviceData::ByteSize() sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::ByteSize")); sl@0: TInt wordSize = iSize.iWidth; sl@0: switch (iDispMode) sl@0: { sl@0: case EGray2: sl@0: wordSize = (wordSize + 31) / 32; sl@0: break; sl@0: case EGray4: sl@0: wordSize = (wordSize + 15) / 16; sl@0: break; sl@0: case EGray16: sl@0: case EColor16: sl@0: wordSize = (wordSize + 7) / 8; sl@0: break; sl@0: case EGray256: sl@0: case EColor256: sl@0: wordSize = (wordSize + 3) / 4; sl@0: break; sl@0: case EColor4K: sl@0: case EColor64K: sl@0: wordSize = (wordSize + 1) / 2; sl@0: break; sl@0: case EColor16M: sl@0: wordSize = (((wordSize * 3) + 11) / 12) * 3; sl@0: break; sl@0: case EColor16MU: sl@0: case EColor16MA: sl@0: //Should not be changed! sl@0: break; sl@0: default: sl@0: break; sl@0: }; sl@0: sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::ByteSize")); sl@0: return wordSize * iSize.iHeight * 4; sl@0: } sl@0: sl@0: /** sl@0: * This method reads a string with this form: (a,,b,c,d) and splits it in an TInt array. sl@0: * sl@0: */ sl@0: void CT_CFbsDrawDeviceData::ReadRectL(HBufC& aString, RArray& aResult) sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::ReadRectL")); sl@0: TChar chr; sl@0: TLex lex(aString); sl@0: TBuf<256> buf; sl@0: sl@0: lex.Inc(); sl@0: while(!lex.Eos()) sl@0: { sl@0: chr = lex.Get(); sl@0: // Check if there was a list separator sl@0: if (chr == ',') sl@0: { sl@0: HBufC* param = buf.AllocLC(); sl@0: buf.Zero(); sl@0: TInt x = 0; sl@0: TLex lexX(*param); sl@0: lexX.Val(x); sl@0: aResult.Append(x); sl@0: CleanupStack::Pop(param); // pointer to buf is stored in RPointerArray sl@0: } sl@0: // If not separator character we can store the character into array sl@0: else sl@0: { sl@0: if (chr != ')') sl@0: { sl@0: buf.Append(chr); sl@0: } sl@0: } sl@0: } sl@0: sl@0: HBufC* param = buf.AllocLC(); sl@0: TInt x = 0; sl@0: TLex lexX(*param); sl@0: lexX.Val(x); sl@0: aResult.Append(x); sl@0: CleanupStack::PopAndDestroy(param); sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::ReadRectL")); sl@0: } sl@0: sl@0: /** sl@0: * This method reads a string with this form: (a,,b,c,d) and splits it in an TInt array. sl@0: * sl@0: */ sl@0: TBool CT_CFbsDrawDeviceData::InitRectangles() sl@0: { sl@0: INFO_PRINTF1(_L("*START* CT_CFbsDrawDeviceData::InitRectangles")); sl@0: TBool readResult = ETrue; sl@0: RPointerArray dimensions; sl@0: RArray result; sl@0: TInt err = KErrNone; sl@0: sl@0: if ( GetArrayRectFromConfig( KRectangleSection(), KRectangles(), dimensions))//its validated by the above call sl@0: { sl@0: for (TInt i = 0; i < iNumTestRects; i++) sl@0: { sl@0: TRAP(err , ReadRectL(*dimensions[i], result)); sl@0: if (err != KErrNone) sl@0: { sl@0: readResult = EFalse; sl@0: break; sl@0: } sl@0: else sl@0: { sl@0: iTestRect.Append(TRect(result[0],result[1],result[2],result[3])); sl@0: result.Reset(); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: readResult = EFalse; sl@0: } sl@0: dimensions.ResetAndDestroy(); sl@0: result.Reset(); sl@0: result.Close(); sl@0: sl@0: INFO_PRINTF1(_L("*END* CT_CFbsDrawDeviceData::InitRectangles")); sl@0: return readResult; sl@0: sl@0: }