os/graphics/graphicsdeviceinterface/screendriver/smcot/SCCOL.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
	// get the offset in bytes
sl@0
    36
	ret = HAL::Get(iScreenNo, HALData::EDisplayOffsetBetweenLines, offset);
sl@0
    37
sl@0
    38
	TInt bitsPerPixel = BitsPerPixel(iDispMode);
sl@0
    39
 	TInt bytesPerPixel  = (bitsPerPixel/8 + (bitsPerPixel % 8 ? 1 : 0));
sl@0
    40
sl@0
    41
	if (ret == KErrNone )
sl@0
    42
		{
sl@0
    43
		// Find iLongwidth (in pixels) from the offset (in bytes).
sl@0
    44
		if (bitsPerPixel >= 8)
sl@0
    45
			{
sl@0
    46
			// a pixel fits in 1 or more bytes
sl@0
    47
		    iLongWidth =  offset / bytesPerPixel;
sl@0
    48
			}
sl@0
    49
			else
sl@0
    50
			{
sl@0
    51
			// 1 or more pixels per byte
sl@0
    52
			TInt pixelsPerByte  = 8 / bitsPerPixel;
sl@0
    53
		    iLongWidth =  offset * pixelsPerByte;
sl@0
    54
			}
sl@0
    55
		iScanLineWords = offset / 4;
sl@0
    56
		
sl@0
    57
		// correct the size of the ScanLineBuffer
sl@0
    58
		User::Heap().Free(iScanLineBuffer);
sl@0
    59
		iScanLineBuffer = (TUint32*)(User::Heap().Alloc(offset));
sl@0
    60
		if(iScanLineBuffer == NULL)
sl@0
    61
			return KErrNoMemory;
sl@0
    62
		}
sl@0
    63
	else
sl@0
    64
		{
sl@0
    65
		return ret;
sl@0
    66
		}
sl@0
    67
	//fixup for emulating smaller screen
sl@0
    68
sl@0
    69
	offset = 0; // Pass in display mode
sl@0
    70
	ret = HAL::Get(iScreenNo, HALData::EDisplayOffsetToFirstPixel,offset);
sl@0
    71
	iBits = (TUint32*)aBitmapAddress;
sl@0
    72
	iBits += offset / sizeof(TUint32);
sl@0
    73
	return ret;
sl@0
    74
	}
sl@0
    75
sl@0
    76
void CDrawScreenBitmap::SetDisplayMode(CFbsDrawDevice* aDrawDevice)
sl@0
    77
	{
sl@0
    78
	CopyOldSettings(aDrawDevice);
sl@0
    79
	}
sl@0
    80
sl@0
    81
void CDrawScreenBitmap::OrientationsAvailable(TBool aOrientation[4])
sl@0
    82
	{
sl@0
    83
	aOrientation[EOrientationNormal] = ETrue;
sl@0
    84
	aOrientation[EOrientationRotated90] = ETrue;
sl@0
    85
	aOrientation[EOrientationRotated180] = ETrue;
sl@0
    86
	aOrientation[EOrientationRotated270] = ETrue;
sl@0
    87
	}
sl@0
    88
sl@0
    89
TBool CDrawScreenBitmap::SetOrientation(TOrientation aOrientation)
sl@0
    90
	{
sl@0
    91
	iOrientation = aOrientation;
sl@0
    92
	return ETrue;
sl@0
    93
	}
sl@0
    94
sl@0
    95
TInt CDrawScreenBitmap::HorzTwipsPerThousandPixels() const
sl@0
    96
	{
sl@0
    97
	if (iSize.iWidth == 0)
sl@0
    98
		return 0;
sl@0
    99
sl@0
   100
	TInt twips = 0;
sl@0
   101
	HAL::Get(iScreenNo, HALData::EDisplayXTwips,twips);
sl@0
   102
sl@0
   103
	return twips * 1000 / iSize.iWidth; // iSize gets iWidth and iHeight swapped by changing the orientation so always use iWidth
sl@0
   104
	}
sl@0
   105
sl@0
   106
TInt CDrawScreenBitmap::VertTwipsPerThousandPixels() const
sl@0
   107
	{
sl@0
   108
	if (iSize.iHeight == 0)
sl@0
   109
		return 0;
sl@0
   110
sl@0
   111
	TInt twips = 0;
sl@0
   112
	HAL::Get(iScreenNo, HALData::EDisplayYTwips,twips);
sl@0
   113
sl@0
   114
	return twips * 1000 / iSize.iHeight;
sl@0
   115
	}
sl@0
   116