os/graphics/windowing/windowserverplugins/openwfc/inc/displaypolicy.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-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 #ifndef CDISPLAYPOLICY_H
    17 #define CDISPLAYPOLICY_H
    18 
    19 // INCLUDES
    20 #include <e32std.h>
    21 #include <e32base.h>
    22 #include <graphics/displaycontrolbase.h>
    23 #include <graphics/displaymapping.h>
    24 #include <graphics/displayconfiguration.h>
    25 #include <graphics/wsdisplaypolicy.h>
    26 // CLASS DECLARATION
    27 enum TCoordinateSpace;
    28 class MWsGraphicDrawerEnvironment;
    29 class MWsScreen;
    30 class MWsScreenConfigList;
    31 class MWsIniFile;
    32 /**
    33  *  CDisplayPolicy
    34  * 
    35  */
    36 class CDisplayPolicy : public CBase
    37 	{
    38 public:
    39 	enum	TUiScaling
    40 		{
    41 		ENone=			0,
    42 		EInteger=		1,
    43 		EIsotropic=		2,
    44 		EAnisotropic=	3		
    45 		};
    46 	// Constructors and destructor
    47 
    48 	/**
    49 	 * Destructor.
    50 	 */
    51 	~CDisplayPolicy();
    52 
    53 	/**
    54 	 * Two-phased constructor.
    55 	 */
    56 	static CDisplayPolicy* NewL(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber);
    57 
    58 	/**
    59 	 * Two-phased constructor.
    60 	 */
    61 	static CDisplayPolicy* NewLC(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber);
    62 
    63 	void NewAppModesAvailable();
    64 	void GetAppModeList();
    65 	TInt MapCoordinates(TCoordinateSpace aSourceSpace, const TRect& aSource, 
    66 			TCoordinateSpace aTargetSpace, TRect& aTarget) const;
    67 	void AddVirtualResolutionCount(TInt& aDisplayCount) const; 
    68 	TInt AddVirtualResolutions(RArray<MDisplayControlBase::TResolution>& aResolutions) const;
    69 	MDisplayControlBase::TResolution AppModeToResolution(RArray<MDisplayControlBase::TResolution>& aResolutions,TInt appMode)const;
    70 	TInt GetSizeModeConfiguration(RArray<MDisplayControlBase::TResolution>& aResolutions,TInt aScreenSizeMode, 
    71 			TDisplayConfiguration& aConfig, TRect& aSizeModePosition) const;
    72 	
    73 	/*
    74 	 * Used when display is disconnected.
    75 	 */
    76 	TInt GetSizeModeConfiguration(TInt aScreenSizeMode,TDisplayConfiguration& aConfig, TRect& aSizeModePosition);
    77 	TBool SettingConfiguration(const RArray<MDisplayControlBase::TResolution>& aResolutions,
    78 			TDisplayConfiguration& aConfig)const;
    79 	TBool PolicyEnabled()const{return (iUiScaling==ENone)?EFalse:ETrue;}
    80 	
    81 	void SetCompositionInfo (const TDisplayConfiguration& aCompositionConfig,const TDisplayConfiguration& aUiConfig);
    82 	void SetSizeModeExtent(TRect& aExtent, TBitFlags32 /*aContext*/);
    83 	void	AdjustStageBufferSize(const TSize& aOldSize,TSize& aNewSize);
    84 	void	CalculateMinBufferSize(RArray<MDisplayControlBase::TResolution>& aResolutions, TInt aConnectionStatus);
    85 	TInt 	SuitableAppMode(MWsDisplayPolicy::TDisplayStatus aSituation);
    86 	void 	SetLastAppMode(TInt aMode);
    87 	
    88 	TSize	GetUiResolution();
    89 	TSize   GetUiResolutionAsTwips() const;
    90 	TRect 	GetPolicyAppMode();
    91 
    92 private:
    93 
    94 	class TAppMode
    95 		{
    96 	public:
    97 		TRect	iPixels;	//<Size and pisition in pixels
    98 		TSize	iTwips;		//<Size in TWips
    99 		TInt	iFlags;		//<Flags
   100 		enum	THighFlags	//<Policy flags are per app mode. Lower bits are defined by MWsScreenConfigList::TModeFlags 
   101 			{		//Currently none
   102 			};
   103 		
   104 		//The app modes are presented based on Normal rotation to calculate correctly with display resolutions
   105 		//which are always in normal rotation
   106 		TInt	iOrientations;	//<Index bits via CFbsBitGc::TGraphicsOrientation
   107 		TInt	iModeIndex;	//<Which screen mode index it refers to
   108 		
   109 		};
   110 	/**
   111 	 * Constructor for performing 1st stage construction
   112 	 */
   113 	CDisplayPolicy();
   114 
   115 	/**
   116 	 * EPOC default constructor for performing 2nd stage construction
   117 	 */
   118 	void ConstructL(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber);
   119 	TBool FindVirtualMode(const RArray<MDisplayControlBase::TResolution>& aResolutions,
   120 			const CDisplayPolicy::TAppMode& aAppMode,TSize& aFullAppModeSize,TInt& aIndex,TInt& aBestScale) const;
   121 	
   122 	TSize ResolutionSize(RArray<MDisplayControlBase::TResolution>& aResolutions, const TSize aBestAppSize,
   123 			TInt aIndex, TInt aScale) const;
   124 	TSize ResolutionSizeFromTwips(RArray<MDisplayControlBase::TResolution>& aResolutions, TInt aAppMode,const TSize& aBestAppSize, 
   125 			TInt aIndex,TBool aSwapAxis) const;
   126 	TSize ResolutionSizeFromAssumedTwips(RArray<MDisplayControlBase::TResolution>& aResolutions,const TSize& aBestAppSize,
   127 			TInt aIndex,TBool aSwapAxis,TInt aScale) const;
   128 	
   129 	TBool MatchConfigToResolutions(const RArray<MDisplayControlBase::TResolution>& aResolutions,
   130 			const TDisplayConfiguration& aConfig, TInt aStartIndex, TInt& aResolutionIndex)const;
   131 	TBool SetConfigToResolution(TInt aAppMode, MDisplayControlBase::TResolution aResolution, TDisplayConfiguration& aConfig)const;
   132 	void CenteredAppInUi(const TSize& aUiSize,const TRect& aAppExtent,TRect& aSizeModePosition) const;
   133 	TInt MapCompositionToUi(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const;
   134 	void MapUiToApplication(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const;
   135 	TInt MapUiToDSA(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const;
   136 	void GetModeInfoL(const MWsScreenConfigList& aList,TInt aIndex,TPoint& aOffset,TSize& aSize,TAppMode& aMode) const;
   137 	TInt MinSizedModeIndex();
   138 	/** Used when calculating how to map app mode to hardware resolutions
   139 		Rounds up when .5
   140 	*/
   141 	class TFraction
   142 		{
   143 	public:
   144 		TFraction();
   145 		TInt operator*(TInt aInt) const;
   146 	public:
   147 		TInt iNumer;
   148 		TInt iDenom;
   149 		};
   150 private:
   151 	RArray<TAppMode>	iAppModes;
   152 	TInt iUiScaling;
   153 	MWsIniFile* iScreenIniFile;
   154 	MWsScreen* iScreen;
   155 	TSize iUiSizePixels;
   156 	TRect iAppSizePixels;
   157 	TSize iAppSizeTwips;
   158 	TSize iCompositionSizeTwips;
   159 	TSize iCompositionSizePixels;
   160 	TSize	iMinUiBufferSize;
   161 	TInt 	iNumNormalAppModes;
   162 	TInt	iLastAppMode;
   163 	TInt 	iConnectionStatus;
   164 	TInt 	iSmallestAppMode;
   165 	TSize 	iSmallestAppSize;
   166 	TDisplayConfiguration::TRotation iLastUiRotation;
   167 	TDisplayConfiguration::TRotation iLastCompositionRotation;
   168 	};
   169 
   170 #endif // CDISPLAYPOLICY_H