graphicsdeviceinterface/screendriver/smint/SCCOL.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <hal.h>
       
    17 #include "scdraw.h"
       
    18 
       
    19 /**
       
    20 Constructs the CDrawScreenBitmap object.
       
    21 @param aScreenNo Screen number. It will be used in HAL::Get() calls.
       
    22 @param aBitmapAddress The screen memory address.
       
    23 @param aSize Screen size
       
    24 @return System-wide error codes, KErrNone if the construction was successfull.
       
    25 */
       
    26 TInt CDrawScreenBitmap::ConstructScreen(TInt aScreenNo, TAny* aBitmapAddress,TSize aSize)
       
    27 	{
       
    28     iScreenNo = aScreenNo;
       
    29 	TInt ret = SCREEN_LAYOUT_BASE_BITMAP::Construct(aSize);
       
    30 	if (ret != KErrNone)
       
    31 		return ret;
       
    32 
       
    33 	//fixup for emulating smaller screen
       
    34 	TInt offset = 0;
       
    35 	ret = HAL::Get(iScreenNo, HALData::EDisplayOffsetBetweenLines, offset);
       
    36 	if (ret == KErrNone && (offset != aSize.iWidth))
       
    37 		{
       
    38 		iLongWidth = offset;
       
    39 		iScanLineWords = iLongWidth / 4;
       
    40 		User::Heap().Free(iScanLineBuffer);
       
    41 		iScanLineBuffer = (TUint32*)(User::Heap().Alloc(offset));
       
    42 		if(iScanLineBuffer == NULL)
       
    43 			return KErrNoMemory;
       
    44 		}
       
    45 	//fixup for emulating smaller screen
       
    46 
       
    47 	offset = 0; // Pass in display mode
       
    48 	ret = HAL::Get(iScreenNo, HALData::EDisplayOffsetToFirstPixel,offset);
       
    49 	iBits = (TUint32*)aBitmapAddress;
       
    50 	iBits += offset / sizeof(TUint32);
       
    51 	return ret;
       
    52 	}
       
    53 
       
    54 void CDrawScreenBitmap::SetDisplayMode(CFbsDrawDevice* aDrawDevice)
       
    55 	{
       
    56 	CopyOldSettings(aDrawDevice);
       
    57 	}
       
    58 
       
    59 void CDrawScreenBitmap::OrientationsAvailable(TBool aOrientation[4])
       
    60 	{
       
    61 	aOrientation[EOrientationNormal] = ETrue;
       
    62 	aOrientation[EOrientationRotated90] = ETrue;
       
    63 	aOrientation[EOrientationRotated180] = ETrue;
       
    64 	aOrientation[EOrientationRotated270] = ETrue;
       
    65 	}
       
    66 
       
    67 TBool CDrawScreenBitmap::SetOrientation(TOrientation aOrientation)
       
    68 	{
       
    69 	iOrientation = aOrientation;
       
    70 	return ETrue;
       
    71 	}
       
    72 
       
    73 TInt CDrawScreenBitmap::HorzTwipsPerThousandPixels() const
       
    74 	{
       
    75 	if (iSize.iWidth == 0)
       
    76 		return 0;
       
    77 
       
    78 	TInt twips = 0;
       
    79 	HAL::Get(iScreenNo, HALData::EDisplayXTwips,twips);
       
    80 
       
    81 	return twips * 1000 / iSize.iWidth; // iSize gets iWidth and iHeight swapped by changing the orientation so always use iWidth
       
    82 	}
       
    83 
       
    84 TInt CDrawScreenBitmap::VertTwipsPerThousandPixels() const
       
    85 	{
       
    86 	if (iSize.iHeight == 0)
       
    87 		return 0;
       
    88 
       
    89 	TInt twips = 0;
       
    90 	HAL::Get(iScreenNo, HALData::EDisplayYTwips,twips);
       
    91 
       
    92 	return twips * 1000 / iSize.iHeight;
       
    93 	}
       
    94