sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "SCDRAW.H" sl@0: #include "_WININC.H" sl@0: sl@0: TInt CDrawEightBppScreenBitmapColor::InitScreen() sl@0: { sl@0: TRect drawRect; sl@0: GetDrawRect(drawRect); sl@0: RWindows* window = ::WindowHandler(iScreenNo); sl@0: window->iDisplayMode = DisplayMode(); sl@0: window->iEpocBitmapSize = drawRect.Size(); sl@0: window->iEpocBitmapLinePitch = (iScanLineWords*4); sl@0: window->iPalette = iPalette; sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette) sl@0: { sl@0: const TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette); sl@0: sl@0: if(::WindowHandler(iScreenNo)->iDisplayMode==DisplayMode()) sl@0: ::WindowHandler(iScreenNo)->iPalette = iPalette; sl@0: sl@0: if (ret == KErrNone) sl@0: { sl@0: CFbsDrawDevice* thisPtr = this; sl@0: TRegionFix<1> rgnSize(iSize); sl@0: thisPtr->Update(rgnSize); // Can't access Update directly because the most-derived implementation is private. sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation) sl@0: { sl@0: if (aOrientation == iEmulatorOrientation) sl@0: return ETrue; sl@0: sl@0: SetScreenOrientation(aOrientation); sl@0: iEmulatorOrientation = aOrientation; sl@0: iOrientation = aOrientation ; sl@0: return ETrue; sl@0: } sl@0: sl@0: void CDrawEightBppScreenBitmapColor::UpdateRect(const TRect& aRect) const sl@0: { sl@0: ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0); sl@0: #if defined(_DEBUG) sl@0: if (iOrientation&1) sl@0: { sl@0: ASSERT(aRect.iBr.iX <= iSize.iHeight); sl@0: ASSERT(aRect.iBr.iY <= iSize.iWidth); sl@0: } sl@0: else sl@0: { sl@0: ASSERT(aRect.iBr.iX <= iSize.iWidth); sl@0: ASSERT(aRect.iBr.iY <= iSize.iHeight); sl@0: } sl@0: #endif sl@0: TInt scanLineLen=iLongWidth; sl@0: TInt srcPixelStep=1; sl@0: TPoint srcStart(aRect.iTl); sl@0: switch(iOrientation) sl@0: { sl@0: case CFbsDrawDevice::EOrientationRotated90: sl@0: srcPixelStep=scanLineLen; sl@0: scanLineLen=-1; sl@0: srcStart.iX=iSize.iWidth-1-aRect.iTl.iY; sl@0: srcStart.iY=aRect.iTl.iX; sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated180: sl@0: srcPixelStep=-1; sl@0: scanLineLen=-scanLineLen; sl@0: srcStart.iX=iSize.iWidth-1-aRect.iTl.iX; sl@0: srcStart.iY=iSize.iHeight-1-aRect.iTl.iY; sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated270: sl@0: srcPixelStep=-scanLineLen; sl@0: scanLineLen=1; sl@0: srcStart.iX=aRect.iTl.iY; sl@0: srcStart.iY=iSize.iHeight-1-aRect.iTl.iX; sl@0: break; sl@0: } sl@0: TUint8* srcePtr = PixelAddress(srcStart.iX,srcStart.iY); sl@0: TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep; sl@0: TInt rowMax = aRect.iTl.iY+aRect.Height(); sl@0: for(TInt row = aRect.iTl.iY; row < rowMax; row++) sl@0: { sl@0: TUint8* tempSrcePtr = srcePtr; sl@0: TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row); sl@0: sl@0: while (tempSrcePtr != srcePtrLimit) sl@0: { sl@0: TRgb pixelColor = IndexToColor(*tempSrcePtr); sl@0: destPixel[0] = TUint8(pixelColor.Blue()); sl@0: destPixel[1] = TUint8(pixelColor.Green()); sl@0: destPixel[2] = TUint8(pixelColor.Red()); sl@0: sl@0: tempSrcePtr+=srcPixelStep; sl@0: destPixel += 3; sl@0: } sl@0: sl@0: srcePtr += scanLineLen; sl@0: srcePtrLimit += scanLineLen; sl@0: } sl@0: } sl@0: