From 644f9b9ec4878cc4db953cea7ceaa502444ae88a Mon Sep 17 00:00:00 2001 From: xuweinan Date: Mon, 11 Mar 2024 10:00:42 +0800 Subject: [PATCH] =?UTF-8?q?Description:DisplaySync=E6=96=B0=E5=A2=9ENDK?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20Feature=20or=20Bugfix:Feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuweinan --- arkui/ace_engine/native/BUILD.gn | 1 + .../native/display_sync/native_display_sync.h | 142 ++++++++++++++++++ arkui/ace_engine/native/libace.ndk.json | 28 ++++ 3 files changed, 171 insertions(+) create mode 100644 arkui/ace_engine/native/display_sync/native_display_sync.h diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 2dc4d659a..9c280910d 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_event.h", "native_interface.h", "native_node.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 000000000..0fe428f81 --- /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 6566446ad..edd7b4ae7 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -170,5 +170,33 @@ { "first_introduced": "12", "name": "OH_NativeXComponent_RegisterOnTouchInterceptCallback" + }, + { + "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 -- Gitee