Support updated area of native image 61/293461/8
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 30 May 2023 01:15:19 +0000 (10:15 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 13 Jun 2023 02:06:28 +0000 (11:06 +0900)
Change-Id: I6b29ea3a8bc8474a991a7f7a5977907827999403

35 files changed:
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-texture.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-texture.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-native-image.h
dali/devel-api/adaptor-framework/native-image-source-devel.cpp
dali/devel-api/adaptor-framework/native-image-source-devel.h
dali/devel-api/adaptor-framework/native-image-source-queue.cpp
dali/devel-api/adaptor-framework/native-image-source-queue.h
dali/internal/graphics/gles-impl/gles-graphics-texture.cpp
dali/internal/imaging/android/native-image-source-impl-android.cpp
dali/internal/imaging/android/native-image-source-impl-android.h
dali/internal/imaging/android/native-image-source-queue-impl-android.cpp
dali/internal/imaging/android/native-image-source-queue-impl-android.h
dali/internal/imaging/common/native-bitmap-buffer-impl.cpp
dali/internal/imaging/common/native-bitmap-buffer-impl.h
dali/internal/imaging/common/native-image-source-impl.h
dali/internal/imaging/common/native-image-source-queue-impl.h
dali/internal/imaging/macos/native-image-source-impl-mac.cpp
dali/internal/imaging/macos/native-image-source-impl-mac.h
dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-impl-tizen.h
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h
dali/internal/imaging/ubuntu-x11/native-image-source-queue-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-queue-impl-x.h
dali/internal/imaging/windows/native-image-source-impl-win.cpp
dali/internal/imaging/windows/native-image-source-impl-win.h
dali/internal/imaging/x11/native-image-source-impl-x.cpp
dali/internal/imaging/x11/native-image-source-impl-x.h
dali/internal/imaging/x11/native-image-source-queue-impl-x.cpp
dali/internal/imaging/x11/native-image-source-queue-impl-x.h
dali/public-api/adaptor-framework/native-image-source.cpp
dali/public-api/adaptor-framework/native-image-source.h

index 40388b3..eb1ab88 100644 (file)
@@ -124,7 +124,7 @@ Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, i
 {
   Texture texture = Texture::New(type, format, width, height);
 
-  int       bufferSize = width * height * 2;
+  int       bufferSize = width * height * GetBytesPerPixel(format);
   uint8_t*  buffer     = reinterpret_cast<uint8_t*>(malloc(bufferSize));
   PixelData pixelData  = PixelData::New(buffer, bufferSize, width, height, format, PixelData::FREE);
   texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height);
index 9e1ad3e..30a759d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -916,22 +916,6 @@ void TestGraphicsTexture::Prepare()
 {
   if(mCreateInfo.nativeImagePtr)
   {
-    /***********************************************************************************
-     * If the native image source changes, we need to re-create the texture.           *
-     * In EGL, this is done in native image implementation in PrepareTexture below.    *
-     *                                                                                 *
-     * In Vulkan impl, this was done in dali-core side. I think we should make this    *
-     * work in the graphics implementation instead.                                    *
-     ***********************************************************************************/
-    if(mCreateInfo.nativeImagePtr->SourceChanged())
-    {
-      uint32_t width  = mCreateInfo.nativeImagePtr->GetWidth();
-      uint32_t height = mCreateInfo.nativeImagePtr->GetHeight();
-      mCreateInfo.SetSize({width, height}); // Size may change
-
-      // @todo Re-initialize this texture from the new create info.
-    }
-
     // Ensure the native image is up-to-date
     mCreateInfo.nativeImagePtr->PrepareTexture();
   }
index 58f7738..782904c 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_GRAPHICS_TEXTURE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -70,7 +70,7 @@ public:
   void Bind(uint32_t textureUnit);
 
   /**
-   * Prepare ensures that the native texture is updated if necessary (SourceChanged)
+   * Prepare ensures that the native texture is updated if necessary
    */
   void Prepare();
 
index bd1bfcc..cbbef46 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_NATIVE_IMAGE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -107,20 +107,31 @@ public:
   };
   inline bool SourceChanged() const override
   {
-    return false;
+    return true;
   };
 
+  inline Rect<uint32_t> GetUpdatedArea() override
+  {
+    return mUpdatedArea;
+  }
+
   inline virtual Dali::NativeImageInterface::Extension* GetExtension()
   {
     return nullptr;
   }
 
+  inline void SetUpdatedArea(const Rect<uint32_t>& updatedArea)
+  {
+    mUpdatedArea = updatedArea;
+  }
+
 private:
   TestNativeImage(uint32_t width, uint32_t height);
   virtual ~TestNativeImage();
 
-  uint32_t mWidth;
-  uint32_t mHeight;
+  uint32_t       mWidth;
+  uint32_t       mHeight;
+  Rect<uint32_t> mUpdatedArea{};
 
 public:
   int32_t                mExtensionCreateCalls;
index 6b2ea45..96d1696 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -30,14 +30,14 @@ bool EncodeToFile(NativeImageSource& image, const std::string& filename, const u
   return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).EncodeToFile(filename, quality);\r
 }\r
 \r
