From f07c0a9d2b89dc052fb6f5a1ab6834f1cb7e53fe Mon Sep 17 00:00:00 2001 From: wangxiuxiu96 Date: Tue, 13 May 2025 17:55:07 +0800 Subject: [PATCH] CAPI supports onIdle event callback 0513. Signed-off-by: wangxiuxiu96 --- arkui/ace_engine/native/libace.ndk.json | 4 ++++ arkui/ace_engine/native/native_node_napi.h | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 3a129e851..c87367b06 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -2847,6 +2847,10 @@ "first_introduced": "18", "name": "OH_ArkUI_PostFrameCallback" }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PostIdleCallback" + }, { "first_introduced": "15", "name": "OH_ArkUI_HostWindowInfo_GetName" diff --git a/arkui/ace_engine/native/native_node_napi.h b/arkui/ace_engine/native/native_node_napi.h index 8070149fa..af0c3b106 100644 --- a/arkui/ace_engine/native/native_node_napi.h +++ b/arkui/ace_engine/native/native_node_napi.h @@ -374,6 +374,24 @@ ArkUI_ErrorCode OH_ArkUI_GetRouterPageId( int32_t OH_ArkUI_PostFrameCallback(ArkUI_ContextHandle uiContext, void* userData, void (*callback)(uint64_t nanoTimestamp, uint32_t frameCount, void* userData)); +/** + * @brief Register a callback to be executed at the end of the next idle frame.If there is no next frame, will request one automatically. + * + * @param uiContext ArkUI_ContextHandle. + * @param userData Indicates the custom data to be saved. + * @param callback Custom callback function. + * @param nanoTimeLeft The remaining time from the deadline for this frame. + * @param frameCount Frame count. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_CAPI_INIT_ERROR} if the CAPI init error. + * Returns {@link ARKUI_ERROR_CODE_UI_CONTEXT_INVALID} if the uiContext is invalid. + * Returns {@link ARKUI_ERROR_CODE_CALLBACK_INVALID} if the callback function is invalid. + * @since 20 + */ + int32_t OH_ArkUI_PostIdleCallback(ArkUI_ContextHandle uiContext, void* userData, + void (*callback)(uint64_t nanoTimeLeft, uint32_t frameCount, void* userData)); + #ifdef __cplusplus }; #endif -- Gitee