Separating integration-devel from devel package for 2nd party to use adaptor #2 ...
[platform/core/uifw/dali-adaptor.git] / adaptors / common / adaptor-impl.cpp
index d12bb01..c045004 100644 (file)
@@ -36,8 +36,7 @@
 
 #include <callback-manager.h>
 #include <trigger-event.h>
-#include <window-render-surface.h>
-#include <render-surface-impl.h>
+#include <render-surface.h>
 #include <tts-player-impl.h>
 #include <accessibility-manager-impl.h>
 #include <timer-impl.h>
 #include <clipboard-impl.h>
 #include <vsync-monitor.h>
 #include <object-profiler.h>
+#include <base/display-connection.h>
 
-#include <slp-logging.h>
-
-
+#include <tizen-logging.h>
 
 namespace Dali
 {
@@ -109,13 +107,11 @@ bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
 
 } // unnamed namespace
 
-Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout,
+Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, const DeviceLayout& baseLayout,
                              Dali::Configuration::ContextLoss configuration )
 {
-  DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );
-
   Dali::Adaptor* adaptor = new Dali::Adaptor;
-  Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
+  Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, baseLayout );
   adaptor->mImpl = impl;
 
   impl->Initialize(configuration);
@@ -131,14 +127,14 @@ void Adaptor::ParseEnvironmentOptions()
   unsigned int logPerformanceStats = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
   unsigned int logPerformanceStatsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
   unsigned int performanceTimeStampOutput= GetIntegerEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
-
+  unsigned int networkControl= GetIntegerEnvironmentVariable( DALI_ENV_NETWORK_CONTROL, 0 );
 
   unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
 
-  // all threads here (event, update, and render) will send their logs to SLP Platform's LogMessage handler.
-  Dali::Integration::Log::LogFunction  logFunction(Dali::SlpPlatform::LogMessage);
+  // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
+  Dali::Integration::Log::LogFunction  logFunction(Dali::TizenPlatform::LogMessage);
 
-  mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceStats, logPerformanceStatsFrequency, performanceTimeStampOutput, logPanGesture );
+  mEnvironmentOptions.SetLogOptions( logFunction, networkControl, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceStats, logPerformanceStatsFrequency, performanceTimeStampOutput, logPanGesture );
 
   int predictionMode;
   if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
@@ -215,6 +211,13 @@ void Adaptor::ParseEnvironmentOptions()
     mEnvironmentOptions.SetGlesCallTime( glesCallTime );
   }
 
+  int windowWidth(0), windowHeight(0);
+  if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
+  {
+    mEnvironmentOptions.SetWindowWidth( windowWidth );
+    mEnvironmentOptions.SetWindowHeight( windowHeight );
+  }
+
   mEnvironmentOptions.InstallLogFunction();
 }
 
@@ -222,7 +225,11 @@ void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
 {
   ParseEnvironmentOptions();
 
-  mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction;
+  mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
+
+  std::string path;
+  GetDataStoragePath( path );
+  mPlatformAbstraction->SetDataStoragePath( path );
 
   ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
   if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
@@ -260,7 +267,7 @@ void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
 
   mObjectProfiler = new ObjectProfiler();
 
-  mNotificationTrigger = new TriggerEvent( boost::bind(&Adaptor::ProcessCoreEvents, this) );
+  mNotificationTrigger = new TriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ) );
 
   mVSyncMonitor = new VSyncMonitor;
 
@@ -301,6 +308,10 @@ void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
   {
     Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
   }
+  if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() )
+  {
+    SurfaceResized( PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ));
+  }
 }
 
 Adaptor::~Adaptor()
@@ -357,22 +368,21 @@ void Adaptor::Start()
     mDeferredRotationObserver = NULL;
   }
 
-  // guarantee map the surface before starting render-thread.
-  mSurface->Map();
-
   // NOTE: dpi must be set before starting the render thread
   // use default or command line settings if not run on device
-#ifdef __arm__
-  // set the DPI value for font rendering
-  unsigned int dpiHor, dpiVer;
-  dpiHor = dpiVer = 0;
-  mSurface->GetDpi(dpiHor, dpiVer);
-
-  // tell core about the value
-  mCore->SetDpi(dpiHor, dpiVer);
-#else
-  mCore->SetDpi(mHDpi, mVDpi);
-#endif
+  if( mHDpi == 0 || mVDpi == 0 )
+  {
+    unsigned int dpiHor, dpiVer;
+    dpiHor = dpiVer = 0;
+    Dali::DisplayConnection::GetDpi(dpiHor, dpiVer);
+
+    // tell core about the value
+    mCore->SetDpi(dpiHor, dpiVer);
+  }
+  else
+  {
+    mCore->SetDpi(mHDpi, mVDpi);
+  }
 
   // Tell the core the size of the surface just before we start the render-thread
   PositionSize size = mSurface->GetPositionSize();
