/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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 <algorithm>
-#include <dali/public-api/object/base-object.h>
-#include <dali/devel-api/adaptor-framework/render-surface.h>
+#include <toolkit-window-impl.h>
+
+// 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/adaptor-framework/adaptor.h>
+#include <dali/integration-api/adaptor-framework/scene-holder.h>
+
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/scene.h>
+#include <test-application.h>
+#include <toolkit-adaptor-impl.h>
+#include <toolkit-scene-holder-impl.h>
+#include <toolkit-test-application.h>
namespace Dali
{
+namespace Internal
+{
+namespace Adaptor
+{
+///////////////////////////////////////////////////////////////////////////////
+//
+// Dali::Internal::Adaptor::Adaptor Stub
+//
+///////////////////////////////////////////////////////////////////////////////
-class EglInterface;
-class DisplayConnection;
-class ThreadSynchronizationInterface;
+Dali::Adaptor* gAdaptor = nullptr;
-namespace Integration
+Dali::Adaptor& Adaptor::New()
{
+ DALI_ASSERT_ALWAYS(!gAdaptor);
+ gAdaptor = new Dali::Adaptor;
+ return *gAdaptor;
+}
-class GlAbstraction;
+Dali::Adaptor& Adaptor::Get()
+{
+ DALI_ASSERT_ALWAYS(gAdaptor);
+ return *gAdaptor;
+}
-} // namespace Integration
+Adaptor::Adaptor()
+{
+}
-class TestRenderSurface : public RenderSurface
+Adaptor::~Adaptor()
{
-public:
- virtual PositionSize GetPositionSize() const { PositionSize size; return size; }
+ gAdaptor = nullptr;
+}
- virtual void InitializeEgl( EglInterface& egl ) {}
+void Adaptor::Start(Dali::Window window)
+{
+ AddWindow(&GetImplementation(window));
+}
- virtual void CreateEglSurface( EglInterface& egl ) {}
+Integration::Scene Adaptor::GetScene(Dali::Window window)
+{
+ return window.GetScene();
+}
- virtual void DestroyEglSurface( EglInterface& egl ) {}
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
+{
+ if(hasReturnValue)
+ {
+ mReturnCallbacks.PushBack(callback);
+ }
+ else
+ {
+ mCallbacks.PushBack(callback);
+ }
+ return true;
+}
- virtual bool ReplaceEGLSurface( EglInterface& egl ) { return false; }
+void Adaptor::RemoveIdle(CallbackBase* callback)
+{
+ mCallbacks.Erase(std::remove_if(mCallbacks.Begin(), mCallbacks.End(), [&callback](CallbackBase* current) { return callback == current; }), mCallbacks.End());
+ mReturnCallbacks.Erase(std::remove_if(mReturnCallbacks.Begin(), mReturnCallbacks.End(), [&callback](CallbackBase* current) { return callback == current; }), mReturnCallbacks.End());
+}
- virtual void MoveResize( Dali::PositionSize positionSize ) {}
+void Adaptor::RunIdles()
+{
+ Dali::Vector<CallbackBase*> reusedCallbacks;
+ for(auto& callback : mReturnCallbacks)
+ {
+ bool retValue = CallbackBase::ExecuteReturn<bool>(*callback);
+ if(retValue)
+ {
+ reusedCallbacks.PushBack(callback);
+ }
+ }
+ for(auto& callback : mCallbacks)
+ {
+ CallbackBase::Execute(*callback);
+ }
- virtual void SetViewMode( ViewMode viewMode ) {}
+ mCallbacks.Clear();
+ mReturnCallbacks.Clear();
+ mReturnCallbacks.Swap(reusedCallbacks);
+}
- virtual void StartRender() {}
+Dali::RenderSurfaceInterface& Adaptor::GetSurface()
+{
+ DALI_ASSERT_ALWAYS(!mWindows.empty());
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) { return false; }
+ return reinterpret_cast<Dali::RenderSurfaceInterface&>(mWindows.front()->GetRenderSurface());
+}
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) {}
+Dali::WindowContainer Adaptor::GetWindows()
+{
+ Dali::WindowContainer windows;
- virtual void StopRender() {}
+ for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter)
+ {
+ // Downcast to Dali::Window
+ Dali::Window window(dynamic_cast<Dali::Internal::Adaptor::Window*>(*iter));
+ if(window)
+ {
+ windows.push_back(window);
+ }
+ }
- virtual void ReleaseLock() {}
+ return windows;
+}
- virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {}
+Dali::SceneHolderList Adaptor::GetSceneHolders()
+{
+ Dali::SceneHolderList sceneHolderList;
-};
+ for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter)
+ {
+ sceneHolderList.push_back(Dali::Integration::SceneHolder(*iter));
+ }
-namespace Internal
-{
-namespace Adaptor
-{
+ return sceneHolderList;
+}
-class Adaptor: public BaseObject
+Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor)
{
-public:
- static Dali::Adaptor& Get();
- Adaptor();
- ~Adaptor();
+ Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
-public:
- static Dali::RenderSurface& GetSurface();
- static Dali::Adaptor::AdaptorSignalType& AdaptorSignal();
-};
+ for(auto window : mWindows)
+ {
+ if(scene == window->GetScene())
+ {
+ return window;
+ }
+ }
-Dali::Adaptor& Adaptor::Get()
-{
- Dali::Adaptor* adaptor = new Dali::Adaptor;
- return *adaptor;
+ return nullptr;
}
-Dali::RenderSurface& Adaptor::GetSurface()
+void Adaptor::AddWindow(Internal::Adaptor::SceneHolder* window)
{
- Dali::RenderSurface *renderSurface = new Dali::TestRenderSurface;
- return *renderSurface;
+ if(window)
+ {
+ mWindows.push_back(window);
+
+ Dali::Integration::SceneHolder newWindow(window);
+ mWindowCreatedSignal.Emit(newWindow);
+ }
}
-Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
+void Adaptor::RemoveWindow(Internal::Adaptor::SceneHolder* window)
{
- Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
- return *signal;
+ auto iter = std::find(mWindows.begin(), mWindows.end(), window);
+ if(iter != mWindows.end())
+ {
+ mWindows.erase(iter);
+ }
}
+void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor)
+{
+ Integration::Core& core = mTestApplication->GetCore();
+ core.RegisterProcessor(processor, postProcessor);
}
-}
+
+void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor)
+{
+ Integration::Core& core = mTestApplication->GetCore();
+ core.UnregisterProcessor(processor, postProcessor);
}
-namespace Dali
+void Adaptor::SetApplication(Dali::TestApplication& testApplication)
{
+ mTestApplication = &testApplication;
+}
-Adaptor& Adaptor::New( Window window )
+Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
{
- return Internal::Adaptor::Adaptor::Get();
+ return mResizedSignal;
}
-Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
+Dali::Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
{
- return Internal::Adaptor::Adaptor::Get();
+ return mLanguageChangedSignal;
}
-Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface )
+Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
{
- return Internal::Adaptor::Adaptor::Get();
+ return mWindowCreatedSignal;
}
-Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface, Configuration::ContextLoss configuration )
+} // namespace Adaptor
+} // namespace Internal
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Dali::Adaptor Stub
+//
+///////////////////////////////////////////////////////////////////////////////
+
+Adaptor::Adaptor()
+: mImpl(new Internal::Adaptor::Adaptor)
{
- return Internal::Adaptor::Adaptor::Get();
}
Adaptor::~Adaptor()
{
+ Internal::Adaptor::gAdaptor = nullptr;
+ delete mImpl;
}
void Adaptor::Start()
{
}
-bool Adaptor::AddIdle( CallbackBase* callback )
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
+{
+ return mImpl->AddIdle(callback, hasReturnValue);
+}
+
+void Adaptor::RemoveIdle(CallbackBase* callback)
{
- return false;
+ mImpl->RemoveIdle(callback);
}
-void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurface& surface )
+void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& surface)
+{
+}
+
+void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface)
{
}
Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
{
- return Internal::Adaptor::Adaptor::AdaptorSignal();
+ return mImpl->ResizedSignal();
}
Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
{
- return Internal::Adaptor::Adaptor::AdaptorSignal();
+ return mImpl->LanguageChangedSignal();
+}
+
+Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
+{
+ return mImpl->WindowCreatedSignal();
+}
+
+Dali::RenderSurfaceInterface& Adaptor::GetSurface()
+{
+ return mImpl->GetSurface();
}
-RenderSurface& Adaptor::GetSurface()
+Dali::WindowContainer Adaptor::GetWindows() const
{
- return Internal::Adaptor::Adaptor::GetSurface();
+ return mImpl->GetWindows();
+}
+
+Dali::SceneHolderList Adaptor::GetSceneHolders() const
+{
+ return mImpl->GetSceneHolders();
}
Any Adaptor::GetNativeWindowHandle()
return window;
}
-void Adaptor::ReleaseSurfaceLock()
+Any Adaptor::GetNativeWindowHandle(Actor actor)
{
+ return GetNativeWindowHandle();
}
-void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
+void Adaptor::ReleaseSurfaceLock()
{
}
-void Adaptor::SetUseHardwareVSync(bool useHardware)
+void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
{
}
bool Adaptor::IsAvailable()
{
- return false;
+ return Internal::Adaptor::gAdaptor;
}
void Adaptor::NotifySceneCreated()
{
}
-void Adaptor::SetMinimumPinchDistance(float distance)
+void Adaptor::FeedTouchPoint(TouchPoint& point, int timeStamp)
{
}
-void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
+void Adaptor::FeedWheelEvent(WheelEvent& wheelEvent)
{
}
-void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
+void Adaptor::FeedKeyEvent(KeyEvent& keyEvent)
{
}
-void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
+void Adaptor::SceneCreated()
{
}
-void Adaptor::SceneCreated()
+class LogFactory : public LogFactoryInterface
+{
+public:
+ virtual void InstallLogFunction() const
+ {
+ Dali::Integration::Log::LogFunction logFunction(&ToolkitTestApplication::LogMessage);
+ Dali::Integration::Log::InstallLogFunction(logFunction);
+ }
+
+ LogFactory()
+ {
+ }
+ virtual ~LogFactory()
+ {
+ }
+};
+
+LogFactory* gLogFactory = NULL;
+const LogFactoryInterface& Adaptor::GetLogFactory()
{
+ if(gLogFactory == NULL)
+ {
+ gLogFactory = new LogFactory;
+ }
+ return *gLogFactory;
}
-void Adaptor::SetViewMode( ViewMode mode )
+class TraceFactory : public TraceFactoryInterface
{
+public:
+ virtual void InstallTraceFunction() const
+ {
+ Dali::Integration::Trace::LogContextFunction logContextFunction(&TestApplication::LogContext);
+ Dali::Integration::Trace::InstallLogContextFunction(logContextFunction);
+ }
+
+ TraceFactory()
+ {
+ }
+ virtual ~TraceFactory()
+ {
+ }
+};
+
+TraceFactory* gTraceFactory = NULL;
+const TraceFactoryInterface& Adaptor::GetTraceFactory()
+{
+ if(gTraceFactory == NULL)
+ {
+ gTraceFactory = new TraceFactory;
+ }
+ return *gTraceFactory;
}
-void Adaptor::SetStereoBase( float stereoBase )
+void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor)
{
+ mImpl->RegisterProcessor(processor, postProcessor);
}
-Adaptor::Adaptor()
-: mImpl( NULL )
+void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor)
{
+ mImpl->UnregisterProcessor(processor, postProcessor);
}
} // namespace Dali