From 60695d66aad2c152d61f474d89a2c960f7711c70 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Thu, 28 Sep 2017 16:13:49 +0100 Subject: [PATCH] Move GLES 3.0 floating point pixel formats to Public API Change-Id: I67abf9f4063080bd1a0f4c258d2b80bfd6284da1 --- automated-tests/src/dali/utc-Dali-Pixel.cpp | 20 +++- automated-tests/src/dali/utc-Dali-Texture.cpp | 15 ++- dali/devel-api/CMakeLists.txt | 1 - dali/devel-api/file.list | 3 +- dali/devel-api/images/pixel-data-devel.cpp | 11 --- dali/devel-api/images/pixel-data-devel.h | 20 +--- dali/devel-api/images/pixel-devel.h | 104 --------------------- dali/integration-api/bitmap.cpp | 18 +++- .../event/images/nine-patch-image-impl.cpp | 11 ++- dali/internal/render/renderers/render-texture.cpp | 17 ++-- dali/public-api/images/pixel.cpp | 16 +++- dali/public-api/images/pixel.h | 8 +- 12 files changed, 83 insertions(+), 161 deletions(-) delete mode 100644 dali/devel-api/images/pixel-devel.h diff --git a/automated-tests/src/dali/utc-Dali-Pixel.cpp b/automated-tests/src/dali/utc-Dali-Pixel.cpp index 25712a9..e86bce2 100644 --- a/automated-tests/src/dali/utc-Dali-Pixel.cpp +++ b/automated-tests/src/dali/utc-Dali-Pixel.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -50,7 +50,7 @@ int UtcDaliPixelHasAlpha(void) tet_infoline("UtcDaliPixelHasAlpha"); - TestPixelEnumSize( 54 ); + TestPixelEnumSize( 56 ); DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::INVALID ) == false ); // For completeness @@ -111,6 +111,9 @@ int UtcDaliPixelHasAlpha(void) DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR ) == true ); DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR ) == true ); + DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::RGB16F ) == false ); + DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::RGB32F ) == false ); + END_TEST; } @@ -126,6 +129,9 @@ int UtcDaliPixelGetBytesPerPixel(void) tet_infoline("UtcDaliPixelGetBytesPerPixel"); + // Be sure that the number of cases tested below is correct: + TestPixelEnumSize( 56 ); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::INVALID ) == 0 ); // For completeness DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::L8 ) == 1 ); @@ -190,6 +196,9 @@ int UtcDaliPixelGetBytesPerPixel(void) DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR ) == 0 ); DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR ) == 0 ); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::RGB16F ) == 12 ); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel( Pixel::RGB32F ) == 24 ); + END_TEST; } @@ -209,7 +218,7 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void) int bitMask = 0; // Be sure that the number of cases tested below is correct: - TestPixelEnumSize( 54 ); + TestPixelEnumSize( 56 ); Pixel::GetAlphaOffsetAndMask( Pixel::INVALID, byteOffset, bitMask ); // For completeness DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); @@ -325,6 +334,11 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void) Pixel::GetAlphaOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, byteOffset, bitMask ); DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + Pixel::GetAlphaOffsetAndMask( Pixel::RGB16F, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + Pixel::GetAlphaOffsetAndMask( Pixel::RGB32F, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Texture.cpp b/automated-tests/src/dali/utc-Dali-Texture.cpp index 458191e..30d0a7f 100644 --- a/automated-tests/src/dali/utc-Dali-Texture.cpp +++ b/automated-tests/src/dali/utc-Dali-Texture.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -562,12 +561,12 @@ int UtcDaliTextureUpload06(void) int UtcDaliTextureUpload07(void) { - DevelPixel::Format FLOATING_POINT_PIXEL_FORMATS[] = + Pixel::Format FLOATING_POINT_PIXEL_FORMATS[] = { - DevelPixel::RGB16F, - DevelPixel::RGB32F, + Pixel::RGB16F, + Pixel::RGB32F, }; - const unsigned int NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS = sizeof( FLOATING_POINT_PIXEL_FORMATS ) / sizeof( DevelPixel::Format ); + const unsigned int NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS = sizeof( FLOATING_POINT_PIXEL_FORMATS ) / sizeof( Pixel::Format ); for( unsigned int index = 0; index < NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS; ++index ) { @@ -577,7 +576,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, static_cast( FLOATING_POINT_PIXEL_FORMATS[index] ), width, height ); + Texture texture = Texture::New( TextureType::TEXTURE_2D, FLOATING_POINT_PIXEL_FORMATS[index], width, height ); application.GetGlAbstraction().EnableTextureCallTrace(true); @@ -599,7 +598,7 @@ int UtcDaliTextureUpload07(void) 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( malloc( bufferSize ) ); - PixelData pixelData = DevelPixelData::New( buffer, bufferSize, width, height, FLOATING_POINT_PIXEL_FORMATS[index], PixelData::FREE ); + PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, FLOATING_POINT_PIXEL_FORMATS[index], PixelData::FREE ); texture.Upload( pixelData ); application.SendNotification(); application.Render(); diff --git a/dali/devel-api/CMakeLists.txt b/dali/devel-api/CMakeLists.txt index 0bdfd9a..bcded75 100644 --- a/dali/devel-api/CMakeLists.txt +++ b/dali/devel-api/CMakeLists.txt @@ -50,7 +50,6 @@ SET( DEVEL_API_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/images/nine-patch-image.h ${CMAKE_CURRENT_SOURCE_DIR}/images/texture-set-image.h ${CMAKE_CURRENT_SOURCE_DIR}/images/pixel-data-devel.h - ${CMAKE_CURRENT_SOURCE_DIR}/images/pixel-devel.h ${CMAKE_CURRENT_SOURCE_DIR}/object/csharp-type-info.h ${CMAKE_CURRENT_SOURCE_DIR}/object/csharp-type-registry.h diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 4a5d6eb..85ddc1e 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -53,8 +53,7 @@ devel_api_core_images_header_files = \ $(devel_api_src_dir)/images/native-image-interface-extension.h \ $(devel_api_src_dir)/images/nine-patch-image.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-devel.h + $(devel_api_src_dir)/images/pixel-data-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 index bd2036c..41dafa3 100644 --- a/dali/devel-api/images/pixel-data-devel.cpp +++ b/dali/devel-api/images/pixel-data-devel.cpp @@ -27,17 +27,6 @@ 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 = Internal::PixelData::New( buffer, bufferSize, width, height, static_cast( pixelFormat ), releaseFunction ); - return PixelData( internal.Get() ); -} - PixelDataBuffer ReleasePixelDataBuffer( PixelData& pixelData ) { Internal::PixelData& pixelDataImpl = GetImplementation( pixelData ); diff --git a/dali/devel-api/images/pixel-data-devel.h b/dali/devel-api/images/pixel-data-devel.h index a3b1f97..506efb7 100644 --- a/dali/devel-api/images/pixel-data-devel.h +++ b/dali/devel-api/images/pixel-data-devel.h @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include namespace Dali { @@ -31,24 +31,6 @@ namespace DevelPixelData { /** - * @brief Creates a PixelData object, using development pixel formats - * - * @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 ); - -/** * Struct to keep the buffer pointer and the allocation method. * * @note Need to find a better solution - one library should not diff --git a/dali/devel-api/images/pixel-devel.h b/dali/devel-api/images/pixel-devel.h deleted file mode 100644 index e93e129..0000000 --- a/dali/devel-api/images/pixel-devel.h +++ /dev/null @@ -1,104 +0,0 @@ -#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 - -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 diff --git a/dali/integration-api/bitmap.cpp b/dali/integration-api/bitmap.cpp index 50c77c8..373af9c 100644 --- a/dali/integration-api/bitmap.cpp +++ b/dali/integration-api/bitmap.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -408,6 +408,22 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i break; } + // GLES 3.0 floating point formats. + case RGB16F: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); + pixelDataType = GL_HALF_FLOAT; + internalFormat= GL_RGB; + break; + } + case RGB32F: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); + pixelDataType = GL_FLOAT; + internalFormat= GL_RGB; + break; + } + case INVALID: { DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" ); diff --git a/dali/internal/event/images/nine-patch-image-impl.cpp b/dali/internal/event/images/nine-patch-image-impl.cpp index 24b5e6f..b43d818 100644 --- a/dali/internal/event/images/nine-patch-image-impl.cpp +++ b/dali/internal/event/images/nine-patch-image-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -147,6 +147,15 @@ void GetRedOffsetAndMask(Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask=0; break; } + + case Dali::Pixel::RGB16F: + case Dali::Pixel::RGB32F: + { + DALI_LOG_ERROR("Pixel format not compatible.\n"); + byteOffset=0; + bitMask=0; + break; + } } } diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index 572e4f2..7e0af70 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -21,7 +21,6 @@ #include //floor, log2 // INTERNAL INCLUDES -#include #include namespace Dali @@ -130,7 +129,7 @@ GLint WrapModeToGL( WrapMode::Type wrapMode, GLint defaultWrapMode ) * @param[out] glInternalFormat The gl internal format. * @param[out] pixelDataType The data type of the pixel data. */ -void PixelFormatToGl( DevelPixel::Format pixelFormat, GLenum& glFormat, GLint& glInternalFormat, GLenum& pixelDataType ) +void PixelFormatToGl( Pixel::Format pixelFormat, GLenum& glFormat, GLint& glInternalFormat, GLenum& pixelDataType ) { // Compressed textures have no pixelDataType, so init to an invalid value: pixelDataType = -1; @@ -505,13 +504,13 @@ void PixelFormatToGl( DevelPixel::Format pixelFormat, GLenum& glFormat, GLint& g } // GLES 3.0 floating point formats. - case DevelPixel::RGB16F: + case Pixel::RGB16F: { glFormat = GL_RGB; pixelDataType = GL_HALF_FLOAT; break; } - case DevelPixel::RGB32F: + case Pixel::RGB32F: { glFormat = GL_RGB; pixelDataType = GL_FLOAT; @@ -528,8 +527,8 @@ void PixelFormatToGl( DevelPixel::Format pixelFormat, GLenum& glFormat, GLint& g switch( pixelFormat ) { - case DevelPixel::RGB16F: - case DevelPixel::RGB32F: // FALL THROUGH + case Pixel::RGB16F: + case Pixel::RGB32F: // FALL THROUGH { glInternalFormat = GL_R11F_G11F_B10F; break; @@ -567,6 +566,8 @@ bool IsCompressedFormat(Pixel::Format pixelFormat) case Pixel::BGR8888: case Pixel::RGBA8888: case Pixel::BGRA8888: + case Pixel::RGB16F: + case Pixel::RGB32F: case Pixel::INVALID: { return false; @@ -638,7 +639,7 @@ Texture::Texture( Type type, Pixel::Format format, ImageDimensions size ) mHasAlpha( HasAlpha( format ) ), mIsCompressed( IsCompressedFormat( format ) ) { - PixelFormatToGl( static_cast( format ), + PixelFormatToGl( format, mGlFormat, mGlInternalFormat, mPixelDataType ); @@ -772,7 +773,7 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal:: GLenum glFormat; GLint glInternalFormat; GLenum pixelDataElementType; - PixelFormatToGl( static_cast( pixelData->GetPixelFormat() ), glFormat, glInternalFormat, 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 diff --git a/dali/public-api/images/pixel.cpp b/dali/public-api/images/pixel.cpp index 276e1c4..725d9e0 100644 --- a/dali/public-api/images/pixel.cpp +++ b/dali/public-api/images/pixel.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -89,6 +89,8 @@ bool Pixel::HasAlpha(Format pixelformat) case COMPRESSED_SRGB8_ETC2: case COMPRESSED_RGB8_ETC1: case COMPRESSED_RGB_PVRTC_4BPPV1: + case RGB16F: + case RGB32F: case INVALID: { return false; @@ -131,6 +133,16 @@ unsigned int Pixel::GetBytesPerPixel(Format pixelFormat) return 4; } + case RGB16F: + { + return 12; + } + + case RGB32F: + { + return 24; + } + case COMPRESSED_R11_EAC: case COMPRESSED_SIGNED_R11_EAC: case COMPRESSED_RG11_EAC: @@ -274,6 +286,8 @@ 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 RGB16F: + case RGB32F: case INVALID: { DALI_LOG_ERROR("Pixel formats for compressed images are not compatible with simple masking-out of per-pixel alpha.\n"); diff --git a/dali/public-api/images/pixel.h b/dali/public-api/images/pixel.h index afd9760..49abf46 100644 --- a/dali/public-api/images/pixel.h +++ b/dali/public-api/images/pixel.h @@ -2,7 +2,7 @@ #define __DALI_PIXEL_H__ /* - * 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. @@ -107,6 +107,10 @@ enum Format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 12x10 block-size. @SINCE_1_1.17 COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 12x12 block-size. @SINCE_1_1.17 + // GLES 3.0 floating point formats. + RGB16F, ///< Color depth 48-bit, 16-16-16 half floating point. @SINCE_1_2.60 + RGB32F, ///< Color depth 96-bit, 32-32-32 floating point. @SINCE_1_2.60 + ///! Update LAST_VALID_PIXEL_FORMAT below if you add an enum value here. }; @@ -122,7 +126,7 @@ const Format FIRST_VALID_PIXEL_FORMAT = A8; * * Sync it to the last value above. */ -const Format LAST_VALID_PIXEL_FORMAT = COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; +const Format LAST_VALID_PIXEL_FORMAT = RGB32F; /** * @brief Whether specified pixel format contains an alpha value. -- 2.7.4