1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserverplugins/openwfc/inc/displaypolicy.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,170 @@
1.4 +// Copyright (c) 2008-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 +#ifndef CDISPLAYPOLICY_H
1.20 +#define CDISPLAYPOLICY_H
1.21 +
1.22 +// INCLUDES
1.23 +#include <e32std.h>
1.24 +#include <e32base.h>
1.25 +#include <graphics/displaycontrolbase.h>
1.26 +#include <graphics/displaymapping.h>
1.27 +#include <graphics/displayconfiguration.h>
1.28 +#include <graphics/wsdisplaypolicy.h>
1.29 +// CLASS DECLARATION
1.30 +enum TCoordinateSpace;
1.31 +class MWsGraphicDrawerEnvironment;
1.32 +class MWsScreen;
1.33 +class MWsScreenConfigList;
1.34 +class MWsIniFile;
1.35 +/**
1.36 + * CDisplayPolicy
1.37 + *
1.38 + */
1.39 +class CDisplayPolicy : public CBase
1.40 + {
1.41 +public:
1.42 + enum TUiScaling
1.43 + {
1.44 + ENone= 0,
1.45 + EInteger= 1,
1.46 + EIsotropic= 2,
1.47 + EAnisotropic= 3
1.48 + };
1.49 + // Constructors and destructor
1.50 +
1.51 + /**
1.52 + * Destructor.
1.53 + */
1.54 + ~CDisplayPolicy();
1.55 +
1.56 + /**
1.57 + * Two-phased constructor.
1.58 + */
1.59 + static CDisplayPolicy* NewL(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber);
1.60 +
1.61 + /**
1.62 + * Two-phased constructor.
1.63 + */
1.64 + static CDisplayPolicy* NewLC(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber);
1.65 +
1.66 + void NewAppModesAvailable();
1.67 + void GetAppModeList();
1.68 + TInt MapCoordinates(TCoordinateSpace aSourceSpace, const TRect& aSource,
1.69 + TCoordinateSpace aTargetSpace, TRect& aTarget) const;
1.70 + void AddVirtualResolutionCount(TInt& aDisplayCount) const;
1.71 + TInt AddVirtualResolutions(RArray<MDisplayControlBase::TResolution>& aResolutions) const;
1.72 + MDisplayControlBase::TResolution AppModeToResolution(RArray<MDisplayControlBase::TResolution>& aResolutions,TInt appMode)const;
1.73 + TInt GetSizeModeConfiguration(RArray<MDisplayControlBase::TResolution>& aResolutions,TInt aScreenSizeMode,
1.74 + TDisplayConfiguration& aConfig, TRect& aSizeModePosition) const;
1.75 +
1.76 + /*
1.77 + * Used when display is disconnected.
1.78 + */
1.79 + TInt GetSizeModeConfiguration(TInt aScreenSizeMode,TDisplayConfiguration& aConfig, TRect& aSizeModePosition);
1.80 + TBool SettingConfiguration(const RArray<MDisplayControlBase::TResolution>& aResolutions,
1.81 + TDisplayConfiguration& aConfig)const;
1.82 + TBool PolicyEnabled()const{return (iUiScaling==ENone)?EFalse:ETrue;}
1.83 +
1.84 + void SetCompositionInfo (const TDisplayConfiguration& aCompositionConfig,const TDisplayConfiguration& aUiConfig);
1.85 + void SetSizeModeExtent(TRect& aExtent, TBitFlags32 /*aContext*/);
1.86 + void AdjustStageBufferSize(const TSize& aOldSize,TSize& aNewSize);
1.87 + void CalculateMinBufferSize(RArray<MDisplayControlBase::TResolution>& aResolutions, TInt aConnectionStatus);
1.88 + TInt SuitableAppMode(MWsDisplayPolicy::TDisplayStatus aSituation);
1.89 + void SetLastAppMode(TInt aMode);
1.90 +
1.91 + TSize GetUiResolution();
1.92 + TSize GetUiResolutionAsTwips() const;
1.93 + TRect GetPolicyAppMode();
1.94 +
1.95 +private:
1.96 +
1.97 + class TAppMode
1.98 + {
1.99 + public:
1.100 + TRect iPixels; //<Size and pisition in pixels
1.101 + TSize iTwips; //<Size in TWips
1.102 + TInt iFlags; //<Flags
1.103 + enum THighFlags //<Policy flags are per app mode. Lower bits are defined by MWsScreenConfigList::TModeFlags
1.104 + { //Currently none
1.105 + };
1.106 +
1.107 + //The app modes are presented based on Normal rotation to calculate correctly with display resolutions
1.108 + //which are always in normal rotation
1.109 + TInt iOrientations; //<Index bits via CFbsBitGc::TGraphicsOrientation
1.110 + TInt iModeIndex; //<Which screen mode index it refers to
1.111 +
1.112 + };
1.113 + /**
1.114 + * Constructor for performing 1st stage construction
1.115 + */
1.116 + CDisplayPolicy();
1.117 +
1.118 + /**
1.119 + * EPOC default constructor for performing 2nd stage construction
1.120 + */
1.121 + void ConstructL(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber);
1.122 + TBool FindVirtualMode(const RArray<MDisplayControlBase::TResolution>& aResolutions,
1.123 + const CDisplayPolicy::TAppMode& aAppMode,TSize& aFullAppModeSize,TInt& aIndex,TInt& aBestScale) const;
1.124 +
1.125 + TSize ResolutionSize(RArray<MDisplayControlBase::TResolution>& aResolutions, const TSize aBestAppSize,
1.126 + TInt aIndex, TInt aScale) const;
1.127 + TSize ResolutionSizeFromTwips(RArray<MDisplayControlBase::TResolution>& aResolutions, TInt aAppMode,const TSize& aBestAppSize,
1.128 + TInt aIndex,TBool aSwapAxis) const;
1.129 + TSize ResolutionSizeFromAssumedTwips(RArray<MDisplayControlBase::TResolution>& aResolutions,const TSize& aBestAppSize,
1.130 + TInt aIndex,TBool aSwapAxis,TInt aScale) const;
1.131 +
1.132 + TBool MatchConfigToResolutions(const RArray<MDisplayControlBase::TResolution>& aResolutions,
1.133 + const TDisplayConfiguration& aConfig, TInt aStartIndex, TInt& aResolutionIndex)const;
1.134 + TBool SetConfigToResolution(TInt aAppMode, MDisplayControlBase::TResolution aResolution, TDisplayConfiguration& aConfig)const;
1.135 + void CenteredAppInUi(const TSize& aUiSize,const TRect& aAppExtent,TRect& aSizeModePosition) const;
1.136 + TInt MapCompositionToUi(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const;
1.137 + void MapUiToApplication(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const;
1.138 + TInt MapUiToDSA(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const;
1.139 + void GetModeInfoL(const MWsScreenConfigList& aList,TInt aIndex,TPoint& aOffset,TSize& aSize,TAppMode& aMode) const;
1.140 + TInt MinSizedModeIndex();
1.141 + /** Used when calculating how to map app mode to hardware resolutions
1.142 + Rounds up when .5
1.143 + */
1.144 + class TFraction
1.145 + {
1.146 + public:
1.147 + TFraction();
1.148 + TInt operator*(TInt aInt) const;
1.149 + public:
1.150 + TInt iNumer;
1.151 + TInt iDenom;
1.152 + };
1.153 +private:
1.154 + RArray<TAppMode> iAppModes;
1.155 + TInt iUiScaling;
1.156 + MWsIniFile* iScreenIniFile;
1.157 + MWsScreen* iScreen;
1.158 + TSize iUiSizePixels;
1.159 + TRect iAppSizePixels;
1.160 + TSize iAppSizeTwips;
1.161 + TSize iCompositionSizeTwips;
1.162 + TSize iCompositionSizePixels;
1.163 + TSize iMinUiBufferSize;
1.164 + TInt iNumNormalAppModes;
1.165 + TInt iLastAppMode;
1.166 + TInt iConnectionStatus;
1.167 + TInt iSmallestAppMode;
1.168 + TSize iSmallestAppSize;
1.169 + TDisplayConfiguration::TRotation iLastUiRotation;
1.170 + TDisplayConfiguration::TRotation iLastCompositionRotation;
1.171 + };
1.172 +
1.173 +#endif // CDISPLAYPOLICY_H