@@ -540,22 +550,12 @@ void Adaptor::SurfaceResized( const PositionSize& positionSize )
   }
 }
 
-void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
+void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
 {
-  // adaptor implementation needs the implementation of
-  RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
-  DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
+  mNativeWindow = nativeWindow;
+  mSurface = &surface;
 
-  ECore::WindowRenderSurface* windowSurface = dynamic_cast<Internal::Adaptor::ECore::WindowRenderSurface*>( &surface);
-  if( windowSurface != NULL )
-  {
-    windowSurface->Map();
-    // @todo Restart event handler with new surface
-  }
-
-  mSurface = internalSurface;
-
-  SurfaceSizeChanged( internalSurface->GetPositionSize() );
+  SurfaceSizeChanged(mSurface->GetPositionSize());
 
   // flush the event queue to give update and render threads chance
   // to start processing messages for new camera setup etc as soon as possible
@@ -564,7 +564,7 @@ void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
   mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
 
   // this method blocks until the render thread has completed the replace.
-  mUpdateRenderController->ReplaceSurface(internalSurface);
+  mUpdateRenderController->ReplaceSurface(mSurface);
 
   // Inform core, so that texture resources can be reloaded
   mCore->RecoverFromContextLoss();
@@ -572,7 +572,7 @@ void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
   mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
 }
 
-Dali::RenderSurface& Adaptor::GetSurface() const
+RenderSurface& Adaptor::GetSurface() const
 {
   return *mSurface;
 }
@@ -593,27 +593,27 @@ Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
   return mTtsPlayers[mode];
 }
 
-bool Adaptor::AddIdle(boost::function<void(void)> callBack)
+bool Adaptor::AddIdle( CallbackBase* callback )
 {
   bool idleAdded(false);
 
   // Only add an idle if the Adaptor is actually running
   if( RUNNING == mState )
   {
-    idleAdded = mCallbackManager->AddCallback(callBack, CallbackManager::IDLE_PRIORITY);
+    idleAdded = mCallbackManager->AddCallback( callback, CallbackManager::IDLE_PRIORITY );
   }
 
   return idleAdded;
 }
 
-bool Adaptor::CallFromMainLoop(boost::function<void(void)> callBack)
+bool Adaptor::CallFromMainLoop( CallbackBase* callback )
 {
   bool callAdded(false);
 
   // Only allow the callback if the Adaptor is actually running
   if ( RUNNING == mState )
   {
-    callAdded = mCallbackManager->AddCallback(callBack, CallbackManager::DEFAULT_PRIORITY);
+    callAdded = mCallbackManager->AddCallback( callback, CallbackManager::DEFAULT_PRIORITY );
   }
 
   return callAdded;
@@ -682,14 +682,22 @@ TriggerEventInterface& Adaptor::GetTriggerEventInterface()
 {
   return *mNotificationTrigger;
 }
+
 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
 {
   return mTriggerEventFactory;
 }
+
+SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
+{
+  return mSocketFactory;
+}
+
 RenderSurface* Adaptor::GetRenderSurfaceInterface()
 {
   return mSurface;
 }
+
 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
 {
   return mVSyncMonitor;
@@ -750,6 +758,10 @@ void Adaptor::SetMinimumPinchDistance(float distance)
   }
 }
 
+Any Adaptor::GetNativeWindowHandle()
+{
+  return mNativeWindow;
+}
 
 void Adaptor::AddObserver( LifeCycleObserver& observer )
 {
@@ -814,7 +826,7 @@ void Adaptor::RequestProcessEventsOnIdle()
   // and we haven't installed the idle notification
   if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
   {
-    mNotificationOnIdleInstalled = AddIdle( boost::bind( &Adaptor::ProcessCoreEventsFromIdle, this ) );
+    mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
   }
 }
 
@@ -882,7 +894,7 @@ void Adaptor::ProcessCoreEventsFromIdle()
   mNotificationOnIdleInstalled = false;
 }
 
-Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
+Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
 : mResizedSignal(),
   mLanguageChangedSignal(),
   mAdaptor(adaptor),
@@ -892,6 +904,7 @@ Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLay
   mVSyncMonitor(NULL),
   mGLES( NULL ),
   mEglFactory( NULL ),
+  mNativeWindow( nativeWindow ),
   mSurface( surface ),
   mPlatformAbstraction( NULL ),
   mEventHandler( NULL ),