os/graphics/graphicsdeviceinterface/screendriver/smomap/sccol24u.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 // This module implements the class for a 24 bpp unpack color screen.
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20 */
    21 
    22 #include <hal.h>
    23 #include <e32std.h>
    24 #include <bitdraw.h>
    25 #include "scdraw.h"
    26 
    27 void CDrawUTwentyFourBppScreenBitmap::SetSize(const TSize& aSize) 
    28 	{
    29     CDrawBitmap::SetSize(aSize);
    30     __ASSERT_DEBUG(iSize == aSize, User::Invariant());
    31 	iLongWidth = iScanLineWords;
    32 	}
    33 
    34 void CDrawUTwentyFourBppScreenBitmap::SetDisplayMode(CFbsDrawDevice* aDrawDevice)
    35 	{
    36 	CopyOldSettings(aDrawDevice);
    37 	InitScreen();
    38 	}
    39 
    40 TInt CDrawUTwentyFourBppScreenBitmap::HorzTwipsPerThousandPixels() const
    41 	{
    42 	if (iSize.iWidth == 0)
    43 		return 0;
    44 	
    45     TInt displayMode;
    46     TInt r = HAL::Get(iScreenNo, HAL::EDisplayMode, displayMode);
    47     if (r != KErrNone)
    48     	return 0;
    49     
    50     TInt width = displayMode;
    51     r = HAL::Get(iScreenNo, HAL::EDisplayXTwips, width);
    52 	if (r != KErrNone)
    53     	return 0;
    54    
    55     return (width * 1000) / iSize.iWidth;
    56 	}
    57 
    58 TInt CDrawUTwentyFourBppScreenBitmap::VertTwipsPerThousandPixels() const
    59 	{
    60 	if (iSize.iHeight == 0)
    61 		return 0;
    62 
    63     TInt displayMode;
    64     TInt r = HAL::Get(iScreenNo, HAL::EDisplayMode, displayMode);
    65     if (r != KErrNone)
    66     	return 0;
    67     TInt height = displayMode;
    68     r = HAL::Get(iScreenNo, HAL::EDisplayYTwips, height);
    69     if (r != KErrNone)
    70     	return 0;
    71 
    72     return (height * 1000) / iSize.iHeight;
    73 	}
    74 
    75 
    76 TInt CDrawUTwentyFourBppScreenBitmap::InitScreen()
    77 	{
    78 	return KErrNone;
    79 	}
    80 
    81 
    82 TInt CDrawUTwentyFourBppScreenBitmap::ConstructScreenL(TInt aScreenNo, TAny* aBitmapAddress, TSize aSize)
    83 	{
    84     iScreenNo = aScreenNo;
    85     TInt displayMode;
    86     TInt ret = HAL::Get(aScreenNo, HALData::EDisplayMode, displayMode);
    87     if (ret != KErrNone)
    88     	return ret;
    89     
    90     TInt linepitchInBytes = displayMode;
    91     ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetBetweenLines,linepitchInBytes);
    92     if (ret != KErrNone)
    93     	return ret;
    94         
    95 	iScanLineWords = linepitchInBytes / 4;
    96 	ret = CDrawUTwentyFourBppBitmap::Construct(aSize);
    97 	if (ret != KErrNone)
    98 		return ret;
    99 	
   100 	TInt offsetToFirstPixel = displayMode;
   101 	ret = HAL::Get(aScreenNo,HALData::EDisplayOffsetToFirstPixel, offsetToFirstPixel);
   102 	if (ret != KErrNone)
   103 		return ret;
   104     
   105 	iBits = (TUint32*)((TUint32)aBitmapAddress + offsetToFirstPixel);
   106 	return KErrNone;
   107 	}
   108 
   109 
   110 
   111 void CDrawUTwentyFourBppScreenBitmap::OrientationsAvailable(TBool aOrientation[4])
   112 	{
   113 	aOrientation[EOrientationNormal]     = ETrue;
   114 	aOrientation[EOrientationRotated90]  = ETrue;
   115 	aOrientation[EOrientationRotated180] = ETrue;
   116 	aOrientation[EOrientationRotated270] = ETrue;
   117 	}
   118 
   119 TBool CDrawUTwentyFourBppScreenBitmap::SetOrientation(TOrientation aOrientation)
   120 	{
   121 	iOrientation = aOrientation ;
   122 	return ETrue ;
   123 	}
   124