*
*/
-// EXTERNAL INCLUDES
-#include <dali/integration-api/adaptor-framework/adaptor.h>
-#include <dali/internal/adaptor/common/adaptor-impl.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>
#include <dali/internal/adaptor/common/thread-controller-interface.h>
-
-// CLASS HEADER
-#include <dali/internal/offscreen/common/offscreen-application-impl.h>
-
-using Dali::Internal::Adaptor::ThreadMode;
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/adaptor-framework/native-render-surface.h>
namespace Dali
{
namespace Internal
{
+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, renderMode );
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() );
+ IntrusivePtr< Internal::OffscreenWindow > impl = Internal::OffscreenWindow::New( width, height, surface, isTranslucent );
+ mDefaultWindow = Dali::OffscreenWindow( impl.Get() );
- mAdaptor = Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( windowPtr.Get() ), windowPtr->GetSurface(),
- Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS, NULL,
- renderMode == RenderMode::AUTO ? ThreadMode::NORMAL : ThreadMode::RUN_IF_REQUESTED );
+ 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( true );
-}
-
-OffscreenApplication::~OffscreenApplication()
-{
- delete mAdaptor;
- mAdaptor = nullptr;
+ impl->Initialize( true );
}
void OffscreenApplication::Start()
{
- // Start the adaptor
- mAdaptor->Start();
- mInitSignal.Emit();
- mAdaptor->NotifySceneCreated();
+ // Start the adaptor
+ mAdaptor->Start();
+
+ Dali::OffscreenApplication handle( this );
+ mInitSignal.Emit();
+ mAdaptor->NotifySceneCreated();
}
void OffscreenApplication::Stop()
{
// Stop the adaptor
mAdaptor->Stop();
+
+ Dali::OffscreenApplication handle( this );
mTerminateSignal.Emit();
}