Floating point formats added to pixel data. 59/133859/9
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 13 Jun 2017 14:41:39 +0000 (15:41 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Wed, 14 Jun 2017 14:14:07 +0000 (15:14 +0100)
Change-Id: I94038c400620fef5a63fcd74bc2f053c2f9d8254
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
automated-tests/src/dali/utc-Dali-Texture.cpp
dali/devel-api/file.list
dali/devel-api/images/pixel-data-devel.cpp [new file with mode: 0644]
dali/devel-api/images/pixel-data-devel.h [new file with mode: 0644]
dali/devel-api/images/pixel-devel.h [new file with mode: 0644]
dali/internal/render/renderers/render-texture.cpp
dali/internal/render/renderers/render-texture.h

index 5613e17..458191e 100644 (file)
@@ -16,6 +16,8 @@
  */
 
 #include <dali/public-api/dali-core.h>
+#include <dali/devel-api/images/pixel-data-devel.h>
+#include <dali/devel-api/images/pixel-devel.h>
 #include <dali-test-suite-utils.h>
 #include <test-native-image.h>
 
@@ -408,61 +410,108 @@ int UtcDaliTextureUpload04(void)
 
 int UtcDaliTextureUpload05(void)
 {
-  TestApplication application;
+  Pixel::Format COMPRESSED_PIXEL_FORMATS[] =
+  {
+    Pixel::COMPRESSED_R11_EAC,
+    Pixel::COMPRESSED_SIGNED_R11_EAC,
+    Pixel::COMPRESSED_RG11_EAC,
+    Pixel::COMPRESSED_SIGNED_RG11_EAC,
+    Pixel::COMPRESSED_RGB8_ETC2,
+    Pixel::COMPRESSED_SRGB8_ETC2,
+    Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
+    Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
+    Pixel::COMPRESSED_RGBA8_ETC2_EAC,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
+    Pixel::COMPRESSED_RGB8_ETC1,
+    Pixel::COMPRESSED_RGB_PVRTC_4BPPV1,
+    Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR,
+    Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
+    Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
+  };
+  const unsigned int NUMBER_OF_COMPRESSED_PIXEL_FORMATS = sizeof( COMPRESSED_PIXEL_FORMATS ) / sizeof( Pixel::Format );
+
+  for( unsigned int index = 0; index < NUMBER_OF_COMPRESSED_PIXEL_FORMATS; ++index )
+  {
+    TestApplication application;
 
-  //Create a texture with a compressed format
-  unsigned int width(64);
-  unsigned int height(64);
-  Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, width, height );
+    //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 );
 
-  application.GetGlAbstraction().EnableTextureCallTrace(true);
+    application.GetGlAbstraction().EnableTextureCallTrace(true);
 
-  application.SendNotification();
-  application.Render();
+    application.SendNotification();
+    application.Render();
 
-  TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+    TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
 
-  //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;
-    DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str() ) );
-  }
+    //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;
+      DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str() ) );
+    }
 
-  //Upload data to the texture
-  callStack.Reset();
+    //Upload data to the texture
+    callStack.Reset();
 
-  unsigned int bufferSize( width * height * 4 );
-  unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
-  PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, PixelData::FREE );
-  texture.Upload( pixelData );
-  application.SendNotification();
-  application.Render();
+    unsigned int bufferSize( width * height * 4 );
+    unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+    PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, COMPRESSED_PIXEL_FORMATS[index], PixelData::FREE );
+    texture.Upload( pixelData );
+    application.SendNotification();
+    application.Render();
 
-  //CompressedTexImage2D should be called to upload the data
-  {
-    std::stringstream out;
-    out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
-    DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str() ) );
-  }
+    //CompressedTexImage2D should be called to upload the data
+    {
+      std::stringstream out;
+      out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+      DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str() ) );
+    }
 
-  //Upload part of the texture
-  callStack.Reset();
-  bufferSize =  width * height * 2;
-  buffer = reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
-  PixelData pixelDataSubImage = PixelData::New( buffer, bufferSize, width, height, Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, PixelData::FREE );
-  texture.Upload( pixelDataSubImage, 0u, 0u, width/2, height/2, width/2, height/2 );
-  application.SendNotification();
-  application.Render();
+    //Upload part of the texture
+    callStack.Reset();
+    bufferSize =  width * height * 2;
+    buffer = reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+    PixelData pixelDataSubImage = PixelData::New( buffer, bufferSize, width, height, COMPRESSED_PIXEL_FORMATS[index], PixelData::FREE );
+    texture.Upload( pixelDataSubImage, 0u, 0u, width/2, height/2, width/2, height/2 );
+    application.SendNotification();
+    application.Render();
 
