1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/smomap/sccol8.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,145 @@
1.4 +// Copyright (c) 2003-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 +// This module implemente the class use for a 8 bpp color screen.
1.18 +// Include files
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 +*/
1.25 +/********************************************************************/
1.26 +#include <bitdraw.h>
1.27 +#include "scdraw.h"
1.28 +#include <hal.h>
1.29 +
1.30 +/********************************************************************/
1.31 +/* Implementation of CDrawEightBppScreenBitmapColor class */
1.32 +/********************************************************************/
1.33 +void CDrawEightBppScreenBitmapColor::SetSize(const TSize& aSize)
1.34 + {
1.35 + CDrawBitmap::SetSize(aSize);
1.36 + __ASSERT_DEBUG(iSize == aSize, User::Invariant());
1.37 + iLongWidth = CDrawBitmap::iScanLineWords * 4;
1.38 + }
1.39 +void CDrawEightBppScreenBitmapColor::SetDisplayMode(CFbsDrawDevice* aDrawDevice)
1.40 + {
1.41 + CopyOldSettings(aDrawDevice) ;
1.42 + InitScreen() ;
1.43 + }
1.44 +
1.45 +TInt CDrawEightBppScreenBitmapColor::HorzTwipsPerThousandPixels() const
1.46 + {
1.47 + if (iSize.iWidth == 0)
1.48 + return 0 ;
1.49 + TMachineInfoV1Buf miBuf ;
1.50 + UserHal::MachineInfo(miBuf) ;
1.51 + return miBuf().iPhysicalScreenSize.iWidth * 1000 / iSize.iWidth ;
1.52 + }
1.53 +
1.54 +TInt CDrawEightBppScreenBitmapColor::VertTwipsPerThousandPixels() const
1.55 + {
1.56 + if (iSize.iHeight == 0)
1.57 + return 0 ;
1.58 +
1.59 + TMachineInfoV1Buf miBuf ;
1.60 + UserHal::MachineInfo(miBuf) ;
1.61 + return miBuf().iPhysicalScreenSize.iHeight * 1000 / iSize.iHeight ;
1.62 + }
1.63 +
1.64 +/**
1.65 +Initialises the palette
1.66 +*/
1.67 +TInt CDrawEightBppScreenBitmapColor::InitScreen()
1.68 + {
1.69 +
1.70 + __ASSERT_ALWAYS(iPaletteAddress!=NULL, Panic(EScreenDriverPanicNullPointer)) ;
1.71 +
1.72 + /* Fill the palette to support 8 Bpp color */
1.73 + TUint16* palettePtr = iPaletteAddress ;
1.74 + for (TInt count = 0; count < KEightBppPaletteEntries; count++)
1.75 + *palettePtr++ = TRgb::Color256(count)._Color4K() | KEightBppPixelBitSize ;
1.76 +
1.77 + return KErrNone ;
1.78 + }
1.79 +
1.80 +/**
1.81 +Constructs the CDrawEightBppScreenBitmapColor object.
1.82 +@param aScreenNo Screen number. It will be used in HAL::Get() calls.
1.83 +@param aBitmapAddress The screen memory address.
1.84 +@param aSize Screen size
1.85 +@return System-wide error codes, KErrNone if the construction was successfull.
1.86 +*/
1.87 +TInt CDrawEightBppScreenBitmapColor::ConstructScreenL(TInt aScreenNo, TAny* aBitmapAddress, TSize aSize)
1.88 + {
1.89 + iScreenNo = aScreenNo;
1.90 + TInt displayMode;
1.91 +
1.92 + TInt ret = HAL::Get(aScreenNo, HALData::EDisplayMode, displayMode);
1.93 + if (ret != KErrNone)
1.94 + return ret;
1.95 +
1.96 + TInt linepitchInBytes = displayMode;
1.97 + ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetBetweenLines,linepitchInBytes);
1.98 + if (ret != KErrNone)
1.99 + return ret;
1.100 +
1.101 + CDrawBitmap::iScanLineWords = linepitchInBytes / 4;
1.102 + ret = CDrawEightBppBitmapColor::Construct(aSize);
1.103 + if (ret != KErrNone)
1.104 + return ret ;
1.105 +
1.106 + /* Set the pointer on the first palette entry */
1.107 + iPaletteAddress = (TUint16*)aBitmapAddress ;
1.108 +
1.109 + TInt offsetToFirstPixel = displayMode;
1.110 + ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetToFirstPixel, offsetToFirstPixel);
1.111 + if (ret != KErrNone)
1.112 + return ret;
1.113 + iBits = (TUint32*)((TUint32)aBitmapAddress + offsetToFirstPixel);
1.114 +
1.115 + return KErrNone ;
1.116 + }
1.117 +
1.118 +void CDrawEightBppScreenBitmapColor::OrientationsAvailable(TBool aOrientation[4])
1.119 + {
1.120 + aOrientation[EOrientationNormal] = ETrue ;
1.121 + aOrientation[EOrientationRotated90] = ETrue ;
1.122 + aOrientation[EOrientationRotated180] = ETrue ;
1.123 + aOrientation[EOrientationRotated270] = ETrue ;
1.124 + }
1.125 +
1.126 +TBool CDrawEightBppScreenBitmapColor::SetOrientation(TOrientation aOrientation)
1.127 + {
1.128 + iOrientation = aOrientation ;
1.129 + return ETrue ;
1.130 + }
1.131 +
1.132 +TInt CDrawEightBppScreenBitmapColor::SetCustomPalette(const CPalette* aPalette)
1.133 + {
1.134 + TInt ret = CDrawEightBppBitmapColor::SetCustomPalette(aPalette) ;
1.135 +
1.136 + if (ret == KErrNone)
1.137 + {
1.138 + TInt index = 0 ;
1.139 + TUint16* palettePtr = iPaletteAddress ;
1.140 + const TUint16* const palettePtrLimit = iPaletteAddress + KEightBppPaletteEntries ;
1.141 +
1.142 + *palettePtr++ = IndexToColor(index++)._Color4K() | KEightBppPixelBitSize ;
1.143 +
1.144 + while (palettePtr < palettePtrLimit)
1.145 + *palettePtr++ = IndexToColor(index++)._Color4K() ;
1.146 + }
1.147 + return ret ;
1.148 + }