os/graphics/graphicsdeviceinterface/screendriver/swins/SCCOL8.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/swins/SCCOL8.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,122 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "SCDRAW.H"
    1.20 +#include "_WININC.H"
    1.21 +
    1.22 +TInt CDrawEightBppScreenBitmapColor::InitScreen()
    1.23 +	{
    1.24 +	TRect drawRect;
    1.25 +	GetDrawRect(drawRect);
    1.26 +    RWindows* window = ::WindowHandler(iScreenNo);
    1.27 +	window->iDisplayMode = DisplayMode();
    1.28 +	window->iEpocBitmapSize = drawRect.Size();
    1.29 +	window->iEpocBitmapLinePitch = (iScanLineWords*4);
    1.30 +	window->iPalette = iPalette;
    1.31 +
    1.32 +	return KErrNone;
    1.33 +	}
    1.34 +
    1.35 +TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette)
    1.36 +	{
    1.37 +	const TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette);
    1.38 +
    1.39 +	if(::WindowHandler(iScreenNo)->iDisplayMode==DisplayMode())
    1.40 +		::WindowHandler(iScreenNo)->iPalette = iPalette;
    1.41 +
    1.42 +	if (ret == KErrNone)
    1.43 +		{
    1.44 +		CFbsDrawDevice* thisPtr = this;
    1.45 +		TRegionFix<1> rgnSize(iSize);
    1.46 +		thisPtr->Update(rgnSize); // Can't access Update directly because the most-derived implementation is private.
    1.47 +		}
    1.48 +
    1.49 +	return ret;
    1.50 +	}
    1.51 +
    1.52 +TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation)
    1.53 +	{
    1.54 +	if (aOrientation == iEmulatorOrientation)
    1.55 +		return ETrue;
    1.56 +
    1.57 +	SetScreenOrientation(aOrientation);
    1.58 +	iEmulatorOrientation = aOrientation;
    1.59 +	iOrientation = aOrientation ;
    1.60 +	return ETrue;
    1.61 +	}
    1.62 +
    1.63 +void CDrawEightBppScreenBitmapColor::UpdateRect(const TRect& aRect) const
    1.64 +	{
    1.65 +	ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
    1.66 +#if defined(_DEBUG)
    1.67 +	if (iOrientation&1)
    1.68 +		{
    1.69 +		ASSERT(aRect.iBr.iX <= iSize.iHeight);
    1.70 +		ASSERT(aRect.iBr.iY <= iSize.iWidth);
    1.71 +		}
    1.72 +	else
    1.73 +		{
    1.74 +		ASSERT(aRect.iBr.iX <= iSize.iWidth);
    1.75 +		ASSERT(aRect.iBr.iY <= iSize.iHeight);
    1.76 +		}
    1.77 +#endif
    1.78 +	TInt scanLineLen=iLongWidth;
    1.79 +	TInt srcPixelStep=1;
    1.80 +	TPoint srcStart(aRect.iTl);
    1.81 +	switch(iOrientation)
    1.82 +		{
    1.83 +	case CFbsDrawDevice::EOrientationRotated90:
    1.84 +		srcPixelStep=scanLineLen;
    1.85 +		scanLineLen=-1;
    1.86 +		srcStart.iX=iSize.iWidth-1-aRect.iTl.iY;
    1.87 +		srcStart.iY=aRect.iTl.iX;
    1.88 +		break;
    1.89 +	case CFbsDrawDevice::EOrientationRotated180:
    1.90 +		srcPixelStep=-1;
    1.91 +		scanLineLen=-scanLineLen;
    1.92 +		srcStart.iX=iSize.iWidth-1-aRect.iTl.iX;
    1.93 +		srcStart.iY=iSize.iHeight-1-aRect.iTl.iY;
    1.94 +		break;
    1.95 +	case CFbsDrawDevice::EOrientationRotated270:
    1.96 +		srcPixelStep=-scanLineLen;
    1.97 +		scanLineLen=1;
    1.98 +		srcStart.iX=aRect.iTl.iY;
    1.99 +		srcStart.iY=iSize.iHeight-1-aRect.iTl.iX;
   1.100 +		break;
   1.101 +		}
   1.102 +	TUint8* srcePtr = PixelAddress(srcStart.iX,srcStart.iY);
   1.103 +	TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep;
   1.104 +	TInt rowMax = aRect.iTl.iY+aRect.Height();
   1.105 +	for(TInt row = aRect.iTl.iY; row < rowMax; row++)
   1.106 +		{
   1.107 +		TUint8* tempSrcePtr = srcePtr;
   1.108 +		TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row);
   1.109 +
   1.110 +		while (tempSrcePtr != srcePtrLimit)
   1.111 +			{
   1.112 +			TRgb pixelColor = IndexToColor(*tempSrcePtr);
   1.113 +			destPixel[0] = TUint8(pixelColor.Blue());
   1.114 +			destPixel[1] = TUint8(pixelColor.Green());
   1.115 +			destPixel[2] = TUint8(pixelColor.Red());
   1.116 +
   1.117 +			tempSrcePtr+=srcPixelStep;
   1.118 +			destPixel += 3;
   1.119 +			}
   1.120 +
   1.121 +		srcePtr += scanLineLen;
   1.122 +		srcePtrLimit += scanLineLen;
   1.123 +		}
   1.124 +	}
   1.125 +