From 8161da22f6dd46ecf79dec8bcb745d3b9a06d5aa Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Wed, 6 Nov 2024 12:06:39 +0800 Subject: [PATCH 1/2] Signed-off-by: xxb-wzy Change-Id: I928ac5cd440236908ad9534afa193d48dbb04f87 --- .../native_vsync/libnative_vsync.ndk.json | 6 ++++- .../graphic_2d/native_vsync/native_vsync.h | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index 196fab524..28ff64c27 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -3,5 +3,9 @@ { "name": "OH_NativeVSync_Destroy" }, { "name": "OH_NativeVSync_RequestFrame" }, { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, - { "name": "OH_NativeVSync_GetPeriod" } + { "name": "OH_NativeVSync_GetPeriod" }, + { + "first_introduced": "14", + "name": "OH_NativeVSync_DVSyncSwitch" + } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 610fe1deb..791fbfd36 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -114,6 +114,32 @@ int OH_NativeVSync_RequestFrameWithMultiCallback( * @version 1.0 */ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); + +/** + * @brief Enables DVSync to improve the smoothness of self-drawing animations. + * DVSync, short for Decoupled VSync, is a frame timing management policy that is decoupled from the hardware's VSync. + * DVSync drives the early rendering of upcoming animation frames by sending VSync signals with future timestamps. + * These frames are stored in a frame buffer queue. This helps DVSync reduce potential frame drop and therefore + * enhances the smoothness of animations. + * DVSync requires free self-drawing frame buffers to store these pre-rendered animation frames. + * Therefore, you must ensure that at least one free frame buffer is available. Otherwise, do not enable DVSync. + * After DVSync is enabled, you must correctly respond to the early VSync signals and request the subsequent VSync + * after the animation frame associated with the previous VSync is complete. In addition, the self-drawing frames must + * carry timestamps that align with VSync. + * After the animation ends, disable DVSync. + * On a platform that does not support DVSync or if another application has enabled DVSync, the attempt to enable it + * will not take effect, and the application still receives normal VSync signals. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param enable Whether to enable DVSync.The value true means to enable DVSync, and false means the opposite. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. + * @since 14 + * @version 1.0 + */ +int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); #ifdef __cplusplus } #endif -- Gitee From 9296cab7d08aa41a951d88c2024e85d74a95dd52 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Mon, 11 Nov 2024 10:21:38 +0800 Subject: [PATCH 2/2] Signed-off-by: xxb-wzy Change-Id: I6e2e2cb0f19a1f431e32f224b6051779d45332a0 --- graphic/graphic_2d/native_vsync/native_vsync.h | 1 + 1 file changed, 1 insertion(+) diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 791fbfd36..bb77a0108 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -127,6 +127,7 @@ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); * after the animation frame associated with the previous VSync is complete. In addition, the self-drawing frames must * carry timestamps that align with VSync. * After the animation ends, disable DVSync. + * Only phones and tablets support DVSync. * On a platform that does not support DVSync or if another application has enabled DVSync, the attempt to enable it * will not take effect, and the application still receives normal VSync signals. * -- Gitee