windowing/windowserver/nonnga/SERVER/screen.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2004-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 // Defines the screen class (was in scrdev.h)
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __SCREEN_H__
       
    19 #define __SCREEN_H__
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <e32base.h>
       
    23 #include <w32std.h>	
       
    24 #include "w32cmd.h"
       
    25 #include "wstypes.h"
       
    26 
       
    27 #include <Graphics/WSGRAPHICDRAWERINTERFACE.H>
       
    28 
       
    29 class CWsDirectScreenAccess;
       
    30 
       
    31 class CWsOffScreenBitmap;
       
    32 class CWsWindowGroup;
       
    33 class CWsWindow;
       
    34 class CWsRootWindow;
       
    35 class CWsClientWindow;
       
    36 class CDebugBar;
       
    37 class CScreenRedraw;
       
    38 class CWsSpriteManager;
       
    39 
       
    40 class CScreen : public CBase, public MWsScreen, public MWsScreenConfig, public MWsFrontBuffer
       
    41 	{
       
    42 	enum {EDefaultShadowX=2};
       
    43 	enum {EDefaultShadowY=2};
       
    44 public:
       
    45 	enum {EGetScanLineBufLen=0x100};	// Buffer of for returning result of GetScanLine
       
    46 	enum {EMaxNumModes=EColorLast-2};		// Number of available devices in the GDI enum TDisplayMode
       
    47 	enum TDisplayScreen
       
    48 		{
       
    49 		EBlankScreenOnRotation = 0x1,
       
    50 		EAutoClear = 0x2,
       
    51 		EBltOffScreenBitmap = 0x04,			// Refrain from clearing window to default background color
       
    52 		};
       
    53 	/**
       
    54 	The fallback map is an array of 32 bit integers sufficiently large to store a single bit for any
       
    55 	possible orientation and size of the screen, with the pixel rows padded to the end of the int.
       
    56 	Andy - This is only used by the screen redraw, so it should be in the screen redraw, not the screen.
       
    57 	Also, it doesnt need its own region, since the root window has the correct region already.
       
    58 	*/
       
    59 	class CFallbackMap : public CBase
       
    60 		{
       
    61 	public:
       
    62 		static CFallbackMap * NewL(CScreen* aScreen);
       
    63 		~CFallbackMap();
       
    64 		
       
    65 		void Prepare();
       
    66 		TBool FillRegion(const TRegion& aRegion);
       
    67 		TBool FillRect(const TRect& aRect);
       
    68 		TInt Count() const;
       
    69 		const TRect * Rect() const;
       
    70 		const RRegion * Region() const;
       
    71 
       
    72 	private:	
       
    73 		CFallbackMap(CScreen* aScreen);
       
    74 		void ConstructL();
       
    75 		
       
    76 	public:
       
    77 		CScreen* iScreen;
       
    78 		RRegionBuf<1> iRegion;
       
    79 		TInt iCount;
       
    80 		TInt iMapSize; // size in padded TInts
       
    81 		TInt * iMap;
       
    82 		};
       
    83 public:
       
    84 	CScreen();
       
    85 	~CScreen();
       
    86 	void ConstructL( const TRect& aDigitiserArea, TInt aScreenNumber );
       
    87 	void AbortAllDirectDrawing(RDirectScreenAccess::TTerminationReasons aReason);
       
    88 	void AddDirect(CWsDirectScreenAccess& aDirect);
       
    89 	void RemoveDirect(CWsDirectScreenAccess& aDirect);
       
    90 	void AbortDSAs(RDirectScreenAccess::TTerminationReasons aReason,TSglQue<CWsDirectScreenAccess>& aDirects);
       
    91 #if defined(_DEBUG)
       
    92 	TBool IsDirectOnQueue(const CWsDirectScreenAccess* aDirect);
       
    93 #if defined(__WINS__)
       
    94 	void UpdateOffScreenBitmap();
       
    95 #endif
       
    96 #endif
       
    97 
       
    98 	inline CWsWindowGroup* FocusWindowGroup();
       
    99 	void KillForegroundSession();
       
   100 	void ResetFocus(CWsWindowGroup *aClosingWindow);
       
   101 	void SetShadowVector(const TPoint &aShadowShift);
       
   102 	inline TPoint ShadowVector();
       
   103 	inline TBool BlankScreenOnRotation();
       
   104 	inline TBool AutoClear();
       
   105 	void RemoveFromDefaultOwningList(CWsWindowGroup *aDestroyedGroup);
       
   106 	void SetDefaultOwningWindow(CWsWindowGroup *aGroup);
       
   107 	inline CWsWindowGroup *DefaultOwningWindowGroup();
       
   108 
       
   109 	void CheckDisplayMode(TBool aUpdateNow);
       
   110 	CFbsScreenDevice *ScreenDevice();
       
   111 	inline CWsRootWindow* RootWindow() const;
       
   112 	inline TInt ScreenNumber() const;
       
   113 	void Update();
       
   114 	void Update(const TRegion &aRegion);
       
   115 	inline TDisplayMode CurrentDisplayMode();
       
   116 	inline TDisplayMode DefaultDisplayMode();
       
   117 	inline TDisplayMode DefaultDisplayMode(const TInt aMode) const;
       
   118 	TDisplayMode FirstDefaultDisplayMode() const;
       
   119 	//
       
   120 	inline CFbsBitGc *ScreenGdi();
       
   121 	void MaxNumColors(TInt& aColors,TInt& aGrays);
       
   122 	TInt ColorModesFlag();
       
   123 	inline void GetFadingParams(TUint8& aBlackMap,TUint8& aWhiteMap) const;
       
   124 	inline void SetFadingParams(TUint8 aBlackMap,TUint8 aWhiteMap);
       
   125 	void GetScanLine(const TWsSdCmdGetScanLine *aGetScanLine);
       
   126 
       
   127 	TBool SetScreenModeEnforcement(TInt aMode);
       
   128 	inline TInt ScreenSizeMode() const;
       
   129 	void SetPointerCursorArea(TInt aMode,const TRect& aRect);
       
   130 	inline TRect GetPointerCursorArea(TInt aMode) const;
       
   131 	CFbsBitGc::TGraphicsOrientation Orientation();
       
   132 	void CycleDisplaySize();
       
   133 	void UpdateOrientation();
       
   134 	void doSetScreenMode(TInt aMode);
       
   135 	inline TSize CurrentScreenSize() const;
       
   136 	TRect DrawableArea() const;
       
   137 	void CycleOrientation();
       
   138 	TClientPanic SetModeRotation(TInt aMode,CFbsBitGc::TGraphicsOrientation aRotation);
       
   139 	void LoadScreenSizesL(TSize aScreenSize);
       
   140 	void LoadScreenSizeProperties();
       
   141 	void LoadScreenScale();
       
   142 	void SetDigitiserAreas(const TSize& aScreenSize,const TRect& aDigitiserArea);
       
   143 	inline TInt NumScreenSizeModes() const;
       
   144 	inline const TSizeMode& ScreenSizeModeData() const;
       
   145 	inline const TSizeMode& ScreenSizeModeData(TInt aMode) const;
       
   146 	inline TPoint ScreenModeOrigin(TInt aMode);
       
   147 	inline TPoint CurrentScreenModeOrigin();
       
   148 	inline TSize CurrentScreenModeScale();
       
   149 	inline TPoint CurrentScreenModeScaledOrigin();
       
   150 	inline TPoint ScreenModeScaledOrigin(TInt aMode);
       
   151 	inline TScreenModeEnforcement SizeEnforcementMode() const;
       
   152 	void GetScreenSizeAndRotation(TPixelsTwipsAndRotation &aSar, TInt aScreenMode);
       
   153 	void GetScreenSizeAndRotation(TPixelsAndRotation &aSar, TInt aScreenMode);
       
   154 	inline TSize GetScreenScale(TInt aMode) const;
       
   155 	inline void SetCurrentScreenModeAttributes(const TSizeMode &aModeData);
       
   156 	inline TSize GetPhysicalScreenSize();
       
   157 	inline void SetPhysicalScreenSize();
       
   158 	inline TBool ShouldSwapWidthAndHeightOffScBitmap(TInt aOldRotation);
       
   159 	inline TInt Modes();
       
   160 	CFbsDevice * DrawDevice();
       
   161 	CWsOffScreenBitmap* OffScreenBitmap();
       
   162 	void FreeOffScreenBitmap();
       
   163 	void UpdateGcs();
       
   164 	inline void SetScalingFactor();
       
   165 	void UpdateOffScreenBitmapGc(const TBool aSwapWidthAndHeight);
       
   166 	TPoint PhysicalToLogical(TPoint aPhysicalPt);
       
   167 	void IncContrast();
       
   168 	void DecContrast();
       
   169 	void IncBrightness();
       
   170 	void DecBrightness();
       
   171 	inline TBool IsValidScreenSizeMode(TInt aMode);
       
   172 	TInt GetScreenSizeModeListL();
       
   173 	void SetDisplayModeFromName(const TDesC& aModeName, TDisplayMode& aMode);
       
   174 	CFbsDevice* GetFbsDevice();
       
   175 	// called by CWsGc when it is implementing MWsGc
       
   176 	const TTime& Now() const;
       
   177 	void ScheduleAnimation(const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop);
       
   178 	// redraw scheduling code
       
   179 	void AddRedrawRegion(const TRegion& aRegion, TBool aSchedule = ETrue, TRedrawDepth aDepth = ERedrawAll);
       
   180 	void DoRedrawNow();
       
   181 	void ScheduleRegionUpdate(const TRegion* aDefinitelyDirty);
       
   182 	void EndClientBuffer();
       
   183 	// implementing MWsScreen
       
   184 	void OnAnimation();
       
   185 	void Redraw();
       
   186 	TBool RedrawInvalid(const TArray<TGraphicDrawerId>& aInvalid);
       
   187 	inline TBool BackLightFlag();
       
   188 	// implementing interface extension
       
   189 	TAny* ResolveObjectInterface(TUint aTypeId);
       
   190 	// implementing MWsScreenConfig interface	
       
   191 	TDisplayMode DisplayMode() const;
       
   192 	TSize SizeInPixels() const;
       
   193 	TSize ScreenModeSizeInPixels() const;
       
   194 	TInt Stride() const;
       
   195 	CFbsBitGc::TGraphicsOrientation Orientation() const;
       
   196 	TInt SizeMode() const;
       
   197 	TSize ScalingFactor() const;
       
   198 	TPoint Origin() const;
       
   199 	TPoint ScaledOrigin() const;
       
   200 	// implementing MWsFrontBuffer
       
   201 	const TAny* GetBits();
       
   202 	CFbsBitGc* GetBitGc();
       
   203 	CFbsBitGc* GetBitGcCurrent();
       
   204 	TInt SetBitGc(CFbsBitGc* aBitGc);
       
   205 	TInt SetBitGc(CFbsBitGc* aBitGc, TBool aInvalidateScreen);
       
   206 	inline TBool IsOffScreenBitmap();
       
   207 	inline TBool MaskingEnabled();
       
   208 	inline TBool BltOffScreen();
       
   209 	void RecalcHeights();
       
   210 	void DiscardAllSchedules();
       
   211 	inline CDebugBar * DebugBar();
       
   212 	inline CFallbackMap * FallbackMap();
       
   213 	inline CWsSpriteManager* SpriteManager();
       
   214 	inline MWsFader* Fader();
       
   215 	TBool IsUpdatePending();
       
   216 	void DSARegionSyncStart( CWsDirectScreenAccess& aDSA );
       
   217 	void DSARegionSyncOver( CWsDirectScreenAccess& aDSA );
       
   218 	TBool HasVisibleDirectOnQueue();
       
   219 	TBool IsDSAClientWindow( const CWsClientWindow* aWin ) const;
       
   220 	void AcceptFadeRequest( CWsWindow* aWin, TBool	aIsFaded, TBool aIsBehind, TBool aIncludeChildren = EFalse );
       
   221 
       
   222 private:
       
   223 	enum TSyncConsts
       
   224 		{
       
   225 		KDSAAbortingImmediateRespAwaitFrameMicrosec = 80000		// 0.08 sec
       
   226 		};
       
   227 private:
       
   228 	void ChangeDisplayModeForAllOffScreenBitmap(TBool aSwapWidthAndHeight=EFalse);
       
   229 	void SetInitialScreenSizeMode();
       
   230 	CWsWindowGroup* FindNewFocus(CWsRootWindow* aRootWindow);
       
   231 	void CreateFallbackMapL();
       
   232 	void CreateScreenDeviceL();
       
   233 	TBool DoCreateScreenDevice(TDisplayMode aScreenMode);
       
   234 private:
       
   235 	enum
       
   236 		{
       
   237 		eTimerCreated=0x1,
       
   238 		};
       
   239 	enum TDsaDrawState
       
   240 		{
       
   241 		EDsaDrawStateIdle,
       
   242 		EDsaDrawStateDrawing
       
   243 		};
       
   244 private:
       
   245 	TSglQue<CWsDirectScreenAccess> iDirects;
       
   246 	RTimer iTimer;
       
   247 	TRequestStatus iTimerStatus;
       
   248 	TUint iFlags;
       
   249 
       
   250 	CScreenRedraw* iRedraw;
       
   251 
       
   252 	CWsRootWindow* iRootWindow;
       
   253 	CWsWindowGroup *iCurrentFocus;
       
   254 	CWsWindowGroup *iDefaultOwningWindow;
       
   255 	CWsOffScreenBitmap* iOffScreenBitmap;
       
   256 	TPoint iShadowShift;
       
   257 
       
   258 	CFbsScreenDevice *iScreenDevice;
       
   259 	CFbsBitGc *iScreenGdi;
       
   260 
       
   261 // Size and roation members
       
   262 	RPointerArray<TSizeMode> *iModes;
       
   263 	TInt iScreenSizeMode;
       
   264 	TScreenModeEnforcement iSizeEnforcementMode;
       
   265 	TSize iPhysicalScreenSize;
       
   266 	TInt iScreenNumber;
       
   267 	TInt iMaxContrast;
       
   268 	TInt iMaxBrightness;
       
   269 	TInt iNumScreenSizeModes;
       
   270 	TInt iNumSupportedScreenSizeModes;
       
   271 	TBool iBackLightFlag;
       
   272 	
       
   273 	// used by MWsFrontBuffer to redirect screen output
       
   274 	CFbsBitGc* iRedirectGc;
       
   275 
       
   276 	TDsaDrawState iDsaDrawState;
       
   277 	CDebugBar* iDebugBar;
       
   278 	CFallbackMap* iFallbackMap;
       
   279 	TUint8 iBlackMap;
       
   280 	TUint8 iWhiteMap;
       
   281 	CWsSpriteManager* iSpriteManager;
       
   282 	MWsFader* iFader;
       
   283 	};
       
   284 
       
   285 
       
   286 
       
   287 //
       
   288 // inlines			//
       
   289 //
       
   290 
       
   291 //
       
   292 // CScreen
       
   293 //
       
   294 inline void CScreen::Update(const TRegion &aRegion)
       
   295 	{iScreenDevice->Update(aRegion);}
       
   296 inline TPoint CScreen::ShadowVector()
       
   297 	{return(iShadowShift);}
       
   298 inline CWsWindowGroup* CScreen::FocusWindowGroup()
       
   299 	{return(iCurrentFocus);}
       
   300 inline TBool CScreen::BlankScreenOnRotation()
       
   301 	{return(iFlags&EBlankScreenOnRotation);}
       
   302 inline TBool CScreen::AutoClear()
       
   303 	{return(iFlags&EAutoClear);}
       
   304 inline CWsWindowGroup* CScreen::DefaultOwningWindowGroup()
       
   305 	{return(iDefaultOwningWindow);}
       
   306 
       
   307 inline CWsRootWindow* CScreen::RootWindow() const
       
   308 	{return iRootWindow;}
       
   309 inline TInt CScreen::ScreenNumber() const
       
   310 	{return iScreenNumber;}
       
   311 
       
   312 inline CFbsBitGc *CScreen::ScreenGdi()
       
   313 	{return(iScreenGdi);}
       
   314 inline TDisplayMode CScreen::CurrentDisplayMode()
       
   315 	{return iScreenDevice->DisplayMode();}
       
   316 inline TDisplayMode CScreen::DefaultDisplayMode()
       
   317 	{return iScreenDevice->DisplayMode();}
       
   318 //
       
   319 inline TInt CScreen::ScreenSizeMode() const
       
   320 	{return(iScreenSizeMode);}
       
   321 inline TRect CScreen::GetPointerCursorArea(TInt aMode) const
       
   322 	{return (*iModes)[aMode]->iPointerCursorArea;}
       
   323 inline TSize CScreen::CurrentScreenSize() const
       
   324 	{return (*iModes)[iScreenSizeMode]->iScreenSize;}
       
   325 inline TInt CScreen::NumScreenSizeModes() const
       
   326 	{return iNumScreenSizeModes;}
       
   327 inline const TSizeMode& CScreen::ScreenSizeModeData() const
       
   328 	{return *(*iModes)[iScreenSizeMode];}
       
   329 inline const TSizeMode& CScreen::ScreenSizeModeData(TInt aMode) const
       
   330 	{return *(*iModes)[aMode];}
       
   331 inline TPoint CScreen::ScreenModeOrigin(TInt aMode)
       
   332 	{return (*iModes)[aMode]->iOrigin;}
       
   333 inline TPoint CScreen::CurrentScreenModeOrigin()
       
   334 	{return (*iModes)[iScreenSizeMode]->iOrigin;}
       
   335 inline TSize CScreen::CurrentScreenModeScale()
       
   336 	{return (*iModes)[iScreenSizeMode]->iScreenScale;}
       
   337 inline TPoint CScreen::CurrentScreenModeScaledOrigin()
       
   338 	{return (*iModes)[iScreenSizeMode]->ScaledOrigin();}
       
   339 inline TPoint CScreen::ScreenModeScaledOrigin(TInt aMode)
       
   340 	{return (*iModes)[aMode]->ScaledOrigin();}
       
   341 inline TSize CScreen::GetScreenScale(TInt aMode) const
       
   342 	{return (*iModes)[aMode]->iScreenScale;}
       
   343 inline TDisplayMode CScreen::DefaultDisplayMode(const TInt aMode) const
       
   344 	{return (*iModes)[aMode]->iDefaultDisplayMode;}
       
   345 inline TSize CScreen::GetPhysicalScreenSize()
       
   346 	{return iPhysicalScreenSize;}
       
   347 inline void CScreen::SetScalingFactor()
       
   348 	{iScreenDevice->SetScalingFactor((*iModes)[iScreenSizeMode]->iOrigin,(*iModes)[iScreenSizeMode]->iScreenScale.iWidth,(*iModes)[iScreenSizeMode]->iScreenScale.iHeight,1,1);}
       
   349 inline void CScreen::SetCurrentScreenModeAttributes(const TSizeMode &aModeData)
       
   350 	{*(*iModes)[iScreenSizeMode]=aModeData;}
       
   351 inline void CScreen::SetPhysicalScreenSize()
       
   352 	{TInt temp=iPhysicalScreenSize.iWidth;iPhysicalScreenSize.iWidth=iPhysicalScreenSize.iHeight;iPhysicalScreenSize.iHeight=temp;}
       
   353 inline TScreenModeEnforcement CScreen::SizeEnforcementMode() const
       
   354 	{return iSizeEnforcementMode;}
       
   355 inline TBool CScreen::IsValidScreenSizeMode(TInt aMode)
       
   356 	{return (aMode>=0 && aMode<iModes->Count() && (*iModes)[aMode]!=NULL);}
       
   357 inline TBool CScreen::BackLightFlag()
       
   358 	{return iBackLightFlag;}
       
   359 inline TBool CScreen::IsOffScreenBitmap()
       
   360 	{return iOffScreenBitmap!=NULL;}
       
   361 
       
   362 inline CDebugBar * CScreen::DebugBar()
       
   363 	{return iDebugBar;}
       
   364 inline CScreen::CFallbackMap * CScreen::FallbackMap()
       
   365 	{return iFallbackMap;}
       
   366 	
       
   367 inline void CScreen::GetFadingParams(TUint8& aBlackMap,TUint8& aWhiteMap) const
       
   368     {aBlackMap=iBlackMap;aWhiteMap=iWhiteMap;}
       
   369 inline void CScreen::SetFadingParams(TUint8 aBlackMap,TUint8 aWhiteMap)
       
   370 	{iBlackMap=aBlackMap;iWhiteMap=aWhiteMap;}
       
   371 inline CWsSpriteManager* CScreen::SpriteManager()
       
   372 	{return iSpriteManager;}
       
   373 inline MWsFader* CScreen::Fader()
       
   374 	{return iFader;}
       
   375 inline TBool CScreen::BltOffScreen()
       
   376 	{return iFlags&EBltOffScreenBitmap;}
       
   377 #endif