sl@0
|
1 |
// Copyright (c) 2006-2010 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 <hal.h>
|
sl@0
|
26 |
#include "ScreenInfo.h"
|
sl@0
|
27 |
#include "scdraw.h"
|
sl@0
|
28 |
#include "scdraw.inl"
|
sl@0
|
29 |
#include <graphics/gdi/gdiconsts.h>
|
sl@0
|
30 |
#include <graphics/suerror.h>
|
sl@0
|
31 |
/**
|
sl@0
|
32 |
Creates an instance of CFbsDrawDevice class.
|
sl@0
|
33 |
@param aScreenNo Screen number
|
sl@0
|
34 |
@param aDispMode Display mode
|
sl@0
|
35 |
@param aScreenInfo Screen parameters: video memory address and screen size
|
sl@0
|
36 |
@return A pointer to the created CFbsDrawDevice object
|
sl@0
|
37 |
@leave System-wide error code including KErrNoMemory
|
sl@0
|
38 |
@internalComponent
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
static CFbsDrawDevice* CreateInstanceL(TInt aScreenNo,
|
sl@0
|
41 |
TDisplayMode aDispMode,
|
sl@0
|
42 |
const TScreenInfo& aScreenInfo)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
CFbsDrawDevice* drawDevice = NULL;
|
sl@0
|
45 |
|
sl@0
|
46 |
TInt modeCount;
|
sl@0
|
47 |
TInt matchedMode=-1;
|
sl@0
|
48 |
//there is some "ambiguity" about 24 and 32 bit modes...
|
sl@0
|
49 |
//They are both byte per color component, and both actually have 32 bits per pixel memory use.
|
sl@0
|
50 |
//This ambiguity does not exist between 12 and 16 bit modes,
|
sl@0
|
51 |
//because they are distinct color component patterns (x444, 565)
|
sl@0
|
52 |
//but for now 24 and 32 bit modes are considered equivalent here.
|
sl@0
|
53 |
|
sl@0
|
54 |
if (HAL::Get(aScreenNo, HALData::EDisplayNumModes,modeCount)== KErrNone && modeCount>=1)
|
sl@0
|
55 |
{ //If multiple modes are supported then the highest bpp must be found
|
sl@0
|
56 |
|
sl@0
|
57 |
TInt reqBpp= TDisplayModeUtils::NumDisplayModeBitsPerPixel(aDispMode);
|
sl@0
|
58 |
TInt reqBpp2=reqBpp;
|
sl@0
|
59 |
if ( reqBpp==24 || reqBpp==32 ) //Best to be specific here. Who knows how likely is 30 or 64 bpp support?
|
sl@0
|
60 |
{
|
sl@0
|
61 |
reqBpp2=32+24 - reqBpp; //reflect 24<==>32
|
sl@0
|
62 |
//Important compile-time decision embedded here: Only one 32-bit mode is supported
|
sl@0
|
63 |
if(CFbsDrawDevice::DisplayMode16M() != aDispMode)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
User::Leave(KErrNotSupported);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
}
|
sl@0
|
68 |
for (TInt mode=0; mode<modeCount; mode++)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
TInt modeBpp=mode;
|
sl@0
|
71 |
if(HAL::Get(aScreenNo, HALData::EDisplayBitsPerPixel, modeBpp) == KErrNone)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
if (modeBpp==reqBpp || modeBpp==reqBpp2)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
matchedMode=mode;
|
sl@0
|
76 |
break;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
}
|
sl@0
|
79 |
}
|
sl@0
|
80 |
}
|
sl@0
|
81 |
if (matchedMode==-1)
|
sl@0
|
82 |
{ //This is the expected error code
|
sl@0
|
83 |
User::Leave(KErrNotSupported);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
//Switch the display mode, call the constructor of the class defined
|
sl@0
|
86 |
switch(aDispMode)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
/** Monochrome display mode (1 bpp) */
|
sl@0
|
89 |
case EGray2:
|
sl@0
|
90 |
{
|
sl@0
|
91 |
CDrawOneBppScreenBitmap* drawDeviceX = new (ELeave) CDrawOneBppScreenBitmap;
|
sl@0
|
92 |
drawDevice=drawDeviceX;
|
sl@0
|
93 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
94 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
95 |
aScreenNo,
|
sl@0
|
96 |
aScreenInfo.iAddress,
|
sl@0
|
97 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
98 |
}
|
sl@0
|
99 |
break;
|
sl@0
|
100 |
/** Four grayscales display mode (2 bpp) */
|
sl@0
|
101 |
case EGray4:
|
sl@0
|
102 |
{
|
sl@0
|
103 |
CDrawTwoBppScreenBitmap* drawDeviceX = new (ELeave) CDrawTwoBppScreenBitmap;
|
sl@0
|
104 |
drawDevice=drawDeviceX;
|
sl@0
|
105 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
106 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
107 |
aScreenNo,
|
sl@0
|
108 |
aScreenInfo.iAddress,
|
sl@0
|
109 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
110 |
}
|
sl@0
|
111 |
break;
|
sl@0
|
112 |
/** 16 grayscales display mode (4 bpp) */
|
sl@0
|
113 |
case EGray16:
|
sl@0
|
114 |
{
|
sl@0
|
115 |
CDrawFourBppScreenBitmapGray* drawDeviceX = new (ELeave) CDrawFourBppScreenBitmapGray;
|
sl@0
|
116 |
drawDevice=drawDeviceX;
|
sl@0
|
117 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
118 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
119 |
aScreenNo,
|
sl@0
|
120 |
aScreenInfo.iAddress,
|
sl@0
|
121 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
122 |
}
|
sl@0
|
123 |
break;
|
sl@0
|
124 |
/** 256 grayscales display mode (8 bpp) */
|
sl@0
|
125 |
case EGray256:
|
sl@0
|
126 |
{
|
sl@0
|
127 |
CDrawEightBppScreenBitmapGray* drawDeviceX = new (ELeave) CDrawEightBppScreenBitmapGray;
|
sl@0
|
128 |
drawDevice=drawDeviceX;
|
sl@0
|
129 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
130 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
131 |
aScreenNo,
|
sl@0
|
132 |
aScreenInfo.iAddress,
|
sl@0
|
133 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
134 |
}
|
sl@0
|
135 |
break;
|
sl@0
|
136 |
/** Low colour EGA 16 colour display mode (4 bpp) */
|
sl@0
|
137 |
case EColor16:
|
sl@0
|
138 |
{
|
sl@0
|
139 |
CDrawFourBppScreenBitmapColor* drawDeviceX = new (ELeave) CDrawFourBppScreenBitmapColor;
|
sl@0
|
140 |
drawDevice=drawDeviceX;
|
sl@0
|
141 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
142 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
143 |
aScreenNo,
|
sl@0
|
144 |
aScreenInfo.iAddress,
|
sl@0
|
145 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
146 |
}
|
sl@0
|
147 |
break;
|
sl@0
|
148 |
/** 256 colour display mode (8 bpp) */
|
sl@0
|
149 |
case EColor256:
|
sl@0
|
150 |
{
|
sl@0
|
151 |
CDrawEightBppScreenBitmapColor* drawDeviceX = new (ELeave) CDrawEightBppScreenBitmapColor;
|
sl@0
|
152 |
drawDevice=drawDeviceX;
|
sl@0
|
153 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
154 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
155 |
aScreenNo,
|
sl@0
|
156 |
aScreenInfo.iAddress,
|
sl@0
|
157 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
158 |
}
|
sl@0
|
159 |
break;
|
sl@0
|
160 |
/** 4,000 colour display mode (16 bpp) */
|
sl@0
|
161 |
case EColor4K: // 12 Bpp color mode
|
sl@0
|
162 |
{
|
sl@0
|
163 |
CDrawTwelveBppScreenBitmapColor* drawDeviceX = new (ELeave) CDrawTwelveBppScreenBitmapColor;
|
sl@0
|
164 |
drawDevice=drawDeviceX;
|
sl@0
|
165 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
166 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
167 |
aScreenNo,
|
sl@0
|
168 |
aScreenInfo.iAddress,
|
sl@0
|
169 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
170 |
}
|
sl@0
|
171 |
break;
|
sl@0
|
172 |
|
sl@0
|
173 |
case EColor64K: // 16 Bpp color mode
|
sl@0
|
174 |
{
|
sl@0
|
175 |
CDrawSixteenBppScreenBitmap* drawDeviceX = new (ELeave) CDrawSixteenBppScreenBitmap;
|
sl@0
|
176 |
drawDevice=drawDeviceX;
|
sl@0
|
177 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
178 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
179 |
aScreenNo,
|
sl@0
|
180 |
aScreenInfo.iAddress,
|
sl@0
|
181 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
182 |
}
|
sl@0
|
183 |
break;
|
sl@0
|
184 |
case EColor16MU:
|
sl@0
|
185 |
{
|
sl@0
|
186 |
CDrawUTwentyFourBppScreenBitmap* drawDeviceX = new (ELeave) CDrawUTwentyFourBppScreenBitmap;
|
sl@0
|
187 |
drawDevice=drawDeviceX;
|
sl@0
|
188 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
189 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
190 |
aScreenNo,
|
sl@0
|
191 |
aScreenInfo.iAddress,
|
sl@0
|
192 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
193 |
}
|
sl@0
|
194 |
break;
|
sl@0
|
195 |
case EColor16MA:
|
sl@0
|
196 |
{
|
sl@0
|
197 |
CDrawThirtyTwoBppScreenBitmapAlpha* drawDeviceX = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlpha;
|
sl@0
|
198 |
drawDevice=drawDeviceX;
|
sl@0
|
199 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
200 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
201 |
aScreenNo,
|
sl@0
|
202 |
aScreenInfo.iAddress,
|
sl@0
|
203 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
204 |
}
|
sl@0
|
205 |
break;
|
sl@0
|
206 |
case EColor16MAP:
|
sl@0
|
207 |
{
|
sl@0
|
208 |
CDrawThirtyTwoBppScreenBitmapAlphaPM* drawDeviceX = new (ELeave) CDrawThirtyTwoBppScreenBitmapAlphaPM;
|
sl@0
|
209 |
drawDevice=drawDeviceX;
|
sl@0
|
210 |
CleanupStack::PushL(drawDevice) ;
|
sl@0
|
211 |
User::LeaveIfError(drawDeviceX->ConstructScreen(
|
sl@0
|
212 |
aScreenNo,
|
sl@0
|
213 |
aScreenInfo.iAddress,
|
sl@0
|
214 |
aScreenInfo.iSize,matchedMode));
|
sl@0
|
215 |
}
|
sl@0
|
216 |
break;
|
sl@0
|
217 |
default:
|
sl@0
|
218 |
User::Leave(KErrNotSupported);
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
CleanupStack::Pop(drawDevice);
|
sl@0
|
222 |
return drawDevice;
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
|
sl@0
|
226 |
/********************************************************************/
|
sl@0
|
227 |
/* Implementation of CFbsDrawDevice class */
|
sl@0
|
228 |
/********************************************************************/
|
sl@0
|
229 |
|
sl@0
|
230 |
/**
|
sl@0
|
231 |
This function calls the correct constructor in function of the display mode.
|
sl@0
|
232 |
@param aInfo, Structure of the LCD info
|
sl@0
|
233 |
@param aDispMode, display mode
|
sl@0
|
234 |
@return A pointer to just created screen device, which implements CFbsDrawDevice interface
|
sl@0
|
235 |
@deprecated Use CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo, TDisplayMode aDispMode)
|
sl@0
|
236 |
*/
|
sl@0
|
237 |
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TScreenInfoV01 aInfo, TDisplayMode aDispMode)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
__ASSERT_ALWAYS(aInfo.iScreenAddressValid, Panic(EScreenDriverPanicInvalidWindowHandle));
|
sl@0
|
240 |
TScreenInfo screenInfo(aInfo.iScreenAddress, aInfo.iScreenSize);
|
sl@0
|
241 |
return ::CreateInstanceL(KDefaultScreenNo, aDispMode, screenInfo);
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
|
sl@0
|
245 |
|
sl@0
|
246 |
/**
|
sl@0
|
247 |
Creates a new screen device instance, which implements CFbsDrawDevice interface.
|
sl@0
|
248 |
The method has to be implemented for each type of supported video hardware.
|
sl@0
|
249 |
@param aScreenNo Screen number
|
sl@0
|
250 |
@param aDispMode Requested display mode
|
sl@0
|
251 |
@return A pointer to just created screen device, which implements CFbsDrawDevice interface
|
sl@0
|
252 |
@leave KErrNoMemory Not enough memory
|
sl@0
|
253 |
KErrNotSupported The requested screen device type is not supported
|
sl@0
|
254 |
*/
|
sl@0
|
255 |
EXPORT_C CFbsDrawDevice* CFbsDrawDevice::NewScreenDeviceL(TInt aScreenNo,
|
sl@0
|
256 |
TDisplayMode aDispMode)
|
sl@0
|
257 |
{
|
sl@0
|
258 |
TInt width = 0, height = 0;
|
sl@0
|
259 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayXPixels, width));
|
sl@0
|
260 |
User::LeaveIfError(HAL::Get(aScreenNo, HALData::EDisplayYPixels, height));
|
sl@0
|
261 |
__ASSERT_ALWAYS(width > 0 && height > 0, Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
262 |
|
sl@0
|
263 |
TUint8* address = 0;
|
sl@0
|
264 |
|
sl@0
|
265 |
TScreenInfo screenInfo(address, TSize(width, height));
|
sl@0
|
266 |
return ::CreateInstanceL(aScreenNo, aDispMode, screenInfo);
|
sl@0
|
267 |
}
|
sl@0
|
268 |
|
sl@0
|
269 |
/**
|
sl@0
|
270 |
Depending on the current graphics hardware this
|
sl@0
|
271 |
will return one of the 16M video modes defined in
|
sl@0
|
272 |
TDisplayMode, or ENone if a 16M video mode is not supported.
|
sl@0
|
273 |
The method has to be implemented on all hardware platforms.
|
sl@0
|
274 |
@return a 16M display mode or ENone.
|
sl@0
|
275 |
ENone - it means that current hardware doesn't have 16M color mode.
|
sl@0
|
276 |
*/
|
sl@0
|
277 |
EXPORT_C TDisplayMode CFbsDrawDevice::DisplayMode16M()
|
sl@0
|
278 |
{
|
sl@0
|
279 |
return EColor16MA;
|
sl@0
|
280 |
}
|
sl@0
|
281 |
|
sl@0
|
282 |
|
sl@0
|
283 |
/**
|
sl@0
|
284 |
Complete construction of the helper object.
|
sl@0
|
285 |
@param aScreenNo The screen number, starting from 0.
|
sl@0
|
286 |
@param aPixelFormat Pixel format UID or 0 for default based on bpp
|
sl@0
|
287 |
@return KErrNone or a system wide error value.
|
sl@0
|
288 |
*/
|
sl@0
|
289 |
TInt CScreenDeviceHelper::Construct(TInt aScreenNo, TUidPixelFormat aPixelFormat, TUint aHalMode)
|
sl@0
|
290 |
{
|
sl@0
|
291 |
iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField] = aScreenNo; // Screen number
|
sl@0
|
292 |
iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] = aHalMode; // Rotation and hal mode index
|
sl@0
|
293 |
iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::ETypeGuidField] = aPixelFormat; //May be zero for non-GCE modes
|
sl@0
|
294 |
iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::ETypeClassField]
|
sl@0
|
295 |
= ((TUint32)(TSurfaceId::EScreenSurface) << TSurfaceId::TScreenSurfaceUsage::ETypeClassShift); // Type
|
sl@0
|
296 |
iAssignedOrientation = EDeviceOrientationNormal; // Actual rotation is held seperately from surface ID
|
sl@0
|
297 |
|
sl@0
|
298 |
TInt val = 0;
|
sl@0
|
299 |
iHasChunk = EFalse;
|
sl@0
|
300 |
TInt ret = HAL::Get(aScreenNo,HALData::EDisplayMemoryHandle,val);
|
sl@0
|
301 |
if (ret == KErrNone)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
__ASSERT_DEBUG(val != 0, Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
304 |
RChunk chunk;
|
sl@0
|
305 |
ret = chunk.SetReturnedHandle(val);
|
sl@0
|
306 |
if (ret != KErrNone)
|
sl@0
|
307 |
{
|
sl@0
|
308 |
return ret;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
iChunk = chunk;
|
sl@0
|
311 |
ret = iChunk.Duplicate(RThread(), EOwnerProcess);
|
sl@0
|
312 |
// Close before checking for errors, as we don't want to leave the
|
sl@0
|
313 |
// temporary chunk handle floating about.
|
sl@0
|
314 |
chunk.Close();
|
sl@0
|
315 |
if (ret != KErrNone)
|
sl@0
|
316 |
{
|
sl@0
|
317 |
return ret;
|
sl@0
|
318 |
}
|
sl@0
|
319 |
iHasChunk = ETrue;
|
sl@0
|
320 |
}
|
sl@0
|
321 |
// KErrNotSupported is returned if we can't get the Handle because it's not a driver
|
sl@0
|
322 |
// that supports the concept. We don't return that error, since it's perfectly valid
|
sl@0
|
323 |
// to not support this.
|
sl@0
|
324 |
else if (ret != KErrNotSupported)
|
sl@0
|
325 |
{
|
sl@0
|
326 |
return ret;
|
sl@0
|
327 |
}
|
sl@0
|
328 |
return iSurfaceUpdateSession.Connect();
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
CScreenDeviceHelper::~CScreenDeviceHelper()
|
sl@0
|
332 |
{
|
sl@0
|
333 |
|
sl@0
|
334 |
iSurfaceUpdateSession.Close();
|
sl@0
|
335 |
iChunk.Close();
|
sl@0
|
336 |
}
|
sl@0
|
337 |
|
sl@0
|
338 |
void CScreenDeviceHelper::NotifyWhenAvailable(TRequestStatus& aStatus)
|
sl@0
|
339 |
{
|
sl@0
|
340 |
iSurfaceUpdateSession.NotifyWhenAvailable(aStatus);
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
void CScreenDeviceHelper::CancelUpdateNotification()
|
sl@0
|
344 |
{
|
sl@0
|
345 |
iSurfaceUpdateSession.CancelAllUpdateNotifications();
|
sl@0
|
346 |
}
|
sl@0
|
347 |
|
sl@0
|
348 |
/**
|
sl@0
|
349 |
Implementation of corresponding function in CDrawDevice, utilizing a tracked
|
sl@0
|
350 |
update region. Updates the screen from the surface, if the update region is
|
sl@0
|
351 |
not empty.
|
sl@0
|
352 |
*/
|
sl@0
|
353 |
void CScreenDeviceHelper::Update()
|
sl@0
|
354 |
{
|
sl@0
|
355 |
TRequestStatus updateComplete = KRequestPending;
|
sl@0
|
356 |
Update(updateComplete);
|
sl@0
|
357 |
User::WaitForRequest(updateComplete);
|
sl@0
|
358 |
}
|
sl@0
|
359 |
|
sl@0
|
360 |
void CScreenDeviceHelper::Update(TRequestStatus& aStatus)
|
sl@0
|
361 |
{
|
sl@0
|
362 |
if (!iUpdateRegion.IsEmpty())
|
sl@0
|
363 |
{
|
sl@0
|
364 |
iSurfaceUpdateSession.NotifyWhenAvailable(aStatus);
|
sl@0
|
365 |
iSurfaceUpdateSession.SubmitUpdate(KAllScreens, iSurface, 0, &iUpdateRegion);
|
sl@0
|
366 |
iUpdateRegion.Clear();
|
sl@0
|
367 |
}
|
sl@0
|
368 |
else
|
sl@0
|
369 |
{
|
sl@0
|
370 |
TRequestStatus* pComplete=&aStatus;
|
sl@0
|
371 |
User::RequestComplete(pComplete,KErrNone);
|
sl@0
|
372 |
}
|
sl@0
|
373 |
}
|
sl@0
|
374 |
|
sl@0
|
375 |
|
sl@0
|
376 |
/**
|
sl@0
|
377 |
Implementation of corresponding function in CDrawDevice, utilizing a tracked
|
sl@0
|
378 |
update region. Adds the given rectangle to the update region.
|
sl@0
|
379 |
@param aRect Rectangle to be added to the update region.
|
sl@0
|
380 |
*/
|
sl@0
|
381 |
void CScreenDeviceHelper::UpdateRegion(const TRect& aRect)
|
sl@0
|
382 |
{
|
sl@0
|
383 |
if (aRect.IsEmpty())
|
sl@0
|
384 |
{
|
sl@0
|
385 |
// Adding an empty rectangle should have no effect.
|
sl@0
|
386 |
return;
|
sl@0
|
387 |
}
|
sl@0
|
388 |
|
sl@0
|
389 |
if (iUpdateRegion.CheckError())
|
sl@0
|
390 |
{
|
sl@0
|
391 |
// Try to ensure the region doesn't keep an error forever.
|
sl@0
|
392 |
iUpdateRegion.Clear();
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
TRect bounds(iUpdateRegion.BoundingRect());
|
sl@0
|
396 |
iUpdateRegion.AddRect(aRect);
|
sl@0
|
397 |
|
sl@0
|
398 |
// If the region fills up, start again with the old bounding box plus this
|
sl@0
|
399 |
// rectangle.
|
sl@0
|
400 |
if (iUpdateRegion.CheckError())
|
sl@0
|
401 |
{
|
sl@0
|
402 |
iUpdateRegion.Clear();
|
sl@0
|
403 |
iUpdateRegion.AddRect(bounds);
|
sl@0
|
404 |
iUpdateRegion.AddRect(aRect);
|
sl@0
|
405 |
}
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
/**
|
sl@0
|
409 |
Reset the update region to be empty without submitting any outstanding updates.
|
sl@0
|
410 |
*/
|
sl@0
|
411 |
void CScreenDeviceHelper::ResetUpdateRegion()
|
sl@0
|
412 |
{
|
sl@0
|
413 |
iUpdateRegion.Clear();
|
sl@0
|
414 |
}
|
sl@0
|
415 |
|
sl@0
|
416 |
/**
|
sl@0
|
417 |
This function returns the current surface in use for this screen.
|
sl@0
|
418 |
@param aSurface The identifier to be updated with the current screen surface.
|
sl@0
|
419 |
*/
|
sl@0
|
420 |
void CScreenDeviceHelper::GetSurface(TSurfaceId& aSid) const
|
sl@0
|
421 |
{
|
sl@0
|
422 |
aSid = iSurface;
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
/**
|
sl@0
|
426 |
This function is used to request the device orientations supported by the
|
sl@0
|
427 |
screen device.
|
sl@0
|
428 |
@return A bitwise combination of one or more TDeviceOrientation enumerated
|
sl@0
|
429 |
values indicating the device orientations that are supported by this device.
|
sl@0
|
430 |
*/
|
sl@0
|
431 |
TUint CScreenDeviceHelper::DeviceOrientationsAvailable(const TSize& aScreenSize) const
|
sl@0
|
432 |
{
|
sl@0
|
433 |
//All that can be reported here is what the CScreenDevice can support via HAL
|
sl@0
|
434 |
//With generic driver, the runtime can be further restricted by the GCE
|
sl@0
|
435 |
if ( aScreenSize.iWidth && aScreenSize.iWidth==aScreenSize.iHeight )
|
sl@0
|
436 |
{
|
sl@0
|
437 |
return EDeviceOrientationNormal | EDeviceOrientation90CW |
|
sl@0
|
438 |
EDeviceOrientation180 | EDeviceOrientation270CW;
|
sl@0
|
439 |
}
|
sl@0
|
440 |
//Query base HAL for rotated view support
|
sl@0
|
441 |
TInt offset1=iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField]|TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
|
sl@0
|
442 |
if ( HAL::Get(ScreenNumber(), HALData::EDisplayOffsetBetweenLines, offset1)==KErrNone
|
sl@0
|
443 |
&& offset1!=0)
|
sl@0
|
444 |
{
|
sl@0
|
445 |
return EDeviceOrientationNormal | EDeviceOrientation90CW |
|
sl@0
|
446 |
EDeviceOrientation180 | EDeviceOrientation270CW;
|
sl@0
|
447 |
}
|
sl@0
|
448 |
else
|
sl@0
|
449 |
return EDeviceOrientationNormal | EDeviceOrientation180;
|
sl@0
|
450 |
}
|
sl@0
|
451 |
|
sl@0
|
452 |
/**
|
sl@0
|
453 |
This function selects the surface and device buffer to use in the screen
|
sl@0
|
454 |
driver for this screen. Normal and 180° rotations will generally use the same
|
sl@0
|
455 |
surface, while 90° and 270° will use another. The surfaces may have different
|
sl@0
|
456 |
width, height, stride and surface ID, so functions that make use of any of
|
sl@0
|
457 |
these may be affected after a change in surface orientation, and the return
|
sl@0
|
458 |
value should be checked for this reason.
|
sl@0
|
459 |
|
sl@0
|
460 |
This call does not change the way rendering is performed, but may operate on
|
sl@0
|
461 |
the underlying memory using a new shape. The call does not change the display
|
sl@0
|
462 |
controller's settings, as this is handled via the GCE. All this changes are the
|
sl@0
|
463 |
internal attributes of the screen device and driver objects. A CFbsBitGc object
|
sl@0
|
464 |
activated on the device should be reactivated, to update its own attributes, or
|
sl@0
|
465 |
drawing may be corrupted.
|
sl@0
|
466 |
|
sl@0
|
467 |
Note: while TDeviceOrientation values do not directly correspond to
|
sl@0
|
468 |
CFbsBitGc::TGraphicsOrientation values, and cannot be used interchangeably, it
|
sl@0
|
469 |
is simple to generate the former from the latter using the left-shift operator
|
sl@0
|
470 |
(i.e. device == (1 << graphics)). In particular a device orientation of
|
sl@0
|
471 |
90 degrees clockwise is equivalent to a content orientation of 90 degrees anti-
|
sl@0
|
472 |
clockwise, which is what TGraphicsOrientation refers to for the equivalent
|
sl@0
|
473 |
setting. The letters "CW" in the TDeviceOrientation enumeration refer
|
sl@0
|
474 |
to a clockwise device rotation, so EDeviceOrientation90CW is a 90 degree
|
sl@0
|
475 |
clockwise rotation of the device.
|
sl@0
|
476 |
|
sl@0
|
477 |
@param aOrientation The new device orientation, relative to the normal physical
|
sl@0
|
478 |
screen orientation.
|
sl@0
|
479 |
@param aNewSize The new pixel dimensions of the surface to be used.
|
sl@0
|
480 |
@return ETrue is returned if any of the surface, width, height or stride
|
sl@0
|
481 |
attributes of the screen device have changed as a result of the call or EFalse
|
sl@0
|
482 |
if none of the attributes have changed.
|
sl@0
|
483 |
*/
|
sl@0
|
484 |
TBool CScreenDeviceHelper::SetDeviceOrientation(TDeviceOrientation aOrientation, TSize& aNewSize)
|
sl@0
|
485 |
{
|
sl@0
|
486 |
// Check only one orientation bit is set
|
sl@0
|
487 |
if (((TInt)aOrientation - 1) & aOrientation)
|
sl@0
|
488 |
{
|
sl@0
|
489 |
Panic(EScreenDriverPanicInvalidParameter);
|
sl@0
|
490 |
}
|
sl@0
|
491 |
|
sl@0
|
492 |
// Check the orientation is supported
|
sl@0
|
493 |
if ((DeviceOrientationsAvailable(aNewSize) & aOrientation) == 0)
|
sl@0
|
494 |
{
|
sl@0
|
495 |
Panic(EScreenDriverPanicInvalidParameter);
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
iAssignedOrientation=aOrientation;
|
sl@0
|
499 |
|
sl@0
|
500 |
return SetDeviceFlipMode(ConvertFlip(aOrientation),aNewSize);
|
sl@0
|
501 |
}
|
sl@0
|
502 |
/** Sets or clears the flipped flag indicating that the width and height have been swapped for a +/-90 deg rotation
|
sl@0
|
503 |
* Rotation is not required for square displays unless the Hal wants one.
|
sl@0
|
504 |
**/
|
sl@0
|
505 |
TBool CScreenDeviceHelper::SetDeviceFlipMode(TBool aFlip, TSize& aNewSize)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
//This is now a private method that doesn't validate aFlip
|
sl@0
|
508 |
TInt newFlipMode= iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField];
|
sl@0
|
509 |
if (aFlip)
|
sl@0
|
510 |
{
|
sl@0
|
511 |
newFlipMode|=TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
|
sl@0
|
512 |
}
|
sl@0
|
513 |
else
|
sl@0
|
514 |
{
|
sl@0
|
515 |
newFlipMode&=~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
|
sl@0
|
516 |
}
|
sl@0
|
517 |
if (newFlipMode == iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField])
|
sl@0
|
518 |
{
|
sl@0
|
519 |
// No change to mode requested.
|
sl@0
|
520 |
return EFalse;
|
sl@0
|
521 |
}
|
sl@0
|
522 |
TInt err=0;
|
sl@0
|
523 |
err|=HAL::Get(ScreenNumber(), HALData::EDisplayXPixels, aNewSize.iWidth);
|
sl@0
|
524 |
err|=HAL::Get(ScreenNumber(), HALData::EDisplayYPixels, aNewSize.iHeight);
|
sl@0
|
525 |
__ASSERT_ALWAYS(err==KErrNone,Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
526 |
if (aNewSize.iWidth==aNewSize.iHeight)
|
sl@0
|
527 |
{ //Attempt optimisation to not flip if the screen is square, so avoid recomposition.
|
sl@0
|
528 |
TInt stride1=iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField];
|
sl@0
|
529 |
TInt stride2=stride1^TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
|
sl@0
|
530 |
TInt offset1=stride1;
|
sl@0
|
531 |
TInt offset2=stride2;
|
sl@0
|
532 |
//Does the rotated mode have any other attributes that differ?
|
sl@0
|
533 |
//It is just about possible to imagine that the rotated display
|
sl@0
|
534 |
//wants to use a different setting for the flipped legacy buffer for optimisation purposes.
|
sl@0
|
535 |
err|=HAL::Get(ScreenNumber(), HALData::EDisplayOffsetToFirstPixel, offset1);
|
sl@0
|
536 |
err|=HAL::Get(ScreenNumber(), HALData::EDisplayOffsetBetweenLines, stride1);
|
sl@0
|
537 |
//The existing mode settings should not fail... we are already in this mode!
|
sl@0
|
538 |
__ASSERT_ALWAYS(err==KErrNone,Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
539 |
|
sl@0
|
540 |
TInt rotatedErr = HAL::Get(ScreenNumber(), HALData::EDisplayOffsetToFirstPixel, offset2);
|
sl@0
|
541 |
rotatedErr |= HAL::Get(ScreenNumber(), HALData::EDisplayOffsetBetweenLines, stride2);
|
sl@0
|
542 |
//The HAL may indicate rotation is not required by failing to return data or returning the same data
|
sl@0
|
543 |
if ( rotatedErr!=KErrNone || stride2==0 ) //Offset can legitimately be zero.
|
sl@0
|
544 |
{
|
sl@0
|
545 |
// No change to mode supported.
|
sl@0
|
546 |
return EFalse;
|
sl@0
|
547 |
}
|
sl@0
|
548 |
if ( stride1==stride2 && offset1==offset2 )
|
sl@0
|
549 |
{
|
sl@0
|
550 |
// No change to mode needed.
|
sl@0
|
551 |
return EFalse;
|
sl@0
|
552 |
}
|
sl@0
|
553 |
}
|
sl@0
|
554 |
|
sl@0
|
555 |
iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] = newFlipMode;
|
sl@0
|
556 |
if (aFlip)
|
sl@0
|
557 |
{
|
sl@0
|
558 |
// Swap width and height in the alternate orientation.
|
sl@0
|
559 |
aNewSize.SetSize(aNewSize.iHeight, aNewSize.iWidth);
|
sl@0
|
560 |
}
|
sl@0
|
561 |
return ETrue;
|
sl@0
|
562 |
}
|
sl@0
|
563 |
/** Returns the stride for the given mode.
|
sl@0
|
564 |
* This method must not panic if it should fail!
|
sl@0
|
565 |
**/
|
sl@0
|
566 |
TUint CScreenDeviceHelper::BytesPerScanline() const
|
sl@0
|
567 |
{
|
sl@0
|
568 |
TInt linepitchInBytes = iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField];
|
sl@0
|
569 |
TInt ret = HAL::Get(ScreenNumber(),HALData::EDisplayOffsetBetweenLines,linepitchInBytes);
|
sl@0
|
570 |
if (ret!=KErrNone)
|
sl@0
|
571 |
{
|
sl@0
|
572 |
return 0;
|
sl@0
|
573 |
}
|
sl@0
|
574 |
return linepitchInBytes ;
|
sl@0
|
575 |
}
|
sl@0
|
576 |
/** Returns the address for the image data
|
sl@0
|
577 |
* This method must not panic if it should fail!
|
sl@0
|
578 |
**/
|
sl@0
|
579 |
void* CScreenDeviceHelper::AddressFirstPixel() const
|
sl@0
|
580 |
{
|
sl@0
|
581 |
TInt bufferStartAddress = iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField];
|
sl@0
|
582 |
TInt ret = KErrNone;
|
sl@0
|
583 |
if (iHasChunk)
|
sl@0
|
584 |
{
|
sl@0
|
585 |
// The "chunk" way to do this is to get the handle of the chunk, and then the base address of the
|
sl@0
|
586 |
// chunk itself.
|
sl@0
|
587 |
bufferStartAddress = (TInt)iChunk.Base();
|
sl@0
|
588 |
}
|
sl@0
|
589 |
else
|
sl@0
|
590 |
{
|
sl@0
|
591 |
// Chunk not supported, use older HAL call to get the buffer address.
|
sl@0
|
592 |
ret = HAL::Get(ScreenNumber(),HALData::EDisplayMemoryAddress,bufferStartAddress);
|
sl@0
|
593 |
if (ret!=KErrNone)
|
sl@0
|
594 |
{
|
sl@0
|
595 |
return 0;
|
sl@0
|
596 |
}
|
sl@0
|
597 |
}
|
sl@0
|
598 |
TInt bufferOffsetFirstPixel = iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField];
|
sl@0
|
599 |
ret = HAL::Get(ScreenNumber(),HALData::EDisplayOffsetToFirstPixel,bufferOffsetFirstPixel);
|
sl@0
|
600 |
if (ret!=KErrNone)
|
sl@0
|
601 |
{
|
sl@0
|
602 |
return 0;
|
sl@0
|
603 |
}
|
sl@0
|
604 |
return (void*)(bufferStartAddress+bufferOffsetFirstPixel);
|
sl@0
|
605 |
}
|
sl@0
|
606 |
|
sl@0
|
607 |
/**
|
sl@0
|
608 |
Returns the current device width/height flip state of this surface, representing a +/-90 deg rotation.
|
sl@0
|
609 |
**/
|
sl@0
|
610 |
TBool CScreenDeviceHelper::DeviceFlipped() const
|
sl@0
|
611 |
{
|
sl@0
|
612 |
return (iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] & TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag) != 0; //!=0 forces true --> 1
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|
sl@0
|
615 |
|
sl@0
|
616 |
/**
|
sl@0
|
617 |
Returns the current device orientation.
|
sl@0
|
618 |
*/
|
sl@0
|
619 |
TDeviceOrientation CScreenDeviceHelper::DeviceOrientation() const
|
sl@0
|
620 |
{
|
sl@0
|
621 |
return iAssignedOrientation;
|
sl@0
|
622 |
}
|
sl@0
|
623 |
/** Returns an accurate scaling factor between twips and pixels in width.
|
sl@0
|
624 |
|
sl@0
|
625 |
**/
|
sl@0
|
626 |
TInt CScreenDeviceHelper::HorzTwipsPerThousandPixels(const TSize& aPixels)const
|
sl@0
|
627 |
{
|
sl@0
|
628 |
__ASSERT_DEBUG(aPixels.iWidth, Panic(EScreenDriverPanicInvalidSize));
|
sl@0
|
629 |
|
sl@0
|
630 |
TInt width = 0;
|
sl@0
|
631 |
TInt r = HAL::Get(ScreenNumber(), SecondIfFlipped(HAL::EDisplayXTwips,HAL::EDisplayYTwips), width);
|
sl@0
|
632 |
__ASSERT_DEBUG(r==KErrNone && width!=0, Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
633 |
|
sl@0
|
634 |
return (width * 1000) / aPixels.iWidth;
|
sl@0
|
635 |
}
|
sl@0
|
636 |
/** Returns an accurate scaling factor between twips and pixels in height.
|
sl@0
|
637 |
**/
|
sl@0
|
638 |
TInt CScreenDeviceHelper::VertTwipsPerThousandPixels(const TSize& aPixels)const
|
sl@0
|
639 |
{
|
sl@0
|
640 |
__ASSERT_DEBUG(aPixels.iHeight, Panic(EScreenDriverPanicInvalidSize));
|
sl@0
|
641 |
|
sl@0
|
642 |
TInt height = 0;
|
sl@0
|
643 |
TInt r = HAL::Get(ScreenNumber(), SecondIfFlipped(HAL::EDisplayYTwips,HAL::EDisplayXTwips), height);
|
sl@0
|
644 |
__ASSERT_DEBUG(r==KErrNone && height!=0, Panic(EScreenDriverPanicInvalidHalValue));
|
sl@0
|
645 |
|
sl@0
|
646 |
return (height * 1000) / aPixels.iHeight;
|
sl@0
|
647 |
}
|
sl@0
|
648 |
|
sl@0
|
649 |
|