/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * 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.
// EXTERNAL INCLUDES
#include <math.h> //floor, log2
-//INTERNAL INCLUDES
-#include <dali/devel-api/rendering/texture.h> // Dali::Texture
+// INTERNAL INCLUDES
+#include <dali/devel-api/images/native-image-interface-extension.h>
namespace Dali
{
}
/**
- * @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( Pixel::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;
}
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;
}
case Pixel::RGBA4444:
{
pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4;
- internalFormat= GL_RGBA;
+ glFormat= GL_RGBA;
break;
}
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;
}
case Pixel::RGBA5551:
{
pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1;
- internalFormat= GL_RGBA;
+ glFormat= GL_RGBA;
break;
}
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;
}
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;
}
{
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;
}
case Pixel::RGBA8888:
{
pixelDataType = GL_UNSIGNED_BYTE;
- internalFormat= GL_RGBA;
+ glFormat= GL_RGBA;
break;
}
{
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;
}
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;
}
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;
}
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 Pixel::RGB16F:
+ {
+ glFormat = GL_RGB;
+ pixelDataType = GL_HALF_FLOAT;
+ break;
+ }
+ case Pixel::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 Pixel::RGB16F:
+ case Pixel::RGB32F: // FALL THROUGH
+ {
+ glInternalFormat = GL_R11F_G11F_B10F;
break;
}
+ default:
+ {
+ glInternalFormat = glFormat;
+ }
}
+
}
+/**
+ * @brief Whether specified pixel format is compressed.
+ *
+ * @param [in] pixelformat Pixel format
+ * @return true if format is compressed, false otherwise
+ */
+bool IsCompressedFormat(Pixel::Format pixelFormat)
+{
+ switch (pixelFormat)
+ {
+ case Pixel::L8:
+ case Pixel::A8:
+ case Pixel::LA88:
+ case Pixel::RGB565:
+ case Pixel::RGBA4444:
+ case Pixel::RGBA5551:
+ case Pixel::BGR565:
+ case Pixel::BGRA4444:
+ case Pixel::BGRA5551:
+ case Pixel::RGB888:
+ case Pixel::RGB8888:
+ case Pixel::BGR8888:
+ case Pixel::RGBA8888:
+ case Pixel::BGRA8888:
+ case Pixel::RGB16F:
+ case Pixel::RGB32F:
+ case Pixel::INVALID:
+ {
+ return false;
+ }
+
+ case Pixel::COMPRESSED_R11_EAC:
+ case Pixel::COMPRESSED_SIGNED_R11_EAC:
+ case Pixel::COMPRESSED_RG11_EAC:
+ case Pixel::COMPRESSED_SIGNED_RG11_EAC:
+ case Pixel::COMPRESSED_RGB8_ETC2:
+ case Pixel::COMPRESSED_SRGB8_ETC2:
+ case Pixel::COMPRESSED_RGB8_ETC1:
+ case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1:
+ case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case Pixel::COMPRESSED_RGBA8_ETC2_EAC:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
} //Unnamed namespace
-NewTexture::NewTexture( Type type, Pixel::Format format, unsigned int width, unsigned int height )
-:mId( 0 ),
- mType( type ),
- mInternalFormat(GL_RGB),
- mPixelDataType(GL_UNSIGNED_BYTE),
- mWidth( width ),
- mHeight( height ),
- mSampler(),
- mHasAlpha( HasAlpha( format ) )
+Texture::Texture( Type type, Pixel::Format format, ImageDimensions size )
+: mNativeImage(),
+ mSampler(),
+ mId( 0 ),
+ mTarget( ( type == TextureType::TEXTURE_2D ) ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP ),
+ mGlInternalFormat( GL_RGB ),
+ mGlFormat( GL_RGB ),
+ mPixelDataType( GL_UNSIGNED_BYTE ),
+ mWidth( size.GetWidth() ),
+ mHeight( size.GetHeight() ),
+ mMaxMipMapLevel( 0 ),
+ mType( type ),
+ mHasAlpha( HasAlpha( format ) ),
+ mIsCompressed( IsCompressedFormat( format ) )
{
- PixelFormatToGl( format, mPixelDataType, mInternalFormat );
+ PixelFormatToGl( format,
+ mGlFormat,
+ mGlInternalFormat,
+ mPixelDataType );
}
-NewTexture::~NewTexture()
+Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
+: mNativeImage( nativeImageInterface ),
+ mSampler(),
+ mId( 0 ),
+ mTarget( GL_TEXTURE_2D ),
+ mGlInternalFormat( GL_RGB ),
+ mGlFormat( GL_RGB ),
+ mPixelDataType( GL_UNSIGNED_BYTE ),
+ mWidth( nativeImageInterface->GetWidth() ),
+ mHeight( nativeImageInterface->GetHeight() ),
+ mMaxMipMapLevel( 0 ),
+ mType( TextureType::TEXTURE_2D ),
+ mHasAlpha( nativeImageInterface->RequiresBlending() ),
+ mIsCompressed( false )
+{
+}
+
+Texture::~Texture()
{}
-void NewTexture::Destroy( Context& context )
+void Texture::Destroy( Context& context )
{
if( mId )
{
context.DeleteTextures( 1, &mId );
+
+ if( mNativeImage )
+ {
+ mNativeImage->GlExtensionDestroy();
+ }
}
}
-void NewTexture::Initialize(Context& context)
+void Texture::GlContextDestroyed()
{
- context.GenTextures( 1, &mId );
+ mId = 0u;
+}
- if( mType == TextureType::TEXTURE_2D )
+void Texture::Initialize(Context& context)
+{
+ if( mNativeImage )
+ {
+ if( mNativeImage->GlExtensionCreate() )
+ {
+ NativeImageInterface::Extension* extension = mNativeImage->GetExtension();
+ if( extension )
+ {
+ mTarget = extension->GetEglImageTextureTarget();
+ }
+
+ context.GenTextures( 1, &mId );
+ context.BindTexture( mTarget, mId );
+ context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
+
+ //Apply default sampling parameters
+ context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
+ context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
+
+ // platform specific implementation decides on what GL extension to use
+ if( mNativeImage->TargetTexture() != 0u )
+ {
+ context.DeleteTextures( 1, &mId );
+ mNativeImage->GlExtensionDestroy();
+ mId = 0u;
+ }
+ }
+ }
+ else
{
- //Creates the texture and reserves memory for the first mipmap level.
- context.Bind2dTexture( mId );
- context.TexImage2D(GL_TEXTURE_2D, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+ //Create the texture and reserve memory for the first mipmap level.
+ context.GenTextures( 1, &mId );
+ context.BindTexture( mTarget, mId );
+ context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
//Apply default sampling parameters
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
-
+ context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
+ context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
+
+ if( mType == TextureType::TEXTURE_2D )
+ {
+ if( !mIsCompressed )
+ {
+ context.TexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, 0 );
+ }
+ else
+ {
+ context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, 0 );
+ }
+ }
+ else if( mType == TextureType::TEXTURE_CUBE )
+ {
+ if( !mIsCompressed )
+ {
+ for( unsigned int i(0); i<6; ++i )
+ {
+ 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, mGlInternalFormat, mWidth, mHeight, 0, 0, 0 );
+ }
+ }
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT );
+ }
}
- else if( mType == TextureType::TEXTURE_CUBE )
+}
+
+void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params )
+{
+ DALI_ASSERT_ALWAYS( mNativeImage == NULL );
+
+ //Get pointer to the data of the PixelData object
+ unsigned char* buffer( pixelData->GetBuffer() );
+
+ //This buffer is only used if manually converting from RGB to RGBA
+ unsigned char* tempBuffer(0);
+
+ //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( 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
+ mMaxMipMapLevel = ( mMaxMipMapLevel > params.mipmap ) ? mMaxMipMapLevel : params.mipmap;
+
+ const bool isSubImage = ( ( params.xOffset != 0 ) ||
+ ( params.yOffset != 0 ) ||
+ ( params.width != ( mWidth / ( 1 << params.mipmap ) ) ) ||
+ ( params.height != ( mHeight / ( 1 << params.mipmap ) ) ) );
+
+ 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;
+#endif
+
+ if( convert )
{
- //Creates the texture and reserves memory for the first mipmap level.
- context.BindCubeMapTexture( mId );
- for( unsigned int i(0); i<6; ++i )
+ size_t dataSize = static_cast< size_t >( params.width ) * params.height;
+ tempBuffer = new unsigned char[dataSize*4u];
+ for( size_t i(0u); i<dataSize; i++ )
{
- context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+ tempBuffer[i*4u] = buffer[i*3u];
+ tempBuffer[i*4u+1] = buffer[i*3u+1];
+ tempBuffer[i*4u+2] = buffer[i*3u+2];
+ tempBuffer[i*4u+3] = 0xFF;
}
- //Apply default sampling parameters
- context.TexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
- context.TexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
- context.TexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT );
- context.TexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
- context.TexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
+ buffer = tempBuffer;
+ glFormat = mGlFormat; // Set the glFormat to GL_RGBA
}
-}
-void NewTexture::Upload( Context& context, Vector<unsigned char>& buffer, const Internal::NewTexture::UploadParams& params )
-{
- if( mType == TextureType::TEXTURE_2D )
+ //Upload data to the texture
+
+ context.BindTexture( mTarget, mId );
+ GLenum target( mTarget );
+ if( mType == TextureType::TEXTURE_CUBE )
{
- context.Bind2dTexture( mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+ target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer;
+ }
+
+ context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- if( params.xOffset == 0 && params.yOffset == 0 &&
- params.width == (unsigned int)(mWidth / (1<<params.mipmap)) &&
- params.height == (unsigned int)(mHeight / (1<<params.mipmap)) )
+ if( !isSubImage )
+ {
+ //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 )
{
- //Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
- context.TexImage2D(GL_TEXTURE_2D, params.mipmap, mInternalFormat, params.width, params.height, 0, mInternalFormat, mPixelDataType, &buffer[0] );
+ context.TexImage2D( target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, glFormat, pixelDataElementType, buffer );
}
else
{
- //Specifying part of the image for the mipmap
- context.TexSubImage2D( GL_TEXTURE_2D, params.mipmap, params.xOffset, params.yOffset, params.width, params.height, mInternalFormat, mPixelDataType, &buffer[0] );
+ context.CompressedTexImage2D( target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, pixelData->GetBufferSize(), buffer );
}
}
- else if( mType == TextureType::TEXTURE_CUBE )
+ else
{
- context.BindCubeMapTexture( mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
- if( params.xOffset == 0 && params.yOffset == 0 &&
- params.width == static_cast<unsigned int>(mWidth / (1<<params.mipmap)) &&
- params.height == static_cast<unsigned int>(mHeight / (1<<params.mipmap)) )
+ //Specifying part of the image for the mipmap
+ if( !mIsCompressed )
{
- //Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
- context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap, mInternalFormat,
- params.width, params.height, 0,
- mInternalFormat, mPixelDataType, &buffer[0] );
+ context.TexSubImage2D( target, params.mipmap,
+ params.xOffset, params.yOffset, params.width, params.height,
+ glFormat, pixelDataElementType, buffer );
}
else
{
- //Specifying part of the image for the mipmap
- context.TexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap,
- params.xOffset, params.yOffset, params.width, params.height,
- mInternalFormat, mPixelDataType, &buffer[0] );
+ context.CompressedTexSubImage2D( target, params.mipmap,
+ params.xOffset, params.yOffset, params.width, params.height,
+ glFormat, pixelData->GetBufferSize(), buffer );
}
}
+
+
+ //Destroy temp buffer used for conversion RGB->RGBA
+ delete[] tempBuffer;
}
-void NewTexture::Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler )
+bool Texture::Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler )
{
- context.ActiveTexture( static_cast<TextureUnit>(textureUnit) );
-
- if( mType == TextureType::TEXTURE_2D )
+ if( mNativeImage && mId == 0 )
{
- context.Bind2dTexture( mId );
+ Initialize( context );
}
- else if( mType == TextureType::TEXTURE_CUBE )
+
+ if( mId != 0 )
{
- context.BindCubeMapTexture( mId );
+ context.BindTextureForUnit( static_cast<TextureUnit>( textureUnit ), mTarget, mId );
+ ApplySampler( context, sampler );
+
+ if( mNativeImage )
+ {
+ mNativeImage->PrepareTexture();
+ }
+
+ return true;
}
- ApplySampler( context, sampler );
+ return false;
}
-void NewTexture::ApplySampler( Context& context, Render::Sampler* sampler )
+void Texture::ApplySampler( Context& context, Render::Sampler* sampler )
{
Render::Sampler oldSampler = mSampler;
- if( sampler )
- {
- mSampler = *sampler;
- }
+ mSampler = sampler ? *sampler : Sampler();
- if( mSampler.mBitfield != oldSampler.mBitfield )
+ if( mSampler != oldSampler )
{
- if( mSampler.mMinificationFilter != oldSampler.mMinificationFilter )
+ GLint mode = FilterModeToGL( mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT );
+ if( mode != FilterModeToGL( oldSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT ) )
{
- GLint glFilterMode = FilterModeToGL( mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glFilterMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, mode );
}
- if( mSampler.mMagnificationFilter != oldSampler.mMagnificationFilter )
+ mode = FilterModeToGL( mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT );
+ if( mode != FilterModeToGL( oldSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT ) )
{
- GLint glFilterMode = FilterModeToGL( mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glFilterMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, mode );
}
- if( mSampler.mSWrapMode != oldSampler.mSWrapMode )
+ mode = WrapModeToGL( mSampler.mSWrapMode, GL_WRAP_DEFAULT );
+ if( mode != WrapModeToGL( oldSampler.mSWrapMode, GL_WRAP_DEFAULT ) )
{
- GLint glWrapMode = WrapModeToGL( mSampler.mSWrapMode, GL_WRAP_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, mode );
}
- if( mSampler.mTWrapMode != oldSampler.mTWrapMode )
+ mode = WrapModeToGL( mSampler.mTWrapMode, GL_WRAP_DEFAULT );
+ if( mode != WrapModeToGL( oldSampler.mTWrapMode, GL_WRAP_DEFAULT ) )
{
- GLint glWrapMode = WrapModeToGL( mSampler.mTWrapMode, GL_WRAP_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, mode );
}
- if( mType == TextureType::TEXTURE_CUBE && mSampler.mRWrapMode != oldSampler.mRWrapMode )
+ if( mType == TextureType::TEXTURE_CUBE )
{
- GLint glWrapMode = WrapModeToGL( mSampler.mRWrapMode, GL_WRAP_DEFAULT );
- context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, glWrapMode );
+ mode = WrapModeToGL( mSampler.mRWrapMode, GL_WRAP_DEFAULT );
+ if( mode != WrapModeToGL( oldSampler.mRWrapMode, GL_WRAP_DEFAULT ) )
+ {
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, mode );
+ }
}
+
+#if DALI_GLES_VERSION >= 30
+ //In GLES 3.0 we do not need to upload all of the mipmap levels, but GL_TEXTURE_MAX_LEVEL must be set
+ if(mMaxMipMapLevel)
+ {
+ context.TexParameteri( mTarget, GL_TEXTURE_MAX_LEVEL, mMaxMipMapLevel );
+ }
+#endif
+
}
}
-bool NewTexture::HasAlphaChannel()
+bool Texture::HasAlphaChannel()
{
return mHasAlpha;
}
-void NewTexture::GenerateMipmaps( Context& context )
+void Texture::GenerateMipmaps( Context& context )
{
- if( mType == TextureType::TEXTURE_2D )
- {
- context.Bind2dTexture( mId );
- context.GenerateMipmap( GL_TEXTURE_2D );
- }
- else if( mType == TextureType::TEXTURE_CUBE )
- {
- context.BindCubeMapTexture( mId );
- context.GenerateMipmap( GL_TEXTURE_CUBE_MAP );
- }
+ //GL_TEXTURE_MAX_LEVEL does not need to be set when mipmaps are generated by GL
+ mMaxMipMapLevel = 0;
+ context.BindTexture( mTarget, mId );
+ context.GenerateMipmap( mTarget );
}
} //Render