sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// WINS platform
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <hal.h>
|
sl@0
|
19 |
#include "SCDRAW.H"
|
sl@0
|
20 |
#include "ScreenInfo.h"
|
sl@0
|
21 |
#include <graphics/gdi/gdiconsts.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
Creates an instance of CFbsDrawDevice class.
|
sl@0
|
25 |
@param aScreenNo Screen number
|
sl@0
|
26 |
@param aDispMode Display mode
|
sl@0
|
27 |
@param aScreenInfo Screen parameters: video memory address and screen size
|
sl@0
|
28 |
@return A pointer to the created CFbsDrawDevice object
|
sl@0
|
29 |
@leave System-wide error code including KErrNoMemory
|
sl@0
|
30 |
@internalComponent
|
sl@0
|
31 |
*/
|
sl@0
|
32 |
static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
|
sl@0
|
33 |
TDisplayMode aDispMode,
|
sl@0
|
34 |
const TScreenInfo& aScreenInfo)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
TUint depths = 0;
|
sl@0
|
37 |
// As multiple screens are possible, the (optional) second parameter is necessary here
|
sl@0
|
38 |
// to find the color depth specific to this screen.
|
sl@0
|
39 |
EmulatorColorDepth(depths, aScreenNo);
|
sl@0
|
40 |
ASSERT(depths);
|
sl@0
|
41 |
|
sl@0
|
42 |
CFbsDrawDevice* drawDevice = NULL;
|
sl@0
|
43 |
|
sl@0
|
44 |
switch(aDispMode)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
case EGray2:
|
sl@0
|
47 |
if (!(depths & KEmulGray2))
|
sl@0
|
48 |
User::Leave(KErrNotSupported);
|
sl@0
|
49 |
drawDevice = new(ELeave) CDrawOneBppScreenBitmap;
|
sl@0
|
50 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
51 |
User::LeaveIfError((static_cast<CDrawOneBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
52 |
aScreenInfo.iAddress,
|
sl@0
|
53 |
aScreenInfo.iSize));
|
sl@0
|
54 |
break;
|
sl@0
|
55 |
case EGray4:
|
sl@0
|
56 |
if (!(depths & KEmulGray4))
|
sl@0
|
57 |
User::Leave(KErrNotSupported);
|
sl@0
|
58 |
drawDevice = new(ELeave) CDrawTwoBppScreenBitmap;
|
sl@0
|
59 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
60 |
User::LeaveIfError((static_cast<CDrawTwoBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
61 |
aScreenInfo.iAddress,
|
sl@0
|
62 |
aScreenInfo.iSize));
|
sl@0
|
63 |
break;
|
sl@0
|
64 |
case EGray16:
|
sl@0
|
65 |
if (!(depths & KEmulGray16))
|
sl@0
|
66 |
User::Leave(KErrNotSupported);
|
sl@0
|
67 |
drawDevice = new(ELeave) CDrawFourBppScreenBitmapGray;
|
sl@0
|
68 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
69 |
User::LeaveIfError((static_cast<CDrawFourBppScreenBitmapGray*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
70 |
aScreenInfo.iAddress,
|
sl@0
|
71 |
aScreenInfo.iSize));
|
sl@0
|
72 |
break;
|
sl@0
|
73 |
case EGray256:
|
sl@0
|
74 |
if (!(depths & KEmulGray256))
|
sl@0
|
75 |
User::Leave(KErrNotSupported);
|
sl@0
|
76 |
drawDevice = new(ELeave) CDrawEightBppScreenBitmapGray;
|
sl@0
|
77 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
78 |
User::LeaveIfError((static_cast<CDrawEightBppScreenBitmapGray*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
79 |
aScreenInfo.iAddress,
|
sl@0
|
80 |
aScreenInfo.iSize));
|
sl@0
|
81 |
break;
|
sl@0
|
82 |
case EColor16:
|
sl@0
|
83 |
if (!(depths & KEmulColor16))
|
sl@0
|
84 |
User::Leave(KErrNotSupported);
|
sl@0
|
85 |
drawDevice = new(ELeave) CDrawFourBppScreenBitmapColor;
|
sl@0
|
86 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
87 |
User::LeaveIfError((static_cast<CDrawFourBppScreenBitmapColor*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
88 |
aScreenInfo.iAddress,
|
sl@0
|
89 |
aScreenInfo.iSize));
|
sl@0
|
90 |
break;
|
sl@0
|
91 |
case EColor256:
|
sl@0
|
92 |
if (!(depths & KEmulColor256))
|
sl@0
|
93 |
User::Leave(KErrNotSupported);
|
sl@0
|
94 |
drawDevice = new(ELeave) CDrawEightBppScreenBitmapColor;
|
sl@0
|
95 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
96 |
User::LeaveIfError((static_cast<CDrawEightBppScreenBitmapColor*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
97 |
aScreenInfo.iAddress,
|
sl@0
|
98 |
aScreenInfo.iSize));
|
sl@0
|
99 |
break;
|
sl@0
|
100 |
case EColor4K:
|
sl@0
|
101 |
if (!(depths & KEmulColor4K))
|
sl@0
|
102 |
User::Leave(KErrNotSupported);
|
sl@0
|
103 |
drawDevice = new(ELeave) CDrawTwelveBppScreenBitmap;
|
sl@0
|
104 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
105 |
User::LeaveIfError((static_cast<CDrawTwelveBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
106 |
aScreenInfo.iAddress,
|
sl@0
|
107 |
aScreenInfo.iSize));
|
sl@0
|
108 |
break;
|
sl@0
|
109 |
case EColor64K:
|
sl@0
|
110 |
if (!(depths & KEmulColor64K))
|
sl@0
|
111 |
User::Leave(KErrNotSupported);
|
sl@0
|
112 |
drawDevice = new(ELeave) CDrawSixteenBppScreenBitmap;
|
sl@0
|
113 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
114 |
User::LeaveIfError((static_cast<CDrawSixteenBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
115 |
aScreenInfo.iAddress,
|
sl@0
|
116 |
aScreenInfo.iSize));
|
sl@0
|
117 |
break;
|
sl@0
|
118 |
case EColor16M:
|
sl@0
|
119 |
if (!(depths & KEmulColor16M))
|
sl@0
|
120 |
User::Leave(KErrNotSupported);
|
sl@0
|
121 |
drawDevice = new(ELeave) CDrawTwentyFourBppScreenBitmap;
|
sl@0
|
122 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
123 |
User::LeaveIfError((static_cast<CDrawTwentyFourBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
124 |
aScreenInfo.iAddress,
|
sl@0
|
125 |
aScreenInfo.iSize));
|
sl@0
|
126 |
break;
|
sl@0
|
127 |
case EColor16MU:
|
sl@0
|
128 |
if (!(depths & KEmulColor16M))
|
sl@0
|
129 |
User::Leave(KErrNotSupported);
|
sl@0
|
130 |
drawDevice = new(ELeave) CDrawUTwentyFourBppScreenBitmap;
|
sl@0
|
131 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
132 |
User::LeaveIfError((static_cast<CDrawUTwentyFourBppScreenBitmap*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
133 |
aScreenInfo.iAddress,
|
sl@0
|
134 |
aScreenInfo.iSize));
|
sl@0
|
135 |
break;
|
sl@0
|
136 |
case EColor16MA:
|
sl@0
|
137 |
if (!(depths & KEmulColor16M))
|
sl@0
|
138 |
User::Leave(KErrNotSupported);
|
sl@0
|
139 |
drawDevice = new(ELeave) CDrawThirtyTwoBppScreenBitmapAlpha;
|
sl@0
|
140 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
141 |
User::LeaveIfError((static_cast<CDrawThirtyTwoBppScreenBitmapAlpha*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
142 |
aScreenInfo.iAddress,
|
sl@0
|
143 |
aScreenInfo.iSize));
|
sl@0
|
144 |
break;
|
sl@0
|
145 |
case EColor16MAP:
|
sl@0
|
146 |
if (!(depths & KEmulColor16M))
|
sl@0
|
147 |
User::Leave(KErrNotSupported);
|
sl@0
|
148 |
drawDevice = new(ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM;
|
sl@0
|
149 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
150 |
User::LeaveIfError((static_cast<CDrawThirtyTwoBppScreenBitmapAlphaPM*> (drawDevice)) ->ConstructScreen(aScreenNo,
|
sl@0
|
151 |
aScreenInfo.iAddress,
|
sl@0
|
152 |
aScreenInfo.iSize));
|
sl@0
|
153 |
break;
|
sl@0
|
154 |
default:
|
sl@0
|
155 |
User::Leave(KErrNotSupported);
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
CleanupStack::Pop(); // drawDevice
|
sl@0
|
159 |
return drawDevice;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
/**
|
sl@0
|
163 |
@deprecated Use NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
|
sl@0
|
164 |
*/
|
sl@0
|
165 |
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo,
|
sl@0
|
166 |
TDisplayMode aDispMode)
|
sl@0
|
167 |
{
|
sl@0
|
168 |
__ASSERT_ALWAYS(aInfo.iScreenAddressValid && aInfo.iScreenAddress, Panic(EScreenDriverPanicInvalidWindowHandle));
|
sl@0
|
169 |
TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
|
sl@0
|
170 |
return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
/**
|
sl@0
|
174 |
Creates a new screen device instance, which implements CFbsDrawDevice interface.
|
sl@0
|
175 |
The method has to be implemented for each type of supported video hardware.
|
sl@0
|
176 |
@param aScreenNo Screen number
|
sl@0
|
177 |
@param aDispMode Requested display mode
|
sl@0
|
178 |
@return A pointer to just created screen device, which implements CFbsDrawDevice interface
|
sl@0
|
179 |
@leave KErrNoMemory Not enough memory
|
sl@0
|
180 |
KErrNotSupported The requested screen device type is not supported
|
sl@0
|
181 |
*/
|
sl@0
|
182 |
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
|
sl@0
|
183 |
TDisplayMode aDispMode)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
TInt address = 0, width = 0, height = 0;
|
sl@0
|
186 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address));
|
sl@0
|
187 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
|
sl@0
|
188 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
|
sl@0
|
189 |
__ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
190 |
TScreenInfo screenInfo(reinterpret_cast <TAny*> (address), TSize(width, height));
|
sl@0
|
191 |
return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
/**
|
sl@0
|
195 |
Depending on the current graphics hardware this
|
sl@0
|
196 |
will return one of the 16M video modes defined in
|
sl@0
|
197 |
TDisplayMode, or ENone if a 16M video mode is not supported.
|
sl@0
|
198 |
@see TDisplayMode
|
sl@0
|
199 |
@return a 16M display mode or ENone.
|
sl@0
|
200 |
*/
|
sl@0
|
201 |
EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()
|
sl@0
|
202 |
{
|
sl@0
|
203 |
return EColor16MU;
|
sl@0
|
204 |
}
|