[dali_2.3.31] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Texture.cpp
index 00b3d75..655136e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * 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.
  */
 
 #include <dali-test-suite-utils.h>
-#include <dali/devel-api/images/pixel-data-devel.h>
 #include <dali/devel-api/rendering/texture-devel.h>
+#include <dali/devel-api/threading/thread.h>
+#include <dali/integration-api/pixel-data-integ.h>
+#include <dali/integration-api/texture-integ.h>
 #include <dali/public-api/dali-core.h>
 #include <test-native-image.h>
 
@@ -35,17 +37,6 @@ void texture_set_cleanup(void)
   test_return_value = TET_PASS;
 }
 
-Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height)
-{
-  Texture texture = Texture::New(type, format, width, height);
-
-  int       bufferSize = width * height * Pixel::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);
-  return texture;
-}
-
 int UtcDaliTextureNew01(void)
 {
   TestApplication application;
@@ -82,6 +73,33 @@ int UtcDaliTextureNew03(void)
   END_TEST;
 }
 
+int UtcDaliTextureNew04(void)
+{
+  TestApplication application;
+
+  Texture texture = Texture::New(TextureType::TEXTURE_2D);
+
+  DALI_TEST_CHECK(texture);
+  END_TEST;
+}
+
+int UtcDaliTextureNew05(void)
+{
+  TestApplication application;
+
+  uint32_t expectResourceId = 11u;
+
+  Texture texture = Integration::NewTextureWithResourceId(TextureType::TEXTURE_2D, expectResourceId);
+
+  DALI_TEST_CHECK(texture);
+
+  uint32_t currentResourceId = Integration::GetTextureResourceId(texture);
+
+  DALI_TEST_EQUALS(currentResourceId, expectResourceId, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliTextureCopyConstructor(void)
 {
   TestApplication application;
@@ -217,9 +235,9 @@ int UtcDaliTextureUpload01(void)
 
   //Upload part of the texture
   callStack.Reset();
-  bufferSize                  = width * height * 2;
+  bufferSize                  = width * height;
   buffer                      = reinterpret_cast<unsigned char*>(malloc(bufferSize));
-  PixelData pixelDataSubImage = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
+  PixelData pixelDataSubImage = PixelData::New(buffer, bufferSize, width / 2, height / 2, Pixel::RGBA8888, PixelData::FREE);
   texture.Upload(pixelDataSubImage, 0u, 0u, width / 2, height / 2, width / 2, height / 2);
   application.SendNotification();
   application.Render();
@@ -393,7 +411,7 @@ int UtcDaliTextureUpload03(void)
 
   bufferSize                 = widthMipmap1 * heightMipmap1 * 4;
   buffer                     = reinterpret_cast<unsigned char*>(malloc(bufferSize));
-  PixelData pixelDataMipmap1 = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
+  PixelData pixelDataMipmap1 = PixelData::New(buffer, bufferSize, widthMipmap1, heightMipmap1, Pixel::RGBA8888, PixelData::FREE);
   texture.Upload(pixelDataMipmap1, 0u, 1u, 0u, 0u, widthMipmap1, heightMipmap1);
   application.SendNotification();
   application.Render();
@@ -436,7 +454,7 @@ int UtcDaliTextureUpload04(void)
 
   bufferSize                 = widthMipmap1 * heightMipmap1 * 4;
   buffer                     = reinterpret_cast<unsigned char*>(malloc(bufferSize));
-  PixelData pixelDataMipmap1 = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
+  PixelData pixelDataMipmap1 = PixelData::New(buffer, bufferSize, widthMipmap1, heightMipmap1, Pixel::RGBA8888, PixelData::FREE);
   texture.Upload(pixelDataMipmap1, CubeMapLayer::NEGATIVE_X, 1u, 0u, 0u, widthMipmap1, heightMipmap1);
   application.SendNotification();
   application.Render();
@@ -545,9 +563,9 @@ int UtcDaliTextureUpload05(void)
 
     //Upload part of the texture
     callStack.Reset();
-    bufferSize                  = width * height * 2;
+    bufferSize                  = width * height;
     buffer                      = reinterpret_cast<unsigned char*>(malloc(bufferSize));
-    PixelData pixelDataSubImage = PixelData::New(buffer, bufferSize, width, height, COMPRESSED_PIXEL_FORMATS[index], PixelData::FREE);
+    PixelData pixelDataSubImage = PixelData::New(buffer, bufferSize, width / 2, height / 2, COMPRESSED_PIXEL_FORMATS[index], PixelData::FREE);
     texture.Upload(pixelDataSubImage, 0u, 0u, width / 2, height / 2, width / 2, height / 2);
     application.SendNotification();
     application.Render();
@@ -665,6 +683,313 @@ int UtcDaliTextureUpload07(void)
   END_TEST;
 }
 
+int UtcDaliTextureUpload08(void)
+{
+  TestApplication application;
+
+  //Create the texture without pixel information
+  tet_infoline("Creating a Texure without any size/format information");
+  Texture texture = Texture::New(TextureType::TEXTURE_2D);
+
+  application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+  application.SendNotification();
+  application.Render();
+
+  TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+  tet_infoline("TexImage2D should not be called with a null pointer to reserve storage for the texture in the gpu");
+  DALI_TEST_CHECK(!callStack.FindMethod("GenTextures"));
+  DALI_TEST_CHECK(!callStack.FindMethod("TexImage2D"));
+
+  tet_infoline("Upload data to the texture");
+  unsigned int width(64);
+  unsigned int height(64);
+  callStack.Reset();
+
+  tet_infoline("Creating a RGB pixel buffer and adding that to the texture to ensure it is handled correctly");
+  unsigned int   bufferSize(width * height * 3);
+  unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
+  PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE);
+  texture.Upload(pixelData);
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("GetWidth / GetHeight / GetPixelFormat will return uploaded value");
+  DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
+
+  tet_infoline("TexImage2D should be called to upload the data");
+  DALI_TEST_CHECK(callStack.FindMethod("GenTextures"));
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
+    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+  }
+
+  tet_infoline("Upload another data to the texture");
+  width  = 40;
+  height = 73;
+  callStack.Reset();
+
+  tet_infoline("Creating a RGB pixel buffer and adding that to the texture to ensure it is handled correctly");
+  bufferSize = width * height * 4;
+  buffer     = reinterpret_cast<unsigned char*>(malloc(bufferSize));
+  pixelData  = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
+  texture.Upload(pixelData);
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("TexImage2D should be generate new graphics, and be called to upload the data");
+  DALI_TEST_CHECK(callStack.FindMethod("GenTextures"));
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
+    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+  }
+
+  tet_infoline("GetWidth / GetHeight / GetPixelFormat will return uploaded value");
+  DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliTextureUpload09(void)
+{
+  TestApplication application;
+
+  //Create the texture
+  uint32_t width(64u);
+  uint32_t height(64u);
+  Texture  texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+
+  application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+  application.SendNotification();
+  application.Render();
+
+  TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+  //Upload data to the texture
+  callStack.Reset();
+
+  uint32_t bufferSize(width * height * 4u);
+  uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
+  buffer[0]       = 'a';
+
+  PixelData pixelData = Dali::Integration::NewPixelDataWithReleaseAfterUpload(buffer, bufferSize, width, height, 0u, Pixel::RGBA8888, PixelData::FREE);
+  DALI_TEST_CHECK(pixelData);
+
+  Dali::Integration::PixelDataBuffer pixelDataBuffer = Dali::Integration::GetPixelDataBuffer(pixelData);
+
+  DALI_TEST_EQUALS(pixelDataBuffer.bufferSize, bufferSize, TEST_LOCATION);
+  DALI_TEST_EQUALS(pixelDataBuffer.buffer[0], static_cast<uint8_t>('a'), TEST_LOCATION);
+
+  texture.Upload(pixelData);
+
+  application.SendNotification();
+  application.Render();
+
+  //TexImage2D should be called to upload the data
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
+    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+  }
+
+  // Check whether the buffer become nullptr after texture uploaded.
+  pixelDataBuffer = Dali::Integration::GetPixelDataBuffer(pixelData);
+
+  DALI_TEST_CHECK(pixelDataBuffer.buffer == nullptr);
+
+  END_TEST;
+}
+
+int UtcDaliTextureUploadSubPixelData01(void)
+{
+  TestApplication application;
+
+  //Create the texture
+  unsigned int width(64);
+  unsigned int height(64);
+  Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+
+  application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+  application.SendNotification();
+  application.Render();
+
+  TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+  //Upload data to the texture
+  callStack.Reset();
+
+  uint32_t bufferWidth   = width * 2;
+  uint32_t bufferHeight  = height * 2;
+  uint32_t bufferXOffset = width;
+  uint32_t bufferYOffset = height;
+
+  unsigned int   bufferSize(bufferWidth * bufferHeight * 4);
+  unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
+  PixelData      pixelData = PixelData::New(buffer, bufferSize, bufferWidth, bufferHeight, Pixel::RGBA8888, PixelData::FREE);
+  DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height);
+  application.SendNotification();
+  application.Render();
+
+  //TexImage2D should be called to upload the data
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
+    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+  }
+
+  //Upload part of the texture
+  callStack.Reset();
+  DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width / 2, height / 2, 0u, 0u, width / 2, height / 2, width / 2, height / 2);
+  application.SendNotification();
+  application.Render();
+
+  //TexSubImage2D should be called to upload the data
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D << ", " << 0u << ", " << width / 2 << ", " << height / 2 << ", " << width / 2 << ", " << height / 2;
+    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str()));
+  }
+
+  END_TEST;
+}
+
+int UtcDaliTextureUploadSubPixelData02(void)
+{
+  TestApplication application;
+
+  //Create the texture
+  unsigned int width(64);
+  unsigned int height(64);
+  Texture      texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
+
+  application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+  application.SendNotification();
+  application.Render();
+
+  TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+  tet_infoline("TexImage2D should be called six times with a null pointer to reserve storage for the six textures of the cube map");
+  for(unsigned int i(0); i < 6; ++i)
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_CUBE_MAP_POSITIVE_X + i << ", " << 0u << ", " << width << ", " << height;
+    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+  }
+
+  uint32_t bufferWidth   = width * 2;
+  uint32_t bufferHeight  = height * 2;
+  uint32_t bufferXOffset = width;
+  uint32_t bufferYOffset = height;
+
+  unsigned int   bufferSize(bufferWidth * bufferHeight * 4);
+  unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
+  PixelData      pixelData = PixelData::New(buffer, bufferSize, bufferWidth, bufferHeight, Pixel::RGBA8888, PixelData::FREE);
+
+  //Upload data to the POSITIVE_X face of the texture
+  {
+    callStack.Reset();
+
+    DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::POSITIVE_X, 0u, 0u, 0u, width, height);
+    application.SendNotification();
+    application.Render();
+
+    //TexImage2D should be called to upload the data to the POSITIVE_X face
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_CUBE_MAP_POSITIVE_X << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+  }
+
+  //Upload data to the NEGATIVE_X face of the texture
+  {
+    callStack.Reset();
+
+    DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::NEGATIVE_X, 0u, 0u, 0u, width, height);
+    application.SendNotification();
+    application.Render();
+
+    //TexImage2D should be called to upload the data to the NEGATIVE_X face
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+  }
+
+  //Upload data to the POSITIVE_Y face of the texture
+  {
+    callStack.Reset();
+    DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::POSITIVE_Y, 0u, 0u, 0u, width, height);
+    application.SendNotification();
+    application.Render();
+
+    //TexImage2D should be called to upload the data to the POSITIVE_Y face
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_CUBE_MAP_POSITIVE_Y << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+  }
+
+  //Upload data to the NEGATIVE_Y face of the texture
+  {
+    callStack.Reset();
+    DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::NEGATIVE_Y, 0u, 0u, 0u, width, height);
+    application.SendNotification();
+    application.Render();
+
+    //TexImage2D should be called to upload the data to the NEGATIVE_Y face
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Y << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+  }
+
+  //Upload data to the POSITIVE_Z face of the texture
+  {
+    callStack.Reset();
+    DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::POSITIVE_Z, 0u, 0u, 0u, width, height);
+    application.SendNotification();
+    application.Render();
+
+    //TexImage2D should be called to upload the data to the POSITIVE_Z face
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_CUBE_MAP_POSITIVE_Z << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+  }
+
+  //Upload data to the NEGATIVE_Z face of the texture
+  {
+    callStack.Reset();
+    DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::NEGATIVE_Z, 0u, 0u, 0u, width, height);
+    application.SendNotification();
+    application.Render();
+
+    //TexImage2D should be called to upload the data to the NEGATIVE_Z face
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Z << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+  }
+
+  END_TEST;
+}
+
 int UtcDaliTextureUploadPixelFormats(void)
 {
   TestApplication application;
@@ -692,11 +1017,16 @@ int UtcDaliTextureUploadPixelFormats(void)
       Pixel::BGRA8888,
       Pixel::DEPTH_UNSIGNED_INT,
       Pixel::DEPTH_FLOAT,
-      Pixel::DEPTH_STENCIL};
+      Pixel::DEPTH_STENCIL,
+      Pixel::RGB16F,
+      Pixel::RGB32F,
+      Pixel::R11G11B10F,
+      Pixel::CHROMINANCE_U,
+      Pixel::CHROMINANCE_V};
 
   for(auto format : formats)
   {
-    tet_infoline("Creating a Texure with an alpha channel");
+    tet_infoline("Creating a Texure with a new or recent format");
     Texture texture = CreateTexture(TextureType::TEXTURE_2D, format, width, height);
 
     application.SendNotification();
@@ -768,7 +1098,6 @@ int UtcDaliTextureUploadSmallerThanSize(void)
 
 int UtcDaliTextureGenerateMipmaps(void)
 {
-#ifdef OLD_GRAPHICS_TEST
   TestApplication application;
   unsigned int    width(64);
   unsigned int    height(64);
@@ -794,9 +1123,26 @@ int UtcDaliTextureGenerateMipmaps(void)
     out << GL_TEXTURE_CUBE_MAP;
     DALI_TEST_CHECK(callStack.FindMethodAndParams("GenerateMipmap", out.str().c_str()));
   }
-#else
-  DALI_TEST_CHECK(1);
-#endif
+
+  END_TEST;
+}
+
+int UtcDaliTextureGenerateMipmapsCompressedFormat(void)
+{
+  TestApplication application;
+  unsigned int    width(64);
+  unsigned int    height(64);
+
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::COMPRESSED_RGBA8_ETC2_EAC, width, height);
+  texture.GenerateMipmaps();
+
+  application.GetGlAbstraction().EnableTextureCallTrace(true);
+  TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+  application.SendNotification();
+  application.Render();
+
+  // Check generate mipmap didn't called when we use compressed pixel format.
+  DALI_TEST_CHECK(!callStack.FindMethod("GenerateMipmap"));
 
   END_TEST;
 }
