os/graphics/graphicsdeviceinterface/screendriver/swins/SCCOL32A.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 CDrawThirtyTwoBppScreenBitmapAlpha::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 TBool CDrawThirtyTwoBppScreenBitmapAlpha::SetOrientation(TOrientation aOrientation)
    32 	{
    33 	if (aOrientation == iEmulatorOrientation)
    34 		return ETrue;
    35 
    36 	SetScreenOrientation(aOrientation);
    37 	iEmulatorOrientation = aOrientation;
    38 	iOrientation = aOrientation ;
    39 	return ETrue;
    40 	}
    41 
    42 void CDrawThirtyTwoBppScreenBitmapAlpha::UpdateRect(const TRect& aRect) const
    43 	{
    44 	ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
    45 #if defined(_DEBUG)
    46 	if (iOrientation&1)
    47 		{
    48 		ASSERT(aRect.iBr.iX <= iSize.iHeight);
    49 		ASSERT(aRect.iBr.iY <= iSize.iWidth);
    50 		}
    51 	else
    52 		{
    53 		ASSERT(aRect.iBr.iX <= iSize.iWidth);
    54 		ASSERT(aRect.iBr.iY <= iSize.iHeight);
    55 		}
    56 #endif
    57 	TInt scanLineLen=iLongWidth*4;
    58 	TInt srcPixelStep=4;
    59 	TPoint srcStart(aRect.iTl);
    60 	switch(iOrientation)
    61 		{
    62 	case CFbsDrawDevice::EOrientationRotated90:
    63 		srcPixelStep=scanLineLen;
    64 		scanLineLen=-4;
    65 		srcStart.iX=iSize.iWidth-1-aRect.iTl.iY;
    66 		srcStart.iY=aRect.iTl.iX;
    67 		break;
    68 	case CFbsDrawDevice::EOrientationRotated180:
    69 		srcPixelStep=-4;
    70 		scanLineLen=-scanLineLen;
    71 		srcStart.iX=iSize.iWidth-1-aRect.iTl.iX;
    72 		srcStart.iY=iSize.iHeight-1-aRect.iTl.iY;
    73 		break;
    74 	case CFbsDrawDevice::EOrientationRotated270:
    75 		srcPixelStep=-scanLineLen;
    76 		scanLineLen=4;
    77 		srcStart.iX=aRect.iTl.iY;
    78 		srcStart.iY=iSize.iHeight-1-aRect.iTl.iX;
    79 		break;
    80 		}
    81 	TUint8* srcePtr = (TUint8*)PixelAddress(srcStart.iX,srcStart.iY);
    82 	TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep;
    83 	TInt rowMax = aRect.iTl.iY+aRect.Height();
    84 	srcPixelStep-=3;	// as we increment while reading it
    85 	for(TInt row = aRect.iTl.iY; row < rowMax; row++)
    86 		{
    87 		TUint8* tempSrcePtr = srcePtr;
    88 		TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row);
    89 
    90 		while (tempSrcePtr != srcePtrLimit)
    91  			{
    92 			*destPixel++=*tempSrcePtr++;
    93 			*destPixel++=*tempSrcePtr++;
    94 			*destPixel++=*tempSrcePtr++;
    95 			tempSrcePtr += srcPixelStep;
    96  			}
    97  		srcePtr+=scanLineLen;
    98  		srcePtrLimit+=scanLineLen;
    99 		}
   100 	}