Revert "Remove EGL surface in the update thread"
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
index ce8863c..2ecb543 100755 (executable)
@@ -20,6 +20,8 @@
 #include <dali/internal/adaptor/common/adaptor-builder-impl.h>
 
 // EXTERNAL INCLUDES
+#include <errno.h>
+#include <sys/stat.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/object/any.h>
@@ -145,14 +147,6 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
   GetDataStoragePath( path );
   mPlatformAbstraction->SetDataStoragePath( path );
 
-  ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
-  if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
-  {
-    dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
-  }
-
-  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from files automatically.
-
   if( mEnvironmentOptions->PerformanceServerRequired() )
   {
     mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
@@ -184,7 +178,6 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
                                   mGLES,
                                   eglSyncImpl,
                                   eglContextHelperImpl,
-                                  dataRetentionPolicy ,
                                   ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
                                   mGraphics->GetDepthBufferRequired(),
                                   mGraphics->GetStencilBufferRequired() );
@@ -201,7 +194,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
     mObjectProfiler = new ObjectProfiler( timeInterval );
   }
 
-  mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
+  mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
 
   mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow->GetSurface()->GetSurfaceType() );
 
@@ -308,11 +301,11 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
   std::string systemCachePath = GetSystemCachePath();
   if( ! systemCachePath.empty() )
   {
-    const int dir_err = system( std::string( "mkdir " + systemCachePath ).c_str() );
-    if (-1 == dir_err)
+    const int dir_err = mkdir( systemCachePath.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH );
+    if ( 0 != dir_err && errno != EEXIST )
     {
-        printf( "Error creating system cache directory: %s!\n", systemCachePath.c_str() );
-        exit(1);
+      DALI_LOG_ERROR( "Error creating system cache directory: %s!\n", systemCachePath.c_str() );
+      exit( 1 );
     }
   }
 
@@ -564,16 +557,6 @@ void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::Rende
   }
 }
 
-void Adaptor::DeleteSurface( Dali::RenderSurfaceInterface& surface )
-{
-  // Flush the event queue to give the update-render thread chance
-  // to start processing messages for new camera setup etc as soon as possible
-  ProcessCoreEvents();
-
-  // This method blocks until the render thread has finished rendering the current surface.
-  mThreadController->DeleteSurface( &surface );
-}
-
 Dali::RenderSurfaceInterface& Adaptor::GetSurface() const
 {
   return *mWindows.front()->GetSurface();
@@ -613,6 +596,12 @@ void Adaptor::RemoveIdle( CallbackBase* callback )
   mCallbackManager->RemoveIdleCallback( callback );
 }
 
+void Adaptor::ProcessIdle()
+{
+  bool idleProcessed = mCallbackManager->ProcessIdle();
+  mNotificationOnIdleInstalled = mNotificationOnIdleInstalled && !idleProcessed;
+}
+
 void Adaptor::SetPreRenderCallback( CallbackBase* callback )
 {
   mThreadController->SetPreRenderCallback( callback );
@@ -626,6 +615,10 @@ bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow, const std::
   // Add the new Window to the container - the order is not important
   mWindows.push_back( &windowImpl );
 
+  Dali::RenderSurfaceInterface* surface = windowImpl.GetSurface();
+
+  mThreadController->AddSurface( surface );
+
   mWindowCreatedSignal.Emit( childWindow );
 
   return true;
@@ -722,11 +715,6 @@ TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
   return *mNotificationTrigger;
 }
 
-TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
-{
-  return mTriggerEventFactory;
-}
-
 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
 {
   return mSocketFactory;
@@ -763,6 +751,11 @@ Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
   return *mPlatformAbstraction;
 }
 
+void Adaptor::GetWindowContainerInterface( WindowContainer& windows )
+{
+  windows = mWindows;
+}
+
 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
 {
   if( mTtsPlayers[mode] )
@@ -978,11 +971,12 @@ void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, Surfa
 
 void Adaptor::SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
 {
+  // Nofify surface resizing before flushing event queue
+  mThreadController->ResizeSurface();
+
   // Flush the event queue to give the update-render thread chance
   // to start processing messages for new camera setup etc as soon as possible
   ProcessCoreEvents();
-
-  mThreadController->ResizeSurface();
 }
 
 void Adaptor::NotifySceneCreated()
@@ -1047,6 +1041,11 @@ bool Adaptor::IsMultipleWindowSupported() const
   return mConfigurationManager->IsMultipleWindowSupported();
 }
 
+bool Adaptor::IsRenderingWindows() const
+{
+  return ( mThreadController && mThreadController->IsRenderingWindows() );
+}
+
 void Adaptor::RequestUpdateOnce()
 {
   if( mThreadController )
@@ -1133,7 +1132,6 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor,
   mPerformanceInterface( nullptr ),
   mKernelTracer(),
   mSystemTracer(),
-  mTriggerEventFactory(),
   mObjectProfiler( nullptr ),
   mSocketFactory(),
   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),