os/graphics/graphicsdeviceinterface/screendriver/swins/SCCOL8.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 CDrawEightBppScreenBitmapColor::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 	window->iPalette = iPalette;
    28 
    29 	return KErrNone;
    30 	}
    31 
    32 TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette)
    33 	{
    34 	const TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette);
    35 
    36 	if(::WindowHandler(iScreenNo)->iDisplayMode==DisplayMode())
    37 		::WindowHandler(iScreenNo)->iPalette = iPalette;
    38 
    39 	if (ret == KErrNone)
    40 		{
    41 		CFbsDrawDevice* thisPtr = this;
    42 		TRegionFix<1> rgnSize(iSize);
    43 		thisPtr->Update(rgnSize); // Can't access Update directly because the most-derived implementation is private.
    44 		}
    45 
    46 	return ret;
    47 	}
    48 
    49 TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation)
    50 	{
    51 	if (aOrientation == iEmulatorOrientation)
    52 		return ETrue;
    53 
    54 	SetScreenOrientation(aOrientation);
    55 	iEmulatorOrientation = aOrientation;
    56 	iOrientation = aOrientation ;
    57 	return ETrue;
    58 	}
    59 
    60 void CDrawEightBppScreenBitmapColor::UpdateRect(const TRect& aRect) const
    61 	{
    62 	ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
    63 #if defined(_DEBUG)
    64 	if (iOrientation&1)
    65 		{
    66 		ASSERT(aRect.iBr.iX <= iSize.iHeight);
    67 		ASSERT(aRect.iBr.iY <= iSize.iWidth);
    68 		}
    69 	else
    70 		{
    71 		ASSERT(aRect.iBr.iX <= iSize.iWidth);
    72 		ASSERT(aRect.iBr.iY <= iSize.iHeight);
    73 		}
    74 #endif
    75 	TInt scanLineLen=iLongWidth;
    76 	TInt srcPixelStep=1;
    77 	TPoint srcStart(aRect.iTl);
    78 	switch(iOrientation)
    79 		{
    80 	case CFbsDrawDevice::EOrientationRotated90:
    81 		srcPixelStep=scanLineLen;
    82 		scanLineLen=-1;
    83 		srcStart.iX=iSize.iWidth-1-aRect.iTl.iY;
    84 		srcStart.iY=aRect.iTl.iX;
    85 		break;
    86 	case CFbsDrawDevice::EOrientationRotated180:
    87 		srcPixelStep=-1;
    88 		scanLineLen=-scanLineLen;
    89 		srcStart.iX=iSize.iWidth-1-aRect.iTl.iX;
    90 		srcStart.iY=iSize.iHeight-1-aRect.iTl.iY;
    91 		break;
    92 	case CFbsDrawDevice::EOrientationRotated270:
    93 		srcPixelStep=-scanLineLen;
    94 		scanLineLen=1;
    95 		srcStart.iX=aRect.iTl.iY;
    96 		srcStart.iY=iSize.iHeight-1-aRect.iTl.iX;
    97 		break;
    98 		}
    99 	TUint8* srcePtr = PixelAddress(srcStart.iX,srcStart.iY);
   100 	TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep;
   101 	TInt rowMax = aRect.iTl.iY+aRect.Height();
   102 	for(TInt row = aRect.iTl.iY; row < rowMax; row++)
   103 		{
   104 		TUint8* tempSrcePtr = srcePtr;
   105 		TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row);
   106 
   107 		while (tempSrcePtr != srcePtrLimit)
   108 			{
   109 			TRgb pixelColor = IndexToColor(*tempSrcePtr);
   110 			destPixel[0] = TUint8(pixelColor.Blue());
   111 			destPixel[1] = TUint8(pixelColor.Green());
   112 			destPixel[2] = TUint8(pixelColor.Red());
   113 
   114 			tempSrcePtr+=srcPixelStep;
   115 			destPixel += 3;
   116 			}
   117 
   118 		srcePtr += scanLineLen;
   119 		srcePtrLimit += scanLineLen;
   120 		}
   121 	}
   122