(RenderSurface/Graphics) Added Resize method to manage different GLES & Vulkan behaviour 37/318837/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 9 Oct 2024 21:24:56 +0000 (22:24 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 10 Oct 2024 08:44:31 +0000 (09:44 +0100)
Change-Id: I08d44294d303a487cc0d2306910d080f5582fb91

15 files changed:
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-egl-application.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-render-surface.h
dali/integration-api/adaptor-framework/render-surface-interface.h
dali/internal/graphics/common/graphics-interface.h
dali/internal/graphics/gles/egl-graphics.cpp
dali/internal/graphics/gles/egl-graphics.h
dali/internal/graphics/vulkan/vulkan-graphics-impl.cpp
dali/internal/graphics/vulkan/vulkan-graphics-impl.h
dali/internal/window-system/common/window-render-surface.cpp
dali/internal/window-system/common/window-render-surface.h
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h
dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h
dali/internal/window-system/x11/pixmap-render-surface-x.h

index aa626202ae10518b476d187e8a34a667029a24b0..08c997cbf90165d91553263b24db3a3f64df2f30 100644 (file)
@@ -183,6 +183,11 @@ public:
     mCallstack.PushCall("Resume()", "");
   }
 
+  void Resize(Integration::RenderSurfaceInterface* surface, Uint16Pair size) override
+  {
+    mCallstack.PushCall("Resize()", "");
+  }
+
   /**
    * Get the buffer age of the surface. 0 means that the back buffer
    * is invalid and needs a full swap.
index 60a0ad0d581d7012f355b454948f0780a3368b62..2c1f574f625978e82f59de5b835938ad561ae454 100644 (file)
@@ -71,6 +71,12 @@ void TestRenderSurface::MoveResize(Dali::PositionSize positionSize)
   mPositionSize = positionSize;
 }
 
+void TestRenderSurface::Resize(Dali::Uint16Pair size)
+{
+  mPositionSize.width  = size.GetWidth();
+  mPositionSize.height = size.GetHeight();
+}
+
 void TestRenderSurface::StartRender()
 {
 }
index b0f7a9424989a255386d6626744a5a7ebe96ff88..b558bc802f39fe0b0d3ca7c32cf0269a1739bb12 100644 (file)
@@ -84,6 +84,11 @@ public:
    */
   void MoveResize(Dali::PositionSize positionSize) override;
 
+  /**
+   * @copydoc Dali::Integration::RenderSurface::Resize
+   */
+  void Resize(Dali::Uint16Pair size) override;
+
   /**
    * @copydoc Dali::Integration::RenderSurface::StartRender
    */
index e5ffe8f9a5323d3eabb3d6e468b60c8dfba31e7b..752960697c1a43dda652353ac983bc5720f9bb47 100644 (file)
@@ -151,10 +151,16 @@ public:
 
   /**
    * @brief Resizes the underlying surface.
-   * @param[in] The dimensions of the new position
+   * @param[in] positionSize The dimensions of the new position
    */
   virtual void MoveResize(Dali::PositionSize positionSize) = 0;
 
+  /**
+   * @brief Sets the size of the surface.
+   * @param[in] size The new size of the surface
+   */
+  virtual void Resize(Uint16Pair size) = 0;
+
   /**
    * @brief Called when Render thread has started
    */
index dfb5f8b71ba0ebf5fda76b13fb5302ef4d1403cf..fc1f7df4503994b37228ad21f65bdbc199be2d21 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
 #include <dali/graphics-api/graphics-controller.h>
 #include <dali/integration-api/core-enumerations.h>
+#include <dali/public-api/math/uint-16-pair.h>
+#include <limits>
+
+// INTERNAL INCLUDES
 #include <dali/internal/system/common/environment-options.h>
 #include <dali/internal/window-system/common/display-connection.h>
 #include <dali/internal/window-system/common/window-base.h>
