Supports to acknowledge for completing window rotation 95/262895/22
authorWonsik Jung <sidein@samsung.com>
Mon, 23 Aug 2021 07:04:29 +0000 (16:04 +0900)
committerWonsik Jung <sidein@samsung.com>
Tue, 19 Oct 2021 05:42:42 +0000 (14:42 +0900)
It is waited the window rotation completing until a view finishes to draw.
The view is drawn on the other thread.
It means asychronous rendering occurs between dali render thread and the other thread when window is rotated.

Change-Id: I6bc0fc45337f7972cf2d2bdc7f1a53c3a3710cf3

automated-tests/src/dali-adaptor/utc-Dali-Window.cpp
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/integration-api/adaptor-framework/scene-holder-impl.cpp
dali/integration-api/adaptor-framework/scene-holder-impl.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/internal/window-system/common/window-render-surface.cpp
dali/internal/window-system/common/window-render-surface.h

index b44030d..895870d 100644 (file)
@@ -1402,3 +1402,50 @@ int UtcDaliWindowSubtractInputRegion(void)
   }
   END_TEST;
 }
+
+
+int UtcDaliWindowSetNeedsRotationCompletedAcknowledgementNegative(void)
+{
+  try
+  {
+    Dali::Window arg1;
+    DevelWindow::SetNeedsRotationCompletedAcknowledgement(arg1, true);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliWindowUnsetNeedsRotationCompletedAcknowledgementNegative(void)
+{
+  try
+  {
+    Dali::Window arg1;
+    DevelWindow::SetNeedsRotationCompletedAcknowledgement(arg1, false);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliWindowSendRotationCompletedAcknowledgementNegative(void)
+{
+  try
+  {
+    Dali::Window arg1;
+    DevelWindow::SendRotationCompletedAcknowledgement(arg1);
+
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
index 9f87ce7..09f070c 100644 (file)
@@ -186,6 +186,16 @@ void ExcludeInputRegion(Window window, const Rect<int>& inputRegion)
   GetImplementation(window).ExcludeInputRegion(inputRegion);
 }
 
+void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement)
+{
+  GetImplementation(window).SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
+}
+
+void SendRotationCompletedAcknowledgement(Window window)
+{
+  GetImplementation(window).SendRotationCompletedAcknowledgement();
+}
+
 } // namespace DevelWindow
 
 } // namespace Dali
index 8bc287e..321b294 100644 (file)
@@ -353,6 +353,29 @@ DALI_ADAPTOR_API void IncludeInputRegion(Window window, const Rect<int>& inputRe
  */
 DALI_ADAPTOR_API void ExcludeInputRegion(Window window, const Rect<int>& inputRegion);
 
+/**
+ * @brief Sets the necessary for window rotation Acknowledgement.
+ * After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
+ *
+ * This function is supprot that application has the window rotation acknowledgement's control.
+ * It means display server waits when application's rotation work is finished.
+ * It is useful application has the other rendering engine which works asynchronous.
+ * For instance, GlView.
+ * It only works on Tizen device.
+ *
+ * @param[in] window The window instance.
+ * @param[in] needAcknowledgement the flag is true if window rotation acknowledge is sent.
+ */
+DALI_ADAPTOR_API void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement);
+
+/**
+ * @brief send the Acknowledgement to complete window rotation.
+ * For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
+ *
+ * @param[in] window The window instance.
+ */
+DALI_ADAPTOR_API void SendRotationCompletedAcknowledgement(Window window);
+
 } // namespace DevelWindow
 
 } // namespace Dali
index fe93f69..5b64638 100644 (file)
@@ -262,6 +262,11 @@ void SceneHolder::SurfaceRotated(float width, float height, int orientation)
   mScene.SurfaceRotated(width, height, orientation);
 }
 
+void SceneHolder::SetRotationCompletedAcknowledgement()
+{
+  mScene.SetRotationCompletedAcknowledgement();
+}
+
 void SceneHolder::FeedTouchPoint(Dali::Integration::Point& point, int timeStamp)
 {
   if(timeStamp < 1)
index ce33fb4..7f6c9ff 100644 (file)
@@ -170,6 +170,12 @@ public:
   void SurfaceRotated(float width, float height, int orientation);
 
   /**
+   * @brief Send message to acknowledge window rotation with current window orientation.
+   * It is to send message to render thread for completing window rotation by user.
+   */
+  void SetRotationCompletedAcknowledgement();
+
+  /**
    * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
    */
   void FeedTouchPoint(Dali::Integration::Point& point, int timeStamp);
index a9ba67e..ce7a6a7 100644 (file)
@@ -79,6 +79,7 @@ Window::Window()
   mIsFocusAcceptable(true),
   mIconified(false),
   mOpaqueState(false),
+  mWindowRotationAcknowledgement(false),
   mParentWindow(NULL),
   mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
   mRotationAngle(0),
@@ -1020,6 +1021,22 @@ void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
   mWindowBase->ExcludeInputRegion(inputRegion);
 }
 
