Separate out Render Helper
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.h
index 432bdcd..26c3bb7 100755 (executable)
@@ -1,5 +1,5 @@
-#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.
@@ -31,6 +31,8 @@
 #include <dali/public-api/adaptor-framework/tts-player.h>
 #include <dali/devel-api/adaptor-framework/clipboard.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>
@@ -43,6 +45,7 @@
 #include <dali/integration-api/trigger-event-factory.h>
 #include <dali/internal/network/common/socket-factory.h>
 
+
 namespace Dali
 {
 
@@ -60,8 +63,9 @@ namespace Internal
 
 namespace Adaptor
 {
+class DisplayConnection;
+class GraphicsFactory;
 class EventHandler;
-class EglFactory;
 class GestureManager;
 class GlImplementation;
 class GlSyncImplementation;
@@ -111,12 +115,44 @@ public:
    * @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::Window window,
+                             Dali::Configuration::ContextLoss configuration,
+                             EnvironmentOptions* environmentOptions );
+
+  /**
+   * Creates a New Adaptor
+   * @param[in]  graphicsFactory     A factory that creates the graphics interface
+   * @param[in]  nativeWindow        Native 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,
+                             Any nativeWindow,
+                             RenderSurface* surface,
+                             Dali::Configuration::ContextLoss configuration,
+                             EnvironmentOptions* environmentOptions );
+
+  /**
+   * Creates a New Adaptor
+   * @param[in]  graphicsFactory     A factory that creates the graphics interface
+   * @param[in]  nativeWindow        native 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::Window 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.
@@ -212,10 +248,40 @@ 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::Window* childWindow,
+                          const std::string& childWindowName,
+                          const std::string& childWindowClassName,
+                          const bool& childWindowMode );
+
+  /**
+   * Removes an existing Window instance from the Adaptor
+   * @param[in]  window The Window instance
+   */
+  virtual bool RemoveWindow( Dali::Window* 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 );
 
+  /**
+   * Sets a pre-render callback.
+   */
+  void SetPreRenderCallback( CallbackBase* callback );
+
 public:
 
   /**
@@ -234,17 +300,6 @@ public:
   void SetUseHardwareVSync(bool useHardware);
 
   /**
-   * @return reference to EglFactory class
-   */
-  EglFactory& GetEGLFactory() const;
-
-  /**
-   * Return GlAbstraction.
-   * @return the GlAbstraction.
-   */
-  Integration::GlAbstraction& GetGlAbstraction() const;
-
-  /**
    * Return the PlatformAbstraction.
    * @return The PlatformAbstraction.
    */
@@ -264,7 +319,7 @@ public:
   void SetRotationObserver( RotationObserver* observer );
 
   /**
-   * 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);
@@ -285,7 +340,14 @@ public:
   Any GetNativeWindowHandle();
 
   /**
-   * 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);
@@ -370,14 +432,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()
@@ -505,8 +567,8 @@ private: // From Dali::Internal::Adaptor::DamageObserver
 private:
 
   // Undefined
-  Adaptor(const Adaptor&);
-  Adaptor& operator=(Adaptor&);
+  Adaptor(const Adaptor&) = delete;
+  Adaptor& operator=(Adaptor&) = delete;
 
 private:
 
@@ -524,7 +586,7 @@ private:
   /**
    * Sends an notification message from main loop idle handler
    */
-  void ProcessCoreEventsFromIdle();
+  bool ProcessCoreEventsFromIdle();
 
   /**
    * Gets path for data/resource storage.
@@ -577,6 +639,19 @@ private: // Types
     STOPPED,             ///< Adaptor has been stopped.
   };
 
+  // A structure to encapsulate each Window instance for the Adaptor to track them
+  typedef struct WindowPane
+  {
+    Dali::Window*  instance;     ///< Window object
+    std::string    window_name;  ///< Name (title)_of the window
+    std::string    class_name;   ///< Class name that the window belongs to
+    bool           window_mode;  ///< Display mode of the window
+    Any            nativeWindow; ///< window identifier
+    RenderSurface* surface;      ///< The surface the Window is bound to
+  } WindowPane;
+
+  typedef std::vector<WindowPane> WindowFrames;
+
   typedef std::vector<LifeCycleObserver*>  ObserverContainer;
 
 private: // Data
@@ -589,12 +664,11 @@ private: // Data
   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
+  WindowFrames                          mWindowFrame;                 ///< A container of all the Windows that are currently created
+
   TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction;      ///< Platform abstraction
 
   EventHandler*                         mEventHandler;                ///< event handler
@@ -617,8 +691,9 @@ private: // Data
   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
+
 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 +702,4 @@ public:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_ADAPTOR_IMPL_H__
+#endif // DALI_INTERNAL_ADAPTOR_IMPL_H