From 9364f17f6f805064c0541635182ca197b8dcbe60 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Fri, 18 Oct 2024 10:44:16 +0800 Subject: [PATCH 1/5] Signed-off-by: xxb-wzy Change-Id: Id49de840b724bca45076d887d0317f282f30314d --- .../native_vsync/libnative_vsync.ndk.json | 3 ++- .../graphic_2d/native_vsync/native_vsync.h | 25 +++++++++++++++++++ 2 files changed, 27 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..7c0511407 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -3,5 +3,6 @@ { "name": "OH_NativeVSync_Destroy" }, { "name": "OH_NativeVSync_RequestFrame" }, { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, - { "name": "OH_NativeVSync_GetPeriod" } + { "name": "OH_NativeVSync_GetPeriod" }, + { "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..0da2aa8e9 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -114,6 +114,31 @@ int OH_NativeVSync_RequestFrameWithMultiCallback( * @version 1.0 */ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); + +/** + * @brief Enable dvsync to improve the performance of self-drawn animation scenes. + * After enabled, dvsync needs to occupy the free surfacebuffer for frame buffering. Users need to ensure that + * there is an idle buffer at least. Otherwise, you are not advised to enable this function. + * When you enable dvsync, it will drive the early drawing of subsequent animations by sending vsync with future + * timestamp in advance, and you need to disable dvsync at the end of animation. + * After dvsync is enabled, the user needs to respond correctly to vsync sent in advance, and needs to request + * the next vsync after the animation frame of the last vsync completes drawing. And the surfacebuffer needs to + * carry a timestamp consistent with vsync. + * In some scenarios, if another application enables dvsync first, the current enabling operation will not + * take effect, and the application will still receive normal vsync signals. + * Not all platforms support dvsync. On platforms that do not support it, users will receive normal vsync + * after enabling it. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param enable Enable or disable the dvsync. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. + * @since 12 + * @version 1.0 + */ +int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); #ifdef __cplusplus } #endif -- Gitee From 9a7ff952b1bc444e522e8dfbbf8e0e2f2fd70d67 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Sat, 19 Oct 2024 15:41:14 +0800 Subject: [PATCH 2/5] Signed-off-by: xxb-wzy Change-Id: I91b51c7786f5aa8bccfc4936d602caceda547f89 --- graphic/graphic_2d/native_vsync/native_vsync.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 0da2aa8e9..2dfb5c1ac 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -135,7 +135,7 @@ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); * @return {@link NATIVE_ERROR_OK} 0 - Success. * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. - * @since 12 + * @since 14 * @version 1.0 */ int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); -- Gitee From ddb15cb2662ac117323cedb9800a8a60abd3b3ca Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Mon, 21 Oct 2024 19:32:31 +0800 Subject: [PATCH 3/5] Signed-off-by: xxb-wzy Change-Id: Ib3e74dcad38979a2c1aa14e3de68e99cb0e90d07 --- .../graphic_2d/native_vsync/native_vsync.h | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 2dfb5c1ac..8d6d3df64 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -116,22 +116,23 @@ int OH_NativeVSync_RequestFrameWithMultiCallback( int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); /** - * @brief Enable dvsync to improve the performance of self-drawn animation scenes. - * After enabled, dvsync needs to occupy the free surfacebuffer for frame buffering. Users need to ensure that - * there is an idle buffer at least. Otherwise, you are not advised to enable this function. - * When you enable dvsync, it will drive the early drawing of subsequent animations by sending vsync with future - * timestamp in advance, and you need to disable dvsync at the end of animation. - * After dvsync is enabled, the user needs to respond correctly to vsync sent in advance, and needs to request - * the next vsync after the animation frame of the last vsync completes drawing. And the surfacebuffer needs to - * carry a timestamp consistent with vsync. - * In some scenarios, if another application enables dvsync first, the current enabling operation will not - * take effect, and the application will still receive normal vsync signals. - * Not all platforms support dvsync. On platforms that do not support it, users will receive normal vsync - * after enabling it. + * @brief Enable DVSync to improve the smoothness of self drawn animation scenes. + * DVSync is Decoupled VSync, which is a frame timing management strategy decoupled from hardware VSync. + * DVSync drives the early drawing of subsequent animation frames by sending VSync signals with future timestamps + * in advance, which are then cached in the frame buffer queue; DVSync reduces the possibility of frame loss + * in the future by caching frames, thereby improving the smoothness of animation scenes. + * Because DVSync requires the use of idle self drawn frame buffers to cache pre drawn animation frames, users need to + * ensure that there is at least one free frame buffer, otherwise it is not recommended to enable this feature. + * After enabling DVSync, users need to respond correctly to the VSync signal sent in advance, and request + * the next VSync after the animation frame corresponding to the previous VSync is completed, and the self + * drawn frame needs to carry a timestamp consistent with VSync. + * After the animation ends, the user needs to turn off DVSync. + * On platforms that do not support DVSync or if another application has already enabled DVSync, the current + * enable operation will not take effect and the application will still receive a normal VSync signal. * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param nativeVsync Indicates the pointer to a NativeVsync. - * @param enable Enable or disable the dvsync. + * @param enable Indicates enable or disable DVSync, true indicates enable, false indicates disable. * @return {@link NATIVE_ERROR_OK} 0 - Success. * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. -- Gitee From f72041a06fded0ff5af3fcacd2cf153171234583 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Mon, 21 Oct 2024 19:59:02 +0800 Subject: [PATCH 4/5] Signed-off-by: xxb-wzy Change-Id: I7ae1c0e354949db4a00d9c83b5bb910e3122b68d --- .../graphic_2d/native_vsync/native_vsync.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 8d6d3df64..83f9af719 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -116,19 +116,19 @@ int OH_NativeVSync_RequestFrameWithMultiCallback( int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); /** - * @brief Enable DVSync to improve the smoothness of self drawn animation scenes. - * DVSync is Decoupled VSync, which is a frame timing management strategy decoupled from hardware VSync. - * DVSync drives the early drawing of subsequent animation frames by sending VSync signals with future timestamps - * in advance, which are then cached in the frame buffer queue; DVSync reduces the possibility of frame loss - * in the future by caching frames, thereby improving the smoothness of animation scenes. - * Because DVSync requires the use of idle self drawn frame buffers to cache pre drawn animation frames, users need to - * ensure that there is at least one free frame buffer, otherwise it is not recommended to enable this feature. + * @brief Enable DVSync to improve the smoothness of self-drawn animation scenes. + * DVSync stands for Decoupled VSync, a frame timing management strategy decoupled from hardware VSync. + * DVSync drives the early rendering of subsequent animation frames by sending VSync signals with future timestamps + * in advance, which are then cached in the frame buffer queue. DVSync reduces the possibility of future frame drops + * by caching pre-rendered frames for display, thereby improving the smoothness of animation scenes. + * Because DVSync requires the use of free self-drawn frame buffers to cache pre-rendered animation frames, users need + * to ensure that there is at least one free frame buffer, otherwise it is not recommended to enable this feature. * After enabling DVSync, users need to respond correctly to the VSync signal sent in advance, and request - * the next VSync after the animation frame corresponding to the previous VSync is completed, and the self - * drawn frame needs to carry a timestamp consistent with VSync. - * After the animation ends, the user needs to turn off DVSync. + * the next VSync after the animation frame corresponding to the previous VSync has completed, and the self-drawn + * frame needs to carry a timestamp consistent with its VSync event. + * After the animation ends, the user needs to disable DVSync. * On platforms that do not support DVSync or if another application has already enabled DVSync, the current - * enable operation will not take effect and the application will still receive a normal VSync signal. + * enable operation will not take effect and the application will still receive normal VSync signals. * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param nativeVsync Indicates the pointer to a NativeVsync. -- Gitee From ff3d26596703ebc1ba24c43383cd546e7cf4ffe9 Mon Sep 17 00:00:00 2001 From: xxb-wzy Date: Wed, 23 Oct 2024 16:11:03 +0800 Subject: [PATCH 5/5] Signed-off-by: xxb-wzy Change-Id: I2e337ec5699505cbb0121da95b62f38a7238f959 --- .../graphic_2d/native_vsync/native_vsync.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 83f9af719..791fbfd36 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -116,25 +116,25 @@ int OH_NativeVSync_RequestFrameWithMultiCallback( int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); /** - * @brief Enable DVSync to improve the smoothness of self-drawn animation scenes. - * DVSync stands for Decoupled VSync, a frame timing management strategy decoupled from hardware VSync. - * DVSync drives the early rendering of subsequent animation frames by sending VSync signals with future timestamps - * in advance, which are then cached in the frame buffer queue. DVSync reduces the possibility of future frame drops - * by caching pre-rendered frames for display, thereby improving the smoothness of animation scenes. - * Because DVSync requires the use of free self-drawn frame buffers to cache pre-rendered animation frames, users need - * to ensure that there is at least one free frame buffer, otherwise it is not recommended to enable this feature. - * After enabling DVSync, users need to respond correctly to the VSync signal sent in advance, and request - * the next VSync after the animation frame corresponding to the previous VSync has completed, and the self-drawn - * frame needs to carry a timestamp consistent with its VSync event. - * After the animation ends, the user needs to disable DVSync. - * On platforms that do not support DVSync or if another application has already enabled DVSync, the current - * enable operation will not take effect and the application will still receive normal VSync signals. + * @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 Indicates enable or disable DVSync, true indicates enable, false indicates disable. + * @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 or callback is NULL. + * {@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 -- Gitee