uiacceltk/hitchcock/Client/src/alfdisplaysubsession.cpp
changeset 0 15bf7259bb7c
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:   Sub-session for display
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alfdisplaysubsession.h"
       
    21 #include "alf/alfconstants.h"
       
    22 #include "alf/alfdisplaybackgrounditem.h"
       
    23 #include "alflogger.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Opens subsession
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 TInt RAlfDisplaySubSession::Open( RAlfClient& aSession, const TRect& aRect, TInt aDisplayType, 
       
    32 	TUid aBufferUid )
       
    33     {
       
    34     if (aDisplayType >= CAlfDisplay::EDisplayNormal)       
       
    35     	{   	
       
    36     	TPckg<TRect> rectPckg(aRect);
       
    37     
       
    38     	TAlfDisplayCreateParams2 params;
       
    39     	params.iWindowGroupId = 0;
       
    40     	CCoeEnv* coeStatic = CCoeEnv::Static();
       
    41     	if ( coeStatic )
       
    42         	{
       
    43         	params.iWindowGroupId = coeStatic->RootWin().Identifier();
       
    44         	}
       
    45     	params.iDisplayType = aDisplayType;
       
    46     	params.iBufferUid = aBufferUid;
       
    47     
       
    48     	TPckg<TAlfDisplayCreateParams2> paramPckg(params);    
       
    49     	TAlfImplementationInformation info(EAlfDisplaySubSessionOpen2);
       
    50     	TPckgC<TAlfImplementationInformation> infoBuf(info);
       
    51     	return CreateSubSession( 
       
    52         	aSession,
       
    53         	EAlfCreateSubSession,
       
    54         	TIpcArgs( &infoBuf, &rectPckg, &paramPckg ));
       
    55     	}    
       
    56     else // deprecated API
       
    57     	{
       
    58     	TPckg<TRect> rectPckg(aRect);
       
    59     
       
    60     	TAlfDisplayCreateParams params;
       
    61     	params.iWindowGroupId = 0;
       
    62     	CCoeEnv* coeStatic = CCoeEnv::Static();
       
    63     	if ( coeStatic )
       
    64         	{
       
    65         	params.iWindowGroupId = coeStatic->RootWin().Identifier();
       
    66         	}
       
    67     	params.iDisplayType = aDisplayType;
       
    68     
       
    69     	TPckg<TAlfDisplayCreateParams> paramPckg(params);    
       
    70     	TAlfImplementationInformation info(EAlfDisplaySubSessionOpen);
       
    71     	TPckgC<TAlfImplementationInformation> infoBuf(info);
       
    72     	return CreateSubSession( 
       
    73         	aSession,
       
    74         	EAlfCreateSubSession,
       
    75         	TIpcArgs( &infoBuf, &rectPckg, &paramPckg ));
       
    76     	}
       
    77     }
       
    78  
       
    79 // ---------------------------------------------------------------------------
       
    80 // Closes subsession
       
    81 // ---------------------------------------------------------------------------
       
    82 //   
       
    83 void RAlfDisplaySubSession::Close()
       
    84     {
       
    85     CloseSubSession( EAlfCloseSubSession );
       
    86     }
       
    87     
       
    88 // ---------------------------------------------------------------------------
       
    89 // Display background
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 TInt RAlfDisplaySubSession::SetClearBackground( TInt aClearBackground )
       
    93     {
       
    94     TInt err = SendReceive(
       
    95         EAlfDoSubSessionCmd, 
       
    96         TIpcArgs( EAlfDisplaySetClearBackground, aClearBackground ) );
       
    97     if ( err != KErrNone )
       
    98         {
       
    99         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetClearBackground return error %d", err )
       
   100         }
       
   101     return err;
       
   102     }
       
   103  
       
   104 // ---------------------------------------------------------------------------
       
   105 // Sets visible area
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 TInt RAlfDisplaySubSession::SetVisibleArea( const TRect& aRect, TBool aForce)
       
   109     {
       
   110     TPckg<TRect> rectPckg(aRect);
       
   111     TInt err;
       
   112     if(aForce)
       
   113         {
       
   114         err = SendReceive(
       
   115             EAlfDoSubSessionCmd, 
       
   116             TIpcArgs(EAlfDisplayForceSetVisibleArea, &rectPckg) );
       
   117         }
       
   118     else
       
   119         {
       
   120         err = SendReceive(
       
   121             EAlfDoSubSessionCmd, 
       
   122             TIpcArgs(EAlfDisplaySetVisibleArea, &rectPckg) );        
       
   123         }
       
   124 
       
   125     if ( err != KErrNone )
       
   126         {
       
   127         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetVisibleArea return error %d", err )
       
   128         }
       
   129     return err;
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // Returns visible area
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 TInt RAlfDisplaySubSession::VisibleArea( TRect& aRect ) const
       
   137     {
       
   138     TPckg<TRect> rectPckg(aRect);
       
   139     TInt err = SendReceive(
       
   140         EAlfDoSubSessionCmd, 
       
   141         TIpcArgs(EAlfDisplayVisibleArea,0,&rectPckg) );
       
   142         
       
   143     if ( err != KErrNone )
       
   144         {
       
   145         __ALFLOGSTRING1( "RAlfDisplaySubSession::VisibleArea return error %d", err )
       
   146         }
       
   147     return err;
       
   148     }
       
   149 
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // Sets display dirty.
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void RAlfDisplaySubSession::SetDirty()
       
   156     {
       
   157     Send/*Receive*/(
       
   158         EAlfDoSubSessionCmd, 
       
   159         TIpcArgs( EAlfDisplaySetDirty ) );
       
   160     __ALFLOGSTRING( "RAlfDisplaySubSession::SetDirty sent" );        
       
   161     }
       
   162     
       
   163 // ---------------------------------------------------------------------------
       
   164 // Sets rendering quality
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 TInt RAlfDisplaySubSession::SetQuality(TAlfQuality aRenderingQuality)
       
   168     {
       
   169     TPckg<TAlfQuality> inPckg(aRenderingQuality);
       
   170     TInt err = SendReceive(
       
   171         EAlfDoSubSessionCmd, 
       
   172         TIpcArgs(EAlfDisplaySetQuality, &inPckg) );
       
   173     if ( err != KErrNone )
       
   174         {
       
   175         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetQuality return error %d", err )
       
   176         }
       
   177     return err;        
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // Returns rendering quality
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 TInt RAlfDisplaySubSession::Quality(TAlfQuality& aRenderingQuality) const
       
   185     {
       
   186     TPckg<TAlfQuality> retPckg(aRenderingQuality);
       
   187     TInt err = SendReceive(
       
   188         EAlfDoSubSessionCmd, 
       
   189         TIpcArgs(EAlfDisplayQuality,0,&retPckg) );
       
   190         
       
   191     if ( err != KErrNone )
       
   192         {
       
   193         __ALFLOGSTRING1( "RAlfDisplaySubSession::Quality return error %d", err )
       
   194         }
       
   195     return err;        
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // Sets flag to specify if depth test is to be used
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 TInt RAlfDisplaySubSession::SetUseDepth(TBool aUseDepth)
       
   203     {
       
   204     TPckg<TBool> inPckg(aUseDepth);
       
   205     TInt err = SendReceive(
       
   206         EAlfDoSubSessionCmd, 
       
   207         TIpcArgs(EAlfDisplaySetUseDepth, &inPckg) );
       
   208     if ( err != KErrNone )
       
   209         {
       
   210         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetUseDepth return error %d", err )
       
   211         }
       
   212     return err;                
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // Sets usage hint for the display.
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 TInt RAlfDisplaySubSession::SetUsage(TUint aUsageHint)
       
   220     {
       
   221     TPckg<TUint> inPckg(aUsageHint);
       
   222 
       
   223     TInt err = SendReceive(
       
   224         EAlfDoSubSessionCmd, 
       
   225         TIpcArgs(EAlfDisplaySetUsage,&inPckg) );
       
   226         
       
   227     if ( err != KErrNone )
       
   228         {
       
   229         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetUsageHint return error %d", err )
       
   230         }
       
   231     return err;        
       
   232         
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------------------------
       
   236 // Sets background items
       
   237 // ---------------------------------------------------------------------------
       
   238 //
       
   239 TInt RAlfDisplaySubSession::SetBackgroundItemsL(const RArray<TAlfDisplayBackgroundItem>& aItems)
       
   240     {
       
   241     HBufC8* buffer = ExternalizeLC(aItems);
       
   242 
       
   243     TInt err = SendReceive(
       
   244         EAlfDoSubSessionCmd, 
       
   245         TIpcArgs(EAlfDisplaySetBackgroundItems, buffer) );
       
   246         
       
   247     if ( err )
       
   248         {
       
   249         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetBackgroundItemsL error %d", err )
       
   250         }
       
   251         
       
   252     CleanupStack::PopAndDestroy( buffer );        
       
   253     return err;        
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // 
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 TInt RAlfDisplaySubSession::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   261     {
       
   262     TPckg<TAdvancedPointerEvent> inPckg(*aPointerEvent.AdvancedPointerEvent());
       
   263 
       
   264     TInt err = SendReceive(
       
   265         EAlfDoSubSessionCmd, 
       
   266         TIpcArgs(EAlfDisplayHandlePointerEvent,&inPckg) );
       
   267         
       
   268     if ( err != KErrNone )
       
   269         {
       
   270         __ALFLOGSTRING1( "RAlfDisplaySubSession::HandlePointerEventL return error %d", err )
       
   271         }
       
   272     return err;        
       
   273     }
       
   274 
       
   275 // ---------------------------------------------------------------------------
       
   276 // Suppresses automatic fading
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 TInt RAlfDisplaySubSession::SuppressAutomaticFading( TBool aSuppress )
       
   280     {
       
   281     TPckg<TBool> inPckg(aSuppress);
       
   282 
       
   283     TInt err = SendReceive(
       
   284         EAlfDoSubSessionCmd, 
       
   285         TIpcArgs( EAlfDisplaySuppressAutomaticFading, &inPckg ) );
       
   286 
       
   287     if ( err != KErrNone )
       
   288         {
       
   289         __ALFLOGSTRING1( "RAlfDisplaySubSession::SuppressAutomaticFading return error %d", err )
       
   290         }
       
   291     return err;
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // 
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 void RAlfDisplaySubSession::SetClientWindowForDrawingL(TInt aWindowGroupId, TInt aClientWindowHandle, TInt aVisualHandle)
       
   299 	{
       
   300 	TInt3 data(aWindowGroupId, aClientWindowHandle, aVisualHandle);
       
   301     TPckg<TInt3> inPckg(data);
       
   302     TInt err = SendReceive(
       
   303         EAlfDoSubSessionCmd, 
       
   304         TIpcArgs(EAlfDisplaySetClientWindowForDrawing, &inPckg) );
       
   305         
       
   306     if ( err != KErrNone )
       
   307         {
       
   308         __ALFLOGSTRING1( "RAlfDisplaySubSession::SetClientWindowForDrawing return error %d", err )
       
   309         }
       
   310   User::LeaveIfError(err);
       
   311 	}