/*
- * Copyright (c) 2019 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.
// 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>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/adaptor-framework/scene-holder.h>
-#include <dali/integration-api/adaptors/scene-holder.h>
-#include <toolkit-scene-holder-impl.h>
-
-#include <toolkit-adaptor-impl.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/scene.h>
#include <test-application.h>
-#include <test-render-surface.h>
+#include <toolkit-adaptor-impl.h>
+#include <toolkit-scene-holder-impl.h>
+#include <toolkit-test-application.h>
namespace Dali
{
-
-namespace
-{
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// LogFactoryStub
-//
-///////////////////////////////////////////////////////////////////////////////
-
-class LogFactory : public LogFactoryInterface
-{
-public:
- LogFactory() = default;
- virtual ~LogFactory() = default;
-
-private:
- void InstallLogFunction() const override
- {
- Dali::Integration::Log::InstallLogFunction( &TestApplication::LogMessage );
- }
-};
-LogFactory* gLogFactory = NULL; // For some reason, destroying this when the Adaptor is destroyed causes a crash in some test cases when running all of them.
-} //unnamed namespace
-
namespace Internal
{
namespace Adaptor
{
-
///////////////////////////////////////////////////////////////////////////////
//
// Dali::Internal::Adaptor::Adaptor Stub
Dali::Adaptor& Adaptor::New()
{
- DALI_ASSERT_ALWAYS( ! gAdaptor );
+ DALI_ASSERT_ALWAYS(!gAdaptor);
gAdaptor = new Dali::Adaptor;
return *gAdaptor;
}
Dali::Adaptor& Adaptor::Get()
{
- DALI_ASSERT_ALWAYS( gAdaptor );
+ DALI_ASSERT_ALWAYS(gAdaptor);
return *gAdaptor;
}
gAdaptor = nullptr;
}
-void Adaptor::Start( Dali::Window window )
+void Adaptor::Start(Dali::Window window)
{
- AddWindow( &GetImplementation( window ) );
+ AddWindow(&GetImplementation(window));
}
-Integration::Scene Adaptor::GetScene( Dali::Window window )
+Integration::Scene Adaptor::GetScene(Dali::Window window)
{
return window.GetScene();
}
-bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
{
- mCallbacks.PushBack( callback );
+ if(hasReturnValue)
+ {
+ mReturnCallbacks.PushBack(callback);
+ }
+ else
+ {
+ mCallbacks.PushBack(callback);
+ }
return true;
}
-void Adaptor::RemoveIdle( CallbackBase* callback )
+void Adaptor::RemoveIdle(CallbackBase* callback)
{
- mCallbacks.Erase( std::find_if( mCallbacks.Begin(), mCallbacks.End(),
- [ &callback ] ( CallbackBase* current ) { return callback == current; } ) );
+ 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());
}
void Adaptor::RunIdles()
{
- for( auto& callback : mCallbacks )
+ 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 );
+ CallbackBase::Execute(*callback);
}
mCallbacks.Clear();
+ mReturnCallbacks.Clear();
+ mReturnCallbacks.Swap(reusedCallbacks);
}
Dali::RenderSurfaceInterface& Adaptor::GetSurface()
{
- DALI_ASSERT_ALWAYS( ! mWindows.empty() );
+ DALI_ASSERT_ALWAYS(!mWindows.empty());
- return reinterpret_cast < Dali::RenderSurfaceInterface& >( mWindows.front()->GetRenderSurface() );
+ return reinterpret_cast<Dali::RenderSurfaceInterface&>(mWindows.front()->GetRenderSurface());
}
Dali::WindowContainer Adaptor::GetWindows()
{
Dali::WindowContainer windows;
- for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ 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 )
+ Dali::Window window(dynamic_cast<Dali::Internal::Adaptor::Window*>(*iter));
+ if(window)
{
- windows.push_back( window );
+ windows.push_back(window);
}
}
{
Dali::SceneHolderList sceneHolderList;
- for( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter)
{
- sceneHolderList.push_back( Dali::Integration::SceneHolder( *iter ) );
+ sceneHolderList.push_back(Dali::Integration::SceneHolder(*iter));
}
return sceneHolderList;
}
-Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor )
+Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor)
{
- Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor );
+ Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
- for( auto window : mWindows )
+ for(auto window : mWindows)
{
- if ( scene == window->GetScene() )
+ if(scene == window->GetScene())
{
return window;
}
return nullptr;
}
-void Adaptor::AddWindow( Internal::Adaptor::SceneHolder* window )
+void Adaptor::AddWindow(Internal::Adaptor::SceneHolder* window)
{
- if ( window )
+ if(window)
{
- mWindows.push_back( window );
+ mWindows.push_back(window);
- Dali::Integration::SceneHolder newWindow( window );
- mWindowCreatedSignal.Emit( newWindow );
+ Dali::Integration::SceneHolder newWindow(window);
+ mWindowCreatedSignal.Emit(newWindow);
}
}
-void Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* window )
+void Adaptor::RemoveWindow(Internal::Adaptor::SceneHolder* window)
{
- auto iter = std::find( mWindows.begin(), mWindows.end(), window );
- if( iter != mWindows.end() )
+ auto iter = std::find(mWindows.begin(), mWindows.end(), window);
+ if(iter != mWindows.end())
{
- mWindows.erase( iter );
+ 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);
+}
+
+void Adaptor::SetApplication(Dali::TestApplication& testApplication)
+{
+ mTestApplication = &testApplication;
+}
+
Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
{
return mResizedSignal;
///////////////////////////////////////////////////////////////////////////////
Adaptor::Adaptor()
-: mImpl( new Internal::Adaptor::Adaptor )
+: mImpl(new Internal::Adaptor::Adaptor)
{
}
{
}
-bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
{
- return mImpl->AddIdle( callback, hasReturnValue );
+ return mImpl->AddIdle(callback, hasReturnValue);
}
-void Adaptor::RemoveIdle( CallbackBase* callback )
+void Adaptor::RemoveIdle(CallbackBase* callback)
{
- mImpl->RemoveIdle( callback );
+ mImpl->RemoveIdle(callback);
}
-void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
+void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& surface)
{
}
-void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
+void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface)
{
}
return window;
}
-Any Adaptor::GetNativeWindowHandle( Actor actor )
+Any Adaptor::GetNativeWindowHandle(Actor actor)
{
return GetNativeWindowHandle();
}
{
}
-void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
+void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
{
}
{
}
-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)
{
}
{
}
+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 )
+ if(gLogFactory == NULL)
{
gLogFactory = new LogFactory;
}
return *gLogFactory;
}
+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::RegisterProcessor(Integration::Processor& processor, bool postProcessor)
+{
+ mImpl->RegisterProcessor(processor, postProcessor);
+}
+
+void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor)
+{
+ mImpl->UnregisterProcessor(processor, postProcessor);
+}
+
} // namespace Dali