/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
*
*/
-#define __DALI_ADAPTOR_H__
-#define __DALI_ACCESSIBILITY_MANAGER_H__
-#define __DALI_TIMER_H__
-#define __DALI_CLIPBOARD_H__
-#define IMFMANAGER_H
+// CLASS HEADER
+#include <dali/integration-api/adaptors/adaptor.h>
-#include "toolkit-adaptor.h"
-#include <map>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/object/base-object.h>
+
+#include <toolkit-adaptor-impl.h>
+#include <dali/integration-api/debug.h>
+#include <test-application.h>
+#include <test-render-surface.h>
namespace Dali
{
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-class TestRenderSurface : public RenderSurface
+namespace Internal
{
-public:
- TestRenderSurface(){}
- virtual ~TestRenderSurface(){}
- virtual SurfaceType GetType() { return RenderSurface::WINDOW; }
- virtual Dali::Any GetSurface() { return Dali::Any(); }
- virtual Dali::Any GetDisplay() { return Dali::Any(); }
- virtual PositionSize GetPositionSize() const { return PositionSize(0, 0, 640, 480);}
- virtual void SetRenderMode(RenderMode mode){}
- virtual RenderMode GetRenderMode() const { return RenderSurface::RENDER_60FPS; }
-};
-
-typedef Dali::Rect<int> PositionSize;
-
-/**
- * Stub for the Adaptor
- */
-class Adaptor
+namespace Adaptor
{
-public:
-
- typedef SignalV2< void ( Adaptor& ) > AdaptorSignalV2;
-
- typedef std::pair<std::string, Dali::BaseHandle> SingletonPair;
- typedef std::map<std::string, Dali::BaseHandle> SingletonContainer;
- typedef SingletonContainer::const_iterator SingletonConstIter;
-
-public:
-
- Adaptor(ToolkitAdaptor& toolkitAdaptor);
- ~Adaptor();
-
-public:
-
- void Start();
- void Pause();
- void Resume();
- void Stop();
- bool AddIdle(boost::function<void(void)> callBack);
- void FeedEvent(TouchPoint& point, int timeStamp);
- bool MoveResize(const PositionSize& positionSize);
- void SurfaceResized(const PositionSize& positionSize);
- void ReplaceSurface(RenderSurface& surface);
- void RenderSync();
- RenderSurface& GetSurface();
-
- void RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton);
- Dali::BaseHandle GetSingleton(const std::type_info& info) const;
-
-public: // static methods
- static Adaptor& Get();
- static bool IsAvailable();
-
-public: // Signals
- AdaptorSignalV2& SignalResize();
+bool Adaptor::mAvailable = false;
+Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
- void EmitSignalResize()
- {
- mResizeSignal.Emit( *this );
- }
+Dali::Adaptor& Adaptor::Get()
+{
+ Dali::Adaptor* adaptor = new Dali::Adaptor;
+ Adaptor::mAvailable = true;
+ return *adaptor;
+}
-private:
+Dali::RenderSurfaceInterface& Adaptor::GetSurface()
+{
+ Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast <Dali::RenderSurfaceInterface*>( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) );
+ return *renderSurface;
+}
- // Undefined
- Adaptor(const Adaptor&);
- Adaptor& operator=(Adaptor&);
+Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
+{
+ Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
+ return *signal;
+}
- AdaptorSignalV2 mResizeSignal;
- TestRenderSurface mRenderSurface;
- ToolkitAdaptor& mToolkitAdaptor;
+} // namespace Adaptor
+} // namespace Internal
- SingletonContainer mSingletonContainer;
-};
+Adaptor& Adaptor::New( Window window )
+{
+ return Internal::Adaptor::Adaptor::Get();
+}
-namespace
+Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
{
-Adaptor* gAdaptor = NULL;
+ return Internal::Adaptor::Adaptor::Get();
+}
+Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface )
+{
+ return Internal::Adaptor::Adaptor::Get();
}
-Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor)
-: mToolkitAdaptor(toolkitAdaptor)
+Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
{
+ return Internal::Adaptor::Adaptor::Get();
}
Adaptor::~Adaptor()
{
-
}
void Adaptor::Start()
{
- mToolkitAdaptor.mFunctionsCalled.Start = true;
}
void Adaptor::Pause()
{
- mToolkitAdaptor.mFunctionsCalled.Pause = true;
}
void Adaptor::Resume()
{
- mToolkitAdaptor.mFunctionsCalled.Resume = true;
}
void Adaptor::Stop()
{
- mToolkitAdaptor.mFunctionsCalled.Stop = true;
}
-bool Adaptor::AddIdle(boost::function<void(void)> callBack)
+bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
{
- mToolkitAdaptor.mFunctionsCalled.AddIdle = true;
- mToolkitAdaptor.mLastIdleAdded = callBack;
- return true;
+ const bool isAvailable = IsAvailable();
+
+ if( isAvailable )
+ {
+ Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
+ }
+
+ return isAvailable;
}
-void Adaptor::FeedEvent(TouchPoint& point, int timeStamp)
+void Adaptor::RemoveIdle( CallbackBase* callback )
{
- mToolkitAdaptor.mFunctionsCalled.FeedEvent = true;
- mToolkitAdaptor.mLastTouchPointFed = point;
- mToolkitAdaptor.mLastTimeStampFed = timeStamp;
+ 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;
+ }
+ }
+ }
}
-bool Adaptor::MoveResize(const PositionSize& positionSize)
+void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& surface )
{
- mToolkitAdaptor.mFunctionsCalled.MoveResize = true;
- mToolkitAdaptor.mLastSizeSet = positionSize;
- return true;
}
-void Adaptor::SurfaceResized(const PositionSize& positionSize)
+Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
{
- mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true;
- mToolkitAdaptor.mLastSizeSet = positionSize;
+ return Internal::Adaptor::Adaptor::AdaptorSignal();
}
-void Adaptor::ReplaceSurface(RenderSurface& surface)
+Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
{
- mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true;
+ return Internal::Adaptor::Adaptor::AdaptorSignal();
}
-void Adaptor::RenderSync()
+Dali::RenderSurfaceInterface& Adaptor::GetSurface()
{
- mToolkitAdaptor.mFunctionsCalled.RenderSync = true;
+ return Internal::Adaptor::Adaptor::GetSurface();
}
-RenderSurface& Adaptor::GetSurface()
+Any Adaptor::GetNativeWindowHandle()
{
- mToolkitAdaptor.mFunctionsCalled.GetSurface = true;
- return mRenderSurface;
+ Any window;
+ return window;
}
-Adaptor& Adaptor::Get()
+void Adaptor::ReleaseSurfaceLock()
{
- DALI_ASSERT_ALWAYS(gAdaptor);
- gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true;
- return *gAdaptor;
}
-bool Adaptor::IsAvailable()
+void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
{
- bool available(false);
-
- if (gAdaptor)
- {
- gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true;
- available = true;
- }
+}
- return available;
+void Adaptor::SetUseHardwareVSync(bool useHardware)
+{
}
-void Adaptor::RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton)
+Adaptor& Adaptor::Get()
{
- mToolkitAdaptor.mFunctionsCalled.RegisterSingleton = true;
+ return Internal::Adaptor::Adaptor::Get();
+}
- if(singleton)
- {
- mSingletonContainer.insert(SingletonPair(info.name(), singleton));
- }
+bool Adaptor::IsAvailable()
+{
+ return Internal::Adaptor::Adaptor::mAvailable;
}
-Dali::BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
+void Adaptor::NotifySceneCreated()
{
- mToolkitAdaptor.mFunctionsCalled.GetSingleton = true;
+}
- Dali::BaseHandle object = Dali::BaseHandle();
+void Adaptor::NotifyLanguageChanged()
+{
+}
- SingletonConstIter iter = mSingletonContainer.find(info.name());
- if(iter != mSingletonContainer.end())
- {
- object = (*iter).second;
- }
+void Adaptor::SetMinimumPinchDistance(float distance)
+{
+}
- return object;
+void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
+{
}
-Adaptor::AdaptorSignalV2& Adaptor::SignalResize()
+void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
{
- mToolkitAdaptor.mFunctionsCalled.SignalResize = true;
- return mResizeSignal;
}
-////////////////////////////////////////////////////////////////////////////////////////////////////
+void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
+{
+}
-ToolkitAdaptor::ToolkitAdaptor()
-: mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f),
- mLastTimeStampFed(0),
- mStyleMonitor(StyleMonitor::Get()),
- mAccessibilityManager(AccessibilityManager::Get()),
- mImfManager(ImfManager::Get()),
- mAdaptorStub(new Adaptor(*this))
+void Adaptor::SceneCreated()
{
- gAdaptor = mAdaptorStub;
}
-ToolkitAdaptor::~ToolkitAdaptor()
+class LogFactory : public LogFactoryInterface
{
- delete mAdaptorStub;
- gAdaptor = NULL;
+public:
+ virtual void InstallLogFunction() const
+ {
+ Dali::Integration::Log::LogFunction logFunction(&TestApplication::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 ToolkitAdaptor::EmitSignalResize()
+Adaptor::Adaptor()
+: mImpl( NULL )
{
- mAdaptorStub->EmitSignalResize();
}
} // namespace Dali