1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/sbit/SCREENDV.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,601 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <hal.h>
1.20 +#include <fbs.h>
1.21 +#include <bitbase.h>
1.22 +#include <bitdev.h>
1.23 +#include <bitdraw.h>
1.24 +#include <bitdrawscaling.h>
1.25 +#include <bitdraworigin.h>
1.26 +#include <bitdrawinterfaceid.h>
1.27 +#include "BITPANIC.H"
1.28 +#include <bmalphablend.h>
1.29 +#include <graphics/gdi/gdiconsts.h>
1.30 +
1.31 +
1.32 +#if defined(SYMBIAN_GRAPHICS_GCE)
1.33 +#include <bitdrawsurface.h>
1.34 +#endif
1.35 +
1.36 +/**
1.37 +@param aScreenNo The screen number. If the device has a support for only one screen, its
1.38 + number is 0.
1.39 +*/
1.40 +CFbsScreenDevice::CFbsScreenDevice(TInt aScreenNo):
1.41 + CFbsDevice(),
1.42 + iScreenNo(aScreenNo)
1.43 + {
1.44 + }
1.45 +
1.46 +
1.47 +/** Creates a new CFbsScreenDevice object.
1.48 +
1.49 +@param aLibname Not used.
1.50 +@param aDispMode The display mode of the device.
1.51 +@return The newly created FBSERV screen device. */
1.52 +EXPORT_C CFbsScreenDevice* CFbsScreenDevice::NewL(const TDesC& /*aLibname*/,
1.53 + TDisplayMode aDispMode)
1.54 + {
1.55 + return CFbsScreenDevice::NewL(KDefaultScreenNo, aDispMode);
1.56 + }
1.57 +
1.58 +/** Creates a new CFbsScreenDevice object.
1.59 +
1.60 +@param aLibname Not used.
1.61 +@param aDispMode The display mode of the device.
1.62 +@param aWhite Not used.
1.63 +@return The newly created font and bitmap server screen device.
1.64 +@deprecated Use two param version instead. */
1.65 +EXPORT_C CFbsScreenDevice* CFbsScreenDevice::NewL(const TDesC& /*aLibname*/,
1.66 + TDisplayMode aDispMode,
1.67 + TRgb /*aWhite*/)
1.68 + {
1.69 + return CFbsScreenDevice::NewL(KDefaultScreenNo, aDispMode);
1.70 + }
1.71 +
1.72 +/**
1.73 +Creates a new CFbsScreenDevice object.
1.74 +@param aScreenNo The screen number. If the device has a support for only one screen, its
1.75 + number is 0.
1.76 +@param aDispMode The display mode of the device.
1.77 +@return The newly created FBSERV screen device.
1.78 +*/
1.79 +EXPORT_C CFbsScreenDevice* CFbsScreenDevice::NewL(TInt aScreenNo, TDisplayMode aDispMode)
1.80 + {
1.81 + CFbsScreenDevice* self = new (ELeave) CFbsScreenDevice(aScreenNo);
1.82 + CleanupStack::PushL(self);
1.83 + self->ConstructL(aScreenNo, aDispMode);
1.84 + CleanupStack::Pop(); // self
1.85 + return self;
1.86 + }
1.87 +
1.88 +/** Frees all resources owned by the object prior to its destruction. */
1.89 +EXPORT_C CFbsScreenDevice::~CFbsScreenDevice()
1.90 + {
1.91 + }
1.92 +
1.93 +void CFbsScreenDevice::ConstructL(TInt aScreenNo, TDisplayMode aDispMode)
1.94 + {
1.95 + iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDispMode);
1.96 + iScreenDevice = ETrue;
1.97 + iTypefaceStore = CFbsTypefaceStore::NewL(this);
1.98 + if(aDispMode != EGray4) // Flicker-free blitting not enabled under EGray4 because it messes up the EGray16-emulating dithering
1.99 + {
1.100 + TInt scanLineBytes = iDrawDevice->ScanLineBytes();
1.101 + const TSize screenSize = SizeInPixels();
1.102 + if(screenSize.iHeight > screenSize.iWidth)
1.103 + {
1.104 + scanLineBytes = scanLineBytes * screenSize.iHeight / screenSize.iWidth;
1.105 + }
1.106 + iBitBltMaskedBuffer = new(ELeave) TUint8[scanLineBytes * 2];
1.107 + }
1.108 + }
1.109 +
1.110 +
1.111 +/** Copies a scanline into a buffer.
1.112 +
1.113 +This implements the pure virtual function
1.114 +CBitmapDevice::GetScanLine(). */
1.115 +EXPORT_C void CFbsScreenDevice::GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,
1.116 + TInt aLength,TDisplayMode aDispMode) const
1.117 + {
1.118 + if (!iDrawDevice)
1.119 + return;
1.120 +
1.121 + ((CFbsScreenDevice*)this)->DoGetScanLine(aBuf,aStartPixel,aLength,aDispMode);
1.122 + }
1.123 +
1.124 +
1.125 +/** Gets the RGB colour of an individual pixel on a bitmapped graphics
1.126 +device.
1.127 +
1.128 +This implements the pure virtual function
1.129 +CBitmapDevice::GetPixel(). */
1.130 +EXPORT_C void CFbsScreenDevice::GetPixel(TRgb& aColor,const TPoint& aPoint) const
1.131 + {
1.132 + if (!iDrawDevice)
1.133 + return;
1.134 +
1.135 + TRect deviceRect;
1.136 + iDrawDevice->GetDrawRect(deviceRect);
1.137 + if (!deviceRect.Contains(aPoint))
1.138 + return;
1.139 +
1.140 + aColor = iDrawDevice->ReadPixel(aPoint.iX,aPoint.iY);
1.141 + }
1.142 +
1.143 +
1.144 +/** Converts a horizontal dimension from pixels to twips.
1.145 +
1.146 +This implements the pure virtual function
1.147 +MGraphicsDeviceMap::HorizontalPixelsToTwips(). */
1.148 +EXPORT_C TInt CFbsScreenDevice::HorizontalPixelsToTwips(TInt aPixels) const
1.149 + {
1.150 + TInt64 pixels=aPixels;
1.151 + pixels=(iDrawDevice->HorzTwipsPerThousandPixels() * pixels + 500) / 1000;
1.152 + return I64INT(pixels);
1.153 + }
1.154 +
1.155 +
1.156 +/** Converts a vertical dimension from pixels to twips.
1.157 +
1.158 +This implements the pure virtual function
1.159 +MGraphicsDeviceMap::VerticalPixelsToTwips(). */
1.160 +EXPORT_C TInt CFbsScreenDevice::VerticalPixelsToTwips(TInt aPixels) const
1.161 + {
1.162 + TInt64 pixels=aPixels;
1.163 + pixels=(iDrawDevice->VertTwipsPerThousandPixels() * pixels + 500) / 1000;
1.164 + return I64INT(pixels);
1.165 + }
1.166 +
1.167 +
1.168 +/**
1.169 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.170 +Calling this method has no effect.
1.171 +@deprecated
1.172 +*/
1.173 +EXPORT_C void CFbsScreenDevice::DrawSpriteBegin()
1.174 + {
1.175 + }
1.176 +
1.177 +
1.178 +/**
1.179 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.180 +Calling this method has no effect.
1.181 +@deprecated
1.182 +*/
1.183 +EXPORT_C void CFbsScreenDevice::DrawSpriteEnd()
1.184 + {
1.185 + }
1.186 +
1.187 +
1.188 +/**
1.189 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.190 +Calling this method has no effect.
1.191 +
1.192 +@return NULL.
1.193 +@deprecated
1.194 +*/
1.195 +EXPORT_C TSpriteBase* CFbsScreenDevice::HideSprite() const
1.196 + {
1.197 + return NULL;
1.198 + }
1.199 +
1.200 +
1.201 +/**
1.202 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.203 +Calling this method has no effect.
1.204 +
1.205 +@param aRect Ignored.
1.206 +@param aClippingRegion Ignored.
1.207 +@return NULL.
1.208 +@deprecated
1.209 +*/
1.210 +EXPORT_C TSpriteBase* CFbsScreenDevice::HideSprite(const TRect& /*aRect*/,
1.211 + const TRegion* /*aClippingRegion*/) const
1.212 + {
1.213 + return NULL;
1.214 + }
1.215 +
1.216 +
1.217 +/**
1.218 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.219 +Calling this method has no effect.
1.220 +
1.221 +@param aSprite Ignored.
1.222 +@deprecated
1.223 +*/
1.224 +EXPORT_C void CFbsScreenDevice::ShowSprite(TSpriteBase* /*aSprite*/) const
1.225 + {
1.226 + }
1.227 +
1.228 +
1.229 +/**
1.230 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.231 +Calling this method has no effect.
1.232 +
1.233 +@param aSprite Ignored.
1.234 +@param aRect Ignored.
1.235 +@param aClippingRegion Ignored.
1.236 +@deprecated
1.237 +*/
1.238 +EXPORT_C void CFbsScreenDevice::ShowSprite(TSpriteBase* /*aSprite*/,const TRect& /*aRect*/,
1.239 + const TRegion* /*aClippingRegion*/) const
1.240 + {
1.241 + }
1.242 +
1.243 +
1.244 +/** Changes the screen device.
1.245 +
1.246 +@param aOldDevice A pointer to the old screen device. */
1.247 +EXPORT_C void CFbsScreenDevice::ChangeScreenDevice(CFbsScreenDevice* aOldDevice)
1.248 + {
1.249 + if (aOldDevice == NULL)
1.250 + {
1.251 + TInt ret = iDrawDevice->InitScreen();
1.252 + BG_ASSERT_ALWAYS(ret == KErrNone,EBitgdiPanicInvalidWindowHandle);
1.253 + }
1.254 + else
1.255 + {
1.256 + delete aOldDevice->iGraphicsAccelerator;
1.257 + aOldDevice->iGraphicsAccelerator = NULL;
1.258 +
1.259 + if (aOldDevice != this)
1.260 + {
1.261 + iDrawDevice->SetDisplayMode(aOldDevice->iDrawDevice);
1.262 + iOrientation = aOldDevice->iOrientation;
1.263 + }
1.264 + // else we're re-initialising the existing CFbsScreenDevice's graphics accelerator only
1.265 + }
1.266 +
1.267 + //Check if the screen device is scaled or the origin is moved.
1.268 + //If it is, then do not create graphics accelerator
1.269 + //instance, because it does not have support for scaling&origin.
1.270 + TBool scalingOff = ETrue;
1.271 + TBool originZero = ETrue;
1.272 + MScalingSettings* scalingSettings = NULL;
1.273 + if(iDrawDevice->GetInterface(KScalingSettingsInterfaceID,
1.274 + reinterpret_cast <TAny*&> (scalingSettings)) == KErrNone)
1.275 + {
1.276 + BG_ASSERT_DEBUG_INVARIANT(scalingSettings);
1.277 + scalingOff = scalingSettings->IsScalingOff();
1.278 + }
1.279 + MDrawDeviceOrigin* originInterface = NULL;
1.280 + if(iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
1.281 + reinterpret_cast <TAny*&> (originInterface)) == KErrNone)
1.282 + {
1.283 + BG_ASSERT_DEBUG_INVARIANT(originInterface);
1.284 + TPoint origin;
1.285 + originInterface->Get(origin);
1.286 + originZero = origin.iX == 0 && origin.iY == 0;
1.287 + }
1.288 + if(scalingOff && originZero)
1.289 + {
1.290 + RHardwareBitmap screen;
1.291 + //Some explanations about "-1 - iScreenNo" expression.
1.292 + //SetAsScreenReference() is a public, exported method with a default argument'value -1.
1.293 + //In SetAsScreenReference()'s implementation before "Multiple screens" source code update,
1.294 + //"-1" value meant - this is a screen hardware bitmap. Positive value meant -
1.295 + //in-memory hardware bitmap.
1.296 + //After "Multiple screens" update, the meaning of SetAsScreenReference()'s argument is:
1.297 + // - Positive value - in-memory hardware bitmap;
1.298 + // - Negative value - screen number: "-1" - screen 0, "-2" - screen 1, "-3" - screen 2, ...;
1.299 + if(screen.SetAsScreenReference(-1 - iScreenNo)==KErrNone)
1.300 + {
1.301 + TRAP_IGNORE(iGraphicsAccelerator = CHardwareGraphicsAccelerator::NewL(screen));
1.302 + }
1.303 + }
1.304 + }
1.305 +
1.306 +
1.307 +/** Gets the palette attributes of the device.
1.308 +
1.309 +@param aModifiable On return, holds information on whether or not the device
1.310 +palette is modifiable (ETrue) or fixed (EFalse).
1.311 +@param aNumEntries On return, holds the number of entries in the device
1.312 +palette. */
1.313 +EXPORT_C void CFbsScreenDevice::PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
1.314 + {
1.315 + aModifiable = (iDrawDevice->DisplayMode() == EColor256);
1.316 + aNumEntries = TDisplayModeUtils::NumDisplayModeColors(iDrawDevice->DisplayMode());
1.317 + }
1.318 +
1.319 +
1.320 +/** Sets the device's palette to the specified palette.
1.321 +
1.322 +Setting the palette is only possible if the device has a modifiable palette,
1.323 +which can be determined by calling PaletteAttributes().
1.324 +
1.325 +@param aPalette The new palette for the device. */
1.326 +EXPORT_C void CFbsScreenDevice::SetPalette(CPalette* aPalette)
1.327 + {
1.328 + SetCustomPalette(aPalette); // Have to ignore error for compatibility
1.329 + }
1.330 +
1.331 +
1.332 +/** Gets the device's current palette.
1.333 +
1.334 +This function is only supported if the device has a modifiable palette,
1.335 +which can be determined by calling PaletteAttributes().
1.336 +
1.337 +@param aPalette On return, holds the devices current palette.
1.338 +@return KErrNone, if successful; otherwise, another of the system-wide error
1.339 +codes. */
1.340 +EXPORT_C TInt CFbsScreenDevice::GetPalette(CPalette*& aPalette) const
1.341 + {
1.342 + return iDrawDevice->GetCustomPalette(aPalette);
1.343 + }
1.344 +
1.345 +
1.346 +/**
1.347 +This method has been deprecated. Sprites are no longer supported in BitGDI.
1.348 +Calling this method has no effect.
1.349 +@deprecated
1.350 +*/
1.351 +EXPORT_C void CFbsScreenDevice::CancelSprite() const
1.352 + {
1.353 + }
1.354 +
1.355 +
1.356 +/** Sets or unsets auto-update for the screen.
1.357 +
1.358 +@param aValue ETrue, if the screen is set to auto-update; EFalse, otherwise. */
1.359 +EXPORT_C void CFbsScreenDevice::SetAutoUpdate(TBool aValue)
1.360 + {
1.361 + iDrawDevice->SetAutoUpdate(aValue);
1.362 + }
1.363 +
1.364 +
1.365 +/** Forces any out of date region of the screen to update. */
1.366 +EXPORT_C void CFbsScreenDevice::Update()
1.367 + {
1.368 + iDrawDevice->Update();
1.369 + }
1.370 +
1.371 +
1.372 +/** Forces any out of date region of the screen to update,
1.373 +and additionally forces the specified region to update.
1.374 +
1.375 +@param aRegion The region of the screen to update, in addition
1.376 +to any out of date region. */
1.377 +EXPORT_C void CFbsScreenDevice::Update(const TRegion& aRegion)
1.378 + {
1.379 + iDrawDevice->Update(aRegion);
1.380 + }
1.381 +
1.382 +
1.383 +/** Gets the size of the device area, in twips.
1.384 +
1.385 +This implements the pure virtual function CGraphicsDevice::SizeInTwips().
1.386 +
1.387 +@see CGraphicsDevice::SizeInTwips() */
1.388 +EXPORT_C TSize CFbsScreenDevice::SizeInTwips() const
1.389 + {
1.390 + TSize twipssize;
1.391 + twipssize.iWidth = HorizontalPixelsToTwips(iDrawDevice->SizeInPixels().iWidth);
1.392 + twipssize.iHeight = VerticalPixelsToTwips(iDrawDevice->SizeInPixels().iHeight);
1.393 + return twipssize;
1.394 + }
1.395 +
1.396 +
1.397 +/** Converts a horizontal dimension from twips to pixels.
1.398 +
1.399 +This implements the pure virtual function
1.400 +MGraphicsDeviceMap::HorizontalTwipsToPixels(). */
1.401 +EXPORT_C TInt CFbsScreenDevice::HorizontalTwipsToPixels(TInt aTwips) const
1.402 + {
1.403 + const TInt htptp = iDrawDevice->HorzTwipsPerThousandPixels();
1.404 + TInt64 twips = aTwips;
1.405 + twips = (1000 * twips + (htptp >> 1)) / htptp;
1.406 + return I64INT(twips);
1.407 + }
1.408 +
1.409 +
1.410 +/** Converts a vertical dimension from twips to pixels.
1.411 +
1.412 +This implements the pure virtual function
1.413 +MGraphicsDeviceMap::VerticalTwipsToPixels(). */
1.414 +EXPORT_C TInt CFbsScreenDevice::VerticalTwipsToPixels(TInt aTwips) const
1.415 + {
1.416 + const TInt vtptp = iDrawDevice->VertTwipsPerThousandPixels();
1.417 + TInt64 twips = aTwips;
1.418 + twips = (1000 * twips + (vtptp >> 1)) / vtptp;
1.419 + return I64INT(twips);
1.420 + }
1.421 +
1.422 +
1.423 +/** Creates and returns a hardware bitmap (a bitmap which can be drawn to by a
1.424 +graphics accelerator whose operations may be implemented in hardware or software),
1.425 +whose handle is to the screen.
1.426 +
1.427 +This allows the caller to draw to the screen like any other hardware bitmap.
1.428 +
1.429 +This function may not be supported on all hardware. If unsupported, it returns
1.430 +an RHardwareBitmap with a handle of zero.
1.431 +
1.432 +The hardware bitmap can be used to draw directly to the screen. Use it to
1.433 +create a TAcceleratedBitmapSpec object, which can either be used to get a
1.434 +TAcceleratedBitmapInfo, or can be passed to a graphics operation (an instance
1.435 +of a class derived from class TGraphicsOperation) e.g. a bitblt to copy one
1.436 +part of the screen to another.
1.437 +
1.438 +Direct screen access must only be carried out in combination with the Window
1.439 +Server's direct screen access classes; i.e. only use the hardware bitmap on
1.440 +the CFbsScreenDevice which you get from CDirectScreenAccess, and not from
1.441 +your own CFbsScreenDevice.
1.442 +
1.443 +@return A hardware bitmap whose handle is to the screen.
1.444 +@see TAcceleratedBitmapSpec
1.445 +@see TGraphicsOperation
1.446 +@see CGraphicsAccelerator::Operation()
1.447 +@see CDirectScreenAccess */
1.448 +EXPORT_C RHardwareBitmap CFbsScreenDevice::HardwareBitmap()
1.449 + {
1.450 + RHardwareBitmap hwb;
1.451 + //Some explanations about "-1 - iScreenNo" expression.
1.452 + //SetAsScreenReference() is a public, exported method with a default argument'value -1.
1.453 + //In SetAsScreenReference()'s implementation before "Multiple screens" source code update,
1.454 + //"-1" value meant - this is a screen hardware bitmap. Positive value meant -
1.455 + //in-memory hardware bitmap.
1.456 + //After "Multiple screens" update, the meaning of SetAsScreenReference()'s argument is:
1.457 + // - Positive value - in-memory hardware bitmap;
1.458 + // - Negative value - screen number: "-1" - screen 0, "-2" - screen 1, "-3" - screen 2, ...;
1.459 + hwb.SetAsScreenReference(-1 - iScreenNo);
1.460 + return hwb;
1.461 + }
1.462 +
1.463 +/** Returns pointer to the location of first pixel in frame buffer. Not necessarily the same as pointer
1.464 +to frame buffer.
1.465 +
1.466 +@return Pointer to the location of first pixel or NULL if it is not accessible.
1.467 +@internalComponent
1.468 +*/
1.469 +EXPORT_C const TUint32* CFbsScreenDevice::Bits() const
1.470 + {
1.471 + TAny* interface = NULL;
1.472 + TInt ret = iDrawDevice->GetInterface(KFastBlit2InterfaceID, interface);
1.473 + if (ret != KErrNone)
1.474 + return NULL;
1.475 +
1.476 + return reinterpret_cast<MFastBlit2*>(interface)->Bits();
1.477 + }
1.478 +
1.479 +/** Returns frame buffer line pitch or stride.
1.480 +
1.481 +@return Frame buffer stride.
1.482 +@internalComponent
1.483 +*/
1.484 +EXPORT_C TInt CFbsScreenDevice::Stride() const
1.485 + {
1.486 + return iDrawDevice->ScanLineBytes();
1.487 + }
1.488 +
1.489 +/** Query the screen number to which the object refers.
1.490 +
1.491 +@return Screen number as passed in aScreenNo to NewL.
1.492 +@publishedAll
1.493 +@released
1.494 +*/
1.495 +EXPORT_C TInt CFbsScreenDevice::ScreenNo() const
1.496 + {
1.497 + return iScreenNo;
1.498 + }
1.499 +
1.500 +/** Get the surface identifier for the current device orientation of the screen.
1.501 +If screen device doesn't support providing a surface, the caller is panicked.
1.502 +
1.503 +@param aSurface Set to the surface identifier for the screen buffer.
1.504 +@internalTechnology
1.505 +@prototype
1.506 +*/
1.507 +EXPORT_C void CFbsScreenDevice::GetSurface(TSurfaceId& aSurface) const
1.508 + {
1.509 +#if defined(SYMBIAN_GRAPHICS_GCE)
1.510 + TAny* interface = NULL;
1.511 + TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
1.512 + if (ret == KErrNone)
1.513 + {
1.514 + reinterpret_cast<MSurfaceId*>(interface)->GetSurface(aSurface);
1.515 + return;
1.516 + }
1.517 +#endif
1.518 + (void)aSurface; // Satisfies the compiler, if its a Non-GCE build.
1.519 + Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
1.520 + }
1.521 +
1.522 +/** This function is used to request the device orientations supported by the
1.523 +screen device.
1.524 +
1.525 +@return A bitwise combination of one or more TDeviceOrientation enumerated
1.526 +values indicating the device orientations that are supported by this device.
1.527 +@internalTechnology
1.528 +@prototype
1.529 +*/
1.530 +EXPORT_C TUint CFbsScreenDevice::DeviceOrientationsAvailable() const
1.531 + {
1.532 +#if defined(SYMBIAN_GRAPHICS_GCE)
1.533 + TAny* interface = NULL;
1.534 + TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
1.535 + if (ret == KErrNone)
1.536 + return reinterpret_cast<MSurfaceId*>(interface)->DeviceOrientationsAvailable();
1.537 +#endif
1.538 + Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
1.539 + return 0; // Make the compiler happy.
1.540 + }
1.541 +
1.542 +/** This function selects the surface and device buffer to use in the screen
1.543 +driver for this screen. Normal and 180° rotations will generally use the same
1.544 +surface, while 90° and 270° will use another. The surfaces may have different
1.545 +width, height, stride and surface, so functions that make use of any of these
1.546 +may be affected after a change in surface orientation, and the return value
1.547 +should be checked for this reason.
1.548 +
1.549 +This call does not change the way rendering is performed, but may operate on
1.550 +the underlying memory using a new shape. The call does not change the display
1.551 +controller’s settings, as this is handled via the GCE. All this changes are the
1.552 +internal attributes of the screen device and driver objects. A CFbsBitGc object
1.553 +activated on the device should be reactivated, to update its own attributes, or
1.554 +drawing may be corrupted.
1.555 +
1.556 +Note: while TDeviceOrientation values do not directly correspond to
1.557 +CFbsBitGc::TGraphicsOrientation values, and cannot be used interchangeably, it
1.558 +is simple to generate the former from the latter using the left-shift operator
1.559 +(i.e. device == (1 << graphics)). In particular a device orientation of 90
1.560 +degrees clockwise is equivalent to a content orientation of 90 degrees anti-
1.561 +clockwise, which is what TGraphicsOrientation refers to for the equivalent
1.562 +setting. The letters "CW" in the TDeviceOrientation enumeration refer to a
1.563 +clockwise device rotation, so EDeviceOrientation90CW is a 90 degree clockwise
1.564 +rotation of the device.
1.565 +
1.566 +@param aOrientation The new device orientation, relative to the normal physical
1.567 +screen orientation.
1.568 +@return ETrue is returned if any of the surface, width, height or stride
1.569 +attributes of the screen device have changed as a result of the call or EFalse
1.570 +if none of the attributes have changed.
1.571 +@internalTechnology
1.572 +@prototype
1.573 +*/
1.574 +EXPORT_C TBool CFbsScreenDevice::SetDeviceOrientation(TDeviceOrientation aOrientation) const
1.575 + {
1.576 +#if defined(SYMBIAN_GRAPHICS_GCE)
1.577 + TAny* interface = NULL;
1.578 + TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
1.579 + if (ret == KErrNone)
1.580 + return reinterpret_cast<MSurfaceId*>(interface)->SetDeviceOrientation(aOrientation);
1.581 +#endif
1.582 + (void)aOrientation; // Satisfies the compiler, if its a Non-GCE build.
1.583 + Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
1.584 + return EFalse; // Make the compiler happy.
1.585 + }
1.586 +
1.587 +/** This function is used to request the current device orientation.
1.588 +
1.589 +@return One of the TDeviceOrientation enumerated values.
1.590 +@internalTechnology
1.591 +@prototype
1.592 +*/
1.593 +EXPORT_C TDeviceOrientation CFbsScreenDevice::DeviceOrientation() const
1.594 + {
1.595 +#if defined(SYMBIAN_GRAPHICS_GCE)
1.596 + TAny* interface = NULL;
1.597 + TInt ret = iDrawDevice->GetInterface(KSurfaceInterfaceID, interface);
1.598 + if (ret == KErrNone)
1.599 + return reinterpret_cast<MSurfaceId*>(interface)->DeviceOrientation();
1.600 +#endif
1.601 + Panic(EBitgdiPanicInvalidScreenDeviceLibrary);
1.602 + return EDeviceOrientationNormal; // Make the compiler happy.
1.603 + }
1.604 +