sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This module implements the class for a 16 bpp color screen. sl@0: // Include files sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: /********************************************************************/ sl@0: #include sl@0: #include sl@0: #include sl@0: #include "scdraw.h" sl@0: sl@0: /********************************************************************/ sl@0: /* Implementation of CDrawSixteenBppScreenBitmap class */ sl@0: /********************************************************************/ sl@0: void CDrawSixteenBppScreenBitmap::SetSize(const TSize& aSize) sl@0: { sl@0: CDrawBitmap::SetSize(aSize); sl@0: __ASSERT_DEBUG(iSize == aSize, User::Invariant()); sl@0: iLongWidth = iScanLineWords *2; sl@0: } sl@0: void CDrawSixteenBppScreenBitmap::SetDisplayMode(CFbsDrawDevice* aDrawDevice) sl@0: { sl@0: CopyOldSettings(aDrawDevice) ; sl@0: InitScreen() ; sl@0: } sl@0: sl@0: TInt CDrawSixteenBppScreenBitmap::HorzTwipsPerThousandPixels() const sl@0: { sl@0: if (iSize.iWidth == 0) sl@0: return 0 ; sl@0: TMachineInfoV1Buf miBuf ; sl@0: UserHal::MachineInfo(miBuf) ; sl@0: return miBuf().iPhysicalScreenSize.iWidth * 1000 / iSize.iWidth ; sl@0: } sl@0: sl@0: TInt CDrawSixteenBppScreenBitmap::VertTwipsPerThousandPixels() const sl@0: { sl@0: if (iSize.iHeight == 0) sl@0: return 0 ; sl@0: sl@0: TMachineInfoV1Buf miBuf ; sl@0: UserHal::MachineInfo(miBuf) ; sl@0: return miBuf().iPhysicalScreenSize.iHeight * 1000 / iSize.iHeight ; sl@0: } sl@0: sl@0: /** sl@0: This function initialize the palette. In this mode, there is no palette sl@0: defined sl@0: */ sl@0: TInt CDrawSixteenBppScreenBitmap::InitScreen() sl@0: { sl@0: return KErrNone ; sl@0: } sl@0: sl@0: /** sl@0: Constructs the CDrawSixteenBppScreenBitmap object. sl@0: @param aScreenNo Screen number. It will be used in HAL::Get() calls. sl@0: @param aBitmapAddress The screen memory address. sl@0: @param aSize Screen size sl@0: @return System-wide error codes, KErrNone if the construction was successfull. sl@0: */ sl@0: TInt CDrawSixteenBppScreenBitmap::ConstructScreenL(TInt aScreenNo, TAny* aBitmapAddress, TSize aSize) sl@0: { sl@0: iScreenNo = aScreenNo; sl@0: TInt displayMode; sl@0: sl@0: TInt ret = HAL::Get(aScreenNo, HALData::EDisplayMode, displayMode); sl@0: if (ret != KErrNone) sl@0: return ret; sl@0: sl@0: TInt linepitchInBytes = displayMode; sl@0: ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetBetweenLines,linepitchInBytes); sl@0: if (ret != KErrNone) sl@0: return ret; sl@0: sl@0: CDrawBitmap::iScanLineWords = linepitchInBytes / 4; sl@0: ret = CDrawSixteenBppBitmap::Construct(aSize); sl@0: if (ret != KErrNone) sl@0: return ret ; sl@0: sl@0: /* Set the pointer on the first pixel */ sl@0: TInt offsetToFirstPixel = displayMode; sl@0: ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetToFirstPixel, offsetToFirstPixel); sl@0: if (ret != KErrNone) sl@0: return ret; sl@0: iBits = (TUint32*)((TUint32)aBitmapAddress + offsetToFirstPixel); sl@0: sl@0: return KErrNone ; sl@0: } sl@0: sl@0: /** sl@0: Define the screen orientation available sl@0: */ sl@0: void CDrawSixteenBppScreenBitmap::OrientationsAvailable(TBool aOrientation[4]) sl@0: { sl@0: aOrientation[EOrientationNormal] = ETrue ; sl@0: aOrientation[EOrientationRotated90] = ETrue ; sl@0: aOrientation[EOrientationRotated180] = ETrue ; sl@0: aOrientation[EOrientationRotated270] = ETrue ; sl@0: } sl@0: sl@0: /** sl@0: Set the current display orientation sl@0: */ sl@0: TBool CDrawSixteenBppScreenBitmap::SetOrientation(TOrientation aOrientation) sl@0: { sl@0: iOrientation = aOrientation ; sl@0: return ETrue ; sl@0: }