-#include <limits>
 
 namespace Dali
 {
@@ -205,8 +208,13 @@ public:
    *
    * @param[in] surface The surface whose context to be switched to.
    */
-  virtual void ActivateSurfaceContext(Dali::Integration::RenderSurfaceInterface* surface) = 0;
+  virtual void ActivateSurfaceContext(Integration::RenderSurfaceInterface* surface) = 0;
 
+  /**
+   * Makes the context for the given surface ID the current context.
+   *
+   * @param surfaceId The ID of the surface whose context we want to make current.
+   */
   virtual void MakeContextCurrent(Graphics::SurfaceId surfaceId) = 0;
 
   /**
@@ -236,6 +244,14 @@ public:
    */
   virtual void Resume() = 0;
 
+  /**
+   * Sets the size of the surface.
+   *
+   * @param[in] surface The surface whose context to resize
+   * @param[in] size The new size of the surface
+   */
+  virtual void Resize(Integration::RenderSurfaceInterface* surface, Uint16Pair size) = 0;
+
   /**
    * Get the buffer age of the surface. 0 means that the back buffer
    * is invalid and needs a full swap.
index 6b0e9d265b7b2c7a0db2c8d79208bb5beb83b390..eb6ab8571a4ace1bbd7bac1d9cce309f27a8ec73 100644 (file)
@@ -122,6 +122,14 @@ void EglGraphics::Resume()
   }
 }
 
+void EglGraphics::Resize(Integration::RenderSurfaceInterface* surface, Uint16Pair size)
+{
+  if(surface)
+  {
+    surface->Resize(size);
+  }
+}
+
 int EglGraphics::GetBufferAge(Graphics::SurfaceId surfaceId)
 {
   auto search = mSurfaceMap.find(surfaceId);
index 09ab88e89f6d9bd7a303b2cd86e79fb70df5ee80..b66595acb3132b32a010d3ff83bd3981ad6566a9 100644 (file)
@@ -144,6 +144,11 @@ public:
    */
   void Resume() override;
 
+  /**
+   * @copydoc Graphics::GraphicsInterface::Resize()
+   */
+  void Resize(Integration::RenderSurfaceInterface* surface, Uint16Pair positionSize) override;
+
   /**
    * @copydoc Graphics::GraphicsInterface::GetBufferAge()
    */
index 8cdef2a73312d40280dcf7e427a43de9e0f2d77b..c8b6f3ede3053f78238c8940309e3ccee61f1dfb 100644 (file)
@@ -143,6 +143,11 @@ void VulkanGraphics::Resume()
   mGraphicsController.Resume();
 }
 
+void VulkanGraphics::Resize(Integration::RenderSurfaceInterface* surface, Uint16Pair size)
+{
+  // TODO: Need to consider how to resize the surface for vulkan
+}
+
 int VulkanGraphics::GetBufferAge(Graphics::SurfaceId surfaceId)
 {
   return 0;
index e412d8b03266532eaaf7d34d06f82f5df0e38426..1f4a64dfbf7a1eff0bf52baa867421603c1cd55e 100644 (file)
@@ -107,6 +107,11 @@ public:
    */
   void Resume() override;
 
+  /**
+   * @copydoc Graphics::GraphicsInterface::Resize()
+   */
+  void Resize(Integration::RenderSurfaceInterface* surface, Uint16Pair positionSize) override;
+
   /**
    * @copydoc Graphics::GraphicsInterface::GetBufferAge()
    */
index c5185df36f3b2f35c7c285428e97ae84882b5590..c6393fa361a61f0e52f9b6a808134c4fe8684a67 100644 (file)
@@ -428,6 +428,20 @@ void WindowRenderSurface::MoveResize(Dali::PositionSize positionSize)
   mWindowBase->MoveResize(positionSize);
 }
 
+void WindowRenderSurface::Resize(Uint16Pair size)
+{
+  Dali::PositionSize positionSize;
+
+  // Some native resize API (e.g. wl_egl_window_resize) have the input parameters of x, y, width and height.
+  // So, position data should be set as well.
+  positionSize.x      = mPositionSize.x;
+  positionSize.y      = mPositionSize.y;
+  positionSize.width  = size.GetWidth();
+  positionSize.height = size.GetHeight();
+
+  mWindowBase->ResizeWindow(positionSize);
+}
+
 void WindowRenderSurface::StartRender()
 {
 }
@@ -551,24 +565,20 @@ bool WindowRenderSurface::PreRender(bool resizingSurface, const std::vector<Rect
     }
 
     // Resize case
-    Dali::PositionSize positionSize;
+    Uint16Pair size;
 
-    // Some native resize API(wl_egl_window_resize) has the input parameters of x, y, width and height.
-    // So, position data should be set.
-    positionSize.x = mPositionSize.x;
-    positionSize.y = mPositionSize.y;
     if(totalAngle == 0 || totalAngle == 180)
     {
-      positionSize.width  = mPositionSize.width;
-      positionSize.height = mPositionSize.height;
+      size.SetWidth(mPositionSize.width);
+      size.SetHeight(mPositionSize.height);
     }
     else
     {
-      positionSize.width  = mPositionSize.height;
-      positionSize.height = mPositionSize.width;
+      size.SetWidth(mPositionSize.height);
+      size.SetHeight(mPositionSize.width);
     }
 