-  //CompressedTexSubImage2D 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("CompressedTexSubImage2D", out.str().c_str() ) );
+    //CompressedTexSubImage2D 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("CompressedTexSubImage2D", out.str().c_str() ) );
+    }
   }
 
-
   END_TEST;
 }
 
@@ -511,6 +560,61 @@ int UtcDaliTextureUpload06(void)
   END_TEST;
 }
 
+int UtcDaliTextureUpload07(void)
+{
+  DevelPixel::Format FLOATING_POINT_PIXEL_FORMATS[] =
+  {
+    DevelPixel::RGB16F,
+    DevelPixel::RGB32F,
+  };
+  const unsigned int NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS = sizeof( FLOATING_POINT_PIXEL_FORMATS ) / sizeof( DevelPixel::Format );
+
+  for( unsigned int index = 0; index < NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS; ++index )
+  {
+    TestApplication application;
+
+    //Create the texture
+    unsigned int width(64);
+    unsigned int height(64);
+    tet_infoline( "Creating a floating point texture" );
+    Texture texture = Texture::New( TextureType::TEXTURE_2D, static_cast<Pixel::Format>( FLOATING_POINT_PIXEL_FORMATS[index] ), width, height );
+
+    application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+    application.SendNotification();
+    application.Render();
+
+    TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+    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;
+      DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+    }
+
+    tet_infoline( "Upload data to the texture" );
+    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 = DevelPixelData::New( buffer, bufferSize, width, height, FLOATING_POINT_PIXEL_FORMATS[index], PixelData::FREE );
+    texture.Upload( pixelData );
+    application.SendNotification();
+    application.Render();
+
+    tet_infoline( "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() ) );
+    }
+  }
+
+  END_TEST;
+}
+
 int UtcDaliTextureUploadSmallerThanSize(void)
 {
   TestApplication application;
index 5a779ad..baab797 100644 (file)
@@ -10,6 +10,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/images/distance-field.cpp \
   $(devel_api_src_dir)/images/texture-set-image.cpp \
   $(devel_api_src_dir)/images/nine-patch-image.cpp \
+  $(devel_api_src_dir)/images/pixel-data-devel.cpp \
   $(devel_api_src_dir)/images/pixel-data-mask.cpp \
   $(devel_api_src_dir)/object/handle-devel.cpp \
   $(devel_api_src_dir)/object/weak-handle.cpp \
@@ -46,9 +47,11 @@ devel_api_core_events_header_files = \
 devel_api_core_images_header_files = \
   $(devel_api_src_dir)/images/distance-field.h \
   $(devel_api_src_dir)/images/native-image-interface-extension.h \
-  $(devel_api_src_dir)/images/texture-set-image.h \
   $(devel_api_src_dir)/images/nine-patch-image.h \
-  $(devel_api_src_dir)/images/pixel-data-mask.h
+  $(devel_api_src_dir)/images/texture-set-image.h \
+  $(devel_api_src_dir)/images/pixel-data-devel.h \
+  $(devel_api_src_dir)/images/pixel-data-mask.h \
+  $(devel_api_src_dir)/images/pixel-devel.h
 
 devel_api_core_object_header_files = \
   $(devel_api_src_dir)/object/csharp-type-info.h \
diff --git a/dali/devel-api/images/pixel-data-devel.cpp b/dali/devel-api/images/pixel-data-devel.cpp
new file mode 100644 (file)
index 0000000..4ff8e8f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// FILE HEADER
+#include <dali/devel-api/images/pixel-data-devel.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/images/pixel-data-impl.h>
+
+namespace Dali
+{
+
+namespace DevelPixelData
+{
+
+PixelData New( unsigned char* buffer,
+               unsigned int bufferSize,
+               unsigned int width,
+               unsigned int height,
+               DevelPixel::Format pixelFormat,
+               PixelData::ReleaseFunction releaseFunction )
+{
+  IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New( buffer, bufferSize, width, height, static_cast<Pixel::Format>( pixelFormat ), releaseFunction );
+  return PixelData( internal.Get() );
+}
+
+} // namespace DevelPixelData
+
+} // namespace Dali
diff --git a/dali/devel-api/images/pixel-data-devel.h b/dali/devel-api/images/pixel-data-devel.h
new file mode 100644 (file)
index 0000000..b4c17a1
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef DALI_PIXEL_DATA_DEVEL_H
+#define DALI_PIXEL_DATA_DEVEL_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/images/pixel-data.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/images/pixel-devel.h>
+
+namespace Dali
+{
+
+namespace DevelPixelData
+{
+
+/**
+ * @brief Creates a PixelData object.
+ *
+ * @param[in] buffer          The raw pixel data
+ * @param[in] bufferSize      The size of the buffer in bytes
+ * @param[in] width           Buffer width in pixels
+ * @param[in] height          Buffer height in pixels
+ * @param[in] pixelFormat     The pixel format
+ * @param[in] releaseFunction The function used to release the memory
+ * @return A handle to the PixelData
+ */
+DALI_IMPORT_API PixelData New( unsigned char* buffer,
+                               unsigned int bufferSize,
+                               unsigned int width,
+                               unsigned int height,
+                               DevelPixel::Format pixelFormat,
+                               PixelData::ReleaseFunction releaseFunction );
+
+} // namespace DevelPixelData
+
+} // Dali
+
+#endif // DALI_PIXEL_DATA_DEVEL_H
diff --git a/dali/devel-api/images/pixel-devel.h b/dali/devel-api/images/pixel-devel.h
new file mode 100644 (file)
index 0000000..e93e129
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef DALI_PIXEL_DEVEL_H
+#define DALI_PIXEL_DEVEL_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/images/pixel.h>
+
+namespace Dali
+{
+
+namespace DevelPixel
+{
+
+enum Format
+{
+  INVALID = Dali::Pixel::INVALID,
+  A8 = Dali::Pixel::A8,
+  L8 = Dali::Pixel::L8,
+  LA88 = Dali::Pixel::LA88,
+  RGB565 = Dali::Pixel::RGB565,
+  BGR565 = Dali::Pixel::BGR565,
+  RGBA4444 = Dali::Pixel::RGBA4444,
+  BGRA4444 = Dali::Pixel::BGRA4444,
+  RGBA5551 = Dali::Pixel::RGBA5551,
+  BGRA5551 = Dali::Pixel::BGRA5551,
+  RGB888 = Dali::Pixel::RGB888,
+  RGB8888 = Dali::Pixel::RGB8888,
+  BGR8888 = Dali::Pixel::BGR8888,
+  RGBA8888 = Dali::Pixel::RGBA8888,
+  BGRA8888 = Dali::Pixel::BGRA8888,
+  COMPRESSED_R11_EAC = Dali::Pixel::COMPRESSED_R11_EAC,
+  COMPRESSED_SIGNED_R11_EAC = Dali::Pixel::COMPRESSED_SIGNED_R11_EAC,
+  COMPRESSED_RG11_EAC = Dali::Pixel::COMPRESSED_RG11_EAC,
+  COMPRESSED_SIGNED_RG11_EAC = Dali::Pixel::COMPRESSED_SIGNED_RG11_EAC,
+  COMPRESSED_RGB8_ETC2 = Dali::Pixel::COMPRESSED_RGB8_ETC2,
+  COMPRESSED_SRGB8_ETC2 = Dali::Pixel::COMPRESSED_SRGB8_ETC2,
+  COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = Dali::Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
+  COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = Dali::Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
+  COMPRESSED_RGBA8_ETC2_EAC = Dali::Pixel::COMPRESSED_RGBA8_ETC2_EAC,
+  COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
+  COMPRESSED_RGB8_ETC1 = Dali::Pixel::COMPRESSED_RGB8_ETC1,
+  COMPRESSED_RGB_PVRTC_4BPPV1 = Dali::Pixel::COMPRESSED_RGB_PVRTC_4BPPV1,
+  COMPRESSED_RGBA_ASTC_4x4_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR,
+  COMPRESSED_RGBA_ASTC_5x4_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR,
+  COMPRESSED_RGBA_ASTC_5x5_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR,
+  COMPRESSED_RGBA_ASTC_6x5_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR,
+  COMPRESSED_RGBA_ASTC_6x6_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR,
+  COMPRESSED_RGBA_ASTC_8x5_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR,
+  COMPRESSED_RGBA_ASTC_8x6_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR,
+  COMPRESSED_RGBA_ASTC_8x8_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR,
+  COMPRESSED_RGBA_ASTC_10x5_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR,
+  COMPRESSED_RGBA_ASTC_10x6_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR,
+  COMPRESSED_RGBA_ASTC_10x8_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR,
+  COMPRESSED_RGBA_ASTC_10x10_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR,
+  COMPRESSED_RGBA_ASTC_12x10_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR,
+  COMPRESSED_RGBA_ASTC_12x12_KHR = Dali::Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
+  COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
+
+  /**
+   * @brief Color depth 48-bit, 16-16-16 half floating point.
+   */
+  RGB16F = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR + 1,
+
+  /**
+   * @brief Color depth 96-bit, 32-32-32 floating point.
+   */
+  RGB32F = Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR + 2,
+
+};
+
+} // namespace DevelPixel
+
+} // namespace Dali
+
+#endif // DALI_PIXEL_DEVEL_H
index 191951c..8ae6829 100644 (file)
@@ -16,6 +16,9 @@
 
 // CLASS HEADER
 #include <dali/internal/render/renderers/render-texture.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/images/pixel-devel.h>
 #include <dali/devel-api/images/native-image-interface-extension.h>
 
 // EXTERNAL INCLUDES
@@ -121,43 +124,44 @@ GLint WrapModeToGL( WrapMode::Type wrapMode, GLint defaultWrapMode )
 }
 
 /**
- * @brief Retrive GL internal format and pixel data type from a Pixel::Format
- * @param[in] pixelFormat The pixel format
- * @param[out] pixelDataType The data type of the pixel data
- * @param[out] internalFormat The internal format
+ * @brief Retrives the GL format, GL internal format and pixel data type from a Pixel::Format
+ * @param[in] pixelFormat The pixel format.
+ * @param[out] glFormat The gl format.
+ * @param[out] glInternalFormat The gl internal format.
+ * @param[out] pixelDataType The data type of the pixel data.
  */
