uiacceltk/hitchcock/ServerCore/Inc/alfappsrvsession.h
changeset 0 15bf7259bb7c
child 8 10534483575f
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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 session
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFAPPSRVSESSION_H
       
    21 #define C_ALFAPPSRVSESSION_H
       
    22 
       
    23 #include <e32hashtab.h>
       
    24 #include <alf/alfappsrvsessionbase.h>
       
    25 #include <uiacceltk/HuiEnv.h>
       
    26 #include <uiacceltk/huigifanimationtexture.h>
       
    27 #include "malfsrvtexturemanagerclient.h"
       
    28 #include "alfframestamp.h"
       
    29 
       
    30 class CHuiControl;
       
    31 class CHuiLayout;
       
    32 class CAlfSrvEffectEnv;
       
    33 class THuiTexturePreferredProperties;
       
    34 class CAlfSrvTextureManager;
       
    35 
       
    36 /**
       
    37  *  Session/service class in the server side.
       
    38  *
       
    39  *  @since S60 v3.2
       
    40  */
       
    41 NONSHARABLE_CLASS(CAlfAppSrvSession)
       
    42     : public CAlfAppSrvSessionBase, 
       
    43       public MWindowVisibilityObserver,
       
    44       private MAlfSrvTextureManagerClient
       
    45     {
       
    46 public:
       
    47     
       
    48     /**
       
    49      * Destructor, singals server to free resources specific for this client
       
    50      */
       
    51     ~CAlfAppSrvSession();
       
    52 
       
    53     /**
       
    54      * Public, two phased constructor, stores pointer to server instance
       
    55      * 
       
    56      * @param aServer Server which the client has connected.
       
    57      */
       
    58     static CAlfAppSrvSession* NewL(const CAlfAppServer* aServer);
       
    59     
       
    60     
       
    61     /**
       
    62      * Gets the drawing area of the session
       
    63      * 
       
    64      * @return TRect of the drawing area
       
    65      */
       
    66     TRect ClientDrawingArea() const;
       
    67     
       
    68     /**
       
    69      * Sets the drawint area. This is set by the display sub session
       
    70      * 
       
    71      * @param aRect Drawing area rect.
       
    72      */
       
    73     void SetClientDrawingArea( const TRect& aRect );
       
    74 
       
    75     /**
       
    76      * Sets the drawint area. This is set by the display sub session
       
    77      * 
       
    78      * @param aRect Drawing area rect.
       
    79      */
       
    80     void SetClientDrawingAreaL( const TRect& aRect );
       
    81     
       
    82     /**
       
    83      * Is client application focused?
       
    84      * 
       
    85      * @return ETrue if client application is focused.
       
    86      */
       
    87     TBool IsFocused() const;
       
    88     
       
    89     /**
       
    90      * Sets session's max fps limiter to half, used if client's window does not have keyboard focus
       
    91      * @param aOnBackground use lowered max fps (ETrue/EFalse)
       
    92      */
       
    93     void SetBackgroundMaxFps( TBool aOnBackground );
       
    94               
       
    95 // from CAlfAppSrvSessionBase
       
    96     /**
       
    97      * From CAlfAppSrvSessionBase
       
    98      * Called when a message is received from the client.
       
    99      * 
       
   100      * @param aMessage Message parameters.
       
   101      */
       
   102     void DoHandleCommandL(const RMessage2& aMessage);
       
   103     
       
   104     /**
       
   105      * From CAlfAppSrvSessionBase
       
   106      * Client's window group received focus.
       
   107      * 
       
   108      * @param aDoTransitionEffect Do fade in transision (RnD)
       
   109      */
       
   110     void FocusGainedL( TBool aDoTransitionEffect );
       
   111     
       
   112     /**
       
   113      * From CAlfAppSrvSessionBase
       
   114      * Client's window group lost focus.
       
   115      * 
       
   116      * @param aDoTransitionEffect Do fade out transision (RnD)
       
   117      * @return Did transition? (RnD)
       
   118      */
       
   119     TBool FocusLostL( TBool aDoTransitionEffect );
       
   120     
       
   121     /**
       
   122      * From CAlfAppSrvSessionBase
       
   123      * Returns the preferred window group posistion.
       
   124      * 
       
   125      * @return WG position
       
   126      */
       
   127     CAlfAppServer::TAlfWGPostion PreferredWindowGroupPosition() const;
       
   128     
       
   129     /**
       
   130      * Returns the preferred refresh mode of the session.
       
   131      *
       
   132      * @return Preferred refresh mode.
       
   133      */
       
   134     THuiRefreshMode PreferredRefreshMode() const;
       
   135     
       
   136     void ReOrderControlGroupSessionsL( RPointerArray<CAlfSrvSubSessionBase>& aGroupSessions );
       
   137     
       
   138  
       
   139 // from MWindowVisibilityObserver 
       
   140     /**
       
   141      * From MWindowVisibilityObserver
       
   142      * Called when window becomes fully visible
       
   143      */
       
   144     void WindowFullyVisible();
       
   145     
       
   146     /**
       
   147      * From MWindowVisibilityObserver
       
   148      * Called when window becomes partially visible
       
   149      */
       
   150     void WindowPartiallyVisible();
       
   151     
       
   152     /**
       
   153      * From MWindowVisibilityObserver
       
   154      * Called when window losts visibility.
       
   155      */
       
   156     void WindowNotVisible();
       
   157     
       
   158     /**
       
   159      * From MWindowVisibilityObserver
       
   160      * Returns the control witch creates the window (CHuiDisplayCoeControl)
       
   161      * @return Contorol. NULL if not have one. Ownership not transferred.
       
   162      */
       
   163     CCoeControl* CoeControl();
       
   164     
       
   165 private:
       
   166 
       
   167     /**
       
   168      * Default constructor, stores pointer to server instance
       
   169      * 
       
   170      * @param aServer Server which the client has connected.
       
   171      */
       
   172     CAlfAppSrvSession(const CAlfAppServer* aServer);
       
   173 
       
   174     /**
       
   175      * Second phase constructor
       
   176      */
       
   177     void ConstructL();
       
   178 
       
   179     void EnvSetRefreshModeL(const RMessage2& aMessage);
       
   180     void EnvSetMaxFrameRateL(const RMessage2& aMessage);
       
   181     void EnvContinueRefreshL(const RMessage2& aMessage);
       
   182     void EnvPauseRefreshL(const RMessage2& aMessage);
       
   183     void EnvRefreshCallBackL(const RMessage2& aMessage);
       
   184     void EnvSetIdleThresholdL(const RMessage2& aMessage);
       
   185     void EnvRendererL(const RMessage2& aMessage);
       
   186     //void BorderArrayAppendBrushL(const RMessage2& aMessage);
       
   187     void RosterHideL(const RMessage2& aMessage);
       
   188     void RosterShowVisualL(const RMessage2& aMessage);
       
   189     void RosterHideVisualL(const RMessage2& aMessage);
       
   190     void RosterMoveVisualToFrontL(const RMessage2& aMessage);
       
   191     void RosterSetPointerEventFlagsL(const RMessage2& aMessage);
       
   192     void RosterAddPointerEventObserverL(const RMessage2& aMessage);
       
   193     void RosterRemovePointerEventObserverL(const RMessage2& aMessage);
       
   194     void RosterSetPointerDragTresholdL(const RMessage2& aMessage);    
       
   195     void RosterDisableLongTapEventWhenDraggingL(const RMessage2& aMessage);
       
   196     void TextureCreateAnimatedL(const RMessage2& aMessage); 
       
   197     void TextureStartAnimation(const RMessage2& aMessage);
       
   198     void TextureStopAnimation(const RMessage2& aMessage);
       
   199     void TextureCreateL(const RMessage2& aMessage);
       
   200     void TextureLoadL(const RMessage2& aMessage);
       
   201     void TextureUnload(const RMessage2& aMessage);
       
   202     void TextureDelete(const RMessage2& aMessage);
       
   203     void TextureRelease(const RMessage2& aMessage);
       
   204     void TextureRestore(const RMessage2& aMessage);
       
   205     void TextureNotifySkinChanged(const RMessage2& aMessage);
       
   206     void TextureBlurL(const RMessage2& aMessage);
       
   207     void TextureHasContentL(const RMessage2& aMessage);
       
   208     void TextureSetAutoSizeParamsL(const RMessage2& aMessage);    
       
   209     void LayoutMetricsTextStyleDataL(const RMessage2& aMessage);
       
   210 
       
   211     void DoFocusLostEffect(TInt aEffect, CHuiVisual& aRootVisual );
       
   212     void DoFocusGainedEffect(TInt aEffect, CHuiVisual& aRootVisual );
       
   213 
       
   214     /**
       
   215      * Checks that texture owner id has been updated.
       
   216      * @param aMessage message.
       
   217      * @return ETrue if it's ok to continue, EFalse otherwise.
       
   218      */
       
   219     TBool RequireTextureOwnerId(const RMessage2& aMessage);
       
   220     
       
   221     /**
       
   222      * Updates @c iTextureOwnedId.
       
   223      * This method must be called successfully before @c TextureOwnerId 
       
   224      * method can be called.
       
   225      * @param aMessage message.
       
   226      */
       
   227     void UpdateTextureOwnerIdL(const RMessage2& aMessage);
       
   228     
       
   229     /**
       
   230      * Returns texture owner id.
       
   231      * This method must not be called before @c UpdateTextureOwnerIdL
       
   232      * has been called successfully.
       
   233      * @return texture owner id.
       
   234      */
       
   235     inline TProcessId TextureOwnerId() const;
       
   236     
       
   237     /**
       
   238      * Configure batch commands execution.
       
   239      * This is used by unit tests in order to test all branches.
       
   240      * @param aMessage message containing configuration.
       
   241      */
       
   242     void ConfigureBatchCommandExecutionL( const RMessage2& aMessage );
       
   243     
       
   244     /**
       
   245      * Executes batch commands.
       
   246      * @param aMessage message to be executed.
       
   247      */
       
   248     void ExecuteBatchCommandsL( const RMessage2& aMessage );
       
   249 
       
   250     /**
       
   251      * Executes batch commands using dynamic buffer, i.e. common buffer or memory allocated.
       
   252      * @param aMessage message to be executed.
       
   253      * @return ETrue if command was executed, EFalse if not.
       
   254      */
       
   255     TBool ExecuteBatchCommandsUsingDynamicBufferL( const RMessage2& aMessage );
       
   256 
       
   257     /**
       
   258      * Executes batch commands using fixed buffer, i.e. common buffer or stack allocated.
       
   259      * @param aMessage message to be executed.
       
   260      */
       
   261     void ExecuteBatchCommandsUsingFixedBufferL( const RMessage2& aMessage );
       
   262 
       
   263     /**
       
   264      * Executes commands using specified buffer.
       
   265      * @param aBuffer buffer to be used.
       
   266      * @param aMessageLength message length.
       
   267      * @param aMessage message to be executed.
       
   268      * @return amount of bytes executed commands took.
       
   269      */
       
   270     TInt ExecuteBatchCommandsUsingBufferL( 
       
   271         TDes8& aBuffer, TInt aMessageLength, const RMessage2& aMessage );
       
   272     
       
   273     /**
       
   274      * Execute commands from descriptor.
       
   275      * @param aDescriptor descriptor which contains commands.
       
   276      * @param aSpaceNeeded this will be updated to contain value
       
   277      *        indicating how much space is needed.
       
   278      * @return amount of bytes executed commands took.
       
   279      */
       
   280     TInt ExecuteCommandsFromDescriptorL( 
       
   281         const TDesC8& aSource, 
       
   282         TInt& aSpaceNeeded );
       
   283 
       
   284     /**
       
   285      * Checks whether it is allowed to execute using dynamic buffer.
       
   286      * @return ETrue if it's allowed, EFalse otherwise.
       
   287      */
       
   288     inline TBool AllowExecuteUsingDynamicBuffer() const;
       
   289 
       
   290     /**
       
   291      * Checks whether it is allowed to execute using common buffer.
       
   292      * @return ETrue if it's allowed, EFalse otherwise.
       
   293      */
       
   294     inline TBool AllowExecuteUsingCommonBuffer() const;
       
   295 
       
   296     /**
       
   297      * Returns reference to texture manager.
       
   298      * @return reference to texture manager.
       
   299      */
       
   300     inline CAlfSrvTextureManager& AlfTextureManager();
       
   301 
       
   302     /**
       
   303      * Starts waiting for texture information for client.
       
   304      */
       
   305     void NotifyTextureInfo( const RMessage2& aMessage );
       
   306     
       
   307     /**
       
   308      * Checks if this session has pending texture information to be
       
   309      * delivered to client side.
       
   310      */
       
   311     inline TBool HasPendingTextureInfo() const;
       
   312     
       
   313     /**
       
   314      * Tries to deliver texture info to client.
       
   315      */
       
   316     void DeliverTextureInfo();
       
   317    
       
   318     /**
       
   319      * Finds position of next texture info for delivery.
       
   320      * @param aPriority priority to look for (0 or 1).
       
   321      * @return position, or KErrNotFound if not found.
       
   322      */
       
   323     TInt FindNextTextureInfoForDelivery( 
       
   324         TInt aPriority, TInt aStartPos ) const;
       
   325     
       
   326     /**
       
   327      * Finds texture info structure position by texture id.
       
   328      * @param aTextureId texture id to be searched.
       
   329      * @return position, or KErrNotFound if not found.
       
   330      */
       
   331     TInt FindTextureInfoById( TInt aTextureId ) const;    
       
   332 
       
   333     /**
       
   334      * Removes texture info based on id.
       
   335      * @param aTextureId texture id
       
   336      */
       
   337     void RemoveTextureInfo( TInt aTextureId );
       
   338     
       
   339     void ShowControlGroupsInOrderL(CHuiDisplay& aDisplay);
       
   340     void StoreControlGroupOrderL(CHuiDisplay& aDisplay, TBool aAlsoHide );
       
   341     
       
   342    /**
       
   343     * Post QT drawing command buffer to CanvasVisual    
       
   344     */
       
   345     void PostQtCommandBufferL( const RMessage2& aMessage );
       
   346     
       
   347     
       
   348     /*
       
   349      *  Frame rate reporting enablers
       
   350      */
       
   351     void ReportFrameRateBegin( const RMessage2& aMessage );
       
   352     
       
   353     void ReportFrameRateEnd( const RMessage2& aMessage );
       
   354     
       
   355 // from base class MAlfSrvTextureManagerClient
       
   356     
       
   357     virtual TBool GetTextureSize( 
       
   358         TInt aTextureId, 
       
   359         TSize& aTextureSize,
       
   360         TBool& aHasBeenDelivered );
       
   361     virtual void SetTextureSize(
       
   362         TInt aTextureId,
       
   363         const TSize& aTextureSize,
       
   364         TInt aPriority );
       
   365     virtual void RemoveTextureSize( TInt aTextureId );
       
   366     virtual void TextureSizeChangesCompleted();
       
   367     
       
   368     void EnvEnableLowMemoryState(const RMessage2& aMessage);
       
   369     void EnvForceSwRendering(const RMessage2& aMessage);
       
   370         
       
   371 private:
       
   372 
       
   373     // Owned items which need to be deleted with the session is terminated.
       
   374     RPointerArray<CBase> iOwnershipItems; 
       
   375     RPointerArray<CHuiTexture> iTextures;
       
   376     RPointerArray<CHuiGifAnimationTexture> iAnimatedTextures;
       
   377     
       
   378     // Is client the focused window group?
       
   379     TBool iFocused;   
       
   380     
       
   381     // Is client partially visible (matters only if iFocused = EFalse )
       
   382     TBool iPartiallyVisible;
       
   383     
       
   384     // Refresh mode
       
   385     THuiRefreshMode iRefreshMode;
       
   386     
       
   387     // Max frame rate
       
   388     TReal32 iMaxFrameRate;
       
   389     
       
   390     // Idle threshold
       
   391     TInt iIdleThreshold;
       
   392     
       
   393     TBool iUsesFullScreen;
       
   394     
       
   395     TRect iClientDisplayRect;
       
   396     
       
   397     CAlfSrvEffectEnv* iEffectEnv;
       
   398 
       
   399     /**
       
   400      * ETrue if @c iTextureOwnerId contains valid value.
       
   401      * EFalse otherwise.
       
   402      */
       
   403     TBool iTextureOwnedIdSet;    
       
   404     
       
   405     /**
       
   406      * Texture owner id.
       
   407      * This contains valid value only if @c iTextureOwnedIdSet
       
   408      * is set to true.
       
   409      */
       
   410     TProcessId iTextureOwnerId;
       
   411     
       
   412     enum TAlfExecutionFlags
       
   413         {
       
   414         // Allow execution using dynammic buffer.
       
   415         EAlfExecuteUsingDynamicBuffer = 0x1,
       
   416         // Allow execution using common buffer.
       
   417         EAlfExecuteUsingCommonBuffer = 0x2
       
   418         };
       
   419             
       
   420     // Current execution flags, see TAlfExecutionFlags.
       
   421     TInt iExecutionFlags;
       
   422     
       
   423     /**
       
   424      * Texture info observer event.
       
   425      */
       
   426     RMessagePtr2 iTextureInfoEvent;
       
   427     
       
   428     /**
       
   429      * Structure containing information about a texture.
       
   430      */
       
   431     struct TAlfTextureInfo
       
   432         {
       
   433         enum TAlfTextureInfoFlags
       
   434             {
       
   435             // Indicates that size has been changed
       
   436             // and new size should be (eventually)
       
   437             // be delivered to client.
       
   438             EAlfFlagTextureSizeChanged = 1,
       
   439             // Indicates that texture size has been
       
   440             // delivered to client.
       
   441             EAlfFlagTextureDelivered = 2
       
   442             };
       
   443         
       
   444         // Flags. Sum of subset of TAlfTextureInfoFlags.
       
   445         TInt8 iFlags;
       
   446         // Delivery priority. The smaller the value
       
   447         // the higher the priority.
       
   448         TInt8 iDeliveryPriority;
       
   449         // Client side texture id.
       
   450         TInt iTextureId;
       
   451         // New texture size.
       
   452         TSize iTextureSize;
       
   453         };
       
   454 
       
   455     /**
       
   456      * Array of texture information. 
       
   457      * Own.
       
   458      */
       
   459     RArray< TAlfTextureInfo > iTextureInfo;
       
   460     
       
   461     /**
       
   462      * Previous index used for iTextureInfo
       
   463      */
       
   464     mutable TInt iPreviousTextureInfoIndex;
       
   465     
       
   466 	// Contains references to all ongoing FPS measurements
       
   467     RHashMap<TUint32,TFrameStamp> iFPSMeasurementArray;
       
   468     
       
   469     RPointerArray<CHuiControlGroup> iControlGroupOrder;
       
   470     };
       
   471 
       
   472 #endif // C_ALFAPPSRVSESSION_H