Sync native image test harness 63/293463/3
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 30 May 2023 01:38:30 +0000 (10:38 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 13 Jun 2023 00:57:35 +0000 (00:57 +0000)
Change-Id: I45deaaa3ca96468ae08488fc54aea469134564fa

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image.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;