Minor test harness updates 70/313170/6
authorDavid Steele <david.steele@samsung.com>
Wed, 19 Jun 2024 09:07:58 +0000 (10:07 +0100)
committerDavid Steele <david.steele@samsung.com>
Mon, 8 Jul 2024 10:08:21 +0000 (11:08 +0100)
Adding test-render-surface to dali-core

Change-Id: Iad1ace557fd4bab95a5e5cae5cf8281a9f4d2c64

automated-tests/src/dali-internal/CMakeLists.txt
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
automated-tests/src/dali/dali-test-suite-utils/test-render-surface.cpp [new file with mode: 0644]
automated-tests/src/dali/dali-test-suite-utils/test-render-surface.h [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-Scene.cpp
build/tizen/CMakeLists.txt
dali/graphics-api/graphics-render-target-create-info.h

index 8247542..f306035 100644 (file)
@@ -58,6 +58,7 @@ LIST(APPEND TC_SOURCES
         ../dali/dali-test-suite-utils/test-native-image.cpp
         ../dali/dali-test-suite-utils/test-platform-abstraction.cpp
         ../dali/dali-test-suite-utils/test-render-controller.cpp
+        ../dali/dali-test-suite-utils/test-render-surface.cpp
         ../dali/dali-test-suite-utils/test-trace-call-stack.cpp
         ../dali/dali-test-suite-utils/test-addon-manager.cpp
 )
index c115058..5687677 100644 (file)
@@ -133,6 +133,7 @@ LIST(APPEND TC_SOURCES
         dali-test-suite-utils/test-native-image.cpp
         dali-test-suite-utils/test-platform-abstraction.cpp
         dali-test-suite-utils/test-render-controller.cpp
+        dali-test-suite-utils/test-render-surface.cpp
         dali-test-suite-utils/test-trace-call-stack.cpp
         dali-test-suite-utils/test-addon-manager.cpp
 )
index 97394d5..145a14a 100644 (file)
@@ -83,9 +83,10 @@ void TestApplication::CreateScene()
   mScene.SetDpi(Vector2(static_cast<float>(mDpi.x), static_cast<float>(mDpi.y)));
 
   // Create render target for the scene
+  mRenderSurface = new TestRenderSurface(Dali::PositionSize(0, 0, mSurfaceWidth, mSurfaceHeight));
   Graphics::RenderTargetCreateInfo rtInfo{};
   rtInfo.SetExtent({mSurfaceWidth, mSurfaceHeight});
-  rtInfo.SetSurface(reinterpret_cast<Integration::RenderSurface*>(this));
+  rtInfo.SetSurface(mRenderSurface);
   mScene.SetSurfaceRenderTarget(rtInfo);
 
   mScenes.push_back(mScene);
index 555822d..6876dc8 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "test-graphics-controller.h"
 #include "test-render-controller.h"
+#include "test-render-surface.h"
 
 namespace Dali
 {
@@ -102,6 +103,7 @@ protected:
   TestPlatformAbstraction mPlatformAbstraction;
   TestRenderController    mRenderController;
   TestGraphicsController  mGraphicsController;
+  TestRenderSurface*      mRenderSurface;
 
   Integration::UpdateStatus mStatus;
   Integration::RenderStatus mRenderStatus;
diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-render-surface.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-render-surface.cpp
new file mode 100644 (file)
index 0000000..2f8865b
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2024 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "test-render-surface.h"
+
+namespace Dali
+{
+namespace Integration
+{
+RenderSurfaceInterface::RenderSurfaceInterface()  = default;
+RenderSurfaceInterface::~RenderSurfaceInterface() = default;
+} // namespace Integration
+
+TestRenderSurface::TestRenderSurface(Dali::PositionSize positionSize)
+: mPositionSize(positionSize),
+  mBackgroundColor()
+{
+}
+
+Dali::PositionSize TestRenderSurface::GetPositionSize() const
+{
+  return mPositionSize;
+};
+
+void TestRenderSurface::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
+{
+  dpiHorizontal = dpiVertical = 96;
+};
+
+int TestRenderSurface::GetSurfaceOrientation() const
+{
+  return 0;
+}
+
+int TestRenderSurface::GetScreenOrientation() const
+{
+  return 0;
+}
+
+void TestRenderSurface::InitializeGraphics()
+{
+}
+
+void TestRenderSurface::CreateSurface()
+{
+}
+
+void TestRenderSurface::DestroySurface()
+{
+}
+
+bool TestRenderSurface::ReplaceGraphicsSurface()
+{
+  return false;
+}
+
+void TestRenderSurface::MoveResize(Dali::PositionSize positionSize)
+{
+  mPositionSize = positionSize;
+}
+
+void TestRenderSurface::StartRender()
+{
+}
+
+bool TestRenderSurface::PreRender(bool resizingSurface, const std::vector<Rect<int>>& damageRects, Rect<int>& clippingRect)
+{
+  return true;
+}
+
+void TestRenderSurface::PostRender()
+{
+}
+
+void TestRenderSurface::StopRender()
+{
+}
+
+void TestRenderSurface::ReleaseLock()
+{
+}
+
+void TestRenderSurface::SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization)
+{
+}
+
+Dali::Integration::RenderSurfaceInterface::Type TestRenderSurface::GetSurfaceType()
+{
+  return WINDOW_RENDER_SURFACE;
+}
+
+void TestRenderSurface::MakeContextCurrent()
+{
+}
+
+Integration::DepthBufferAvailable TestRenderSurface::GetDepthBufferRequired()
+{
+  return Integration::DepthBufferAvailable::TRUE;
+}
+
+Integration::StencilBufferAvailable TestRenderSurface::GetStencilBufferRequired()
+{
+  return Integration::StencilBufferAvailable::TRUE;
+}
+
+} // namespace Dali
diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-render-surface.h b/automated-tests/src/dali/dali-test-suite-utils/test-render-surface.h
new file mode 100644 (file)
index 0000000..17fdaa2
--- /dev/null
@@ -0,0 +1,195 @@
+#ifndef TEST_RENDER_SURFACE_H
+#define TEST_RENDER_SURFACE_H
+
+/*
+ * Copyright (c) 2024 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/core.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/rect.h>
+#include <vector>
+
+namespace Dali
+{
+using PositionSize = Dali::Rect<int>;
+class ThreadSynchronizationInterface;
+
+namespace Integration
+{
+class RenderSurfaceInterface
+{
+public:
+  enum Type
+  {
+    WINDOW_RENDER_SURFACE,
+    PIXMAP_RENDER_SURFACE,
+    NATIVE_RENDER_SURFACE
+  };
+  RenderSurfaceInterface();
+
+  virtual Dali::PositionSize                              GetPositionSize() const                                                                             = 0;
+  virtual void                                            GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)                                      = 0;
+  virtual int                                             GetSurfaceOrientation() const                                                                       = 0;
+  virtual int                                             GetScreenOrientation() const                                                                        = 0;
+  virtual void                                            InitializeGraphics()                                                                                = 0;
+  virtual void                                            CreateSurface()                                                                                     = 0;
+  virtual void                                            DestroySurface()                                                                                    = 0;
+  virtual bool                                            ReplaceGraphicsSurface()                                                                            = 0;
+  virtual void                                            MoveResize(Dali::PositionSize positionSize)                                                         = 0;
+  virtual void                                            StartRender()                                                                                       = 0;
+  virtual bool                                            PreRender(bool resizingSurface, const std::vector<Rect<int>>& damageRects, Rect<int>& clippingRect) = 0;
+  virtual void                                            PostRender()                                                                                        = 0;
+  virtual void                                            StopRender()                                                                                        = 0;
+  virtual void                                            ReleaseLock()                                                                                       = 0;
+  virtual void                                            SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization)                     = 0;
+  virtual Dali::Integration::RenderSurfaceInterface::Type GetSurfaceType()                                                                                    = 0;
+  virtual void                                            MakeContextCurrent()                                                                                = 0;
+  virtual Integration::DepthBufferAvailable               GetDepthBufferRequired()                                                                            = 0;
+  virtual Integration::StencilBufferAvailable             GetStencilBufferRequired()                                                                          = 0;
+
+protected:
+  virtual ~RenderSurfaceInterface();
+};
+} // namespace Integration
+
+/**
+ * Concrete implementation of the RenderSurface class.
+ */
+class TestRenderSurface : public Dali::Integration::RenderSurfaceInterface
+{
+public:
+  /**
+   * @copydoc Dali::Integration::RenderSurface::RenderSurface
+   */
+  TestRenderSurface(Dali::PositionSize positionSize);
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::~RenderSurface
+   */
+  ~TestRenderSurface() override = default;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetPositionSize
+   */
+  Dali::PositionSize GetPositionSize() const override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetDpi
+   */
+  void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetSurfaceOrientation
+   */
+  int GetSurfaceOrientation() const override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetScreenOrientation
+   */
+  int GetScreenOrientation() const override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::InitializeGraphics
+   */
+  void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::CreateSurface
+   */
+  void CreateSurface() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::DestroySurface
+   */
+  void DestroySurface() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface
+   */
+  bool ReplaceGraphicsSurface() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::MoveResize
+   */
+  void MoveResize(Dali::PositionSize positionSize) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::StartRender
+   */
+  void StartRender() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::PreRender
+   */
+  bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damageRects, Rect<int>& clippingRect) override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::PostRender
+   */
+  void PostRender() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::StopRender
+   */
+  void StopRender() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::ReleaseLock
+   */
+  void ReleaseLock() override;
+
+  void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetSurfaceType
+   */
+  Dali::Integration::RenderSurfaceInterface::Type GetSurfaceType() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent
+   */
+  void MakeContextCurrent() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired
+   */
+  Integration::DepthBufferAvailable GetDepthBufferRequired() override;
+
+  /**
+   * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired
+   */
+  Integration::StencilBufferAvailable GetStencilBufferRequired() override;
+
+private:
+  /**
+   * @brief Undefined copy constructor. RenderSurface cannot be copied
+   */
+  TestRenderSurface(const TestRenderSurface& rhs);
+
+  /**
+   * @brief Undefined assignment operator. RenderSurface cannot be copied
+   */
+  TestRenderSurface& operator=(const TestRenderSurface& rhs);
+
+private:
+  Dali::PositionSize mPositionSize;
+  Vector4            mBackgroundColor; ///< The background color of the surface
+};
+
+} // namespace Dali
+
+#endif // TEST_RENDER_SURFACE_H
index 94320c5..4a95e64 100644 (file)
@@ -29,6 +29,7 @@
 #include <iostream>
 
 // Internal headers are allowed here
