os/graphics/windowing/windowserver/nonnga/SERVER/screen.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/nonnga/SERVER/screen.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,377 @@
     1.4 +// Copyright (c) 2004-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 +// Defines the screen class (was in scrdev.h)
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __SCREEN_H__
    1.22 +#define __SCREEN_H__
    1.23 +
    1.24 +#include <e32std.h>
    1.25 +#include <e32base.h>
    1.26 +#include <w32std.h>	
    1.27 +#include "w32cmd.h"
    1.28 +#include "wstypes.h"
    1.29 +
    1.30 +#include <Graphics/WSGRAPHICDRAWERINTERFACE.H>
    1.31 +
    1.32 +class CWsDirectScreenAccess;
    1.33 +
    1.34 +class CWsOffScreenBitmap;
    1.35 +class CWsWindowGroup;
    1.36 +class CWsWindow;
    1.37 +class CWsRootWindow;
    1.38 +class CWsClientWindow;
    1.39 +class CDebugBar;
    1.40 +class CScreenRedraw;
    1.41 +class CWsSpriteManager;
    1.42 +
    1.43 +class CScreen : public CBase, public MWsScreen, public MWsScreenConfig, public MWsFrontBuffer
    1.44 +	{
    1.45 +	enum {EDefaultShadowX=2};
    1.46 +	enum {EDefaultShadowY=2};
    1.47 +public:
    1.48 +	enum {EGetScanLineBufLen=0x100};	// Buffer of for returning result of GetScanLine
    1.49 +	enum {EMaxNumModes=EColorLast-2};		// Number of available devices in the GDI enum TDisplayMode
    1.50 +	enum TDisplayScreen
    1.51 +		{
    1.52 +		EBlankScreenOnRotation = 0x1,
    1.53 +		EAutoClear = 0x2,
    1.54 +		EBltOffScreenBitmap = 0x04,			// Refrain from clearing window to default background color
    1.55 +		};
    1.56 +	/**
    1.57 +	The fallback map is an array of 32 bit integers sufficiently large to store a single bit for any
    1.58 +	possible orientation and size of the screen, with the pixel rows padded to the end of the int.
    1.59 +	Andy - This is only used by the screen redraw, so it should be in the screen redraw, not the screen.
    1.60 +	Also, it doesnt need its own region, since the root window has the correct region already.
    1.61 +	*/
    1.62 +	class CFallbackMap : public CBase
    1.63 +		{
    1.64 +	public:
    1.65 +		static CFallbackMap * NewL(CScreen* aScreen);
    1.66 +		~CFallbackMap();
    1.67 +		
    1.68 +		void Prepare();
    1.69 +		TBool FillRegion(const TRegion& aRegion);
    1.70 +		TBool FillRect(const TRect& aRect);
    1.71 +		TInt Count() const;
    1.72 +		const TRect * Rect() const;
    1.73 +		const RRegion * Region() const;
    1.74 +
    1.75 +	private:	
    1.76 +		CFallbackMap(CScreen* aScreen);
    1.77 +		void ConstructL();
    1.78 +		
    1.79 +	public:
    1.80 +		CScreen* iScreen;
    1.81 +		RRegionBuf<1> iRegion;
    1.82 +		TInt iCount;
    1.83 +		TInt iMapSize; // size in padded TInts
    1.84 +		TInt * iMap;
    1.85 +		};
    1.86 +public:
    1.87 +	CScreen();
    1.88 +	~CScreen();
    1.89 +	void ConstructL( const TRect& aDigitiserArea, TInt aScreenNumber );
    1.90 +	void AbortAllDirectDrawing(RDirectScreenAccess::TTerminationReasons aReason);
    1.91 +	void AddDirect(CWsDirectScreenAccess& aDirect);
    1.92 +	void RemoveDirect(CWsDirectScreenAccess& aDirect);
    1.93 +	void AbortDSAs(RDirectScreenAccess::TTerminationReasons aReason,TSglQue<CWsDirectScreenAccess>& aDirects);
    1.94 +#if defined(_DEBUG)
    1.95 +	TBool IsDirectOnQueue(const CWsDirectScreenAccess* aDirect);
    1.96 +#if defined(__WINS__)
    1.97 +	void UpdateOffScreenBitmap();
    1.98 +#endif
    1.99 +#endif
   1.100 +
   1.101 +	inline CWsWindowGroup* FocusWindowGroup();
   1.102 +	void KillForegroundSession();
   1.103 +	void ResetFocus(CWsWindowGroup *aClosingWindow);
   1.104 +	void SetShadowVector(const TPoint &aShadowShift);
   1.105 +	inline TPoint ShadowVector();
   1.106 +	inline TBool BlankScreenOnRotation();
   1.107 +	inline TBool AutoClear();
   1.108 +	void RemoveFromDefaultOwningList(CWsWindowGroup *aDestroyedGroup);
   1.109 +	void SetDefaultOwningWindow(CWsWindowGroup *aGroup);
   1.110 +	inline CWsWindowGroup *DefaultOwningWindowGroup();
   1.111 +
   1.112 +	void CheckDisplayMode(TBool aUpdateNow);
   1.113 +	CFbsScreenDevice *ScreenDevice();
   1.114 +	inline CWsRootWindow* RootWindow() const;
   1.115 +	inline TInt ScreenNumber() const;
   1.116 +	void Update();
   1.117 +	void Update(const TRegion &aRegion);
   1.118 +	inline TDisplayMode CurrentDisplayMode();
   1.119 +	inline TDisplayMode DefaultDisplayMode();
   1.120 +	inline TDisplayMode DefaultDisplayMode(const TInt aMode) const;
   1.121 +	TDisplayMode FirstDefaultDisplayMode() const;
   1.122 +	//
   1.123 +	inline CFbsBitGc *ScreenGdi();
   1.124 +	void MaxNumColors(TInt& aColors,TInt& aGrays);
   1.125 +	TInt ColorModesFlag();
   1.126 +	inline void GetFadingParams(TUint8& aBlackMap,TUint8& aWhiteMap) const;
   1.127 +	inline void SetFadingParams(TUint8 aBlackMap,TUint8 aWhiteMap);
   1.128 +	void GetScanLine(const TWsSdCmdGetScanLine *aGetScanLine);
   1.129 +
   1.130 +	TBool SetScreenModeEnforcement(TInt aMode);
   1.131 +	inline TInt ScreenSizeMode() const;
   1.132 +	void SetPointerCursorArea(TInt aMode,const TRect& aRect);
   1.133 +	inline TRect GetPointerCursorArea(TInt aMode) const;
   1.134 +	CFbsBitGc::TGraphicsOrientation Orientation();
   1.135 +	void CycleDisplaySize();
   1.136 +	void UpdateOrientation();
   1.137 +	void doSetScreenMode(TInt aMode);
   1.138 +	inline TSize CurrentScreenSize() const;
   1.139 +	TRect DrawableArea() const;
   1.140 +	void CycleOrientation();
   1.141 +	TClientPanic SetModeRotation(TInt aMode,CFbsBitGc::TGraphicsOrientation aRotation);
   1.142 +	void LoadScreenSizesL(TSize aScreenSize);
   1.143 +	void LoadScreenSizeProperties();
   1.144 +	void LoadScreenScale();
   1.145 +	void SetDigitiserAreas(const TSize& aScreenSize,const TRect& aDigitiserArea);
   1.146 +	inline TInt NumScreenSizeModes() const;
   1.147 +	inline const TSizeMode& ScreenSizeModeData() const;
   1.148 +	inline const TSizeMode& ScreenSizeModeData(TInt aMode) const;
   1.149 +	inline TPoint ScreenModeOrigin(TInt aMode);
   1.150 +	inline TPoint CurrentScreenModeOrigin();
   1.151 +	inline TSize CurrentScreenModeScale();
   1.152 +	inline TPoint CurrentScreenModeScaledOrigin();
   1.153 +	inline TPoint ScreenModeScaledOrigin(TInt aMode);
   1.154 +	inline TScreenModeEnforcement SizeEnforcementMode() const;
   1.155 +	void GetScreenSizeAndRotation(TPixelsTwipsAndRotation &aSar, TInt aScreenMode);
   1.156 +	void GetScreenSizeAndRotation(TPixelsAndRotation &aSar, TInt aScreenMode);
   1.157 +	inline TSize GetScreenScale(TInt aMode) const;
   1.158 +	inline void SetCurrentScreenModeAttributes(const TSizeMode &aModeData);
   1.159 +	inline TSize GetPhysicalScreenSize();
   1.160 +	inline void SetPhysicalScreenSize();
   1.161 +	inline TBool ShouldSwapWidthAndHeightOffScBitmap(TInt aOldRotation);
   1.162 +	inline TInt Modes();
   1.163 +	CFbsDevice * DrawDevice();
   1.164 +	CWsOffScreenBitmap* OffScreenBitmap();
   1.165 +	void FreeOffScreenBitmap();
   1.166 +	void UpdateGcs();
   1.167 +	inline void SetScalingFactor();
   1.168 +	void UpdateOffScreenBitmapGc(const TBool aSwapWidthAndHeight);
   1.169 +	TPoint PhysicalToLogical(TPoint aPhysicalPt);
   1.170 +	void IncContrast();
   1.171 +	void DecContrast();
   1.172 +	void IncBrightness();
   1.173 +	void DecBrightness();
   1.174 +	inline TBool IsValidScreenSizeMode(TInt aMode);
   1.175 +	TInt GetScreenSizeModeListL();
   1.176 +	void SetDisplayModeFromName(const TDesC& aModeName, TDisplayMode& aMode);
   1.177 +	CFbsDevice* GetFbsDevice();
   1.178 +	// called by CWsGc when it is implementing MWsGc
   1.179 +	const TTime& Now() const;
   1.180 +	void ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop);
   1.181 +	// redraw scheduling code
   1.182 +	void AddRedrawRegion(const TRegion& aRegion, TBool aSchedule = ETrue, TRedrawDepth aDepth = ERedrawAll);
   1.183 +	void DoRedrawNow();
   1.184 +	void ScheduleRegionUpdate(const TRegion* aDefinitelyDirty);
   1.185 +	void EndClientBuffer();
   1.186 +	// implementing MWsScreen
   1.187 +	void OnAnimation();
   1.188 +	void Redraw();
   1.189 +	TBool RedrawInvalid(const TArray<TGraphicDrawerId>& aInvalid);
   1.190 +	inline TBool BackLightFlag();
   1.191 +	// implementing interface extension
   1.192 +	TAny* ResolveObjectInterface(TUint aTypeId);
   1.193 +	// implementing MWsScreenConfig interface	
   1.194 +	TDisplayMode DisplayMode() const;
   1.195 +	TSize SizeInPixels() const;
   1.196 +	TSize ScreenModeSizeInPixels() const;
   1.197 +	TInt Stride() const;
   1.198 +	CFbsBitGc::TGraphicsOrientation Orientation() const;
   1.199 +	TInt SizeMode() const;
   1.200 +	TSize ScalingFactor() const;
   1.201 +	TPoint Origin() const;
   1.202 +	TPoint ScaledOrigin() const;
   1.203 +	// implementing MWsFrontBuffer
   1.204 +	const TAny* GetBits();
   1.205 +	CFbsBitGc* GetBitGc();
   1.206 +	CFbsBitGc* GetBitGcCurrent();
   1.207 +	TInt SetBitGc(CFbsBitGc* aBitGc);
   1.208 +	TInt SetBitGc(CFbsBitGc* aBitGc, TBool aInvalidateScreen);
   1.209 +	inline TBool IsOffScreenBitmap();
   1.210 +	inline TBool MaskingEnabled();
   1.211 +	inline TBool BltOffScreen();
   1.212 +	void RecalcHeights();
   1.213 +	void DiscardAllSchedules();
   1.214 +	inline CDebugBar * DebugBar();
   1.215 +	inline CFallbackMap * FallbackMap();
   1.216 +	inline CWsSpriteManager* SpriteManager();
   1.217 +	inline MWsFader* Fader();
   1.218 +	TBool IsUpdatePending();
   1.219 +	void DSARegionSyncStart( CWsDirectScreenAccess& aDSA );
   1.220 +	void DSARegionSyncOver( CWsDirectScreenAccess& aDSA );
   1.221 +	TBool HasVisibleDirectOnQueue();
   1.222 +	TBool IsDSAClientWindow( const CWsClientWindow* aWin ) const;
   1.223 +	void AcceptFadeRequest( CWsWindow* aWin, TBool	aIsFaded, TBool aIsBehind, TBool aIncludeChildren = EFalse );
   1.224 +
   1.225 +private:
   1.226 +	enum TSyncConsts
   1.227 +		{
   1.228 +		KDSAAbortingImmediateRespAwaitFrameMicrosec = 80000		// 0.08 sec
   1.229 +		};
   1.230 +private:
   1.231 +	void ChangeDisplayModeForAllOffScreenBitmap(TBool aSwapWidthAndHeight=EFalse);
   1.232 +	void SetInitialScreenSizeMode();
   1.233 +	CWsWindowGroup* FindNewFocus(CWsRootWindow* aRootWindow);
   1.234 +	void CreateFallbackMapL();
   1.235 +	void CreateScreenDeviceL();
   1.236 +	TBool DoCreateScreenDevice(TDisplayMode aScreenMode);
   1.237 +private:
   1.238 +	enum
   1.239 +		{
   1.240 +		eTimerCreated=0x1,
   1.241 +		};
   1.242 +	enum TDsaDrawState
   1.243 +		{
   1.244 +		EDsaDrawStateIdle,
   1.245 +		EDsaDrawStateDrawing
   1.246 +		};
   1.247 +private:
   1.248 +	TSglQue<CWsDirectScreenAccess> iDirects;
   1.249 +	RTimer iTimer;
   1.250 +	TRequestStatus iTimerStatus;
   1.251 +	TUint iFlags;
   1.252 +
   1.253 +	CScreenRedraw* iRedraw;
   1.254 +
   1.255 +	CWsRootWindow* iRootWindow;
   1.256 +	CWsWindowGroup *iCurrentFocus;
   1.257 +	CWsWindowGroup *iDefaultOwningWindow;
   1.258 +	CWsOffScreenBitmap* iOffScreenBitmap;
   1.259 +	TPoint iShadowShift;
   1.260 +
   1.261 +	CFbsScreenDevice *iScreenDevice;
   1.262 +	CFbsBitGc *iScreenGdi;
   1.263 +
   1.264 +// Size and roation members
   1.265 +	RPointerArray<TSizeMode> *iModes;
   1.266 +	TInt iScreenSizeMode;
   1.267 +	TScreenModeEnforcement iSizeEnforcementMode;
   1.268 +	TSize iPhysicalScreenSize;
   1.269 +	TInt iScreenNumber;
   1.270 +	TInt iMaxContrast;
   1.271 +	TInt iMaxBrightness;
   1.272 +	TInt iNumScreenSizeModes;
   1.273 +	TInt iNumSupportedScreenSizeModes;
   1.274 +	TBool iBackLightFlag;
   1.275 +	
   1.276 +	// used by MWsFrontBuffer to redirect screen output
   1.277 +	CFbsBitGc* iRedirectGc;
   1.278 +
   1.279 +	TDsaDrawState iDsaDrawState;
   1.280 +	CDebugBar* iDebugBar;
   1.281 +	CFallbackMap* iFallbackMap;
   1.282 +	TUint8 iBlackMap;
   1.283 +	TUint8 iWhiteMap;
   1.284 +	CWsSpriteManager* iSpriteManager;
   1.285 +	MWsFader* iFader;
   1.286 +	};
   1.287 +
   1.288 +
   1.289 +
   1.290 +//
   1.291 +// inlines			//
   1.292 +//
   1.293 +
   1.294 +//
   1.295 +// CScreen
   1.296 +//
   1.297 +inline void CScreen::Update(const TRegion &aRegion)
   1.298 +	{iScreenDevice->Update(aRegion);}
   1.299 +inline TPoint CScreen::ShadowVector()
   1.300 +	{return(iShadowShift);}
   1.301 +inline CWsWindowGroup* CScreen::FocusWindowGroup()
   1.302 +	{return(iCurrentFocus);}
   1.303 +inline TBool CScreen::BlankScreenOnRotation()
   1.304 +	{return(iFlags&EBlankScreenOnRotation);}
   1.305 +inline TBool CScreen::AutoClear()
   1.306 +	{return(iFlags&EAutoClear);}
   1.307 +inline CWsWindowGroup* CScreen::DefaultOwningWindowGroup()
   1.308 +	{return(iDefaultOwningWindow);}
   1.309 +
   1.310 +inline CWsRootWindow* CScreen::RootWindow() const
   1.311 +	{return iRootWindow;}
   1.312 +inline TInt CScreen::ScreenNumber() const
   1.313 +	{return iScreenNumber;}
   1.314 +
   1.315 +inline CFbsBitGc *CScreen::ScreenGdi()
   1.316 +	{return(iScreenGdi);}
   1.317 +inline TDisplayMode CScreen::CurrentDisplayMode()
   1.318 +	{return iScreenDevice->DisplayMode();}
   1.319 +inline TDisplayMode CScreen::DefaultDisplayMode()
   1.320 +	{return iScreenDevice->DisplayMode();}
   1.321 +//
   1.322 +inline TInt CScreen::ScreenSizeMode() const
   1.323 +	{return(iScreenSizeMode);}
   1.324 +inline TRect CScreen::GetPointerCursorArea(TInt aMode) const
   1.325 +	{return (*iModes)[aMode]->iPointerCursorArea;}
   1.326 +inline TSize CScreen::CurrentScreenSize() const
   1.327 +	{return (*iModes)[iScreenSizeMode]->iScreenSize;}
   1.328 +inline TInt CScreen::NumScreenSizeModes() const
   1.329 +	{return iNumScreenSizeModes;}
   1.330 +inline const TSizeMode& CScreen::ScreenSizeModeData() const
   1.331 +	{return *(*iModes)[iScreenSizeMode];}
   1.332 +inline const TSizeMode& CScreen::ScreenSizeModeData(TInt aMode) const
   1.333 +	{return *(*iModes)[aMode];}
   1.334 +inline TPoint CScreen::ScreenModeOrigin(TInt aMode)
   1.335 +	{return (*iModes)[aMode]->iOrigin;}
   1.336 +inline TPoint CScreen::CurrentScreenModeOrigin()
   1.337 +	{return (*iModes)[iScreenSizeMode]->iOrigin;}
   1.338 +inline TSize CScreen::CurrentScreenModeScale()
   1.339 +	{return (*iModes)[iScreenSizeMode]->iScreenScale;}
   1.340 +inline TPoint CScreen::CurrentScreenModeScaledOrigin()
   1.341 +	{return (*iModes)[iScreenSizeMode]->ScaledOrigin();}
   1.342 +inline TPoint CScreen::ScreenModeScaledOrigin(TInt aMode)
   1.343 +	{return (*iModes)[aMode]->ScaledOrigin();}
   1.344 +inline TSize CScreen::GetScreenScale(TInt aMode) const
   1.345 +	{return (*iModes)[aMode]->iScreenScale;}
   1.346 +inline TDisplayMode CScreen::DefaultDisplayMode(const TInt aMode) const
   1.347 +	{return (*iModes)[aMode]->iDefaultDisplayMode;}
   1.348 +inline TSize CScreen::GetPhysicalScreenSize()
   1.349 +	{return iPhysicalScreenSize;}
   1.350 +inline void CScreen::SetScalingFactor()
   1.351 +	{iScreenDevice->SetScalingFactor((*iModes)[iScreenSizeMode]->iOrigin,(*iModes)[iScreenSizeMode]->iScreenScale.iWidth,(*iModes)[iScreenSizeMode]->iScreenScale.iHeight,1,1);}
   1.352 +inline void CScreen::SetCurrentScreenModeAttributes(const TSizeMode &aModeData)
   1.353 +	{*(*iModes)[iScreenSizeMode]=aModeData;}
   1.354 +inline void CScreen::SetPhysicalScreenSize()
   1.355 +	{TInt temp=iPhysicalScreenSize.iWidth;iPhysicalScreenSize.iWidth=iPhysicalScreenSize.iHeight;iPhysicalScreenSize.iHeight=temp;}
   1.356 +inline TScreenModeEnforcement CScreen::SizeEnforcementMode() const
   1.357 +	{return iSizeEnforcementMode;}
   1.358 +inline TBool CScreen::IsValidScreenSizeMode(TInt aMode)
   1.359 +	{return (aMode>=0 && aMode<iModes->Count() && (*iModes)[aMode]!=NULL);}
   1.360 +inline TBool CScreen::BackLightFlag()
   1.361 +	{return iBackLightFlag;}
   1.362 +inline TBool CScreen::IsOffScreenBitmap()
   1.363 +	{return iOffScreenBitmap!=NULL;}
   1.364 +
   1.365 +inline CDebugBar * CScreen::DebugBar()
   1.366 +	{return iDebugBar;}
   1.367 +inline CScreen::CFallbackMap * CScreen::FallbackMap()
   1.368 +	{return iFallbackMap;}
   1.369 +	
   1.370 +inline void CScreen::GetFadingParams(TUint8& aBlackMap,TUint8& aWhiteMap) const
   1.371 +    {aBlackMap=iBlackMap;aWhiteMap=iWhiteMap;}
   1.372 +inline void CScreen::SetFadingParams(TUint8 aBlackMap,TUint8 aWhiteMap)
   1.373 +	{iBlackMap=aBlackMap;iWhiteMap=aWhiteMap;}
   1.374 +inline CWsSpriteManager* CScreen::SpriteManager()
   1.375 +	{return iSpriteManager;}
   1.376 +inline MWsFader* CScreen::Fader()
   1.377 +	{return iFader;}
   1.378 +inline TBool CScreen::BltOffScreen()
   1.379 +	{return iFlags&EBltOffScreenBitmap;}
   1.380 +#endif