First public contribution.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This module implemente the class use for a 8 bpp color screen.
22 /********************************************************************/
27 /********************************************************************/
28 /* Implementation of CDrawEightBppScreenBitmapColor class */
29 /********************************************************************/
30 void CDrawEightBppScreenBitmapColor::SetSize(const TSize& aSize)
32 CDrawBitmap::SetSize(aSize);
33 __ASSERT_DEBUG(iSize == aSize, User::Invariant());
34 iLongWidth = CDrawBitmap::iScanLineWords * 4;
36 void CDrawEightBppScreenBitmapColor::SetDisplayMode(CFbsDrawDevice* aDrawDevice)
38 CopyOldSettings(aDrawDevice) ;
42 TInt CDrawEightBppScreenBitmapColor::HorzTwipsPerThousandPixels() const
44 if (iSize.iWidth == 0)
46 TMachineInfoV1Buf miBuf ;
47 UserHal::MachineInfo(miBuf) ;
48 return miBuf().iPhysicalScreenSize.iWidth * 1000 / iSize.iWidth ;
51 TInt CDrawEightBppScreenBitmapColor::VertTwipsPerThousandPixels() const
53 if (iSize.iHeight == 0)
56 TMachineInfoV1Buf miBuf ;
57 UserHal::MachineInfo(miBuf) ;
58 return miBuf().iPhysicalScreenSize.iHeight * 1000 / iSize.iHeight ;
62 Initialises the palette
64 TInt CDrawEightBppScreenBitmapColor::InitScreen()
67 __ASSERT_ALWAYS(iPaletteAddress!=NULL, Panic(EScreenDriverPanicNullPointer)) ;
69 /* Fill the palette to support 8 Bpp color */
70 TUint16* palettePtr = iPaletteAddress ;
71 for (TInt count = 0; count < KEightBppPaletteEntries; count++)
72 *palettePtr++ = TRgb::Color256(count)._Color4K() | KEightBppPixelBitSize ;
78 Constructs the CDrawEightBppScreenBitmapColor object.
79 @param aScreenNo Screen number. It will be used in HAL::Get() calls.
80 @param aBitmapAddress The screen memory address.
81 @param aSize Screen size
82 @return System-wide error codes, KErrNone if the construction was successfull.
84 TInt CDrawEightBppScreenBitmapColor::ConstructScreenL(TInt aScreenNo, TAny* aBitmapAddress, TSize aSize)
86 iScreenNo = aScreenNo;
89 TInt ret = HAL::Get(aScreenNo, HALData::EDisplayMode, displayMode);
93 TInt linepitchInBytes = displayMode;
94 ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetBetweenLines,linepitchInBytes);
98 CDrawBitmap::iScanLineWords = linepitchInBytes / 4;
99 ret = CDrawEightBppBitmapColor::Construct(aSize);
103 /* Set the pointer on the first palette entry */
104 iPaletteAddress = (TUint16*)aBitmapAddress ;
106 TInt offsetToFirstPixel = displayMode;
107 ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetToFirstPixel, offsetToFirstPixel);
110 iBits = (TUint32*)((TUint32)aBitmapAddress + offsetToFirstPixel);
115 void CDrawEightBppScreenBitmapColor::OrientationsAvailable(TBool aOrientation[4])
117 aOrientation[EOrientationNormal] = ETrue ;
118 aOrientation[EOrientationRotated90] = ETrue ;
119 aOrientation[EOrientationRotated180] = ETrue ;
120 aOrientation[EOrientationRotated270] = ETrue ;
123 TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation)
125 iOrientation = aOrientation ;
129 TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette)
131 TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette) ;
136 TUint16* palettePtr = iPaletteAddress ;
137 const TUint16* const palettePtrLimit = iPaletteAddress + KEightBppPaletteEntries ;
139 *palettePtr++ = IndexToColor(index++)._Color4K() | KEightBppPixelBitSize ;
141 while (palettePtr < palettePtrLimit)
142 *palettePtr++ = IndexToColor(index++)._Color4K() ;