-uint8_t* AcquireBuffer(NativeImageSource& image, uint16_t& width, uint16_t& height, uint16_t& stride)\r
+uint8_t* AcquireBuffer(NativeImageSource& image, uint32_t& width, uint32_t& height, uint32_t& stride)\r
 {\r
   return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).AcquireBuffer(width, height, stride);\r
 }\r
 \r
-bool ReleaseBuffer(NativeImageSource& image)\r
+bool ReleaseBuffer(NativeImageSource& image, const Rect<uint32_t>& updatedArea)\r
 {\r
-  return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).ReleaseBuffer();\r
+  return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).ReleaseBuffer(updatedArea);\r
 }\r
 \r
 void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback)\r
@@ -45,6 +45,11 @@ void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallbac
   return Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).SetResourceDestructionCallback(callback);\r
 }\r
 \r
+void EnableBackBuffer(NativeImageSource& image, bool enable)\r
+{\r
+  Dali::Internal::Adaptor::NativeImageSource::GetImplementation(image).EnableBackBuffer(enable);\r
+}\r
+\r
 } // namespace DevelNativeImageSource\r
 \r
 } // namespace Dali\r
index 3ddc317..1263696 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_NATIVE_IMAGE_SOURCE_DEVEL_H\r
 #define DALI_NATIVE_IMAGE_SOURCE_DEVEL_H\r
 /*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  */\r
 \r
 // EXTERNAL INCLUDES\r
-#include <dali/public-api/adaptor-framework/native-image-source.h>\r
-#include <dali/devel-api/adaptor-framework/event-thread-callback.h>\r
+#include <dali/public-api/math/rect.h>\r
 \r
+// INTERNAL INCLUDES\r
+#include <dali/devel-api/adaptor-framework/event-thread-callback.h>\r
+#include <dali/public-api/adaptor-framework/native-image-source.h>\r
 \r
 namespace Dali\r
 {\r
@@ -43,34 +45,46 @@ DALI_ADAPTOR_API bool EncodeToFile(NativeImageSource& image, const std::string&
  * @brief Acquire buffer and information of an internal native image.\r
  *\r
  * AcquireBuffer() and ReleaseBuffer() are a pair.\r
- * It should be call ReleaseBuffer() after AcquireBuffer().\r
+ * ReleaseBuffer() MUST be called after AcquireBuffer().\r
  * @param[in] image The instance of NativeImageSource.\r
  * @param[out] width The width of image\r
  * @param[out] height The height of image\r
  * @param[out] stride The stride of image\r
  * @return     The buffer of an internal native image\r
+ * @note This locks a mutex until ReleaseBuffer is called.\r
  */\r
-DALI_ADAPTOR_API uint8_t* AcquireBuffer(NativeImageSource& image, uint16_t& width, uint16_t& height, uint16_t& stride);\r
+DALI_ADAPTOR_API uint8_t* AcquireBuffer(NativeImageSource& image, uint32_t& width, uint32_t& height, uint32_t& stride);\r
 \r
 /**\r
  * @brief Release information of an internal native image.\r
  *\r
  * AcquireBuffer() and ReleaseBuffer() are a pair.\r
- * It should be call ReleaseBuffer() after AcquireBuffer().\r
+ * ReleaseBuffer() MUST be called after AcquireBuffer().\r
  * @param[in] image The instance of NativeImageSource.\r
- * @return     @c true If the buffer is released successfully, and @c false otherwise\r
+ * @param[in] updatedArea The updated area of the buffer.\r
+ * @return @c true If the buffer is released successfully, and @c false otherwise\r
+ * @note The empty updatedArea means that the entire area has been changed.\r
+ * @note This unlocks the mutex locked by AcquireBuffer.\r
  */\r
-DALI_ADAPTOR_API bool ReleaseBuffer(NativeImageSource& image);\r
+DALI_ADAPTOR_API bool ReleaseBuffer(NativeImageSource& image, const Rect<uint32_t>& updatedArea);\r
 \r
 /**\r
  * @brief Set the Resource Destruction Callback object\r
  *\r
- * @param image The instance of NativeImageSource.\r
- * @param callback The Resource Destruction callback\r
+ * @param[in] image The instance of NativeImageSource.\r
+ * @param[in] callback The Resource Destruction callback\r
  * @note Ownership of the callback is passed onto this class.\r
  */\r
 DALI_ADAPTOR_API void SetResourceDestructionCallback(NativeImageSource& image, EventThreadCallback* callback);\r
 \r
+/**\r
+ * @brief Enable a back buffer.\r
+ * @param[in] image The instance of NativeImageSource.\r
+ * @param[in] enable Whether a back buffer is enabled.\r
+ * @note The front buffer will be copied to the back buffer before rendering if the front buffer is updated by AcquireBuffer and ReleaseBuffer.\r
+ */\r
+DALI_ADAPTOR_API void EnableBackBuffer(NativeImageSource& image, bool enable);\r
+\r
 } // namespace DevelNativeImageSource\r
 \r
 } // namespace Dali\r
