|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This module implemente the class use for a 8 bpp color screen. |
|
15 // Include files |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 */ |
|
22 /********************************************************************/ |
|
23 #include <bitdraw.h> |
|
24 #include "scdraw.h" |
|
25 #include <hal.h> |
|
26 |
|
27 /********************************************************************/ |
|
28 /* Implementation of CDrawEightBppScreenBitmapColor class */ |
|
29 /********************************************************************/ |
|
30 void CDrawEightBppScreenBitmapColor::SetSize(const TSize& aSize) |
|
31 { |
|
32 CDrawBitmap::SetSize(aSize); |
|
33 __ASSERT_DEBUG(iSize == aSize, User::Invariant()); |
|
34 iLongWidth = CDrawBitmap::iScanLineWords * 4; |
|
35 } |
|
36 void CDrawEightBppScreenBitmapColor::SetDisplayMode(CFbsDrawDevice* aDrawDevice) |
|
37 { |
|
38 CopyOldSettings(aDrawDevice) ; |
|
39 InitScreen() ; |
|
40 } |
|
41 |
|
42 TInt CDrawEightBppScreenBitmapColor::HorzTwipsPerThousandPixels() const |
|
43 { |
|
44 if (iSize.iWidth == 0) |
|
45 return 0 ; |
|
46 TMachineInfoV1Buf miBuf ; |
|
47 UserHal::MachineInfo(miBuf) ; |
|
48 return miBuf().iPhysicalScreenSize.iWidth * 1000 / iSize.iWidth ; |
|
49 } |
|
50 |
|
51 TInt CDrawEightBppScreenBitmapColor::VertTwipsPerThousandPixels() const |
|
52 { |
|
53 if (iSize.iHeight == 0) |
|
54 return 0 ; |
|
55 |
|
56 TMachineInfoV1Buf miBuf ; |
|
57 UserHal::MachineInfo(miBuf) ; |
|
58 return miBuf().iPhysicalScreenSize.iHeight * 1000 / iSize.iHeight ; |
|
59 } |
|
60 |
|
61 /** |
|
62 Initialises the palette |
|
63 */ |
|
64 TInt CDrawEightBppScreenBitmapColor::InitScreen() |
|
65 { |
|
66 |
|
67 __ASSERT_ALWAYS(iPaletteAddress!=NULL, Panic(EScreenDriverPanicNullPointer)) ; |
|
68 |
|
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 ; |
|
73 |
|
74 return KErrNone ; |
|
75 } |
|
76 |
|
77 /** |
|
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. |
|
83 */ |
|
84 TInt CDrawEightBppScreenBitmapColor::ConstructScreenL(TInt aScreenNo, TAny* aBitmapAddress, TSize aSize) |
|
85 { |
|
86 iScreenNo = aScreenNo; |
|
87 TInt displayMode; |
|
88 |
|
89 TInt ret = HAL::Get(aScreenNo, HALData::EDisplayMode, displayMode); |
|
90 if (ret != KErrNone) |
|
91 return ret; |
|
92 |
|
93 TInt linepitchInBytes = displayMode; |
|
94 ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetBetweenLines,linepitchInBytes); |
|
95 if (ret != KErrNone) |
|
96 return ret; |
|
97 |
|
98 CDrawBitmap::iScanLineWords = linepitchInBytes / 4; |
|
99 ret = CDrawEightBppBitmapColor::Construct(aSize); |
|
100 if (ret != KErrNone) |
|
101 return ret ; |
|
102 |
|
103 /* Set the pointer on the first palette entry */ |
|
104 iPaletteAddress = (TUint16*)aBitmapAddress ; |
|
105 |
|
106 TInt offsetToFirstPixel = displayMode; |
|
107 ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetToFirstPixel, offsetToFirstPixel); |
|
108 if (ret != KErrNone) |
|
109 return ret; |
|
110 iBits = (TUint32*)((TUint32)aBitmapAddress + offsetToFirstPixel); |
|
111 |
|
112 return KErrNone ; |
|
113 } |
|
114 |
|
115 void CDrawEightBppScreenBitmapColor::OrientationsAvailable(TBool aOrientation[4]) |
|
116 { |
|
117 aOrientation[EOrientationNormal] = ETrue ; |
|
118 aOrientation[EOrientationRotated90] = ETrue ; |
|
119 aOrientation[EOrientationRotated180] = ETrue ; |
|
120 aOrientation[EOrientationRotated270] = ETrue ; |
|
121 } |
|
122 |
|
123 TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation) |
|
124 { |
|
125 iOrientation = aOrientation ; |
|
126 return ETrue ; |
|
127 } |
|
128 |
|
129 TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette) |
|
130 { |
|
131 TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette) ; |
|
132 |
|
133 if (ret == KErrNone) |
|
134 { |
|
135 TInt index = 0 ; |
|
136 TUint16* palettePtr = iPaletteAddress ; |
|
137 const TUint16* const palettePtrLimit = iPaletteAddress + KEightBppPaletteEntries ; |
|
138 |
|
139 *palettePtr++ = IndexToColor(index++)._Color4K() | KEightBppPixelBitSize ; |
|
140 |
|
141 while (palettePtr < palettePtrLimit) |
|
142 *palettePtr++ = IndexToColor(index++)._Color4K() ; |
|
143 } |
|
144 return ret ; |
|
145 } |