From 538d808523cf7cdb8dc37e10d60aa4fce636fb24 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 15 Feb 2022 15:48:17 +0900 Subject: [PATCH 1/1] Level up Dali::Internal::FreeList as Dali::FreeList Open devel Dali::Internal::FreeList as Dali::FreeList so we can use this container in another packages i.e. dali-toolkit's texture-manager Change-Id: I719e960ce1ecf8b61a980e49cba976fe1ab57200 Signed-off-by: Eunki, Hong --- automated-tests/src/dali/CMakeLists.txt | 1 + automated-tests/src/dali/utc-Dali-FreeList.cpp | 117 +++++++++++++++++++++ .../manager => devel-api/common}/free-list.h | 25 ++--- dali/devel-api/file.list | 1 + dali/internal/update/manager/transform-manager.h | 4 +- 5 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 automated-tests/src/dali/utc-Dali-FreeList.cpp rename dali/{internal/update/manager => devel-api/common}/free-list.h (83%) diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index 6f299d8..835a9d3 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -30,6 +30,7 @@ SET(TC_SOURCES utc-Dali-Extents.cpp utc-Dali-FrameBuffer.cpp utc-Dali-FrameCallbackInterface.cpp + utc-Dali-FreeList.cpp utc-Dali-Geometry.cpp utc-Dali-GestureDetector.cpp utc-Dali-Handle.cpp diff --git a/automated-tests/src/dali/utc-Dali-FreeList.cpp b/automated-tests/src/dali/utc-Dali-FreeList.cpp new file mode 100644 index 0000000..ac732a7 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-FreeList.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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 + +using namespace Dali; + +void utc_dali_free_list_startuP(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_free_list_cleanuP(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliFreeListConstructor01P(void) +{ + TestApplication application; + tet_infoline("UtcDaliFreeListConstructor01P simple constructor check"); + try + { + FreeList freeList; + DALI_TEST_CHECK(true); + } + catch(...) + { + DALI_TEST_CHECK(false); + } + + END_TEST; +} + +int UtcDaliFreeListAddGetRemove(void) +{ + TestApplication application; + tet_infoline("UtcDaliFreeListAddGetRemove Add, Get, and Remove test"); + FreeList list1; + FreeList list2; + + auto FreeListAddTest = [](FreeList& list, std::uint32_t value, std::uint32_t exceptIndex, const char* location) { + std::uint32_t index = list.Add(value); + DALI_TEST_EQUALS(index, exceptIndex, location); + }; + auto FreeListGetTest = [](const FreeList& list, std::uint32_t exceptValue, std::uint32_t index, const char* location) { + std::uint32_t value = list[index]; + DALI_TEST_EQUALS(value, exceptValue, location); + }; + + tet_printf("Add some values first\n"); + FreeListAddTest(list1, 111, 0, TEST_LOCATION); + FreeListAddTest(list1, 222, 1, TEST_LOCATION); + FreeListAddTest(list1, 333, 2, TEST_LOCATION); + FreeListAddTest(list1, 444, 3, TEST_LOCATION); + + tet_printf("Check input values exist well\n"); + FreeListGetTest(list1, 111, 0, TEST_LOCATION); + FreeListGetTest(list1, 222, 1, TEST_LOCATION); + FreeListGetTest(list1, 333, 2, TEST_LOCATION); + FreeListGetTest(list1, 444, 3, TEST_LOCATION); + + tet_printf("Remove 1 and 3 value\n"); + + list1.Remove(1); + list1.Remove(3); + tet_printf("Check not-removed values exist well\n"); + FreeListGetTest(list1, 111, 0, TEST_LOCATION); + FreeListGetTest(list1, 333, 2, TEST_LOCATION); + + tet_printf("Copy list. FreeList is not handle. copy whole info\n"); + list2 = list1; + FreeListGetTest(list2, 111, 0, TEST_LOCATION); + FreeListGetTest(list2, 333, 2, TEST_LOCATION); + + tet_printf("Add some values after removed\n"); + FreeListAddTest(list1, 555, 3, TEST_LOCATION); + FreeListAddTest(list1, 666, 1, TEST_LOCATION); + FreeListAddTest(list1, 777, 4, TEST_LOCATION); + FreeListAddTest(list2, 888, 3, TEST_LOCATION); + + tet_printf("Check input values exist well\n"); + FreeListGetTest(list1, 111, 0, TEST_LOCATION); + FreeListGetTest(list1, 666, 1, TEST_LOCATION); + FreeListGetTest(list1, 333, 2, TEST_LOCATION); + FreeListGetTest(list1, 555, 3, TEST_LOCATION); + FreeListGetTest(list1, 777, 4, TEST_LOCATION); + FreeListGetTest(list2, 111, 0, TEST_LOCATION); + FreeListGetTest(list2, 333, 2, TEST_LOCATION); + FreeListGetTest(list2, 888, 3, TEST_LOCATION); + + tet_printf("Change value directly\n"); + list2.Remove(2); + list2[3] = 999; + FreeListGetTest(list2, 111, 0, TEST_LOCATION); + FreeListGetTest(list2, 999, 3, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file diff --git a/dali/internal/update/manager/free-list.h b/dali/devel-api/common/free-list.h similarity index 83% rename from dali/internal/update/manager/free-list.h rename to dali/devel-api/common/free-list.h index 354da68..6dc4b44 100644 --- a/dali/internal/update/manager/free-list.h +++ b/dali/devel-api/common/free-list.h @@ -1,8 +1,8 @@ -#ifndef FREE_LIST_H_ -#define FREE_LIST_H_ +#ifndef DALI_FREE_LIST_H +#define DALI_FREE_LIST_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,8 @@ namespace Dali { -namespace Internal -{ /** - * FreeList operates by connecting unused elements of a vector together in a linked list using the + * @brief FreeList operates by connecting unused elements of a vector together in a linked list using the * value of each unused cell as a pointer to the next. When a new element is added, it will be added * to the first free index of the vector and the new free index will be the value which was on that * cell @@ -37,7 +35,7 @@ namespace Internal struct FreeList { /** - * Constructor + * @brief Constructor */ FreeList() : mData(), @@ -46,12 +44,12 @@ struct FreeList } /** - * Destructor + * @brief Destructor */ ~FreeList() = default; /** - * Adds a new item to the list. If there is no more space in the vector it will + * @brief Adds a new item to the list. If there is no more space in the vector it will * allocate more space, otherwise, it will use the first free cell to store the * new value and will update the first free index. * @@ -77,7 +75,7 @@ struct FreeList } /** - * Removes the item at position "index" from the list and + * @brief Removes the item at position "index" from the list and * updates the first free index * * @param[in] index The index of the element to remove @@ -89,7 +87,7 @@ struct FreeList } /** - * Subscript operator. + * @brief Subscript operator. * * @param[in] index Index of the element. * @return Reference to the element for given index. @@ -100,7 +98,7 @@ struct FreeList } /** - * Subscript operator (const). + * @brief Subscript operator (const). * * @param[in] index Index of the element. * @return Reference to the element for given index. @@ -115,7 +113,6 @@ private: uint32_t mFirstFreeIndex; ///< Index where a new element will be added }; -} // namespace Internal } // namespace Dali -#endif /* FREE_LIST_H_ */ +#endif /* DALI_FREE_LIST_H */ diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index c28900e..7f48c24 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -70,6 +70,7 @@ SET( devel_api_core_common_header_files ${devel_api_src_dir}/common/capabilities.h ${devel_api_src_dir}/common/circular-queue.h ${devel_api_src_dir}/common/hash.h + ${devel_api_src_dir}/common/free-list.h ${devel_api_src_dir}/common/singleton-service.h ${devel_api_src_dir}/common/map-wrapper.h ${devel_api_src_dir}/common/owner-container.h diff --git a/dali/internal/update/manager/transform-manager.h b/dali/internal/update/manager/transform-manager.h index 26936a8..97294e2 100644 --- a/dali/internal/update/manager/transform-manager.h +++ b/dali/internal/update/manager/transform-manager.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_TRANSFORM_MANAGER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include #include #include #include -- 2.7.4