index 4bf089b..e0e7acc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -141,6 +141,11 @@ bool NativeImageSourceQueue::SourceChanged() const
   return mImpl->SourceChanged();
 }
 
+Rect<uint32_t> NativeImageSourceQueue::GetUpdatedArea()
+{
+  return mImpl->GetUpdatedArea();
+}
+
 NativeImageInterface::Extension* NativeImageSourceQueue::GetExtension()
 {
   return mImpl->GetNativeImageInterfaceExtension();
index d6995d9..4f8c5bc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -211,6 +211,11 @@ private: // native image
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetExtension() override;
index 9b997c6..9d2e77b 100644 (file)
@@ -379,14 +379,6 @@ void Texture::Prepare()
   NativeImageInterfacePtr nativeImage = mCreateInfo.nativeImagePtr;
   if(nativeImage)
   {
-    if(nativeImage->SourceChanged())
-    {
-      // Update size
-      uint32_t width  = mCreateInfo.nativeImagePtr->GetWidth();
-      uint32_t height = mCreateInfo.nativeImagePtr->GetHeight();
-      mCreateInfo.SetSize({width, height}); // Size may change
-    }
-
     nativeImage->PrepareTexture();
   }
 }
index bb25e3f..1b25af1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -357,7 +357,7 @@ void NativeImageSourceAndroid::GetPixmapDetails()
   }
 }
 
