/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-// CLASS HEADER
-#include <dali/integration-api/adaptors/adaptor.h>
-
-#include <dali/public-api/object/base-object.h>
-#include <dali/devel-api/adaptor-framework/render-surface.h>
-
-namespace Dali
-{
+#include <toolkit-window.h>
-class EglInterface;
-class DisplayConnection;
-class ThreadSynchronizationInterface;
+// Don't want to include the actual window.h which otherwise will be indirectly included by adaptor.h.
+#define DALI_WINDOW_H
+#include <dali/integration-api/adaptors/adaptor.h>
-namespace Integration
-{
+#include <dali/integration-api/adaptors/scene-holder.h>
-class GlAbstraction;
+#include <dali/public-api/object/base-object.h>
-} // namespace Integration
+#include <toolkit-adaptor-impl.h>
+#include <dali/integration-api/debug.h>
+#include <test-application.h>
+#include <test-render-surface.h>
-class TestRenderSurface : public RenderSurface
+namespace Dali
{
-public:
- virtual PositionSize GetPositionSize() const { PositionSize size; return size; }
-
- virtual void InitializeEgl( EglInterface& egl ) {}
-
- virtual void CreateEglSurface( EglInterface& egl ) {}
-
- virtual void DestroyEglSurface( EglInterface& egl ) {}
-
- virtual bool ReplaceEGLSurface( EglInterface& egl ) { return false; }
-
- virtual void MoveResize( Dali::PositionSize positionSize ) {}
-
- virtual void SetViewMode( ViewMode viewMode ) {}
-
- virtual void StartRender() {}
-
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) { return false; }
-
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) {}
-
- virtual void StopRender() {}
-
- virtual void ReleaseLock() {}
-
- virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {}
-
-};
namespace Internal
{
namespace Adaptor
{
-class Adaptor: public BaseObject
-{
-public:
- static Dali::Adaptor& Get();
- Adaptor();
- ~Adaptor();
-
-public:
- static Dali::RenderSurface& GetSurface();
- static Dali::Adaptor::AdaptorSignalType& AdaptorSignal();
-};
+bool Adaptor::mAvailable = false;
+Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
+Dali::WindowContainer Adaptor::mWindows;
+Dali::Adaptor::WindowCreatedSignalType* Adaptor::mWindowCreatedSignal = nullptr;
Dali::Adaptor& Adaptor::Get()
{
Dali::Adaptor* adaptor = new Dali::Adaptor;
+ Adaptor::mAvailable = true;
return *adaptor;
}
-Dali::RenderSurface& Adaptor::GetSurface()
+Dali::RenderSurfaceInterface& Adaptor::GetSurface()
{
- Dali::RenderSurface *renderSurface = new Dali::TestRenderSurface;
+ Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast <Dali::RenderSurfaceInterface*>( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) );
return *renderSurface;
}
+Dali::WindowContainer Adaptor::GetWindows()
+{
+ return Adaptor::mWindows;
+}
+
Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
{
Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
return *signal;
}
+Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
+{
+ if ( !Adaptor::mWindowCreatedSignal )
+ {
+ Adaptor::mWindowCreatedSignal = new Dali::Adaptor::WindowCreatedSignalType;
+ }
+
+ return *Adaptor::mWindowCreatedSignal;
}
+
+} // namespace Adaptor
+} // namespace Internal
+
+Adaptor& Adaptor::New( Window window )
+{
+ return Internal::Adaptor::Adaptor::Get();
}
+
+Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
+{
+ return Internal::Adaptor::Adaptor::Get();
}
-namespace Dali
+Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface )
{
+ return Internal::Adaptor::Adaptor::Get();
+}
-Adaptor& Adaptor::New( Window window )
+Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
{
return Internal::Adaptor::Adaptor::Get();
}
-Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window )
+{
+ return Internal::Adaptor::Adaptor::Get();
+}
+
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration )
{
return Internal::Adaptor::Adaptor::Get();
}
-Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface )
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface )
{
return Internal::Adaptor::Adaptor::Get();
}
-Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface, Configuration::ContextLoss configuration )
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
{
return Internal::Adaptor::Adaptor::Get();
}
{
}
-bool Adaptor::AddIdle( CallbackBase* callback )
+bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
{
- return false;
+ const bool isAvailable = IsAvailable();
+
+ if( isAvailable )
+ {
+ Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
+ }
+
+ return isAvailable;
}
-void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurface& surface )
+void Adaptor::RemoveIdle( CallbackBase* callback )
+{
+ const bool isAvailable = IsAvailable();
+
+ if( isAvailable )
+ {
+ for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
+ endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
+ it != endIt;
+ ++it )
+ {
+ if( callback == *it )
+ {
+ Internal::Adaptor::Adaptor::mCallbacks.Remove( it );
+ return;
+ }
+ }
+ }
+}
+
+void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
+{
+}
+
+void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
{
}
return Internal::Adaptor::Adaptor::AdaptorSignal();
}
-RenderSurface& Adaptor::GetSurface()
+Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
+{
+ return Internal::Adaptor::Adaptor::WindowCreatedSignal();
+}
+
+Dali::RenderSurfaceInterface& Adaptor::GetSurface()
{
return Internal::Adaptor::Adaptor::GetSurface();
}
+Dali::WindowContainer Adaptor::GetWindows() const
+{
+ return Internal::Adaptor::Adaptor::GetWindows();
+}
+
Any Adaptor::GetNativeWindowHandle()
{
Any window;
bool Adaptor::IsAvailable()
{
- return false;
+ return Internal::Adaptor::Adaptor::mAvailable;
}
void Adaptor::NotifySceneCreated()
{
}
-void Adaptor::SetMinimumPinchDistance(float distance)
-{
-}
-
void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
{
}
{
}
-void Adaptor::SetViewMode( ViewMode mode )
+class LogFactory : public LogFactoryInterface
{
-}
+public:
+ virtual void InstallLogFunction() const
+ {
+ Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
+ Dali::Integration::Log::InstallLogFunction(logFunction);
+ }
+
+ LogFactory()
+ {
+ }
+ virtual ~LogFactory()
+ {
+ }
+};
-void Adaptor::SetStereoBase( float stereoBase )
+LogFactory* gLogFactory = NULL;
+const LogFactoryInterface& Adaptor::GetLogFactory()
{
+ if( gLogFactory == NULL )
+ {
+ gLogFactory = new LogFactory;
+ }
+ return *gLogFactory;
}
Adaptor::Adaptor()
: mImpl( NULL )
{
+ Dali::PositionSize win_size;
+ win_size.width = 640;
+ win_size.height = 800;
+
+ Dali::Window window = Dali::Window::New( win_size, "" );
+ Internal::Adaptor::Adaptor::mWindows.push_back( window );
}
} // namespace Dali