diff --git a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json index 2e76360574711680bfcb669fd1bce4a97e388687..34518ef907dfce33e6215d0802c661954c2c4747 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json +++ b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json @@ -129,6 +129,11 @@ "kitName": "ArkGraphicsD", "subSystem": "图形图像" }, + { + "filePath": "graphic/graphic_2d/native_fence/native_fence.h", + "kitName": "ArkGraphicsD", + "subSystem": "图形图像" + }, { "filePath": "graphic/graphic_2d/native_drawing/drawing_bitmap.h", "kitName": "ArkGraphicsD", diff --git a/graphic/graphic_2d/native_fence/BUILD.gn b/graphic/graphic_2d/native_fence/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..920b8d47d7fa2868bf5750fc9123cbc53fae255d --- /dev/null +++ b/graphic/graphic_2d/native_fence/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2025 Huawei Device 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_fence_header") { + dest_dir = "$ndk_headers_out_dir/native_fence" + sources = + [ "//interface/sdk_c/graphic/graphic_2d/native_fence/native_fence.h" ] +} + +ohos_ndk_library("libnative_fence_ndk") { + output_name = "native_fence" + output_extension = "so" + ndk_description_file = "./libnative_fence.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.NativeFence" + system_capability_headers = [ "native_fence/native_fence.h" ] +} diff --git a/graphic/graphic_2d/native_fence/libnative_fence.ndk.json b/graphic/graphic_2d/native_fence/libnative_fence.ndk.json new file mode 100755 index 0000000000000000000000000000000000000000..b29686ae54cee229a97c387a519564211aca7d69 --- /dev/null +++ b/graphic/graphic_2d/native_fence/libnative_fence.ndk.json @@ -0,0 +1,18 @@ +[ + { + "first_introduced": "20", + "name": "OH_NativeFence_IsValid" + }, + { + "first_introduced": "20", + "name": "OH_NativeFence_Wait" + }, + { + "first_introduced": "20", + "name": "OH_NativeFence_WaitForever" + }, + { + "first_introduced": "20", + "name": "OH_NativeFence_Close" + } +] \ No newline at end of file diff --git a/graphic/graphic_2d/native_fence/native_fence.h b/graphic/graphic_2d/native_fence/native_fence.h new file mode 100755 index 0000000000000000000000000000000000000000..e0d6dd9a7c3e0fd5d862c09df743b78d9707828c --- /dev/null +++ b/graphic/graphic_2d/native_fence/native_fence.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2025 Huawei Device 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. + */ + +/** + * @addtogroup NativeFence + * @{ + * + * @brief Provides the native fence capability + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @since 20 + * @version 1.0 + */ + +/** + * @file native_fence.h + * + * @brief Defines the functions for using native fence. + * + * @kit ArkGraphics2D + * @library libnative_fence.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @since 20 + * @version 1.0 + */ + +#ifndef NDK_INCLUDE_NATIVE_FENCE_H_ +#define NDK_INCLUDE_NATIVE_FENCE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Checks if the fenceFd is valid. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. + * @return Returns true if the fenceFd is valid. + * Returns false if the fenceFd is a negative integer. + * @since 20 + * @version 1.0 + */ +bool OH_NativeFence_IsValid(int fenceFd); + +/** + * @brief Waits for a fence signal. The maximum waiting time is determined by the timeout parameter. + * The incoming fenceFd needs to be closed by the user themselves. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. + * @param timeout Indicates the timeout duration. + * The unit is milliseconds, -1 represents permanent waiting, 0 represents immediate return. + * @return Returns true if the fence signaled. + * Returns false in the following cases: + * 1.if the fenceFd is a negative integer. + * 2.no event occurred within the specified timeout period. + * 3.the underlying poll interface call failed. + * 4.the timeout value is 0. + * 5.failed to duplicate the file descriptor. + * @since 20 + * @version 1.0 + */ +bool OH_NativeFence_Wait(int fenceFd, uint32_t timeout); + +/** + * @brief Waits forever for a fence signal. + * The incoming fenceFd needs to be closed by the user themselves. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. + * @return Returns true if the fence signaled. + * Returns false in the following cases: + * 1.if the fenceFd is a negative integer. + * 2.no incidents have occurred, permanent waiting. + * 3.failed to duplicate the file descriptor. + * @since 20 + * @version 1.0 + */ +bool OH_NativeFence_WaitForever(int fenceFd); + +/** + * @brief Close the fenceFd. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. + * This value is a non negative integer. + * @since 20 + * @version 1.0 + */ +void OH_NativeFence_Close(int fenceFd); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/ndk_targets.gni b/ndk_targets.gni index 3ac0d40025df7cd1518d027cdba21c2a0f5e76fb..9c7db45fd1843849d8505c79b70d4805f1bb67eb 100644 --- a/ndk_targets.gni +++ b/ndk_targets.gni @@ -89,6 +89,8 @@ _ndk_library_targets = [ "//interface/sdk_c/graphic/graphic_2d/native_image:native_image_header", "//interface/sdk_c/graphic/graphic_2d/native_vsync:libnative_vsync_ndk", "//interface/sdk_c/graphic/graphic_2d/native_vsync:native_vsync_header", + "//interface/sdk_c/graphic/graphic_2d/native_fence:libnative_fence_ndk", + "//interface/sdk_c/graphic/graphic_2d/native_fence:native_fence_header", "//interface/sdk_c/graphic/graphic_2d/native_color_space_manager:libnative_color_space_manager_ndk", "//interface/sdk_c/graphic/graphic_2d/native_color_space_manager:native_color_space_manager_header", "//interface/sdk_c/graphic/graphic_2d/native_drawing:libnative_drawing_ndk",