-uint8_t* NativeImageSourceAndroid::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceAndroid::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
 {
   if(mPixmap)
   {
@@ -382,7 +382,7 @@ uint8_t* NativeImageSourceAndroid::AcquireBuffer(uint16_t& width, uint16_t& heig
   return NULL;
 }
 
-bool NativeImageSourceAndroid::ReleaseBuffer()
+bool NativeImageSourceAndroid::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
 {
   if(mPixmap)
   {
@@ -401,6 +401,10 @@ void NativeImageSourceAndroid::SetResourceDestructionCallback(EventThreadCallbac
   mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
 }
 
+void NativeImageSourceAndroid::EnableBackBuffer(bool enable)
+{
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index feaaa2b..d735456 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -153,7 +153,15 @@ public:
    */
   bool SourceChanged() const override
   {
-    return false;
+    return true;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
   }
 
   /**
@@ -167,18 +175,23 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+  uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
-  bool ReleaseBuffer() override;
+  bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
    */
   void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+  /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  void EnableBackBuffer(bool enable) override;
+
 private:
   /**
    * Private constructor; @see NativeImageSource::New()
index ff0addc..5a9528f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -124,7 +124,7 @@ Any NativeImageSourceQueueAndroid::GetNativeImageHandle() const
 
 bool NativeImageSourceQueueAndroid::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 } // namespace Adaptor
index 0ed28c3..010780d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_ANDROID_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -166,6 +166,14 @@ public:
    */
   bool SourceChanged() const override;
 
+  /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
 private:
   /**
    * Private constructor; @see NativeImageSourceQueue::New()
index 0537f1b..cc7051b 100644 (file)
@@ -127,7 +127,7 @@ Any NativeBitmapBuffer::GetNativeImageHandle() const
 
 bool NativeBitmapBuffer::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 } // namespace Adaptor
index 344334f..64122cc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_NATIVE_BITMAP_BUFFER_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -127,6 +127,14 @@ public:
    */
   bool SourceChanged() const override;
 
+  /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
 private:
   NativeBitmapBuffer(const NativeBitmapBuffer&);            ///< not defined
   NativeBitmapBuffer& operator=(const NativeBitmapBuffer&); ///< not defined
index dcb0570..d990c62 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -20,9 +20,8 @@
 
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/bitmap-saver.h>
-#include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
-
+#include <dali/public-api/adaptor-framework/native-image-source.h>
 
 namespace Dali
 {
@@ -137,26 +136,36 @@ public:
   virtual bool SourceChanged() const = 0;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  virtual Rect<uint32_t> GetUpdatedArea() = 0;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   virtual NativeImageInterface::Extension* GetNativeImageInterfaceExtension() = 0;
 
   /**
-   * @brief Dali::DevelNativeImageSource::AcquireBuffer()
+   * @copydoc Dali::DevelNativeImageSource::AcquireBuffer()
    */
-  virtual uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) = 0;
+  virtual uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) = 0;
 
   /**
-   * @brief Dali::DevelNativeImageSource::ReleaseBuffer()
+   * @copydoc Dali::DevelNativeImageSource::ReleaseBuffer()
    */
-  virtual bool ReleaseBuffer() = 0;
+  virtual bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) = 0;
 
   /**
-   * @brief Dali::DevelNativeImageSource::SetResourceDestructionCallback()
+   * @copydoc Dali::DevelNativeImageSource::SetResourceDestructionCallback()
    */
   virtual void SetResourceDestructionCallback(EventThreadCallback* callback) = 0;
 
   /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  virtual void EnableBackBuffer(bool enable) = 0;
+
+  /**
    * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
    */
   inline bool EncodeToFile(const std::string& filename) const
index 19ea0c6..04c8604 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -139,6 +139,11 @@ public:
   virtual bool SourceChanged() const = 0;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  virtual Rect<uint32_t> GetUpdatedArea() = 0;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   virtual NativeImageInterface::Extension* GetNativeImageInterfaceExtension() = 0;
index cc99b1b..f6ad654 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -193,15 +193,15 @@ bool NativeImageSourceCocoa::RequiresBlending() const
 
 bool NativeImageSourceCocoa::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
-uint8_t* NativeImageSourceCocoa::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceCocoa::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
 {
   return nullptr;
 }
 
-bool NativeImageSourceCocoa::ReleaseBuffer()
+bool NativeImageSourceCocoa::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
 {
   return false;
 }
@@ -211,4 +211,8 @@ void NativeImageSourceCocoa::SetResourceDestructionCallback(EventThreadCallback*
   mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
 }
 
+void NativeImageSourceCocoa::EnableBackBuffer(bool enable)
+{
+}
+
 } // namespace Dali::Internal::Adaptor
index 5bb1db5..100fa74 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -139,6 +139,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, static_cast<uint32_t>(CGImageGetWidth(mImage.get())), static_cast<uint32_t>(CGImageGetHeight(mImage.get()))};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
@@ -149,18 +157,23 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+  uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
-  bool ReleaseBuffer() override;
+  bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
    */
   void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+  /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  void EnableBackBuffer(bool enable) override;
+
 private:
   /**
    * Private constructor; @see NativeImageSource::New()
@@ -176,8 +189,8 @@ private:
     Any                                 nativeImageSource);
 
 private:
-  CFRef<CGImageRef> mImage;
-  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;  ///< The Resource Destruction Callback
+  CFRef<CGImageRef>                    mImage;
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
 };
 
 } // namespace Dali::Internal::Adaptor
index 153848f..e5936b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -76,19 +76,20 @@ NativeImageSourceTizen* NativeImageSourceTizen::New(uint32_t width, uint32_t hei
 NativeImageSourceTizen::NativeImageSourceTizen(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
 : mWidth(width),
   mHeight(height),
-  mOwnTbmSurface(false),
   mTbmSurface(NULL),
+  mTbmBackSurface(NULL),
   mTbmFormat(0),
-  mBlendingRequired(false),
   mColorDepth(depth),
+  mMutex(),
   mEglImageKHR(NULL),
   mEglGraphics(NULL),
   mEglImageExtensions(NULL),
+  mResourceDestructionCallback(),
+  mOwnTbmSurface(false),
+  mBlendingRequired(false),
   mSetSource(false),
-  mMutex(),
   mIsBufferAcquired(false),
-  mResourceDestructionCallback()
-
+  mBackBufferEnabled(false)
 {
   DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
 
@@ -189,7 +190,8 @@ void NativeImageSourceTizen::DestroySurface()
   {
     if(mIsBufferAcquired)
     {
-      ReleaseBuffer();
+      Rect<uint32_t> emptyRect{};
+      ReleaseBuffer(emptyRect);
     }
     if(mOwnTbmSurface)
     {
@@ -202,6 +204,9 @@ void NativeImageSourceTizen::DestroySurface()
     {
       tbm_surface_internal_unref(mTbmSurface);
     }
+    mTbmSurface = NULL;
+
+    DestroyBackBuffer();
   }
 }
 
@@ -217,7 +222,7 @@ Any NativeImageSourceTizen::GetNativeImageSource() const
 
 bool NativeImageSourceTizen::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
+  std::scoped_lock lock(mMutex);
   if(mTbmSurface != NULL)
   {
     tbm_surface_info_s surface_info;
@@ -332,7 +337,7 @@ bool NativeImageSourceTizen::GetPixels(std::vector<unsigned char>& pixbuf, unsig
 
 void NativeImageSourceTizen::SetSource(Any source)
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
+  std::scoped_lock lock(mMutex);
 
   DestroySurface();
 
@@ -346,6 +351,12 @@ void NativeImageSourceTizen::SetSource(Any source)
     mBlendingRequired = CheckBlending(tbm_surface_get_format(mTbmSurface));
     mWidth            = tbm_surface_get_width(mTbmSurface);
     mHeight           = tbm_surface_get_height(mTbmSurface);
+
+    if(mBackBufferEnabled)
+    {
+      DestroyBackBuffer();
+      CreateBackBuffer();
+    }
   }
 }
 
@@ -410,9 +421,10 @@ bool NativeImageSourceTizen::CreateResource()
 
   // casting from an unsigned int to a void *, which should then be cast back
   // to an unsigned int in the driver.
-  EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mTbmSurface);
+  EGLClientBuffer eglBuffer = mTbmBackSurface ? reinterpret_cast<EGLClientBuffer>(mTbmBackSurface) : reinterpret_cast<EGLClientBuffer>(mTbmSurface);
   if(!eglBuffer || !tbm_surface_internal_is_valid(mTbmSurface))
   {
+    DALI_LOG_ERROR("Invalid surface\n");
     return false;
   }
 
@@ -420,13 +432,17 @@ bool NativeImageSourceTizen::CreateResource()
   DALI_ASSERT_DEBUG(mEglImageExtensions);
 
   mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
+  if(!mEglImageKHR)
+  {
+    DALI_LOG_ERROR("Fail to CreateImageKHR\n");
+  }
 
   return mEglImageKHR != NULL;
 }
 
 void NativeImageSourceTizen::DestroyResource()
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
+  std::scoped_lock lock(mMutex);
   if(mEglImageKHR)
   {
     mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
@@ -449,7 +465,7 @@ uint32_t NativeImageSourceTizen::TargetTexture()
 
 void NativeImageSourceTizen::PrepareTexture()
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
+  std::scoped_lock lock(mMutex);
   if(mSetSource)
   {
     // Destroy previous eglImage because use for new one.
@@ -488,7 +504,60 @@ Any NativeImageSourceTizen::GetNativeImageHandle() const
 
 bool NativeImageSourceTizen::SourceChanged() const
 {
-  return false;
+  if(mTbmBackSurface)
+  {
+    return mUpdatedArea.IsEmpty() ? false : true;
+  }
+  return true;
+}
+
+Rect<uint32_t> NativeImageSourceTizen::GetUpdatedArea()
+{
+  std::scoped_lock lock(mMutex);
+  Rect<uint32_t>   updatedArea{0, 0, mWidth, mHeight};
+  if(!mUpdatedArea.IsEmpty() && mTbmSurface != NULL && mTbmBackSurface != NULL)
+  {
+    updatedArea = mUpdatedArea;
+
+    tbm_surface_info_s info;
+    if(tbm_surface_map(mTbmSurface, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &info) != TBM_SURFACE_ERROR_NONE)
+    {
+      DALI_LOG_ERROR("Fail to map tbm_surface\n");
+      return updatedArea;
+    }
+
+    tbm_surface_info_s backBufferInfo;
+    if(tbm_surface_map(mTbmBackSurface, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &backBufferInfo) != TBM_SURFACE_ERROR_NONE)
+    {
+      DALI_LOG_ERROR("Fail to map tbm_surface - backbuffer\n");
+      tbm_surface_unmap(mTbmSurface);
+      return updatedArea;
+    }
+
+    unsigned char* srcBuffer = info.planes[0].ptr;
+    unsigned char* dstBuffer = backBufferInfo.planes[0].ptr;
+
+    uint32_t stride        = info.planes[0].stride;
+    uint32_t bytesPerPixel = info.bpp >> 3;
+
+    srcBuffer += updatedArea.y * stride + updatedArea.x * bytesPerPixel;
+    dstBuffer += updatedArea.y * stride + updatedArea.x * bytesPerPixel;
+
+    // Copy to back buffer
+    for(uint32_t y = 0; y < updatedArea.height; y++)
+    {
+      memcpy(dstBuffer, srcBuffer, updatedArea.width * bytesPerPixel);
+      srcBuffer += stride;
+      dstBuffer += stride;
+    }
+
+    tbm_surface_unmap(mTbmSurface);
+    tbm_surface_unmap(mTbmBackSurface);
+
+    // Reset the updated area
+    mUpdatedArea.Set(0u, 0u, 0u, 0u);
+  }
+  return updatedArea;
 }
 
 bool NativeImageSourceTizen::CheckBlending(tbm_format format)
@@ -509,9 +578,9 @@ bool NativeImageSourceTizen::CheckBlending(tbm_format format)
   return mBlendingRequired;
 }
 
-uint8_t* NativeImageSourceTizen::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceTizen::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
+  mMutex.lock(); // We don't use std::scoped_lock here
   if(mTbmSurface != NULL)
   {
     tbm_surface_info_s info;
@@ -523,6 +592,7 @@ uint8_t* NativeImageSourceTizen::AcquireBuffer(uint16_t& width, uint16_t& height
       width  = 0;
       height = 0;
 
+      mMutex.unlock();
       return NULL;
     }
     tbm_surface_internal_ref(mTbmSurface);
@@ -532,17 +602,37 @@ uint8_t* NativeImageSourceTizen::AcquireBuffer(uint16_t& width, uint16_t& height
     width  = mWidth;
     height = mHeight;
 
+    // The lock is held until ReleaseBuffer is called
     return info.planes[0].ptr;
   }
+  mMutex.unlock();
   return NULL;
 }
 
-bool NativeImageSourceTizen::ReleaseBuffer()
+bool NativeImageSourceTizen::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
-  bool                    ret = false;
+  bool ret = false;
   if(mTbmSurface != NULL)
   {
+    if(mTbmBackSurface)
+    {
+      if(updatedArea.IsEmpty())
+      {
+        mUpdatedArea.Set(0, 0, mWidth, mHeight);
+      }
+      else
+      {
+        if(mUpdatedArea.IsEmpty())
+        {
+          mUpdatedArea = updatedArea;
+        }
+        else
+        {
+          mUpdatedArea.Merge(updatedArea);
+        }
+      }
+    }
+
     ret = (tbm_surface_unmap(mTbmSurface) == TBM_SURFACE_ERROR_NONE);
     if(!ret)
     {
@@ -551,15 +641,54 @@ bool NativeImageSourceTizen::ReleaseBuffer()
     tbm_surface_internal_unref(mTbmSurface);
     mIsBufferAcquired = false;
   }
+  // Unlock the mutex locked by AcquireBuffer.
+  mMutex.unlock();
   return ret;
 }
 
 void NativeImageSourceTizen::SetResourceDestructionCallback(EventThreadCallback* callback)
 {
-  Dali::Mutex::ScopedLock lock(mMutex);
+  std::scoped_lock lock(mMutex);
   mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
 }
 
+void NativeImageSourceTizen::EnableBackBuffer(bool enable)
+{
+  if(enable != mBackBufferEnabled)
+  {
+    mBackBufferEnabled = enable;
+
+    if(mBackBufferEnabled)
+    {
+      CreateBackBuffer();
+    }
+    else
+    {
+      DestroyBackBuffer();
+    }
+  }
+}
+
+void NativeImageSourceTizen::CreateBackBuffer()
+{
+  if(!mTbmBackSurface && mTbmSurface)
+  {
+    mTbmBackSurface = tbm_surface_create(mWidth, mHeight, tbm_surface_get_format(mTbmSurface));
+  }
+}
+
+void NativeImageSourceTizen::DestroyBackBuffer()
+{
+  if(mTbmBackSurface)
+  {
+    if(tbm_surface_destroy(mTbmBackSurface) != TBM_SURFACE_ERROR_NONE)
+    {
+      DALI_LOG_ERROR("Failed to destroy tbm_surface\n");
+    }
+    mTbmBackSurface = NULL;
+  }
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 35299ba..e2d1881 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
  */
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/threading/mutex.h>
 #include <dali/public-api/common/dali-vector.h>
 #include <tbm_surface.h>
 #include <memory>
+#include <mutex>
 
 // INTERNAL INCLUDES
 #include <dali/internal/imaging/common/native-image-source-impl.h>
@@ -152,6 +152,11 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
@@ -162,18 +167,23 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+  uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
-  bool ReleaseBuffer() override;
+  bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
    */
   void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+  /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  void EnableBackBuffer(bool enable) override;
+
 private:
   /**
    * Private constructor; @see NativeImageSource::New()
@@ -195,21 +205,34 @@ private:
 
   void DestroySurface();
 
+  /**
+   * @brief Create back buffer
+   */
+  void CreateBackBuffer();
+
+  /**
+   * @brief Destroy back buffer
+   */
+  void DestroyBackBuffer();
+
 private:
-  uint32_t                             mWidth;                        ///< image width
-  uint32_t                             mHeight;                       ///< image height
-  bool                                 mOwnTbmSurface;                ///< Whether we created pixmap or not
-  tbm_surface_h                        mTbmSurface;
+  uint32_t                             mWidth;          ///< image width
+  uint32_t                             mHeight;         ///< image height
+  tbm_surface_h                        mTbmSurface;     ///< Tbm surface
+  tbm_surface_h                        mTbmBackSurface; ///< Back buffer
   tbm_format                           mTbmFormat;
-  bool                                 mBlendingRequired;             ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth  mColorDepth;                   ///< color depth of image
-  void*                                mEglImageKHR;                  ///< From EGL extension
-  EglGraphics*                         mEglGraphics;                  ///< EGL Graphics
-  EglImageExtensions*                  mEglImageExtensions;           ///< The EGL Image Extensions
-  bool                                 mSetSource;
-  mutable Dali::Mutex                  mMutex;
-  bool                                 mIsBufferAcquired;             ///< Whether AcquireBuffer is called
-  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;  ///< The Resource Destruction Callback
+  Dali::NativeImageSource::ColorDepth  mColorDepth;    ///< color depth of image
+  Rect<uint32_t>                       mUpdatedArea{}; ///< Updated area
+  mutable std::mutex                   mMutex;
+  void*                                mEglImageKHR;                 ///< From EGL extension
+  EglGraphics*                         mEglGraphics;                 ///< EGL Graphics
+  EglImageExtensions*                  mEglImageExtensions;          ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
+  bool                                 mOwnTbmSurface : 1;           ///< Whether we created pixmap or not
+  bool                                 mBlendingRequired : 1;        ///< Whether blending is required
+  bool                                 mSetSource : 1;
+  bool                                 mIsBufferAcquired : 1;  ///< Whether AcquireBuffer is called
+  bool                                 mBackBufferEnabled : 1; ///< Whether the back buffer is enabled
 };
 
 } // namespace Adaptor
