Merge "Changed 'virtual' function override declarations to 'override' in automated...
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.h
index edd2e40..a62bede 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_ADAPTOR_IMPL_H
 
 /*
- * Copyright (c) 2019 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.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/common/view-mode.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/signals/callback.h>
 #include <dali/public-api/math/uint-16-pair.h>
 #include <dali/integration-api/render-controller.h>
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/adaptor.h>
-#include <dali/integration-api/scene.h>
-
-#ifdef DALI_ADAPTOR_COMPILATION
-#include <dali/integration-api/scene-holder-impl.h>
-#else
-#include <dali/integration-api/adaptors/scene-holder-impl.h>
-#endif
-
 #include <dali/public-api/adaptor-framework/tts-player.h>
 #include <dali/devel-api/adaptor-framework/clipboard.h>
-
+#include <dali/integration-api/scene.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
+#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
+#include <dali/internal/adaptor/common/adaptor-internal-services.h>
 #include <dali/internal/graphics/common/graphics-interface.h>
-
 #include <dali/internal/legacy/common/tizen-platform-abstraction.h>
-#include <dali/internal/adaptor/common/adaptor-internal-services.h>
-#include <dali/internal/system/common/environment-options.h>
+#include <dali/internal/network/common/socket-factory.h>
 #include <dali/internal/system/common/core-event-interface.h>
-#include <dali/internal/window-system/common/damage-observer.h>
-#include <dali/internal/window-system/common/window-visibility-observer.h>
+#include <dali/internal/system/common/environment-options.h>
 #include <dali/internal/system/common/kernel-trace.h>
 #include <dali/internal/system/common/system-trace.h>
-#include <dali/integration-api/trigger-event-factory.h>
-#include <dali/internal/network/common/socket-factory.h>
-
+#include <dali/internal/window-system/common/damage-observer.h>
+#include <dali/internal/window-system/common/window-visibility-observer.h>
 
 namespace Dali
 {
@@ -63,6 +53,7 @@ namespace Integration
 class Core;
 class GlAbstraction;
 class Processor;
+class AddOnManager;
 }
 
 namespace Internal
@@ -72,7 +63,6 @@ namespace Adaptor
 {
 class DisplayConnection;
 class GraphicsFactory;
-class GestureManager;
 class GlImplementation;
 class GlSyncImplementation;
 class ThreadController;
@@ -85,6 +75,8 @@ class PerformanceInterface;
 class LifeCycleObserver;
 class ObjectProfiler;
 class SceneHolder;
+class ConfigurationManager;
+enum class ThreadMode;
 
 /**
  * Implementation of the Adaptor class.
@@ -97,9 +89,10 @@ 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
@@ -107,22 +100,18 @@ public:
    * @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( Dali::Integration::SceneHolder window,
                              Dali::RenderSurfaceInterface* surface,
-                             Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
 
   /**
    * Creates a New Adaptor
    * @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::Integration::SceneHolder window,
-                             Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
 
   /**
@@ -132,38 +121,33 @@ public:
    * @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( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration );
+  void Initialize( GraphicsFactory& graphicsFactory );
 
   /**
    * Virtual destructor.
    */
-  virtual ~Adaptor();
+  ~Adaptor() override;
 
   /**
    * @copydoc Dali::Adaptor::Get()
@@ -219,12 +203,12 @@ public: // AdaptorInternalServices implementation
   /**
    * @copydoc Dali::EventFeeder::FeedWheelEvent()
    */
-  virtual void FeedWheelEvent( WheelEvent& wheelEvent );
+  virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
 
   /**
    * @copydoc Dali::EventFeeder::FeedKeyEvent()
    */
-  virtual void FeedKeyEvent( KeyEvent& keyEvent );
+  virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent );
 
   /**
    * @copydoc Dali::Adaptor::ReplaceSurface()
@@ -256,14 +240,8 @@ public: // AdaptorInternalServices implementation
   /**
    * 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,
-                          const bool& childWindowMode );
+  virtual bool AddWindow( Dali::Integration::SceneHolder childWindow );
 
   /**
    * Removes an existing Window instance from the Adaptor
@@ -284,6 +262,11 @@ public: // AdaptorInternalServices implementation
   virtual void RemoveIdle( CallbackBase* callback );
 
   /**
+   * @copydoc Dali::Adaptor::ProcessIdle()
+   */
+  virtual void ProcessIdle();
+
+  /**
    * Sets a pre-render callback.
    */
   void SetPreRenderCallback( CallbackBase* callback );
