diff -r 000000000000 -r bde4ae8d615e os/graphics/windowing/windowserverplugins/openwfc/inc/displaypolicy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/graphics/windowing/windowserverplugins/openwfc/inc/displaypolicy.h Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,170 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef CDISPLAYPOLICY_H +#define CDISPLAYPOLICY_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +// CLASS DECLARATION +enum TCoordinateSpace; +class MWsGraphicDrawerEnvironment; +class MWsScreen; +class MWsScreenConfigList; +class MWsIniFile; +/** + * CDisplayPolicy + * + */ +class CDisplayPolicy : public CBase + { +public: + enum TUiScaling + { + ENone= 0, + EInteger= 1, + EIsotropic= 2, + EAnisotropic= 3 + }; + // Constructors and destructor + + /** + * Destructor. + */ + ~CDisplayPolicy(); + + /** + * Two-phased constructor. + */ + static CDisplayPolicy* NewL(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber); + + /** + * Two-phased constructor. + */ + static CDisplayPolicy* NewLC(MWsGraphicDrawerEnvironment* aEnv,MWsScreen* aScreen,TInt aScreenNumber); + + void NewAppModesAvailable(); + void GetAppModeList(); + TInt MapCoordinates(TCoordinateSpace aSourceSpace, const TRect& aSource, + TCoordinateSpace aTargetSpace, TRect& aTarget) const; + void AddVirtualResolutionCount(TInt& aDisplayCount) const; + TInt AddVirtualResolutions(RArray& aResolutions) const; + MDisplayControlBase::TResolution AppModeToResolution(RArray& aResolutions,TInt appMode)const; + TInt GetSizeModeConfiguration(RArray& aResolutions,TInt aScreenSizeMode, + TDisplayConfiguration& aConfig, TRect& aSizeModePosition) const; + + /* + * Used when display is disconnected. + */ + TInt GetSizeModeConfiguration(TInt aScreenSizeMode,TDisplayConfiguration& aConfig, TRect& aSizeModePosition); + TBool SettingConfiguration(const RArray& aResolutions, + TDisplayConfiguration& aConfig)const; + TBool PolicyEnabled()const{return (iUiScaling==ENone)?EFalse:ETrue;} + + void SetCompositionInfo (const TDisplayConfiguration& aCompositionConfig,const TDisplayConfiguration& aUiConfig); + void SetSizeModeExtent(TRect& aExtent, TBitFlags32 /*aContext*/); + void AdjustStageBufferSize(const TSize& aOldSize,TSize& aNewSize); + void CalculateMinBufferSize(RArray& aResolutions, TInt aConnectionStatus); + TInt SuitableAppMode(MWsDisplayPolicy::TDisplayStatus aSituation); + void SetLastAppMode(TInt aMode); + + TSize GetUiResolution(); + TSize GetUiResolutionAsTwips() const; + TRect GetPolicyAppMode(); + +private: + + class TAppMode + { + public: + TRect iPixels; //& aResolutions, + const CDisplayPolicy::TAppMode& aAppMode,TSize& aFullAppModeSize,TInt& aIndex,TInt& aBestScale) const; + + TSize ResolutionSize(RArray& aResolutions, const TSize aBestAppSize, + TInt aIndex, TInt aScale) const; + TSize ResolutionSizeFromTwips(RArray& aResolutions, TInt aAppMode,const TSize& aBestAppSize, + TInt aIndex,TBool aSwapAxis) const; + TSize ResolutionSizeFromAssumedTwips(RArray& aResolutions,const TSize& aBestAppSize, + TInt aIndex,TBool aSwapAxis,TInt aScale) const; + + TBool MatchConfigToResolutions(const RArray& aResolutions, + const TDisplayConfiguration& aConfig, TInt aStartIndex, TInt& aResolutionIndex)const; + TBool SetConfigToResolution(TInt aAppMode, MDisplayControlBase::TResolution aResolution, TDisplayConfiguration& aConfig)const; + void CenteredAppInUi(const TSize& aUiSize,const TRect& aAppExtent,TRect& aSizeModePosition) const; + TInt MapCompositionToUi(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const; + void MapUiToApplication(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const; + TInt MapUiToDSA(const TRect& aSource, TRect& aTarget, TBool aIsReverseMapping) const; + void GetModeInfoL(const MWsScreenConfigList& aList,TInt aIndex,TPoint& aOffset,TSize& aSize,TAppMode& aMode) const; + TInt MinSizedModeIndex(); + /** Used when calculating how to map app mode to hardware resolutions + Rounds up when .5 + */ + class TFraction + { + public: + TFraction(); + TInt operator*(TInt aInt) const; + public: + TInt iNumer; + TInt iDenom; + }; +private: + RArray iAppModes; + TInt iUiScaling; + MWsIniFile* iScreenIniFile; + MWsScreen* iScreen; + TSize iUiSizePixels; + TRect iAppSizePixels; + TSize iAppSizeTwips; + TSize iCompositionSizeTwips; + TSize iCompositionSizePixels; + TSize iMinUiBufferSize; + TInt iNumNormalAppModes; + TInt iLastAppMode; + TInt iConnectionStatus; + TInt iSmallestAppMode; + TSize iSmallestAppSize; + TDisplayConfiguration::TRotation iLastUiRotation; + TDisplayConfiguration::TRotation iLastCompositionRotation; + }; + +#endif // CDISPLAYPOLICY_H