-void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsigned& internalFormat )
+void PixelFormatToGl( DevelPixel::Format pixelFormat, GLenum& glFormat, GLint& glInternalFormat, GLenum& pixelDataType )
 {
   // Compressed textures have no pixelDataType, so init to an invalid value:
   pixelDataType  = -1;
 
-  switch( pixelformat )
+  switch( pixelFormat )
   {
     case Pixel::A8:
     {
       pixelDataType = GL_UNSIGNED_BYTE;
-      internalFormat= GL_ALPHA;
+      glFormat= GL_ALPHA;
       break;
     }
 
     case Pixel::L8:
     {
       pixelDataType = GL_UNSIGNED_BYTE;
-      internalFormat= GL_LUMINANCE;
+      glFormat= GL_LUMINANCE;
       break;
     }
 
     case Pixel::LA88:
     {
       pixelDataType = GL_UNSIGNED_BYTE;
-      internalFormat= GL_LUMINANCE_ALPHA;
+      glFormat= GL_LUMINANCE_ALPHA;
       break;
     }
 
     case Pixel::RGB565:
     {
       pixelDataType = GL_UNSIGNED_SHORT_5_6_5;
-      internalFormat= GL_RGB;
+      glFormat= GL_RGB;
       break;
     }
 
@@ -166,9 +170,9 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
       DALI_LOG_ERROR("Pixel format BGR565 is not supported by GLES.\n");
       pixelDataType  = GL_UNSIGNED_SHORT_5_6_5;
 #ifdef _ARCH_ARM_
-      internalFormat= GL_BGRA_EXT; // alpha is reserved but not used
+      glFormat= GL_BGRA_EXT; // alpha is reserved but not used
 #else
-      internalFormat= GL_RGBA;     // alpha is reserved but not used
+      glFormat= GL_RGBA;     // alpha is reserved but not used
 #endif
       break;
     }
@@ -176,7 +180,7 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::RGBA4444:
     {
       pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4;
-      internalFormat= GL_RGBA;
+      glFormat= GL_RGBA;
       break;
     }
 
@@ -185,9 +189,9 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
       DALI_LOG_ERROR("Pixel format BGRA4444 is not supported by GLES.\n");
       pixelDataType  = GL_UNSIGNED_SHORT_4_4_4_4;
 #ifdef _ARCH_ARM_
-      internalFormat= GL_BGRA_EXT; // alpha is reserved but not used
+      glFormat= GL_BGRA_EXT; // alpha is reserved but not used
 #else
-      internalFormat= GL_RGBA;     // alpha is reserved but not used
+      glFormat= GL_RGBA;     // alpha is reserved but not used
 #endif
       break;
     }
