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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <hal.h>
|
sl@0
|
17 |
#include <fbs.h>
|
sl@0
|
18 |
#include <bitbase.h>
|
sl@0
|
19 |
#include <bitdev.h>
|
sl@0
|
20 |
#include <bitdraw.h>
|
sl@0
|
21 |
#include <bitdrawscaling.h>
|
sl@0
|
22 |
#include <bitdraworigin.h>
|
sl@0
|
23 |
#include <bitdrawinterfaceid.h>
|
sl@0
|
24 |
#include "BITPANIC.H"
|
sl@0
|
25 |
#include <bmalphablend.h>
|
sl@0
|
26 |
#include <graphics/gdi/gdiconsts.h>
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
#if defined(SYMBIAN_GRAPHICS_GCE)
|
sl@0
|
30 |
#include <bitdrawsurface.h>
|
sl@0
|
31 |
#endif
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
@param aScreenNo The screen number. If the device has a support for only one screen, its
|
sl@0
|
35 |
number is 0.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
CFbsScreenDevice::CFbsScreenDevice(TInt aScreenNo):
|
sl@0
|
38 |
CFbsDevice(),
|
sl@0
|
39 |
iScreenNo(aScreenNo)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
/** Creates a new CFbsScreenDevice object.
|
sl@0
|
45 |
|
sl@0
|
46 |
@param aLibname Not used.
|
sl@0
|
47 |
@param aDispMode The display mode of the device.
|
sl@0
|
48 |
@return The newly created FBSERV screen device. */
|
sl@0
|
49 |
EXPORT_C CFbsScreenDevice* CFbsScreenDevice::NewL(const TDesC& /*aLibname*/,
|
sl@0
|
50 |
TDisplayMode aDispMode)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
return CFbsScreenDevice::NewL(KDefaultScreenNo, aDispMode);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
/** Creates a new CFbsScreenDevice object.
|
sl@0
|
56 |
|
sl@0
|
57 |
@param aLibname Not used.
|
sl@0
|
58 |
@param aDispMode The display mode of the device.
|
sl@0
|
59 |
@param aWhite Not used.
|
sl@0
|
60 |
@return The newly created font and bitmap server screen device.
|
sl@0
|
61 |
@deprecated Use two param version instead. */
|
sl@0
|
62 |
EXPORT_C CFbsScreenDevice* CFbsScreenDevice::NewL(const TDesC& /*aLibname*/,
|
sl@0
|
63 |
TDisplayMode aDispMode,
|
sl@0
|
64 |
TRgb /*aWhite*/)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
return CFbsScreenDevice::NewL(KDefaultScreenNo, aDispMode);
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
/**
|
sl@0
|
70 |
Creates a new CFbsScreenDevice object.
|
sl@0
|
71 |
@param aScreenNo The screen number. If the device has a support for only one screen, its
|
sl@0
|
72 |
number is 0.
|
sl@0
|
73 |
@param aDispMode The display mode of the device.
|
sl@0
|
74 |
@return The newly created FBSERV screen device.
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
EXPORT_C CFbsScreenDevice* CFbsScreenDevice::NewL(TInt aScreenNo, TDisplayMode aDispMode)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
CFbsScreenDevice* self = new (ELeave) CFbsScreenDevice(aScreenNo);
|
sl@0
|
79 |
CleanupStack::PushL(self);
|
sl@0
|
80 |
self->ConstructL(aScreenNo, aDispMode);
|
sl@0
|
81 |
CleanupStack::Pop(); // self
|
sl@0
|
82 |
return self;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
/** Frees all resources owned by the object prior to its destruction. */
|
sl@0
|
86 |
EXPORT_C CFbsScreenDevice::~CFbsScreenDevice()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
void CFbsScreenDevice::ConstructL(TInt aScreenNo, TDisplayMode aDispMode)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDispMode);
|
sl@0
|
93 |
iScreenDevice = ETrue;
|
sl@0
|
94 |
iTypefaceStore = CFbsTypefaceStore::NewL(this);
|
sl@0
|
95 |
if(aDispMode != EGray4) // Flicker-free blitting not enabled under EGray4 because it messes up the EGray16-emulating dithering
|
sl@0
|
96 |
{
|
sl@0
|
97 |
TInt scanLineBytes = iDrawDevice->ScanLineBytes();
|
sl@0
|
98 |
const TSize screenSize = SizeInPixels();
|
sl@0
|
99 |
if(screenSize.iHeight > screenSize.iWidth)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
scanLineBytes = scanLineBytes * screenSize.iHeight / screenSize.iWidth;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
iBitBltMaskedBuffer = new(ELeave) TUint8[scanLineBytes * 2];
|
sl@0
|
104 |
}
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
|
sl@0
|
108 |
/** Copies a scanline into a buffer.
|
sl@0
|
109 |
|
sl@0
|
110 |
This implements the pure virtual function
|
sl@0
|
111 |
CBitmapDevice::GetScanLine(). */
|
sl@0
|
112 |
EXPORT_C void CFbsScreenDevice::GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,
|
sl@0
|
113 |
TInt aLength,TDisplayMode aDispMode) const
|
sl@0
|
114 |
{
|
sl@0
|
115 |
if (!iDrawDevice)
|
sl@0
|
116 |
return;
|
sl@0
|
117 |
|
sl@0
|
118 |
((CFbsScreenDevice*)this)->DoGetScanLine(aBuf,aStartPixel,aLength,aDispMode);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
/** Gets the RGB colour of an individual pixel on a bitmapped graphics
|
sl@0
|
123 |
device.
|
sl@0
|
124 |
|
sl@0
|
125 |
This implements the pure virtual function
|
sl@0
|
126 |
CBitmapDevice::GetPixel(). */
|
sl@0
|
127 |
EXPORT_C void CFbsScreenDevice::GetPixel(TRgb& aColor,const TPoint& aPoint) const
|
sl@0
|
128 |
{
|
sl@0
|
129 |
if (!iDrawDevice)
|
sl@0
|
130 |
return;
|
sl@0
|
131 |
|
sl@0
|
132 |
TRect deviceRect;
|
sl@0
|
133 |
iDrawDevice->GetDrawRect(deviceRect);
|
sl@0
|
134 |
if (!deviceRect.Contains(aPoint))
|
sl@0
|
135 |
return;
|
sl@0
|
136 |
|
sl@0
|
137 |
aColor = iDrawDevice->ReadPixel(aPoint.iX,aPoint.iY);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
/** Converts a horizontal dimension from pixels to twips.
|
sl@0
|
142 |
|
sl@0
|
143 |
This implements the pure virtual function
|
sl@0
|
144 |
MGraphicsDeviceMap::HorizontalPixelsToTwips(). */
|
sl@0
|
145 |
EXPORT_C TInt CFbsScreenDevice::HorizontalPixelsToTwips(TInt aPixels) const
|
sl@0
|
146 |
{
|
sl@0
|
147 |
TInt64 pixels=aPixels;
|
sl@0
|
148 |
pixels=(iDrawDevice->HorzTwipsPerThousandPixels() * pixels + 500) / 1000;
|
sl@0
|
149 |
return I64INT(pixels);
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
|
sl@0
|
153 |
/** Converts a vertical dimension from pixels to twips.
|
sl@0
|
154 |
|
sl@0
|
155 |
This implements the pure virtual function
|
sl@0
|
156 |
MGraphicsDeviceMap::VerticalPixelsToTwips(). */
|
sl@0
|
157 |
EXPORT_C TInt CFbsScreenDevice::VerticalPixelsToTwips(TInt aPixels) const
|
sl@0
|
158 |
{
|
sl@0
|
159 |
TInt64 pixels=aPixels;
|
sl@0
|
160 |
pixels=(iDrawDevice->VertTwipsPerThousandPixels() * pixels + 500) / 1000;
|
sl@0
|
161 |
return I64INT(pixels);
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
|
sl@0
|
165 |
/**
|
sl@0
|
166 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
167 |
Calling this method has no effect.
|
sl@0
|
168 |
@deprecated
|
sl@0
|
169 |
*/
|
sl@0
|
170 |
EXPORT_C void CFbsScreenDevice::DrawSpriteBegin()
|
sl@0
|
171 |
{
|
sl@0
|
172 |
}
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
177 |
Calling this method has no effect.
|
sl@0
|
178 |
@deprecated
|
sl@0
|
179 |
*/
|
sl@0
|
180 |
EXPORT_C void CFbsScreenDevice::DrawSpriteEnd()
|
sl@0
|
181 |
{
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
|
sl@0
|
185 |
/**
|
sl@0
|
186 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
187 |
Calling this method has no effect.
|
sl@0
|
188 |
|
sl@0
|
189 |
@return NULL.
|
sl@0
|
190 |
@deprecated
|
sl@0
|
191 |
*/
|
sl@0
|
192 |
EXPORT_C TSpriteBase* CFbsScreenDevice::HideSprite() const
|
sl@0
|
193 |
{
|
sl@0
|
194 |
return NULL;
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
/**
|
sl@0
|
199 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
200 |
Calling this method has no effect.
|
sl@0
|
201 |
|
sl@0
|
202 |
@param aRect Ignored.
|
sl@0
|
203 |
@param aClippingRegion Ignored.
|
sl@0
|
204 |
@return NULL.
|
sl@0
|
205 |
@deprecated
|
sl@0
|
206 |
*/
|
sl@0
|
207 |
EXPORT_C TSpriteBase* CFbsScreenDevice::HideSprite(const TRect& /*aRect*/,
|
sl@0
|
208 |
const TRegion* /*aClippingRegion*/) const
|
sl@0
|
209 |
{
|
sl@0
|
210 |
return NULL;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
|
sl@0
|
214 |
/**
|
sl@0
|
215 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
216 |
Calling this method has no effect.
|
sl@0
|
217 |
|
sl@0
|
218 |
@param aSprite Ignored.
|
sl@0
|
219 |
@deprecated
|
sl@0
|
220 |
*/
|
sl@0
|
221 |
EXPORT_C void CFbsScreenDevice::ShowSprite(TSpriteBase* /*aSprite*/) const
|
sl@0
|
222 |
{
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
|
sl@0
|
226 |
/**
|
sl@0
|
227 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
228 |
Calling this method has no effect.
|
sl@0
|
229 |
|
sl@0
|
230 |
@param aSprite Ignored.
|
sl@0
|
231 |
@param aRect Ignored.
|
sl@0
|
232 |
@param aClippingRegion Ignored.
|
sl@0
|
233 |
@deprecated
|
sl@0
|
234 |
*/
|
sl@0
|
235 |
EXPORT_C void CFbsScreenDevice::ShowSprite(TSpriteBase* /*aSprite*/,const TRect& /*aRect*/,
|
sl@0
|
236 |
const TRegion* /*aClippingRegion*/) const
|
sl@0
|
237 |
{
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
|
sl@0
|
241 |
/** Changes the screen device.
|
sl@0
|
242 |
|
sl@0
|
243 |
@param aOldDevice A pointer to the old screen device. */
|
sl@0
|
244 |
EXPORT_C void CFbsScreenDevice::ChangeScreenDevice(CFbsScreenDevice* aOldDevice)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
if (aOldDevice == NULL)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
TInt ret = iDrawDevice->InitScreen();
|
sl@0
|
249 |
BG_ASSERT_ALWAYS(ret == KErrNone,EBitgdiPanicInvalidWindowHandle);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
else
|
sl@0
|
252 |
{
|
sl@0
|
253 |
delete aOldDevice->iGraphicsAccelerator;
|
sl@0
|
254 |
aOldDevice->iGraphicsAccelerator = NULL;
|
sl@0
|
255 |
|
sl@0
|
256 |
if (aOldDevice != this)
|
sl@0
|
257 |
{
|
sl@0
|
258 |
iDrawDevice->SetDisplayMode(aOldDevice->iDrawDevice);
|
sl@0
|
259 |
iOrientation = aOldDevice->iOrientation;
|
sl@0
|
260 |
}
|
sl@0
|
261 |
// else we're re-initialising the existing CFbsScreenDevice's graphics accelerator only
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
//Check if the screen device is scaled or the origin is moved.
|
sl@0
|
265 |
//If it is, then do not create graphics accelerator
|
sl@0
|
266 |
//instance, because it does not have support for scaling&origin.
|
sl@0
|
267 |
TBool scalingOff = ETrue;
|
sl@0
|
268 |
TBool originZero = ETrue;
|
sl@0
|
269 |
MScalingSettings* scalingSettings = NULL;
|
sl@0
|
270 |
if(iDrawDevice->GetInterface(KScalingSettingsInterfaceID,
|
sl@0
|
271 |
reinterpret_cast <TAny*&> (scalingSettings)) == KErrNone)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
BG_ASSERT_DEBUG_INVARIANT(scalingSettings);
|
sl@0
|
274 |
scalingOff = scalingSettings->IsScalingOff();
|
sl@0
|
275 |
}
|
sl@0
|
276 |
MDrawDeviceOrigin* originInterface = NULL;
|
sl@0
|
277 |
if(iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
|
sl@0
|
278 |
reinterpret_cast <TAny*&> (originInterface)) == KErrNone)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
BG_ASSERT_DEBUG_INVARIANT(originInterface);
|
sl@0
|
281 |
TPoint origin;
|
sl@0
|
282 |
originInterface->Get(origin);
|
sl@0
|
283 |
originZero = origin.iX == 0 && origin.iY == 0;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
if(scalingOff && originZero)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
RHardwareBitmap screen;
|
sl@0
|
288 |
//Some explanations about "-1 - iScreenNo" expression.
|
sl@0
|
289 |
//SetAsScreenReference() is a public, exported method with a default argument'value -1.
|
sl@0
|
290 |
//In SetAsScreenReference()'s implementation before "Multiple screens" source code update,
|
sl@0
|
291 |
//"-1" value meant - this is a screen hardware bitmap. Positive value meant -
|
sl@0
|
292 |
//in-memory hardware bitmap.
|
sl@0
|
293 |
//After "Multiple screens" update, the meaning of SetAsScreenReference()'s argument is:
|
sl@0
|
294 |
// - Positive value - in-memory hardware bitmap;
|
sl@0
|
295 |
// - Negative value - screen number: "-1" - screen 0, "-2" - screen 1, "-3" - screen 2, ...;
|
sl@0
|
296 |
if(screen.SetAsScreenReference(-1 - iScreenNo)==KErrNone)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
TRAP_IGNORE(iGraphicsAccelerator = CHardwareGraphicsAccelerator::NewL(screen));
|
sl@0
|
299 |
}
|
sl@0
|
300 |
}
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
|
sl@0
|
304 |
/** Gets the palette attributes of the device.
|
sl@0
|
305 |
|
sl@0
|
306 |
@param aModifiable On return, holds information on whether or not the device
|
sl@0
|
307 |
palette is modifiable (ETrue) or fixed (EFalse).
|
sl@0
|
308 |
@param aNumEntries On return, holds the number of entries in the device
|
sl@0
|
309 |
palette. */
|
sl@0
|
310 |
EXPORT_C void CFbsScreenDevice::PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
|
sl@0
|
311 |
{
|
sl@0
|
312 |
aModifiable = (iDrawDevice->DisplayMode() == EColor256);
|
sl@0
|
313 |
aNumEntries = TDisplayModeUtils::NumDisplayModeColors(iDrawDevice->DisplayMode());
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
|
sl@0
|
317 |
/** Sets the device's palette to the specified palette.
|
sl@0
|
318 |
|
sl@0
|
319 |
Setting the palette is only possible if the device has a modifiable palette,
|
sl@0
|
320 |
which can be determined by calling PaletteAttributes().
|
sl@0
|
321 |
|
sl@0
|
322 |
@param aPalette The new palette for the device. */
|
sl@0
|
323 |
EXPORT_C void CFbsScreenDevice::SetPalette(CPalette* aPalette)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
SetCustomPalette(aPalette); // Have to ignore error for compatibility
|
sl@0
|
326 |
}
|
sl@0
|
327 |
|
sl@0
|
328 |
|
sl@0
|
329 |
/** Gets the device's current palette.
|
sl@0
|
330 |
|
sl@0
|
331 |
This function is only supported if the device has a modifiable palette,
|
sl@0
|
332 |
which can be determined by calling PaletteAttributes().
|
sl@0
|
333 |
|
sl@0
|
334 |
@param aPalette On return, holds the devices current palette.
|
sl@0
|
335 |
@return KErrNone, if successful; otherwise, another of the system-wide error
|
sl@0
|
336 |
codes. */
|
sl@0
|
337 |
EXPORT_C TInt CFbsScreenDevice::GetPalette(CPalette*& aPalette) const
|
sl@0
|
338 |
{
|
sl@0
|
339 |
return iDrawDevice->GetCustomPalette(aPalette);
|
sl@0
|
340 |
}
|
sl@0
|
341 |
|
sl@0
|
342 |
|
sl@0
|
343 |
/**
|
sl@0
|
344 |
This method has been deprecated. Sprites are no longer supported in BitGDI.
|
sl@0
|
345 |
Calling this method has no effect.
|
sl@0
|
346 |
@deprecated
|
sl@0
|
347 |
*/
|
sl@0
|
348 |
EXPORT_C void CFbsScreenDevice::CancelSprite() const
|
sl@0
|
349 |
{
|
sl@0
|
350 |
}
|
sl@0
|
351 |
|
sl@0
|
352 |
|
sl@0
|
353 |
/** Sets or unsets auto-update for the screen.
|
sl@0
|
354 |
|
sl@0
|
355 |
@param aValue ETrue, if the screen is set to auto-update; EFalse, otherwise. */
|
sl@0
|
356 |
EXPORT_C void CFbsScreenDevice::SetAutoUpdate(TBool aValue)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
iDrawDevice->SetAutoUpdate(aValue);
|
sl@0
|
359 |
}
|
sl@0
|
360 |
|
sl@0
|
361 |
|
sl@0
|
362 |
/** Forces any out of date region of the screen to update. */
|
sl@0
|
363 |
EXPORT_C void CFbsScreenDevice::Update()
|
sl@0
|
364 |
{
|
sl@0
|
365 |
iDrawDevice->Update();
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
|
sl@0
|
369 |
/** Forces any out of date region of the screen to update,
|
sl@0
|
370 |
and additionally forces the specified region to update.
|
sl@0
|
371 |
|
sl@0
|
372 |
@param aRegion The region of the screen to update, in addition
|
sl@0
|
373 |
to any out of date region. */
|
sl@0
|
374 |
EXPORT_C void CFbsScreenDevice::Update(const TRegion& aRegion)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
iDrawDevice->Update(aRegion);
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
|
sl@0
|
380 |
/** Gets the size of the device area, in twips.
|
sl@0
|
381 |
|
sl@0
|
382 |
This implements the pure virtual function CGraphicsDevice::SizeInTwips().
|
sl@0
|
383 |
|
sl@0
|
384 |
@see CGraphicsDevice::SizeInTwips() */
|
sl@0
|
385 |
EXPORT_C TSize CFbsScreenDevice::SizeInTwips() const
|
sl@0
|
386 |
{
|
sl@0
|
387 |
TSize twipssize;
|
sl@0
|
388 |
twipssize.iWidth = HorizontalPixelsToTwips(iDrawDevice->SizeInPixels().iWidth);
|
sl@0
|
389 |
twipssize.iHeight = VerticalPixelsToTwips(iDrawDevice->SizeInPixels().iHeight);
|
sl@0
|
390 |
return twipssize;
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
|
sl@0
|
394 |
/** Converts a horizontal dimension from twips to pixels.
|
sl@0
|
395 |
|
sl@0
|
396 |
This implements the pure virtual function
|
sl@0
|
397 |
MGraphicsDeviceMap::HorizontalTwipsToPixels(). */
|
sl@0
|
398 |
EXPORT_C TInt CFbsScreenDevice::HorizontalTwipsToPixels(TInt aTwips) const
|
sl@0
|
399 |
{
|
sl@0
|
400 |
const TInt htptp = iDrawDevice->HorzTwipsPerThousandPixels();
|
sl@0
|
401 |
TInt64 twips = aTwips;
|
sl@0
|
402 |
twips = (1000 * twips + (htptp >> 1)) / htptp;
|
sl@0
|
403 |
return I64INT(twips);
|
sl@0
|
404 |
}
|
sl@0
|
405 |
|
sl@0
|
406 |
|
sl@0
|
407 |
/** Converts a vertical dimension from twips to pixels.
|
sl@0
|
408 |
|
sl@0
|
409 |
This implements the pure virtual function
|
sl@0
|
410 |
MGraphicsDeviceMap::VerticalTwipsToPixels(). */
|
sl@0
|
411 |
EXPORT_C TInt CFbsScreenDevice::VerticalTwipsToPixels(TInt aTwips) const
|
sl@0
|
412 |
{
|
sl@0
|
413 |
const TInt vtptp = iDrawDevice->VertTwipsPerThousandPixels();
|
sl@0
|
414 |
TInt64 twips = aTwips;
|
sl@0
|
415 |
twips = (1000 * twips + (vtptp >> 1)) / vtptp;
|
sl@0
|
416 |
return I64INT(twips);
|
sl@0
|
417 |
}
|
sl@0
|
418 |
|
sl@0
|
419 |
|
sl@0
|
420 |
/** Creates and returns a hardware bitmap (a bitmap which can be drawn to by a
|
sl@0
|
421 |
graphics accelerator whose operations may be implemented in hardware or software),
|
sl@0
|
422 |
whose handle is to the screen.
|
sl@0
|
423 |
|
sl@0
|
424 |
This allows the caller to draw to the screen like any other hardware bitmap.
|
sl@0
|
425 |
|
sl@0
|
426 |
This function may not be supported on all hardware. If unsupported, it returns
|
sl@0
|
427 |
an RHardwareBitmap with a handle of zero.
|
sl@0
|
428 |
|
sl@0
|
429 |
The hardware bitmap can be used to draw directly to the screen. Use it to
|
sl@0
|
430 |
create a TAcceleratedBitmapSpec object, which can either be used to get a
|
sl@0
|
431 |
TAcceleratedBitmapInfo, or can be passed to a graphics operation (an instance
|
sl@0
|
432 |
of a class derived from class TGraphicsOperation) e.g. a bitblt to copy one
|
sl@0
|
433 |
part of the screen to another.
|
sl@0
|
434 |
|
sl@0
|
435 |
Direct screen access must only be carried out in combination with the Window
|
sl@0
|
436 |
Server's direct screen access classes; i.e. only use the hardware bitmap on
|
sl@0
|
437 |
the CFbsScreenDevice which you get from CDirectScreenAccess, and not from
|
sl@0
|
438 |
your own CFbsScreenDevice.
|
sl@0
|
439 |
|
sl@0
|
440 |
@return A hardware bitmap whose handle is to the screen.
|
sl@0
|
441 |
@see TAcceleratedBitmapSpec
|
sl@0
|
442 |
@see TGraphicsOperation
|
sl@0
|
443 |
@see CGraphicsAccelerator::Operation()
|
sl@0
|
444 |
@see CDirectScreenAccess */
|
sl@0
|
445 |
EXPORT_C RHardwareBitmap CFbsScreenDevice::HardwareBitmap()
|
sl@0
|
446 |
{
|
sl@0
|
447 |
RHardwareBitmap hwb;
|
sl@0
|
448 |
//Some explanations about "-1 - iScreenNo" expression.
|
sl@0
|
449 |
//SetAsScreenReference() is a public, exported method with a default argument'value -1.
|
sl@0
|
450 |
//In SetAsScreenReference()'s implementation before "Multiple screens" source code update,
|
sl@0
|
451 |
//"-1" value meant - this is a screen hardware bitmap. Positive value meant -
|
sl@0
|
452 |
//in-memory hardware bitmap.
|
sl@0
|
453 |
//After "Multiple screens" update, the meaning of SetAsScreenReference()'s argument is:
|
sl@0
|
454 |
// - Positive value - in-memory hardware bitmap;
|
sl@0
|
455 |
// - Negative value - screen number: "-1" - screen 0, "-2" - screen 1, "-3" - screen 2, ...;
|
sl@0
|
456 |
hwb.SetAsScreenReference(-1 - iScreenNo);
|
sl@0
|
457 |
return hwb;
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
/** Returns pointer to the location of first pixel in frame buffer. Not necessarily the same as pointer
|
sl@0
|
461 |
to frame buffer.
|
sl@0
|
462 |
|
sl@0
|
463 |
@return Pointer to the location of first pixel or NULL if it is not accessible.
|
sl@0
|
464 |
@internalComponent
|
sl@0
|
465 |
*/
|
sl@0
|
466 |
EXPORT_C const TUint32* CFbsScreenDevice::Bits() const
|
sl@0
|
467 |
{
|
sl@0
|
468 |
TAny* interface = NULL;
|
sl@0
|
469 |
TInt ret = iDrawDevice->GetInterface(KFastBlit2InterfaceID, interface);
|
sl@0
|
470 |
if (ret != KErrNone)
|
sl@0
|
471 |
return NULL;
|
sl@0
|
472 |
|
sl@0
|
473 |
return reinterpret_cast<MFastBlit2*>(interface)->Bits();
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
/** Returns frame buffer line pitch or stride.
|
sl@0
|
477 |
|
sl@0
|
478 |
@return Frame buffer stride.
|
sl@0
|
479 |
@internalComponent
|
sl@0
|
480 |
*/
|
sl@0
|
481 |
EXPORT_C TInt CFbsScreenDevice::Stride() const
|
sl@0
|
482 |
{
|
sl@0
|
483 |
return iDrawDevice->ScanLineBytes();
|
sl@0
|
484 |
}
|
sl@0
|
485 |
|
sl@0
|
486 |
/** Query the screen number to which the object refers.
|
sl@0
|
487 |
|
sl@0
|
488 |
@return Screen number as passed in aScreenNo to NewL.
|
sl@0
|
489 |
@publishedAll
|
sl@0
|
490 |
@released
|
sl@0
|
491 |
*/
|
sl@0
|
492 |
EXPORT_C TInt CFbsScreenDevice::ScreenNo() const
|
sl@0
|
493 |
{
|
sl@0
|
494 |
return iScreenNo;
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
/** Get the surface identifier for the current device orientation of the screen.
|
sl@0
|
498 |
If screen device doesn't support providing a surface, the caller is panicked.
|
sl@0
|
499 |
|
sl@0
|
500 |
@param aSurface Set to the surface identifier for the screen buffer.
|
sl@0
|
501 |
@internalTechnology
|
sl@0
|
502 |
@prototype
|
sl@0
|
503 |
*/
|
sl@0
|
504 |
EXPORT_C void CFbsScreenDevice::GetSurface(TSurfaceId& aSurface) const
|
sl@0
|
505 |
{
|
sl@0
|
506 |
#if defined(SYMBIAN_GRAPHICS_GCE)
|
sl@0
|
507 |
TAny* interface = NULL;
|
sl@0
|
508 |
TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
|
sl@0
|
509 |
if (ret == KErrNone)
|
sl@0
|
510 |
{
|
sl@0
|
511 |
reinterpret_cast<MSurfaceId*>(interface)->GetSurface(aSurface);
|
sl@0
|
512 |
return;
|
sl@0
|
513 |
}
|
sl@0
|
514 |
#endif
|
sl@0
|
515 |
(void)aSurface; // Satisfies the compiler, if its a Non-GCE build.
|
sl@0
|
516 |
Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
|
sl@0
|
517 |
}
|
sl@0
|
518 |
|
sl@0
|
519 |
/** This function is used to request the device orientations supported by the
|
sl@0
|
520 |
screen device.
|
sl@0
|
521 |
|
sl@0
|
522 |
@return A bitwise combination of one or more TDeviceOrientation enumerated
|
sl@0
|
523 |
values indicating the device orientations that are supported by this device.
|
sl@0
|
524 |
@internalTechnology
|
sl@0
|
525 |
@prototype
|
sl@0
|
526 |
*/
|
sl@0
|
527 |
EXPORT_C TUint CFbsScreenDevice::DeviceOrientationsAvailable() const
|
sl@0
|
528 |
{
|
sl@0
|
529 |
#if defined(SYMBIAN_GRAPHICS_GCE)
|
sl@0
|
530 |
TAny* interface = NULL;
|
sl@0
|
531 |
TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
|
sl@0
|
532 |
if (ret == KErrNone)
|
sl@0
|
533 |
return reinterpret_cast<MSurfaceId*>(interface)->DeviceOrientationsAvailable();
|
sl@0
|
534 |
#endif
|
sl@0
|
535 |
Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
|
sl@0
|
536 |
return 0; // Make the compiler happy.
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
/** This function selects the surface and device buffer to use in the screen
|
sl@0
|
540 |
driver for this screen. Normal and 180° rotations will generally use the same
|
sl@0
|
541 |
surface, while 90° and 270° will use another. The surfaces may have different
|
sl@0
|
542 |
width, height, stride and surface, so functions that make use of any of these
|
sl@0
|
543 |
may be affected after a change in surface orientation, and the return value
|
sl@0
|
544 |
should be checked for this reason.
|
sl@0
|
545 |
|
sl@0
|
546 |
This call does not change the way rendering is performed, but may operate on
|
sl@0
|
547 |
the underlying memory using a new shape. The call does not change the display
|
sl@0
|
548 |
controller’s settings, as this is handled via the GCE. All this changes are the
|
sl@0
|
549 |
internal attributes of the screen device and driver objects. A CFbsBitGc object
|
sl@0
|
550 |
activated on the device should be reactivated, to update its own attributes, or
|
sl@0
|
551 |
drawing may be corrupted.
|
sl@0
|
552 |
|
sl@0
|
553 |
Note: while TDeviceOrientation values do not directly correspond to
|
sl@0
|
554 |
CFbsBitGc::TGraphicsOrientation values, and cannot be used interchangeably, it
|
sl@0
|
555 |
is simple to generate the former from the latter using the left-shift operator
|
sl@0
|
556 |
(i.e. device == (1 << graphics)). In particular a device orientation of 90
|
sl@0
|
557 |
degrees clockwise is equivalent to a content orientation of 90 degrees anti-
|
sl@0
|
558 |
clockwise, which is what TGraphicsOrientation refers to for the equivalent
|
sl@0
|
559 |
setting. The letters "CW" in the TDeviceOrientation enumeration refer to a
|
sl@0
|
560 |
clockwise device rotation, so EDeviceOrientation90CW is a 90 degree clockwise
|
sl@0
|
561 |
rotation of the device.
|
sl@0
|
562 |
|
sl@0
|
563 |
@param aOrientation The new device orientation, relative to the normal physical
|
sl@0
|
564 |
screen orientation.
|
sl@0
|
565 |
@return ETrue is returned if any of the surface, width, height or stride
|
sl@0
|
566 |
attributes of the screen device have changed as a result of the call or EFalse
|
sl@0
|
567 |
if none of the attributes have changed.
|
sl@0
|
568 |
@internalTechnology
|
sl@0
|
569 |
@prototype
|
sl@0
|
570 |
*/
|
sl@0
|
571 |
EXPORT_C TBool CFbsScreenDevice::SetDeviceOrientation(TDeviceOrientation aOrientation) const
|
sl@0
|
572 |
{
|
sl@0
|
573 |
#if defined(SYMBIAN_GRAPHICS_GCE)
|
sl@0
|
574 |
TAny* interface = NULL;
|
sl@0
|
575 |
TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
|
sl@0
|
576 |
if (ret == KErrNone)
|
sl@0
|
577 |
return reinterpret_cast<MSurfaceId*>(interface)->SetDeviceOrientation(aOrientation);
|
sl@0
|
578 |
#endif
|
sl@0
|
579 |
(void)aOrientation; // Satisfies the compiler, if its a Non-GCE build.
|
sl@0
|
580 |
Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
|
sl@0
|
581 |
return EFalse; // Make the compiler happy.
|
sl@0
|
582 |
}
|
sl@0
|
583 |
|
sl@0
|
584 |
/** This function is used to request the current device orientation.
|
sl@0
|
585 |
|
sl@0
|
586 |
@return One of the TDeviceOrientation enumerated values.
|
sl@0
|
587 |
@internalTechnology
|
sl@0
|
588 |
@prototype
|
sl@0
|
589 |
*/
|
sl@0
|
590 |
EXPORT_C TDeviceOrientation CFbsScreenDevice::DeviceOrientation() const
|
sl@0
|
591 |
{
|
sl@0
|
592 |
#if defined(SYMBIAN_GRAPHICS_GCE)
|
sl@0
|
593 |
TAny* interface = NULL;
|
sl@0
|
594 |
TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
|
sl@0
|
595 |
if (ret == KErrNone)
|
sl@0
|
596 |
return reinterpret_cast<MSurfaceId*>(interface)->DeviceOrientation();
|
sl@0
|
597 |
#endif
|
sl@0
|
598 |
Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
|
sl@0
|
599 |
return EDeviceOrientationNormal; // Make the compiler happy.
|
sl@0
|
600 |
}
|
sl@0
|
601 |
|