@@ -295,6 +278,12 @@ public: // AdaptorInternalServices implementation
   bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
 
   /**
+   * @brief Deletes the rendering surface
+   * @param[in] surface to delete
+   */
+  void DeleteSurface( Dali::RenderSurfaceInterface& surface );
+
+  /**
    * @brief Retrieve the window that the given actor is added to.
    *
    * @param[in] actor The actor
@@ -302,12 +291,27 @@ public: // AdaptorInternalServices implementation
    */
   Dali::Internal::Adaptor::SceneHolder* GetWindow( Dali::Actor& actor );
 
+  /**
+   * @copydoc Dali::Adaptor::GetWindows()
+   */
+  Dali::WindowContainer GetWindows() const;
+
+  /**
+   * @copydoc Dali::Adaptor::GetSceneHolders()
+   */
+  Dali::SceneHolderList GetSceneHolders() const;
+
+  /**
+   * @copydoc Dali::Adaptor::GetObjectRegistry()
+   */
+  Dali::ObjectRegistry GetObjectRegistry() const;
+
 public:
 
   /**
    * @return the Core instance
    */
-  virtual Dali::Integration::Core& GetCore();
+  Dali::Integration::Core& GetCore() override;
 
   /**
    * @copydoc Dali::Adaptor::SetRenderRefreshRate()
@@ -315,11 +319,6 @@ public:
   void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender );
 
   /**
-   * @copydoc Dali::Adaptor::SetUseHardwareVSync()
-   */
-  void SetUseHardwareVSync(bool useHardware);
-
-  /**
    * Return the PlatformAbstraction.
    * @return The PlatformAbstraction.
    */
@@ -339,6 +338,14 @@ public:
   Any GetNativeWindowHandle();
 
   /**
+   * @brief Retrieve native window handle that the given actor is added to.
+   *
+   * @param[in] actor The actor
+   * @return native window handle
+   */
+  Any GetNativeWindowHandle( Dali::Actor actor );
+
+  /**
    * Get the native display associated with the graphics backend
    *
    * @return A handle to the native display
@@ -393,12 +400,12 @@ public:
   void GetAppId( std::string& appId );
 
   /**
-   * Informs core the surface size has changed
+   * @copydoc Dali::Adaptor::SurfaceResizePrepare
    */
   void SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
 
   /**
-   * Informs ThreadController the surface size has changed
+   * @copydoc Dali::Adaptor::SurfaceResizeComplete
    */
   void SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
 
@@ -428,62 +435,62 @@ public:
    */
   void UnregisterProcessor( Integration::Processor& processor );
 
+  /**
+   * Check MultipleWindow is supported
+   */
+  bool IsMultipleWindowSupported() const;
+
 public:  //AdaptorInternalServices
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPlatformAbstractionInterface()
    */
-  virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface();
+  Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetDisplayConnectionInterface()
    */
-  virtual Dali::DisplayConnection& GetDisplayConnectionInterface();
+  Dali::DisplayConnection& GetDisplayConnectionInterface() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGraphicsInterface()
    */
-  virtual GraphicsInterface& GetGraphicsInterface();
+  GraphicsInterface& GetGraphicsInterface() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
    */
-  virtual TriggerEventInterface& GetProcessCoreEventsTrigger();
-
-  /**
-   * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface()
-   */
-  virtual TriggerEventFactoryInterface& GetTriggerEventFactoryInterface();
+  TriggerEventInterface& GetProcessCoreEventsTrigger() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetSocketFactoryInterface()
    */
-  virtual SocketFactoryInterface& GetSocketFactoryInterface();
+  SocketFactoryInterface& GetSocketFactoryInterface() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetRenderSurfaceInterface()
    */
-  virtual Dali::RenderSurfaceInterface* GetRenderSurfaceInterface();
-
-  /**
-   * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetVSyncMonitorInterface()
-   */
-  virtual VSyncMonitorInterface* GetVSyncMonitorInterface();
+  Dali::RenderSurfaceInterface* GetRenderSurfaceInterface() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPerformanceInterface()
    */
