uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp
branchRCL_3
changeset 11 46927d61fef3
parent 10 88b23e2e82e1
child 12 275a27dfa5ea
child 17 3ac8bf5c5014
equal deleted inserted replaced
10:88b23e2e82e1 11:46927d61fef3
    51 #include <uiacceltk/HuiTextureManager.h>
    51 #include <uiacceltk/HuiTextureManager.h>
    52 #include "alfsrvtexturemanager.h"
    52 #include "alfsrvtexturemanager.h"
    53 #include "alfshareddisplaycoecontrol.h"
    53 #include "alfshareddisplaycoecontrol.h"
    54 #include "alfuids.h"
    54 #include "alfuids.h"
    55 
    55 
    56 #ifdef SYMBIAN_BUILD_GCE
       
    57 #include "alfbridge.h"
    56 #include "alfbridge.h"
    58 #include "alfstreamerserver.h"
    57 #include "alfstreamerserver.h"
    59 #include "alfdecoderserverclient.h"
    58 #include "alfdecoderserverclient.h"
    60 #include "alfstreamerconsts.h"
    59 #include "alfstreamerconsts.h"
    61 #endif // #ifdef SYMBIAN_BUILD_GCE
    60 #include "HuiFxEngine.h"
       
    61 #include "alfstreamerconsts.h"
    62 
    62 
    63 // DISABLE this if you want to use the AHDemoApp layout switch. If this is enabled
    63 // DISABLE this if you want to use the AHDemoApp layout switch. If this is enabled
    64 // and switch is done through AHDemoApp, the layout will be rotated too much.
    64 // and switch is done through AHDemoApp, the layout will be rotated too much.
    65 #ifdef __WINSCW__
    65 #ifdef __WINSCW__
    66 // Use this, if you want the VGA layout to show correctly
    66 // Use this, if you want the VGA layout to show correctly
    67 #define ALF_USE_EMULATOR_LAYOUT_SWITCH_BUTTON
    67 #define ALF_USE_EMULATOR_LAYOUT_SWITCH_BUTTON
    68 #endif
    68 #endif
    69 
    69 
       
    70 NONSHARABLE_CLASS(TAlfEffectObserver): public MHuiEffectObserver
       
    71     {
       
    72     public:    
       
    73     TAlfEffectObserver(volatile TInt* aEffectCount, CAlfBridge& aBridge):iEffectCount((TInt*)aEffectCount), iBridge(aBridge){}
       
    74     void EffectAdded(CHuiFxEffect* aEffect)
       
    75         {
       
    76         if (iBridge.BridgerClient() && aEffect && aEffect->Handle())
       
    77             {    
       
    78             __ALFFXLOGSTRING1("Effect about to start 0x%x", aEffect->Handle());
       
    79             iBridge.BridgerClient()->SendBlind(EAlfCompleteSignal, TIpcArgs(aEffect->Handle(), EAlfSignalEffectStarted));
       
    80             }
       
    81         (*iEffectCount)++;
       
    82         }   
       
    83     void EffectComplete(CHuiFxEffect* aEffect)
       
    84         {
       
    85         if (iBridge.BridgerClient() && aEffect && aEffect->Handle())
       
    86             {    
       
    87             __ALFFXLOGSTRING1("Effect complete 0x%x", aEffect->Handle());
       
    88             iBridge.BridgerClient()->SendBlind(EAlfCompleteSignal, TIpcArgs(aEffect->Handle(), EAlfSignalEffectComplete));
       
    89             }
       
    90         (*iEffectCount)--;    
       
    91         }
       
    92     TInt* iEffectCount;
       
    93     CAlfBridge& iBridge;
       
    94     };
    70 
    95 
    71 _LIT(KAlfEventThreadName,"alfevents");
    96 _LIT(KAlfEventThreadName,"alfevents");
    72 NONSHARABLE_CLASS(CAlfEventCatcher): public CActive
    97 NONSHARABLE_CLASS(CAlfEventCatcher): public CActive
    73     { // this class does not actually catch the events but moves the wg so that alf can get pointer events
    98     { // this class does not actually catch the events but moves the wg so that alf can get pointer events
    74     public:
    99     public:
   625         if (iEventAo)
   650         if (iEventAo)
   626             {
   651             {
   627             iEventAo->Cancel();
   652             iEventAo->Cancel();
   628             }
   653             }
   629         delete iEventAo; // before session is being terminated       
   654         delete iEventAo; // before session is being terminated       
       
   655         if (iHuiEnv && iHuiEnv->EffectsEngine())
       
   656             {
       
   657             iHuiEnv->EffectsEngine()->SetObserver(0);    
       
   658             delete iAlfEffectObserver; // cannot exist if huienv was not present
       
   659             }    
   630         delete iHuiEnv;
   660         delete iHuiEnv;
   631         delete iSharedWindow;
   661         delete iSharedWindow;
   632 #ifdef SYMBIAN_BUILD_GCE
       
   633         delete iBridgeObj;
   662         delete iBridgeObj;
   634 #endif // #ifdef SYMBIAN_BUILD_GCE
       
   635         }
   663         }
   636     TBool iAllClientsClosed;
   664     TBool iAllClientsClosed;
   637 
   665 
   638     // Boolean flag indicating if non-fading of shared window is enabled or disabled.
   666     // Boolean flag indicating if non-fading of shared window is enabled or disabled.
   639     TBool iSharedWindowNonFading;
   667     TBool iSharedWindowNonFading;
   640 #ifdef SYMBIAN_BUILD_GCE
       
   641     CAlfBridge* iBridgeObj;
   668     CAlfBridge* iBridgeObj;
   642     CAlfStreamerBridge* iBridge;
   669     CAlfStreamerBridge* iBridge;
   643 #endif // #ifdef SYMBIAN_BUILD_GCE
   670     TAlfEffectObserver* iAlfEffectObserver;
   644     RWindow* iPlainWindow;
   671     RWindow* iPlainWindow;
   645     CHuiDisplay* iMainDisplay;
   672     CHuiDisplay* iMainDisplay;
   646     CHuiDisplay* iTVDisplay;
   673     CHuiDisplay* iTVDisplay;
   647     CAlfEventBridge* iEventAo;
   674     CAlfEventBridge* iEventAo;
   648     };
   675     };
   754 //
   781 //
   755 void CAlfAppUi::AllClientsClosed()
   782 void CAlfAppUi::AllClientsClosed()
   756     {
   783     {
   757 // In NGA master scene graph role, 
   784 // In NGA master scene graph role, 
   758 // we must not close the server even there were no hitchcock app clients present
   785 // we must not close the server even there were no hitchcock app clients present
   759 #ifndef SYMBIAN_BUILD_GCE
       
   760     iData->iAllClientsClosed = ETrue;
       
   761     CAknEnv::Static()->RunAppShutter();
       
   762 #endif // #ifdef SYMBIAN_BUILD_GCE
       
   763     }
   786     }
   764 
   787 
   765 // ---------------------------------------------------------------------------
   788 // ---------------------------------------------------------------------------
   766 // From class CAknAppUi.
   789 // From class CAknAppUi.
   767 // 2nd phase constructor
   790 // 2nd phase constructor
   866         iData->iPlainWindow->SetVisible(ETrue);
   889         iData->iPlainWindow->SetVisible(ETrue);
   867         iData->iPlainWindow->SetTransparencyAlphaChannel();
   890         iData->iPlainWindow->SetTransparencyAlphaChannel();
   868         iData->iPlainWindow->SetBackgroundColor(~0);          
   891         iData->iPlainWindow->SetBackgroundColor(~0);          
   869         }
   892         }
   870 
   893 
   871 #ifdef SYMBIAN_BUILD_GCE    
   894     iData->iBridge = CAlfStreamerBridge::NewL(0);
       
   895     iData->iBridge->iAlfWindowData.iAlfWindowGrpId = mainWg.Identifier();
       
   896     iData->iBridge->iAlfWindowData.iAlfWindowHandle =  iData->iPlainWindow->ClientHandle();
       
   897     iData->iBridge->iAlfWindowData.iScreenNumber = 0; // TBD multiple screen support
   872 
   898 
   873     iData->iBridgeObj = CAlfBridge::NewL( &iData->iBridge, iData->iHuiEnv );
   899     iData->iBridgeObj = CAlfBridge::NewL( &iData->iBridge, iData->iHuiEnv );
   874 	iData->iBridgeObj->iAppUi = this;
   900 	iData->iBridgeObj->iAppUi = this;
   875 		
   901 	
       
   902 	iData->iBridge->SetObserver(iData->iBridgeObj);
       
   903 	
       
   904 	iData->iAlfEffectObserver = new (ELeave) TAlfEffectObserver(&iData->iBridge->iActiveEffectCount, *iData->iBridgeObj);
       
   905 	iData->iHuiEnv->EffectsEngine()->SetObserver(iData->iAlfEffectObserver);
       
   906 			
   876     if( !iData->iPlainWindow)
   907     if( !iData->iPlainWindow)
   877         {
   908         {
   878         // Create default CAlfScreen already now to be able to show controlgroups early enough... 
   909         // Create default CAlfScreen already now to be able to show controlgroups early enough... 
   879   	    iData->iBridgeObj->AddNewScreenL(iData->iSharedWindow);
   910   	    iData->iBridgeObj->AddNewScreenL(iData->iSharedWindow);
   880         }
   911         }
   896         eventThread.Resume();
   927         eventThread.Resume();
   897         eventThread.Close();
   928         eventThread.Close();
   898         }
   929         }
   899 
   930 
   900     AppendDisplayOnSharedWindowL(*(iData->iBridgeObj->Display(0)));
   931     AppendDisplayOnSharedWindowL(*(iData->iBridgeObj->Display(0)));
   901 
   932     
   902     iData->iBridge = CAlfStreamerBridge::NewL(iData->iBridgeObj);
       
   903     iData->iBridge->iAlfWindowData.iAlfWindowGrpId = mainWg.Identifier();
       
   904     iData->iBridge->iAlfWindowData.iAlfWindowHandle =  iData->iPlainWindow->ClientHandle();
       
   905     iData->iBridge->iAlfWindowData.iScreenNumber = 0; // TBD multiple screen support
       
   906         
       
   907     TThreadId threadId;
   933     TThreadId threadId;
   908   	CAlfStreamerServer::LaunchServer(threadId, iData->iBridge);
   934   	CAlfStreamerServer::LaunchServer(threadId, iData->iBridge);
   909     
   935     
   910 #endif // #ifdef SYMBIAN_BUILD_GCE    
       
   911     // Inform texture manager that env has been created.
   936     // Inform texture manager that env has been created.
   912     iData->iServer->TextureManager().HandleEnvCreateL( *iData->iHuiEnv );
   937     iData->iServer->TextureManager().HandleEnvCreateL( *iData->iHuiEnv );
   913     
   938     
   914     // Construct transition effect instance if it does not yet exist
   939     // Construct transition effect instance if it does not yet exist
   915 	iData->iServer->CreateTransitionEffectsL();
   940 	iData->iServer->CreateTransitionEffectsL();
  1333 // 
  1358 // 
  1334 // ---------------------------------------------------------------------------
  1359 // ---------------------------------------------------------------------------
  1335 //
  1360 //
  1336 TInt CAlfAppUi::FirstAlfControlGroupIndex( TInt aScreenNumber )
  1361 TInt CAlfAppUi::FirstAlfControlGroupIndex( TInt aScreenNumber )
  1337     {
  1362     {
  1338 #ifdef SYMBIAN_BUILD_GCE
       
  1339     return iData->iBridgeObj->FirstAlfControlGroupIndex( aScreenNumber );
  1363     return iData->iBridgeObj->FirstAlfControlGroupIndex( aScreenNumber );
  1340 #endif // #ifdef SYMBIAN_BUILD_GCE
       
  1341     }
  1364     }
  1342 
  1365 
  1343 // ---------------------------------------------------------------------------
  1366 // ---------------------------------------------------------------------------
  1344 // 
  1367 // 
  1345 // ---------------------------------------------------------------------------
  1368 // ---------------------------------------------------------------------------
  1346 //
  1369 //
  1347 TInt CAlfAppUi::LastAlfControlGroupIndex( TInt aScreenNumber )
  1370 TInt CAlfAppUi::LastAlfControlGroupIndex( TInt aScreenNumber )
  1348     {
  1371     {
  1349 #ifdef SYMBIAN_BUILD_GCE
       
  1350     return iData->iBridgeObj->LastAlfControlGroupIndex( aScreenNumber );
  1372     return iData->iBridgeObj->LastAlfControlGroupIndex( aScreenNumber );
  1351 #endif // #ifdef SYMBIAN_BUILD_GCE
       
  1352     }
  1373     }
  1353 
  1374 
  1354 
  1375 
  1355 // ---------------------------------------------------------------------------
  1376 // ---------------------------------------------------------------------------
  1356 // 
  1377 // 
  1357 // ---------------------------------------------------------------------------
  1378 // ---------------------------------------------------------------------------
  1358 //
  1379 //
  1359 void CAlfAppUi::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber )
  1380 void CAlfAppUi::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber )
  1360     {
  1381     {
  1361 #ifdef SYMBIAN_BUILD_GCE
       
  1362     iData->iBridgeObj->ShowControlGroupL(aRoster, aGroup, aWhere, aScreenNumber);    
  1382     iData->iBridgeObj->ShowControlGroupL(aRoster, aGroup, aWhere, aScreenNumber);    
  1363     iData->iBridgeObj->HandleVisualVisibility( aScreenNumber );    
  1383     iData->iBridgeObj->HandleVisualVisibility( aScreenNumber );    
  1364 #endif // #ifdef SYMBIAN_BUILD_GCE
       
  1365 
  1384 
  1366     }
  1385     }
  1367 
  1386 
  1368 // ---------------------------------------------------------------------------
  1387 // ---------------------------------------------------------------------------
  1369 // PostQTCommandBufferL
  1388 // PostQTCommandBufferL
  1456 TInt CAlfAppUi::ReadPixels(CFbsBitmap* aBitmap)
  1475 TInt CAlfAppUi::ReadPixels(CFbsBitmap* aBitmap)
  1457     {
  1476     {
  1458     return iData->iBridgeObj->ReadPixels(aBitmap);
  1477     return iData->iBridgeObj->ReadPixels(aBitmap);
  1459     }
  1478     }
  1460     
  1479     
  1461 void CAlfAppUi::SetAlfAppWindowGroup( TInt aID )
  1480 void CAlfAppUi::SetAlfAppWindowGroup( TInt aId )
  1462     {
  1481     {
  1463     iData->iBridgeObj->SetWindowGroupAsAlfApp( aID );
  1482     iData->iBridgeObj->SetWindowGroupAsAlfApp( aId );
       
  1483     }
       
  1484 
       
  1485 void CAlfAppUi::RemoveAlfAppWindowGroup( TInt aId )
       
  1486     {
       
  1487     iData->iBridgeObj->RemoveWindowGroupAsAlfApp( aId );
  1464     }
  1488     }
  1465 
  1489 
  1466 CAlfAppSrvSessionBase* CAlfAppUi::SrvSessionForControlGroup(CHuiControlGroup& aGroup)
  1490 CAlfAppSrvSessionBase* CAlfAppUi::SrvSessionForControlGroup(CHuiControlGroup& aGroup)
  1467     {
  1491     {
  1468     return iData->iServer->SrvSessionForControlGroup(aGroup);
  1492     return iData->iServer->SrvSessionForControlGroup(aGroup);