index b5d926b..144b826 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -433,7 +433,7 @@ Any NativeImageSourceQueueTizen::GetNativeImageHandle() const
 
 bool NativeImageSourceQueueTizen::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 void NativeImageSourceQueueTizen::ResetEglImageList(bool releaseConsumeSurface)
index 736ab60..16dcf9f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -163,6 +163,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
index 7c4f911..49aeef5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -380,7 +380,7 @@ Any NativeImageSourceX::GetNativeImageHandle() const
 
 bool NativeImageSourceX::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 Ecore_X_Pixmap NativeImageSourceX::GetPixmapFromAny(Any pixmap) const
@@ -421,12 +421,12 @@ void NativeImageSourceX::GetPixmapDetails()
   mBlendingRequired = (depth == 32 || depth == 8);
 }
 
-uint8_t* NativeImageSourceX::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceX::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
 {
   return NULL;
 }
 
-bool NativeImageSourceX::ReleaseBuffer()
+bool NativeImageSourceX::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
 {
   return false;
 }
@@ -436,6 +436,10 @@ void NativeImageSourceX::SetResourceDestructionCallback(EventThreadCallback* cal
   mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
 }
 
+void NativeImageSourceX::EnableBackBuffer(bool enable)
+{
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 38b5dac..6890f0e 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -149,6 +149,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
@@ -159,18 +167,23 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+  uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
-  bool ReleaseBuffer() override;
+  bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
    */
   void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+  /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  void EnableBackBuffer(bool enable) override;
+
 private:
   /**
    * Private constructor; @see NativeImageSource::New()
index 5198ee3..b6c4722 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -129,7 +129,7 @@ Any NativeImageSourceQueueX::GetNativeImageHandle() const
 
 bool NativeImageSourceQueueX::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 } // namespace Adaptor
index 279b368..6fe065d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -159,6 +159,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
index c234e03..181204e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -256,15 +256,15 @@ Any NativeImageSourceWin::GetNativeImageHandle() const
 
 bool NativeImageSourceWin::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
-uint8_t* NativeImageSourceWin::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceWin::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
 {
   return NULL;
 }
 
-bool NativeImageSourceWin::ReleaseBuffer()
+bool NativeImageSourceWin::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
 {
   return false;
 }
@@ -274,6 +274,10 @@ void NativeImageSourceWin::SetResourceDestructionCallback(EventThreadCallback* c
   mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
 }
 
+void NativeImageSourceWin::EnableBackBuffer(bool enable)
+{
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index eb05a9e..d590782 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -146,6 +146,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
@@ -156,18 +164,23 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+  uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
-  bool ReleaseBuffer() override;
+  bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
    */
   void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+  /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  void EnableBackBuffer(bool enable) override;
+
 private:
   /**
    * Private constructor; @see NativeImageSource::New()
index 1422494..3a71586 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -384,7 +384,7 @@ Any NativeImageSourceX::GetNativeImageHandle() const
 
 bool NativeImageSourceX::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 ::Pixmap NativeImageSourceX::GetPixmapFromAny(Any pixmap) const
@@ -422,12 +422,12 @@ void NativeImageSourceX::GetPixmapDetails()
   }
 }
 
-uint8_t* NativeImageSourceX::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceX::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
 {
   return NULL;
 }
 
-bool NativeImageSourceX::ReleaseBuffer()
+bool NativeImageSourceX::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
 {
   return false;
 }
@@ -437,6 +437,10 @@ void NativeImageSourceX::SetResourceDestructionCallback(EventThreadCallback* cal
   mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
 }
 
+void NativeImageSourceX::EnableBackBuffer(bool enable)
+{
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index e511166..68c4126 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -148,6 +148,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
@@ -158,18 +166,23 @@ public:
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
    */
-  uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+  uint8_t* AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
    */
-  bool ReleaseBuffer() override;
+  bool ReleaseBuffer(const Rect<uint32_t>& updatedArea) override;
 
   /**
    * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
    */
   void SetResourceDestructionCallback(EventThreadCallback* callback) override;
 
+  /**
+   * @copydoc Dali::DevelNativeImageSource::EnableBackBuffer()
+   */
+  void EnableBackBuffer(bool enable) override;
+
 private:
   /**
    * Private constructor; @see NativeImageSource::New()
index d5c5da5..5dfbd1a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -119,7 +119,7 @@ Any NativeImageSourceQueueX::GetNativeImageHandle() const
 
 bool NativeImageSourceQueueX::SourceChanged() const
 {
-  return false;
+  return true;
 }
 
 } // namespace Adaptor
index 279b368..6fe065d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -159,6 +159,14 @@ public:
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override
+  {
+    return Rect<uint32_t>{0, 0, mWidth, mHeight};
+  }
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
index 727b71b..1eae664 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -125,6 +125,11 @@ bool NativeImageSource::SourceChanged() const
   return mImpl->SourceChanged();
 }
 
+Rect<uint32_t> NativeImageSource::GetUpdatedArea()
+{
+  return mImpl->GetUpdatedArea();
+}
+
 NativeImageInterface::Extension* NativeImageSource::GetExtension()
 {
   return mImpl->GetNativeImageInterfaceExtension();
index 1d038b6..2e4c752 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -213,6 +213,11 @@ private: // native image
   bool SourceChanged() const override;
 
   /**
+   * @copydoc Dali::NativeImageInterface::GetUpdatedArea()
+   */
+  Rect<uint32_t> GetUpdatedArea() override;
+
+  /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
   NativeImageInterface::Extension* GetExtension() override;