os/graphics/graphicsdeviceinterface/screendriver/smint/SCCOL.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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 "scdraw.h"
sl@0
    18
sl@0
    19
/**
sl@0
    20
Constructs the CDrawScreenBitmap object.
sl@0
    21
@param aScreenNo Screen number. It will be used in HAL::Get() calls.
sl@0
    22
@param aBitmapAddress The screen memory address.
sl@0
    23
@param aSize Screen size
sl@0
    24
@return System-wide error codes, KErrNone if the construction was successfull.
sl@0
    25
*/
sl@0
    26
TInt CDrawScreenBitmap::ConstructScreen(TInt aScreenNo, TAny* aBitmapAddress,TSize aSize)
sl@0
    27
	{
sl@0
    28
    iScreenNo = aScreenNo;
sl@0
    29
	TInt ret = SCREEN_LAYOUT_BASE_BITMAP::Construct(aSize);
sl@0
    30
	if (ret != KErrNone)
sl@0
    31
		return ret;
sl@0
    32
sl@0
    33
	//fixup for emulating smaller screen
sl@0
    34
	TInt offset = 0;
sl@0
    35
	ret = HAL::Get(iScreenNo, HALData::EDisplayOffsetBetweenLines, offset);
sl@0
    36
	if (ret == KErrNone && (offset != aSize.iWidth))
sl@0
    37
		{
sl@0
    38
		iLongWidth = offset;
sl@0
    39
		iScanLineWords = iLongWidth / 4;
sl@0
    40
		User::Heap().Free(iScanLineBuffer);
sl@0
    41
		iScanLineBuffer = (TUint32*)(User::Heap().Alloc(offset));
sl@0
    42
		if(iScanLineBuffer == NULL)
sl@0
    43
			return KErrNoMemory;
sl@0
    44
		}
sl@0
    45
	//fixup for emulating smaller screen
sl@0
    46
sl@0
    47
	offset = 0; // Pass in display mode
sl@0
    48
	ret = HAL::Get(iScreenNo, HALData::EDisplayOffsetToFirstPixel,offset);
sl@0
    49
	iBits = (TUint32*)aBitmapAddress;
sl@0
    50
	iBits += offset / sizeof(TUint32);
sl@0
    51
	return ret;
sl@0
    52
	}
sl@0
    53
sl@0
    54
void CDrawScreenBitmap::SetDisplayMode(CFbsDrawDevice* aDrawDevice)
sl@0
    55
	{
sl@0
    56
	CopyOldSettings(aDrawDevice);
sl@0
    57
	}
sl@0
    58
sl@0
    59
void CDrawScreenBitmap::OrientationsAvailable(TBool aOrientation[4])
sl@0
    60
	{
sl@0
    61
	aOrientation[EOrientationNormal] = ETrue;
sl@0
    62
	aOrientation[EOrientationRotated90] = ETrue;
sl@0
    63
	aOrientation[EOrientationRotated180] = ETrue;
sl@0
    64
	aOrientation[EOrientationRotated270] = ETrue;
sl@0
    65
	}
sl@0
    66
sl@0
    67
TBool CDrawScreenBitmap::SetOrientation(TOrientation aOrientation)
sl@0
    68
	{
sl@0
    69
	iOrientation = aOrientation;
sl@0
    70
	return ETrue;
sl@0
    71
	}
sl@0
    72
sl@0
    73
TInt CDrawScreenBitmap::HorzTwipsPerThousandPixels() const
sl@0
    74
	{
sl@0
    75
	if (iSize.iWidth == 0)
sl@0
    76
		return 0;
sl@0
    77
sl@0
    78
	TInt twips = 0;
sl@0
    79
	HAL::Get(iScreenNo, HALData::EDisplayXTwips,twips);
sl@0
    80
sl@0
    81
	return twips * 1000 / iSize.iWidth; // iSize gets iWidth and iHeight swapped by changing the orientation so always use iWidth
sl@0
    82
	}
sl@0
    83
sl@0
    84
TInt CDrawScreenBitmap::VertTwipsPerThousandPixels() const
sl@0
    85
	{
sl@0
    86
	if (iSize.iHeight == 0)
sl@0
    87
		return 0;
sl@0
    88
sl@0
    89
	TInt twips = 0;
sl@0
    90
	HAL::Get(iScreenNo, HALData::EDisplayYTwips,twips);
sl@0
    91
sl@0
    92
	return twips * 1000 / iSize.iHeight;
sl@0
    93
	}
sl@0
    94