Level up Dali::Internal::FreeList as Dali::FreeList 82/271082/14
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 15 Feb 2022 06:48:17 +0000 (15:48 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 4 Apr 2022 17:47:00 +0000 (02:47 +0900)
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 <eunkiki.hong@samsung.com>
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/utc-Dali-FreeList.cpp [new file with mode: 0644]
dali/devel-api/common/free-list.h [moved from dali/internal/update/manager/free-list.h with 83% similarity]
dali/devel-api/file.list
dali/internal/update/manager/transform-manager.h

index 6f299d8..835a9d3 100644 (file)
@@ -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 (file)
index 0000000..ac732a7
--- /dev/null
@@ -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 <dali-test-suite-utils.h>
+#include <dali/devel-api/common/free-list.h>
+#include <dali/public-api/dali-core.h>
+
+#include <iostream>
+
+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
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 (file)
@@ -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.
 
 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 */
index c28900e..7f48c24 100644 (file)
@@ -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
index 26936a8..97294e2 100644 (file)
@@ -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 <dali/internal/update/manager/free-list.h>
+#include <dali/devel-api/common/free-list.h>
 #include <dali/public-api/common/constants.h>
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/math/matrix.h>