diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 2539ea4d51003f98e318e430be91e4573844ed33..6e8191b20a1078237c9f5e8360ee87e8d3ecf680 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -26,6 +26,7 @@ if (!is_arkui_x) { ohos_ndk_headers("arkui_header") { dest_dir = "$ndk_headers_out_dir/arkui/" sources = [ + "display_sync/native_display_sync.h", "native_dialog.h", "native_event.h", "native_gesture.h", diff --git a/arkui/ace_engine/native/display_sync/native_display_sync.h b/arkui/ace_engine/native/display_sync/native_display_sync.h new file mode 100644 index 0000000000000000000000000000000000000000..0fe428f81a43dd4e1306a667060b8c25818ca34d --- /dev/null +++ b/arkui/ace_engine/native/display_sync/native_display_sync.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 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. + */ + + +#ifndef NATIVE_DISPLAY_SYNC_H +#define NATIVE_DISPLAY_SYNC_H + +/** + * @addtogroup OH_DisplaySync + * @{ + * + * @brief Provides the native displaySync capability. + * + * @since 12 + * @version 1.0 + */ + +/** + * @file native_display_sync.h + * + * @brief Defines the functions for obtaining and using a native displaySync. + * @library libace_ndk.z.so + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + * @version 1.0 + */ +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the native displySync struct. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_DisplaySync OH_DisplaySync; + +/** + * @brief Defines the expected frame rate range struct. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /** The minimum frame rate of dynamical callback rate range. */ + int32_t min; + /** The maximum frame rate of dynamical callback rate range. */ + int32_t max; + /** The expected frame rate of dynamical callback rate range. */ + int32_t expected; +} DisplaySync_ExpectedRateRange; + +/** + * @brief Creates a OH_DisplaySync instance.\n + * + * @return Returns the pointer to the OH_DisplaySync instance. + * @since 12 + * @version 1.0 + */ +OH_DisplaySync* OH_DisplaySync_Create(); + +/** + * @brief Add OH_DisplaySync instance to pipeline.\n + * + * @param displaySync Indicates the pointer to a native displaySync. + * @since 12 + * @version 1.0 + */ +void OH_DisplaySync_Start(OH_DisplaySync* displaySync); + +/** + * @brief Stop OH_DisplaySync instance from pipeline.\n + * + * @param displaySync Indicates the pointer to a native displaySync. + * @since 12 + * @version 1.0 + */ +void OH_DisplaySync_Stop(OH_DisplaySync* displaySync); + +/** + * @brief Registers a callback for this OH_DisplaySync instance. + * + * @param displaySync Indicates the pointer to a native displaySync. + * @param userData Indicates the pointer to user data. + * @param callback Indicates the pointer to a onFrame callback. + * @param timestamp Indicates the current timestamp. + * @param targetTimestamp Indicates the target timestamp. + * @since 12 + * @version 1.0 + */ +void OH_DisplaySync_RegisterCallback(OH_DisplaySync* displaySync, void* userData, + void (*Callback)(uint64_t timestamp, uint64_t targetTimestamp, void* userData)); + +/** + * @brief Unregisters a callback for this OH_DisplaySync instance. + * + * @param displaySync Indicates the pointer to a native displaySync. + * @since 12 + * @version 1.0 + */ +void OH_DisplaySync_UnregisterCallback(OH_DisplaySync* displaySync); + +/** + * @brief Set the Expected FrameRateRange. + * + * @param displaySync Indicates the pointer to a native displaySync. + * @param range Indicates the pointer to a expected rate range. + * @since 12 + * @version 1.0 + */ +void OH_DisplaySync_SetExpectedFrameRateRange( + OH_DisplaySync* displaySync, DisplaySync_ExpectedRateRange* range); + +/** + * @brief Destroy a OH_DisplaySync instance.\n + * + * @param displaySync Indicates the pointer to a native displaySync. + * @since 12 + * @version 1.0 + */ +void OH_DisplaySync_Destroy(OH_DisplaySync* displaySync); + +#ifdef __cplusplus +} +#endif + +#endif +/** @} */ \ No newline at end of file diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 1d484b8606eb25f0de910cf4d8c2de1731eb367c..f160f0fbd24bc5bcfb6b1d6f9919f9cabacae8c8 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -302,5 +302,33 @@ { "first_introduced": "12", "name": "OH_ArkUI_DrawContext_GetSize" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_Create" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_Start" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_Stop" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_RegisterCallback" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_UnregisterCallback" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_SetExpectedFrameRateRange" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySync_Destroy" } ] \ No newline at end of file