windowing/windowserver/nga/SERVER/openwfc/walkwindowtree.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2006-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 // TWalkWindowTreeBase and associated classes definitions
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __WALKWINDOWTREE_H__
       
    19 #define __WALKWINDOWTREE_H__
       
    20 
       
    21 #include "server.h"
       
    22 
       
    23 class CWsWindow;
       
    24 class CWsWindowBase;
       
    25 class RWsTextCursor;
       
    26 
       
    27 class TWalkWindowTreeBase
       
    28 	{
       
    29 public:
       
    30 	virtual TBool DoIt(CWsWindow *aWin)=0;
       
    31 	};
       
    32 
       
    33 class TResumableWalkWindowTreeBase
       
    34 	{
       
    35 public:
       
    36 	virtual TBool DoIt(CWsWindow *aWin)=0;
       
    37 private: // walk state
       
    38 	friend class CWsWindowBase;
       
    39 	CWsWindowBase* iWin;
       
    40 	CWsWindowBase* iEnd;
       
    41 	CWsWindowBase* iNextChild;
       
    42 	CWsWindowBase* iParent;
       
    43 	};
       
    44 	
       
    45 class TWalkWindowTreeRegionBase : public TWalkWindowTreeBase
       
    46 	{
       
    47 public:
       
    48 	enum TTranslucentBehaviour
       
    49 		{
       
    50 		EDontWalkTranslucent,              //< Default behaviour - stop when you reach a window
       
    51 		EWalkTranslucent,                  //< Walk through translucent parts of windows
       
    52 		};
       
    53 protected:
       
    54 	TWalkWindowTreeRegionBase(RWsRegion *aRegion, TTranslucentBehaviour aTranslucentBehaviour = EDontWalkTranslucent);
       
    55 	TBool DoIt(CWsWindow *aWin);
       
    56 	virtual void DoIt2(CWsWindow *aWin)=0;
       
    57 	virtual TBool DoIt3(CWsWindow *aWin);
       
    58 protected:
       
    59 	TTranslucentBehaviour iTranslucentBehaviour;
       
    60 	RWsRegion *iRegion;
       
    61 	RWsRegion *iSubRegion;
       
    62 	
       
    63 	};
       
    64 	
       
    65 /**
       
    66 This tree walker calculates the visible regions of all windows and schedules
       
    67 redraws for anywhere which has changed.
       
    68 */
       
    69 class TWalkWindowTreeUpdateRegions : public TWalkWindowTreeBase
       
    70 	{
       
    71 public:
       
    72 	TWalkWindowTreeUpdateRegions(CScreen & aScreen);
       
    73 	TBool DoIt(CWsWindow * aWin);
       
    74 	void Walk();
       
    75 
       
    76 private:
       
    77 	CScreen & iScreen;
       
    78 	RWsRegion iVisible;
       
    79 	RWsRegion iTop;
       
    80 	RWsRegion iRemainsOfFadableScreen; // The remains after the accumulation of already faded regions
       
    81 	};
       
    82 
       
    83 /**
       
    84 This schedules the visible regions of all windows walked for redraw.
       
    85 */
       
    86 class TWalkWindowTreeScheduleRedraws : public TWalkWindowTreeBase
       
    87 	{
       
    88 public:
       
    89 	enum TBitMask
       
    90 		{
       
    91 		ERedrawFilterNoFilter	= 0x00,
       
    92 		ERedrawFilterOmitDSA	= 0x01
       
    93 		};
       
    94 	
       
    95 public:
       
    96 	TWalkWindowTreeScheduleRedraws();
       
    97 	TWalkWindowTreeScheduleRedraws( TUint32 aFilter );
       
    98 	TBool DoIt(CWsWindow * aWin);
       
    99 
       
   100 private:
       
   101 	TUint32	iScheduleRedrawFilter;
       
   102 	};
       
   103 
       
   104 /**
       
   105 This offsets all the transparent regions
       
   106 */
       
   107 class TWalkWindowTreeOffsetTransparentRegions : public TWalkWindowTreeBase
       
   108 	{
       
   109 public:
       
   110 	TWalkWindowTreeOffsetTransparentRegions(const TPoint& aOffset);
       
   111 	TBool DoIt(CWsWindow * aWin);
       
   112 
       
   113 private:
       
   114 	const TPoint & iOffset;	
       
   115 	};
       
   116 
       
   117 /**
       
   118 This recalculates the user opaque regions
       
   119 */
       
   120 class TWalkWindowTreeRecalcOpaque : public TWalkWindowTreeBase
       
   121 	{
       
   122 public:
       
   123 	TWalkWindowTreeRecalcOpaque();
       
   124 	TBool DoIt(CWsWindow * aWin);
       
   125 	};
       
   126 
       
   127 // Tree walkers which schedule a set of windows to be drawn derive from this
       
   128 class TWalkWindowTreeSchedule: public TWalkWindowTreeBase
       
   129 	{
       
   130 public:
       
   131 	TWalkWindowTreeSchedule();
       
   132 	CWsWindow * HeadWindow() const;
       
   133 	virtual const TRegion& WindowRegion(const CWsWindow& aWin) const = 0;
       
   134 	virtual const TRegion& SpriteRegion(const CWsWindow& aWin) const = 0;
       
   135 protected:
       
   136 	CWsWindow* iHead;
       
   137 	};
       
   138 
       
   139 class TWalkWindowListSchedule : public TWalkWindowTreeSchedule
       
   140 	{
       
   141 public:
       
   142 	TWalkWindowListSchedule(CWsWindow* aHeadWin, TRegion& aScreenUpdateRegion);
       
   143 	TBool DoIt(CWsWindow* aWin);
       
   144 	const TRegion& WindowRegion(const CWsWindow& aWin) const;
       
   145 	const TRegion& SpriteRegion(const CWsWindow& aWin) const;
       
   146 	void WalkWindowList();
       
   147 private:
       
   148 	TBool DoWindow(CWsWindow& aWin);
       
   149 	TBool DoSprites(CWsWindow& aWin);
       
   150 	
       
   151 private:
       
   152 	TRegion& iScreenUpdateRegion;
       
   153 	};
       
   154 
       
   155 // This walker uses regions to work out the minimum set of pixels that need updating
       
   156 // It requires memory allocation, and so can fail.  Check ScheduledRegionsOk before
       
   157 // relying on the results.
       
   158 class TWalkWindowTreeScheduleRegions: public TWalkWindowTreeSchedule
       
   159 	{
       
   160 public:
       
   161 	TWalkWindowTreeScheduleRegions(TRegion& aRegion, const TRegion& aTopElement);
       
   162 	TBool DoIt(CWsWindow *aWin);
       
   163 	TBool ScheduledRegionsOk() const;
       
   164 	const TRegion& WindowRegion(const CWsWindow& aWin) const;
       
   165 	const TRegion& SpriteRegion(const CWsWindow& aWin) const;
       
   166 private:
       
   167 	TRegion& iRegion;
       
   168 	const TRegion &iTopElement;
       
   169 	TBool iScheduledRegionsOk;
       
   170 	};
       
   171 	
       
   172 // This walker uses the screens fallback mechanism.  This does not require memory
       
   173 // allocation and so should never fail, but is significantly less efficient than the
       
   174 // region based walker.
       
   175 class TWalkWindowTreeScheduleFallback: public TWalkWindowTreeSchedule
       
   176 	{
       
   177 public:
       
   178 	TWalkWindowTreeScheduleFallback(CScreen::CFallbackMap * aFallbackMap);
       
   179 	TBool DoIt(CWsWindow *aWin);
       
   180 	const TRegion& WindowRegion(const CWsWindow& aWin) const;
       
   181 	const TRegion& SpriteRegion(const CWsWindow& aWin) const;
       
   182 private:
       
   183 	CScreen::CFallbackMap * iFallbackMap;
       
   184 	};
       
   185 	
       
   186 class TWalkWindowTreeFocusChanged : public TWalkWindowTreeBase
       
   187 	{
       
   188 public:
       
   189 	TWalkWindowTreeFocusChanged(TBool aNewFocusState);
       
   190 	TBool DoIt(CWsWindow *aWin);
       
   191 // Data	
       
   192 private:
       
   193 	TBool iNewFocusState;
       
   194 	};
       
   195 	
       
   196 class TResumableWalkWindowTreeFindInvalid : public TResumableWalkWindowTreeBase
       
   197 	{
       
   198 public:
       
   199 	TResumableWalkWindowTreeFindInvalid(CWsWindowRedraw** aResult);
       
   200 	TBool DoIt(CWsWindow* aWin);
       
   201 // Data
       
   202 private:
       
   203 	CWsWindowRedraw** iResult;
       
   204 	};
       
   205 	
       
   206 class TWalkWindowTreeDisconnect : public TWalkWindowTreeBase
       
   207 	{
       
   208 public:
       
   209 	TWalkWindowTreeDisconnect(RWsTextCursor *aCursor);
       
   210 	TBool DoIt(CWsWindow *aWin);
       
   211 private:
       
   212 	RWsTextCursor *iTextCursor;
       
   213 	};
       
   214 	
       
   215 class TWalkWindowTreeIsObscured : public TWalkWindowTreeBase
       
   216 	{
       
   217 public:
       
   218 	TWalkWindowTreeIsObscured(TBool &aResult);
       
   219 	TBool DoIt(CWsWindow *aWin);
       
   220 // Data	
       
   221 	TBool *iResult;
       
   222 	};
       
   223 
       
   224 class TWalkWindowTreeSetupVisibleRegionTracking : public TWalkWindowTreeBase
       
   225 	{
       
   226 public:
       
   227 	TWalkWindowTreeSetupVisibleRegionTracking(TBool aRegister);
       
   228 	TBool DoIt(CWsWindow *aWin);
       
   229 // Data	
       
   230 	TBool iRegister;
       
   231 	};
       
   232 
       
   233 class TWalkWindowTreeSetNonFading : public TWalkWindowTreeBase  
       
   234 	{
       
   235 public:
       
   236 	TWalkWindowTreeSetNonFading(TBool aNonFading);
       
   237 	TBool DoIt(CWsWindow *aWin);
       
   238 // Data	
       
   239 	const TBool iNonFading;
       
   240 	};
       
   241 	
       
   242 class TWalkWindowTreeSetFaded : public TWalkWindowTreeBase 
       
   243 	{
       
   244 public:
       
   245 	TWalkWindowTreeSetFaded(TBool aFaded,CWsWindowBase* aWin,TUint8 aBlackMap,TUint8 aWhiteMap);
       
   246 //from TWalkWindowTreeBase
       
   247 	TBool DoIt(CWsWindow *aWin);
       
   248 // Data	
       
   249 	const TUint8 iBlackMap;
       
   250 	const TUint8 iWhiteMap;
       
   251 	const TBool iFaded;
       
   252 	const CWsWindowGroup* iGroup;
       
   253 	};
       
   254 	
       
   255 class TWalkWindowTreeSetSystemFaded : public TWalkWindowTreeSetFaded 
       
   256 	{
       
   257 public:
       
   258 	TWalkWindowTreeSetSystemFaded(TBool aFaded, CWsWindowBase* aWin, TUint8 aBlackMap, TUint8 aWhiteMap, TBool& aStateChanged);
       
   259 //from TWalkWindowTreeBase
       
   260 	TBool DoIt(CWsWindow *aWin);
       
   261 // Data	
       
   262 	TBool& iStateChanged;
       
   263 	};
       
   264 
       
   265 class TWalkWindowTreePurgeEvents : public TWalkWindowTreeBase
       
   266 	{
       
   267 public:
       
   268 	TWalkWindowTreePurgeEvents();
       
   269 	TBool DoIt(CWsWindow *aWin);
       
   270 	};
       
   271 
       
   272 class TWalkWindowTreeCalcInvalidGraphics: public TWalkWindowTreeRegionBase
       
   273 	{
       
   274 public:
       
   275 	TWalkWindowTreeCalcInvalidGraphics(RWsRegion *aRegion,TRegion &aDirty,const TArray<TGraphicDrawerId>& aInvalid);
       
   276 	void CalcInvalid(CScreen& aScreen);
       
   277 	TBool CreateSubRegion();
       
   278 	void DoIt2(CWsWindow */*aWin*/) {}
       
   279 	TBool DoIt3(CWsWindow *aWin);
       
   280 	void DestroyRegions();
       
   281 private:
       
   282 	TRegion& iDirty;
       
   283 	const TArray<TGraphicDrawerId>& iInvalid;
       
   284 	};
       
   285 
       
   286 #if defined(_DEBUG)
       
   287 class TWalkWindowTreeCheck : public TWalkWindowTreeBase
       
   288 	{
       
   289 public:
       
   290 	TBool DoIt(CWsWindow *aWin);
       
   291 	};	
       
   292 	
       
   293 #endif
       
   294 
       
   295 class TWalkWindowTreeRedrawStoreSize : public TWalkWindowTreeBase
       
   296 	{
       
   297 public:
       
   298 	TWalkWindowTreeRedrawStoreSize();
       
   299 	TBool DoIt(CWsWindow *aWin);
       
   300 	TInt iTotalSize;
       
   301 	};
       
   302 
       
   303 
       
   304 // We can't do a proper find_if unless we are prepared to write our own
       
   305 // mem_fun, but this isn't a bad start
       
   306 class TWalkWindowTreeFindWithFlag : public TWalkWindowTreeBase
       
   307 	{
       
   308 public:
       
   309 	TWalkWindowTreeFindWithFlag(TUint aFlag) : iFlag(aFlag), iFound(0) { }
       
   310 	TBool DoIt(CWsWindow *aWin);
       
   311 	CWsWindow * Found() { return iFound; }
       
   312 private:
       
   313 	TUint iFlag;
       
   314 	CWsWindow * iFound;
       
   315 	};
       
   316 
       
   317 class TWalkWindowTreeFindByHandle : public TWalkWindowTreeBase
       
   318 	{
       
   319 public:
       
   320 	TWalkWindowTreeFindByHandle(TUint32 aHandle) : iHandle(aHandle) { }
       
   321 	TBool DoIt(CWsWindow * aWin);
       
   322 	CWsWindow * Found() { return iFound; }
       
   323 private:
       
   324 	TUint32 iHandle;
       
   325 	CWsWindow * iFound;
       
   326 	};
       
   327 
       
   328 class TWalkWindowTreeSendState : public TWalkWindowTreeBase
       
   329 	{
       
   330 public:
       
   331 	TWalkWindowTreeSendState(MWsWindowTreeObserver& aWindowTreeObserver);
       
   332 	TBool DoIt(CWsWindow *aWin);
       
   333 private:
       
   334 	MWsWindowTreeObserver& iWindowTreeObserver;
       
   335 	};
       
   336 
       
   337 #endif