First public contribution.
1 // Copyright (c) 1997-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.
20 #include "ScreenInfo.h"
21 #include <graphics/gdi/gdiconsts.h>
24 Creates an instance of CFbsDrawDevice class.
25 @param aScreenNo Screen number
26 @param aDispMode Display mode
27 @param aScreenInfo Screen parameters: video memory address and screen size
28 @return A pointer to the created CFbsDrawDevice object
29 @leave System-wide error code including KErrNoMemory
32 static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
33 TDisplayMode aDispMode,
34 const TScreenInfo& aScreenInfo)
37 // As multiple screens are possible, the (optional) second parameter is necessary here
38 // to find the color depth specific to this screen.
39 EmulatorColorDepth(depths, aScreenNo);
42 CFbsDrawDevice* drawDevice = NULL;
47 if (!(depths & KEmulGray2))
48 User::Leave(KErrNotSupported);
49 drawDevice = new(ELeave) CDrawOneBppScreenBitmap;
50 CleanupStack::PushL(drawDevice);
51 User::LeaveIfError((static_cast<CDrawOneBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
56 if (!(depths & KEmulGray4))
57 User::Leave(KErrNotSupported);
58 drawDevice = new(ELeave) CDrawTwoBppScreenBitmap;
59 CleanupStack::PushL(drawDevice);
60 User::LeaveIfError((static_cast<CDrawTwoBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
65 if (!(depths & KEmulGray16))
66 User::Leave(KErrNotSupported);
67 drawDevice = new(ELeave) CDrawFourBppScreenBitmapGray;
68 CleanupStack::PushL(drawDevice);
69 User::LeaveIfError((static_cast<CDrawFourBppScreenBitmapGray*> (drawDevice)) ->ConstructScreen(aScreenNo,
74 if (!(depths & KEmulGray256))
75 User::Leave(KErrNotSupported);
76 drawDevice = new(ELeave) CDrawEightBppScreenBitmapGray;
77 CleanupStack::PushL(drawDevice);
78 User::LeaveIfError((static_cast<CDrawEightBppScreenBitmapGray*> (drawDevice)) ->ConstructScreen(aScreenNo,
83 if (!(depths & KEmulColor16))
84 User::Leave(KErrNotSupported);
85 drawDevice = new(ELeave) CDrawFourBppScreenBitmapColor;
86 CleanupStack::PushL(drawDevice);
87 User::LeaveIfError((static_cast<CDrawFourBppScreenBitmapColor*> (drawDevice)) ->ConstructScreen(aScreenNo,
92 if (!(depths & KEmulColor256))
93 User::Leave(KErrNotSupported);
94 drawDevice = new(ELeave) CDrawEightBppScreenBitmapColor;
95 CleanupStack::PushL(drawDevice);
96 User::LeaveIfError((static_cast<CDrawEightBppScreenBitmapColor*> (drawDevice)) ->ConstructScreen(aScreenNo,
101 if (!(depths & KEmulColor4K))
102 User::Leave(KErrNotSupported);
103 drawDevice = new(ELeave) CDrawTwelveBppScreenBitmap;
104 CleanupStack::PushL(drawDevice);
105 User::LeaveIfError((static_cast<CDrawTwelveBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
106 aScreenInfo.iAddress,
110 if (!(depths & KEmulColor64K))
111 User::Leave(KErrNotSupported);
112 drawDevice = new(ELeave) CDrawSixteenBppScreenBitmap;
113 CleanupStack::PushL(drawDevice);
114 User::LeaveIfError((static_cast<CDrawSixteenBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
115 aScreenInfo.iAddress,
119 if (!(depths & KEmulColor16M))
120 User::Leave(KErrNotSupported);
121 drawDevice = new(ELeave) CDrawTwentyFourBppScreenBitmap;
122 CleanupStack::PushL(drawDevice);
123 User::LeaveIfError((static_cast<CDrawTwentyFourBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
124 aScreenInfo.iAddress,
128 if (!(depths & KEmulColor16M))
129 User::Leave(KErrNotSupported);
130 drawDevice = new(ELeave) CDrawUTwentyFourBppScreenBitmap;
131 CleanupStack::PushL(drawDevice);
132 User::LeaveIfError((static_cast<CDrawUTwentyFourBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
133 aScreenInfo.iAddress,
137 if (!(depths & KEmulColor16M))
138 User::Leave(KErrNotSupported);
139 drawDevice = new(ELeave) CDrawThirtyTwoBppScreenBitmapAlpha;
140 CleanupStack::PushL(drawDevice);
141 User::LeaveIfError((static_cast<CDrawThirtyTwoBppScreenBitmapAlpha*> (drawDevice)) ->ConstructScreen(aScreenNo,
142 aScreenInfo.iAddress,
146 if (!(depths & KEmulColor16M))
147 User::Leave(KErrNotSupported);
148 drawDevice = new(ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM;
149 CleanupStack::PushL(drawDevice);
150 User::LeaveIfError((static_cast<CDrawThirtyTwoBppScreenBitmapAlphaPM*> (drawDevice)) ->ConstructScreen(aScreenNo,
151 aScreenInfo.iAddress,
155 User::Leave(KErrNotSupported);
158 CleanupStack::Pop(); // drawDevice
163 @deprecated Use NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
165 EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo,
166 TDisplayMode aDispMode)
168 __ASSERT_ALWAYS(aInfo.iScreenAddressValid && aInfo.iScreenAddress, Panic(EScreenDriverPanicInvalidWindowHandle));
169 TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
170 return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
174 Creates a new screen device instance, which implements CFbsDrawDevice interface.
175 The method has to be implemented for each type of supported video hardware.
176 @param aScreenNo Screen number
177 @param aDispMode Requested display mode
178 @return A pointer to just created screen device, which implements CFbsDrawDevice interface
179 @leave KErrNoMemory Not enough memory
180 KErrNotSupported The requested screen device type is not supported
182 EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
183 TDisplayMode aDispMode)
185 TInt address = 0, width = 0, height = 0;
186 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address));
187 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
188 User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
189 __ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue));
190 TScreenInfo screenInfo(reinterpret_cast <TAny*> (address), TSize(width, height));
191 return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
195 Depending on the current graphics hardware this
196 will return one of the 16M video modes defined in
197 TDisplayMode, or ENone if a 16M video mode is not supported.
199 @return a 16M display mode or ENone.
201 EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()