+void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
+{
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), needAcknowledgement(%d) Set needs Rotation Completed Acknowledgement\n", this, mNativeWindowId, needAcknowledgement);
+  mWindowSurface->SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
+  mWindowRotationAcknowledgement = needAcknowledgement;
+}
+
+void Window::SendRotationCompletedAcknowledgement()
+{
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SendRotationCompletedAcknowledgement(): orientation: %d, mWindowRotationAcknowledgement: %d\n", this, mNativeWindowId, mRotationAngle, mWindowRotationAcknowledgement);
+  if(mWindowRotationAcknowledgement)
+  {
+    SetRotationCompletedAcknowledgement();
+  }
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 843870b..4287126 100644 (file)
@@ -406,6 +406,16 @@ public: // Dali::Internal::Adaptor::SceneHolder
    */
   void ExcludeInputRegion(const Rect<int>& inputRegion);
 
+  /**
+   * @copydoc Dali::DevelWindow::SetNeedsRotationCompletedAcknowledgement()
+   */
+  void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement);
+
+  /**
+   * @copydoc Dali::DevelWindow::SendRotationCompletedAcknowledgement()
+   */
+  void SendRotationCompletedAcknowledgement();
+
 private:
   /**
    * @brief Enumeration for orietation mode.
@@ -610,6 +620,7 @@ private:
   bool                 mIsFocusAcceptable : 1;
   bool                 mIconified : 1;
   bool                 mOpaqueState : 1;
+  bool                 mWindowRotationAcknowledgement : 1;
   Dali::Window         mParentWindow;
 
   OrientationPtr   mOrientation;
index 4a44951..8e3c997 100644 (file)
@@ -146,7 +146,8 @@ WindowRenderSurface::WindowRenderSurface(Dali::PositionSize positionSize, Any su
   mScreenRotationFinished(true),
   mResizeFinished(true),
   mDefaultScreenRotationAvailable(false),
-  mIsImeWindowSurface(false)
+  mIsImeWindowSurface(false),
+  mNeedWindowRotationAcknowledgement(false)
 {
   DALI_LOG_INFO(gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n");
   Initialize(surface);
@@ -215,7 +216,7 @@ void WindowRenderSurface::RequestRotation(int angle, int width, int height)
   if(!mPostRenderTrigger)
   {
     mPostRenderTrigger = std::unique_ptr<TriggerEventInterface>(TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &WindowRenderSurface::ProcessPostRender),
-                                                                                                        TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
+                                                                                                      TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
   }
 
   mPositionSize.width  = width;
@@ -581,7 +582,31 @@ void WindowRenderSurface::PostRender()
     GlImplementation& mGLES = eglGraphics->GetGlesInterface();
     mGLES.PostRender();
 
-    if((mIsResizing && !mWindowRotationFinished) || mIsImeWindowSurface)
+    bool needWindowRotationCompleted = false;
+
+    if(!mWindowRotationFinished)
+    {
+      if(mNeedWindowRotationAcknowledgement)
+      {
+        Dali::Integration::Scene scene = mScene.GetHandle();
+        if(scene)
+        {
+          if(scene.IsRotationCompletedAcknowledgementSet())
+          {
+            needWindowRotationCompleted = true;
+          }
+        }
+      }
+      else
+      {
+        if(mIsResizing)
+        {
+          needWindowRotationCompleted = true;
+        }
+      }
+    }
+
+    if(needWindowRotationCompleted || mIsImeWindowSurface)
     {
       if(mThreadSynchronization)
       {
@@ -659,6 +684,11 @@ void WindowRenderSurface::InitializeImeSurface()
   }
 }
 
+void WindowRenderSurface::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
+{
+  mNeedWindowRotationAcknowledgement = needAcknowledgement;
+}
+
 void WindowRenderSurface::OutputTransformed()
 {
   int screenRotationAngle = mWindowBase->GetScreenRotationAngle();
index bd15471..e0ef0ec 100644 (file)
@@ -119,6 +119,17 @@ public: // API
   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 This signal is emitted when the output is transformed.
    */
   OutputSignalType& OutputTransformedSignal();
@@ -319,6 +330,7 @@ private: // Data
   bool                                   mResizeFinished;
   bool                                   mDefaultScreenRotationAvailable;
   bool                                   mIsImeWindowSurface;
+  bool                                   mNeedWindowRotationAcknowledgement;
 
 }; // class WindowRenderSurface