+#include "test-render-surface.h"
 
 namespace
 {
@@ -2414,23 +2415,24 @@ int UtcDaliSceneEnsureRenderTargetRecreated(void)
 
   graphicsCallStack.Reset();
 
-  int                              fakeSurface1;
+  auto testRenderSurface = new TestRenderSurface(PositionSize(0, 0, 480, 800));
+
   Graphics::RenderTargetCreateInfo createInfo{};
-  createInfo.SetSurface(&fakeSurface1).SetExtent(Graphics::Extent2D{480u, 800u});
+  createInfo.SetSurface(testRenderSurface).SetExtent(Graphics::Extent2D{480u, 800u});
   defaultScene.SetSurfaceRenderTarget(createInfo);
 
   application.SendNotification();
   application.Render();
 
   TraceCallStack::NamedParams query1;
-  query1["surface"] << std::hex << &fakeSurface1;
+  query1["surface"] << std::hex << testRenderSurface;
   const TraceCallStack::NamedParams* matching2 = graphicsCallStack.FindLastMatch("CreateRenderTarget", query1);
   DALI_TEST_CHECK(matching2 != nullptr);
 
   const TraceCallStack::NamedParams* matching3 = graphicsCallStack.FindLastMatch("PresentRenderTarget", empty);
   DALI_TEST_CHECK(matching3 != nullptr);
   DALI_TEST_EQUALS((*matching3)["surface"].str(), query1["surface"].str(), TEST_LOCATION);
-
+  delete testRenderSurface;
   END_TEST;
 }
 
