Add SetPartialUpdateEnabled to Window resf/for/devel/master
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 22 Jun 2023 04:17:13 +0000 (13:17 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 26 Jun 2023 00:09:20 +0000 (09:09 +0900)
Change-Id: Ic8ae7c4c1a76d9aa5dbd31e61485d7900c8dc13b

automated-tests/src/dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-actor-utils.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/public-api/adaptor-framework/window.cpp
dali/public-api/adaptor-framework/window.h

index eb1ab88..d628f0d 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/dali-core.h>
 
 // INTERNAL INCLUDES
+#include <dali-test-suite-utils.h>
 #include "mesh-builder.h"
 
 namespace Dali
@@ -138,4 +139,29 @@ TextureSet CreateTextureSet(Pixel::Format format, int width, int height)
   return textureSet;
 }
 
+void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation)
+{
+  // Just check damagedRect contain all expectRectList.
+  DALI_TEST_GREATER(damagedRects.size() + 1u, expectedRectList.size(), testLocation);
+
+  for(auto& rect : damagedRects)
+  {
+    auto iter = expectedRectList.find(rect);
+    if(iter != expectedRectList.end())
+    {
+      expectedRectList.erase(iter);
+    }
+    else if(checkRectsExact)
+    {
+      std::ostringstream o;
+      o << rect << " exist in expectRectList" << std::endl;
+      fprintf(stderr, "Test failed in %s, checking %s", testLocation, o.str().c_str());
+      tet_result(TET_FAIL);
+    }
+  }
+
+  // Check all rects are matched
+  DALI_TEST_EQUALS(expectedRectList.empty(), true, testLocation);
+}
+
 } // namespace Dali
index 94f1493..6571365 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/public-api/rendering/texture.h>
+#include <set> // For std::multiset
 #include <string>
 
 namespace Dali
@@ -63,6 +64,30 @@ Actor CreateRenderableActor2(TextureSet textures, const std::string& vertexShade
 Texture    CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height);
 TextureSet CreateTextureSet(Pixel::Format format, int width, int height);
 
+// Check dirtyRect is equal with expected multiset.
+// Note that the order of damagedRect is not important
+struct RectSorter
+{
+  bool operator()(const Rect<int>& lhs, const Rect<int>& rhs) const
+  {
+    if(lhs.x != rhs.x)
+    {
+      return lhs.x < rhs.x;
+    }
+    if(lhs.y != rhs.y)
+    {
+      return lhs.y < rhs.y;
+    }
+    if(lhs.width != rhs.width)
+    {
+      return lhs.width < rhs.width;
+    }
+    return lhs.height < rhs.height;
+  }
+};
+
+void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation);
+
 } // namespace Dali
 
 #endif // DALI_TEST_ACTOR_UTILS_H
index dd75c39..f1b62f8 100644 (file)
@@ -190,8 +190,8 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   bool isSetWithScreenSize = false;
   if(mWindowWidth <= 0 || mWindowHeight <= 0)
   {
-    mWindowWidth         = screenWidth;
-    mWindowHeight        = screenHeight;
+    mWindowWidth        = screenWidth;
+    mWindowHeight       = screenHeight;
     isSetWithScreenSize = true;
     DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
   }
@@ -334,6 +334,16 @@ void Window::KeepRendering(float durationSeconds)
   mScene.KeepRendering(durationSeconds);
 }
 
+void Window::SetPartialUpdateEnabled(bool enabled)
+{
+  mScene.SetPartialUpdateEnabled(enabled);
+}
+
+bool Window::IsPartialUpdateEnabled() const
+{
+  return mScene.IsPartialUpdateEnabled();
+}
+
 std::string Window::GetNativeResourceId() const
 {
   return mWindowBase->GetNativeWindowResourceId();
index da9336d..e78d32b 100644 (file)
@@ -169,6 +169,16 @@ public:
   void KeepRendering(float durationSeconds);
 
   /**
+   * @copydoc Dali::Window::SetPartialUpdateEnabled()
+   */
+  void SetPartialUpdateEnabled(bool enabled);
+
+  /**
+   * @copydoc Dali::Window::IsPartialUpdateEnabled()
+   */
+  bool IsPartialUpdateEnabled() const;
+
+  /**
    * @brief Get window resource ID assigned by window manager
    * @return The resource ID of the window
    */
@@ -823,10 +833,10 @@ private:
   std::vector<int> mAvailableAngles;
   int              mPreferredAngle;
 
-  int mRotationAngle;               ///< The angle of the rotation
-  int mWindowWidth;                 ///< The width of the window
-  int mWindowHeight;                ///< The height of the window
-  int mNativeWindowId;              ///< The Native Window Id
+  int mRotationAngle;  ///< The angle of the rotation
+  int mWindowWidth;    ///< The width of the window
+  int mWindowHeight;   ///< The height of the window
+  int mNativeWindowId; ///< The Native Window Id
 
   EventHandlerPtr mEventHandler;    ///< The window events handler
   OrientationMode mOrientationMode; ///< The physical screen mode is portrait or landscape
@@ -856,7 +866,7 @@ private:
   bool mOpaqueState : 1;
   bool mWindowRotationAcknowledgement : 1;
   bool mFocused : 1;
-  bool mIsWindowRotating : 1;     ///< The window rotating flag.
+  bool mIsWindowRotating : 1;      ///< The window rotating flag.
   bool mIsEnabledUserGeometry : 1; ///< The user geometry enable flag.
 };
 
index 5e49474..069b57e 100644 (file)
@@ -344,6 +344,16 @@ void Window::KeepRendering(float durationSeconds)
   GetImplementation(*this).KeepRendering(durationSeconds);
 }
 
+void Window::SetPartialUpdateEnabled(bool enabled)
+{
+  GetImplementation(*this).SetPartialUpdateEnabled(enabled);
+}
+
+bool Window::IsPartialUpdateEnabled() const
+{
+  return GetImplementation(*this).IsPartialUpdateEnabled();
+}
+
 Window::KeyEventSignalType& Window::KeyEventSignal()
 {
   return GetImplementation(*this).KeyEventSignal();
index c66abe4..64d191a 100644 (file)
@@ -581,7 +581,7 @@ public:
   RenderTaskList GetRenderTaskList();
 
   /**
-   * @brief Keep rendering for at least the given amount of time.
+   * @brief Keeps rendering for at least the given amount of time.
    *
    * By default, Dali will stop rendering when no Actor positions are being set, and when no animations are running etc.
    * This method is useful to force screen refreshes.
@@ -591,6 +591,24 @@ public:
    */
   void KeepRendering(float durationSeconds);
 
+  /**
+   * @brief Sets whether the window will update partial area or full area.
+   *
+   * @SINCE_2_2.33
+   * @param[in] enabled True if the window should update partial area
+   * @note This doesn't change the global value which is set by the environment variable.
+   * This works when partial update is enabled by the environment variable. If the partial update is disabled by the environment variable, it changes nothing.
+   */
+  void SetPartialUpdateEnabled(bool enabled);
+
+  /**
+   * @brief Queries whether the window will update partial area.
+   *
+   * @SINCE_2_2.33
+   * @return True if the window should update partial area
+   */
+  bool IsPartialUpdateEnabled() const;
+
 public: // Signals
   /**
    * @brief The user should connect to this signal to get a timing when window gains focus or loses focus.