@@ -824,6 +1170,68 @@ int UtcDaliTextureGetHeight(void)
   END_TEST;
 }
 
+int UtcDaliTextureGetTextureType(void)
+{
+  TestApplication application;
+  unsigned int    width(64);
+  unsigned int    height(64);
+
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  DALI_TEST_EQUALS(Integration::GetTextureType(texture), TextureType::TEXTURE_2D, TEST_LOCATION);
+
+  texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
+  DALI_TEST_EQUALS(Integration::GetTextureType(texture), TextureType::TEXTURE_CUBE, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliTextureSetSize(void)
+{
+  TestApplication application;
+  unsigned int    width(64);
+  unsigned int    height(64);
+
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
+
+  width += 11u;
+  height += 22u;
+
+  Integration::SetTextureSize(texture, ImageDimensions(width, height));
+  DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
+int UtcDaliTextureSetPixelFormat(void)
+{
+  TestApplication application;
+  unsigned int    width(64);
+  unsigned int    height(64);
+
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
+
+  Integration::SetTexturePixelFormat(texture, Pixel::BGRA5551);
+  DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::BGRA5551, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
 int UtcDaliTextureContextLoss(void)
 {
   tet_infoline("UtcDaliTextureContextLoss\n");
@@ -1059,8 +1467,11 @@ int UtcDaliTextureApplyFragShaderP1(void)
   std::string fragShader = baseFragShader;
   bool        applied    = DevelTexture::ApplyNativeFragmentShader(nativeTexture, fragShader);
 
+  std::string fragPrefix = "#extension GL_OES_EGL_image_external:require\n";
+
   DALI_TEST_CHECK(applied);
   DALI_TEST_CHECK(baseFragShader.compare(fragShader));
+  DALI_TEST_CHECK(fragShader.compare(fragPrefix + baseFragShader) == 0);
   DALI_TEST_CHECK(!fragShader.empty());
   END_TEST;
 }
@@ -1123,3 +1534,248 @@ int UtcDaliTextureApplyFragShaderN2(void)
   DALI_TEST_CHECK(!baseFragShader.compare(fragShader));
   END_TEST;
 }
+
+int UtcDaliTextureGetPixelFormat(void)
+{
+  TestApplication application;
+  uint32_t        width(64);
+  uint32_t        height(64);
+
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
+
+  texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, width, height);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
+
+  texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::L8, width, height);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::L8, TEST_LOCATION);
+
+  texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::CHROMINANCE_U, width, height);
+  DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int utcDaliTexturePartialUpdate01(void)
+{
+  TestApplication application(
+    TestApplication::DEFAULT_SURFACE_WIDTH,
+    TestApplication::DEFAULT_SURFACE_HEIGHT,
+    TestApplication::DEFAULT_HORIZONTAL_DPI,
+    TestApplication::DEFAULT_VERTICAL_DPI,
+    true,
+    true);
+
+  tet_infoline("Check the damaged rect with partial update and texture change");
+
+  const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+  std::vector<Rect<int32_t>> damagedRects;
+  Rect<int32_t>              clippingRect;
+
+  Geometry geometry = CreateQuadGeometry();
+  Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
+  Renderer renderer = Renderer::New(geometry, shader);
+
+  uint32_t   width(4);
+  uint32_t   height(4);
+  Texture    texture    = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  TextureSet textureSet = TextureSet::New();
+  textureSet.SetTexture(0u, texture);
+  renderer.SetTextures(textureSet);
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+
+  actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
+  actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
+  application.GetScene().Add(actor);
+
+  damagedRects.clear();
+  application.SendNotification();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+  // Aligned by 16
+  clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates
+  DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+  DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+  // Ensure the damaged rect is empty
+  DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
+
+  // Upload texture
+  uint32_t  bufferSize(width * height * 4);
+  uint8_t*  buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
+  PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
+  texture.Upload(pixelData);
+
+  damagedRects.clear();
+  application.SendNotification();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+  // Aligned by 16
+  clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates
+  DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+  DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+  // Ensure the damaged rect is empty
+  DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int utcDaliTexturePartialUpdate02(void)
+{
+  TestApplication application(
+    TestApplication::DEFAULT_SURFACE_WIDTH,
+    TestApplication::DEFAULT_SURFACE_HEIGHT,
+    TestApplication::DEFAULT_HORIZONTAL_DPI,
+    TestApplication::DEFAULT_VERTICAL_DPI,
+    true,
+    true);
+
+  tet_infoline("Check the damaged rect with partial update and texture change");
+
+  const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+  std::vector<Rect<int32_t>> damagedRects;
+  Rect<int32_t>              clippingRect;
+
+  Geometry geometry = CreateQuadGeometry();
+  Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
+  Renderer renderer = Renderer::New(geometry, shader);
+
+  uint32_t   width(4);
+  uint32_t   height(4);
+  Texture    texture1   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture    texture2   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  TextureSet textureSet = TextureSet::New();
+  textureSet.SetTexture(0u, texture1);
+  renderer.SetTextures(textureSet);
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+
+  actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
+  actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
+  application.GetScene().Add(actor);
+
+  damagedRects.clear();
+  application.SendNotification();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+  // Aligned by 16
+  clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
+  DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+  DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+  // Ensure the damaged rect is empty
+  DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
+
+  // Set another texture
+  textureSet.SetTexture(0u, texture2);
+
+  damagedRects.clear();
+  application.SendNotification();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+  // Aligned by 16
+  clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
+  DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+  DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+  // Ensure the damaged rect is empty
+  DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliTextureDestructWorkerThreadN(void)
+{
+  TestApplication application;
+  tet_infoline("UtcDaliTextureDestructWorkerThreadN Test, for line coverage");
+
+  try
+  {
+    class TestThread : public Thread
+    {
+    public:
+      virtual void Run()
+      {
+        tet_printf("Run TestThread\n");
+        // Upload at worker thread
+        uint8_t*        rawBuffer = new uint8_t[4];
+        Dali::PixelData pixelData = Dali::PixelData::New(rawBuffer, 4, 1, 1, Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY);
+
+        // Use try-catch to avoid memory leak false alarm
+        try
+        {
+          // Upload, GenerateMipmaps, and Destruct at worker thread.
+          mTexture.Upload(pixelData);
+          mTexture.GenerateMipmaps();
+          mTexture.Reset();
+        }
+        catch(...)
+        {
+        }
+      }
+
+      Dali::Texture mTexture;
+    };
+    TestThread thread;
+
+    Dali::Texture texture = Dali::Texture::New(Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100);
+    thread.mTexture       = std::move(texture);
+    texture.Reset();
+
+    thread.Start();
+
+    thread.Join();
+  }
+  catch(...)
+  {
+  }
+
+  // Always success
+  DALI_TEST_CHECK(true);
+
+  END_TEST;
+}