|
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 implements the class for a 16 bpp color screen. |
|
15 // Include files |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 */ |
|
22 /********************************************************************/ |
|
23 #include <hal.h> |
|
24 #include <e32std.h> |
|
25 #include <bitdraw.h> |
|
26 #include "scdraw.h" |
|
27 |
|
28 /********************************************************************/ |
|
29 /* Implementation of CDrawSixteenBppScreenBitmap class */ |
|
30 /********************************************************************/ |
|
31 void CDrawSixteenBppScreenBitmap::SetSize(const TSize& aSize) |
|
32 { |
|
33 CDrawBitmap::SetSize(aSize); |
|
34 __ASSERT_DEBUG(iSize == aSize, User::Invariant()); |
|
35 iLongWidth = iScanLineWords *2; |
|
36 } |
|
37 void CDrawSixteenBppScreenBitmap::SetDisplayMode(CFbsDrawDevice* aDrawDevice) |
|
38 { |
|
39 CopyOldSettings(aDrawDevice) ; |
|
40 InitScreen() ; |
|
41 } |
|
42 |
|
43 TInt CDrawSixteenBppScreenBitmap::HorzTwipsPerThousandPixels() const |
|
44 { |
|
45 if (iSize.iWidth == 0) |
|
46 return 0 ; |
|
47 TMachineInfoV1Buf miBuf ; |
|
48 UserHal::MachineInfo(miBuf) ; |
|
49 return miBuf().iPhysicalScreenSize.iWidth * 1000 / iSize.iWidth ; |
|
50 } |
|
51 |
|
52 TInt CDrawSixteenBppScreenBitmap::VertTwipsPerThousandPixels() const |
|
53 { |
|
54 if (iSize.iHeight == 0) |
|
55 return 0 ; |
|
56 |
|
57 TMachineInfoV1Buf miBuf ; |
|
58 UserHal::MachineInfo(miBuf) ; |
|
59 return miBuf().iPhysicalScreenSize.iHeight * 1000 / iSize.iHeight ; |
|
60 } |
|
61 |
|
62 /** |
|
63 This function initialize the palette. In this mode, there is no palette |
|
64 defined |
|
65 */ |
|
66 TInt CDrawSixteenBppScreenBitmap::InitScreen() |
|
67 { |
|
68 return KErrNone ; |
|
69 } |
|
70 |
|
71 /** |
|
72 Constructs the CDrawSixteenBppScreenBitmap object. |
|
73 @param aScreenNo Screen number. It will be used in HAL::Get() calls. |
|
74 @param aBitmapAddress The screen memory address. |
|
75 @param aSize Screen size |
|
76 @return System-wide error codes, KErrNone if the construction was successfull. |
|
77 */ |
|
78 TInt CDrawSixteenBppScreenBitmap::ConstructScreenL(TInt aScreenNo, TAny* aBitmapAddress, TSize aSize) |
|
79 { |
|
80 iScreenNo = aScreenNo; |
|
81 TInt displayMode; |
|
82 |
|
83 TInt ret = HAL::Get(aScreenNo, HALData::EDisplayMode, displayMode); |
|
84 if (ret != KErrNone) |
|
85 return ret; |
|
86 |
|
87 TInt linepitchInBytes = displayMode; |
|
88 ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetBetweenLines,linepitchInBytes); |
|
89 if (ret != KErrNone) |
|
90 return ret; |
|
91 |
|
92 CDrawBitmap::iScanLineWords = linepitchInBytes / 4; |
|
93 ret = CDrawSixteenBppBitmap::Construct(aSize); |
|
94 if (ret != KErrNone) |
|
95 return ret ; |
|
96 |
|
97 /* Set the pointer on the first pixel */ |
|
98 TInt offsetToFirstPixel = displayMode; |
|
99 ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetToFirstPixel, offsetToFirstPixel); |
|
100 if (ret != KErrNone) |
|
101 return ret; |
|
102 iBits = (TUint32*)((TUint32)aBitmapAddress + offsetToFirstPixel); |
|
103 |
|
104 return KErrNone ; |
|
105 } |
|
106 |
|
107 /** |
|
108 Define the screen orientation available |
|
109 */ |
|
110 void CDrawSixteenBppScreenBitmap::OrientationsAvailable(TBool aOrientation[4]) |
|
111 { |
|
112 aOrientation[EOrientationNormal] = ETrue ; |
|
113 aOrientation[EOrientationRotated90] = ETrue ; |
|
114 aOrientation[EOrientationRotated180] = ETrue ; |
|
115 aOrientation[EOrientationRotated270] = ETrue ; |
|
116 } |
|
117 |
|
118 /** |
|
119 Set the current display orientation |
|
120 */ |
|
121 TBool CDrawSixteenBppScreenBitmap::SetOrientation(TOrientation aOrientation) |
|
122 { |
|
123 iOrientation = aOrientation ; |
|
124 return ETrue ; |
|
125 } |