From f763f05ba0668ee9c446459f445054faa2ee2131 Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Fri, 25 Apr 2025 14:26:48 +0800 Subject: [PATCH] sync fence interface C upload Signed-off-by: lw19901203 --- .../kit_sub_system/c_file_kit_sub_system.json | 5 + graphic/graphic_2d/native_fence/BUILD.gn | 29 +++++ .../native_fence/libnative_fence.ndk.json | 18 +++ .../graphic_2d/native_fence/native_fence.h | 110 ++++++++++++++++++ ndk_targets.gni | 2 + 5 files changed, 164 insertions(+) create mode 100755 graphic/graphic_2d/native_fence/BUILD.gn create mode 100755 graphic/graphic_2d/native_fence/libnative_fence.ndk.json create mode 100755 graphic/graphic_2d/native_fence/native_fence.h 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 2e7636057..34518ef90 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 000000000..920b8d47d --- /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 000000000..b29686ae5 --- /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 000000000..e0d6dd9a7 --- /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 3ac0d4002..9c7db45fd 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", -- Gitee