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..ee597f3ec1dfe7228edcd845f5c12b015d95e76e --- /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" ] +} \ No newline at end of file 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..3aed298140fd4db3388ffd29e5d1a08ba9ec28cd --- /dev/null +++ b/graphic/graphic_2d/native_fence/native_fence.h @@ -0,0 +1,108 @@ +/* + * 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 fence is valid. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. \n + * This value is a non negative integer. + * @return Returns true if the fence is valid; returns false otherwise. + * @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. \n + * If the fence is invalid, it is equivalent to the fence having signaled, \n + * and the function will return false immediately. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. \n + * This value is a non negative integer. + * @param timeout Indicates the timeout duration. \n + * The unit is milliseconds, -1 represents permanent waiting, 0 represents immediate return. + * @return Returns true if the fence signaled; \n + * returns false if the fence is invalid or no event occurred after timeout, \n + * or call the underlying poll interface has failed. + * @since 20 + * @version 1.0 + */ +bool OH_NativeFence_Wait(int fenceFd, uint32_t timeout); + +/** + * @brief Waits forever for a fence signal. \n + * If the fence is invalid, it is equivalent to the fence having signaled, \n + * and the function will return false immediately. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. \n + * This value is a non negative integer. + * @return Returns true if the fence signaled; \n + * returns false if the fence is invalid or no incidents have occurred, permanent waiting. + * @since 20 + * @version 1.0 + */ +bool OH_NativeFence_WaitForever(int fenceFd); + +/** + * @brief Close the fence. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeFence + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. \n + * 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 25da4956f0ebd55ca422b24b0de722e5394c0dcc..1142357448bafc8cbaeff6b0f27e1de204f738a4 100644 --- a/ndk_targets.gni +++ b/ndk_targets.gni @@ -86,6 +86,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",