From d82c595946e16d3316e44dc12229ace61282e57c Mon Sep 17 00:00:00 2001 From: ljh Date: Thu, 8 May 2025 17:08:12 +0800 Subject: [PATCH 1/4] NativeVSync Signed-off-by: ljh --- .../native_vsync/libnative_vsync.ndk.json | 1 + .../graphic_2d/native_vsync/native_vsync.h | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index 5362d474e..4eae1df09 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -5,6 +5,7 @@ { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, { "name": "OH_NativeVSync_GetPeriod" }, { "name": "OH_NativeVSync_Create_ForAssociatedWindow" }, + { "name": "OH_NativeVSync_SetExpectedFrameRateRange"}, { "first_introduced": "14", "name": "OH_NativeVSync_DVSyncSwitch" diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index f7d45c0e7..b17c61295 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -49,6 +49,21 @@ struct OH_NativeVSync; typedef struct OH_NativeVSync OH_NativeVSync; typedef void (*OH_NativeVSync_FrameCallback)(long long timestamp, void *data); +/** + * @brief Defines the expected frame rate range struct. + * + * @since 20 + * @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; +} OH_NativeVSync_ExpectedRateRange; + /** * @brief Creates a NativeVsync instance.\n * A new NativeVsync instance is created each time this function is called. @@ -163,6 +178,25 @@ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); * @version 1.0 */ int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); + +/** + * @brief Set Vsync expected frame rate range. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync + * @param range Indicates the pointer to an expected rate range. + * Valid range is 0 <= min <= expected <= max <= 144. + * expected == 0 indicates cancle vote. + * This pointer needs to be released by developer. + * @return {@link NATIVE_ERROR_OK}0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter is NULL or range is invalid. + * {@link NATIVE_ERROR_NOT_SUPPORT} 50102000 - the object nativeVsync does not support this interface + * Consider using other methods to create nativeVsync instead. + * @since 20 + * @version 1.0 + */ + +int OH_NativeVSync_SetExpectedFrameRateRange(OH_NativeVSync* nativeVsync, OH_NativeVSync_ExpectedRateRange* range); #ifdef __cplusplus } #endif -- Gitee From c0339f3760a2d3c4886e1761f2b9aa9b8df92741 Mon Sep 17 00:00:00 2001 From: ljh Date: Tue, 13 May 2025 08:34:14 +0000 Subject: [PATCH 2/4] update graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json. Signed-off-by: ljh --- graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json | 2 +- 1 file changed, 1 insertion(+), 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 4eae1df09..3678dea04 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -5,7 +5,7 @@ { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, { "name": "OH_NativeVSync_GetPeriod" }, { "name": "OH_NativeVSync_Create_ForAssociatedWindow" }, - { "name": "OH_NativeVSync_SetExpectedFrameRateRange"}, + { "name": "OH_NativeVSync_SetExpectedFrameRateRange" }, { "first_introduced": "14", "name": "OH_NativeVSync_DVSyncSwitch" -- Gitee From c560a8400b62ec8ce977f61544cc806a16d1a586 Mon Sep 17 00:00:00 2001 From: ljh Date: Tue, 13 May 2025 08:40:38 +0000 Subject: [PATCH 3/4] update graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json. Signed-off-by: ljh --- graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json | 5 ++++- 1 file changed, 4 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 3678dea04..ca01c8fbb 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -5,9 +5,12 @@ { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, { "name": "OH_NativeVSync_GetPeriod" }, { "name": "OH_NativeVSync_Create_ForAssociatedWindow" }, - { "name": "OH_NativeVSync_SetExpectedFrameRateRange" }, { "first_introduced": "14", "name": "OH_NativeVSync_DVSyncSwitch" + }, + { + "first_introduced": "20", + "name": "OH_NativeVSync_SetExpectedFrameRateRange" } ] \ No newline at end of file -- Gitee From 1c53da63781905a6eb6f4cbab96f087e852caf56 Mon Sep 17 00:00:00 2001 From: ljh Date: Wed, 14 May 2025 01:57:51 +0000 Subject: [PATCH 4/4] update graphic/graphic_2d/native_vsync/native_vsync.h. Signed-off-by: ljh --- graphic/graphic_2d/native_vsync/native_vsync.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index b17c61295..f670c2838 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -180,18 +180,15 @@ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); /** - * @brief Set Vsync expected frame rate range. + * @brief Sets the desired VSync frame rate and the range of the desired frame rate. * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync - * @param nativeVsync Indicates the pointer to a NativeVsync - * @param range Indicates the pointer to an expected rate range. - * Valid range is 0 <= min <= expected <= max <= 144. - * expected == 0 indicates cancle vote. - * This pointer needs to be released by developer. - * @return {@link NATIVE_ERROR_OK}0 - Success. - * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter is NULL or range is invalid. - * {@link NATIVE_ERROR_NOT_SUPPORT} 50102000 - the object nativeVsync does not support this interface - * Consider using other methods to create nativeVsync instead. + * @param nativeVsync Pointer to an instance of {@link OH_NativeVSync}. + * @param range Pointer to an instance of {@link OH_NativeVSync_ExpectedRateRange}.\n + * The valid range for the desired frame rate is: 0 <= minimum <= desired frame rate <= maximum <= 144.\n + * A desired frame rate of 0 indicates that the desired frame rate is canceled.\n + * The developer is responsible for managing the lifecycle of this pointer. + * @return Returns 0 on success, other return values can be referenced from {@link OHNativeErrorCode}. * @since 20 * @version 1.0 */ -- Gitee