From: Heeyong Song Date: Thu, 14 Apr 2022 09:24:14 +0000 (+0900) Subject: Add CHROMINANCE pixel format X-Git-Tag: dali_2.1.19~3^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=e9a4c4232f585c546e081a10f703fae17bde6d54 Add CHROMINANCE pixel format Change-Id: I6c66da9db49874c7273e2580964423dc23c36e90 --- diff --git a/automated-tests/src/dali/utc-Dali-Pixel.cpp b/automated-tests/src/dali/utc-Dali-Pixel.cpp index cd94b61..6eb1948 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) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -49,7 +49,7 @@ int UtcDaliPixelHasAlpha(void) tet_infoline("UtcDaliPixelHasAlpha"); - TestPixelEnumSize(60); + TestPixelEnumSize(62); DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::INVALID) == false); // For completeness @@ -119,6 +119,9 @@ int UtcDaliPixelHasAlpha(void) DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::R11G11B10F) == false); + DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::CHROMINANCE_U) == false); + DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::CHROMINANCE_V) == false); + END_TEST; } @@ -135,7 +138,7 @@ int UtcDaliPixelGetBytesPerPixel(void) tet_infoline("UtcDaliPixelGetBytesPerPixel"); // Be sure that the number of cases tested below is correct: - TestPixelEnumSize(60); + TestPixelEnumSize(62); DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::INVALID) == 0); // For completeness @@ -208,6 +211,10 @@ int UtcDaliPixelGetBytesPerPixel(void) DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::DEPTH_FLOAT) == 4); DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::DEPTH_STENCIL) == 4); DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::R11G11B10F) == 4); + + DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::CHROMINANCE_U) == 1); + DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::CHROMINANCE_V) == 1); + END_TEST; } @@ -227,7 +234,7 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void) int bitMask = 0; // Be sure that the number of cases tested below is correct: - TestPixelEnumSize(60); + TestPixelEnumSize(62); Pixel::GetAlphaOffsetAndMask(Pixel::INVALID, byteOffset, bitMask); // For completeness DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0); @@ -357,6 +364,11 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void) Pixel::GetAlphaOffsetAndMask(Pixel::R11G11B10F, byteOffset, bitMask); DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::CHROMINANCE_U, byteOffset, bitMask); + DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::CHROMINANCE_V, byteOffset, bitMask); + DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0); + END_TEST; } @@ -380,6 +392,15 @@ int UtcDaliPixelConvertGlFormat(void) Dali::Integration::ConvertToGlFormat(Pixel::Format::R11G11B10F, pixelDataType, internalFormat); DALI_TEST_CHECK(pixelDataType == GL_FLOAT); DALI_TEST_CHECK(internalFormat == GL_R11F_G11F_B10F); + + Dali::Integration::ConvertToGlFormat(Pixel::Format::CHROMINANCE_U, pixelDataType, internalFormat); + DALI_TEST_CHECK(pixelDataType == GL_UNSIGNED_BYTE); + DALI_TEST_CHECK(internalFormat == GL_LUMINANCE); + + Dali::Integration::ConvertToGlFormat(Pixel::Format::CHROMINANCE_V, pixelDataType, internalFormat); + DALI_TEST_CHECK(pixelDataType == GL_UNSIGNED_BYTE); + DALI_TEST_CHECK(internalFormat == GL_LUMINANCE); + END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Texture.cpp b/automated-tests/src/dali/utc-Dali-Texture.cpp index acac5fd..650fd8b 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) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -685,7 +685,8 @@ int UtcDaliTextureUploadPixelFormats(void) Pixel::RGB16F, Pixel::RGB32F, Pixel::R11G11B10F, - }; + Pixel::CHROMINANCE_U, + Pixel::CHROMINANCE_V}; for(auto format : formats) { diff --git a/dali/integration-api/bitmap.cpp b/dali/integration-api/bitmap.cpp index 4491800..70db04b 100644 --- a/dali/integration-api/bitmap.cpp +++ b/dali/integration-api/bitmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -450,6 +450,20 @@ void ConvertToGlFormat(Format pixelformat, unsigned& pixelDataType, unsigned& in break; } + // Chrominance formats + case Pixel::CHROMINANCE_U: + { + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_LUMINANCE; // GL doesn't support chrominance format. We should convert it in the shader. + break; + } + case Pixel::CHROMINANCE_V: + { + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_LUMINANCE; // GL doesn't support chrominance format. We should convert it in the shader. + break; + } + case INVALID: { DALI_LOG_ERROR("Invalid pixel format for bitmap\n"); diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index 8887251..b0fca79 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -148,7 +148,6 @@ constexpr Graphics::Format ConvertPixelFormat(Pixel::Format format) case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR: return Graphics::Format::ASTC_12x12_UNORM_BLOCK; case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - return Graphics::Format::ASTC_4x4_SRGB_BLOCK; // not type with alpha, but likely to use SRGB case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: return Graphics::Format::ASTC_5x4_SRGB_BLOCK; @@ -176,12 +175,18 @@ constexpr Graphics::Format ConvertPixelFormat(Pixel::Format format) return Graphics::Format::ASTC_12x10_SRGB_BLOCK; case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return Graphics::Format::ASTC_12x12_SRGB_BLOCK; + case Pixel::RGB16F: return Graphics::Format::R16G16B16_SFLOAT; case Pixel::RGB32F: return Graphics::Format::R32G32B32_SFLOAT; case Pixel::R11G11B10F: return Graphics::Format::R11G11B10_UFLOAT_PACK32; + + case Pixel::CHROMINANCE_U: + return Graphics::Format::L8; + case Pixel::CHROMINANCE_V: + return Graphics::Format::L8; } return Graphics::Format::UNDEFINED; } diff --git a/dali/public-api/images/pixel.cpp b/dali/public-api/images/pixel.cpp index 1571166..90985a4 100644 --- a/dali/public-api/images/pixel.cpp +++ b/dali/public-api/images/pixel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -95,6 +95,8 @@ bool Pixel::HasAlpha(Format pixelformat) case DEPTH_STENCIL: case R11G11B10F: case INVALID: + case CHROMINANCE_U: + case CHROMINANCE_V: { return false; } @@ -108,6 +110,8 @@ uint32_t Pixel::GetBytesPerPixel(Format pixelFormat) { case L8: case A8: + case CHROMINANCE_U: + case CHROMINANCE_V: { return 1; } @@ -299,6 +303,8 @@ void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitM case DEPTH_FLOAT: case DEPTH_STENCIL: case R11G11B10F: + case CHROMINANCE_U: + case CHROMINANCE_V: case INVALID: { DALI_LOG_ERROR("Pixel formats 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 5c25141..d62907d 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) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -119,7 +119,10 @@ enum Format DEPTH_STENCIL, ///< Depth stencil 32-bit, 24 bit for depth, 8 bit for stencil. @SINCE_1_9.9 - R11G11B10F ///< Packed 32-bit, 11-11-10 unsigned floating point. + R11G11B10F, ///< Packed 32-bit, 11-11-10 unsigned floating point. + + CHROMINANCE_U, ///< Color depth 8-bit, chrominance U + CHROMINANCE_V ///< Color depth 8-bit, chrominance V ///! Update LAST_VALID_PIXEL_FORMAT below if you add an enum value here. }; @@ -135,7 +138,7 @@ const Format FIRST_VALID_PIXEL_FORMAT = A8; * * Sync it to the last value above. */ -const Format LAST_VALID_PIXEL_FORMAT = R11G11B10F; +const Format LAST_VALID_PIXEL_FORMAT = CHROMINANCE_V; /** * @brief Whether specified pixel format contains an alpha value.