@@ -195,7 +199,7 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::RGBA5551:
     {
       pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1;
-      internalFormat= GL_RGBA;
+      glFormat= GL_RGBA;
       break;
     }
 
@@ -204,9 +208,9 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
       DALI_LOG_ERROR("Pixel format BGRA5551 is not supported by GLES.\n");
       pixelDataType  = GL_UNSIGNED_SHORT_5_5_5_1;
 #ifdef _ARCH_ARM_
-      internalFormat= GL_BGRA_EXT; // alpha is reserved but not used
+      glFormat= GL_BGRA_EXT; // alpha is reserved but not used
 #else
-      internalFormat= GL_RGBA;     // alpha is reserved but not used
+      glFormat= GL_RGBA;     // alpha is reserved but not used
 #endif
       break;
     }
@@ -214,14 +218,14 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::RGB888:
     {
       pixelDataType = GL_UNSIGNED_BYTE;
-      internalFormat= GL_RGB;
+      glFormat= GL_RGB;
       break;
     }
 
     case Pixel::RGB8888:
     {
       pixelDataType = GL_UNSIGNED_BYTE;
-      internalFormat= GL_RGBA;     // alpha is reserved but not used
+      glFormat= GL_RGBA;     // alpha is reserved but not used
       break;
     }
 
