os/graphics/graphicsdeviceinterface/screendriver/swins/SCMON2.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 "SCDRAW.H"
sl@0
    17
#include "_WININC.H"
sl@0
    18
sl@0
    19
TInt CDrawTwoBppScreenBitmap::InitScreen()
sl@0
    20
	{
sl@0
    21
	TRect drawRect;
sl@0
    22
	GetDrawRect(drawRect);
sl@0
    23
    RWindows* window = ::WindowHandler(iScreenNo);
sl@0
    24
	window->iDisplayMode = DisplayMode();
sl@0
    25
	window->iEpocBitmapSize = drawRect.Size();
sl@0
    26
	window->iEpocBitmapLinePitch = (iScanLineWords*4);
sl@0
    27
sl@0
    28
	return KErrNone;
sl@0
    29
	}
sl@0
    30
sl@0
    31
void CDrawTwoBppScreenBitmap::OrientationsAvailable(TBool aOrientation[4])
sl@0
    32
	{
sl@0
    33
	aOrientation[EOrientationNormal] = ETrue;
sl@0
    34
	aOrientation[EOrientationRotated90] = EFalse;
sl@0
    35
	aOrientation[EOrientationRotated180] = EFalse;
sl@0
    36
	aOrientation[EOrientationRotated270] = EFalse;
sl@0
    37
	}
sl@0
    38
sl@0
    39
void CDrawTwoBppScreenBitmap::UpdateRect(const TRect& aRect) const
sl@0
    40
	{
sl@0
    41
	ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
sl@0
    42
	ASSERT(aRect.iBr.iX <= iSize.iWidth);
sl@0
    43
	ASSERT(aRect.iBr.iY <= iSize.iHeight);
sl@0
    44
sl@0
    45
	const TUint8 gray4lookup[4] = {0, 85, 170, 255};
sl@0
    46
sl@0
    47
	TInt lx = aRect.iTl.iX & ~0xf;
sl@0
    48
	TInt rx = (aRect.iBr.iX + 15) & ~0xf;
sl@0
    49
sl@0
    50
	TUint8* srcePtr = ((TUint8*)(ScanLine(aRect.iTl.iY))) + (lx / 4);
sl@0
    51
	TUint8* srcePtrLimit = srcePtr + ((rx - lx) / 4);
sl@0
    52
sl@0
    53
	TInt byteWidth = iScanLineWords * 4;
sl@0
    54
sl@0
    55
	for(TInt row = aRect.iTl.iY; row < aRect.iBr.iY; row++)
sl@0
    56
		{
sl@0
    57
		TUint8* tempSrcePtr = srcePtr;
sl@0
    58
		TUint8* destPixel = WinPixelAddress(lx,row);
sl@0
    59
sl@0
    60
		while (tempSrcePtr < srcePtrLimit)
sl@0
    61
			{
sl@0
    62
			TUint8 pixelValue1 = *tempSrcePtr++;
sl@0
    63
			TUint8 pixelValue2 = TUint8((pixelValue1 >> 2) & 0x03);
sl@0
    64
			TUint8 pixelValue3 = TUint8((pixelValue1 >> 4) & 0x03);
sl@0
    65
			TUint8 pixelValue4 = TUint8((pixelValue1 >> 6) & 0x03);
sl@0
    66
			pixelValue1 &= 0x03;
sl@0
    67
sl@0
    68
			TUint8 pixelGray = gray4lookup[pixelValue1];
sl@0
    69
			destPixel[0] = pixelGray;
sl@0
    70
			destPixel[1] = pixelGray;
sl@0
    71
			destPixel[2] = pixelGray;
sl@0
    72
sl@0
    73
			pixelGray = gray4lookup[pixelValue2];
sl@0
    74
			destPixel[3] = pixelGray;
sl@0
    75
			destPixel[4] = pixelGray;
sl@0
    76
			destPixel[5] = pixelGray;
sl@0
    77
sl@0
    78
			pixelGray = gray4lookup[pixelValue3];
sl@0
    79
			destPixel[6] = pixelGray;
sl@0
    80
			destPixel[7] = pixelGray;
sl@0
    81
			destPixel[8] = pixelGray;
sl@0
    82
sl@0
    83
			pixelGray = gray4lookup[pixelValue4];
sl@0
    84
			destPixel[9] = pixelGray;
sl@0
    85
			destPixel[10] = pixelGray;
sl@0
    86
			destPixel[11] = pixelGray;
sl@0
    87
sl@0
    88
			destPixel += 12;
sl@0
    89
			}
sl@0
    90
sl@0
    91
		srcePtr += byteWidth;
sl@0
    92
		srcePtrLimit += byteWidth;
sl@0
    93
		}
sl@0
    94
	}
sl@0
    95