uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
child 13 8f67d927ea57
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Server declaration, internal for Nokia
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __ALF_BRIDGE_H__
       
    21 #define __ALF_BRIDGE_H__
       
    22 
       
    23 #include <e32hashtab.h>
       
    24 
       
    25 #include "alfscreen.h"
       
    26 #include "alfstreamerbridge.h"
       
    27 #include "alfdecoderserverclient.h"
       
    28 
       
    29 #include <alf/alfconstants.h>
       
    30 
       
    31 #include "HuiFxEffect.h"
       
    32 #include <alf/AlfTransEffectPlugin.h>
       
    33 #include <uiacceltk/HuiDisplay.h>
       
    34 
       
    35 class CAlfEffectEndTimer;
       
    36 class CAlfCommandDebug;
       
    37 class CAlfLayoutSwitchEffectCoordinator;
       
    38 class RMemReadStream;
       
    39 
       
    40 const TInt KAlfBridgeRegionGranularity = 10;
       
    41 
       
    42 NONSHARABLE_CLASS(CAlfBridge): 
       
    43 	public CBase, 
       
    44     public MAlfStreamerListener, 
       
    45     public MHuiDisplayRefreshObserver, 
       
    46     public MHuiBitmapProvider,
       
    47     public MAlfGfxEffectObserver,
       
    48     public MHuiRosterObserver
       
    49     {
       
    50 	// Helper class for keeping ongoing effects in order. Kept in iEffectCleanupStack
       
    51     private:
       
    52 
       
    53         struct TEffectCleanupStruct
       
    54             {
       
    55             public:
       
    56                 TEffectCleanupStruct(
       
    57                         TInt aHandle,
       
    58                         CHuiVisual* aEffectedVisual,
       
    59                         CHuiVisual* aTemporaryPresenterVisual,
       
    60                         TBool aIsLayout, 
       
    61                         TBool aHideWhenFinished) 
       
    62                 : iHandle(aHandle), 
       
    63                 iEffectedVisual(aEffectedVisual),
       
    64                 iTemporaryPresenterVisual(aTemporaryPresenterVisual),
       
    65                 iIsLayout(aIsLayout),
       
    66                 iHideWhenFinished(aHideWhenFinished)
       
    67                         {
       
    68 //                        RDebug::Printf("TEffectCleanupStruct - 0x%x 0x%x, %d", iEffectedVisual, iTemporaryPresenterVisual, iIsLayout );
       
    69                         };
       
    70 
       
    71                 TInt iHandle;
       
    72 
       
    73                 TBool iIsLayout;
       
    74 
       
    75                 TBool iHideWhenFinished;
       
    76 				
       
    77 				// not own, unless iEffectedVisual has EShouldDestroy flag enabled
       
    78                 CHuiVisual* iEffectedVisual;
       
    79 				// owned
       
    80                 CHuiVisual* iTemporaryPresenterVisual;
       
    81             };
       
    82             
       
    83 public:
       
    84 
       
    85     static CAlfBridge* NewL( CAlfStreamerBridge** aHost, CHuiEnv* aEnv );
       
    86     ~CAlfBridge();
       
    87     
       
    88 	void AddNewScreenL(CAlfSharedDisplayCoeControl* aSharedCoeControl);
       
    89 	void AddNewScreenFromWindowL(RWindow* aWindow);
       
    90     /**
       
    91      * This method returns the index of first alf controlgroup in the roster.
       
    92      * 
       
    93      */
       
    94     TInt FirstAlfControlGroupIndex( TInt aScreenNumber );
       
    95         
       
    96     /**
       
    97      * This method returns the index of last alf controlgroup in the roster.
       
    98      * 
       
    99      */
       
   100     TInt LastAlfControlGroupIndex( TInt aScreenNumber );        
       
   101     
       
   102     /**
       
   103      * Sets flag to indicated that visual tree has changed (in every screen).
       
   104      * 
       
   105      */
       
   106     void SetVisualTreeVisibilityChanged(TBool aChanged);
       
   107     
       
   108     /**
       
   109      * Solution to reduce active visuals until we handle window tree hierarchy correctly
       
   110      */
       
   111     void HandleVisualVisibility( TInt aScreenNumber );
       
   112 
       
   113     /**
       
   114      * Solution to reduce active visuals until we handle window tree hierarchy correctly. 
       
   115 	 *  Note: Recursive method
       
   116      */
       
   117     TBool HandleLayoutVisualVisibility(
       
   118             CHuiLayout* aLayout,
       
   119             CHuiControlGroup& aControlGroup,
       
   120             CHuiControl& aControl,
       
   121             TBool& aFullscreenCovered, 
       
   122             TRect& aFullscreen,
       
   123             CAlfScreen* aScreen,
       
   124             TBool& aSubtreeVisible,
       
   125             TBool aChildCanBeOpaque );
       
   126     /**
       
   127      * This method shows the control group in roster, however the aWhere param
       
   128      * is modified so that controlgroup appears at the right position depending on
       
   129      * controlgroup type
       
   130      *
       
   131      */
       
   132     void ShowControlGroupL(
       
   133             CHuiRoster& aRoster, 
       
   134             CHuiControlGroup& aGroup, 
       
   135             TInt aWhere, 
       
   136             TInt aScreenNumber );
       
   137 
       
   138     /**
       
   139      * This method sets the windowgroup id for the alf window.
       
   140      * 
       
   141      */
       
   142     void SetAlfWindowGroupId(TInt aAlfWindowGroupId);
       
   143     
       
   144     CHuiDisplay* Display(TInt aScreenNum);
       
   145     
       
   146     /**
       
   147      * AlfAppUi delegates the QT command buffer posting functionality to bridge 
       
   148      * through this function. It identifies the corrcet CHuiCanvasVisual, 
       
   149      * from the RWindow::ClientId(), that it has got from client
       
   150      * and posts the command buffer to that visual. 
       
   151      *
       
   152      * @param params  QTParams containg window information and command buffer
       
   153      * 
       
   154      */
       
   155     void PostQTCommandBufferL( TAlfQtCommandBufferParams params );
       
   156        
       
   157     /**
       
   158      * Set the client window where the visual or layout will be drawn to.
       
   159      * @param aWindowGroupId Window group id.
       
   160      * @param aClientWindowHandle Client side window handle.
       
   161      * @param aVisual Visual or layout.
       
   162      */
       
   163     void SetClientWindowForDrawingL(TInt aWindowGroupId, TInt aClientWindowHandle, CHuiVisual* aVisual);
       
   164 
       
   165     // This is the final callback that does the actual work
       
   166     // AlfGfxEffectEndCallBack starts a timer, and when the timer finishes,
       
   167     // it calls this function
       
   168 
       
   169     void TransitionFinishedHandlerL( TInt aHandle );
       
   170     
       
   171     // from  MAlfGfxEffectObserver
       
   172     
       
   173   	/**
       
   174  	 * Function to be called when CHuiFxEffect class effect has ended
       
   175   	 * @param aHandle handle of the effect, given when the effect is started
       
   176   	 */
       
   177     void AlfGfxEffectEndCallBack( TInt aHandle );
       
   178    
       
   179     TInt FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup );
       
   180     
       
   181     void RemoveAllTemporaryPresenterVisuals();
       
   182 
       
   183     /**
       
   184      * Helper function to abort fullscreen effect
       
   185      * @param aClientRequest ETrue if requested by client.
       
   186      */
       
   187     void HandleGfxStopEvent( TBool aClientRequest );
       
   188     
       
   189     void EnableSwRenderingL(TBool aEnable = ETrue);
       
   190     void UploadSwRenderingTargetL( CAlfScreen* aScreen );
       
   191     TBool PrepareSwRenderingTarget( CAlfScreen* aScreen );
       
   192 
       
   193     /**
       
   194      * Sets memory level.
       
   195      * @param aMemoryLevel memory level.
       
   196      */
       
   197     void SetMemoryLevel(THuiMemoryLevel aMemoryLevel);
       
   198     
       
   199     /**
       
   200      * Sets low memory. This is used by this class.
       
   201      * @param aEnabled ETrue if enabled, EFalse if disabled.
       
   202      */
       
   203     void SetLowMemory(TBool aEnabled);
       
   204     
       
   205     /**
       
   206      * Requests to force SW rendering to be used.
       
   207      * @param aEnabled enabled status.
       
   208      * @return error code.
       
   209      */
       
   210     TInt ForceSwRendering(TBool aEnabled);
       
   211     
       
   212     /**
       
   213      * Chooses appropriate memory level and informs
       
   214      * core toolkit.
       
   215      */
       
   216     void DoUpdateMemoryLevel();
       
   217     
       
   218     /**
       
   219      * Cancels all effects due to low memory.
       
   220      */
       
   221     void LowMemoryCancelAllEffects();
       
   222     
       
   223     // From MHuiRosterObserver
       
   224     void NotifyRosterDrawStart(CHuiDisplay& aDisplay);
       
   225     void NotifyRosterDrawEnd(CHuiDisplay& aDisplay);
       
   226     
       
   227 private:    
       
   228     
       
   229     class CFullScreenEffectState;
       
   230     
       
   231     class CControlEffectState;
       
   232     
       
   233     CAlfBridge( CAlfStreamerBridge** aHost );
       
   234     
       
   235     void ConstructL(CHuiEnv* aEnv);
       
   236     
       
   237 	/**
       
   238 	* RegisterFadeEffectL
       
   239 	*
       
   240 	* Register existing fade effect from MMC (RND ONLY) or ROM.
       
   241 	*/
       
   242     void RegisterFadeEffectL();
       
   243 
       
   244     /**
       
   245 	* DoSetCachedFadeEffectL
       
   246 	*
       
   247 	* Resolves the fade effect filename. Speeds up fade effect loading.
       
   248 	*/    
       
   249     void DoSetCachedFadeEffectL();
       
   250     
       
   251 	void HandleDestroyDisplay( TInt aScreenNumber );
       
   252 	
       
   253 	void HandleRegisterEffectL( TAlfBridgerData data );
       
   254 	
       
   255 	/**
       
   256 	* DoRegisterEffectL
       
   257 	*
       
   258 	* Register effect filename to a certain action in HuiFxEngine
       
   259 	*/
       
   260 	void DoRegisterEffectL(const TDesC& aFilename, TInt aAction);
       
   261 	
       
   262 	// effect handling
       
   263 	void HandleGfxEffectsL( TAlfBridgerData data );
       
   264 
       
   265     // remove effect
       
   266     // This is needed if we have to abort an effect
       
   267     void HandleGfxStopEffectsL( TAlfBridgerData data );
       
   268     
       
   269 	/**
       
   270 	*	RemoveEffectFromApp
       
   271 	*
       
   272 	*	Removes effects on appui.
       
   273 	*/
       
   274     void RemoveEffectFromApp(TInt aAppUid);
       
   275     
       
   276     // component effect handling
       
   277     void HandleGfxControlEffectsL( TAlfBridgerData data );
       
   278     
       
   279     /**
       
   280      * Handles begin and end fullscreen events
       
   281      */
       
   282     TBool HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout);
       
   283     
       
   284 	/**
       
   285 	*	FreezeLayoutUntilEffectDestroyedL
       
   286 	*
       
   287 	*	Tries to take screenshot of the layout. If that fails, the layout will not be effected at all.
       
   288 	*/
       
   289     void FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle);
       
   290 
       
   291     /**
       
   292      * Handles control effect events
       
   293      */    
       
   294     void HandleGfxControlEventL(CControlEffectState& aEvent, CHuiCanvasVisual* aCanvasVisual);
       
   295     
       
   296     /*
       
   297      * SetupEffectLayoutContainerL
       
   298      * 
       
   299      * This method creates an own layout into iFullScreenEffectControlGroup. Then it creates
       
   300      * temporary presenter visual visuals for each visual in aSourceLayout and binds them
       
   301      * using SetExternalContentL. Finally the effect entry is added to iEffectCleanupStack, 
       
   302      * thus it can be cleaned after effect completion.
       
   303 	 *
       
   304 	 *
       
   305 	 *	@return	ETrue, 	if layout have been initialized succesfully for the effect
       
   306 	 			EFalse,	if any visuals have been removed. Effect should not be applied.
       
   307      */
       
   308     TBool SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect);
       
   309 
       
   310     /*
       
   311      *	AddEffectItemL
       
   312 	 *
       
   313 	 *	Prepares visual for the effect. Removes previous effect if necessary. @aItemDestroyed will return EFalse,
       
   314 	 *	if the visual has been destroyed during the previous effect.
       
   315 	 *	
       
   316 	 *	@param	aItemDestroyed	
       
   317      */
       
   318     CHuiCanvasVisual* AddEffectItemL(
       
   319             TInt aEffectHandle,
       
   320             CHuiVisual* aSourceVisual, 
       
   321             CHuiLayout* aTargetLayout, 
       
   322             CHuiControl* aEffectControl,
       
   323             TBool aInsertTemporaryVisual,
       
   324             TBool& aItemDestroyed,
       
   325             TBool aIsExitEffect = EFalse);
       
   326             
       
   327 
       
   328     /*
       
   329      *	AddToEffectLayoutContainerL
       
   330      */
       
   331     void AddToEffectLayoutContainerL(
       
   332             TInt aEffectHandle,
       
   333             CHuiLayout* aSourceLayout, 
       
   334             CHuiLayout* aTargetLayout,
       
   335             CHuiControl* aEffectControlGroup,
       
   336             TInt& aItemsDestroyed,
       
   337             TBool aAddLayout = ETrue,
       
   338             TBool aIsExitEffect = EFalse);
       
   339 
       
   340     /*
       
   341      *	ListFamilyTreeL
       
   342      */   
       
   343     void ListFamilyTreeL( RPointerArray<CHuiLayout>& aArray, const CHuiLayout* aLayout );
       
   344     /*
       
   345      * SetupEffectLayoutContainerL
       
   346      * 
       
   347      * This method creates an own temporary presenter visual visual and binds it to aSourceVisul
       
   348      * using SetExternalContentL. Finally the effect entry is added to iEffectCleanupStack, 
       
   349      * thus it can be cleaned after effect completion.
       
   350      */
       
   351     void SetupEffectContainerL(TInt aHandle, CHuiCanvasVisual* aSourceVisual, TBool aIsExitEffect);
       
   352 
       
   353     /*
       
   354      * RemoveTemporaryPresenterItem
       
   355      * 
       
   356      * Effects are shown indirectly by a another visual, that is in iFullScreenEffect control group. 
       
   357      * This methods unbinds the external content and the removes temporary presenter visual 
       
   358 	 * from iFullScreenEffect group and . It does not delete the CHuiFxEffect 
       
   359 	 * object associated with the content visual. See also iEffectCleanupStack.  
       
   360      */
       
   361     TBool RemoveTemporaryPresenterItem(TEffectCleanupStruct& aEffectItem);
       
   362 
       
   363     /*
       
   364      * FindTemporaryPresenterLayout
       
   365      * 
       
   366      * Finds temporary presenter layout based on a visual.
       
   367      *
       
   368      * @param   aVisual 
       
   369      * 
       
   370      * @return  NULL, if visual does not have temporary presenter visual in the active effect list
       
   371      */
       
   372     CHuiLayout* FindTemporaryPresenterLayout(CHuiVisual* aVisual);
       
   373     
       
   374     /*
       
   375      * FindLayoutByEffectHandle
       
   376      * 
       
   377      * Application exit effect for application that does not stay background is destroyed and removed
       
   378      * from normal control groups. FindLayoutByEffectHandle is used to find the correct group 
       
   379      * in order to apply the exit effect on already "destroyed" application. 
       
   380      *
       
   381      * @param   aHandle     Effect handle.
       
   382      * 
       
   383      * @return  NULL, if visual does not have temporary presenter visual in the active effect list
       
   384      */
       
   385     CHuiLayout* FindLayoutByEffectHandle(TInt aHandle);
       
   386     
       
   387     /*
       
   388      * HasActiveEffect
       
   389      */
       
   390     TBool HasActiveEffect(CHuiVisual* aVisual);
       
   391     
       
   392    /*
       
   393 	*	FindEffectHandle
       
   394 	*
       
   395 	*	@return 	Returns the effect handle number, which is associated with this visual. If none found, then 
       
   396 	*               returns KErrNotFound.
       
   397 	*/
       
   398     TInt FindEffectHandle(CHuiVisual* aVisual);
       
   399     /*
       
   400      * RemoveTemporaryPresenterVisual
       
   401      * 
       
   402      * Effects are shown indirectly by a another visual, that is in iFullScreenEffect control group. 
       
   403      * This methods unbinds the external content and the removes temporary presenter visual 
       
   404 	 * from iFullScreenEffect group and . It does not delete the CHuiFxEffect 
       
   405 	 * object associated with the content visual. See also iEffectCleanupStack.  
       
   406      */
       
   407     TBool RemoveTemporaryPresenterVisual(CHuiVisual* aVisual, TInt aHandle = KErrNotFound);
       
   408     
       
   409     /*
       
   410      *	RemoveTemporaryPresenterVisuals
       
   411      *	
       
   412      *	See above. 
       
   413      */
       
   414     TBool RemoveTemporaryPresenterVisuals();
       
   415     
       
   416 	void HandleNewWindowL( TAlfBridgerData& aData );
       
   417 	
       
   418 	void DestroyWindow(CHuiVisual* aVisual, TBool aForce = EFalse);
       
   419 	
       
   420 	void HandleDestroyWindowL( TAlfBridgerData& aData );
       
   421 	
       
   422 	void HandleSetWindowPosL( TAlfBridgerData& aData );
       
   423 	
       
   424 	void HandleSetWindowSizeL( TAlfBridgerData& aData );
       
   425 	
       
   426 	void HandleSetWindowRotationL( TAlfBridgerData& aData );
       
   427 	
       
   428 	void HandleSetWindowOpacityL( TAlfBridgerData& aData );
       
   429 	
       
   430 	void HandleReorderWindowL( TAlfBridgerData& aData );
       
   431 	
       
   432 	void HandlePostCanvasBufferL( TAlfBridgerData& aData );
       
   433 	
       
   434 	void HandleSetWindowFlagL( TAlfBridgerData& aData, TInt aOp );
       
   435 	
       
   436 	void SetWindowActiveL(CHuiVisual* aVisual, TBool aActive);
       
   437 	
       
   438 	void HandleSetWindowActiveL( TAlfBridgerData& aData );
       
   439 	
       
   440 	void HandleSetSurfaceExtentL( TAlfBridgerData& aData );
       
   441 	
       
   442 	void HandleLayerUsesAlphaFlagChanged( TAlfBridgerData& aData );
       
   443 	
       
   444 	void HandleGetNativeWindowDataL( TAlfBridgerData& aData );
       
   445 
       
   446 	void HandleSetCoveringBitmapL( TAlfBridgerData& aData );
       
   447 	
       
   448 	void HandleSetCursorDataL( TAlfBridgerData& aData );
       
   449 	
       
   450 	void HandleSetNodeTracking( TAlfBridgerData& aData );
       
   451 	
       
   452 	void HandleSetFadeEffectL( TAlfBridgerData& aData );
       
   453 
       
   454     void HandleSetLayoutSwitchEffectL();
       
   455 	
       
   456     void ClearCanvasVisualCommandSets(TBool aInactiveOnly);
       
   457     
       
   458     void ClipVisualRect(TRect& aRect, const TRect& aClippingRect);
       
   459 
       
   460     TBool IsRectCoveredByRegion(TRect aRect, TRegion& aCoveringRegion);
       
   461 
       
   462     void ShowSessionContainerControlGroupL(
       
   463             CHuiRoster& aRoster, 
       
   464             CHuiControlGroup& aGroup, 
       
   465             TInt aWhere, 
       
   466             TInt aScreenNumber );
       
   467 
       
   468     void ShowWindowGroupControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber );
       
   469     
       
   470 private:
       
   471          
       
   472     /**
       
   473      * Provide a bitmap and mask from the given UID.
       
   474      * This method should create a bitmap and its mask, usually by loading it from disk.
       
   475      *
       
   476      * @param aId      TextureManager id of this bitmap, may be used for extracting
       
   477      *                 an icon resource.
       
   478      * @param aBitmap  Output parameter for the provider: On return, has to store 
       
   479      *                 a pointer to the generated bitmap. Ownership transferred to caller.
       
   480 	 *                 The support for input CFbsBitmap formats varies between 
       
   481 	 *                 different renderers. See \ref cfbsbitmapsupport 
       
   482 	 *                 Table describing renderer bitmap support.      
       
   483 	 * @param aMaskBitmap  
       
   484 	 *                 Output parameter for the provider: On return, has to store 
       
   485      *                 a pointer to the generated alpha mask or <code>NULL</code> 
       
   486      * 				   if there is no mask. Ownership of the bitmap is transferred 
       
   487      *                 to the caller.
       
   488      * 
       
   489      * @see CHuiTextureManager::CreateTextureL()
       
   490      */
       
   491     virtual void ProvideBitmapL(TInt /*aId*/, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap);
       
   492     
       
   493     /**
       
   494      * InsertVisualL
       
   495      *  
       
   496      * @param  aKey    The key object of type K to add to the array.
       
   497      * @param  aVisual  The value object of type V to associate with aKey.
       
   498      * @leave  KErrNoMemory if memory could not be allocated to store the copies of aKey and aValue.
       
   499      */
       
   500     void AddVisual( TInt aKey, TInt aClientSideId, TInt aClientSideGroupId, CHuiCanvasVisual* aVisual );
       
   501     
       
   502     /**
       
   503      * RemoveVisual
       
   504      * 
       
   505      * @param  aKey    The key to be removed.
       
   506      * @return         KErrNone if the key object and corresponding value object were
       
   507      *                 removed successfully. KErrNotFound if the key object was not present in the array.
       
   508      */
       
   509     void RemoveVisual( TInt aWindowNodeId );
       
   510     
       
   511     /**
       
   512      * FindVisual
       
   513      * 
       
   514      * AddVisual and FindVisual set the iPreviouslySearchedVisual, which speeds
       
   515      * up the sequential search of the same visual.
       
   516      * 
       
   517      * @param  aKey    The key to be removed.
       
   518      * @return         NULL if the key object is not found. Otherwise returns 
       
   519      *                 the pointer to visual corresponding the key.
       
   520      */    
       
   521     CHuiCanvasVisual* FindVisual( TInt aKey );
       
   522  
       
   523      /**
       
   524      * FindVisualByClientSideIds
       
   525      * 
       
   526      * Finds a visual based on the provided client side ids. 
       
   527 	 *
       
   528      * @param  aClientSideId    The key to be removed.
       
   529      * @param  aClientSideId    The key to be removed.
       
   530      * @return         NULL if the visual was not not found. Otherwise returns 
       
   531      *                 the pointer to visual corresponding the client side keys.
       
   532      */       
       
   533     CHuiCanvasVisual* FindVisualByClientSideIds(TUint32 aClientSideId, TUint32 aClientSideGroupId );
       
   534 
       
   535     /**
       
   536      * This method finds controlgroup which has been assosiated with given window group id. 
       
   537      * Control group may or may not be active in roster.
       
   538      *
       
   539      * @param aWindowGroupNodeId Node id of the window group, internal.
       
   540      */
       
   541     CHuiControlGroup* FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber );
       
   542 
       
   543     /**
       
   544      * This method finds controlgroup which has been assosiated with window server window group id. 
       
   545      *
       
   546      * @param aWindowGroupNodeId window server window group id of the window group, internal.
       
   547      * @param aScreenNumber Screen number where to search, if not known KErrNotFound
       
   548      *        at return will contain the screen number where the group was found
       
   549      * @return pointer to the window group if found, NULL if not found.
       
   550      */
       
   551     CHuiControlGroup* FindControlGroupByWindowGroupId( 
       
   552             TInt aWindowGroupId, 
       
   553             TInt& aScreenNumber, 
       
   554             TAlfControlGroupEntry** aAlfGroup = NULL );
       
   555 
       
   556     CHuiControlGroup* FindControlGroupByAppId( TInt aAppId );
       
   557     /**
       
   558      * This method deletes controlgroup which has been assosiated with given window group id. 
       
   559      * Control group may or may not be active in roster.
       
   560      *
       
   561      * @param aWindowGroupNodeId Node id of the window group, internal.
       
   562      */
       
   563     void DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber );
       
   564 
       
   565     /**
       
   566      * Creates a control group
       
   567      *
       
   568      * @param aWindowGroupNodeId Node id of the window group, internal.
       
   569      * @param aClientWindowGroupId External window group id.
       
   570      */
       
   571     CHuiControlGroup& CreateControlGroupL(
       
   572             TInt aWindowGroupNodeId, 
       
   573             TInt aClientWindowGroupId,
       
   574             TInt aSecureId,
       
   575             TInt aScreenNumber );
       
   576 
       
   577     /**
       
   578      * This method prepares cached and HW accelerarted versions of texts & images from
       
   579      * canvas command buffers if those buffers has not yet been handled before. 
       
   580      */
       
   581     void PrepareCanvasVisualCaches( TInt aScreenNumber );
       
   582 
       
   583     /**
       
   584      * This method reorders alf controlgroups to just above alf servers
       
   585      * windowgroup.
       
   586      * 
       
   587      */
       
   588 
       
   589     void ReorderAlfControlGroupsL( TInt aScreenNumber );
       
   590         
       
   591     /**
       
   592      * Called to notify the observer that a display refresh is about to begin.
       
   593      * The observer should prepare its state for the display.
       
   594      */
       
   595     TInt ResolveScreenNumber( CHuiDisplay& aDisplay );
       
   596     
       
   597     void NotifyDisplayRefreshStarted(CHuiDisplay& aDisplay);
       
   598 
       
   599     /**
       
   600      * 
       
   601      */
       
   602     TBool IsVisualOpaque(CHuiVisual& aVisual);
       
   603 
       
   604     /**
       
   605      * Enables default transformation steps
       
   606      */
       
   607     void EnableVisualDefaultTransformationsL(CHuiVisual& aVisual);
       
   608 
       
   609     /**
       
   610      * 
       
   611      */
       
   612     void HandleCallback(TInt aStatus);
       
   613     
       
   614     /**
       
   615      * 
       
   616      */
       
   617     void DoDispatchL(TInt aStatus);
       
   618 
       
   619     void InsertImageBrushL(CHuiVisual& aVisual, TInt aBitmapHandle);
       
   620     void UpdateImageBrushL(CHuiVisual& aVisual, TInt aBitmapHandle);
       
   621     void RemoveImageBrushL(CHuiVisual& aVisual);
       
   622 
       
   623     
       
   624     void DebugPrintControlGroupOrder(
       
   625             CAlfScreen& aScreen, 
       
   626             CHuiRoster& aRoster, 
       
   627             CHuiControlGroup& aGroup);
       
   628     
       
   629     void VisualizeControlGroupOrderL(
       
   630             CHuiRoster& aRoster, 
       
   631             CHuiControlGroup& aGroup);
       
   632     
       
   633     void PrintAllocMem();
       
   634 
       
   635     // Fading methods
       
   636     TBool SetupFadeEffectL(CHuiCanvasVisual& aVisual);
       
   637     void PrepareFadeEffects( CHuiCanvasVisual& aVisual );    
       
   638     TBool LoadFadeEffectsL( CHuiCanvasVisual& aVisual );        
       
   639 
       
   640     // Fading related utility methods
       
   641     static TBool CanFadeChildren( CHuiCanvasVisual& aParent );
       
   642     static TInt RecursiveChildCount( CHuiCanvasVisual& aParent, TInt aCanvasFlags );
       
   643     static TBool IsFadedByParent( CHuiCanvasVisual& aVisual );
       
   644     static TBool IsNearestParentEffectFade( CHuiCanvasVisual& aVisual );
       
   645     static TBool HasActivePaintedAreas( CHuiCanvasVisual& aVisual, TBool aIncludeChildren );
       
   646     static TBool HasActiveFadedChildren( CHuiCanvasVisual& aVisual );
       
   647 
       
   648 private:
       
   649 
       
   650     RPointerArray<CAlfScreen> iAlfScreens;
       
   651     void SetCursorTimerL(TUint aTime = 0, CHuiVisual* aCursor = 0);
       
   652 
       
   653 NONSHARABLE_CLASS ( TDeadControlGroup )
       
   654     {
       
   655 public:
       
   656     TDeadControlGroup():
       
   657         iDeadGroup( 0 ),
       
   658         iScreen( 0 ),
       
   659         iLayout(NULL)
       
   660             {
       
   661             }
       
   662     TInt iDeadGroup;
       
   663     TInt iScreen;
       
   664     CHuiLayout* iLayout;
       
   665     };
       
   666     
       
   667 NONSHARABLE_CLASS( TEffectControlGroupEntry )  
       
   668     {
       
   669 public:
       
   670     TEffectControlGroupEntry() :    
       
   671         iHandle( KErrNotFound ),
       
   672         iVisual( NULL ),
       
   673         iEffect( NULL ),
       
   674         iAction( 0 ),
       
   675         iWindowGroupNodeId( 0 ),
       
   676         iClientWindowGroupId( 0 ),
       
   677         iScreenNumber( 0 )
       
   678             {
       
   679             }
       
   680 
       
   681     /** Handle of the attached effect */
       
   682     TInt iHandle;
       
   683     // Visual to which the effect has been attached */
       
   684     // This controls the case where a new effect replaces an old one.
       
   685     // If a new effect has been added to the same visual, the old one does not need
       
   686     // to be removed as adding the later effect has already removed the previous one.
       
   687     // Pointer not owned, value only saved for reference
       
   688     CHuiVisual* iVisual;
       
   689     // The effect that has been attached to the visual
       
   690     // Pointer not owned, value only saved for reference
       
   691     CHuiFxEffect* iEffect;
       
   692     // The action that is the cause of the effect (control appear or disappear)
       
   693     TInt iAction;
       
   694     /** Window group node id, internal */
       
   695     TInt iWindowGroupNodeId; 
       
   696     /** Window group id, external id seen e.g. by the application using wserv */
       
   697     TInt iClientWindowGroupId;
       
   698     TUint8 iScreenNumber;
       
   699     };
       
   700 
       
   701     // Array of window groups that have attached full screen effects
       
   702     RArray<TInt> iEffectWindowGroups;
       
   703     // Array of control groups that should have been deleted,
       
   704     // but have been left alive until the effect has run its course.
       
   705     RArray<TDeadControlGroup> iDeadControlGroups;
       
   706     // Array of individual controls that have attached effects
       
   707     RArray<TEffectControlGroupEntry> iEffectControls;
       
   708     
       
   709     // Array of callback data structures
       
   710     // The structures contain the handle that identifies the initiator of the effect
       
   711     // and a pointer to CAlfBridge instance to allow handling via static functions
       
   712     RArray<TInt> iEffectHandles;
       
   713         
       
   714     // iEffectCleanupStack contains the entries for effects that are currently associated 
       
   715     // with visuals in iFullscreenEffectControlGroup
       
   716     RArray<TEffectCleanupStruct> iEffectCleanupStack;
       
   717     
       
   718     // Effects that have finished by their own, or framework requested to end them
       
   719     RArray<TInt> iFinishedEffects;
       
   720     
       
   721     // Same as iEffectCleanupStack, but only the ones that can be now cleaned away.
       
   722     // See method RemoveTemporaryPresenterVisuals.
       
   723     RArray<TInt> iFinishedCleanupStackEffects;
       
   724     
       
   725 	// Effects states are used for effects request that arrive before the effected 
       
   726 	// window has been created. This is very common with fullscreen effects and 
       
   727 	// occational with control effects.
       
   728 	//
       
   729 	// NOTE: control effects support currently only one "delayed" effect. This is propably
       
   730 	// not sufficient for all sitations.
       
   731     NONSHARABLE_CLASS(CEffectState) : public CBase
       
   732         {
       
   733     public:    
       
   734         
       
   735         CEffectState();
       
   736          ~CEffectState();
       
   737          
       
   738     protected:
       
   739 	   /**
       
   740 		* ResolveFileNameL
       
   741 		*
       
   742 		* Reads filename from stream and composes it to iEffectName variable.
       
   743 		*/
       
   744          void ResolveFileNameL(RMemReadStream& aStream);
       
   745          
       
   746     public:
       
   747          
       
   748          TInt iAction;
       
   749          TInt iHandle;
       
   750             
       
   751          HBufC* iEffectName;
       
   752          // Handle using which client should be informed of completion.
       
   753          TInt iCompletionHandle;
       
   754          // State information
       
   755          TInt iOperation;
       
   756          
       
   757         };
       
   758     
       
   759     NONSHARABLE_CLASS( CControlEffectState ) : public CEffectState
       
   760         {
       
   761     public:
       
   762 
       
   763         TUint32 iClientHandle;
       
   764         TUint32 iClientGroupHandle;
       
   765     
       
   766         void ConstructL(TInt aAction, RMemReadStream& aStream);
       
   767         };
       
   768 
       
   769     NONSHARABLE_CLASS( CFullScreenEffectState ) : public CEffectState
       
   770         {
       
   771     public:
       
   772        // CFullScreenEffectState();
       
   773        // ~CFullScreenEffectState();
       
   774         
       
   775         void ConstructL(TInt aAction, RMemReadStream& aStream);
       
   776 
       
   777         // Information from BeginFullScreen
       
   778         TInt iType;
       
   779         TInt iWg1;
       
   780         TInt iWg2;
       
   781         TInt iToAppId;
       
   782         TInt iFromAppId;
       
   783         TRect iRect;
       
   784         
       
   785         // ETrue if waiting for window group to appear
       
   786         TBool iWaitingWindowGroup;
       
   787         // ETrue if end fullscreen has been performed
       
   788         TBool iEndFullScreen;
       
   789         // ETrue if setup effect container has been done
       
   790         TBool iSetupDone;
       
   791 
       
   792         // used for resolving the iCleanupStackItem that holds the frozen app layout underneath the starting application
       
   793         TInt iAppStartScreenshotItemHandle;
       
   794         };
       
   795 
       
   796     /**
       
   797      * Full screen effect state.
       
   798      * Own.
       
   799      */
       
   800     CFullScreenEffectState* iFullScreenEffectData;
       
   801     
       
   802     /**
       
   803      * Control effect state.
       
   804      * Own.
       
   805      */
       
   806     CControlEffectState* iControlEffectData;
       
   807         
       
   808     // these save the current full screen transition data
       
   809     // so that the correct transition can be ended from the callback
       
   810     // when the effect ends
       
   811     TInt iLastFullScreenEffectWindowGroup;
       
   812     TInt iLastFullScreenScreen;
       
   813     TInt iLastAction;
       
   814     TInt iLastEffectHandle;
       
   815     CAlfEffectEndTimer* iEffectEndTimer;
       
   816     TBool iLayoutInitializedForExitEffect;
       
   817     
       
   818     CAlfStreamerBridge** iHost;
       
   819 
       
   820     TInt iAlfWindowGroupId;
       
   821     TInt iAlfWindowGroupNodeId;
       
   822 
       
   823 
       
   824     CFbsBitmap* iHack; // not excactly owned..
       
   825     CFbsBitmap* iDummyMask; // not excactly owned..
       
   826     
       
   827     TBool iActivated;
       
   828     RAlfBridgerClient iBridgerClient;
       
   829     
       
   830     class THashVisualStruct
       
   831         {
       
   832     public:
       
   833         THashVisualStruct( 
       
   834                 CHuiCanvasVisual* aVisual, 
       
   835                 TUint32 aClientSideId,
       
   836                 TUint32 aClientSideGroupId) : 
       
   837             iVisual( aVisual ), 
       
   838             iClientSideId(aClientSideId),
       
   839             iClientSideGroupId(aClientSideGroupId)
       
   840                 {};
       
   841         
       
   842     public:
       
   843         CHuiCanvasVisual* iVisual;  // not own
       
   844         TInt32 iClientSideId;
       
   845         TInt32 iClientSideGroupId;
       
   846         };
       
   847     
       
   848     RHashMap<TUint32,THashVisualStruct> iWindowHashArray;
       
   849     class TRegisteredEffectsStruct
       
   850         {
       
   851     public:
       
   852         TRegisteredEffectsStruct()
       
   853             {
       
   854             iAction = 0;
       
   855             iEffectFile = NULL;
       
   856             }
       
   857     public:
       
   858         TInt iAction;
       
   859         HBufC* iEffectFile; 
       
   860         };
       
   861 		
       
   862 public:
       
   863     
       
   864     RArray<TRegisteredEffectsStruct> iAlfRegisteredEffects;
       
   865     CHuiEnv* iHuiEnv;
       
   866 	CAlfAppUi* iAppUi;
       
   867 
       
   868 private:    
       
   869 
       
   870     HBufC16* iFadeEffectFile;
       
   871     
       
   872 	CHuiCanvasVisual* iPreviouslySearchedVisual;
       
   873     
       
   874 	TInt iPreviouslySearchedVisualId;
       
   875 	
       
   876 	// For textcursor opacity
       
   877     CPeriodic* iCursorTimer;
       
   878     TUint iCursorInterval;
       
   879     CHuiVisual* iCursorVisual;
       
   880 
       
   881 #ifdef SYMBIAN_BUILD_GCE    
       
   882     TBool iPrintFPS;
       
   883 #endif
       
   884 
       
   885     CAlfCommandDebug* iCommandDebug;
       
   886 
       
   887     mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempVisualRegion;
       
   888     mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempIntersectingRegion;
       
   889     mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempRegion;
       
   890     TBool iBgSurfaceFound;
       
   891     TBool iInLowMemMode;
       
   892     CAlfLayoutSwitchEffectCoordinator* iLayoutSwitchEffectCoordinator;
       
   893     TInt iAlfSecureId; 	    
       
   894     TBool iSwRenderingEnabled;
       
   895     
       
   896     TBool iForcedSwRendering;
       
   897     TBool iLowMemoryMode;
       
   898     THuiMemoryLevel iCurrentMemoryLevel;
       
   899     };    
       
   900 
       
   901 #endif // __ALF_BRIDGE_H__