Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.h
index 1e0e5b0..55bc955 100644 (file)
  */
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/render-surface.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
+
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/egl-interface.h>
+#include <dali/integration-api/render-surface-interface.h>
+#else
+#include <dali/integration-api/adaptors/egl-interface.h>
+#include <dali/integration-api/adaptors/render-surface-interface.h>
+#endif
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/signals/connection-tracker.h>
+#include <dali/public-api/signals/dali-signal.h>
 
 namespace Dali
 {
@@ -31,47 +43,61 @@ namespace Internal
 namespace Adaptor
 {
 
+class WindowBase;
+class AdaptorInternalServices;
+
 /**
  * Window interface of render surface.
  */
-class WindowRenderSurface : public Dali::RenderSurface
+class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
 {
 public:
 
+  typedef Signal< void ( ) > OutputSignalType;
+
   /**
-   * @brief Default constructor
-   */
-  WindowRenderSurface() = default;
+    * Uses an window surface to render to.
+    * @param [in] positionSize the position and size of the surface
+    * @param [in] surface can be a window or pixmap.
+    * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+    */
+  WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
 
   /**
    * @brief Destructor
    */
-  virtual ~WindowRenderSurface() = default;
+  virtual ~WindowRenderSurface();
 
 public: // API
 
   /**
-   * @brief Get the render surface the adaptor is using to render to.
-   * @return reference to current render surface
+   * @brief Get the native window handle
+   * @return The native window handle
    */
-  virtual Any GetWindow() = 0;
+  Any GetNativeWindow();
+
+  /**
+   * @brief Get the native window id
+   * @return The native window id
+   */
+  int GetNativeWindowId();
 
   /**
    * @brief Map window
    */
-  virtual void Map() = 0;
+  void Map();
 
   /**
    * @brief Sets the render notification trigger to call when render thread is completed a frame
    * @param renderNotification to use
    */
-  virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) = 0;
+  void SetRenderNotification( TriggerEventInterface* renderNotification );
 
   /**
    * @brief Sets whether the surface is transparent or not.
    * @param[in] transparent Whether the surface is transparent
    */
-  virtual void SetTransparency( bool transparent ) = 0;
+  void SetTransparency( bool transparent );
 
   /**
    * Request surface rotation
@@ -79,25 +105,121 @@ public: // API
    * @param[in] width A new width of the surface
    * @param[in] height A new height of the surface
    */
-  virtual void RequestRotation( int angle, int width, int height ) = 0;
+  void RequestRotation( int angle, int width, int height );
 
-protected:
+  /**
+   * @brief Gets the window base object
+   * @return The window base object
+   */
+  WindowBase* GetWindowBase();
+
+  /**
+   * @brief This signal is emitted when the output is transformed.
+   */
+  OutputSignalType& OutputTransformedSignal();
+
+public: // from Dali::Integration::RenderSurface
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetPositionSize()
+   */
+  virtual PositionSize GetPositionSize() const override;
+
+  /**
+   */
+  virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
+   */
+  virtual void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::CreateSurface()
+   */
+  virtual void CreateSurface() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::DestroySurface()
+   */
+  virtual void DestroySurface() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
+   */
+  virtual bool ReplaceGraphicsSurface() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::MoveResize()
+   */
+  virtual void MoveResize( Dali::PositionSize positionSize) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::StartRender()
+   */
+  virtual void StartRender() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::PreRender()
+   */
+  virtual bool PreRender( bool resizingSurface ) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::PostRender()
+   */
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::StopRender()
+   */
+  virtual void StopRender() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
+   */
+  virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
+   */
+  virtual void ReleaseLock() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
+   */
+  virtual Integration::RenderSurface::Type GetSurfaceType() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
+   */
+  virtual void MakeContextCurrent() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired()
+   */
+  virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired()
+   */
+  virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
+
+private:
 
   /**
    * @brief Second stage construction
    */
-  virtual void Initialize( Any surface ) = 0;
+  void Initialize( Any surface );
 
   /**
-   * @brief Create window
+   * Notify output is transformed.
    */
-  virtual void CreateRenderable() = 0;
+  void OutputTransformed();
 
   /**
-   * @brief Use an existing render surface
-   * @param surfaceId the id of the surface
+   * @brief Used as the callback for the rotation-trigger.
    */
-  virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
+  void ProcessRotationRequest();
 
 protected:
 
@@ -107,6 +229,28 @@ protected:
   // Undefined
   WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
 
+private: // Data
+
+  EglInterface*                   mEGL;
+  Dali::DisplayConnection*        mDisplayConnection;
+  PositionSize                    mPositionSize;       ///< Position
+  std::unique_ptr< WindowBase >   mWindowBase;
+  ThreadSynchronizationInterface* mThreadSynchronization;
+  TriggerEventInterface*          mRenderNotification; ///< Render notification trigger
+  TriggerEventInterface*          mRotationTrigger;
+  GraphicsInterface*              mGraphics;           ///< Graphics interface
+  EGLSurface                      mEGLSurface;
+  EGLContext                      mEGLContext;
+  ColorDepth                      mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
+  OutputSignalType                mOutputTransformedSignal;
+  int                             mRotationAngle;
+  int                             mScreenRotationAngle;
+  bool                            mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)
+  bool                            mRotationSupported;
+  bool                            mRotationFinished;
+  bool                            mScreenRotationFinished;
+  bool                            mResizeFinished;
+
 }; // class WindowRenderSurface
 
 } // namespace Adaptor