Revert "[Tizen] Add screen and client rotation itself function"
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.h
index 6cab258..6b72a55 100644 (file)
 // 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 <unistd.h>
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/adaptor-framework/egl-interface.h>
 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
 #include <dali/internal/graphics/common/graphics-interface.h>
+#include <dali/internal/system/common/file-descriptor-monitor.h>
 
 namespace Dali
 {
@@ -124,12 +128,6 @@ public: // from Dali::RenderSurfaceInterface
   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
 
   /**
-   * @brief Return the orientation of the surface.
-   * @return The orientation
-   */
-  virtual int GetOrientation() const override;
-
-  /**
    * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
    */
   virtual void InitializeGraphics() override;
@@ -162,12 +160,12 @@ public: // from Dali::RenderSurfaceInterface
   /**
    * @copydoc Dali::RenderSurfaceInterface::PreRender()
    */
-  virtual bool PreRender( bool resizingSurface ) override;
+  virtual bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::PostRender()
    */
-  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
 
   /**
    * @copydoc Dali::RenderSurfaceInterface::StopRender()
@@ -221,6 +219,18 @@ private:
    */
   void ProcessRotationRequest();
 
+  /**
+   * @brief Used as the callback for the frame rendered / presented.
+   */
+  void ProcessFrameCallback();
+
+  /**
+   * @brief Called when our event file descriptor has been written to.
+   * @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 );
+
 protected:
 
   // Undefined
@@ -229,6 +239,36 @@ protected:
   // Undefined
   WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
 
+private:
+
+  struct FrameCallbackInfo
+  {
+    FrameCallbackInfo( Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd )
+    : callbacks(),
+      fileDescriptorMonitor(),
+      fileDescriptor( fd )
+    {
+      // Transfer owership of the CallbackBase
+      for( auto&& iter : callbackList )
+      {
+        callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
+      }
+    }
+
+    ~FrameCallbackInfo()
+    {
+      // Delete FileDescriptorMonitor before close fd.
+      fileDescriptorMonitor.release();
+      close( fileDescriptor );
+    }
+
+    Dali::Integration::Scene::FrameCallbackContainer callbacks;
+    std::unique_ptr< FileDescriptorMonitor > fileDescriptorMonitor;
+    int fileDescriptor;
+  };
+
+  using FrameCallbackInfoContainer = std::vector< std::unique_ptr< FrameCallbackInfo > >;
+
 private: // Data
 
   EglInterface*                   mEGL;
@@ -238,11 +278,14 @@ private: // Data
   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;
+  Dali::Mutex                     mMutex;
   int                             mRotationAngle;
   int                             mScreenRotationAngle;
   bool                            mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)