Revert "[Tizen] Appendix log for ttrace + Print keycode and timestamp"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Texture.cpp
index 95cb6c8..3b63aa5 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.
@@ -16,7 +16,6 @@
  */
 
 #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/public-api/dali-core.h>
 #include <test-native-image.h>
@@ -178,7 +177,7 @@ int UtcDaliTextureUpload01(void)
   //Create the texture
   unsigned int width(64);
   unsigned int height(64);
-  Texture      texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -187,13 +186,6 @@ int UtcDaliTextureUpload01(void)
 
   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
 
-  //TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
-  {
-    std::stringstream out;
-    out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
-    DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
-  }
-
   //Upload data to the texture
   callStack.Reset();
 
@@ -213,9 +205,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();
@@ -237,7 +229,7 @@ int UtcDaliTextureUpload02(void)
   //Create the texture
   unsigned int width(64);
   unsigned int height(64);
-  Texture      texture = Texture::New(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
+  Texture      texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -246,7 +238,7 @@ int UtcDaliTextureUpload02(void)
 
   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
 
-  //TexImage2D should be called six times with a null pointer to reserve storage for the six textures of the cube map
+  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;
@@ -363,7 +355,7 @@ int UtcDaliTextureUpload03(void)
   unsigned int widthMipmap1(32);
   unsigned int heightMipmap1(32);
 
-  Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -372,7 +364,7 @@ int UtcDaliTextureUpload03(void)
 
   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
 
-  //TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
+  tet_infoline("TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
   {
     std::stringstream out;
     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
@@ -389,7 +381,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();
@@ -419,7 +411,7 @@ int UtcDaliTextureUpload04(void)
   unsigned int widthMipmap1(32);
   unsigned int heightMipmap1(32);
 
-  Texture texture = Texture::New(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
+  Texture texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
@@ -432,7 +424,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();
@@ -506,7 +498,7 @@ int UtcDaliTextureUpload05(void)
     //Create a texture with a compressed format
     unsigned int width(64);
     unsigned int height(64);
-    Texture      texture = Texture::New(TextureType::TEXTURE_2D, COMPRESSED_PIXEL_FORMATS[index], width, height);
+    Texture      texture = CreateTexture(TextureType::TEXTURE_2D, COMPRESSED_PIXEL_FORMATS[index], width, height);
 
     application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -515,7 +507,7 @@ int UtcDaliTextureUpload05(void)
 
     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
 
-    //CompressedTexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
+    tet_infoline("CompressedTexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
     {
       std::stringstream out;
       out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
@@ -541,9 +533,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();
@@ -569,7 +561,7 @@ int UtcDaliTextureUpload06(void)
   unsigned int width(64);
   unsigned int height(64);
   tet_infoline("Creating a Texure with an alpha channel");
-  Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -623,7 +615,7 @@ int UtcDaliTextureUpload07(void)
     unsigned int width(64);
     unsigned int height(64);
     tet_infoline("Creating a floating point texture");
-    Texture texture = Texture::New(TextureType::TEXTURE_2D, FLOATING_POINT_PIXEL_FORMATS[index], width, height);
+    Texture texture = CreateTexture(TextureType::TEXTURE_2D, FLOATING_POINT_PIXEL_FORMATS[index], width, height);
 
     application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -661,6 +653,245 @@ int UtcDaliTextureUpload07(void)
   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;
+  application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+  //Create the texture
+  unsigned int width(64);
+  unsigned int height(64);
+
+  std::vector<Pixel::Format> formats =
+    {
+      Pixel::A8,
+      Pixel::L8,
+      Pixel::LA88,
+      Pixel::RGB565,
+      Pixel::BGR565,
+      Pixel::RGBA4444,
+      Pixel::BGRA4444,
+      Pixel::RGBA5551,
+      Pixel::BGRA5551,
+      Pixel::RGB888,
+      Pixel::RGB8888,
+      Pixel::BGR8888,
+      Pixel::RGBA8888,
+      Pixel::BGRA8888,
+      Pixel::DEPTH_UNSIGNED_INT,
+      Pixel::DEPTH_FLOAT,
+      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 a new or recent format");
+    Texture texture = CreateTexture(TextureType::TEXTURE_2D, format, width, height);
+
+    application.SendNotification();
+    application.Render();
+
+    TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+    tet_infoline("TexImage2D should be called twice per texture");
+    DALI_TEST_EQUALS(callStack.CountMethod("TexImage2D"), 2, TEST_LOCATION);
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
+      DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
+    }
+    callStack.Reset();
+  }
+
+  END_TEST;
+}
+
 int UtcDaliTextureUploadSmallerThanSize(void)
 {
   TestApplication application;
@@ -668,7 +899,7 @@ int UtcDaliTextureUploadSmallerThanSize(void)
   //Create the texture
   unsigned int width(64);
   unsigned int height(64);
-  Texture      texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
 
@@ -676,8 +907,11 @@ int UtcDaliTextureUploadSmallerThanSize(void)
   application.Render();
 
   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+  callStack.EnableLogging(true);
+  TraceCallStack& texParamCallStack = application.GetGlAbstraction().GetTexParameterTrace();
+  texParamCallStack.EnableLogging(true);
 
-  //TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
+  tet_infoline("TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
   {
     std::stringstream out;
     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
@@ -696,7 +930,7 @@ int UtcDaliTextureUploadSmallerThanSize(void)
   application.SendNotification();
   application.Render();
 
-  //TexImage2D should be called to upload the data
+  //TexSubImage2D should be called to upload the data
   {
     std::stringstream out;
     out << GL_TEXTURE_2D << ", " << 0u << ", " << 0u << ", " << 0u << ", " << width / 2 << ", " << height / 2;
@@ -704,7 +938,6 @@ int UtcDaliTextureUploadSmallerThanSize(void)
     DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("TexSubImage2D", params));
     DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
   }
-
   END_TEST;
 }
 
@@ -714,10 +947,10 @@ int UtcDaliTextureGenerateMipmaps(void)
   unsigned int    width(64);
   unsigned int    height(64);
 
-  Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
   texture.GenerateMipmaps();
 
-  Texture textureCubemap = Texture::New(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
+  Texture textureCubemap = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
   textureCubemap.GenerateMipmaps();
 
   application.GetGlAbstraction().EnableTextureCallTrace(true);
@@ -745,7 +978,7 @@ int UtcDaliTextureGetWidth(void)
   unsigned int    width(64);
   unsigned int    height(64);
 
-  Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
   END_TEST;
 }
@@ -756,7 +989,7 @@ int UtcDaliTextureGetHeight(void)
   unsigned int    width(64);
   unsigned int    height(64);
 
-  Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
 
   END_TEST;
@@ -770,7 +1003,7 @@ int UtcDaliTextureContextLoss(void)
   //Create the texture
   unsigned int width(64);
   unsigned int height(64);
-  Texture      texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
   DALI_TEST_CHECK(texture);
 
   application.SendNotification();
@@ -836,8 +1069,9 @@ int UtcDaliNativeImageTexture02(void)
 
     // Expect 2 attempts to create the texture - once when adding the texture
     // to the scene-graph, and again since that failed, during the Bind.
+    // The second one succeeds (TargetTexture only errors once)
     DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 2, TEST_LOCATION);
-    DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 2, TEST_LOCATION);
+    DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);
 
     UnparentAndReset(actor);
 
@@ -958,7 +1192,7 @@ int UtcDaliTextureCheckNativeN1(void)
   TestApplication application;
   unsigned int    width(64);
   unsigned int    height(64);
-  Texture         texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture         texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
 
   DALI_TEST_CHECK(texture);
   DALI_TEST_CHECK(!DevelTexture::IsNative(texture));
@@ -996,8 +1230,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;
 }
@@ -1046,7 +1283,7 @@ int UtcDaliTextureApplyFragShaderN2(void)
   TestApplication application;
   unsigned int    width(64);
   unsigned int    height(64);
-  Texture         texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture         texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
 
   const std::string baseFragShader =
     "varying mediump vec4 uColor;\n"
@@ -1060,3 +1297,196 @@ 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    = Texture::New(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   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture    texture2   = Texture::New(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;
+}