sl@0
|
1 |
// Copyright (c) 2003-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 |
// This module implements the functions that create the screen class depending
|
sl@0
|
15 |
// on the screen type.
|
sl@0
|
16 |
// Include files
|
sl@0
|
17 |
//
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
/********************************************************************/
|
sl@0
|
24 |
#include <bitdraw.h>
|
sl@0
|
25 |
#include "scdraw.h"
|
sl@0
|
26 |
#include <hal.h>
|
sl@0
|
27 |
#include "ScreenInfo.h"
|
sl@0
|
28 |
#include <graphics/gdi/gdiconsts.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
Creates an instance of CFbsDrawDevice class.
|
sl@0
|
32 |
@param aScreenNo Screen number
|
sl@0
|
33 |
@param aDispMode Display mode
|
sl@0
|
34 |
@param aScreenInfo Screen parameters: video memory address and screen size
|
sl@0
|
35 |
@return A pointer to the created CFbsDrawDevice object
|
sl@0
|
36 |
@leave System-wide error code including KErrNoMemory
|
sl@0
|
37 |
@internalComponent
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
|
sl@0
|
40 |
TDisplayMode aDispMode,
|
sl@0
|
41 |
const TScreenInfo& aScreenInfo)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
CFbsDrawDevice* drawDevice = NULL;
|
sl@0
|
44 |
|
sl@0
|
45 |
TInt bpp;
|
sl@0
|
46 |
if(HAL::Get(aScreenNo, HALData::EDisplayMode, bpp) != KErrNone)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
User::Leave(KErrNotSupported);
|
sl@0
|
49 |
}
|
sl@0
|
50 |
if(HAL::Get(aScreenNo, HALData::EDisplayBitsPerPixel, bpp) != KErrNone)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
User::Leave(KErrNotSupported);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
//Switch the display mode, call the construtor of the class defined
|
sl@0
|
56 |
//in the ScmonXX.cpp or SccolXX.cpp file.
|
sl@0
|
57 |
switch(aDispMode)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
case EColor256: // 8 Bpp color mode
|
sl@0
|
60 |
if(bpp == 8)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
drawDevice = new (ELeave) CDrawEightBppScreenBitmapColor;
|
sl@0
|
63 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
64 |
User::LeaveIfError(((CDrawEightBppScreenBitmapColor*)drawDevice)->ConstructScreenL(
|
sl@0
|
65 |
aScreenNo,
|
sl@0
|
66 |
aScreenInfo.iAddress,
|
sl@0
|
67 |
aScreenInfo.iSize));
|
sl@0
|
68 |
}
|
sl@0
|
69 |
else
|
sl@0
|
70 |
{
|
sl@0
|
71 |
User::Leave(KErrNotSupported);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
break;
|
sl@0
|
74 |
|
sl@0
|
75 |
case EColor64K: // 16 Bpp color mode
|
sl@0
|
76 |
if(bpp == 16)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
drawDevice = new (ELeave) CDrawSixteenBppScreenBitmap;
|
sl@0
|
79 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
80 |
User::LeaveIfError(((CDrawSixteenBppScreenBitmap*)drawDevice)->ConstructScreenL(
|
sl@0
|
81 |
aScreenNo,
|
sl@0
|
82 |
aScreenInfo.iAddress,
|
sl@0
|
83 |
aScreenInfo.iSize));
|
sl@0
|
84 |
}
|
sl@0
|
85 |
else
|
sl@0
|
86 |
{
|
sl@0
|
87 |
User::Leave(KErrNotSupported);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
break;
|
sl@0
|
90 |
|
sl@0
|
91 |
case EColor16MU: // 24 unpacked Bpp color mode
|
sl@0
|
92 |
if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes...
|
sl@0
|
93 |
//They are both byte per color component, and both actually have 32 bits per pixel memory use.
|
sl@0
|
94 |
{
|
sl@0
|
95 |
drawDevice = new (ELeave) CDrawUTwentyFourBppScreenBitmap;
|
sl@0
|
96 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
97 |
User::LeaveIfError(((CDrawUTwentyFourBppScreenBitmap*)drawDevice)->ConstructScreenL(
|
sl@0
|
98 |
aScreenNo,
|
sl@0
|
99 |
aScreenInfo.iAddress,
|
sl@0
|
100 |
aScreenInfo.iSize));
|
sl@0
|
101 |
}
|
sl@0
|
102 |
else
|
sl@0
|
103 |
{
|
sl@0
|
104 |
User::Leave(KErrNotSupported);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
break;
|
sl@0
|
107 |
|
sl@0
|
108 |
case EColor16MA: // 32 Bpp color mode
|
sl@0
|
109 |
if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes...
|
sl@0
|
110 |
//They are both byte per color component, and both actually have 32 bits per pixel memory use.
|
sl@0
|
111 |
{
|
sl@0
|
112 |
drawDevice = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlpha;
|
sl@0
|
113 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
114 |
User::LeaveIfError(((CDrawThirtyTwoBppScreenBitmapAlpha*)drawDevice)->ConstructScreenL(
|
sl@0
|
115 |
aScreenNo,
|
sl@0
|
116 |
aScreenInfo.iAddress,
|
sl@0
|
117 |
aScreenInfo.iSize));
|
sl@0
|
118 |
}
|
sl@0
|
119 |
else
|
sl@0
|
120 |
{
|
sl@0
|
121 |
User::Leave(KErrNotSupported);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
break;
|
sl@0
|
124 |
|
sl@0
|
125 |
case EColor16MAP: // 32 Bpp color mode
|
sl@0
|
126 |
if((bpp == 24 || bpp == 32) && aDispMode == CFbsDrawDevice::DisplayMode16M()) //there is some "ambiguity" about 24 and 32 bit modes...
|
sl@0
|
127 |
//They are both byte per color component, and both actually have 32 bits per pixel memory use.
|
sl@0
|
128 |
{
|
sl@0
|
129 |
drawDevice = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM;
|
sl@0
|
130 |
CleanupStack::PushL(drawDevice);
|
sl@0
|
131 |
User::LeaveIfError(((CDrawThirtyTwoBppScreenBitmapAlphaPM*)drawDevice)->ConstructScreenL(
|
sl@0
|
132 |
aScreenNo,
|
sl@0
|
133 |
aScreenInfo.iAddress,
|
sl@0
|
134 |
aScreenInfo.iSize));
|
sl@0
|
135 |
}
|
sl@0
|
136 |
else
|
sl@0
|
137 |
{
|
sl@0
|
138 |
User::Leave(KErrNotSupported);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
break;
|
sl@0
|
141 |
|
sl@0
|
142 |
default:
|
sl@0
|
143 |
User::Leave(KErrNotSupported);
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
CleanupStack::Pop(drawDevice);
|
sl@0
|
147 |
return drawDevice;
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
|
sl@0
|
151 |
/********************************************************************/
|
sl@0
|
152 |
/* Implementation of CFbsDrawDevice class */
|
sl@0
|
153 |
/********************************************************************/
|
sl@0
|
154 |
|
sl@0
|
155 |
/**
|
sl@0
|
156 |
This function calls the correct constructor in function of the display mode.
|
sl@0
|
157 |
@param aInfo, Structure of the LCD info
|
sl@0
|
158 |
@param aDispMode, display mode
|
sl@0
|
159 |
@return A pointer to just created screen device, which implements CFbsDrawDevice interface
|
sl@0
|
160 |
@deprecated Use CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
|
sl@0
|
161 |
*/
|
sl@0
|
162 |
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo, TDisplayMode aDispMode)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
__ASSERT_ALWAYS(aInfo.iScreenAddressValid, Panic(EScreenDriverPanicInvalidWindowHandle));
|
sl@0
|
165 |
TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
|
sl@0
|
166 |
return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
/**
|
sl@0
|
170 |
Creates a new screen device instance, which implements CFbsDrawDevice interface.
|
sl@0
|
171 |
The method has to be implemented for each type of supported video hardware.
|
sl@0
|
172 |
@param aScreenNo Screen number
|
sl@0
|
173 |
@param aDispMode Requested display mode
|
sl@0
|
174 |
@return A pointer to just created screen device, which implements CFbsDrawDevice interface
|
sl@0
|
175 |
@leave KErrNoMemory Not enough memory
|
sl@0
|
176 |
KErrNotSupported The requested screen device type is not supported
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
|
sl@0
|
179 |
TDisplayMode aDispMode)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
TInt address = 0, width = 0, height = 0;
|
sl@0
|
182 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayMemoryAddress, address));
|
sl@0
|
183 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
|
sl@0
|
184 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
|
sl@0
|
185 |
__ASSERT_ALWAYS(width > 0 && height > 0 && address != 0, Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
186 |
TScreenInfo screenInfo(reinterpret_cast <TAny*> (address), TSize(width, height));
|
sl@0
|
187 |
return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
/**
|
sl@0
|
191 |
Depending on the current graphics hardware this
|
sl@0
|
192 |
will return one of the 16M video modes defined in
|
sl@0
|
193 |
TDisplayMode, or ENone if a 16M video mode is not supported.
|
sl@0
|
194 |
@see TDisplayMode
|
sl@0
|
195 |
@return a 16M display mode or ENone.
|
sl@0
|
196 |
*/
|
sl@0
|
197 |
EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()
|
sl@0
|
198 |
{
|
sl@0
|
199 |
// return ENone;
|
sl@0
|
200 |
return EColor16MA;
|
sl@0
|
201 |
}
|