diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index 5362d474e0217b0a4b53c0ed0924b05a53e69d88..ca01c8fbb56c5a0db920d4fd44f125457b7ff0f4 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -8,5 +8,9 @@ { "first_introduced": "14", "name": "OH_NativeVSync_DVSyncSwitch" + }, + { + "first_introduced": "20", + "name": "OH_NativeVSync_SetExpectedFrameRateRange" } ] \ 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 f7d45c0e753e84ae3892bf4d679e6b7f212402ef..f670c283853005bb82d753e7da36a4ea9aaac6d6 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,22 @@ int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); * @version 1.0 */ int OH_NativeVSync_DVSyncSwitch(OH_NativeVSync* nativeVsync, bool enable); + +/** + * @brief Sets the desired VSync frame rate and the range of the desired frame rate. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @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 + */ + +int OH_NativeVSync_SetExpectedFrameRateRange(OH_NativeVSync* nativeVsync, OH_NativeVSync_ExpectedRateRange* range); #ifdef __cplusplus } #endif