Support NativeImageInterface can generate url 05/300505/2
authorEunki Hong <eunkiki.hong@samsung.com>
Thu, 26 Oct 2023 08:20:54 +0000 (17:20 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Thu, 26 Oct 2023 10:10:02 +0000 (19:10 +0900)
Previously, we only support to generate url only by native image source.
But now, there was some usage to generate url from NativeImageQueue.

Unfortunatly, NativeImageQueue is devel api. So, let we just support
NativeImageInterface instead of NativeImageQueue directly.

Change-Id: I722cc599b6f3d7ddfe7d0727e5a2efcb4c4fb0fb
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-Image.cpp
dali-toolkit/public-api/image-loader/image.cpp
dali-toolkit/public-api/image-loader/image.h

index e6451bc..dd21194 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <dali-toolkit/public-api/image-loader/image-url.h>
 #include <dali-toolkit/public-api/image-loader/image.h>
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/public-api/images/pixel-data.h>
 #include <dali/public-api/rendering/frame-buffer.h>
@@ -182,6 +183,60 @@ int UtcDaliImageConvertNativeImageSourceToUrl02(void)
   END_TEST;
 }
 
+int UtcDaliImageConvertNativeImageInterfaceToUrl01(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliImageConvertNativeImageInterfaceToUrl01");
+
+  unsigned int width(64);
+  unsigned int height(64);
+  try
+  {
+    NativeImageSourceQueuePtr nativeImageQueue = NativeImageSourceQueue::New(width, height, (Dali::NativeImageSourceQueue::ColorFormat::BGR888));
+
+    DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageQueue).GetUrl().size() > 0u);
+  }
+  catch(Dali::DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT(e);
+    DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
+  }
+  catch(...)
+  {
+    tet_printf("Assertion test failed - wrong Exception\n");
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliImageConvertNativeImageInterfaceToUrl02(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliImageConvertNativeImageInterfaceToUrl02");
+
+  unsigned int width(64);
+  unsigned int height(64);
+  try
+  {
+    NativeImageSourceQueuePtr nativeImageQueue = NativeImageSourceQueue::New(width, height, (Dali::NativeImageSourceQueue::ColorFormat::BGR888));
+
+    DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageQueue, true).GetUrl().size() > 0u);
+  }
+  catch(Dali::DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT(e);
+    DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
+  }
+  catch(...)
+  {
+    tet_printf("Assertion test failed - wrong Exception\n");
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
 int UtcDaliImageConvertEncodedImageBufferToUrl(void)
 {
   ToolkitTestApplication application;
index dea398a..5481d5f 100644 (file)
@@ -55,9 +55,9 @@ Dali::Toolkit::ImageUrl GenerateUrl(const Dali::PixelData pixelData, bool preMul
   return imageUrl;
 }
 
-Dali::Toolkit::ImageUrl GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource, bool preMultiplied)
+Dali::Toolkit::ImageUrl GenerateUrl(const Dali::NativeImageInterfacePtr nativeImageInterface, bool preMultiplied)
 {
-  Texture texture = Dali::Texture::New(*nativeImageSource);
+  Texture texture = Dali::Texture::New(*nativeImageInterface);
   Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::ImageUrl::New(texture, preMultiplied);
   return imageUrl;
 }
index bdb9996..96b40f9 100644 (file)
@@ -18,8 +18,8 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
+#include <dali/public-api/images/native-image-interface.h>
 #include <dali/public-api/images/pixel-data.h>
 #include <dali/public-api/rendering/frame-buffer.h>
 
@@ -33,7 +33,7 @@ namespace Toolkit
 {
 /**
  * API to interface with the toolkit image
- * Allows developers to add FrameBuffer, PixelData and NativeImageSource to toolkit so that visuals can use them to render
+ * Allows developers to add FrameBuffer, PixelData and NativeImageInterface to toolkit so that visuals can use them to render
  */
 namespace Image
 {
@@ -72,14 +72,14 @@ DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::FrameBuffer fra
 DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::PixelData pixelData, bool preMultiplied = false);
 
 /**
- * @brief Generate a Url from native image source.
- * This Url can be used in visuals to render the native image source.
- * @note This method does not check for duplicates, If same native image source is entered multiple times, a different URL is returned each time.
- * @param[in] nativeImageSource the native image source to converted to Url
- * @param[in] preMultiplied Whether this native image source preMultiplied or not. Default as false.
- * @return the ImageUrl representing this native image source
+ * @brief Generate a Url from native image interface.
+ * This Url can be used in visuals to render the native image interface.
+ * @note This method does not check for duplicates, If same native image interface is entered multiple times, a different URL is returned each time.
+ * @param[in] nativeImageInterface the native image interface to converted to Url
+ * @param[in] preMultiplied Whether this native image interface preMultiplied or not. Default as false.
+ * @return the ImageUrl representing this native image interface
  */
-DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource, bool preMultiplied = false);
+DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::NativeImageInterfacePtr nativeImageInterface, bool preMultiplied = false);
 
 /**
  * @brief Generate a Url from encoded image buffer.