@@ -229,9 +233,9 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     {
       pixelDataType = GL_UNSIGNED_BYTE;
 #ifdef GL_BGRA_EXT
-      internalFormat= GL_BGRA_EXT; // alpha is reserved but not used
+      glFormat= GL_BGRA_EXT; // alpha is reserved but not used
 #else
-      internalFormat= GL_RGBA;     // alpha is reserved but not used
+      glFormat= GL_RGBA;     // alpha is reserved but not used
 #endif
     break;
     }
@@ -239,7 +243,7 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::RGBA8888:
     {
       pixelDataType = GL_UNSIGNED_BYTE;
-      internalFormat= GL_RGBA;
+      glFormat= GL_RGBA;
       break;
     }
 
@@ -247,9 +251,9 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     {
       pixelDataType = GL_UNSIGNED_BYTE;
 #ifdef GL_BGRA_EXT
-      internalFormat= GL_BGRA_EXT; // alpha is reserved but not used
+      glFormat= GL_BGRA_EXT; // alpha is reserved but not used
 #else
-      internalFormat= GL_RGBA;     // alpha is reserved but not used
+      glFormat= GL_RGBA;     // alpha is reserved but not used
 #endif
       break;
     }
@@ -258,13 +262,13 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::COMPRESSED_RGB8_ETC1:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" );
-      internalFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
+      glFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
       break;
     }
     case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" );
-      internalFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
+      glFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
       break;
     }
 
@@ -272,61 +276,61 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::COMPRESSED_R11_EAC:
     {
       DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.\n");
-      internalFormat = GL_COMPRESSED_R11_EAC;
+      glFormat = GL_COMPRESSED_R11_EAC;
       break;
     }
     case Pixel::COMPRESSED_SIGNED_R11_EAC:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n" );
-      internalFormat = GL_COMPRESSED_SIGNED_R11_EAC;
+      glFormat = GL_COMPRESSED_SIGNED_R11_EAC;
       break;
     }
     case Pixel::COMPRESSED_RG11_EAC:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n" );
-      internalFormat = GL_COMPRESSED_RG11_EAC;
+      glFormat = GL_COMPRESSED_RG11_EAC;
       break;
     }
     case Pixel::COMPRESSED_SIGNED_RG11_EAC:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n" );