-    mWindowBase->ResizeWindow(positionSize);
+    mGraphics->Resize(this, size);
 
     SetFullSwapNextFrame();
   }
index 427df1ba396ba61bfc3a9dd8e0448956dfa561a2..e39ba17be381d329dafb8d0979146d3a5f1788cc 100644 (file)
@@ -221,6 +221,11 @@ public: // from Dali::Integration::RenderSurfaceInterface
    */
   void MoveResize(Dali::PositionSize positionSize) override;
 
+  /**
+   * @copydoc Dali::Integration::RenderSurfaceInterface::Resize()
+   */
+  void Resize(Uint16Pair size) override;
+
   /**
    * @copydoc Dali::Integration::RenderSurfaceInterface::StartRender()
    */
index c0615ea993b87704b5fbf52e0a96b3b64f699806..e69e960af4fcc791c6199e7b2efb74fb9db5a38b 100644 (file)
@@ -299,6 +299,11 @@ void NativeRenderSurfaceEcoreWl::MoveResize(Dali::PositionSize positionSize)
   mSurfaceSize.SetHeight(static_cast<uint16_t>(positionSize.height));
 }
 
+void NativeRenderSurfaceEcoreWl::Resize(Dali::Uint16Pair size)
+{
+  MoveResize(PositionSize(0, 0, size.GetWidth(), size.GetHeight()));
+}
+
 void NativeRenderSurfaceEcoreWl::StartRender()
 {
 }
index f4baa69b42b73dc8d45ab8d3d4d58110019d444d..93d6f64f001d1c535660c94959324d7fe2d86064 100644 (file)
@@ -122,6 +122,11 @@ public: // from Dali::Integration::RenderSurfaceInterface
    */
   void MoveResize(Dali::PositionSize positionSize) override;
 
+  /**
+   * @copydoc Dali::Integration::RenderSurfaceInterface::Resize()
+   */
+  void Resize(Uint16Pair size) override;
+
   /**
    * @copydoc Dali::Integration::RenderSurfaceInterface::StartRender()
    */
@@ -189,15 +194,15 @@ private:
   void DestroyContext();
 
 private: // Data
-  SurfaceSize                           mSurfaceSize;
-  TriggerEventInterface*                mRenderNotification;
-  Graphics::GraphicsInterface*          mGraphics; ///< The graphics interface
-  EglInterface*                         mEGL;
-  EGLSurface                            mEGLSurface;
-  EGLContext                            mEGLContext;
-  ColorDepth                            mColorDepth;
-  tbm_format                            mTbmFormat;
-  bool                                  mOwnSurface;
+  SurfaceSize                  mSurfaceSize;
+  TriggerEventInterface*       mRenderNotification;
+  Graphics::GraphicsInterface* mGraphics; ///< The graphics interface
+  EglInterface*                mEGL;
+  EGLSurface                   mEGLSurface;
+  EGLContext                   mEGLContext;
+  ColorDepth                   mColorDepth;
+  tbm_format                   mTbmFormat;
+  bool                         mOwnSurface;
 
   tbm_surface_queue_h                  mTbmQueue;
   ThreadSynchronizationInterface*      mThreadSynchronization; ///< A pointer to the thread-synchronization
index b010a8a5c1304af6f41ff2c95d828686045dad53..769cf8fefe85077144863951c65b7e44567c23f6 100644 (file)
@@ -112,7 +112,14 @@ public: // from Dali::Integration::RenderSurfaceInterface
   /**
    * @copydoc Dali::Integration::RenderSurfaceInterface::MoveResize()
    */
-  virtual void MoveResize(Dali::PositionSize positionSize) override
+  void MoveResize(Dali::PositionSize positionSize) override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Integration::RenderSurfaceInterface::Resize()
+   */
+  void Resize(Dali::Uint16Pair size) override
   {
   }
 
index f86eb75b9fd306fd2c57b6e4a70e4532b83f62e2..dc365105cef3c0970c6240c2e60862fbbdb2e7be 100644 (file)
@@ -109,7 +109,14 @@ public: // from Dali::Integration::RenderSurfaceInterface
   /**
    * @copydoc Dali::Integration::RenderSurfaceInterface::MoveResize()
    */
-  virtual void MoveResize(Dali::PositionSize positionSize) override
+  void MoveResize(Dali::PositionSize positionSize) override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Integration::RenderSurfaceInterface::Resize()
+   */
+  void Resize(Dali::Uint16Pair size) override
   {
   }