index f58f7da..68760c3 100644 (file)
@@ -402,10 +402,11 @@ IF( ENABLE_LINK_TEST )
     ${DALI_TEST_SUITE_DIR}/test-graphics-texture.cpp
     ${DALI_TEST_SUITE_DIR}/test-platform-abstraction.cpp
     ${DALI_TEST_SUITE_DIR}/test-render-controller.cpp
+    ${DALI_TEST_SUITE_DIR}/test-render-surface.cpp
     ${DALI_TEST_SUITE_DIR}/test-trace-call-stack.cpp
   )
   ADD_EXECUTABLE( ${LINKER_TEST_NAME} ${LINKER_TEST_SOURCES} )
-  TARGET_LINK_LIBRARIES(${LINKER_TEST_NAME} ${name} )
+  TARGET_LINK_LIBRARIES(${LINKER_TEST_NAME} ${name})
   TARGET_INCLUDE_DIRECTORIES( ${LINKER_TEST_NAME} PRIVATE ${DALI_TEST_SUITE_DIR} )
 ENDIF()
 
index 6b3a131..0c4714e 100644 (file)
@@ -29,7 +29,7 @@ namespace Dali
 {
 namespace Integration
 {
-struct RenderSurface;
+struct RenderSurfaceInterface;
 }
 namespace Graphics
 {
@@ -65,7 +65,7 @@ struct RenderTargetCreateInfo
    * @param[in] value Pointer to the native surface
    * @return reference to this structure
    */
-  auto& SetSurface( Integration::RenderSurface* value )
+  auto& SetSurface(Integration::RenderSurfaceInterface* value)
   {
     surface = value;
     return *this;
@@ -79,7 +79,7 @@ struct RenderTargetCreateInfo
    * @param[in] value Pointer to the Framebuffer object
    * @return reference to this structure
    */
-  auto& SetFramebuffer( Framebuffer* value )
+  auto& SetFramebuffer(Framebuffer* value)
   {
     framebuffer = value;
     return *this;
@@ -91,7 +91,7 @@ struct RenderTargetCreateInfo
    * @param[in] value Size of render target
    * @return reference to this structure
    */
-  auto& SetExtent( Extent2D value )
+  auto& SetExtent(Extent2D value)
   {
     extent = value;
     return *this;
@@ -103,7 +103,7 @@ struct RenderTargetCreateInfo
    * @param[in] value transform flags
    * @return reference to this structure
    */
-  auto& SetPreTransform( RenderTargetTransformFlags value )
+  auto& SetPreTransform(RenderTargetTransformFlags value)
   {
     preTransform = value;
     return *this;
@@ -122,16 +122,16 @@ struct RenderTargetCreateInfo
     return *this;
   }
 
-  GraphicsStructureType         type{GraphicsStructureType::RENDER_TARGET_CREATE_INFO_STRUCT};
-  Integration::RenderSurface*   surface{nullptr};
-  Framebuffer*                  framebuffer{nullptr};
-  Extent2D                      extent{};
-  RenderTargetTransformFlags    preTransform{0u};
-  ExtensionCreateInfo*          nextExtension{nullptr};
+  GraphicsStructureType                type{GraphicsStructureType::RENDER_TARGET_CREATE_INFO_STRUCT};
+  Integration::RenderSurfaceInterface* surface{nullptr};
+  Framebuffer*                         framebuffer{nullptr};
+  Extent2D                             extent{};
+  RenderTargetTransformFlags           preTransform{0u};
+  ExtensionCreateInfo*                 nextExtension{nullptr};
 
   const AllocationCallbacks* allocationCallbacks{nullptr};
 };
 
 } // namespace Graphics
 } // namespace Dali
-#endif //DALI_GRAPHICS_RENDER_TARGET_CREATE_INFO
+#endif // DALI_GRAPHICS_RENDER_TARGET_CREATE_INFO