-  virtual PerformanceInterface* GetPerformanceInterface();
+  PerformanceInterface* GetPerformanceInterface() override;
 
   /**
    * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetKernelTraceInterface()
    */
-  virtual TraceInterface& GetKernelTraceInterface();
+  TraceInterface& GetKernelTraceInterface() override;
 
   /**
    * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetSystemTraceInterface()
    */
-  virtual TraceInterface& GetSystemTraceInterface();
+  TraceInterface& GetSystemTraceInterface() override;
+
+  /**
+   * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetWindowContainerInterface()
+   */
+  void GetWindowContainerInterface( WindowContainer& windows ) override;
 
 public: // Signals
 
@@ -503,50 +510,58 @@ public: // Signals
     return mLanguageChangedSignal;
   }
 
+  /**
+   * @copydoc Dali::Adaptor::WindowCreatedSignal
+   */
+  WindowCreatedSignalType& WindowCreatedSignal()
+  {
+    return mWindowCreatedSignal;
+  }
+
 public: // From Dali::Internal::Adaptor::CoreEventInterface
 
   /**
    * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
    */
-  virtual void ProcessCoreEvents();
+  void ProcessCoreEvents() override;
 
 private: // From Dali::Internal::Adaptor::CoreEventInterface
 
   /**
    * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
    */
-  virtual void QueueCoreEvent(const Dali::Integration::Event& event);
+  void QueueCoreEvent(const Dali::Integration::Event& event) override;
 
 private: // From Dali::Integration::RenderController
 
   /**
    * @copydoc Dali::Integration::RenderController::RequestUpdate()
    */
-  virtual void RequestUpdate( bool forceUpdate );
+  void RequestUpdate( bool forceUpdate ) override;
 
   /**
    * @copydoc Dali::Integration::RenderController::RequestProcessEventsOnIdle()
    */
-  virtual void RequestProcessEventsOnIdle( bool forceProcess );
+  void RequestProcessEventsOnIdle( bool forceProcess ) override;
 
-private: // From Dali::Internal::Adaptor::WindowVisibilityObserver
+public: // From Dali::Internal::Adaptor::WindowVisibilityObserver
 
   /**
    * Called when the window becomes fully or partially visible.
    */
-  virtual void OnWindowShown();
+  void OnWindowShown() override;
 
   /**
    * Called when the window is fully hidden.
    */
-  virtual void OnWindowHidden();
+  void OnWindowHidden() override;
 
 private: // From Dali::Internal::Adaptor::DamageObserver
 
   /**
    * @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged()
    */
-  void OnDamaged( const DamageArea& area );
+  void OnDamaged( const DamageArea& area ) override;
 
 private:
 
@@ -616,32 +631,36 @@ 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.
   };
 
-  using SceneHolderPtr = IntrusivePtr< Dali::Internal::Adaptor::SceneHolder >;
-  using WindowContainer = std::vector<SceneHolderPtr>;
+  // 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<Dali::Internal::Adaptor::SceneHolder*>;
   using ObserverContainer = std::vector<LifeCycleObserver*>;
 
 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
 
-  GraphicsInterface*                    mGraphics;                    ///< Graphics interface
+  std::unique_ptr< GraphicsInterface >  mGraphics;                    ///< Graphics interface
   Dali::DisplayConnection*              mDisplayConnection;           ///< Display connection
   WindowContainer                       mWindows;                     ///< A container of all the Windows that are currently created
 
+  std::unique_ptr<ConfigurationManager> mConfigurationManager;        ///< Configuration manager
+
   TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction;      ///< Platform abstraction
 
   CallbackManager*                      mCallbackManager;             ///< Used to install callbacks
@@ -655,11 +674,14 @@ private: // Data
   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
+  ThreadMode                            mThreadMode;                  ///< The thread mode
   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
+  Dali::LayoutDirection::Type           mRootLayoutDirection;         ///< LayoutDirection of window
+
+  std::unique_ptr<Integration::AddOnManager> mAddOnManager;           ///< Pointer to the addon manager
 
 public:
   inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) { return *adaptor.mImpl; }