From e12e3567121d07d92b18f0ce8aab3a2785402b6c Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Mon, 22 Jun 2020 17:36:17 +0900 Subject: [PATCH 01/16] Add npatch utility Change-Id: I31cece8e4a1f85c515038f66a9afa3b697e7a112 --- .../utc-Dali-Visuals-internal.cpp | 140 --------- automated-tests/src/dali-toolkit/CMakeLists.txt | 1 + .../src/dali-toolkit/utc-Dali-NPatchUtilities.cpp | 302 ++++++++++++++++++++ .../src/dali-toolkit/utc-Dali-VisualFactory.cpp | 3 +- dali-toolkit/devel-api/file.list | 6 + .../devel-api/utility/npatch-utilities.cpp | 317 +++++++++++++++++++++ dali-toolkit/devel-api/utility/npatch-utilities.h | 75 +++++ dali-toolkit/internal/visuals/npatch-loader.cpp | 224 +-------------- dali-toolkit/internal/visuals/npatch-loader.h | 17 +- .../internal/visuals/npatch/npatch-visual.cpp | 8 +- 10 files changed, 715 insertions(+), 378 deletions(-) create mode 100644 automated-tests/src/dali-toolkit/utc-Dali-NPatchUtilities.cpp create mode 100644 dali-toolkit/devel-api/utility/npatch-utilities.cpp create mode 100644 dali-toolkit/devel-api/utility/npatch-utilities.h diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp index d20cbcf..d607e33 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include <../dali-toolkit/dali-toolkit-test-utils/dummy-control.h> #include @@ -161,145 +160,6 @@ int UtcDaliVisualSetProperties(void) END_TEST; } -int UtcDaliNPatchBufferGetRedOffsetAndMask(void) -{ - TestApplication application; - - tet_infoline("UtcDaliNPatchBufferGetRedOffsetAndMask"); - - int byteOffset = 0; - int bitMask = 0; - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::A8, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::L8, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::LA88, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGB888, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGB8888, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGBA8888, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::BGR8888, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 2 && bitMask == 0xff ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::BGRA8888, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 2 && bitMask == 0xff ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGB565, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xf8 ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::BGR565, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x1f ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGBA4444, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xf0 ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::BGRA4444, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0xf0 ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGBA5551, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xf8 ); - - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::BGRA5551, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x1e ); - - // Compressed formats are not supported - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::INVALID, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_R11_EAC, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SIGNED_R11_EAC, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RG11_EAC, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SIGNED_RG11_EAC, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB8_ETC2, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ETC2, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB8_ETC1, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB_PVRTC_4BPPV1, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA8_ETC2_EAC, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - - // Not supported - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGB16F, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - Toolkit::Internal::NPatchBuffer::GetRedOffsetAndMask( Pixel::RGB32F, byteOffset, bitMask ); - DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); - - END_TEST; -} - int UtcDaliAnimatedVectorImageVisualCreateInstancePropertyMap(void) { ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 849bf3a..1488b2c 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -71,6 +71,7 @@ SET(TC_SOURCES utc-Dali-SyncImageLoader.cpp utc-Dali-ControlWrapper.cpp utc-Dali-DragAndDropDetector.cpp + utc-Dali-NPatchUtilities.cpp ) # Append list of test harness files (Won't get parsed for test cases) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-NPatchUtilities.cpp b/automated-tests/src/dali-toolkit/utc-Dali-NPatchUtilities.cpp new file mode 100644 index 0000000..64f57d5 --- /dev/null +++ b/automated-tests/src/dali-toolkit/utc-Dali-NPatchUtilities.cpp @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2020 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. + */ + +#include +#include +#include +#include +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ + +void InitialiseRegionsToZeroAlpha( Dali::Devel::PixelBuffer pixelBuffer, uint32_t width, uint32_t height, Pixel::Format pixelFormat ) +{ + unsigned char* buffer = pixelBuffer.GetBuffer(); + uint32_t bytesPerPixel = GetBytesPerPixel( pixelFormat ); + + for( uint32_t row = 0; row < width; ++row ) + { + uint32_t pixelOffset = row * bytesPerPixel; + buffer[ pixelOffset + 3 ] = 0x00; + pixelOffset += ( height - 1 ) * width * bytesPerPixel; + buffer[ pixelOffset + 3 ] = 0x00; + } + + for( unsigned int column = 0; column < height; ++column ) + { + uint32_t pixelOffset = column * width * bytesPerPixel; + buffer[ pixelOffset + 3 ] = 0x00; + pixelOffset += ( width -1 ) * bytesPerPixel; + buffer[ pixelOffset + 3 ] = 0x00; + } +} + +void AddStretchRegionsToImage( Dali::Devel::PixelBuffer pixelBuffer, uint32_t width, uint32_t height, const Vector4& requiredStretchBorder, Pixel::Format pixelFormat ) +{ + unsigned char* buffer = pixelBuffer.GetBuffer(); + uint32_t bytesPerPixel = GetBytesPerPixel( pixelFormat ); + + for( uint32_t column = requiredStretchBorder.x; column < width - requiredStretchBorder.z; ++column ) + { + uint32_t pixelOffset = column * bytesPerPixel; + buffer[ pixelOffset ] = 0x00; + buffer[ pixelOffset + 1 ] = 0x00; + buffer[ pixelOffset + 2 ] = 0x00; + buffer[ pixelOffset + 3 ] = 0xFF; + } + + for( uint32_t row = requiredStretchBorder.y; row < height - requiredStretchBorder.w; ++row ) + { + unsigned int pixelOffset = row * width * bytesPerPixel; + buffer[ pixelOffset ] = 0x00; + buffer[ pixelOffset + 1 ] = 0x00; + buffer[ pixelOffset + 2 ] = 0x00; + buffer[ pixelOffset + 3 ] = 0xFF; + } +} + +Dali::Devel::PixelBuffer CustomizeNPatch( uint32_t width, uint32_t height, const Vector4& requiredStretchBorder ) +{ + Pixel::Format pixelFormat = Pixel::RGBA8888; + Dali::Devel::PixelBuffer pixelBuffer = Dali::Devel::PixelBuffer::New( width, height, pixelFormat ); + + unsigned char* buffer = pixelBuffer.GetBuffer(); + memset( buffer, 0, width * height * Dali::Pixel::GetBytesPerPixel( pixelFormat ) ); + + InitialiseRegionsToZeroAlpha( pixelBuffer, width, height, pixelFormat ); + + AddStretchRegionsToImage( pixelBuffer, width, height, requiredStretchBorder, pixelFormat ); + + return pixelBuffer; +} + +} //namespace + +void dali_npatch_utilities_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void dali_npatch_utilities_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliNPatchUtilityGetRedOffsetAndMask(void) +{ + TestApplication application; + + tet_infoline("UtcDaliNPatchUtilityGetRedOffsetAndMask"); + + int32_t byteOffset = 0; + int32_t bitMask = 0; + + NPatchUtility::GetRedOffsetAndMask( Pixel::A8, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::L8, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::LA88, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::RGB888, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff ); + NPatchUtility::GetRedOffsetAndMask( Pixel::RGB8888, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff ); + NPatchUtility::GetRedOffsetAndMask( Pixel::RGBA8888, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::BGR8888, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 2 && bitMask == 0xff ); + NPatchUtility::GetRedOffsetAndMask( Pixel::BGRA8888, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 2 && bitMask == 0xff ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::RGB565, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xf8 ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::BGR565, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x1f ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::RGBA4444, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xf0 ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::BGRA4444, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0xf0 ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::RGBA5551, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xf8 ); + + NPatchUtility::GetRedOffsetAndMask( Pixel::BGRA5551, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x1e ); + + // Compressed formats are not supported + NPatchUtility::GetRedOffsetAndMask( Pixel::INVALID, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_R11_EAC, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SIGNED_R11_EAC, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RG11_EAC, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SIGNED_RG11_EAC, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB8_ETC2, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ETC2, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB8_ETC1, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB_PVRTC_4BPPV1, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA8_ETC2_EAC, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + + // Not supported + NPatchUtility::GetRedOffsetAndMask( Pixel::RGB16F, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + NPatchUtility::GetRedOffsetAndMask( Pixel::RGB32F, byteOffset, bitMask ); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0 ); + + END_TEST; +} + +int UtcDaliNPatchUtilityParseBorders(void) +{ + TestApplication application; + tet_infoline("UtcDaliNPatchUtilityParseBorders"); + + /* Stretch region left(2) top(2) right (2) bottom (2) + * ss + * OOOOOO + * OOOOOOc + * sOOooOOc + * sOOooOOc + * OOOOOOc + * OOOOOO + * cccc + */ + + const unsigned int imageHeight = 18; + const unsigned int imageWidth = 28; + const Vector4 requiredStretchBorder( 3, 4, 5, 6 ); + + Dali::Devel::PixelBuffer pixelBuffer = CustomizeNPatch( imageHeight, imageWidth, requiredStretchBorder ); + DALI_TEST_CHECK( pixelBuffer ); + + if( pixelBuffer ) + { + NPatchUtility::StretchRanges stretchPixelsX; + NPatchUtility::StretchRanges stretchPixelsY; + + NPatchUtility::ParseBorders( pixelBuffer, stretchPixelsX, stretchPixelsY ); + + DALI_TEST_CHECK( stretchPixelsX.Size() == 1 ); + DALI_TEST_CHECK( stretchPixelsY.Size() == 1 ); + + Vector4 stretchBorders; + //The NPatch image stretch pixels are in the cropped image space, inset by 1 to get it to uncropped image space + stretchBorders.x = stretchPixelsX[ 0 ].GetX() + 1; + stretchBorders.y = stretchPixelsY[ 0 ].GetX() + 1; + stretchBorders.z = imageHeight - stretchPixelsX[ 0 ].GetY() - 1; + stretchBorders.w = imageWidth - stretchPixelsY[ 0 ].GetY() - 1; + + DALI_TEST_EQUALS( stretchBorders, requiredStretchBorder, 0.001, TEST_LOCATION ); + } + else + { + test_return_value = TET_FAIL; + } + + END_TEST; +} + +int UtcDaliNPatchUtilityIsNinePatchUrl(void) +{ + tet_infoline( "UtcDaliNPatchUtilityIsNinePatchUrl" ); + + DALI_TEST_CHECK( NPatchUtility::IsNinePatchUrl( "test.9.jpg" ) ); + DALI_TEST_CHECK( NPatchUtility::IsNinePatchUrl( "test.#.jpg" ) ); + DALI_TEST_CHECK( !NPatchUtility::IsNinePatchUrl( "test.9" ) ); + DALI_TEST_CHECK( !NPatchUtility::IsNinePatchUrl( "test.#" ) ); + DALI_TEST_CHECK( !NPatchUtility::IsNinePatchUrl( "test" ) ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index 513e132..b4c4f3f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "dummy-control.h" #include @@ -33,7 +34,7 @@ using namespace Dali::Toolkit; namespace { -typedef Toolkit::Internal::NPatchLoader::StretchRanges StretchRanges; +typedef Toolkit::NPatchUtility::StretchRanges StretchRanges; const char* TEST_9_PATCH_FILE_NAME = TEST_RESOURCE_DIR "/demo-tile-texture-focused.9.png"; const char* TEST_NPATCH_FILE_NAME = TEST_RESOURCE_DIR "/heartsframe.9.png"; diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 5eb6d82..36f0649 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -47,6 +47,7 @@ SET( devel_api_src_files ${devel_api_src_dir}/transition-effects/cube-transition-effect.cpp ${devel_api_src_dir}/transition-effects/cube-transition-fold-effect.cpp ${devel_api_src_dir}/transition-effects/cube-transition-wave-effect.cpp + ${devel_api_src_dir}/utility/npatch-utilities.cpp ${devel_api_src_dir}/visual-factory/transition-data.cpp ${devel_api_src_dir}/visual-factory/visual-factory.cpp ${devel_api_src_dir}/visual-factory/visual-base.cpp @@ -223,6 +224,10 @@ SET( devel_api_drag_and_drop_detector_header_files ${devel_api_src_dir}/drag-drop-detector/drag-and-drop-detector.h ) +SET( devel_api_utility_header_files + ${devel_api_src_dir}/utility/npatch-utilities.h +) + SET( SOURCES ${SOURCES} ${devel_api_src_files} ) @@ -259,4 +264,5 @@ SET( DEVEL_API_HEADERS ${DEVEL_API_HEADERS} ${devel_api_video_view_header_files} ${devel_api_web_view_header_files} ${devel_api_drag_and_drop_detector_header_files} + ${devel_api_utility_header_files} ) diff --git a/dali-toolkit/devel-api/utility/npatch-utilities.cpp b/dali-toolkit/devel-api/utility/npatch-utilities.cpp new file mode 100644 index 0000000..a8b6e32 --- /dev/null +++ b/dali-toolkit/devel-api/utility/npatch-utilities.cpp @@ -0,0 +1,317 @@ +/* +* Copyright (c) 2020 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. +* +*/ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace NPatchUtility +{ + +namespace +{ + +Uint16Pair ParseRange( uint32_t& index, uint32_t width, uint8_t*& pixel, uint32_t pixelStride, int32_t testByte, int32_t testBits, int32_t testValue ) +{ + unsigned int start = 0xFFFF; + for( ; index < width; ++index, pixel += pixelStride ) + { + if( ( pixel[ testByte ] & testBits ) == testValue ) + { + start = index; + ++index; + pixel += pixelStride; + break; + } + } + + unsigned int end = width; + for( ; index < width; ++index, pixel += pixelStride ) + { + if( ( pixel[ testByte ] & testBits ) != testValue ) + { + end = index; + ++index; + pixel += pixelStride; + break; + } + } + + return Uint16Pair( start, end ); +} + +} // unnamed namespace + +void GetRedOffsetAndMask( Dali::Pixel::Format pixelFormat, int32_t& byteOffset, int32_t& bitMask ) +{ + switch( pixelFormat ) + { + case Dali::Pixel::A8: + case Dali::Pixel::L8: + case Dali::Pixel::LA88: + { + byteOffset = 0; + bitMask = 0; + break; + } + case Dali::Pixel::RGB888: + case Dali::Pixel::RGB8888: + case Dali::Pixel::RGBA8888: + { + byteOffset = 0; + bitMask = 0xFF; + break; + } + case Dali::Pixel::BGR8888: + case Dali::Pixel::BGRA8888: + { + byteOffset = 2; + bitMask = 0xff; + break; + } + case Dali::Pixel::RGB565: + { + byteOffset = 0; + bitMask = 0xf8; + break; + } + case Dali::Pixel::BGR565: + { + byteOffset = 1; + bitMask = 0x1f; + break; + } + case Dali::Pixel::RGBA4444: + { + byteOffset = 0; + bitMask = 0xf0; + break; + } + case Dali::Pixel::BGRA4444: + { + byteOffset = 1; + bitMask = 0xf0; + break; + } + case Dali::Pixel::RGBA5551: + { + byteOffset = 0; + bitMask = 0xf8; + break; + } + case Dali::Pixel::BGRA5551: + { + byteOffset = 1; + bitMask = 0x1e; + break; + } + case Dali::Pixel::INVALID: + case Dali::Pixel::COMPRESSED_R11_EAC: + case Dali::Pixel::COMPRESSED_SIGNED_R11_EAC: + case Dali::Pixel::COMPRESSED_RG11_EAC: + case Dali::Pixel::COMPRESSED_SIGNED_RG11_EAC: + case Dali::Pixel::COMPRESSED_RGB8_ETC2: + case Dali::Pixel::COMPRESSED_SRGB8_ETC2: + case Dali::Pixel::COMPRESSED_RGB8_ETC1: + case Dali::Pixel::COMPRESSED_RGB_PVRTC_4BPPV1: + case Dali::Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case Dali::Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case Dali::Pixel::COMPRESSED_RGBA8_ETC2_EAC: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR: + case Dali::Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + { + DALI_LOG_ERROR("Pixel formats for compressed images are not compatible with simple masking-out of per-pixel alpha.\n"); + byteOffset=0; + bitMask=0; + break; + } + case Dali::Pixel::RGB16F: + case Dali::Pixel::RGB32F: + case Dali::Pixel::DEPTH_UNSIGNED_INT: + case Dali::Pixel::DEPTH_FLOAT: + case Dali::Pixel::DEPTH_STENCIL: + { + DALI_LOG_ERROR("Pixel format not compatible.\n"); + byteOffset=0; + bitMask=0; + break; + } + } +} + +void ParseBorders( Devel::PixelBuffer& pixelBuffer, StretchRanges& stretchPixelsX, StretchRanges& stretchPixelsY ) +{ + stretchPixelsX.Clear(); + stretchPixelsY.Clear(); + + Pixel::Format pixelFormat = pixelBuffer.GetPixelFormat(); + + int32_t alphaByte = 0; + int32_t alphaBits = 0; + Pixel::GetAlphaOffsetAndMask( pixelFormat, alphaByte, alphaBits ); + + int32_t testByte = alphaByte; + int32_t testBits = alphaBits; + int32_t testValue = alphaBits; // Opaque == stretch + if( !alphaBits ) + { + GetRedOffsetAndMask( pixelFormat, testByte, testBits ); + testValue = 0; // Black == stretch + } + + uint32_t bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat ); + uint32_t width = pixelBuffer.GetWidth(); + uint32_t height = pixelBuffer.GetHeight(); + uint8_t* srcPixels = pixelBuffer.GetBuffer(); + uint32_t srcStride = width * bytesPerPixel; + + // TOP + uint8_t* top = srcPixels + bytesPerPixel; + uint32_t index = 0; + + for( ; index < width - 2; ) + { + Uint16Pair range = ParseRange( index, width - 2, top, bytesPerPixel, testByte, testBits, testValue ); + if( range.GetX() != 0xFFFF ) + { + stretchPixelsX.PushBack( range ); + } + } + + // LEFT + uint8_t* left = srcPixels + srcStride; + index = 0; + for( ; index < height - 2; ) + { + Uint16Pair range = ParseRange( index, height - 2, left, srcStride, testByte, testBits, testValue ); + if( range.GetX() != 0xFFFF ) + { + stretchPixelsY.PushBack( range ); + } + } + + // If there are no stretch pixels then make the entire image stretchable + if( stretchPixelsX.Size() == 0 ) + { + stretchPixelsX.PushBack( Uint16Pair( 0, width - 2 ) ); + } + if( stretchPixelsY.Size() == 0 ) + { + stretchPixelsY.PushBack( Uint16Pair( 0, height - 2 ) ); + } +} + +bool IsNinePatchUrl( const std::string& url ) +{ + bool match = false; + + std::string::const_reverse_iterator iter = url.rbegin(); + enum { SUFFIX, HASH, HASH_DOT, DONE } state = SUFFIX; + while(iter < url.rend()) + { + switch(state) + { + case SUFFIX: + { + if(*iter == '.') + { + state = HASH; + } + else if(!isalnum(*iter)) + { + state = DONE; + } + } + break; + case HASH: + { + if( *iter == '#' || *iter == '9' ) + { + state = HASH_DOT; + } + else + { + state = DONE; + } + } + break; + case HASH_DOT: + { + if(*iter == '.') + { + match = true; + } + state = DONE; // Stop testing characters + } + break; + case DONE: + { + } + break; + } + + // Satisfy prevent + if( state == DONE ) + { + break; + } + + ++iter; + } + return match; +} + +} // namespace NPatchBuffer + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/utility/npatch-utilities.h b/dali-toolkit/devel-api/utility/npatch-utilities.h new file mode 100644 index 0000000..c85e6cd --- /dev/null +++ b/dali-toolkit/devel-api/utility/npatch-utilities.h @@ -0,0 +1,75 @@ +#ifndef DALI_TOOLKIT_NPATCH_UTILITIES_H +#define DALI_TOOLKIT_NPATCH_UTILITIES_H + +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace NPatchUtility +{ + +/** + * The list that includes stretch pixel ranges + */ +using StretchRanges = Dali::Vector< Uint16Pair >; + +/** + * @brief Get the offset of the red channel for the format. + * + * @param[in] pixelFormat The pixel format + * @param[out] byteOffset The byte offset of the red channel. + * @param[out] bitMask The bit mask of the red channel. + */ +DALI_TOOLKIT_API void GetRedOffsetAndMask( Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask ); + +/** + * @brief Read the borders of the buffer and determine the child area and stretch borders. + * + * @param[in] pixelBuffer The npatch image buffer. + * @param[out] stretchPixelsX The horizontal stretchable pixels in the cropped image space. + * @param[out] stretchPixelsY The vertical stretchable pixels in the cropped image space. + */ +DALI_TOOLKIT_API void ParseBorders( Devel::PixelBuffer& pixelBuffer, StretchRanges& stretchPixelsX, StretchRanges& stretchPixelsY ); + +/** + * @brief Helper method to determine if the filename indicates that the image has a 9 patch or n patch border. + * + * @param [in] url The URL of the image file. + * @return true if it is a 9 patch or n patch image + */ +DALI_TOOLKIT_API bool IsNinePatchUrl( const std::string& url ); + +} // namespace NPatchUtility + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_NPATCH_UTILITIES_H diff --git a/dali-toolkit/internal/visuals/npatch-loader.cpp b/dali-toolkit/internal/visuals/npatch-loader.cpp index 0c6409d..d4a1f0e 100644 --- a/dali-toolkit/internal/visuals/npatch-loader.cpp +++ b/dali-toolkit/internal/visuals/npatch-loader.cpp @@ -18,8 +18,7 @@ // CLASS HEADER #include -// EXTERNAL HEADER -#include +// EXTERNAL INCLUDES #include #include @@ -35,226 +34,11 @@ namespace Internal namespace NPatchBuffer { -void GetRedOffsetAndMask( Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask ) -{ - switch( pixelFormat ) - { - case Dali::Pixel::A8: - case Dali::Pixel::L8: - case Dali::Pixel::LA88: - { - byteOffset = 0; - bitMask = 0; - break; - } - case Dali::Pixel::RGB888: - case Dali::Pixel::RGB8888: - case Dali::Pixel::RGBA8888: - { - byteOffset = 0; - bitMask = 0xFF; - break; - } - case Dali::Pixel::BGR8888: - case Dali::Pixel::BGRA8888: - { - byteOffset = 2; - bitMask = 0xff; - break; - } - case Dali::Pixel::RGB565: - { - byteOffset = 0; - bitMask = 0xf8; - break; - } - case Dali::Pixel::BGR565: - { - byteOffset = 1; - bitMask = 0x1f; - break; - } - case Dali::Pixel::RGBA4444: - { - byteOffset = 0; - bitMask = 0xf0; - break; - } - case Dali::Pixel::BGRA4444: - { - byteOffset = 1; - bitMask = 0xf0; - break; - } - case Dali::Pixel::RGBA5551: - { - byteOffset = 0; - bitMask = 0xf8; - break; - } - case Dali::Pixel::BGRA5551: - { - byteOffset = 1; - bitMask = 0x1e; - break; - } - case Dali::Pixel::INVALID: - case Dali::Pixel::COMPRESSED_R11_EAC: - case Dali::Pixel::COMPRESSED_SIGNED_R11_EAC: - case Dali::Pixel::COMPRESSED_RG11_EAC: - case Dali::Pixel::COMPRESSED_SIGNED_RG11_EAC: - case Dali::Pixel::COMPRESSED_RGB8_ETC2: - case Dali::Pixel::COMPRESSED_SRGB8_ETC2: - case Dali::Pixel::COMPRESSED_RGB8_ETC1: - case Dali::Pixel::COMPRESSED_RGB_PVRTC_4BPPV1: - case Dali::Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case Dali::Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case Dali::Pixel::COMPRESSED_RGBA8_ETC2_EAC: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR: - case Dali::Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - case Dali::Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - { - DALI_LOG_ERROR("Pixel formats for compressed images are not compatible with simple masking-out of per-pixel alpha.\n"); - byteOffset=0; - bitMask=0; - break; - } - case Dali::Pixel::RGB16F: - case Dali::Pixel::RGB32F: - case Dali::Pixel::DEPTH_UNSIGNED_INT: - case Dali::Pixel::DEPTH_FLOAT: - case Dali::Pixel::DEPTH_STENCIL: - { - DALI_LOG_ERROR("Pixel format not compatible.\n"); - byteOffset=0; - bitMask=0; - break; - } - } -} - -Uint16Pair ParseRange( unsigned int& index, unsigned int width, unsigned char*& pixel, unsigned int pixelStride, int testByte, int testBits, int testValue ) -{ - unsigned int start = 0xFFFF; - for( ; index < width; ++index, pixel += pixelStride ) - { - if( ( pixel[ testByte ] & testBits ) == testValue ) - { - start = index; - ++index; - pixel += pixelStride; - break; - } - } - - unsigned int end = width; - for( ; index < width; ++index, pixel += pixelStride ) - { - if( ( pixel[ testByte ] & testBits ) != testValue ) - { - end = index; - ++index; - pixel += pixelStride; - break; - } - } - - return Uint16Pair( start, end ); -} - -void ParseBorders( Devel::PixelBuffer& pixelBuffer, NPatchLoader::Data* data ) -{ - data->stretchPixelsX.Clear(); - data->stretchPixelsY.Clear(); - - Pixel::Format pixelFormat = pixelBuffer.GetPixelFormat(); - - int alphaByte = 0; - int alphaBits = 0; - Pixel::GetAlphaOffsetAndMask( pixelFormat, alphaByte, alphaBits ); - - int testByte = alphaByte; - int testBits = alphaBits; - int testValue = alphaBits; // Opaque == stretch - if( !alphaBits ) - { - GetRedOffsetAndMask( pixelFormat, testByte, testBits ); - testValue = 0; // Black == stretch - } - - unsigned int bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat ); - unsigned int width = pixelBuffer.GetWidth(); - unsigned int height = pixelBuffer.GetHeight(); - unsigned char* srcPixels = pixelBuffer.GetBuffer(); - unsigned int srcStride = width * bytesPerPixel; - - // TOP - unsigned char* top = srcPixels + bytesPerPixel; - unsigned int index = 0; - - for( ; index < width - 2; ) - { - Uint16Pair range = ParseRange( index, width - 2, top, bytesPerPixel, testByte, testBits, testValue ); - if( range.GetX() != 0xFFFF ) - { - data->stretchPixelsX.PushBack( range ); - } - } - - // LEFT - unsigned char* left = srcPixels + srcStride; - index = 0; - for( ; index < height - 2; ) - { - Uint16Pair range = ParseRange( index, height - 2, left, srcStride, testByte, testBits, testValue ); - if( range.GetX() != 0xFFFF ) - { - data->stretchPixelsY.PushBack( range ); - } - } - - // If there are no stretch pixels then make the entire image stretchable - if( data->stretchPixelsX.Size() == 0 ) - { - data->stretchPixelsX.PushBack( Uint16Pair( 0, width - 2 ) ); - } - if( data->stretchPixelsY.Size() == 0 ) - { - data->stretchPixelsY.PushBack( Uint16Pair( 0, height - 2 ) ); - } -} - void SetLoadedNPatchData( NPatchLoader::Data* data, Devel::PixelBuffer& pixelBuffer ) { if( data->border == Rect< int >( 0, 0, 0, 0 ) ) { - NPatchBuffer::ParseBorders( pixelBuffer, data ); + NPatchUtility::ParseBorders( pixelBuffer, data->stretchPixelsX, data->stretchPixelsY ); // Crop the image pixelBuffer.Crop( 1, 1, pixelBuffer.GetWidth() - 2, pixelBuffer.GetHeight() - 2 ); @@ -328,10 +112,10 @@ std::size_t NPatchLoader::Load( TextureManager& textureManager, TextureUploadObs data->textureSet = mCache[ index ]->textureSet; - StretchRanges stretchRangesX; + NPatchUtility::StretchRanges stretchRangesX; stretchRangesX.PushBack( Uint16Pair( border.left, ( (data->croppedWidth >= static_cast< unsigned int >( border.right )) ? data->croppedWidth - border.right : 0 ) ) ); - StretchRanges stretchRangesY; + NPatchUtility::StretchRanges stretchRangesY; stretchRangesY.PushBack( Uint16Pair( border.top, ( (data->croppedHeight >= static_cast< unsigned int >( border.bottom )) ? data->croppedHeight - border.bottom : 0 ) ) ); data->stretchPixelsX = stretchRangesX; diff --git a/dali-toolkit/internal/visuals/npatch-loader.h b/dali-toolkit/internal/visuals/npatch-loader.h index 6bdc2f9..58bd73f 100644 --- a/dali-toolkit/internal/visuals/npatch-loader.h +++ b/dali-toolkit/internal/visuals/npatch-loader.h @@ -20,12 +20,12 @@ // EXTERNAL INCLUDES #include #include -#include #include #include -// INTERNAL HEADERS +// INTERNAL INCLUDES #include +#include namespace Dali { @@ -36,13 +36,6 @@ namespace Toolkit namespace Internal { -namespace NPatchBuffer -{ - -void GetRedOffsetAndMask( Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask ); - -} // namespace NPatchBuffer - /** * The manager for loading Npatch textures. * It caches them internally for better performance; i.e. to avoid loading and @@ -56,8 +49,6 @@ class NPatchLoader { public: - typedef Dali::Vector< Uint16Pair > StretchRanges; - enum { UNINITIALIZED_ID = 0 ///< uninitialised id, use to initialize ids @@ -77,8 +68,8 @@ public: std::string url; ///< Url of the N-Patch TextureSet textureSet; ///< Texture containing the cropped image - StretchRanges stretchPixelsX; ///< X stretch pixels - StretchRanges stretchPixelsY; ///< Y stretch pixels + NPatchUtility::StretchRanges stretchPixelsX; ///< X stretch pixels + NPatchUtility::StretchRanges stretchPixelsY; ///< Y stretch pixels std::size_t hash; ///< Hash code for the Url uint32_t croppedWidth; ///< Width of the cropped middle part of N-patch uint32_t croppedHeight; ///< Height of the cropped middle part of N-patch diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp index ef77ee5..02f9e1b 100755 --- a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp +++ b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp @@ -223,13 +223,13 @@ void AddVertex( Vector< Vector2 >& vertices, unsigned int x, unsigned int y ) vertices.PushBack( Vector2( x, y ) ); } -void RegisterStretchProperties( Renderer& renderer, const char * uniformName, const NPatchLoader::StretchRanges& stretchPixels, uint16_t imageExtent) +void RegisterStretchProperties( Renderer& renderer, const char * uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent) { uint16_t prevEnd = 0; uint16_t prevFix = 0; uint16_t prevStretch = 0; unsigned int i = 1; - for( NPatchLoader::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i ) + for( NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i ) { uint16_t start = it->GetX(); uint16_t end = it->GetY(); @@ -518,8 +518,8 @@ Shader NPatchVisual::CreateShader() const NPatchLoader::Data* data; // 0 is either no data (load failed?) or no stretch regions on image // for both cases we use the default shader - NPatchLoader::StretchRanges::SizeType xStretchCount = 0; - NPatchLoader::StretchRanges::SizeType yStretchCount = 0; + NPatchUtility::StretchRanges::SizeType xStretchCount = 0; + NPatchUtility::StretchRanges::SizeType yStretchCount = 0; auto fragmentShader = mAuxiliaryPixelBuffer ? FRAGMENT_MASK_SHADER : FRAGMENT_SHADER; -- 2.7.4 From d50b2163fcc2c91b0cb25f9b5f3d849e4e247e09 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Thu, 25 Jun 2020 11:24:28 +0900 Subject: [PATCH 02/16] Change target share directory from dali to dali-legacy Change-Id: I854e6e6f307708af3f7ec5e64f3fde930fd2e34e Signed-off-by: Seungho, Baek --- CMakeLists.txt | 10 +++++----- build/tizen/CMakeLists.txt | 12 ++++++------ packaging/dali-toolkit.spec | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff17e64..a2fe956 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,11 @@ PROJECT (dali-toolkit) ADD_DEFINITIONS( -DDALI_ENV="../../dali-env" --DDALI_DATA_READ_ONLY_DIR=DALI_ENV"/opt/share/dali" --DDALI_IMAGE_DIR=DALI_ENV"/opt/share/dali/toolkit/images/" --DDALI_STYLE_DIR=DALI_ENV"/opt/share/dali/toolkit/styles/" --DDALI_SOUND_DIR=DALI_ENV"/opt/share/dali/toolkit/sounds/" --DDALI_STYLE_IMAGE_DIR=DALI_ENV"/opt/share/dali/toolkit/styles/images/" +-DDALI_DATA_READ_ONLY_DIR=DALI_ENV"/opt/share/dali-legacy" +-DDALI_IMAGE_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/images/" +-DDALI_STYLE_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/styles/" +-DDALI_SOUND_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/sounds/" +-DDALI_STYLE_IMAGE_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/styles/images/" -DCURL_STATICLIB=0 /DBUILDING_DALI_TOOLKIT /vmg diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 25edb06..fde4eb2 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -79,13 +79,13 @@ SET( toolkit_style_images_dir ${STYLE_DIR}/images ) IF( DEFINED ENV{DALI_DATA_RW_DIR} ) SET( dataReadWriteDir $ENV{DALI_DATA_RW_DIR} ) ELSE() - SET( dataReadWriteDir ${CMAKE_INSTALL_PREFIX}/share/dali/ ) + SET( dataReadWriteDir ${CMAKE_INSTALL_PREFIX}/share/dali-legacy/ ) ENDIF() IF( DEFINED ENV{DALI_DATA_RO_DIR} ) SET( dataReadOnlyDir $ENV{DALI_DATA_RO_DIR} ) ELSE() - SET( dataReadOnlyDir ${CMAKE_INSTALL_PREFIX}/share/dali/ ) + SET( dataReadOnlyDir ${CMAKE_INSTALL_PREFIX}/share/dali-legacy/ ) ENDIF() # Set up compiler definitions @@ -115,10 +115,10 @@ IF( WIN32 ) SET( INSTALL_SHARE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share" ) ENDIF() - ADD_DEFINITIONS( -DDALI_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/images/\" - -DDALI_SOUND_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/sounds/\" - -DDALI_STYLE_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/styles/\" - -DDALI_STYLE_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/styles/images/\" + ADD_DEFINITIONS( -DDALI_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/images/\" + -DDALI_SOUND_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/sounds/\" + -DDALI_STYLE_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/styles/\" + -DDALI_STYLE_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/styles/images/\" -DDALI_DATA_READ_ONLY_DIR=\"${INSTALL_SHARE_DIR}/\" ) ENDIF() ELSEIF( UNIX ) diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 6c2f417..71dced0 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -88,8 +88,8 @@ Application development package for Dali 3D engine toolkit - headers and package %prep %setup -q -%define dali_data_rw_dir %TZ_SYS_SHARE/dali/ -%define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali/ +%define dali_data_rw_dir %TZ_SYS_SHARE/dali-legacy/ +%define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali-legacy/ %define dali_toolkit_image_files %{dali_data_ro_dir}/toolkit/images/ %define dali_toolkit_sound_files %{dali_data_ro_dir}/toolkit/sounds/ @@ -194,6 +194,7 @@ popd %pre resources_360x360 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -203,6 +204,7 @@ esac %pre resources_480x800 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -212,6 +214,7 @@ esac %pre resources_720x1280 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -221,6 +224,7 @@ esac %pre resources_1920x1080 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -235,21 +239,25 @@ esac exit 0 %post resources_360x360 +mkdir -p %{dali_toolkit_style_files}/360x360 pushd %{dali_toolkit_style_files}/360x360 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd %post resources_480x800 +mkdir -p %{dali_toolkit_style_files}/480x800 pushd %{dali_toolkit_style_files}/480x800 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd %post resources_720x1280 +mkdir -p %{dali_toolkit_style_files}/720x1280 pushd %{dali_toolkit_style_files}/720x1280 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd %post resources_1920x1080 +mkdir -p %{dali_toolkit_style_files}/1920x1080 pushd %{dali_toolkit_style_files}/1920x1080 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd @@ -262,6 +270,7 @@ popd case "$1" in 0) %preun resources_360x360 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./360x360 mv dali-toolkit-default-theme.json ./360x360 @@ -273,6 +282,7 @@ esac case "$1" in 0) %preun resources_480x800 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./480x800 mv dali-toolkit-default-theme.json ./480x800 @@ -284,6 +294,7 @@ esac case "$1" in 0) %preun resources_720x1280 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./720x1280 mv dali-toolkit-default-theme.json ./720x1280 @@ -295,6 +306,7 @@ esac case "$1" in 0) %preun resources_1920x1080 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./1920x1080 mv dali-toolkit-default-theme.json ./1920x1080 @@ -312,6 +324,7 @@ exit 0 %postun resources_360x360 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd @@ -321,6 +334,7 @@ esac %postun resources_480x800 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd @@ -330,6 +344,7 @@ esac %postun resources_720x1280 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd @@ -339,6 +354,7 @@ esac %postun resources_1920x1080 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd -- 2.7.4 From 2c23a90e5de1cbc41e0ee974db53e97330a7ead3 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Thu, 25 Jun 2020 11:24:28 +0900 Subject: [PATCH 03/16] [Tizen] Change target share directory from dali to dali-legacy Change-Id: I854e6e6f307708af3f7ec5e64f3fde930fd2e34e Signed-off-by: Seungho, Baek --- CMakeLists.txt | 10 +++++----- build/tizen/CMakeLists.txt | 12 ++++++------ packaging/dali-toolkit.spec | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbd38b4..eba4398 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,11 @@ PROJECT (dali-toolkit) ADD_DEFINITIONS( -DDALI_ENV="../../dali-env" --DDALI_DATA_READ_ONLY_DIR=DALI_ENV"/opt/share/dali" --DDALI_IMAGE_DIR=DALI_ENV"/opt/share/dali/toolkit/images/" --DDALI_STYLE_DIR=DALI_ENV"/opt/share/dali/toolkit/styles/" --DDALI_SOUND_DIR=DALI_ENV"/opt/share/dali/toolkit/sounds/" --DDALI_STYLE_IMAGE_DIR=DALI_ENV"/opt/share/dali/toolkit/styles/images/" +-DDALI_DATA_READ_ONLY_DIR=DALI_ENV"/opt/share/dali-legacy" +-DDALI_IMAGE_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/images/" +-DDALI_STYLE_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/styles/" +-DDALI_SOUND_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/sounds/" +-DDALI_STYLE_IMAGE_DIR=DALI_ENV"/opt/share/dali-legacy/toolkit/styles/images/" -DCURL_STATICLIB=0 /DBUILDING_DALI_TOOLKIT /vmg diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 25edb06..fde4eb2 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -79,13 +79,13 @@ SET( toolkit_style_images_dir ${STYLE_DIR}/images ) IF( DEFINED ENV{DALI_DATA_RW_DIR} ) SET( dataReadWriteDir $ENV{DALI_DATA_RW_DIR} ) ELSE() - SET( dataReadWriteDir ${CMAKE_INSTALL_PREFIX}/share/dali/ ) + SET( dataReadWriteDir ${CMAKE_INSTALL_PREFIX}/share/dali-legacy/ ) ENDIF() IF( DEFINED ENV{DALI_DATA_RO_DIR} ) SET( dataReadOnlyDir $ENV{DALI_DATA_RO_DIR} ) ELSE() - SET( dataReadOnlyDir ${CMAKE_INSTALL_PREFIX}/share/dali/ ) + SET( dataReadOnlyDir ${CMAKE_INSTALL_PREFIX}/share/dali-legacy/ ) ENDIF() # Set up compiler definitions @@ -115,10 +115,10 @@ IF( WIN32 ) SET( INSTALL_SHARE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share" ) ENDIF() - ADD_DEFINITIONS( -DDALI_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/images/\" - -DDALI_SOUND_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/sounds/\" - -DDALI_STYLE_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/styles/\" - -DDALI_STYLE_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali/toolkit/styles/images/\" + ADD_DEFINITIONS( -DDALI_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/images/\" + -DDALI_SOUND_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/sounds/\" + -DDALI_STYLE_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/styles/\" + -DDALI_STYLE_IMAGE_DIR=\"${INSTALL_SHARE_DIR}/dali-legacy/toolkit/styles/images/\" -DDALI_DATA_READ_ONLY_DIR=\"${INSTALL_SHARE_DIR}/\" ) ENDIF() ELSEIF( UNIX ) diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 6c2f417..71dced0 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -88,8 +88,8 @@ Application development package for Dali 3D engine toolkit - headers and package %prep %setup -q -%define dali_data_rw_dir %TZ_SYS_SHARE/dali/ -%define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali/ +%define dali_data_rw_dir %TZ_SYS_SHARE/dali-legacy/ +%define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali-legacy/ %define dali_toolkit_image_files %{dali_data_ro_dir}/toolkit/images/ %define dali_toolkit_sound_files %{dali_data_ro_dir}/toolkit/sounds/ @@ -194,6 +194,7 @@ popd %pre resources_360x360 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -203,6 +204,7 @@ esac %pre resources_480x800 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -212,6 +214,7 @@ esac %pre resources_720x1280 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -221,6 +224,7 @@ esac %pre resources_1920x1080 case "$1" in 2) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf ./* popd @@ -235,21 +239,25 @@ esac exit 0 %post resources_360x360 +mkdir -p %{dali_toolkit_style_files}/360x360 pushd %{dali_toolkit_style_files}/360x360 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd %post resources_480x800 +mkdir -p %{dali_toolkit_style_files}/480x800 pushd %{dali_toolkit_style_files}/480x800 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd %post resources_720x1280 +mkdir -p %{dali_toolkit_style_files}/720x1280 pushd %{dali_toolkit_style_files}/720x1280 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd %post resources_1920x1080 +mkdir -p %{dali_toolkit_style_files}/1920x1080 pushd %{dali_toolkit_style_files}/1920x1080 for FILE in *; do mv ./"${FILE}" ../"${FILE}"; done popd @@ -262,6 +270,7 @@ popd case "$1" in 0) %preun resources_360x360 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./360x360 mv dali-toolkit-default-theme.json ./360x360 @@ -273,6 +282,7 @@ esac case "$1" in 0) %preun resources_480x800 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./480x800 mv dali-toolkit-default-theme.json ./480x800 @@ -284,6 +294,7 @@ esac case "$1" in 0) %preun resources_720x1280 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./720x1280 mv dali-toolkit-default-theme.json ./720x1280 @@ -295,6 +306,7 @@ esac case "$1" in 0) %preun resources_1920x1080 + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} mv images ./1920x1080 mv dali-toolkit-default-theme.json ./1920x1080 @@ -312,6 +324,7 @@ exit 0 %postun resources_360x360 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd @@ -321,6 +334,7 @@ esac %postun resources_480x800 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd @@ -330,6 +344,7 @@ esac %postun resources_720x1280 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd @@ -339,6 +354,7 @@ esac %postun resources_1920x1080 case "$1" in 0) + mkdir -p %{dali_toolkit_style_files} pushd %{dali_toolkit_style_files} rm -rf * popd -- 2.7.4 From e76b7c695d12f578a61afa1788cd8cd8d9700bfe Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Fri, 12 Jun 2020 21:43:23 +0900 Subject: [PATCH 04/16] Support WebP format - Modified animated-image-visual to support webp amimated image format - Added and removed some functions of image-cache to use rolling-animated-image-cache for the both of gif and webp - Checked whether mFrameDelayTimer is null or not for the case that Action::PLAY is entered but the system do not support animated webp Change-Id: I254c4c8e715772acb6c0725c58e64aba1a6dafc4 Signed-off-by: Seungho, Baek --- .../dali-toolkit/utc-Dali-AnimatedImageVisual.cpp | 2 +- dali-toolkit/internal/file.list | 2 +- .../animated-image/animated-image-visual.cpp | 35 +++++----- .../visuals/animated-image/animated-image-visual.h | 15 ++--- .../visuals/animated-image/fixed-image-cache.cpp | 26 +++----- .../visuals/animated-image/fixed-image-cache.h | 6 +- .../internal/visuals/animated-image/image-cache.h | 10 ++- ...-cache.cpp => rolling-animated-image-cache.cpp} | 78 +++++++++------------- ...mage-cache.h => rolling-animated-image-cache.h} | 42 ++++++------ .../visuals/animated-image/rolling-image-cache.cpp | 21 +----- .../visuals/animated-image/rolling-image-cache.h | 6 +- .../internal/visuals/visual-factory-impl.cpp | 2 + dali-toolkit/internal/visuals/visual-url.cpp | 12 +++- dali-toolkit/internal/visuals/visual-url.h | 3 +- 14 files changed, 112 insertions(+), 148 deletions(-) rename dali-toolkit/internal/visuals/animated-image/{rolling-gif-image-cache.cpp => rolling-animated-image-cache.cpp} (68%) rename dali-toolkit/internal/visuals/animated-image/{rolling-gif-image-cache.h => rolling-animated-image-cache.h} (72%) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp index bb591dd..bad5ea0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp @@ -293,7 +293,7 @@ int UtcDaliAnimatedImageVisualStopBehavior(void) } -int UtcDaliAnimatedImageVisualGif01(void) +int UtcDaliAnimatedImageVisualAnimatedImage01(void) { ToolkitTestApplication application; TestGlAbstraction& gl = application.GetGlAbstraction(); diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 8f3b2f2..246ba89 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -17,7 +17,7 @@ SET( toolkit_src_files ${toolkit_src_dir}/visuals/animated-image/image-cache.cpp ${toolkit_src_dir}/visuals/animated-image/fixed-image-cache.cpp ${toolkit_src_dir}/visuals/animated-image/rolling-image-cache.cpp - ${toolkit_src_dir}/visuals/animated-image/rolling-gif-image-cache.cpp + ${toolkit_src_dir}/visuals/animated-image/rolling-animated-image-cache.cpp ${toolkit_src_dir}/visuals/animated-vector-image/animated-vector-image-visual.cpp ${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-task.cpp ${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-thread.cpp diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp index 386013a..fdde260 100755 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -111,7 +111,7 @@ Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, " AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties ) { AnimatedImageVisualPtr visual( new AnimatedImageVisual( factoryCache, shaderFactory ) ); - visual->InitializeGif( imageUrl ); + visual->InitializeAnimatedImage( imageUrl ); visual->SetProperties( properties ); if( visual->mFrameCount > 0 ) @@ -149,7 +149,7 @@ AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCach AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl ) { AnimatedImageVisualPtr visual( new AnimatedImageVisual( factoryCache, shaderFactory ) ); - visual->InitializeGif( imageUrl ); + visual->InitializeAnimatedImage( imageUrl ); if( visual->mFrameCount > 0 ) { @@ -159,12 +159,11 @@ AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCach return visual; } -void AnimatedImageVisual::InitializeGif( const VisualUrl& imageUrl ) +void AnimatedImageVisual::InitializeAnimatedImage( const VisualUrl& imageUrl ) { mImageUrl = imageUrl; - mGifLoading = GifLoading::New( imageUrl.GetUrl(), imageUrl.IsLocalResource() ); - mFrameCount = mGifLoading->GetImageCount(); - mGifLoading->LoadFrameDelays( mFrameDelayContainer ); + mAnimatedImageLoading = AnimatedImageLoading::New( imageUrl.GetUrl(), imageUrl.IsLocalResource() ); + mFrameCount = mAnimatedImageLoading.GetImageCount(); } AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory ) @@ -174,7 +173,7 @@ AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache, Imag mImageVisualShaderFactory( shaderFactory ), mPixelArea( FULL_TEXTURE_RECT ), mImageUrl(), - mGifLoading( nullptr ), + mAnimatedImageLoading(), mCurrentFrameIndex( 0 ), mImageUrls( NULL ), mImageCache( NULL ), @@ -206,7 +205,7 @@ void AnimatedImageVisual::GetNaturalSize( Vector2& naturalSize ) { if( mImageUrl.IsValid() ) { - mImageSize = mGifLoading->GetImageSize(); + mImageSize = mAnimatedImageLoading.GetImageSize(); } else if( mImageUrls && mImageUrls->size() > 0 ) { @@ -270,7 +269,7 @@ void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, cons } case DevelAnimatedImageVisual::Action::PLAY: { - if( IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY ) + if( mFrameDelayTimer && IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY ) { mFrameDelayTimer.Start(); } @@ -542,9 +541,9 @@ void AnimatedImageVisual::LoadFirstBatch() mUrlIndex = 0; TextureManager& textureManager = mFactoryCache.GetTextureManager(); - if( mGifLoading != nullptr ) + if( mAnimatedImageLoading ) { - mImageCache = new RollingGifImageCache( textureManager, *mGifLoading, mFrameCount, *this, cacheSize, batchSize ); + mImageCache = new RollingAnimatedImageCache( textureManager, mAnimatedImageLoading, mFrameCount, *this, cacheSize, batchSize ); } else if( mImageUrls ) { @@ -592,11 +591,10 @@ void AnimatedImageVisual::StartFirstFrame( TextureSet& textureSet ) if( mFrameCount > 1 ) { int frameDelay = mFrameDelay; // from URL array - if( mFrameDelayContainer.Count() > 0 ) // from GIF + if( mAnimatedImageLoading && mImageCache ) { - frameDelay = mFrameDelayContainer[0]; + frameDelay = mImageCache->GetFrameInterval( 0 ); } - mFrameDelayTimer = Timer::New( frameDelay ); mFrameDelayTimer.TickSignal().Connect( this, &AnimatedImageVisual::DisplayNextFrame ); mFrameDelayTimer.Start(); @@ -706,11 +704,10 @@ bool AnimatedImageVisual::DisplayNextFrame() return DisplayNextFrame(); } } - - if( mFrameDelayContainer.Count() > 0 ) + // TODO : newly added one. + if( mAnimatedImageLoading && mImageCache ) { - unsigned int delay = mFrameDelayContainer[mCurrentFrameIndex]; - + unsigned int delay = mImageCache->GetFrameInterval( mCurrentFrameIndex ); if( mFrameDelayTimer.GetInterval() != delay ) { mFrameDelayTimer.SetInterval( delay ); diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h index 0d21f97..7c0764e 100755 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include // INTERNAL INCLUDES #include @@ -92,7 +92,7 @@ public: * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object * @param[in] shaderFactory The ImageVisualShaderFactory object - * @param[in] imageUrl The URL to gif resource to use + * @param[in] imageUrl The URL to animated image resource to use * @param[in] properties A Property::Map containing settings for this visual * @return A smart-pointer to the newly allocated visual. */ @@ -224,10 +224,10 @@ private: bool DisplayNextFrame(); /** - * Initialize the gif variables. - * @param[in] imageUrl The url of the animated gif + * Initialize the animated image variables. + * @param[in] imageUrl The url of the animated image */ - void InitializeGif( const VisualUrl& imageUrl ); + void InitializeAnimatedImage( const VisualUrl& imageUrl ); // Undefined AnimatedImageVisual( const AnimatedImageVisual& animatedImageVisual ); @@ -241,11 +241,10 @@ private: WeakHandle mPlacementActor; ImageVisualShaderFactory& mImageVisualShaderFactory; - // Variables for GIF player - Dali::Vector mFrameDelayContainer; + // Variables for Animated Image player Vector4 mPixelArea; VisualUrl mImageUrl; - std::unique_ptr mGifLoading; // Only needed for animated gifs + Dali::AnimatedImageLoading mAnimatedImageLoading; // Only needed for animated image uint32_t mCurrentFrameIndex; // Frame index into textureRects // Variables for Multi-Image player diff --git a/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp b/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp index d71ee94..726cd39 100644 --- a/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp +++ b/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp @@ -58,8 +58,14 @@ TextureSet FixedImageCache::Frame( uint32_t frameIndex ) { while( frameIndex > mFront ) { - NextFrame(); + ++mFront; + if( mFront >= mImageUrls.size() ) + { + mFront = 0; + } + LoadBatch(); } + mFront = frameIndex; TextureSet textureSet; @@ -87,23 +93,9 @@ TextureSet FixedImageCache::FirstFrame() return textureSet; } -TextureSet FixedImageCache::NextFrame() +uint32_t FixedImageCache::GetFrameInterval( uint32_t frameIndex ) { - TextureSet textureSet; - ++mFront; - mFront %= mImageUrls.size(); - - if( IsFrontReady() == true ) - { - textureSet = GetFrontTextureSet(); - } - else - { - mWaitingForReadyFrame = true; - } - LoadBatch(); - - return textureSet; + return 0u; } bool FixedImageCache::IsFrontReady() const diff --git a/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h b/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h index d884e28..5063232 100644 --- a/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h @@ -61,11 +61,9 @@ public: TextureSet FirstFrame() override; /** - * Get the next frame. If it's not ready, this will trigger the - * sending of FrameReady() when the image becomes ready. - * This will trigger the loading of the next batch. + * Get the interval of Nth frame. */ - TextureSet NextFrame() override; + uint32_t GetFrameInterval( uint32_t frameIndex ) override; private: /** diff --git a/dali-toolkit/internal/visuals/animated-image/image-cache.h b/dali-toolkit/internal/visuals/animated-image/image-cache.h index 7354992..1d385c8 100644 --- a/dali-toolkit/internal/visuals/animated-image/image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/image-cache.h @@ -79,17 +79,15 @@ public: virtual TextureSet FirstFrame() = 0; /** - * Get the next frame. If it's not ready, this will trigger the + * Get the Nth frame. If it's not ready, this will trigger the * sending of FrameReady() when the image becomes ready. - * This will trigger the loading of the next batch. */ - virtual TextureSet NextFrame() = 0; + virtual TextureSet Frame( uint32_t frameIndex ) = 0; /** - * Get the Nth frame. If it's not ready, this will trigger the - * sending of FrameReady() when the image becomes ready. + * Get the interval of Nth frame. */ - virtual TextureSet Frame( uint32_t frameIndex ) = 0; + virtual uint32_t GetFrameInterval( uint32_t frameIndex ) = 0; private: diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp similarity index 68% rename from dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp rename to dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp index 04f0f1d..c421678 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.cpp +++ b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp @@ -15,7 +15,7 @@ */ // CLASS HEADER -#include "rolling-gif-image-cache.h" +#include "rolling-animated-image-cache.h" // EXTERNAL HEADERS @@ -58,11 +58,11 @@ namespace Toolkit namespace Internal { -RollingGifImageCache::RollingGifImageCache( - TextureManager& textureManager, GifLoading& gifLoading, uint32_t frameCount, ImageCache::FrameReadyObserver& observer, +RollingAnimatedImageCache::RollingAnimatedImageCache( + TextureManager& textureManager, AnimatedImageLoading& animatedImageLoading, uint32_t frameCount, ImageCache::FrameReadyObserver& observer, uint16_t cacheSize, uint16_t batchSize ) : ImageCache( textureManager, observer, batchSize ), - mGifLoading( gifLoading ), + mAnimatedImageLoading( animatedImageLoading ), mFrameCount( frameCount ), mFrameIndex( 0 ), mCacheSize( cacheSize ), @@ -72,11 +72,11 @@ RollingGifImageCache::RollingGifImageCache( LoadBatch(); } -RollingGifImageCache::~RollingGifImageCache() +RollingAnimatedImageCache::~RollingAnimatedImageCache() { if( mTextureManagerAlive ) { - while( !mQueue.IsEmpty() ) + while( IsFrontReady() ) { ImageFrame imageFrame = mQueue.PopFront(); Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); @@ -84,64 +84,51 @@ RollingGifImageCache::~RollingGifImageCache() } } -TextureSet RollingGifImageCache::Frame( uint32_t frameIndex ) +TextureSet RollingAnimatedImageCache::Frame( uint32_t frameIndex ) { - // If a frame of frameIndex is not loaded, clear the queue and remove all loaded textures. - if( mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID ) + bool popExist = false; + while( IsFrontReady() && mQueue.Front().mFrameNumber != frameIndex ) { - mFrameIndex = frameIndex; - while( !mQueue.IsEmpty() ) - { - ImageFrame imageFrame = mQueue.PopFront(); - Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); - mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; - } - LoadBatch(); + ImageFrame imageFrame = mQueue.PopFront(); + Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); + mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; + popExist = true; } - // If the frame is already loaded, remove previous frames of the frame in the queue - // and load new frames amount of removed frames. - else + if( popExist || mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID ) { - bool popExist = false; - while( !mQueue.IsEmpty() && mQueue.Front().mFrameNumber != frameIndex ) + // If the frame of frameIndex was already loaded, load batch from the last frame of queue + if( IsFrontReady() ) { - ImageFrame imageFrame = mQueue.PopFront(); - Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); - mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; - popExist = true; + mFrameIndex = ( mQueue.Back().mFrameNumber + 1 ) % mFrameCount; } - if( popExist ) + // If the queue is empty, load batch from the frame of frameIndex + else { - mFrameIndex = ( mQueue.Back().mFrameNumber + 1 ) % mFrameCount; - LoadBatch(); + mFrameIndex = frameIndex; } + LoadBatch(); } return GetFrontTextureSet(); } -TextureSet RollingGifImageCache::FirstFrame() +TextureSet RollingAnimatedImageCache::FirstFrame() { return Frame( 0u ); } -TextureSet RollingGifImageCache::NextFrame() +uint32_t RollingAnimatedImageCache::GetFrameInterval( uint32_t frameIndex ) { - ImageFrame imageFrame = mQueue.PopFront(); - Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl ); - mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID; - - LoadBatch(); - - return GetFrontTextureSet(); + Frame( frameIndex ); + return mAnimatedImageLoading.GetFrameInterval( frameIndex ); } -bool RollingGifImageCache::IsFrontReady() const +bool RollingAnimatedImageCache::IsFrontReady() const { return ( !mQueue.IsEmpty() ); } -void RollingGifImageCache::LoadBatch() +void RollingAnimatedImageCache::LoadBatch() { // Try and load up to mBatchSize images, until the cache is filled. // Once the cache is filled, as frames progress, the old frame is @@ -151,9 +138,8 @@ void RollingGifImageCache::LoadBatch() // Get the smallest number of frames we need to load int batchSize = std::min( std::size_t(mBatchSize), mCacheSize - mQueue.Count() ); - DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingGifImageCache::LoadBatch() mFrameIndex:%d batchSize:%d\n", mFrameIndex, batchSize ); - - if( mGifLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) ) + DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::LoadBatch() mFrameIndex:%d batchSize:%d\n", mFrameIndex, batchSize ); + if( mAnimatedImageLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) ) { unsigned int pixelDataListCount = pixelDataList.size(); @@ -203,15 +189,15 @@ void RollingGifImageCache::LoadBatch() LOG_CACHE; } -TextureSet RollingGifImageCache::GetFrontTextureSet() const +TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const { - DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingGifImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[ 0 ].mFrameNumber ); + DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingAnimatedImageCache::GetFrontTextureSet() FrameNumber:%d\n", mQueue[ 0 ].mFrameNumber ); TextureManager::TextureId textureId = GetCachedTextureId( 0 ); return mTextureManager.GetTextureSet( textureId ); } -TextureManager::TextureId RollingGifImageCache::GetCachedTextureId( int index ) const +TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId( int index ) const { return mImageUrls[ mQueue[ index ].mFrameNumber ].mTextureId; } diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.h b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h similarity index 72% rename from dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.h rename to dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h index 91a1210..503f65e 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-gif-image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h @@ -1,5 +1,5 @@ -#ifndef DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H -#define DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H +#ifndef DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H +#define DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H /* * Copyright (c) 2020 Samsung Electronics Co., Ltd. @@ -18,7 +18,7 @@ */ // EXTERNAL INCLUDES -#include +#include #include #include #include @@ -31,20 +31,20 @@ namespace Internal { /** - * Class to manage a rolling cache of GIF images, where the cache size + * Class to manage a rolling cache of Animated images, where the cache size * is smaller than the total number of images. * * Frames are always ready, so the observer.FrameReady callback is never triggered; * the FirstFrame and NextFrame APIs will always return a texture. */ -class RollingGifImageCache : public ImageCache +class RollingAnimatedImageCache : public ImageCache { public: /** * Constructor. * @param[in] textureManager The texture manager - * @param[in] gifLoader The loaded gif image - * @param[in] frameCount The number of frames in the gif + * @param[in] animatedImageLoader The loaded animated image + * @param[in] frameCount The number of frames in the animated image * @param[in] observer FrameReady observer * @param[in] cacheSize The size of the cache * @param[in] batchSize The size of a batch to load @@ -52,8 +52,8 @@ public: * This will start loading textures immediately, according to the * batch and cache sizes. */ - RollingGifImageCache( TextureManager& textureManager, - GifLoading& gifLoader, + RollingAnimatedImageCache( TextureManager& textureManager, + AnimatedImageLoading& animatedImageLoader, uint32_t frameCount, ImageCache::FrameReadyObserver& observer, uint16_t cacheSize, @@ -62,7 +62,7 @@ public: /** * Destructor */ - virtual ~RollingGifImageCache(); + virtual ~RollingAnimatedImageCache(); /** * Get the Nth frame. If it's not ready, this will trigger the @@ -77,11 +77,9 @@ public: TextureSet FirstFrame() override; /** - * Get the next frame. If it's not ready, this will trigger the - * sending of FrameReady() when the image becomes ready. - * This will trigger the loading of the next batch. + * Get the interval of Nth frame. */ - TextureSet NextFrame() override; + uint32_t GetFrameInterval( uint32_t frameIndex ) override; private: /** @@ -114,16 +112,18 @@ private: unsigned int mFrameNumber = 0u; }; - GifLoading& mGifLoading; - uint32_t mFrameCount; - int mFrameIndex; - std::vector mImageUrls; - uint16_t mCacheSize; - CircularQueue mQueue; + Dali::AnimatedImageLoading& mAnimatedImageLoading; + uint32_t mFrameCount; + int mFrameIndex; + std::vector mImageUrls; + uint16_t mCacheSize; + CircularQueue mQueue; }; } // namespace Internal + } // namespace Toolkit + } // namespace Dali -#endif +#endif //DALI_TOOLKIT_INTERNAL_ROLLING_ANIMATED_IMAGE_CACHE_H diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp b/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp index 21f81b7..2284778 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp +++ b/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp @@ -131,26 +131,9 @@ TextureSet RollingImageCache::FirstFrame() return Frame( 0u ); } -TextureSet RollingImageCache::NextFrame() +uint32_t RollingImageCache::GetFrameInterval( uint32_t frameIndex ) { - TextureSet textureSet; - - ImageFrame imageFrame = mQueue.PopFront(); - mTextureManager.Remove( mImageUrls[ imageFrame.mUrlIndex ].mTextureId, this ); - mImageUrls[ imageFrame.mUrlIndex ].mTextureId = TextureManager::INVALID_TEXTURE_ID; - - LoadBatch(); - - if( IsFrontReady() == true ) - { - textureSet = GetFrontTextureSet(); - } - else - { - mWaitingForReadyFrame = true; - } - - return textureSet; + return 0u; } bool RollingImageCache::IsFrontReady() const diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h b/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h index 47a5155..f57b5c2 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h +++ b/dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h @@ -72,11 +72,9 @@ public: TextureSet FirstFrame() override; /** - * Get the next frame. If it's not ready, this will trigger the - * sending of FrameReady() when the image becomes ready. - * This will trigger the loading of the next batch. + * Get the interval of Nth frame. */ - TextureSet NextFrame() override; + uint32_t GetFrameInterval( uint32_t frameIndex ) override; private: /** diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index dc35220..d753ddb 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -165,6 +165,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property break; } case VisualUrl::GIF: + case VisualUrl::WEBP: { visualPtr = AnimatedImageVisual::New( GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl, propertyMap ); break; @@ -361,6 +362,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image break; } case VisualUrl::GIF: + case VisualUrl::WEBP: { visualPtr = AnimatedImageVisual::New( GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl ); break; diff --git a/dali-toolkit/internal/visuals/visual-url.cpp b/dali-toolkit/internal/visuals/visual-url.cpp index 731ed20..451ac06 100644 --- a/dali-toolkit/internal/visuals/visual-url.cpp +++ b/dali-toolkit/internal/visuals/visual-url.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -99,9 +99,11 @@ VisualUrl::Type ResolveType( const std::string& url ) enum { SUFFIX, HASH, HASH_DOT } state = SUFFIX; char SVG[ 4 ] = { 'g', 'v', 's', '.' }; char GIF[ 4 ] = { 'f', 'i', 'g', '.' }; + char WEBP[ 5 ] = { 'p', 'b', 'e', 'w', '.' }; char JSON[ 5 ] = { 'n', 'o', 's', 'j', '.' }; unsigned int svgScore = 0; unsigned int gifScore = 0; + unsigned int webpScore = 0; unsigned int jsonScore = 0; int index = count; while( --index >= 0 ) @@ -124,6 +126,14 @@ VisualUrl::Type ResolveType( const std::string& url ) return VisualUrl::GIF; } } + if( ( offsetFromEnd < sizeof(WEBP) )&&( currentChar == WEBP[ offsetFromEnd ] ) ) + { + // early out if WEBP as can't be used in N patch for now + if( ++webpScore == sizeof(WEBP) ) + { + return VisualUrl::WEBP; + } + } if( ( offsetFromEnd < sizeof(JSON) )&&( currentChar == JSON[ offsetFromEnd ] ) ) { // early out if JSON as can't be used in N patch for now diff --git a/dali-toolkit/internal/visuals/visual-url.h b/dali-toolkit/internal/visuals/visual-url.h index f3af2e0..63ad5e4 100644 --- a/dali-toolkit/internal/visuals/visual-url.h +++ b/dali-toolkit/internal/visuals/visual-url.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -41,6 +41,7 @@ public: N_PATCH, SVG, GIF, + WEBP, JSON }; -- 2.7.4 From 0b2c26595d9bddb2c7ec9f9f7931920c9185501e Mon Sep 17 00:00:00 2001 From: Sunghyun kim Date: Mon, 13 Jan 2020 16:05:19 +0900 Subject: [PATCH 05/16] Change not to use the mask if it is set to an empty path If an application sets an empty path to the alpha mask, unload the alpha mask. Change-Id: Id70bf53f5fc631c9d82a59472f4d05d5d276f6b9 --- .../utc-Dali-TextureManager.cpp | 68 ++++++++++++++++++++++ .../internal/visuals/texture-manager-impl.cpp | 4 +- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp index f2b032d..a6b7460 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp @@ -25,6 +25,7 @@ #include #include #include +#include using namespace Dali::Toolkit::Internal; @@ -204,3 +205,70 @@ int UtcTextureManagerCachingForDifferentLoadingType(void) END_TEST; } + +int UtcTextureManagerUseInvalidMask(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcTextureManagerUseInvalidMask" ); + + TextureManager textureManager; // Create new texture manager + + TestObserver observer; + std::string filename( TEST_IMAGE_FILE_NAME ); + std::string maskname(""); + TextureManager::MaskingDataPointer maskInfo = nullptr; + maskInfo.reset(new TextureManager::MaskingData()); + maskInfo->mAlphaMaskUrl = maskname; + maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID; + maskInfo->mCropToMask = true; + maskInfo->mContentScaleFactor = 1.0f; + + auto textureId( TextureManager::INVALID_TEXTURE_ID ); + Vector4 atlasRect( 0.f, 0.f, 1.f, 1.f ); + Dali::ImageDimensions atlasRectSize( 0,0 ); + bool synchronousLoading(false); + bool atlasingStatus(false); + bool loadingStatus(false); + auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + ImageAtlasManagerPtr atlasManager = nullptr; + Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr; + + textureManager.LoadTexture( + filename, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + WrapMode::DEFAULT, + WrapMode::DEFAULT, + &observer, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply + ); + + DALI_TEST_EQUALS( observer.mLoaded, false, TEST_LOCATION ); + DALI_TEST_EQUALS( observer.mObserverCalled, false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( observer.mLoaded, true, TEST_LOCATION ); + DALI_TEST_EQUALS( observer.mObserverCalled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( observer.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 8912c17..f4fa5fb 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -208,7 +208,7 @@ TextureSet TextureManager::LoadTexture( { Devel::PixelBuffer pixelBuffer = LoadImageFromFile( url.GetUrl(), desiredSize, fittingMode, samplingMode, orientationCorrection ); - if( maskInfo ) + if( maskInfo && maskInfo->mAlphaMaskUrl.IsValid() ) { Devel::PixelBuffer maskPixelBuffer = LoadImageFromFile( maskInfo->mAlphaMaskUrl.GetUrl(), ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true ); @@ -270,7 +270,7 @@ TextureSet TextureManager::LoadTexture( if( !textureSet ) // big image, no atlasing or atlasing failed { atlasingStatus = false; - if( !maskInfo ) + if( !maskInfo || !maskInfo->mAlphaMaskUrl.IsValid() ) { textureId = RequestLoad( url, desiredSize, fittingMode, samplingMode, TextureManager::NO_ATLAS, textureObserver, orientationCorrection, reloadPolicy, preMultiplyOnLoad ); -- 2.7.4 From 22145128af65439a70266fd55533efaf9db78579 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Mon, 6 Jul 2020 17:55:33 +0900 Subject: [PATCH 06/16] DALi Version 1.5.18 Change-Id: I20a7a54967ece305e8db8faa5c332bf4cccf5faa Signed-off-by: Seungho, Baek --- dali-toolkit/public-api/dali-toolkit-version.cpp | 2 +- packaging/dali-toolkit.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 1553ce2..1fc75cb 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 5; -const unsigned int TOOLKIT_MICRO_VERSION = 17; +const unsigned int TOOLKIT_MICRO_VERSION = 18; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 71dced0..ee0f96b 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: Dali 3D engine Toolkit -Version: 1.5.17 +Version: 1.5.18 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT -- 2.7.4 From 946af1f4d8c0e6d04868ae73fef6299943ac960e Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Fri, 26 Jun 2020 15:44:13 +0100 Subject: [PATCH 07/16] Fixes for the CMake build on MS-Windows. Change-Id: I4812a6292521f777c3e020130c84da794b8f007e Signed-off-by: Victor Cebollada --- build/tizen/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index fde4eb2..0423307 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -283,6 +283,8 @@ IF( WIN32 ) FIND_PACKAGE( unofficial-angle REQUIRED ) FIND_PACKAGE( unofficial-cairo REQUIRED ) + FIND_PACKAGE( WebP REQUIRED ) + SET( DALIADAPTOR_LDFLAGS "${DALIADAPTOR_LDFLAGS}" dali-adaptor::dali-adaptor ) -- 2.7.4 From 651ecbbdae3201c84119a5efd4e6c54d382abe3f Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 30 Jun 2020 16:48:44 +0100 Subject: [PATCH 08/16] Fixed SVACE error in TextVisual Change-Id: Icf15764d48b0b879577451172bced309bfffada4 --- dali-toolkit/internal/visuals/text/text-visual.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) mode change 100755 => 100644 dali-toolkit/internal/visuals/text/text-visual.cpp diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp old mode 100755 new mode 100644 index a3057c3..04f3618 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -820,8 +820,11 @@ void TextVisual::AddRenderer( Actor& actor, const Vector2& size, bool hasMultipl // Get the current offset for recalculate the offset when tiling. Property::Map retMap; mImpl->mTransform.GetPropertyMap( retMap ); - Vector2 offSet = retMap.Find( Dali::Toolkit::Visual::Transform::Property::OFFSET )->Get< Vector2 >(); - info.offSet = offSet; + Property::Value* offsetValue = retMap.Find( Dali::Toolkit::Visual::Transform::Property::OFFSET ); + if( offsetValue ) + { + offsetValue->Get( info.offSet ); + } // Create a textureset in the default renderer. CreateTextureSet( info, mImpl->mRenderer, sampler, hasMultipleTextColors, containsColorGlyph, styleEnabled ); -- 2.7.4 From cad91bf56a353ee70a33952d3968597a012a19b6 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Thu, 9 Jul 2020 13:19:03 +0900 Subject: [PATCH 09/16] DALi Version 1.5.19 Change-Id: I9d341fff0e8e67a550e6d459df55021ba0411716 Signed-off-by: Seungho, Baek --- dali-toolkit/public-api/dali-toolkit-version.cpp | 2 +- packaging/dali-toolkit.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 1fc75cb..57cd508 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 5; -const unsigned int TOOLKIT_MICRO_VERSION = 18; +const unsigned int TOOLKIT_MICRO_VERSION = 19; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index ee0f96b..ba76dd8 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: Dali 3D engine Toolkit -Version: 1.5.18 +Version: 1.5.19 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT -- 2.7.4 From 2c7f0246a7bbfeb207fcd84a68c41dbeff0a24f0 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Mon, 6 Jul 2020 15:41:28 +0900 Subject: [PATCH 10/16] (Vector) Ensure not to add duplicated task Change-Id: I3f023b6615ca36b40ddc3534fd8faab7985eb08e --- .../utc-Dali-AnimatedVectorImageVisual.cpp | 4 ++ .../vector-animation-task.cpp | 15 +----- .../animated-vector-image/vector-animation-task.h | 1 - .../vector-animation-thread.cpp | 60 +++++++++++++++++----- .../vector-animation-thread.h | 1 + 5 files changed, 53 insertions(+), 28 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 7816a11..8e19dcb 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -270,6 +270,8 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) application.SendNotification(); application.Render(); + std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run + Property::Map resultMap; resultMap = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); @@ -679,6 +681,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) application.SendNotification(); application.Render(); + std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run + map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); value = map.Find( DevelImageVisual::Property::PLAY_RANGE ); diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index 55968e1..bae4fbc 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -70,7 +70,6 @@ VectorAnimationTask::VectorAnimationTask( VisualFactoryCache& factoryCache, cons mAnimationDataIndex( 0 ), mLoopCount( LOOP_FOREVER ), mCurrentLoop( 0 ), - mResourceReady( false ), mForward( true ), mUpdateFrameNumber( false ), mNeedAnimationFinishedTrigger( true ), @@ -138,8 +137,6 @@ void VectorAnimationTask::SetSize( uint32_t width, uint32_t height ) mWidth = width; mHeight = height; - mResourceReady = false; - DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetSize: width = %d, height = %d [%p]\n", width, height, this ); } } @@ -148,6 +145,7 @@ void VectorAnimationTask::PlayAnimation() { if( mPlayState != PlayState::PLAYING ) { + mNeedAnimationFinishedTrigger = true; mUpdateFrameNumber = false; mPlayState = PlayState::PLAYING; @@ -266,12 +264,10 @@ void VectorAnimationTask::SetPlayRange( const Property::Array& playRange ) if( mStartFrame > mCurrentFrame ) { mCurrentFrame = mStartFrame; - mResourceReady = false; } else if( mEndFrame < mCurrentFrame ) { mCurrentFrame = mEndFrame; - mResourceReady = false; } DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%p]\n", mStartFrame, mEndFrame, this ); @@ -302,7 +298,6 @@ void VectorAnimationTask::SetCurrentFrameNumber( uint32_t frameNumber ) { mCurrentFrame = frameNumber; mUpdateFrameNumber = false; - mResourceReady = false; DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this ); } @@ -394,10 +389,7 @@ bool VectorAnimationTask::Rasterize() currentFrame = mCurrentFrame; - // Reset values - mResourceReady = true; mUpdateFrameNumber = true; - mNeedAnimationFinishedTrigger = true; if( mPlayState == PlayState::STOPPING ) { @@ -462,11 +454,6 @@ bool VectorAnimationTask::Rasterize() { DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this ); mUpdateFrameNumber = false; - - if( !mResourceReady ) - { - mResourceReady = false; - } } } diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h index 79c3ee2..844d378 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h @@ -309,7 +309,6 @@ private: uint32_t mAnimationDataIndex; int32_t mLoopCount; int32_t mCurrentLoop; - bool mResourceReady; bool mForward; bool mUpdateFrameNumber; bool mNeedAnimationFinishedTrigger; diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp index 8403e6a..c80e00a 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp @@ -59,6 +59,7 @@ Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New( Debug::NoLogging, VectorAnimationThread::VectorAnimationThread() : mAnimationTasks(), mCompletedTasks(), + mWorkingTasks(), mRasterizers( GetNumberOfThreads( NUMBER_OF_RASTERIZE_THREADS_ENV, DEFAULT_NUMBER_OF_RASTERIZE_THREADS ), [&]() { return RasterizeHelper( *this ); } ), mSleepThread( MakeCallback( this, &VectorAnimationThread::OnAwakeFromSleep ) ), mConditionalWait(), @@ -75,6 +76,7 @@ VectorAnimationThread::~VectorAnimationThread() { ConditionalWait::ScopedLock lock( mConditionalWait ); mDestroyThread = true; + mNeedToSleep = false; mConditionalWait.Notify( lock ); } @@ -108,6 +110,7 @@ void VectorAnimationThread::AddTask( VectorAnimationTaskPtr task ) mAnimationTasks.push_back( task ); } + mNeedToSleep = false; // wake up the animation thread mConditionalWait.Notify( lock ); } @@ -115,14 +118,35 @@ void VectorAnimationThread::AddTask( VectorAnimationTaskPtr task ) void VectorAnimationThread::OnTaskCompleted( VectorAnimationTaskPtr task, bool keepAnimation ) { - if( keepAnimation && !mDestroyThread ) + if( !mDestroyThread ) { ConditionalWait::ScopedLock lock( mConditionalWait ); + bool needRasterize = false; + + auto workingTask = std::find( mWorkingTasks.begin(), mWorkingTasks.end(), task ); + if( workingTask != mWorkingTasks.end() ) + { + mWorkingTasks.erase( workingTask ); + } - if( mCompletedTasks.end() == std::find( mCompletedTasks.begin(), mCompletedTasks.end(), task ) ) + // Check pending task + if( mAnimationTasks.end() != std::find( mAnimationTasks.begin(), mAnimationTasks.end(), task ) ) { - mCompletedTasks.push_back( task ); + needRasterize = true; + } + + if( keepAnimation ) + { + if( mCompletedTasks.end() == std::find( mCompletedTasks.begin(), mCompletedTasks.end(), task ) ) + { + mCompletedTasks.push_back( task ); + needRasterize = true; + } + } + if( needRasterize ) + { + mNeedToSleep = false; // wake up the animation thread mConditionalWait.Notify( lock ); } @@ -156,12 +180,12 @@ void VectorAnimationThread::Rasterize() ConditionalWait::ScopedLock lock( mConditionalWait ); // conditional wait - if( (mAnimationTasks.empty() && mCompletedTasks.empty() ) || mNeedToSleep ) + if( mNeedToSleep ) { mConditionalWait.Wait( lock ); } - mNeedToSleep = false; + mNeedToSleep = true; // Process completed tasks for( auto&& task : mCompletedTasks ) @@ -192,10 +216,9 @@ void VectorAnimationThread::Rasterize() mCompletedTasks.clear(); // pop out the next task from the queue - while( !mAnimationTasks.empty() && !mNeedToSleep ) + for( auto it = mAnimationTasks.begin(); it != mAnimationTasks.end(); ) { - std::vector< VectorAnimationTaskPtr >::iterator next = mAnimationTasks.begin(); - VectorAnimationTaskPtr nextTask = *next; + VectorAnimationTaskPtr nextTask = *it; auto currentTime = std::chrono::system_clock::now(); auto nextFrameTime = nextTask->GetNextFrameTime(); @@ -208,17 +231,28 @@ void VectorAnimationThread::Rasterize() if( nextFrameTime <= currentTime ) { - mAnimationTasks.erase( next ); + // If the task is not in the working list + if( std::find( mWorkingTasks.begin(), mWorkingTasks.end(), nextTask ) == mWorkingTasks.end() ) + { + it = mAnimationTasks.erase( it ); + + // Add it to the working list + mWorkingTasks.push_back( nextTask ); - auto rasterizerHelperIt = mRasterizers.GetNext(); - DALI_ASSERT_ALWAYS( rasterizerHelperIt != mRasterizers.End() ); + auto rasterizerHelperIt = mRasterizers.GetNext(); + DALI_ASSERT_ALWAYS( rasterizerHelperIt != mRasterizers.End() ); - rasterizerHelperIt->Rasterize( nextTask ); + rasterizerHelperIt->Rasterize( nextTask ); + } + else + { + it++; + } } else { - mNeedToSleep = true; mSleepThread.SleepUntil( nextFrameTime ); + break; } } } diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h index 8d3dd64..964f662 100755 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h @@ -183,6 +183,7 @@ private: std::vector< VectorAnimationTaskPtr > mAnimationTasks; std::vector< VectorAnimationTaskPtr > mCompletedTasks; + std::vector< VectorAnimationTaskPtr > mWorkingTasks; RoundRobinContainerView< RasterizeHelper > mRasterizers; SleepThread mSleepThread; ConditionalWait mConditionalWait; -- 2.7.4 From 08566df88fd60a844011c19b5bf6cc26ad1fc655 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Thu, 9 Jul 2020 18:37:43 +0900 Subject: [PATCH 11/16] Divide Render() into small apis Change-Id: If20f7a5cef20386e2aeb00cf1d3e283b10da3e93 --- dali-toolkit/devel-api/text/text-utils-devel.cpp | 511 +++++++++++++++-------- 1 file changed, 333 insertions(+), 178 deletions(-) diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index fc8afb9..ccea7e0 100755 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -104,6 +104,36 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( DevelText::CircularAlignment, CENTER ) DALI_ENUM_TO_STRING_WITH_SCOPE( DevelText::CircularAlignment, END ) DALI_ENUM_TO_STRING_TABLE_END( CIRCULAR_ALIGNMENT_TYPE ) +struct InternalDataModel +{ + InternalDataModel( FontClient& fontClient, + MetricsPtr metrics, + Text::ModelPtr textModel ) + : fontClient( fontClient ), + metrics( metrics ), + textModel( textModel ), + numberOfCharacters{ 0u }, + isTextMirrored{ false }, + numberOfGlyphs{ 0u } + { + layoutEngine.SetMetrics( metrics ); + } + + FontClient& fontClient; + MetricsPtr metrics; + Text::Layout::Engine layoutEngine; ///< The layout engine. + Text::ModelPtr textModel; ///< Pointer to the text's model. + Vector blendingMode; ///< How embedded items and bitmap font glyphs are blended with color text. + Vector isEmoji; ///< Whether the glyph is an emoji. + + Vector mirroredUtf32Characters; // The utf32Characters Characters but mirrored if there are RTL text. + + Length numberOfCharacters; // The number of characters (not glyphs!). + bool isTextMirrored ; // Whether the text has been mirrored. + + Length numberOfGlyphs; +}; + bool GetLayoutEnumeration(const Property::Value& propertyValue, DevelText::Layout::Type& layout) { return Scripting::GetEnumerationProperty(propertyValue, LAYOUT_TYPE_TABLE, LAYOUT_TYPE_TABLE_COUNT, layout); @@ -114,80 +144,38 @@ bool GetCircularAlignmentEnumeration(const Property::Value& propertyValue, Devel return Scripting::GetEnumerationProperty(propertyValue, CIRCULAR_ALIGNMENT_TYPE_TABLE, CIRCULAR_ALIGNMENT_TYPE_TABLE_COUNT, circularAlignment); } -Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& embeddedItemLayout ) -{ - if( textParameters.text.empty() ) - { - Dali::Devel::PixelBuffer pixelBuffer = Dali::Devel::PixelBuffer::New( textParameters.textWidth, - textParameters.textHeight, - Dali::Pixel::RGBA8888 ); - - const unsigned int bufferSize = textParameters.textWidth * textParameters.textHeight * Dali::Pixel::GetBytesPerPixel(Dali::Pixel::RGBA8888); - unsigned char* buffer = pixelBuffer.GetBuffer(); - memset(buffer, 0, bufferSize); - return pixelBuffer; - } +void ShapeTextPreprocess( const RendererParameters& textParameters, TextAbstraction::TextRenderer::Parameters& rendererParameters, InternalDataModel& internalDataModel ) +{ MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get(); - FontClient fontClient = FontClient::Get(); - MetricsPtr metrics; - Text::Layout::Engine layoutEngine; ///< The layout engine. - Text::ModelPtr textModel = Text::Model::New(); ///< Pointer to the text's model. - Vector blendingMode; ///< How embedded items and bitmap font glyphs are blended with color text. - Vector isEmoji; ///< Whether the glyph is an emoji. - - // Use this to access FontClient i.e. to get down-scaled Emoji metrics. - metrics = Metrics::New( fontClient ); - layoutEngine.SetMetrics( metrics ); - - TextAbstraction::TextRenderer::Parameters rendererParameters( textModel->mVisualModel->mGlyphs, - textModel->mVisualModel->mGlyphPositions, - textModel->mVisualModel->mColors, - textModel->mVisualModel->mColorIndices, - blendingMode, - isEmoji ); + const uint8_t* utf8 = NULL; // pointer to the first character of the text (encoded in utf8) + Length textSize = 0u; // The length of the utf8 string. - rendererParameters.width = textParameters.textWidth; - rendererParameters.height = textParameters.textHeight; - rendererParameters.pixelFormat = TextAbstraction::TextRenderer::Parameters::RGBA8888; // @note: At the moment all textures are generated RGBA8888 + Length& numberOfCharacters = internalDataModel.numberOfCharacters; + Vector& mirroredUtf32Characters = internalDataModel.mirroredUtf32Characters; + Text::ModelPtr& textModel = internalDataModel.textModel; Vector& utf32Characters = textModel->mLogicalModel->mText; // Characters encoded in utf32. - Vector mirroredUtf32Characters; // The utf32Characters Characters but mirrored if there are RTL text. Vector& lineBreakInfo = textModel->mLogicalModel->mLineBreakInfo; // The line break info. Vector& scripts = textModel->mLogicalModel->mScriptRuns; // Charactes's script. Vector& fontDescriptionRuns = textModel->mLogicalModel->mFontDescriptionRuns; // Desired font descriptions. Vector& validFonts = textModel->mLogicalModel->mFontRuns; // Validated fonts. Vector& bidirectionalInfo = textModel->mLogicalModel->mBidirectionalParagraphInfo; // The bidirectional info per paragraph. - //Vector& bidirectionalLineInfo = textModel->mLogicalModel->mBidirectionalLineInfo; // The bidirectional info per line. Vector& directions = textModel->mLogicalModel->mCharacterDirections; // Character's directions. Vector& colorRuns = textModel->mLogicalModel->mColorRuns; // colors of the text. - Vector& glyphsToCharacters = textModel->mVisualModel->mGlyphsToCharacters; // Glyphs to character map. - Vector& charactersToGlyph = textModel->mVisualModel->mCharactersToGlyph; // Characters to glyphs map. - Vector& charactersPerGlyph = textModel->mVisualModel->mCharactersPerGlyph; // Number of characters per glyph. - Vector& glyphsPerCharacter = textModel->mVisualModel->mGlyphsPerCharacter; // The number of glyphs that are shaped. - Vector& lines = textModel->mVisualModel->mLines; // The laid out lines. - - Vector newParagraphGlyphs; // Glyphs for the new paragraph characters. - // the default font's description. FontDescription defaultFontDescription; PointSize26Dot6 defaultPointSize = FontClient::DEFAULT_POINT_SIZE; - Length numberOfCharacters = 0u; // The number of characters (not glyphs!). - bool isTextMirrored = false; // Whether the text has been mirrored. - - const uint8_t* utf8 = NULL; // pointer to the first character of the text (encoded in utf8) - Length textSize = 0u; // The length of the utf8 string. - //////////////////////////////////////////////////////////////////////////////// // Process the markup string if the mark-up processor is enabled. //////////////////////////////////////////////////////////////////////////////// MarkupProcessData markupProcessData( colorRuns, - fontDescriptionRuns, - textModel->mLogicalModel->mEmbeddedItems ); + fontDescriptionRuns, + textModel->mLogicalModel->mEmbeddedItems ); if (textParameters.markupEnabled) { @@ -232,9 +220,9 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& embeddedItemLayout, InternalDataModel& internalDataModel ) +{ + Vector newParagraphGlyphs; // Glyphs for the new paragraph characters. + const Length numberOfCharacters = internalDataModel.numberOfCharacters; + const bool isTextMirrored = internalDataModel.isTextMirrored; + Text::ModelPtr& textModel = internalDataModel.textModel; + const Vector& mirroredUtf32Characters = internalDataModel.mirroredUtf32Characters; + FontClient& fontClient = internalDataModel.fontClient; + const Vector& utf32Characters = textModel->mLogicalModel->mText; // Characters encoded in utf32. + const Vector& lineBreakInfo = textModel->mLogicalModel->mLineBreakInfo; // The line break info. + const Vector& scripts = textModel->mLogicalModel->mScriptRuns; // Charactes's script. + const Vector& validFonts = textModel->mLogicalModel->mFontRuns; // Validated fonts. + + Vector& glyphsToCharacters = textModel->mVisualModel->mGlyphsToCharacters; // Glyphs to character map. + Vector& charactersPerGlyph = textModel->mVisualModel->mCharactersPerGlyph; // Number of characters per glyph. //////////////////////////////////////////////////////////////////////////////// // Retrieve the glyphs. Text shaping @@ -363,7 +368,7 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormVisualModel->CreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters ); textModel->mVisualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters ); - const Length numberOfGlyphs = rendererParameters.glyphs.Count(); + internalDataModel.numberOfGlyphs = rendererParameters.glyphs.Count(); // Once the text has been shaped and the glyphs created it's possible to replace the font id of those glyphs // that represent an image or an item and create the embedded item layout info. @@ -402,12 +407,18 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& blendingMode = internalDataModel.blendingMode; + + Vector& colorRuns = textModel->mLogicalModel->mColorRuns; // colors of the text. - metrics->GetGlyphMetrics( rendererParameters.glyphs.Begin(), numberOfGlyphs ); + Vector& charactersToGlyph = textModel->mVisualModel->mCharactersToGlyph; // Characters to glyphs map. + Vector& glyphsPerCharacter = textModel->mVisualModel->mGlyphsPerCharacter; // The number of glyphs that are shaped. //////////////////////////////////////////////////////////////////////////////// // Set the color runs in glyphs. @@ -418,7 +429,7 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormVisualModel->mColors, textModel->mVisualModel->mColorIndices ); @@ -426,7 +437,7 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormVisualModel->mColors.Insert( textModel->mVisualModel->mColors.Begin(),textParameters.textColor ); // Set how the embedded items are blended with text color. - blendingMode.Resize( numberOfGlyphs, textParameters.isTextColorSet ? ColorBlendingMode::MULTIPLY : ColorBlendingMode::NONE ); + blendingMode.Resize( internalDataModel.numberOfGlyphs, textParameters.isTextColorSet ? ColorBlendingMode::MULTIPLY : ColorBlendingMode::NONE ); if( !textParameters.isTextColorSet ) { @@ -450,7 +461,15 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormVisualModel->mCharactersToGlyph[item.characterIndex]; blendingMode[glyphIndex] = item.colorBlendingMode; } +} +void SetEmojiVector( InternalDataModel& internalDataModel ) +{ + Vector& isEmoji = internalDataModel.isEmoji; + Text::ModelPtr& textModel = internalDataModel.textModel; + const Length numberOfGlyphs = internalDataModel.numberOfGlyphs; + + const Vector& scripts = textModel->mLogicalModel->mScriptRuns; // Charactes's script. //////////////////////////////////////////////////////////////////////////////// // Set the isEmoji Vector //////////////////////////////////////////////////////////////////////////////// @@ -471,120 +490,21 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector( maxAscenderDescender ); - - // Convert CircularAlignment to HorizontalAlignment. - if( isCircularTextLayout ) - { - switch( circularAlignment ) - { - case CircularAlignment::BEGIN: - { - horizontalCircularAlignment = Toolkit::HorizontalAlignment::BEGIN; - break; - } - case CircularAlignment::CENTER: - { - horizontalCircularAlignment = Toolkit::HorizontalAlignment::CENTER; - break; - } - case CircularAlignment::END: - { - horizontalCircularAlignment = Toolkit::HorizontalAlignment::END; - break; - } - } - } - - // Set the layout parameters. - Size textLayoutArea( static_cast( textParameters.textWidth ), - static_cast( textParameters.textHeight ) ); - - if( isCircularTextLayout ) - { - // In a circular layout, the length of the text area depends on the radius. - rendererParameters.radius = radius; - textLayoutArea.width = fabs( Radian( Degree( textParameters.incrementAngle ) ) * static_cast( rendererParameters.radius ) ); - } - - textModel->mHorizontalAlignment = isCircularTextLayout ? horizontalCircularAlignment : horizontalAlignment; - textModel->mLineWrapMode = LineWrap::WORD; - textModel->mIgnoreSpacesAfterText = false; - textModel->mMatchSystemLanguageDirection = false; - Text::Layout::Parameters layoutParameters( textLayoutArea, - textModel ); - - // Resize the vector of positions to have the same size than the vector of glyphs. - rendererParameters.positions.Resize( numberOfGlyphs ); - - // Whether the last character is a new paragraph character. - layoutParameters.isLastNewParagraph = TextAbstraction::IsNewParagraph( textToShape[numberOfCharacters - 1u] ); - // The initial glyph and the number of glyphs to layout. - layoutParameters.startGlyphIndex = 0u; - layoutParameters.numberOfGlyphs = numberOfGlyphs; - layoutParameters.startLineIndex = 0u; - layoutParameters.estimatedNumberOfLines = 1u; - layoutParameters.interGlyphExtraAdvance = 0.f; +void Align( const RendererParameters& textParameters, TextAbstraction::TextRenderer::Parameters& rendererParameters, + Vector& embeddedItemLayout, InternalDataModel& internalDataModel, + Size& textLayoutArea, const Size& newLayoutSize, + const bool isCircularTextLayout, const bool isClockwise, + HorizontalAlignment::Type horizontalAlignment, VerticalAlignment::Type verticalAlignment, CircularAlignment::Type circularAlignment, + const unsigned int radius ) +{ + Text::Layout::Engine& layoutEngine = internalDataModel.layoutEngine; + Text::ModelPtr& textModel = internalDataModel.textModel; + const Length numberOfCharacters = internalDataModel.numberOfCharacters; - // Update the visual model. - Size newLayoutSize; - bool isAutoScrollEnabled = false; - layoutEngine.LayoutText( layoutParameters, - newLayoutSize, - textParameters.ellipsisEnabled, - isAutoScrollEnabled ); + Vector& lines = textModel->mVisualModel->mLines; // The laid out lines. //////////////////////////////////////////////////////////////////////////////// // Align the text. @@ -730,7 +650,7 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& embeddedItemLayout, Size& textLayoutArea, InternalDataModel& internalDataModel ) +{ + Text::ModelPtr& textModel = internalDataModel.textModel; + FontClient& fontClient = internalDataModel.fontClient; + + Vector& lines = textModel->mVisualModel->mLines; // The laid out lines. + Vector& isEmoji = internalDataModel.isEmoji; + //////////////////////////////////////////////////////////////////////////////// // Ellipsis the text. //////////////////////////////////////////////////////////////////////////////// @@ -995,7 +926,149 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& embeddedItemLayout, InternalDataModel& internalDataModel ) +{ + //////////////////////////////////////////////////////////////////////////////// + // Layout the text. + //////////////////////////////////////////////////////////////////////////////// + Text::ModelPtr& textModel = internalDataModel.textModel; + Text::Layout::Engine& layoutEngine = internalDataModel.layoutEngine; + FontClient& fontClient = internalDataModel.fontClient; + const Length numberOfGlyphs = internalDataModel.numberOfGlyphs; + const bool isTextMirrored = internalDataModel.isTextMirrored; + const Vector& mirroredUtf32Characters = internalDataModel.mirroredUtf32Characters; + const Length numberOfCharacters = internalDataModel.numberOfCharacters; + + // Sets the alignment + HorizontalAlignment::Type horizontalAlignment = Toolkit::HorizontalAlignment::CENTER; + HorizontalAlignment::Type horizontalCircularAlignment = Toolkit::HorizontalAlignment::CENTER; + VerticalAlignment::Type verticalAlignment = VerticalAlignment::CENTER; + Layout::Type layout = Layout::SINGLELINE; + CircularAlignment::Type circularAlignment = CircularAlignment::BEGIN; + + Property::Value horizontalAlignmentStr( textParameters.horizontalAlignment ); + GetHorizontalAlignmentEnumeration( horizontalAlignmentStr, horizontalAlignment ); + horizontalCircularAlignment = horizontalAlignment; + + Property::Value verticalAlignmentStr( textParameters.verticalAlignment ); + GetVerticalAlignmentEnumeration( verticalAlignmentStr, verticalAlignment ); + + Property::Value layoutStr( textParameters.layout ); + GetLayoutEnumeration( layoutStr, layout ); + + Property::Value circularAlignmentStr( textParameters.circularAlignment ); + GetCircularAlignmentEnumeration( circularAlignmentStr, circularAlignment ); + + // Whether the layout is multi-line. + const Text::Layout::Engine::Type horizontalLayout = ( Layout::MULTILINE == layout ) ? Text::Layout::Engine::MULTI_LINE_BOX : Text::Layout::Engine::SINGLE_LINE_BOX; + layoutEngine.SetLayout( horizontalLayout ); // TODO: multi-line. + + + // Whether the layout is circular. + const bool isCircularTextLayout = (Layout::CIRCULAR == layout); + const bool isClockwise = isCircularTextLayout && ( 0.f < textParameters.incrementAngle ); + + // Calculates the max ascender or the max descender. + // Is used to calculate the radius of the base line of the text. + float maxAscenderDescender = 0.f; + if( isCircularTextLayout ) + { + FontId currentFontId = 0u; + for( const auto& glyph : rendererParameters.glyphs ) + { + if( currentFontId != glyph.fontId ) + { + currentFontId = glyph.fontId; + FontMetrics metrics; + fontClient.GetFontMetrics(currentFontId, metrics); + maxAscenderDescender = std::max( maxAscenderDescender, isClockwise ? metrics.ascender : metrics.descender ); + } + } + } + const unsigned int radius = textParameters.radius - static_cast( maxAscenderDescender ); + + // Convert CircularAlignment to HorizontalAlignment. + if( isCircularTextLayout ) + { + switch( circularAlignment ) + { + case CircularAlignment::BEGIN: + { + horizontalCircularAlignment = Toolkit::HorizontalAlignment::BEGIN; + break; + } + case CircularAlignment::CENTER: + { + horizontalCircularAlignment = Toolkit::HorizontalAlignment::CENTER; + break; + } + case CircularAlignment::END: + { + horizontalCircularAlignment = Toolkit::HorizontalAlignment::END; + break; + } + } + } + + // Set the layout parameters. + Size textLayoutArea( static_cast( textParameters.textWidth ), + static_cast( textParameters.textHeight ) ); + + if( isCircularTextLayout ) + { + // In a circular layout, the length of the text area depends on the radius. + rendererParameters.radius = radius; + textLayoutArea.width = fabs( Radian( Degree( textParameters.incrementAngle ) ) * static_cast( rendererParameters.radius ) ); + } + // Resize the vector of positions to have the same size than the vector of glyphs. + rendererParameters.positions.Resize( numberOfGlyphs ); + + + + textModel->mHorizontalAlignment = isCircularTextLayout ? horizontalCircularAlignment : horizontalAlignment; + textModel->mLineWrapMode = LineWrap::WORD; + textModel->mIgnoreSpacesAfterText = false; + textModel->mMatchSystemLanguageDirection = false; + Text::Layout::Parameters layoutParameters( textLayoutArea, + textModel ); + + + // Whether the last character is a new paragraph character. + const Vector& textToShape = isTextMirrored ? mirroredUtf32Characters : textModel->mLogicalModel->mText; + layoutParameters.isLastNewParagraph = TextAbstraction::IsNewParagraph( textToShape[numberOfCharacters - 1u] ); + + // The initial glyph and the number of glyphs to layout. + layoutParameters.startGlyphIndex = 0u; + layoutParameters.numberOfGlyphs = numberOfGlyphs; + layoutParameters.startLineIndex = 0u; + layoutParameters.estimatedNumberOfLines = 1u; + layoutParameters.interGlyphExtraAdvance = 0.f; + + // Update the visual model. + Size newLayoutSize; + bool isAutoScrollEnabled = false; + layoutEngine.LayoutText( layoutParameters, + newLayoutSize, + textParameters.ellipsisEnabled, + isAutoScrollEnabled ); + + //////////////////////////////////////////////////////////////////////////////// + // Align the text. + //////////////////////////////////////////////////////////////////////////////// + Align( textParameters, rendererParameters, embeddedItemLayout, internalDataModel, + textLayoutArea, newLayoutSize, isCircularTextLayout, isClockwise, + horizontalAlignment, verticalAlignment, circularAlignment, radius ); + + return textLayoutArea; + +} + + +Devel::PixelBuffer RenderText( const RendererParameters& textParameters, TextAbstraction::TextRenderer::Parameters& rendererParameters ) +{ //////////////////////////////////////////////////////////////////////////////// // Render the text. //////////////////////////////////////////////////////////////////////////////// @@ -1007,6 +1080,88 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& embeddedItemLayout ) +{ + if( textParameters.text.empty() ) + { + Dali::Devel::PixelBuffer pixelBuffer = Dali::Devel::PixelBuffer::New( textParameters.textWidth, + textParameters.textHeight, + Dali::Pixel::RGBA8888 ); + + const unsigned int bufferSize = textParameters.textWidth * textParameters.textHeight * Dali::Pixel::GetBytesPerPixel(Dali::Pixel::RGBA8888); + unsigned char* buffer = pixelBuffer.GetBuffer(); + memset(buffer, 0, bufferSize); + + return pixelBuffer; + } + + FontClient fontClient = FontClient::Get(); + MetricsPtr metrics; + // Use this to access FontClient i.e. to get down-scaled Emoji metrics. + metrics = Metrics::New( fontClient ); + + Text::ModelPtr textModel = Text::Model::New(); + InternalDataModel internalData( fontClient, metrics, textModel ); + + TextAbstraction::TextRenderer::Parameters rendererParameters( internalData.textModel->mVisualModel->mGlyphs, + internalData.textModel->mVisualModel->mGlyphPositions, + internalData.textModel->mVisualModel->mColors, + internalData.textModel->mVisualModel->mColorIndices, + internalData.blendingMode, + internalData.isEmoji ); + + + rendererParameters.width = textParameters.textWidth; + rendererParameters.height = textParameters.textHeight; + rendererParameters.pixelFormat = TextAbstraction::TextRenderer::Parameters::RGBA8888; // @note: At the moment all textures are generated RGBA8888 + + + //////////////////////////////////////////////////////////////////////////////// + // Process the markup string if the mark-up processor is enabled. + //////////////////////////////////////////////////////////////////////////////// + ShapeTextPreprocess( textParameters, rendererParameters, internalData ); + + //////////////////////////////////////////////////////////////////////////////// + // Retrieve the glyphs. Text shaping + //////////////////////////////////////////////////////////////////////////////// + ShapeText( rendererParameters, embeddedItemLayout, internalData ); + + + //////////////////////////////////////////////////////////////////////////////// + // Retrieve the glyph's metrics. + //////////////////////////////////////////////////////////////////////////////// + + metrics->GetGlyphMetrics( rendererParameters.glyphs.Begin(), internalData.numberOfGlyphs ); + + //////////////////////////////////////////////////////////////////////////////// + // Set the color runs in glyphs. + //////////////////////////////////////////////////////////////////////////////// + SetColorSegmentation( textParameters, internalData ); + + + //////////////////////////////////////////////////////////////////////////////// + // Set the isEmoji Vector + //////////////////////////////////////////////////////////////////////////////// + SetEmojiVector( internalData ); + + //////////////////////////////////////////////////////////////////////////////// + // Layout the text and Align the text + //////////////////////////////////////////////////////////////////////////////// + Size textLayoutArea = LayoutText( textParameters, rendererParameters, embeddedItemLayout, internalData ); + + //////////////////////////////////////////////////////////////////////////////// + // Ellipsis the text. + //////////////////////////////////////////////////////////////////////////////// + Ellipsis( textParameters, rendererParameters, embeddedItemLayout, textLayoutArea, internalData ); + + //////////////////////////////////////////////////////////////////////////////// + // Render the text. + //////////////////////////////////////////////////////////////////////////////// + return RenderText( textParameters, rendererParameters ); +} + + Devel::PixelBuffer CreateShadow( const ShadowParameters& shadowParameters ) { // The size of the pixel data. -- 2.7.4 From 3b724dc08e62968be03a00dedaf39bee6261b81d Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Tue, 14 Jul 2020 18:54:20 +0900 Subject: [PATCH 12/16] Revert "[Tizen] Add AutofillContainer class and autofill implementation" This reverts commit 0fe7433266413b9e9656cb39391340ec91af386a. --- CMakeLists.txt | 2 - .../controls/text-controls/autofill-container.cpp | 137 --------- .../controls/text-controls/autofill-container.h | 219 -------------- dali-toolkit/devel-api/file.list | 2 - .../controls/control/control-data-impl.cpp | 36 +-- .../internal/controls/control/control-data-impl.h | 42 --- .../text-controls/autofill-container-impl.cpp | 332 --------------------- .../text-controls/autofill-container-impl.h | 249 ---------------- .../controls/text-controls/text-field-impl.cpp | 25 +- .../controls/text-controls/text-field-impl.h | 2 - dali-toolkit/internal/file.list | 1 - 11 files changed, 5 insertions(+), 1042 deletions(-) delete mode 100644 dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp delete mode 100644 dali-toolkit/devel-api/controls/text-controls/autofill-container.h delete mode 100755 dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp delete mode 100644 dali-toolkit/internal/controls/text-controls/autofill-container-impl.h diff --git a/CMakeLists.txt b/CMakeLists.txt index eba4398..a2fe956 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,6 @@ SET ( SOURCES ${SOURCES} ${devel_api_src_dir}/controls/popup/popup.cpp ${devel_api_src_dir}/controls/shadow-view/shadow-view.cpp ${devel_api_src_dir}/controls/super-blur-view/super-blur-view.cpp - ${devel_api_src_dir}/controls/text-controls/autofill-container.cpp ${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp @@ -162,7 +161,6 @@ SET( SOURCES ${SOURCES} ${internal_src_dir}/controls/slider/slider-impl.cpp ${internal_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp ${internal_src_dir}/controls/table-view/table-view-impl.cpp - ${internal_src_dir}/controls/text-controls/autofill-container-impl.cpp ${internal_src_dir}/controls/text-controls/text-editor-impl.cpp ${internal_src_dir}/controls/text-controls/text-field-impl.cpp ${internal_src_dir}/controls/text-controls/text-label-impl.cpp diff --git a/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp b/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp deleted file mode 100644 index e75ca6f..0000000 --- a/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2019 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -AutofillContainer AutofillContainer::New( const std::string& name ) -{ - return Internal::AutofillContainer::New( name ); -} - -AutofillContainer::AutofillContainer() -{ -} - -AutofillContainer::AutofillContainer( const AutofillContainer& handle ) -: BaseHandle(handle) -{ -} - -AutofillContainer& AutofillContainer::operator=( const AutofillContainer& handle ) -{ - BaseHandle::operator=(handle); - return *this; -} - -AutofillContainer::~AutofillContainer() -{ -} - -AutofillContainer AutofillContainer::DownCast( BaseHandle handle ) -{ - return AutofillContainer( dynamic_cast( handle.GetObjectPtr() ) ); -} - - -void AutofillContainer::AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ) -{ - GetImpl(*this).AddAutofillItem( control, propertyIndex, id, label, hint, isSensitive ); -} - -void AutofillContainer::RemoveAutofillItem( Control control ) -{ - GetImpl(*this).RemoveAutofillItem( control ); -} - -void AutofillContainer::SetFocusedControl( Toolkit::Control focused ) -{ - GetImpl(*this).SetFocusedControl( focused ); -} - -Toolkit::Control AutofillContainer::GetFocusedControl() -{ - return GetImpl(*this).GetFocusedControl(); -} - -void AutofillContainer::SaveAutofillData() -{ - GetImpl(*this).SaveAutofillData(); -} - -void AutofillContainer::RequestFillData() -{ - GetImpl(*this).RequestFillData(); -} - -const std::string& AutofillContainer::GetAutofillServiceName() const -{ - return GetImpl(*this).GetAutofillServiceName(); -} - -const std::string& AutofillContainer::GetAutofillServiceMessage() const -{ - return GetImpl(*this).GetAutofillServiceMessage(); -} - -const std::string& AutofillContainer::GetAutofillServiceImagePath() const -{ - return GetImpl(*this).GetAutofillServiceImagePath(); -} - -unsigned int AutofillContainer::GetListCount() -{ - return GetImpl(*this).GetListCount(); -} - -const std::string& AutofillContainer::GetListItem( unsigned int index ) const -{ - return GetImpl(*this).GetListItem( index ); -} - -void AutofillContainer::SetSelectedItem( const std::string& selected ) -{ - GetImpl(*this).SetSelectedItem( selected ); -} - -AutofillContainer::AutofillContainer( Internal::AutofillContainer* implementation ) -: BaseHandle(implementation) -{ -} - -AutofillContainer::AuthenticationSignalType& AutofillContainer::AutofillServiceShownSignal() -{ - return GetImpl(*this).AutofillServiceShownSignal(); -} - -AutofillContainer::ListShownSignalType& AutofillContainer::AutofillListShownSignal() -{ - return GetImpl(*this).AutofillListShownSignal(); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/text-controls/autofill-container.h b/dali-toolkit/devel-api/controls/text-controls/autofill-container.h deleted file mode 100644 index eecad1a..0000000 --- a/dali-toolkit/devel-api/controls/text-controls/autofill-container.h +++ /dev/null @@ -1,219 +0,0 @@ -#ifndef DALI_TOOLKIT_AUTO_FILL_CONTAINER_H -#define DALI_TOOLKIT_AUTO_FILL_CONTAINER_H - -/* - * Copyright (c) 2019 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. - * - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class AutofillContainer; -} - -/** - * @brief AutofillContainer controls several text input boxes (Dali::Toolkit::TextField and Dali::Toolkit::TextEditor). - * - * It can make these editors a group of text boxes. - */ -class DALI_TOOLKIT_API AutofillContainer : public BaseHandle -{ -public: - - // TODO : Need to update parameter and return value according to each Signal - typedef Signal< void (AutofillContainer&) > AuthenticationSignalType; ///< Authentication Signal Type - typedef Signal< void (Control&) > ListShownSignalType; ///< List Shown Signal Type - -public: - - /** - * @brief Creates the AutofillContainer. - * - * @param[in] name The AutofillContainer name - * @return A handle to the AutofillContainer - */ - static AutofillContainer New( const std::string& name ); - - /** - * @brief Creates an empty handle. - */ - AutofillContainer(); - - /** - * @brief Copy constructor. - * - * @param[in] handle The handle to copy from - */ - AutofillContainer( const AutofillContainer& handle ); - - /** - * @brief Assignment operator. - * - * @param[in] handle The handle to copy from - * @return A reference to this - */ - AutofillContainer& operator=( const AutofillContainer& handle ); - - /** - * @brief Destructor. - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~AutofillContainer(); - - /** - * @brief Downcasts a handle to AutofillContainer. - * - * If the BaseHandle points is a AutofillContainer, the downcast returns a valid handle. - * If not, the returned handle is left empty. - * - * @param[in] handle Handle to an object - * @return Handle to a AutofillContainer or an empty handle - */ - static AutofillContainer DownCast( BaseHandle handle ); - - /** - * @brief Adds Control and AutofillItem information to Autofill Container. - * - * @param[in] control The control to be added to Autofill Container - * @param[in] propertyIndex The Property to be filled automatically of each Control - * @param[in] id A unique ID that does not always change on each launching - * @param[in] label An auxiliary means to guess heuristically what data is - * @param[in] hint The Hint - id (username), name, password, phone, credit card number, organization, and so on - * @param[in] isSensitive Whether this information is a sensitive data or not - */ - void AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ); - - /** - * @brief Removes Control and its AutofillItem information to Autofill Container. - * - * @param[in] control The control to be removed - */ - void RemoveAutofillItem( Control control ); - - /** - * @brief Sets that a control is focused. - * - * @param focused The focused control - */ - void SetFocusedControl( Toolkit::Control focused ); - - /** - * @brief Gets the focused control. - * - * @return The focused control - */ - Toolkit::Control GetFocusedControl(); - - /** - * @brief Stores autofill data. - */ - void SaveAutofillData(); - - /** - * @brief Sends a request for filling the data. - */ - void RequestFillData(); - - /** - * @brief Gets the Autofill Service Name. - * - * @return Autofill Service Name - */ - const std::string& GetAutofillServiceName() const; - - /** - * @brief Gets the Autofill Service Message. - * - * @return Autofill Service Message - */ - const std::string& GetAutofillServiceMessage() const; - - /** - * @brief Gets the Autofill Service Image Path. - * - * @return Autofill Service Image Path - */ - const std::string& GetAutofillServiceImagePath() const; - - /** - * @brief Gets the number of list items. (The presentation text of Autofill) - * - * @return The number of list items - */ - unsigned int GetListCount(); - - /** - * @brief Gets the list item of the index. - * - * @param[in] index The index for the list - * @return The list item of the index - */ - const std::string& GetListItem( unsigned int index ) const; - - /** - * @brief Sets the selected item to fill out. - * - * @param[in] selected The selected item - */ - void SetSelectedItem( const std::string& selected ); - -public: - // Signals - - /** - * @brief AutofillServiceShownSignal - * - * @return The signal containing the received data - */ - AuthenticationSignalType& AutofillServiceShownSignal(); - - /** - * @brief AutofillListShownSignal - * - * @return The signal containing the received data - */ - ListShownSignalType& AutofillListShownSignal(); - - -public: // Not intended for application developers - - /** - * @brief Creates a handle using the Toolkit::Internal implementation. - * - * @param[in] implementation The Control implementation - */ - DALI_INTERNAL AutofillContainer( Internal::AutofillContainer* implementation ); - -}; - - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_AUTO_FILL_CONTAINER_H diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 721a456..36f0649 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -26,7 +26,6 @@ SET( devel_api_src_files ${devel_api_src_dir}/controls/scene3d-view/scene3d-view.cpp ${devel_api_src_dir}/controls/shadow-view/shadow-view.cpp ${devel_api_src_dir}/controls/super-blur-view/super-blur-view.cpp - ${devel_api_src_dir}/controls/text-controls/autofill-container.cpp ${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp @@ -180,7 +179,6 @@ SET( devel_api_super_blur_view_header_files ) SET( devel_api_text_controls_header_files - ${devel_api_src_dir}/controls/text-controls/autofill-container.h ${devel_api_src_dir}/controls/text-controls/text-editor-devel.h ${devel_api_src_dir}/controls/text-controls/text-field-devel.h ${devel_api_src_dir}/controls/text-controls/text-label-devel.h diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index b49a8c5..eb6285a 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -313,6 +313,7 @@ const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocu const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_15( typeRegistration, "shadow", Toolkit::DevelControl::Property::SHADOW, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); + Control::Impl::Impl( Control& controlImpl ) : mControlImpl( controlImpl ), mState( Toolkit::DevelControl::NORMAL ), @@ -337,12 +338,9 @@ Control::Impl::Impl( Control& controlImpl ) mLongPressGestureDetector(), mTooltip( NULL ), mInputMethodContext(), - mAutofillItem(), - mAutofillContainer(), mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mIsKeyboardNavigationSupported( false ), - mIsKeyboardFocusGroup( false ), - mIsAutofillEnabled( false ) + mIsKeyboardFocusGroup( false ) { } @@ -1452,36 +1450,6 @@ void Control::Impl::ClearShadow() mControlImpl.RelayoutRequest(); } -void Control::Impl::SetAutofillEnabled( bool autofillEnabled ) -{ - mIsAutofillEnabled = autofillEnabled; -} - -bool Control::Impl::IsAutofillEnabled() -{ - return mIsAutofillEnabled; -} - -void Control::Impl::SetAutofillItemHandle( Dali::AutofillItem item ) -{ - mAutofillItem = item; -} - -Dali::AutofillItem Control::Impl::GetAutofillItemHandle() -{ - return mAutofillItem; -} - -void Control::Impl::SetAutofillContainer( Toolkit::AutofillContainer container ) -{ - mAutofillContainer = container; -} - -Toolkit::AutofillContainer Control::Impl::GetAutofillContainer() -{ - return mAutofillContainer; -} - } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 9648cd6..210f6e2 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -21,14 +21,11 @@ // EXTERNAL INCLUDES #include #include -#include -#include #include // INTERNAL INCLUDES #include #include -#include #include #include #include @@ -349,42 +346,6 @@ public: * @brief Clear the shadow. */ void ClearShadow(); - - /** - * @brief Sets whether the Autofill functionality is enabled. - * @param[in] autofillEnabled Set true when Autofill should be enabled. - */ - void SetAutofillEnabled( bool autofillEnabled ); - - /** - * @brief Check if the Autofill framework is enabled. - * @return True if Autofill is enabled - */ - bool IsAutofillEnabled(); - - /** - * @brief Sets AutofillItemHandle - * @param item AutofillItem handle - */ - void SetAutofillItemHandle( Dali::AutofillItem item ); - - /** - * @brief Gets AutofillItemHandle - * @return AutofillItem handle - */ - Dali::AutofillItem GetAutofillItemHandle(); - - /** - * @brief Sets AutofillContainer which this control belongs to. - * @param[in] container - */ - void SetAutofillContainer( Toolkit::AutofillContainer container ); - - /** - * @brief Gets AutofillContainer that the control belongs to. - * @return AutofillContainer handle - */ - Toolkit::AutofillContainer GetAutofillContainer(); private: @@ -458,13 +419,10 @@ public: TooltipPtr mTooltip; InputMethodContext mInputMethodContext; - AutofillItem mAutofillItem; - Toolkit::AutofillContainer mAutofillContainer; ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor. bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control. bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group. - bool mIsAutofillEnabled : 1; ///< Stroes whether the Autofill functionality is enabled. RegisteredVisualContainer mRemoveVisuals; ///< List of visuals that are being replaced by another visual once ready diff --git a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp deleted file mode 100755 index 6c9628b..0000000 --- a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2019 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. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include // for strcmp -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace -{ - -#if defined ( DEBUG_ENABLED ) - Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_AUTOFILL_CONTAINER"); -#endif - -// Type registration -BaseHandle Create() -{ - return Toolkit::AutofillContainer::New( "" ); -} - -// Setup properties, signals and actions using the type-registry. -DALI_TYPE_REGISTRATION_BEGIN( Toolkit::AutofillContainer, Dali::BaseHandle, Create ); - -DALI_SIGNAL_REGISTRATION( Toolkit, AutofillContainer, "serviceShown", SIGNAL_SERVICE_SHOWN ) -DALI_SIGNAL_REGISTRATION( Toolkit, AutofillContainer, "listShown", SIGNAL_LIST_SHOWN ) - -DALI_TYPE_REGISTRATION_END() - -} // namespace - -Toolkit::AutofillContainer AutofillContainer::New( const std::string& name ) -{ - // Create the implementation, temporarily owned by this handle on stack - Internal::AutofillContainer* impl = new AutofillContainer(); - - // Pass ownership to CustomActor handle - Toolkit::AutofillContainer handle( impl ); - impl->Initialize( name ); - - return handle; -} - -void AutofillContainer::Initialize( const std::string& name ) -{ - mAutofillManager = Dali::AutofillManager::Get(); - mAutofillGroup = mAutofillManager.CreateAutofillGroup( name ); - - // If the authentication is needed, AuthenticationReceivedSignal would be emitted. - mAutofillManager.AuthenticationReceivedSignal().Connect( mSlotDelegate, &AutofillContainer::OnAutofillAuthReceived ); - - // If the data to be filled is present, FillResponseReceivedSignal would be emitted. - mAutofillManager.FillResponseReceivedSignal().Connect( mSlotDelegate, &AutofillContainer::OnDataFillReceived ); - - // If the values to be filled are multiple, ListEventSignal would be emitted. - mAutofillManager.ListEventSignal().Connect( mSlotDelegate, &AutofillContainer::OnListReceived ); -} - -void AutofillContainer::AddAutofillItem( Dali::Toolkit::Control control, Dali::Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ) -{ - if( control ) - { - Dali::AutofillItem item = mAutofillManager.CreateAutofillItem( id, label, static_cast(hint), isSensitive ); - - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - controlDataImpl.SetAutofillContainer( this ); - controlDataImpl.SetAutofillEnabled( true ); - controlDataImpl.SetAutofillItemHandle( item ); // TODO : This instance would be here as... std::map or pair - - mAutofillGroup.AddAutofillItem( item ); - - mPropertyIndex = propertyIndex; - - // TODO : Remove the mControlItemList below and replace it. - mControlList.push_back( std::pair< Dali::Toolkit::Control, Dali::AutofillItem >( control, item ) ); - - // Push back a Control to the list - mControlItemList.push_back( control ); - } -} - -void AutofillContainer::RemoveAutofillItem( Dali::Toolkit::Control control ) -{ - if( control ) - { - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - controlDataImpl.SetAutofillEnabled( false ); - // TODO : Put the control out the list - } -} - -Dali::AutofillGroup AutofillContainer::GetAutofillGroup() -{ - return mAutofillGroup; -} - -void AutofillContainer::SetFocusedControl( Toolkit::Control focused ) -{ - mCurrentFocused = focused; -} - -Toolkit::Control AutofillContainer::GetFocusedControl() -{ - return mCurrentFocused; -} - -void AutofillContainer::SaveAutofillData() -{ - for( std::vector::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter ) - { - std::string controlValue = (*iter).GetProperty( mPropertyIndex ); - Internal::Control& controlImpl = GetImplementation( *iter ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - controlDataImpl.GetAutofillItemHandle().SetSaveValue( controlValue ); - } - - // Sends request to save the current autofill data - mAutofillGroup.SaveAutofillData(); - mAutofillManager.SaveAutofillData( mAutofillGroup ); -} - -void AutofillContainer::RequestFillData() -{ - // Sends fill request to fill out the data. - mAutofillGroup.SendFillRequest(); -} - -void AutofillContainer::SetAutofillServiceName( const std::string& serviceName ) -{ - mAutofillServiceName = serviceName; -} - -const std::string& AutofillContainer::GetAutofillServiceName() const -{ - return mAutofillServiceName; -} - -void AutofillContainer::SetAutofillServiceMessage( const std::string& serviceMessage ) -{ - mAutofillServiceMessage = serviceMessage; -} - -const std::string& AutofillContainer::GetAutofillServiceMessage() const -{ - return mAutofillServiceMessage; -} - -void AutofillContainer::SetAutofillServiceImagePath( const std::string& serviceImagePath ) -{ - mAutofillServiceImagePath = serviceImagePath; -} - -const std::string& AutofillContainer::GetAutofillServiceImagePath() const -{ - return mAutofillServiceImagePath; -} - -unsigned int AutofillContainer::GetListCount() -{ - Toolkit::Control control = mCurrentFocused; - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - return controlDataImpl.GetAutofillItemHandle().GetFillValueCount(); -} - -const std::string& AutofillContainer::GetListItem( unsigned int index ) const -{ - Toolkit::Control control = mCurrentFocused; - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - return controlDataImpl.GetAutofillItemHandle().GetPresentationText( index ); -} - -void AutofillContainer::SetSelectedItem( const std::string& selected ) -{ - Toolkit::Control control = mCurrentFocused; - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - unsigned int count = controlDataImpl.GetAutofillItemHandle().GetFillValueCount(); - unsigned int index = 0; - for( index = 0; index < count; index++ ) - { - std::string presentationText = controlDataImpl.GetAutofillItemHandle().GetPresentationText( index ); - if( 0 == strcmp( presentationText.c_str(), selected.c_str() ) ) - { - break; - } - } - - for( std::vector::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter ) - { - Internal::Control& controlImpl = GetImplementation( *iter ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - std::string fillValue = controlDataImpl.GetAutofillItemHandle().GetFillValue( index ); - (*iter).SetProperty( Toolkit::TextField::Property::TEXT, fillValue ); - } -} - -// -void AutofillContainer::OnAutofillAuthReceived() -{ - SetAutofillServiceName( mAutofillManager.GetAuthenticationServiceName() ); - SetAutofillServiceMessage( mAutofillManager.GetAuthenticationServiceMessage() ); - SetAutofillServiceImagePath( mAutofillManager.GetAuthenticationServiceImagePath() ); - - Dali::Toolkit::AutofillContainer handle( this ); - mAuthenticationEventSignal.Emit( handle ); - - DALI_LOG_ERROR(" [ Emit DALi signal to receive the auth information ] \n"); - -} - -void AutofillContainer::OnDataFillReceived( Dali::AutofillItem item ) -{ - for( std::vector::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter ) - { - Internal::Control& controlImpl = GetImplementation( *iter ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - - if( 0 == strcmp( controlDataImpl.GetAutofillItemHandle().GetId().c_str(), item.GetId().c_str() ) ) - { - // TODO : Is the index for fill data always 0 in this case? - std::string itemText = controlDataImpl.GetAutofillItemHandle().GetFillValue( 0 ); - (*iter).SetProperty( Toolkit::TextField::Property::TEXT, itemText ); - } - } - -} - -void AutofillContainer::OnListReceived() -{ - mListEventSignal.Emit( mCurrentFocused ); - -} - - -AutofillContainer::AutofillContainer() -: mAutofillManager(), - mAutofillGroup(), - mControlItemList(), - mControlList(), - mSlotDelegate( this ), - mPropertyIndex( Property::INVALID_INDEX ), - mAutofillServiceName( "" ), - mAutofillServiceMessage( "" ), - mAutofillServiceImagePath( "" ), - mCurrentFocused() -{ -} - -AutofillContainer::~AutofillContainer() -{ - mAutofillManager.AuthenticationReceivedSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnAutofillAuthReceived ); - mAutofillManager.FillResponseReceivedSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnDataFillReceived ); - mAutofillManager.ListEventSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnListReceived ); -} - -// Signals -Toolkit::AutofillContainer::AuthenticationSignalType& AutofillContainer::AutofillServiceShownSignal() -{ - return mAuthenticationEventSignal; -} - -Toolkit::AutofillContainer::ListShownSignalType& AutofillContainer::AutofillListShownSignal() -{ - return mListEventSignal; -} - -bool AutofillContainer::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) -{ - Dali::BaseHandle handle( object ); - - bool connected( true ); - Toolkit::AutofillContainer container = Toolkit::AutofillContainer::DownCast( handle ); - - if( container ) - { - if( 0 == signalName.compare( SIGNAL_SERVICE_SHOWN ) ) - { - container.AutofillServiceShownSignal().Connect( tracker, functor ); - } - else if( 0 == signalName.compare( SIGNAL_LIST_SHOWN ) ) - { - container.AutofillListShownSignal().Connect( tracker, functor ); - } - else - { - // signalName does not match any signal - connected = false; - } - } - - return connected; -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h deleted file mode 100644 index 1ef8262..0000000 --- a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h +++ /dev/null @@ -1,249 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H -#define DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H - -/* - * Copyright (c) 2019 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include - - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -/** - * @copydoc Toolkit::AutofillContainer - */ -class AutofillContainer : public Dali::BaseObject -{ -public: - - /** - * @copydoc Dali::Toollkit::AutofillContainer::New() - */ - static Toolkit::AutofillContainer New( const std::string& name ); - - /** - * @brief Initialize AutofillContainer - */ - void Initialize( const std::string& name ); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::AddAutofillItem() - */ - void AddAutofillItem( Dali::Toolkit::Control control, Dali::Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::RemoveAutofillItem() - */ - void RemoveAutofillItem( Dali::Toolkit::Control control ); - - /** - * @brief Gets AutofillGroup setting to AutofillContainer. - * - * @return The AutofillGroup instance - */ - Dali::AutofillGroup GetAutofillGroup(); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::SetFocusedControl() - */ - void SetFocusedControl( Toolkit::Control focused ); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::GetFocusedControl() - */ - Toolkit::Control GetFocusedControl(); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::SaveAutofillData() - */ - void SaveAutofillData(); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::RequestFillData() - */ - void RequestFillData(); - - /** - * @brief Sets the Autofill Service Name - * - * @param serviceName Autofill Service Name - */ - void SetAutofillServiceName( const std::string& serviceName ); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceName() - */ - const std::string& GetAutofillServiceName() const; - - /** - * @brief Sets the Autofill Service Message - * - * @param serviceMessage Autofill Service Message - */ - void SetAutofillServiceMessage( const std::string& serviceMessage ); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceMessage() - */ - const std::string& GetAutofillServiceMessage() const; - - /** - * @brief Sets the Autofill Service Image Path - * - * @param serviceImagePath Autofill Service Image Path - */ - void SetAutofillServiceImagePath( const std::string& serviceImagePath ); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceImagePath() - */ - const std::string& GetAutofillServiceImagePath() const; - - /** - * @copydoc Dali::Toollkit::AutofillContainer::GetListCount() - */ - unsigned int GetListCount(); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::GetListItem() - */ - const std::string& GetListItem( unsigned int index ) const; - - /** - * @copydoc Dali::Toollkit::AutofillContainer::SetSelectedItem() - */ - void SetSelectedItem( const std::string& selected ); - - /** - * @brief Callback when Autofill Authentication information is recieved. - */ - void OnAutofillAuthReceived(); - - /** - * @brief Callback when Autofill Fill Response is recieved. - * @param[in] item The callback parameter - */ - void OnDataFillReceived( Dali::AutofillItem item ); - - /** - * @brief Callback when the values to be filled are multiple. - */ - void OnListReceived(); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::AutofillServiceShownSignal() - */ - Toolkit::AutofillContainer::AuthenticationSignalType& AutofillServiceShownSignal(); - - /** - * @copydoc Dali::Toollkit::AutofillContainer::AutofillListShownSignal() - */ - Toolkit::AutofillContainer::ListShownSignalType& AutofillListShownSignal(); - - /** - * Connects a callback function with the object's signals. - * @param[in] object The object providing the signal. - * @param[in] tracker Used to disconnect the signal. - * @param[in] signalName The signal to connect to. - * @param[in] functor A newly allocated FunctorDelegate. - * @return True if the signal was connected. - * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. - */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); - - -private: // Implementation - - /** - * Construct a new AutofillContainer. - */ - AutofillContainer(); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~AutofillContainer(); - -private: - - // Undefined copy constructor and assignment operators - AutofillContainer(const AutofillContainer&); - AutofillContainer& operator=(const AutofillContainer& rhs); - -private: // Data - - Dali::AutofillManager mAutofillManager; - Dali::AutofillGroup mAutofillGroup; - std::vector mControlItemList; ///< The List of Control adding to AutofillContainer - //std::map mControlList; - std::vector< std::pair< Dali::Toolkit::Control, Dali::AutofillItem > > mControlList; - - SlotDelegate< AutofillContainer > mSlotDelegate; - - Property::Index mPropertyIndex; ///< The index of property registered by each control - - Toolkit::AutofillContainer::AuthenticationSignalType mAuthenticationEventSignal; - Toolkit::AutofillContainer::ListShownSignalType mListEventSignal; - - std::string mAutofillServiceName; - std::string mAutofillServiceMessage; - std::string mAutofillServiceImagePath; - - Toolkit::Control mCurrentFocused; -}; - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Toolkit::Internal::AutofillContainer& GetImpl( Toolkit::AutofillContainer& autofillContainer ) -{ - DALI_ASSERT_ALWAYS(autofillContainer); - - Dali::BaseObject& handle = autofillContainer.GetBaseObject(); - - return static_cast(handle); -} - -inline const Toolkit::Internal::AutofillContainer& GetImpl( const Toolkit::AutofillContainer& autofillContainer ) -{ - DALI_ASSERT_ALWAYS(autofillContainer); - - const Dali::BaseObject& handle = autofillContainer.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 33d9689..2b4fcc0 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -37,8 +37,6 @@ #include #include #include -#include -#include #include #include #include @@ -1587,7 +1585,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) void TextField::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() ); - if( mInputMethodContext ) + if ( mInputMethodContext ) { mInputMethodContext.ApplyOptions( mInputMethodOptions ); @@ -1601,30 +1599,13 @@ void TextField::OnKeyInputFocusGained() // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated. mInputMethodContext.SetRestoreAfterFocusLost( true ); } - ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); - if( notifier ) + + if ( notifier ) { notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected ); } - Toolkit::Control control = Toolkit::Control::DownCast( Self() ); - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - bool enableAutofill = controlDataImpl.IsAutofillEnabled(); - if( enableAutofill ) - { - Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer(); - container.SetFocusedControl( control ); - - Internal::AutofillContainer& containerImpl = GetImpl( container ); - Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup(); - if( containerGroup != nullptr ) - { - containerGroup.RequestAuthentication(); - } - - } mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last. diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 59bedf8..2991931 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include #include -#include // INTERNAL INCLUDES #include @@ -292,7 +291,6 @@ private: // Data Toolkit::Control mStencil; ///< For EXCEED_POLICY_CLIP std::vector mClippingDecorationActors; ///< Decoration actors which need clipping. Dali::InputMethodOptions mInputMethodOptions; - Dali::AutofillItem mAutofillItem; Actor mRenderableActor; Actor mActiveLayer; diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index b9fde11..246ba89 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -95,7 +95,6 @@ SET( toolkit_src_files ${toolkit_src_dir}/controls/slider/slider-impl.cpp ${toolkit_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp ${toolkit_src_dir}/controls/table-view/table-view-impl.cpp - ${toolkit_src_dir}/controls/text-controls/autofill-container-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-editor-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-field-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-label-impl.cpp -- 2.7.4 From e4d9ad343fb6daa616423ba59039aed85d5e406f Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Tue, 14 Jul 2020 18:54:30 +0900 Subject: [PATCH 13/16] Revert "[Tizen] Restore behavior of Uploaded and LoadingFinished signal" This reverts commit a21d7401ca0cb826b788256117faa9f7423713e2. --- .../internal/controls/image-view/image-view-impl.cpp | 16 ---------------- .../internal/controls/image-view/image-view-impl.h | 5 ----- 2 files changed, 21 deletions(-) diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index c07355a..9843128 100755 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -237,22 +237,6 @@ void ImageView::SetDepthIndex( int depthIndex ) } } -void ImageView::OnStageConnection( int depth ) -{ - if( mImage ) - { - mImage.UploadedSignal().Emit( mImage ); - } - - Dali::ResourceImage resourceImage = Dali::ResourceImage::DownCast( mImage ); - if( resourceImage ) - { - resourceImage.LoadingFinishedSignal().Emit( resourceImage ); - } - - Control::OnStageConnection( depth ); // Enabled visuals will be put on stage -} - Vector3 ImageView::GetNaturalSize() { if( mVisual ) diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.h b/dali-toolkit/internal/controls/image-view/image-view-impl.h index 0a8fbd8..382feb8 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.h +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.h @@ -128,11 +128,6 @@ private: // From Control void OnInitialize(); /** - * @copydoc CustomActorImpl::OnStageConnection() - */ - virtual void OnStageConnection( int depth ); - - /** * @copydoc Toolkit::Control::GetNaturalSize */ virtual Vector3 GetNaturalSize(); -- 2.7.4 From 1ef98fc483196e4f9ba58044bd76b271d4692309 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Tue, 14 Jul 2020 18:54:35 +0900 Subject: [PATCH 14/16] [Tizen] Restore behavior of Uploaded and LoadingFinished signal This reverts commit e4d9ad343fb6daa616423ba59039aed85d5e406f. Change-Id: Ia1fd59d82916f3166afe92a7857c38dffd04ce12 --- .../internal/controls/image-view/image-view-impl.cpp | 16 ++++++++++++++++ .../internal/controls/image-view/image-view-impl.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 9843128..c07355a 100755 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -237,6 +237,22 @@ void ImageView::SetDepthIndex( int depthIndex ) } } +void ImageView::OnStageConnection( int depth ) +{ + if( mImage ) + { + mImage.UploadedSignal().Emit( mImage ); + } + + Dali::ResourceImage resourceImage = Dali::ResourceImage::DownCast( mImage ); + if( resourceImage ) + { + resourceImage.LoadingFinishedSignal().Emit( resourceImage ); + } + + Control::OnStageConnection( depth ); // Enabled visuals will be put on stage +} + Vector3 ImageView::GetNaturalSize() { if( mVisual ) diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.h b/dali-toolkit/internal/controls/image-view/image-view-impl.h index 382feb8..0a8fbd8 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.h +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.h @@ -128,6 +128,11 @@ private: // From Control void OnInitialize(); /** + * @copydoc CustomActorImpl::OnStageConnection() + */ + virtual void OnStageConnection( int depth ); + + /** * @copydoc Toolkit::Control::GetNaturalSize */ virtual Vector3 GetNaturalSize(); -- 2.7.4 From dd29431ab7ffd67da49106037c63700d122c7e2b Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Tue, 14 Jul 2020 18:54:45 +0900 Subject: [PATCH 15/16] [Tizen] Add AutofillContainer class and autofill implementation This reverts commit 3b724dc08e62968be03a00dedaf39bee6261b81d. Change-Id: Iefa264b00b68b456b6c5920baaf204540f71fc21 --- CMakeLists.txt | 2 + .../controls/text-controls/autofill-container.cpp | 137 +++++++++ .../controls/text-controls/autofill-container.h | 219 ++++++++++++++ dali-toolkit/devel-api/file.list | 2 + .../controls/control/control-data-impl.cpp | 36 ++- .../internal/controls/control/control-data-impl.h | 42 +++ .../text-controls/autofill-container-impl.cpp | 332 +++++++++++++++++++++ .../text-controls/autofill-container-impl.h | 249 ++++++++++++++++ .../controls/text-controls/text-field-impl.cpp | 25 +- .../controls/text-controls/text-field-impl.h | 2 + dali-toolkit/internal/file.list | 1 + 11 files changed, 1042 insertions(+), 5 deletions(-) create mode 100644 dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp create mode 100644 dali-toolkit/devel-api/controls/text-controls/autofill-container.h create mode 100755 dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp create mode 100644 dali-toolkit/internal/controls/text-controls/autofill-container-impl.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a2fe956..eba4398 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ SET ( SOURCES ${SOURCES} ${devel_api_src_dir}/controls/popup/popup.cpp ${devel_api_src_dir}/controls/shadow-view/shadow-view.cpp ${devel_api_src_dir}/controls/super-blur-view/super-blur-view.cpp + ${devel_api_src_dir}/controls/text-controls/autofill-container.cpp ${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp @@ -161,6 +162,7 @@ SET( SOURCES ${SOURCES} ${internal_src_dir}/controls/slider/slider-impl.cpp ${internal_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp ${internal_src_dir}/controls/table-view/table-view-impl.cpp + ${internal_src_dir}/controls/text-controls/autofill-container-impl.cpp ${internal_src_dir}/controls/text-controls/text-editor-impl.cpp ${internal_src_dir}/controls/text-controls/text-field-impl.cpp ${internal_src_dir}/controls/text-controls/text-label-impl.cpp diff --git a/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp b/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp new file mode 100644 index 0000000..e75ca6f --- /dev/null +++ b/dali-toolkit/devel-api/controls/text-controls/autofill-container.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2019 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. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +AutofillContainer AutofillContainer::New( const std::string& name ) +{ + return Internal::AutofillContainer::New( name ); +} + +AutofillContainer::AutofillContainer() +{ +} + +AutofillContainer::AutofillContainer( const AutofillContainer& handle ) +: BaseHandle(handle) +{ +} + +AutofillContainer& AutofillContainer::operator=( const AutofillContainer& handle ) +{ + BaseHandle::operator=(handle); + return *this; +} + +AutofillContainer::~AutofillContainer() +{ +} + +AutofillContainer AutofillContainer::DownCast( BaseHandle handle ) +{ + return AutofillContainer( dynamic_cast( handle.GetObjectPtr() ) ); +} + + +void AutofillContainer::AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ) +{ + GetImpl(*this).AddAutofillItem( control, propertyIndex, id, label, hint, isSensitive ); +} + +void AutofillContainer::RemoveAutofillItem( Control control ) +{ + GetImpl(*this).RemoveAutofillItem( control ); +} + +void AutofillContainer::SetFocusedControl( Toolkit::Control focused ) +{ + GetImpl(*this).SetFocusedControl( focused ); +} + +Toolkit::Control AutofillContainer::GetFocusedControl() +{ + return GetImpl(*this).GetFocusedControl(); +} + +void AutofillContainer::SaveAutofillData() +{ + GetImpl(*this).SaveAutofillData(); +} + +void AutofillContainer::RequestFillData() +{ + GetImpl(*this).RequestFillData(); +} + +const std::string& AutofillContainer::GetAutofillServiceName() const +{ + return GetImpl(*this).GetAutofillServiceName(); +} + +const std::string& AutofillContainer::GetAutofillServiceMessage() const +{ + return GetImpl(*this).GetAutofillServiceMessage(); +} + +const std::string& AutofillContainer::GetAutofillServiceImagePath() const +{ + return GetImpl(*this).GetAutofillServiceImagePath(); +} + +unsigned int AutofillContainer::GetListCount() +{ + return GetImpl(*this).GetListCount(); +} + +const std::string& AutofillContainer::GetListItem( unsigned int index ) const +{ + return GetImpl(*this).GetListItem( index ); +} + +void AutofillContainer::SetSelectedItem( const std::string& selected ) +{ + GetImpl(*this).SetSelectedItem( selected ); +} + +AutofillContainer::AutofillContainer( Internal::AutofillContainer* implementation ) +: BaseHandle(implementation) +{ +} + +AutofillContainer::AuthenticationSignalType& AutofillContainer::AutofillServiceShownSignal() +{ + return GetImpl(*this).AutofillServiceShownSignal(); +} + +AutofillContainer::ListShownSignalType& AutofillContainer::AutofillListShownSignal() +{ + return GetImpl(*this).AutofillListShownSignal(); +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/text-controls/autofill-container.h b/dali-toolkit/devel-api/controls/text-controls/autofill-container.h new file mode 100644 index 0000000..eecad1a --- /dev/null +++ b/dali-toolkit/devel-api/controls/text-controls/autofill-container.h @@ -0,0 +1,219 @@ +#ifndef DALI_TOOLKIT_AUTO_FILL_CONTAINER_H +#define DALI_TOOLKIT_AUTO_FILL_CONTAINER_H + +/* + * Copyright (c) 2019 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. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Internal DALI_INTERNAL +{ +class AutofillContainer; +} + +/** + * @brief AutofillContainer controls several text input boxes (Dali::Toolkit::TextField and Dali::Toolkit::TextEditor). + * + * It can make these editors a group of text boxes. + */ +class DALI_TOOLKIT_API AutofillContainer : public BaseHandle +{ +public: + + // TODO : Need to update parameter and return value according to each Signal + typedef Signal< void (AutofillContainer&) > AuthenticationSignalType; ///< Authentication Signal Type + typedef Signal< void (Control&) > ListShownSignalType; ///< List Shown Signal Type + +public: + + /** + * @brief Creates the AutofillContainer. + * + * @param[in] name The AutofillContainer name + * @return A handle to the AutofillContainer + */ + static AutofillContainer New( const std::string& name ); + + /** + * @brief Creates an empty handle. + */ + AutofillContainer(); + + /** + * @brief Copy constructor. + * + * @param[in] handle The handle to copy from + */ + AutofillContainer( const AutofillContainer& handle ); + + /** + * @brief Assignment operator. + * + * @param[in] handle The handle to copy from + * @return A reference to this + */ + AutofillContainer& operator=( const AutofillContainer& handle ); + + /** + * @brief Destructor. + * + * This is non-virtual since derived Handle types must not contain data or virtual methods. + */ + ~AutofillContainer(); + + /** + * @brief Downcasts a handle to AutofillContainer. + * + * If the BaseHandle points is a AutofillContainer, the downcast returns a valid handle. + * If not, the returned handle is left empty. + * + * @param[in] handle Handle to an object + * @return Handle to a AutofillContainer or an empty handle + */ + static AutofillContainer DownCast( BaseHandle handle ); + + /** + * @brief Adds Control and AutofillItem information to Autofill Container. + * + * @param[in] control The control to be added to Autofill Container + * @param[in] propertyIndex The Property to be filled automatically of each Control + * @param[in] id A unique ID that does not always change on each launching + * @param[in] label An auxiliary means to guess heuristically what data is + * @param[in] hint The Hint - id (username), name, password, phone, credit card number, organization, and so on + * @param[in] isSensitive Whether this information is a sensitive data or not + */ + void AddAutofillItem( Control control, Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ); + + /** + * @brief Removes Control and its AutofillItem information to Autofill Container. + * + * @param[in] control The control to be removed + */ + void RemoveAutofillItem( Control control ); + + /** + * @brief Sets that a control is focused. + * + * @param focused The focused control + */ + void SetFocusedControl( Toolkit::Control focused ); + + /** + * @brief Gets the focused control. + * + * @return The focused control + */ + Toolkit::Control GetFocusedControl(); + + /** + * @brief Stores autofill data. + */ + void SaveAutofillData(); + + /** + * @brief Sends a request for filling the data. + */ + void RequestFillData(); + + /** + * @brief Gets the Autofill Service Name. + * + * @return Autofill Service Name + */ + const std::string& GetAutofillServiceName() const; + + /** + * @brief Gets the Autofill Service Message. + * + * @return Autofill Service Message + */ + const std::string& GetAutofillServiceMessage() const; + + /** + * @brief Gets the Autofill Service Image Path. + * + * @return Autofill Service Image Path + */ + const std::string& GetAutofillServiceImagePath() const; + + /** + * @brief Gets the number of list items. (The presentation text of Autofill) + * + * @return The number of list items + */ + unsigned int GetListCount(); + + /** + * @brief Gets the list item of the index. + * + * @param[in] index The index for the list + * @return The list item of the index + */ + const std::string& GetListItem( unsigned int index ) const; + + /** + * @brief Sets the selected item to fill out. + * + * @param[in] selected The selected item + */ + void SetSelectedItem( const std::string& selected ); + +public: + // Signals + + /** + * @brief AutofillServiceShownSignal + * + * @return The signal containing the received data + */ + AuthenticationSignalType& AutofillServiceShownSignal(); + + /** + * @brief AutofillListShownSignal + * + * @return The signal containing the received data + */ + ListShownSignalType& AutofillListShownSignal(); + + +public: // Not intended for application developers + + /** + * @brief Creates a handle using the Toolkit::Internal implementation. + * + * @param[in] implementation The Control implementation + */ + DALI_INTERNAL AutofillContainer( Internal::AutofillContainer* implementation ); + +}; + + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_AUTO_FILL_CONTAINER_H diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 36f0649..721a456 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -26,6 +26,7 @@ SET( devel_api_src_files ${devel_api_src_dir}/controls/scene3d-view/scene3d-view.cpp ${devel_api_src_dir}/controls/shadow-view/shadow-view.cpp ${devel_api_src_dir}/controls/super-blur-view/super-blur-view.cpp + ${devel_api_src_dir}/controls/text-controls/autofill-container.cpp ${devel_api_src_dir}/controls/text-controls/text-editor-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-field-devel.cpp ${devel_api_src_dir}/controls/text-controls/text-selection-popup.cpp @@ -179,6 +180,7 @@ SET( devel_api_super_blur_view_header_files ) SET( devel_api_text_controls_header_files + ${devel_api_src_dir}/controls/text-controls/autofill-container.h ${devel_api_src_dir}/controls/text-controls/text-editor-devel.h ${devel_api_src_dir}/controls/text-controls/text-field-devel.h ${devel_api_src_dir}/controls/text-controls/text-label-devel.h diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index eb6285a..b49a8c5 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -313,7 +313,6 @@ const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocu const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_15( typeRegistration, "shadow", Toolkit::DevelControl::Property::SHADOW, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); - Control::Impl::Impl( Control& controlImpl ) : mControlImpl( controlImpl ), mState( Toolkit::DevelControl::NORMAL ), @@ -338,9 +337,12 @@ Control::Impl::Impl( Control& controlImpl ) mLongPressGestureDetector(), mTooltip( NULL ), mInputMethodContext(), + mAutofillItem(), + mAutofillContainer(), mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mIsKeyboardNavigationSupported( false ), - mIsKeyboardFocusGroup( false ) + mIsKeyboardFocusGroup( false ), + mIsAutofillEnabled( false ) { } @@ -1450,6 +1452,36 @@ void Control::Impl::ClearShadow() mControlImpl.RelayoutRequest(); } +void Control::Impl::SetAutofillEnabled( bool autofillEnabled ) +{ + mIsAutofillEnabled = autofillEnabled; +} + +bool Control::Impl::IsAutofillEnabled() +{ + return mIsAutofillEnabled; +} + +void Control::Impl::SetAutofillItemHandle( Dali::AutofillItem item ) +{ + mAutofillItem = item; +} + +Dali::AutofillItem Control::Impl::GetAutofillItemHandle() +{ + return mAutofillItem; +} + +void Control::Impl::SetAutofillContainer( Toolkit::AutofillContainer container ) +{ + mAutofillContainer = container; +} + +Toolkit::AutofillContainer Control::Impl::GetAutofillContainer() +{ + return mAutofillContainer; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 210f6e2..9648cd6 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -21,11 +21,14 @@ // EXTERNAL INCLUDES #include #include +#include +#include #include // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -346,6 +349,42 @@ public: * @brief Clear the shadow. */ void ClearShadow(); + + /** + * @brief Sets whether the Autofill functionality is enabled. + * @param[in] autofillEnabled Set true when Autofill should be enabled. + */ + void SetAutofillEnabled( bool autofillEnabled ); + + /** + * @brief Check if the Autofill framework is enabled. + * @return True if Autofill is enabled + */ + bool IsAutofillEnabled(); + + /** + * @brief Sets AutofillItemHandle + * @param item AutofillItem handle + */ + void SetAutofillItemHandle( Dali::AutofillItem item ); + + /** + * @brief Gets AutofillItemHandle + * @return AutofillItem handle + */ + Dali::AutofillItem GetAutofillItemHandle(); + + /** + * @brief Sets AutofillContainer which this control belongs to. + * @param[in] container + */ + void SetAutofillContainer( Toolkit::AutofillContainer container ); + + /** + * @brief Gets AutofillContainer that the control belongs to. + * @return AutofillContainer handle + */ + Toolkit::AutofillContainer GetAutofillContainer(); private: @@ -419,10 +458,13 @@ public: TooltipPtr mTooltip; InputMethodContext mInputMethodContext; + AutofillItem mAutofillItem; + Toolkit::AutofillContainer mAutofillContainer; ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor. bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control. bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group. + bool mIsAutofillEnabled : 1; ///< Stroes whether the Autofill functionality is enabled. RegisteredVisualContainer mRemoveVisuals; ///< List of visuals that are being replaced by another visual once ready diff --git a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp new file mode 100755 index 0000000..6c9628b --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.cpp @@ -0,0 +1,332 @@ +/* + * Copyright (c) 2019 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. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include // for strcmp +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Internal +{ + +namespace +{ + +#if defined ( DEBUG_ENABLED ) + Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_AUTOFILL_CONTAINER"); +#endif + +// Type registration +BaseHandle Create() +{ + return Toolkit::AutofillContainer::New( "" ); +} + +// Setup properties, signals and actions using the type-registry. +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::AutofillContainer, Dali::BaseHandle, Create ); + +DALI_SIGNAL_REGISTRATION( Toolkit, AutofillContainer, "serviceShown", SIGNAL_SERVICE_SHOWN ) +DALI_SIGNAL_REGISTRATION( Toolkit, AutofillContainer, "listShown", SIGNAL_LIST_SHOWN ) + +DALI_TYPE_REGISTRATION_END() + +} // namespace + +Toolkit::AutofillContainer AutofillContainer::New( const std::string& name ) +{ + // Create the implementation, temporarily owned by this handle on stack + Internal::AutofillContainer* impl = new AutofillContainer(); + + // Pass ownership to CustomActor handle + Toolkit::AutofillContainer handle( impl ); + impl->Initialize( name ); + + return handle; +} + +void AutofillContainer::Initialize( const std::string& name ) +{ + mAutofillManager = Dali::AutofillManager::Get(); + mAutofillGroup = mAutofillManager.CreateAutofillGroup( name ); + + // If the authentication is needed, AuthenticationReceivedSignal would be emitted. + mAutofillManager.AuthenticationReceivedSignal().Connect( mSlotDelegate, &AutofillContainer::OnAutofillAuthReceived ); + + // If the data to be filled is present, FillResponseReceivedSignal would be emitted. + mAutofillManager.FillResponseReceivedSignal().Connect( mSlotDelegate, &AutofillContainer::OnDataFillReceived ); + + // If the values to be filled are multiple, ListEventSignal would be emitted. + mAutofillManager.ListEventSignal().Connect( mSlotDelegate, &AutofillContainer::OnListReceived ); +} + +void AutofillContainer::AddAutofillItem( Dali::Toolkit::Control control, Dali::Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ) +{ + if( control ) + { + Dali::AutofillItem item = mAutofillManager.CreateAutofillItem( id, label, static_cast(hint), isSensitive ); + + Internal::Control& controlImpl = GetImplementation( control ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + controlDataImpl.SetAutofillContainer( this ); + controlDataImpl.SetAutofillEnabled( true ); + controlDataImpl.SetAutofillItemHandle( item ); // TODO : This instance would be here as... std::map or pair + + mAutofillGroup.AddAutofillItem( item ); + + mPropertyIndex = propertyIndex; + + // TODO : Remove the mControlItemList below and replace it. + mControlList.push_back( std::pair< Dali::Toolkit::Control, Dali::AutofillItem >( control, item ) ); + + // Push back a Control to the list + mControlItemList.push_back( control ); + } +} + +void AutofillContainer::RemoveAutofillItem( Dali::Toolkit::Control control ) +{ + if( control ) + { + Internal::Control& controlImpl = GetImplementation( control ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + controlDataImpl.SetAutofillEnabled( false ); + // TODO : Put the control out the list + } +} + +Dali::AutofillGroup AutofillContainer::GetAutofillGroup() +{ + return mAutofillGroup; +} + +void AutofillContainer::SetFocusedControl( Toolkit::Control focused ) +{ + mCurrentFocused = focused; +} + +Toolkit::Control AutofillContainer::GetFocusedControl() +{ + return mCurrentFocused; +} + +void AutofillContainer::SaveAutofillData() +{ + for( std::vector::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter ) + { + std::string controlValue = (*iter).GetProperty( mPropertyIndex ); + Internal::Control& controlImpl = GetImplementation( *iter ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + controlDataImpl.GetAutofillItemHandle().SetSaveValue( controlValue ); + } + + // Sends request to save the current autofill data + mAutofillGroup.SaveAutofillData(); + mAutofillManager.SaveAutofillData( mAutofillGroup ); +} + +void AutofillContainer::RequestFillData() +{ + // Sends fill request to fill out the data. + mAutofillGroup.SendFillRequest(); +} + +void AutofillContainer::SetAutofillServiceName( const std::string& serviceName ) +{ + mAutofillServiceName = serviceName; +} + +const std::string& AutofillContainer::GetAutofillServiceName() const +{ + return mAutofillServiceName; +} + +void AutofillContainer::SetAutofillServiceMessage( const std::string& serviceMessage ) +{ + mAutofillServiceMessage = serviceMessage; +} + +const std::string& AutofillContainer::GetAutofillServiceMessage() const +{ + return mAutofillServiceMessage; +} + +void AutofillContainer::SetAutofillServiceImagePath( const std::string& serviceImagePath ) +{ + mAutofillServiceImagePath = serviceImagePath; +} + +const std::string& AutofillContainer::GetAutofillServiceImagePath() const +{ + return mAutofillServiceImagePath; +} + +unsigned int AutofillContainer::GetListCount() +{ + Toolkit::Control control = mCurrentFocused; + Internal::Control& controlImpl = GetImplementation( control ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + return controlDataImpl.GetAutofillItemHandle().GetFillValueCount(); +} + +const std::string& AutofillContainer::GetListItem( unsigned int index ) const +{ + Toolkit::Control control = mCurrentFocused; + Internal::Control& controlImpl = GetImplementation( control ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + return controlDataImpl.GetAutofillItemHandle().GetPresentationText( index ); +} + +void AutofillContainer::SetSelectedItem( const std::string& selected ) +{ + Toolkit::Control control = mCurrentFocused; + Internal::Control& controlImpl = GetImplementation( control ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + unsigned int count = controlDataImpl.GetAutofillItemHandle().GetFillValueCount(); + unsigned int index = 0; + for( index = 0; index < count; index++ ) + { + std::string presentationText = controlDataImpl.GetAutofillItemHandle().GetPresentationText( index ); + if( 0 == strcmp( presentationText.c_str(), selected.c_str() ) ) + { + break; + } + } + + for( std::vector::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter ) + { + Internal::Control& controlImpl = GetImplementation( *iter ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + std::string fillValue = controlDataImpl.GetAutofillItemHandle().GetFillValue( index ); + (*iter).SetProperty( Toolkit::TextField::Property::TEXT, fillValue ); + } +} + +// +void AutofillContainer::OnAutofillAuthReceived() +{ + SetAutofillServiceName( mAutofillManager.GetAuthenticationServiceName() ); + SetAutofillServiceMessage( mAutofillManager.GetAuthenticationServiceMessage() ); + SetAutofillServiceImagePath( mAutofillManager.GetAuthenticationServiceImagePath() ); + + Dali::Toolkit::AutofillContainer handle( this ); + mAuthenticationEventSignal.Emit( handle ); + + DALI_LOG_ERROR(" [ Emit DALi signal to receive the auth information ] \n"); + +} + +void AutofillContainer::OnDataFillReceived( Dali::AutofillItem item ) +{ + for( std::vector::iterator iter = mControlItemList.begin(), endIter = mControlItemList.end(); iter != endIter; ++iter ) + { + Internal::Control& controlImpl = GetImplementation( *iter ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + + if( 0 == strcmp( controlDataImpl.GetAutofillItemHandle().GetId().c_str(), item.GetId().c_str() ) ) + { + // TODO : Is the index for fill data always 0 in this case? + std::string itemText = controlDataImpl.GetAutofillItemHandle().GetFillValue( 0 ); + (*iter).SetProperty( Toolkit::TextField::Property::TEXT, itemText ); + } + } + +} + +void AutofillContainer::OnListReceived() +{ + mListEventSignal.Emit( mCurrentFocused ); + +} + + +AutofillContainer::AutofillContainer() +: mAutofillManager(), + mAutofillGroup(), + mControlItemList(), + mControlList(), + mSlotDelegate( this ), + mPropertyIndex( Property::INVALID_INDEX ), + mAutofillServiceName( "" ), + mAutofillServiceMessage( "" ), + mAutofillServiceImagePath( "" ), + mCurrentFocused() +{ +} + +AutofillContainer::~AutofillContainer() +{ + mAutofillManager.AuthenticationReceivedSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnAutofillAuthReceived ); + mAutofillManager.FillResponseReceivedSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnDataFillReceived ); + mAutofillManager.ListEventSignal().Disconnect( mSlotDelegate, &AutofillContainer::OnListReceived ); +} + +// Signals +Toolkit::AutofillContainer::AuthenticationSignalType& AutofillContainer::AutofillServiceShownSignal() +{ + return mAuthenticationEventSignal; +} + +Toolkit::AutofillContainer::ListShownSignalType& AutofillContainer::AutofillListShownSignal() +{ + return mListEventSignal; +} + +bool AutofillContainer::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + Dali::BaseHandle handle( object ); + + bool connected( true ); + Toolkit::AutofillContainer container = Toolkit::AutofillContainer::DownCast( handle ); + + if( container ) + { + if( 0 == signalName.compare( SIGNAL_SERVICE_SHOWN ) ) + { + container.AutofillServiceShownSignal().Connect( tracker, functor ); + } + else if( 0 == signalName.compare( SIGNAL_LIST_SHOWN ) ) + { + container.AutofillListShownSignal().Connect( tracker, functor ); + } + else + { + // signalName does not match any signal + connected = false; + } + } + + return connected; +} + +} // namespace Internal + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h new file mode 100644 index 0000000..1ef8262 --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/autofill-container-impl.h @@ -0,0 +1,249 @@ +#ifndef DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H +#define DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H + +/* + * Copyright (c) 2019 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include + + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Internal +{ + +/** + * @copydoc Toolkit::AutofillContainer + */ +class AutofillContainer : public Dali::BaseObject +{ +public: + + /** + * @copydoc Dali::Toollkit::AutofillContainer::New() + */ + static Toolkit::AutofillContainer New( const std::string& name ); + + /** + * @brief Initialize AutofillContainer + */ + void Initialize( const std::string& name ); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::AddAutofillItem() + */ + void AddAutofillItem( Dali::Toolkit::Control control, Dali::Property::Index propertyIndex, const std::string& id, const std::string& label, Dali::AutofillItem::Hint hint, bool isSensitive ); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::RemoveAutofillItem() + */ + void RemoveAutofillItem( Dali::Toolkit::Control control ); + + /** + * @brief Gets AutofillGroup setting to AutofillContainer. + * + * @return The AutofillGroup instance + */ + Dali::AutofillGroup GetAutofillGroup(); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::SetFocusedControl() + */ + void SetFocusedControl( Toolkit::Control focused ); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::GetFocusedControl() + */ + Toolkit::Control GetFocusedControl(); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::SaveAutofillData() + */ + void SaveAutofillData(); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::RequestFillData() + */ + void RequestFillData(); + + /** + * @brief Sets the Autofill Service Name + * + * @param serviceName Autofill Service Name + */ + void SetAutofillServiceName( const std::string& serviceName ); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceName() + */ + const std::string& GetAutofillServiceName() const; + + /** + * @brief Sets the Autofill Service Message + * + * @param serviceMessage Autofill Service Message + */ + void SetAutofillServiceMessage( const std::string& serviceMessage ); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceMessage() + */ + const std::string& GetAutofillServiceMessage() const; + + /** + * @brief Sets the Autofill Service Image Path + * + * @param serviceImagePath Autofill Service Image Path + */ + void SetAutofillServiceImagePath( const std::string& serviceImagePath ); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::GetAutofillServiceImagePath() + */ + const std::string& GetAutofillServiceImagePath() const; + + /** + * @copydoc Dali::Toollkit::AutofillContainer::GetListCount() + */ + unsigned int GetListCount(); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::GetListItem() + */ + const std::string& GetListItem( unsigned int index ) const; + + /** + * @copydoc Dali::Toollkit::AutofillContainer::SetSelectedItem() + */ + void SetSelectedItem( const std::string& selected ); + + /** + * @brief Callback when Autofill Authentication information is recieved. + */ + void OnAutofillAuthReceived(); + + /** + * @brief Callback when Autofill Fill Response is recieved. + * @param[in] item The callback parameter + */ + void OnDataFillReceived( Dali::AutofillItem item ); + + /** + * @brief Callback when the values to be filled are multiple. + */ + void OnListReceived(); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::AutofillServiceShownSignal() + */ + Toolkit::AutofillContainer::AuthenticationSignalType& AutofillServiceShownSignal(); + + /** + * @copydoc Dali::Toollkit::AutofillContainer::AutofillListShownSignal() + */ + Toolkit::AutofillContainer::ListShownSignalType& AutofillListShownSignal(); + + /** + * Connects a callback function with the object's signals. + * @param[in] object The object providing the signal. + * @param[in] tracker Used to disconnect the signal. + * @param[in] signalName The signal to connect to. + * @param[in] functor A newly allocated FunctorDelegate. + * @return True if the signal was connected. + * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. + */ + static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + + +private: // Implementation + + /** + * Construct a new AutofillContainer. + */ + AutofillContainer(); + + /** + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~AutofillContainer(); + +private: + + // Undefined copy constructor and assignment operators + AutofillContainer(const AutofillContainer&); + AutofillContainer& operator=(const AutofillContainer& rhs); + +private: // Data + + Dali::AutofillManager mAutofillManager; + Dali::AutofillGroup mAutofillGroup; + std::vector mControlItemList; ///< The List of Control adding to AutofillContainer + //std::map mControlList; + std::vector< std::pair< Dali::Toolkit::Control, Dali::AutofillItem > > mControlList; + + SlotDelegate< AutofillContainer > mSlotDelegate; + + Property::Index mPropertyIndex; ///< The index of property registered by each control + + Toolkit::AutofillContainer::AuthenticationSignalType mAuthenticationEventSignal; + Toolkit::AutofillContainer::ListShownSignalType mListEventSignal; + + std::string mAutofillServiceName; + std::string mAutofillServiceMessage; + std::string mAutofillServiceImagePath; + + Toolkit::Control mCurrentFocused; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Toolkit::Internal::AutofillContainer& GetImpl( Toolkit::AutofillContainer& autofillContainer ) +{ + DALI_ASSERT_ALWAYS(autofillContainer); + + Dali::BaseObject& handle = autofillContainer.GetBaseObject(); + + return static_cast(handle); +} + +inline const Toolkit::Internal::AutofillContainer& GetImpl( const Toolkit::AutofillContainer& autofillContainer ) +{ + DALI_ASSERT_ALWAYS(autofillContainer); + + const Dali::BaseObject& handle = autofillContainer.GetBaseObject(); + + return static_cast(handle); +} + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_INTERNAL_AUTOFILL_CONTAINER_H diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 2b4fcc0..33d9689 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include #include @@ -1585,7 +1587,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) void TextField::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() ); - if ( mInputMethodContext ) + if( mInputMethodContext ) { mInputMethodContext.ApplyOptions( mInputMethodOptions ); @@ -1599,13 +1601,30 @@ void TextField::OnKeyInputFocusGained() // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated. mInputMethodContext.SetRestoreAfterFocusLost( true ); } - ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); - if ( notifier ) + ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); + if( notifier ) { notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected ); } + Toolkit::Control control = Toolkit::Control::DownCast( Self() ); + Internal::Control& controlImpl = GetImplementation( control ); + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); + bool enableAutofill = controlDataImpl.IsAutofillEnabled(); + if( enableAutofill ) + { + Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer(); + container.SetFocusedControl( control ); + + Internal::AutofillContainer& containerImpl = GetImpl( container ); + Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup(); + if( containerGroup != nullptr ) + { + containerGroup.RequestAuthentication(); + } + + } mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last. diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 2991931..59bedf8 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -291,6 +292,7 @@ private: // Data Toolkit::Control mStencil; ///< For EXCEED_POLICY_CLIP std::vector mClippingDecorationActors; ///< Decoration actors which need clipping. Dali::InputMethodOptions mInputMethodOptions; + Dali::AutofillItem mAutofillItem; Actor mRenderableActor; Actor mActiveLayer; diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 246ba89..b9fde11 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -95,6 +95,7 @@ SET( toolkit_src_files ${toolkit_src_dir}/controls/slider/slider-impl.cpp ${toolkit_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp ${toolkit_src_dir}/controls/table-view/table-view-impl.cpp + ${toolkit_src_dir}/controls/text-controls/autofill-container-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-editor-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-field-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-label-impl.cpp -- 2.7.4 From d65c9d224f52287085dadcee04526c217225666c Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Wed, 9 Sep 2020 14:56:45 +0900 Subject: [PATCH 16/16] [Tizen] Add deprecated log to Control - DALi projects are deprecated now, so added deprecated log to major class, Control. Change-Id: Ie21a7b184ee56bbdbb3c672d7d370800751b3620 Signed-off-by: Seoyeon Kim --- dali-toolkit/public-api/controls/control.cpp | 1 + dali-toolkit/public-api/controls/control.h | 4 ++++ doc/dali-toolkit-doc.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dali-toolkit/public-api/controls/control.cpp b/dali-toolkit/public-api/controls/control.cpp index d9b2f8f..38d67d0 100644 --- a/dali-toolkit/public-api/controls/control.cpp +++ b/dali-toolkit/public-api/controls/control.cpp @@ -33,6 +33,7 @@ namespace Toolkit Control Control::New() { + DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: DALi is deprecated and will be removed from next version. Please use NUI(C# interface of DALi).\n For more information on NUI, see the NUI quick start page : https://docs.tizen.org/application/dotnet/get-started/nui/quickstart/ \n" ); return Internal::Control::New(); } diff --git a/dali-toolkit/public-api/controls/control.h b/dali-toolkit/public-api/controls/control.h index ed68e15..dae155c 100644 --- a/dali-toolkit/public-api/controls/control.h +++ b/dali-toolkit/public-api/controls/control.h @@ -49,6 +49,8 @@ class Control; */ /** + * @DEPRECATED_1_5.19 + * * @brief Control is the base class for all controls. * * The implementation of the control must be supplied; see Internal::Control for more details. @@ -178,6 +180,8 @@ public: public: // Creation & Destruction /** + * @DEPRECATED_1_5.19 + * * @brief Creates a new instance of a Control. * * @SINCE_1_0.0 diff --git a/doc/dali-toolkit-doc.h b/doc/dali-toolkit-doc.h index 5765d9c..edb10e3 100755 --- a/doc/dali-toolkit-doc.h +++ b/doc/dali-toolkit-doc.h @@ -19,7 +19,7 @@ */ /** - * @defgroup dali DALi + * @defgroup dali DALi (Deprecated) * @ingroup CAPI_UI_FRAMEWORK * * @brief DALi is a cross-platform 3D UI Toolkit for embedded systems. -- 2.7.4