[Tizen] Add to get the status whether window is rotating or not
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.h
index 373e131..5e58893 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/signals/connection-tracker.h>
-#include <dali/public-api/signals/dali-signal.h>
 #include <dali/devel-api/threading/mutex.h>
 #include <dali/integration-api/scene.h>
+#include <dali/public-api/signals/connection-tracker.h>
+#include <dali/public-api/signals/dali-signal.h>
 #include <unistd.h>
 
 // INTERNAL INCLUDES
 
 namespace Dali
 {
-
 class TriggerEventInterface;
 
 namespace Internal
 {
 namespace Adaptor
 {
-
 class WindowBase;
 class AdaptorInternalServices;
 
@@ -50,9 +48,8 @@ class AdaptorInternalServices;
 class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
 {
 public:
-
-  using OutputSignalType = Signal< void ( ) >;
-  using DamagedRectsContainer = std::list< std::vector< Rect< int > > >;
+  using OutputSignalType      = Signal<void()>;
+  using DamagedRectsContainer = std::list<std::vector<Rect<int>>>;
 
   /**
     * Uses an window surface to render to.
@@ -60,7 +57,7 @@ public:
     * @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 );
+  WindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false);
 
   /**
    * @brief Destructor
@@ -68,7 +65,6 @@ public:
   virtual ~WindowRenderSurface();
 
 public: // API
-
   /**
    * @brief Get the native window handle
    * @return The native window handle
@@ -90,21 +86,20 @@ public: // API
    * @brief Sets the render notification trigger to call when render thread is completed a frame
    * @param renderNotification to use
    */
-  void SetRenderNotification( TriggerEventInterface* renderNotification );
+  void SetRenderNotification(TriggerEventInterface* renderNotification);
 
   /**
    * @brief Sets whether the surface is transparent or not.
    * @param[in] transparent Whether the surface is transparent
    */
-  void SetTransparency( bool transparent );
+  void SetTransparency(bool transparent);
 
   /**
    * Request surface rotation
    * @param[in] angle A new angle of the surface
-   * @param[in] width A new width of the surface
-   * @param[in] height A new height of the surface
+   * @param[in] positionSize A new position and size of the surface
    */
-  void RequestRotation( int angle, int width, int height );
+  void RequestRotation(int angle, PositionSize positionSize);
 
   /**
    * @brief Gets the window base object
@@ -113,12 +108,48 @@ public: // API
   WindowBase* GetWindowBase();
 
   /**
+   * @brief Intiailize Ime Surface for Ime window rendering.
+   *
+   * It sets one flag and callback function for Ime window rendering
+   * This callback function calls one special native window function for ready to commit buffer.
+   * The special function notify to display server.
+   * It is only used for Ime window.
+   */
+  void InitializeImeSurface();
+
+  /**
+   * @brief Sets the necessary for window rotation acknowledge.
+   * After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
+   *
+   * More detail description is written in DevelWindow::SetNeedsRotationCompletedAcknowledgement().
+   *
+   * @param[in] window The window instance.
+   * @param[in] needAcknowledgement the flag is true if window rotation acknowledgement is sent.
+   */
+  void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement);
+
+  /**
+   * @brief Updates window surface's position and size.
+   * It is just to update the local variable in window surface.
+   * This function is only called when window's position or size is changed by display server.
+   *
+   * @param[in] positionSize The updated window surface's position and size.
+   */
+  void UpdatePositionSize(Dali::PositionSize positionSize);
+
+  /**
+   * @brief Query whether window is rotating or not.
+   *
+   * @return true if window is rotating, false otherwise.
+   */
+  bool IsWindowRotating() const;
+
+  /**
    * @brief This signal is emitted when the output is transformed.
    */
   OutputSignalType& OutputTransformedSignal();
 
 public: // from Dali::RenderSurfaceInterface
-
   /**
    * @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
    */
@@ -126,13 +157,12 @@ public: // from Dali::RenderSurfaceInterface
 
   /**
    */
-  void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+  void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
 
   /**
-   * @brief Return the orientation of the surface.
-   * @return The orientation
+   * @copydoc Dali::RenderSurfaceInterface::GetOrientation()
    */
-  virtual int GetOrientation() const override;
+  int GetOrientation() const override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
@@ -157,7 +187,7 @@ public: // from Dali::RenderSurfaceInterface
   /**
    * @copydoc Dali::RenderSurfaceInterface::MoveResize()
    */
-  void MoveResize( Dali::PositionSize positionSize) override;
+  void MoveResize(Dali::PositionSize positionSize) override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::StartRender()
@@ -167,12 +197,12 @@ public: // from Dali::RenderSurfaceInterface
   /**
    * @copydoc Dali::RenderSurfaceInterface::PreRender()
    */
-  bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
+  bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::PostRender()
    */
-  void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
+  void PostRender() override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::StopRender()
@@ -182,7 +212,7 @@ public: // from Dali::RenderSurfaceInterface
   /**
    * @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
    */
-  void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
+  void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
@@ -210,11 +240,10 @@ public: // from Dali::RenderSurfaceInterface
   Integration::StencilBufferAvailable GetStencilBufferRequired() override;
 
 private:
-
   /**
    * @brief Second stage construction
    */
-  void Initialize( Any surface );
+  void Initialize(Any surface);
 
   /**
    * Notify output is transformed.
@@ -222,9 +251,10 @@ private:
   void OutputTransformed();
 
   /**
-   * @brief Used as the callback for the rotation-trigger.
+   * @brief Used as the callback for the post render.
+   * It is used both window rotation and supporting Ime window
    */
-  void ProcessRotationRequest();
+  void ProcessPostRender();
 
   /**
    * @brief Used as the callback for the frame rendered / presented.
@@ -236,23 +266,22 @@ private:
    * @param[in] eventBitMask bit mask of events that occured on the file descriptor
    * @param[in] fileDescriptor The file descriptor
    */
-  void OnFileDescriptorEventDispatched( FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor );
+  void OnFileDescriptorEventDispatched(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor);
 
   /**
    * @brief Set the buffer damage rects.
    * @param[in] damagedRects List of damaged rects
    * @param[in] clippingRect The rect to clip rendered scene
    */
-  void SetBufferDamagedRects( const std::vector< Rect< int > >& damagedRects, Rect< int >& clippingRect );
+  void SetBufferDamagedRects(const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
 
   /**
    * @brief Swap buffers.
    * @param[in] damagedRects List of damaged rects
    */
-  void SwapBuffers( const std::vector<Rect<int>>& damagedRects );
+  void SwapBuffers(const std::vector<Rect<int>>& damagedRects);
 
 protected:
-
   // Undefined
   WindowRenderSurface(const WindowRenderSurface&) = delete;
 
@@ -260,18 +289,17 @@ protected:
   WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
 
 private:
-
   struct FrameCallbackInfo
   {
-    FrameCallbackInfo( Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd )
+    FrameCallbackInfo(Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd)
     : callbacks(),
       fileDescriptorMonitor(),
-      fileDescriptor( fd )
+      fileDescriptor(fd)
     {
       // Transfer owership of the CallbackBase
-      for( auto&& iter : callbackList )
+      for(auto&& iter : callbackList)
       {
-        callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
+        callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
       }
     }
 
@@ -279,50 +307,51 @@ private:
     {
       // Delete FileDescriptorMonitor before close fd.
       fileDescriptorMonitor.release();
-      close( fileDescriptor );
+      close(fileDescriptor);
     }
 
     Dali::Integration::Scene::FrameCallbackContainer callbacks;
-    std::unique_ptr< FileDescriptorMonitor > fileDescriptorMonitor;
-    int fileDescriptor;
+    std::unique_ptr<FileDescriptorMonitor>           fileDescriptorMonitor;
+    int                                              fileDescriptor;
   };
 
-  using FrameCallbackInfoContainer = std::vector< std::unique_ptr< FrameCallbackInfo > >;
+  using FrameCallbackInfoContainer = std::vector<std::unique_ptr<FrameCallbackInfo>>;
 
 private: // Data
-
-  EglInterface*                   mEGL;
-  Dali::DisplayConnection*        mDisplayConnection;
-  PositionSize                    mPositionSize;       ///< Position
-  std::unique_ptr< WindowBase >   mWindowBase;
-  ThreadSynchronizationInterface* mThreadSynchronization;
-  TriggerEventInterface*          mRenderNotification; ///< Render notification trigger
-  TriggerEventInterface*          mRotationTrigger;
-  std::unique_ptr< TriggerEventInterface > mFrameRenderedTrigger;
-  GraphicsInterface*              mGraphics;           ///< Graphics interface
-  EGLSurface                      mEGLSurface;
-  EGLContext                      mEGLContext;
-  ColorDepth                      mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
-  OutputSignalType                mOutputTransformedSignal;
-  FrameCallbackInfoContainer      mFrameCallbackInfoContainer;
-  DamagedRectsContainer           mBufferDamagedRects;
-  Dali::Mutex                     mMutex;
-  int                             mRotationAngle;
-  int                             mScreenRotationAngle;
-  uint32_t                        mDpiHorizontal;
-  uint32_t                        mDpiVertical;
-  bool                            mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)
-  bool                            mRotationSupported;
-  bool                            mRotationFinished;
-  bool                            mScreenRotationFinished;
-  bool                            mResizeFinished;
-  bool                            mDefaultScreenRotationAvailable;
+  EglInterface*                          mEGL;
+  Dali::DisplayConnection*               mDisplayConnection;
+  PositionSize                           mPositionSize; ///< Position
+  std::unique_ptr<WindowBase>            mWindowBase;
+  ThreadSynchronizationInterface*        mThreadSynchronization;
+  TriggerEventInterface*                 mRenderNotification; ///< Render notification trigger
+  std::unique_ptr<TriggerEventInterface> mPostRenderTrigger;  ///< Post render callback function
+  std::unique_ptr<TriggerEventInterface> mFrameRenderedTrigger;
+  GraphicsInterface*                     mGraphics; ///< Graphics interface
+  EGLSurface                             mEGLSurface;
+  EGLContext                             mEGLContext;
+  ColorDepth                             mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
+  OutputSignalType                       mOutputTransformedSignal;
+  FrameCallbackInfoContainer             mFrameCallbackInfoContainer;
+  DamagedRectsContainer                  mBufferDamagedRects;
+  Dali::Mutex                            mMutex;
+  int                                    mWindowRotationAngle;
+  int                                    mScreenRotationAngle;
+  uint32_t                               mDpiHorizontal;
+  uint32_t                               mDpiVertical;
+  std::vector<Rect<int>>                 mDamagedRects{}; ///< Keeps collected damaged render items rects for one render pass
+  bool                                   mOwnSurface;     ///< Whether we own the surface (responsible for deleting it)
+  bool                                   mWindowRotationFinished;
+  bool                                   mScreenRotationFinished;
+  bool                                   mResizeFinished;
+  bool                                   mDefaultScreenRotationAvailable;
+  bool                                   mIsImeWindowSurface;
+  bool                                   mNeedWindowRotationAcknowledgement;
 
 }; // class WindowRenderSurface
 
 } // namespace Adaptor
 
-} // namespace internal
+} // namespace Internal
 
 } // namespace Dali