-      internalFormat = GL_COMPRESSED_SIGNED_RG11_EAC;
+      glFormat = GL_COMPRESSED_SIGNED_RG11_EAC;
       break;
     }
     case Pixel::COMPRESSED_RGB8_ETC2:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n" );
-      internalFormat = GL_COMPRESSED_RGB8_ETC2;
+      glFormat = GL_COMPRESSED_RGB8_ETC2;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ETC2:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ETC2;
+      glFormat = GL_COMPRESSED_SRGB8_ETC2;
       break;
     }
     case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" );
-      internalFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+      glFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+      glFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
       break;
     }
     case Pixel::COMPRESSED_RGBA8_ETC2_EAC:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n" );
-      internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
+      glFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
       break;
     }
 
@@ -334,181 +338,211 @@ void PixelFormatToGl( Pixel::Format pixelformat, unsigned& pixelDataType, unsign
     case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR;
       break;
     }
     case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n" );
-      internalFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR;
+      glFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
       break;
     }
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
     {
       DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n" );
-      internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
+      glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
+      break;
+    }
+
+    // GLES 3.0 floating point formats.
+    case DevelPixel::RGB16F:
+    {
+      glFormat = GL_RGB;
+      pixelDataType = GL_HALF_FLOAT;
+      break;
+    }
+    case DevelPixel::RGB32F:
+    {
+      glFormat = GL_RGB;
+      pixelDataType = GL_FLOAT;
       break;
     }
 
     case Pixel::INVALID:
     {
       DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" );
-      internalFormat = 0;
+      glFormat = 0;
+      break;
+    }
+  }
+
+  switch( pixelFormat )
+  {
+    case DevelPixel::RGB16F:
+    case DevelPixel::RGB32F: // FALL THROUGH
+    {
+      glInternalFormat = GL_R11F_G11F_B10F;
       break;
     }
+    default:
+    {
+      glInternalFormat = glFormat;
+    }
   }
+
 }
 
