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