X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fadaptor-impl.h;h=c2a9ad4a0392416563598016f98ddb39b7a4bc46;hb=aecc2d4c642e0cdf360e56accd3e5b96622a707f;hp=33597463862a5110aba7ff45d7e2ab52c663aee2;hpb=5854a9224319ce2cf96f8fbb87ea790078fab1a5;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/adaptor-impl.h b/dali/internal/adaptor/common/adaptor-impl.h index 3359746..c2a9ad4 100755 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_ADAPTOR_IMPL_H__ -#define __DALI_INTERNAL_ADAPTOR_IMPL_H__ +#ifndef DALI_INTERNAL_ADAPTOR_IMPL_H +#define DALI_INTERNAL_ADAPTOR_IMPL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -27,32 +27,33 @@ #include // INTERNAL INCLUDES -#include #include #include - -#include +#include +#include +#include +#include #include -#include +#include +#include +#include #include -#include -#include -#include +#include #include #include -#include -#include +#include +#include namespace Dali { -class RenderSurface; -class Window; +class RenderSurfaceInterface; namespace Integration { class Core; class GlAbstraction; +class Processor; } namespace Internal @@ -60,9 +61,8 @@ namespace Internal namespace Adaptor { -class EventHandler; -class EglFactory; -class GestureManager; +class DisplayConnection; +class GraphicsFactory; class GlImplementation; class GlSyncImplementation; class ThreadController; @@ -70,11 +70,12 @@ class TriggerEvent; class CallbackManager; class FeedbackPluginProxy; class FeedbackController; -class RotationObserver; class VSyncMonitor; class PerformanceInterface; class LifeCycleObserver; class ObjectProfiler; +class SceneHolder; +class ConfigurationManager; /** * Implementation of the Adaptor class. @@ -87,36 +88,69 @@ class Adaptor : public Integration::RenderController, { public: - typedef Dali::Adaptor::AdaptorSignalType AdaptorSignalType; + using AdaptorSignalType = Dali::Adaptor::AdaptorSignalType; + using WindowCreatedSignalType = Dali::Adaptor::WindowCreatedSignalType; - typedef Uint16Pair SurfaceSize; ///< Surface size type + using SurfaceSize = Uint16Pair; ///< Surface size type /** * Creates a New Adaptor - * @param[in] nativeWindow Native window handle + * @param[in] window The window handle * @param[in] surface A render surface can be one of the following * - Pixmap, adaptor will use existing Pixmap to draw on to * - Window, adaptor will use existing Window to draw on to * @param[in] configuration The context loss configuration ( to choose resource discard policy ) * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - static Dali::Adaptor* New( Any nativeWindow, - RenderSurface* surface, + static Dali::Adaptor* New( Dali::Integration::SceneHolder window, + Dali::RenderSurfaceInterface* surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); /** * Creates a New Adaptor - * @param[in] nativeWindow native window handle + * @param[in] window The window handle * @param[in] configuration The context loss configuration ( to choose resource discard policy ) * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - static Dali::Adaptor* New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); + static Dali::Adaptor* New( Dali::Integration::SceneHolder window, + Dali::Configuration::ContextLoss configuration, + EnvironmentOptions* environmentOptions ); + + /** + * Creates a New Adaptor + * @param[in] graphicsFactory A factory that creates the graphics interface + * @param[in] window The window handle + * @param[in] surface A render surface can be one of the following + * - Pixmap, adaptor will use existing Pixmap to draw on to + * - Window, adaptor will use existing Window to draw on to + * @param[in] configuration The context loss configuration ( to choose resource discard policy ) + * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. + */ + static Dali::Adaptor* New( GraphicsFactory& graphicsFactory, + Dali::Integration::SceneHolder window, + Dali::RenderSurfaceInterface* surface, + Dali::Configuration::ContextLoss configuration, + EnvironmentOptions* environmentOptions ); + + /** + * Creates a New Adaptor + * @param[in] graphicsFactory A factory that creates the graphics interface + * @param[in] window The window handle + * @param[in] configuration The context loss configuration ( to choose resource discard policy ) + * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. + */ + static Dali::Adaptor* New( GraphicsFactory& graphicsFactory, + Dali::Integration::SceneHolder window, + Dali::Configuration::ContextLoss configuration, + EnvironmentOptions* environmentOptions ); /** * 2-step initialisation, this should be called after creating an adaptor instance. + * @param[in] graphicsFactory A factory that creates the graphics interface + * @param[in] configuration The context loss configuration ( to choose resource discard policy ) */ - void Initialize(Dali::Configuration::ContextLoss configuration); + void Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration ); /** * Virtual destructor. @@ -185,14 +219,14 @@ public: // AdaptorInternalServices implementation virtual void FeedKeyEvent( KeyEvent& keyEvent ); /** - * @copydoc AdaptorInterface::ReplaceSurface() + * @copydoc Dali::Adaptor::ReplaceSurface() */ - virtual void ReplaceSurface( Any nativeWindow, RenderSurface& surface ); + virtual void ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ); /** * @copydoc Dali::Adaptor::GetSurface() */ - virtual RenderSurface& GetSurface() const; + virtual Dali::RenderSurfaceInterface& GetSurface() const; /** * @copydoc Dali::Adaptor::ReleaseSurfaceLock() @@ -212,80 +246,117 @@ public: // AdaptorInternalServices implementation virtual bool AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd ); /** + * Adds a new Window instance to the Adaptor + * @param[in] childWindow The child window instance + * @param[in] childWindowName The child window title/name + * @param[in] childWindowClassName The class name that the child window belongs to + * @param[in] childWindowMode The mode of the child window + */ + virtual bool AddWindow( Dali::Integration::SceneHolder childWindow, + const std::string& childWindowName, + const std::string& childWindowClassName, + bool childWindowMode ); + + /** + * Removes an existing Window instance from the Adaptor + * @param[in] window The Window instance + */ + virtual bool RemoveWindow( Dali::Integration::SceneHolder* childWindow ); + + /** + * Removes an existing Window instance from the Adaptor + * @param[in] windowName The Window name + * @note If two Windows have the same name, the first one that matches will be removed + */ + virtual bool RemoveWindow( std::string childWindowName ); + + /** * @copydoc Dali::Adaptor::RemoveIdle() */ virtual void RemoveIdle( CallbackBase* callback ); -public: + /** + * @copydoc Dali::Adaptor::ProcessIdle() + */ + virtual void ProcessIdle(); /** - * @return the Core instance + * Sets a pre-render callback. */ - virtual Dali::Integration::Core& GetCore(); + void SetPreRenderCallback( CallbackBase* callback ); /** - * @copydoc Dali::Adaptor::SetRenderRefreshRate() + * Removes an existing Window instance from the Adaptor + * @param[in] childWindow The Window instance */ - void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ); + bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow ); /** - * @copydoc Dali::Adaptor::SetUseHardwareVSync() + * @brief Retrieve the window that the given actor is added to. + * + * @param[in] actor The actor + * @return The window the actor is added to or a null pointer if the actor is not added to any widnow. */ - void SetUseHardwareVSync(bool useHardware); + Dali::Internal::Adaptor::SceneHolder* GetWindow( Dali::Actor& actor ); /** - * @return reference to EglFactory class + * @copydoc Dali::Adaptor::GetWindows() */ - EglFactory& GetEGLFactory() const; + Dali::WindowContainer GetWindows() const; /** - * Return GlAbstraction. - * @return the GlAbstraction. + * @copydoc Dali::Adaptor::GetSceneHolders() */ - Integration::GlAbstraction& GetGlAbstraction() const; + Dali::SceneHolderList GetSceneHolders() const; + +public: /** - * Return the PlatformAbstraction. - * @return The PlatformAbstraction. + * @return the Core instance */ - Integration::PlatformAbstraction& GetPlatformAbstraction() const; + virtual Dali::Integration::Core& GetCore(); /** - * Sets the Drag & Drop Listener. - * @param[in] detector The detector to send Drag & Drop events to. + * @copydoc Dali::Adaptor::SetRenderRefreshRate() */ - void SetDragAndDropDetector( DragAndDropDetectorPtr detector ); + void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ); /** - * Sets a rotation observer, or set to NULL to remove. - * @pre Adaptor::Start() has been called ( to create EventHandler ) - * @param[in] observer The observer to listen for window rotation events + * Return the PlatformAbstraction. + * @return The PlatformAbstraction. */ - void SetRotationObserver( RotationObserver* observer ); + Integration::PlatformAbstraction& GetPlatformAbstraction() const; /** - * Destroy the TtsPlayer of sepcific mode. + * Destroy the TtsPlayer of specific mode. * @param[in] mode The mode of TtsPlayer to destroy */ void DestroyTtsPlayer(Dali::TtsPlayer::Mode mode); /** - * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to - * trigger a pinch gesture + * Gets native window handle * - * @param[in] distance The minimum pinch distance in pixels + * @return native window handle */ - void SetMinimumPinchDistance(float distance); + Any GetNativeWindowHandle(); /** - * Gets native window handle + * @brief Retrieve native window handle that the given actor is added to. * + * @param[in] actor The actor * @return native window handle */ - Any GetNativeWindowHandle(); + Any GetNativeWindowHandle( Dali::Actor actor ); /** - * Sets use remote surface for eglSurface output + * Get the native display associated with the graphics backend + * + * @return A handle to the native display + */ + Any GetGraphicsDisplay(); + + /** + * Sets use remote surface for Surface output * @param[in] useRemoteSurface True if the remote surface is used */ void SetUseRemoteSurface(bool useRemoteSurface); @@ -317,11 +388,6 @@ public: void RequestUpdateOnce(); /** - * Request adaptor to update indicator's height - */ - void IndicatorSizeChanged(int height); - - /** * @copydoc Dali::Adaptor::NotifySceneCreated() */ void NotifySceneCreated(); @@ -337,14 +403,14 @@ public: void GetAppId( std::string& appId ); /** - * Informs core the surface size has changed + * @copydoc Dali::Adaptor::SurfaceResizePrepare */ - void SurfaceResizePrepare( SurfaceSize surfaceSize ); + void SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize ); /** - * Informs ThreadController the surface size has changed + * @copydoc Dali::Adaptor::SurfaceResizeComplete */ - void SurfaceResizeComplete( SurfaceSize surfaceSize ); + void SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize ); /** * Sets layout direction of root by system language @@ -362,6 +428,28 @@ public: */ const LogFactoryInterface& GetLogFactory(); + /** + * @copydoc Dali::Adaptor::RegisterProcessor + */ + void RegisterProcessor( Integration::Processor& processor ); + + /** + * @coydoc Dali::Adaptor::UnregisterProcessor + */ + void UnregisterProcessor( Integration::Processor& processor ); + + /** + * Check MultipleWindow is supported + */ + bool IsMultipleWindowSupported() const; + + /** + * @brief Checks whether the windows are being rendered in the render thread. + * + * @return true if the windows are being rendered in the render thread, or false if not. + */ + bool IsRenderingWindows() const; + public: //AdaptorInternalServices /** @@ -370,14 +458,14 @@ public: //AdaptorInternalServices virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface(); /** - * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGlesInterface() + * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetDisplayConnectionInterface() */ - virtual Dali::Integration::GlAbstraction& GetGlesInterface(); + virtual Dali::DisplayConnection& GetDisplayConnectionInterface(); /** - * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetEGLFactoryInterface() - */ - virtual EglFactoryInterface& GetEGLFactoryInterface() const; + * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGraphicsInterface() + */ + virtual GraphicsInterface& GetGraphicsInterface(); /** * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface() @@ -385,11 +473,6 @@ public: //AdaptorInternalServices virtual TriggerEventInterface& GetProcessCoreEventsTrigger(); /** - * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface() - */ - virtual TriggerEventFactoryInterface& GetTriggerEventFactoryInterface(); - - /** * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetSocketFactoryInterface() */ virtual SocketFactoryInterface& GetSocketFactoryInterface(); @@ -397,12 +480,7 @@ public: //AdaptorInternalServices /** * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetRenderSurfaceInterface() */ - virtual RenderSurface* GetRenderSurfaceInterface(); - - /** - * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetVSyncMonitorInterface() - */ - virtual VSyncMonitorInterface* GetVSyncMonitorInterface(); + virtual Dali::RenderSurfaceInterface* GetRenderSurfaceInterface(); /** * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPerformanceInterface() @@ -419,27 +497,10 @@ public: //AdaptorInternalServices */ virtual TraceInterface& GetSystemTraceInterface(); -public: // Stereoscopy - /** - * @copydoc Dali::Integration::Core::SetViewMode() + * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetWindowContainerInterface() */ - void SetViewMode( ViewMode viewMode ); - - /** - * @copydoc Dali::Integration::Core::GetViewMode() - */ - ViewMode GetViewMode() const; - - /** - * @copydoc Dali::Integration::Core::SetStereoBase() - */ - void SetStereoBase( float stereoBase ); - - /** - * @copydoc Dali::Integration::Core::GetStereoBase() - */ - float GetStereoBase() const; + virtual void GetWindowContainerInterface( WindowContainer& windows ); public: // Signals @@ -459,18 +520,28 @@ public: // Signals return mLanguageChangedSignal; } -private: // From Dali::Internal::Adaptor::CoreEventInterface - /** - * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent() + * @copydoc Dali::Adaptor::WindowCreatedSignal */ - virtual void QueueCoreEvent(const Dali::Integration::Event& event); + WindowCreatedSignalType& WindowCreatedSignal() + { + return mWindowCreatedSignal; + } + +public: // From Dali::Internal::Adaptor::CoreEventInterface /** * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents() */ virtual void ProcessCoreEvents(); +private: // From Dali::Internal::Adaptor::CoreEventInterface + + /** + * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent() + */ + virtual void QueueCoreEvent(const Dali::Integration::Event& event); + private: // From Dali::Integration::RenderController /** @@ -483,7 +554,7 @@ private: // From Dali::Integration::RenderController */ virtual void RequestProcessEventsOnIdle( bool forceProcess ); -private: // From Dali::Internal::Adaptor::WindowVisibilityObserver +public: // From Dali::Internal::Adaptor::WindowVisibilityObserver /** * Called when the window becomes fully or partially visible. @@ -505,8 +576,8 @@ private: // From Dali::Internal::Adaptor::DamageObserver private: // Undefined - Adaptor(const Adaptor&); - Adaptor& operator=(Adaptor&); + Adaptor(const Adaptor&) = delete; + Adaptor& operator=(Adaptor&) = delete; private: @@ -514,7 +585,7 @@ private: * Assigns the render surface to the adaptor * */ - void SetSurface(RenderSurface *surface); + void SetSurface(Dali::RenderSurfaceInterface *surface); /** * called after surface is created @@ -557,68 +628,69 @@ private: /** * Constructor - * @param[in] nativeWindow native window handle + * @param[in] window window handle * @param[in] adaptor The public adaptor * @param[in] surface A render surface can be one of the following * - Pixmap, adaptor will use existing Pixmap to draw on to * - Window, adaptor will use existing Window to draw on to * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions ); + Adaptor( Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions ); private: // Types enum State { - READY, ///< Initial state before Adaptor::Start is called. - RUNNING, ///< Adaptor is running. - PAUSED, ///< Adaptor has been paused. - PAUSED_WHILE_HIDDEN, ///< Adaptor is paused while window is hidden (& cannot be resumed until window is shown). - STOPPED, ///< Adaptor has been stopped. + READY, ///< Initial state before Adaptor::Start is called. + RUNNING, ///< Adaptor is running. + PAUSED, ///< Adaptor has been paused. + PAUSED_WHILE_HIDDEN, ///< Adaptor is paused while window is hidden (& cannot be resumed until window is shown). + PAUSED_WHILE_INITIALIZING, ///< Adaptor is paused while application is initializing. + STOPPED, ///< Adaptor has been stopped. }; - typedef std::vector ObserverContainer; + // There is no weak handle for BaseHandle in DALi, but we can't ref count the window here, + // so we have to store the raw pointer. + using WindowContainer = std::vector; + using ObserverContainer = std::vector; private: // Data AdaptorSignalType mResizedSignal; ///< Resized signal. AdaptorSignalType mLanguageChangedSignal; ///< Language changed signal. + WindowCreatedSignalType mWindowCreatedSignal; ///< Window created signal. Dali::Adaptor& mAdaptor; ///< Reference to public adaptor instance. State mState; ///< Current state of the adaptor Dali::Integration::Core* mCore; ///< Dali Core ThreadController* mThreadController; ///< Controls the threads - VSyncMonitor* mVSyncMonitor; ///< Monitors VSync events - GlImplementation* mGLES; ///< GL implementation - GlSyncImplementation* mGlSync; ///< GL Sync implementation - EglFactory* mEglFactory; ///< EGL Factory - Any mNativeWindow; ///< window identifier - RenderSurface* mSurface; ///< Current surface + GraphicsInterface* mGraphics; ///< Graphics interface + Dali::DisplayConnection* mDisplayConnection; ///< Display connection + WindowContainer mWindows; ///< A container of all the Windows that are currently created + + std::unique_ptr mConfigurationManager; ///< Configuration manager + TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction - EventHandler* mEventHandler; ///< event handler CallbackManager* mCallbackManager; ///< Used to install callbacks bool mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event TriggerEventInterface* mNotificationTrigger; ///< Notification event trigger - GestureManager* mGestureManager; ///< Gesture manager FeedbackPluginProxy* mDaliFeedbackPlugin; ///< Used to access feedback support FeedbackController* mFeedbackController; ///< Plays feedback effects for Dali-Toolkit UI Controls. Dali::TtsPlayer mTtsPlayers[Dali::TtsPlayer::MODE_NUM]; ///< Provides TTS support ObserverContainer mObservers; ///< A list of adaptor observer pointers - DragAndDropDetectorPtr mDragAndDropDetector; ///< The Drag & Drop detector - RotationObserver* mDeferredRotationObserver; ///< deferred Rotation observer needs event handler EnvironmentOptions* mEnvironmentOptions; ///< environment options PerformanceInterface* mPerformanceInterface; ///< Performance interface KernelTrace mKernelTracer; ///< Kernel tracer SystemTrace mSystemTracer; ///< System tracer - TriggerEventFactory mTriggerEventFactory; ///< Trigger event factory ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling SocketFactory mSocketFactory; ///< Socket factory const bool mEnvironmentOptionsOwned:1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it) - bool mUseRemoteSurface; ///< whether the remoteSurface is used or not + bool mUseRemoteSurface:1; ///< whether the remoteSurface is used or not + public: - inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;} + inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) { return *adaptor.mImpl; } }; } // namespace Internal @@ -627,4 +699,4 @@ public: } // namespace Dali -#endif // __DALI_INTERNAL_ADAPTOR_IMPL_H__ +#endif // DALI_INTERNAL_ADAPTOR_IMPL_H