+
 /**
  * @brief Whether specified pixel format is compressed.
  *
@@ -591,19 +625,23 @@ bool IsCompressedFormat(Pixel::Format pixelFormat)
 
 Texture::Texture( Type type, Pixel::Format format, unsigned int width, unsigned int height )
 :mId( 0 ),
- mTarget( (type == TextureType::TEXTURE_2D)? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP ),
+ mTarget( ( type == TextureType::TEXTURE_2D ) ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP ),
  mType( type ),
  mSampler(),
  mNativeImage(),
- mInternalFormat(GL_RGB),
- mPixelDataType(GL_UNSIGNED_BYTE),
+ mGlFormat( GL_RGB ),
+ mGlInternalFormat( GL_RGB ),
+ mPixelDataType( GL_UNSIGNED_BYTE ),
  mWidth( width ),
  mHeight( height ),
- mMaxMipMapLevel(0),
+ mMaxMipMapLevel( 0 ),
  mHasAlpha( HasAlpha( format ) ),
  mIsCompressed( IsCompressedFormat( format ) )
 {
-  PixelFormatToGl( format, mPixelDataType, mInternalFormat );
+  PixelFormatToGl( static_cast<DevelPixel::Format>( format ),
+                   mGlFormat,
+                   mGlInternalFormat,
+                   mPixelDataType );
 }
 
 Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
@@ -612,11 +650,12 @@ Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
  mType( TextureType::TEXTURE_2D ),
  mSampler(),
  mNativeImage( nativeImageInterface ),
- mInternalFormat(GL_RGB),
- mPixelDataType(GL_UNSIGNED_BYTE),
+ mGlFormat( GL_RGB ),
+ mGlInternalFormat( GL_RGB ),
+ mPixelDataType( GL_UNSIGNED_BYTE ),
  mWidth( nativeImageInterface->GetWidth() ),
  mHeight( nativeImageInterface->GetHeight() ),
- mMaxMipMapLevel(0),
+ mMaxMipMapLevel( 0 ),
  mHasAlpha( nativeImageInterface->RequiresBlending() ),
  mIsCompressed( false )
 {
@@ -691,11 +730,11 @@ void Texture::Initialize(Context& context)
     {
       if( !mIsCompressed )
       {
-        context.TexImage2D(GL_TEXTURE_2D, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+        context.TexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, 0 );
       }
       else
       {
-        context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mInternalFormat, mWidth, mHeight, 0, 0, 0 );
+        context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, 0 );
       }
     }
     else if( mType == TextureType::TEXTURE_CUBE )
@@ -704,14 +743,14 @@ void Texture::Initialize(Context& context)
       {
         for( unsigned int i(0); i<6; ++i )
         {
-          context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+          context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, 0 );
         }
       }
       else
       {
         for( unsigned int i(0); i<6; ++i )
         {
-          context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, 0, 0 );
+          context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, 0 );
         }
       }
       context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT );
@@ -729,9 +768,11 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::
   //This buffer is only used if manually converting from RGB to RGBA
   unsigned char* tempBuffer(0);
 
-  //Get pixel format and data type of the data contained in the PixelData object
-  GLenum pixelDataFormat, pixelDataElementType;
-  PixelFormatToGl( pixelData->GetPixelFormat(), pixelDataElementType, pixelDataFormat );
+  //Retrieves the pixel data element type, the gl format and gl internal format of the data contained in the PixelData object.
+  GLenum glFormat;
+  GLint glInternalFormat;
+  GLenum pixelDataElementType;
+  PixelFormatToGl( static_cast<DevelPixel::Format>( pixelData->GetPixelFormat() ), glFormat, glInternalFormat, pixelDataElementType );
 
   //Get the maximum mipmap level to set GL_TEXTURE_MAX_LEVEL parameter in GLES3x because is not
   //necessary to upload all the mipmap levels
@@ -742,7 +783,7 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::
                             ( params.width  != ( mWidth  / ( 1 << params.mipmap ) ) ) ||
                             ( params.height != ( mHeight / ( 1 << params.mipmap ) ) ) );
 
-  bool convert = ( ( pixelDataFormat == GL_RGB ) && ( mInternalFormat == GL_RGBA ) );
+  bool convert = ( ( glFormat == GL_RGB ) && ( mGlFormat == GL_RGBA ) );
 #if DALI_GLES_VERSION >= 30
   // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
   convert = convert && !isSubImage;
@@ -761,7 +802,7 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::
     }
 
     buffer = tempBuffer;
-    pixelDataFormat = mInternalFormat;
+    glFormat = mGlFormat; // Set the glFormat to GL_RGBA
   }
 
   //Upload data to the texture
@@ -780,11 +821,11 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::
     //Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
     if( !mIsCompressed )
     {
-      context.TexImage2D( target, params.mipmap, mInternalFormat, params.width, params.height, 0, pixelDataFormat, pixelDataElementType, buffer );
+      context.TexImage2D( target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, glFormat, pixelDataElementType, buffer );
     }
     else
     {
-      context.CompressedTexImage2D( target, params.mipmap, mInternalFormat, params.width, params.height, 0, pixelData->GetBufferSize(), buffer );
+      context.CompressedTexImage2D( target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, pixelData->GetBufferSize(), buffer );
     }
   }
   else
@@ -794,13 +835,13 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::
     {
       context.TexSubImage2D( target, params.mipmap,
                              params.xOffset, params.yOffset, params.width, params.height,
-                             pixelDataFormat, pixelDataElementType, buffer );
+                             glFormat, pixelDataElementType, buffer );
     }
     else
     {
       context.CompressedTexSubImage2D( target, params.mipmap,
                                        params.xOffset, params.yOffset, params.width, params.height,
-                                       pixelDataFormat, pixelData->GetBufferSize(), buffer );
+                                       glFormat, pixelData->GetBufferSize(), buffer );
     }
   }
 
index 1ae9a3c..8497b83 100644 (file)
@@ -168,7 +168,8 @@ private:
   Type mType;                           ///< Type of the texture
   Render::Sampler mSampler;             ///< The current sampler state
   NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
-  GLenum mInternalFormat;               ///< The format of the pixel data
+  GLenum mGlFormat;                     ///< The gl format of the pixel data
+  GLint mGlInternalFormat;              ///< The gl internal format of the pixel data
   GLenum mPixelDataType;                ///< The data type of the pixel data
   unsigned int mWidth;                  ///< Width of the texture
   unsigned int mHeight;                 ///< Height of the texture