Added ASTC Native file format loader 45/56645/6
authorTom Robinson <tom.robinson@samsung.com>
Mon, 11 Jan 2016 16:50:26 +0000 (16:50 +0000)
committerTom Robinson <tom.robinson@samsung.com>
Thu, 14 Jan 2016 12:12:42 +0000 (04:12 -0800)
ASTC can be wrapped in a KTX file, but also has its own native file format.
This patch provides support for the native ASTC file format (.astc).

Textures can be generated using tools (Eg. Mali texture compression tool).

Note: ASTC is "OpenGL friendly" in that the textures are pre-flipped vertically.
In DALi there is currently not a differenciation between different texture compression formats in that the data (once the header is extracted) is given to the hardware as-is.
For this reason textures must currently be pre-flipped vertically (before compression) when using the native .astc file format with DALI.

An example .astc file is included as part of the unit tests.

Change-Id: I78025f11f9aed23ed9ccf369057ce9c5f3a65fca

automated-tests/src/dali/utc-Dali-Pixel.cpp
dali/integration-api/bitmap.cpp
dali/internal/event/images/nine-patch-image-impl.cpp
dali/public-api/images/pixel.cpp
dali/public-api/images/pixel.h

index 0a67e27..25712a9 100644 (file)
@@ -52,6 +52,8 @@ int UtcDaliPixelHasAlpha(void)
 
   TestPixelEnumSize( 54 );
 
+  DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::INVALID ) == false ); // For completeness
+
   DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::L8 ) == false );
   DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::RGB565 ) == false );
   DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::RGB888 ) == false );
@@ -124,6 +126,8 @@ int UtcDaliPixelGetBytesPerPixel(void)
 
   tet_infoline("UtcDaliPixelGetBytesPerPixel");
 
+  DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::INVALID ) == 0 ); // For completeness
+
   DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::L8 ) == 1 );
   DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::A8 ) == 1 );
 
@@ -207,6 +211,9 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void)
   // Be sure that the number of cases tested below is correct:
   TestPixelEnumSize( 54 );
 
+  Pixel::GetAlphaOffsetAndMask( Pixel::INVALID, byteOffset, bitMask ); // For completeness
+  DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 );
+
   Pixel::GetAlphaOffsetAndMask( Pixel::L8, byteOffset, bitMask );
   DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 );
   Pixel::GetAlphaOffsetAndMask( Pixel::A8, byteOffset, bitMask );
index 5f7bbd5..50c77c8 100644 (file)
@@ -407,6 +407,13 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i
       internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
       break;
     }
+
+    case INVALID:
+    {
+      DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" );
+      internalFormat = 0;
+      break;
+    }
   }
 }
 
index b376cba..7ff6859 100644 (file)
@@ -103,6 +103,7 @@ void GetRedOffsetAndMask(Dali::Pixel::Format pixelFormat, int& byteOffset, int&
       break;
     }
 
+    case Dali::Pixel::INVALID:
     case Dali::Pixel::COMPRESSED_R11_EAC:
     case Dali::Pixel::COMPRESSED_SIGNED_R11_EAC:
     case Dali::Pixel::COMPRESSED_RG11_EAC:
index 166d220..276e1c4 100644 (file)
@@ -89,6 +89,7 @@ bool Pixel::HasAlpha(Format pixelformat)
     case COMPRESSED_SRGB8_ETC2:
     case COMPRESSED_RGB8_ETC1:
     case COMPRESSED_RGB_PVRTC_4BPPV1:
+    case INVALID:
     {
       return false;
     }
@@ -170,6 +171,7 @@ unsigned int Pixel::GetBytesPerPixel(Format pixelFormat)
     case COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
     case COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
     case COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+    case INVALID:
     {
       DALI_LOG_ERROR("Pixel formats for compressed images do not have meaningful integer bits per pixel values.\n");
       return 0;
@@ -272,6 +274,7 @@ void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitM
     case COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
     case COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
     case COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+    case INVALID:
     {
       DALI_LOG_ERROR("Pixel formats for compressed images are not compatible with simple masking-out of per-pixel alpha.\n");
       byteOffset=0;
index 590df68..6a2f4ed 100644 (file)
@@ -40,6 +40,8 @@ namespace Pixel
  */
 enum Format ///< pixel format, default color depth is RGBA 32 bit with alpha
 {
+  INVALID = 0,
+
   // Start at > 0 to distinguish null data:
   A8 = 1,                                   ///< color depth 8-bit, alpha
   L8,                                       ///< color depth 8-bit, luminance