Revert "[Tizen] Add GlWindow"
[platform/core/uifw/dali-adaptor.git] / dali / internal / offscreen / common / offscreen-application-impl.cpp
index eedf1b8..396dbc4 100644 (file)
  *
  */
 
-// EXTERNAL INCLUDES
-#include <dali/integration-api/adaptor-framework/adaptor.h>
-#include <dali/integration-api/adaptor-framework/native-render-surface.h>
+// CLASS HEADER
+#include <dali/internal/offscreen/common/offscreen-application-impl.h>
 
 // INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/offscreen/common/offscreen-window-impl.h>
-#include <dali/internal/offscreen/common/offscreen-window-factory.h>
-
-// CLASS HEADER
-#include <dali/internal/offscreen/common/offscreen-application-impl.h>
+#include <dali/internal/adaptor/common/thread-controller-interface.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/adaptor-framework/native-render-surface.h>
 
 namespace Dali
 {
@@ -32,72 +31,54 @@ namespace Dali
 namespace Internal
 {
 
-IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent)
+using RenderMode = Dali::OffscreenApplication::RenderMode;
+
+IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
 {
-  IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent );
+  IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
   return offscreenApplication;
 }
 
-OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent )
-: mState( READY )
+OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
 {
   // Generate a default window
-  auto windowFactory = Dali::Internal::GetOffscreenWindowFactory();
-  IntrusivePtr <Internal::OffscreenWindow > windowPtr = windowFactory->CreateOffscreenWindow( width, height, surface, isTranslucent ).release();
-  mDefaultWindow = Dali::OffscreenWindow( windowPtr.Get() );
-
-  // Generate DALi adaptor
-  NativeRenderSurface* naitveSurface = static_cast<NativeRenderSurface*>( windowPtr->GetSurface() );
+  IntrusivePtr< Internal::OffscreenWindow > impl = Internal::OffscreenWindow::New( width, height, surface, isTranslucent );
+  mDefaultWindow = Dali::OffscreenWindow( impl.Get() );
 
-  mAdaptor = &Dali::Adaptor::New( Dali::Integration::SceneHolder( windowPtr.Get() ), *naitveSurface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
+  mAdaptor.reset( Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( impl.Get() ), impl->GetSurface(), NULL,
+                            renderMode == RenderMode::AUTO ? Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED ) );
 
   // Initialize default window
-  windowPtr->Initialize( this, true );
+  impl->Initialize( true );
 }
 
-OffscreenApplication::~OffscreenApplication()
+void OffscreenApplication::Start()
 {
-  delete mAdaptor;
-  mAdaptor = nullptr;
-}
+  // Start the adaptor
+  mAdaptor->Start();
 
-Dali::Adaptor* OffscreenApplication::GetAdaptor()
-{
-  return mAdaptor;
+  Dali::OffscreenApplication handle( this );
+  mInitSignal.Emit();
+  mAdaptor->NotifySceneCreated();
 }
 
-void OffscreenApplication::Run()
+void OffscreenApplication::Stop()
 {
-  if( READY == mState )
-  {
-    // Start the adaptor
-    mAdaptor->Start();
-
-    mState = RUNNING;
-
-    mPreInitSignal.Emit();
-
-    mInitSignal.Emit();
+  // Stop the adaptor
+  mAdaptor->Stop();
 
-    mAdaptor->NotifySceneCreated();
-  }
+  Dali::OffscreenApplication handle( this );
+  mTerminateSignal.Emit();
 }
 
-void OffscreenApplication::Stop()
+Dali::OffscreenWindow OffscreenApplication::GetWindow()
 {
-  if( mState != STOPPED )
-  {
-    // Stop the adaptor
-    mAdaptor->Stop();
-    mState = STOPPED;
-
-    mTerminateSignal.Emit();
-  }
+  return mDefaultWindow;
 }
 
-Dali::OffscreenWindow OffscreenApplication::GetWindow()
+void OffscreenApplication::RenderOnce()
 {
-  return mDefaultWindow;
+  mAdaptor->RenderOnce();
 }
 
 } // namespace Internal