From 8d97108f5bc1b1c92a7212762e3298d8870d96e7 Mon Sep 17 00:00:00 2001 From: gonghongyu Date: Fri, 29 Nov 2024 18:36:00 +0800 Subject: [PATCH] =?UTF-8?q?DisplaySolist=E6=96=B0=E5=A2=9E=E5=8D=95?= =?UTF-8?q?=E5=8F=91=E6=A8=A1=E5=BC=8F=E5=8F=8APause/Resume=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gonghongyu --- .../libnative_display_soloist.ndk.json | 12 +++++ .../native_display_soloist.h | 48 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/graphic/graphic_2d/native_display_soloist/libnative_display_soloist.ndk.json b/graphic/graphic_2d/native_display_soloist/libnative_display_soloist.ndk.json index 88da1e4f6..5d2a2b416 100644 --- a/graphic/graphic_2d/native_display_soloist/libnative_display_soloist.ndk.json +++ b/graphic/graphic_2d/native_display_soloist/libnative_display_soloist.ndk.json @@ -15,6 +15,18 @@ "first_introduced": "12", "name": "OH_DisplaySoloist_Stop" }, + { + "first_introduced": "12", + "name": "OH_DisplaySoloist_Pause" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySoloist_Resume" + }, + { + "first_introduced": "12", + "name": "OH_DisplaySoloist_RequestFrame" + }, { "first_introduced": "12", "name": "OH_DisplaySoloist_SetExpectedFrameRateRange" diff --git a/graphic/graphic_2d/native_display_soloist/native_display_soloist.h b/graphic/graphic_2d/native_display_soloist/native_display_soloist.h index 8f3b9dca0..d886874e7 100644 --- a/graphic/graphic_2d/native_display_soloist/native_display_soloist.h +++ b/graphic/graphic_2d/native_display_soloist/native_display_soloist.h @@ -63,6 +63,16 @@ typedef struct OH_DisplaySoloist OH_DisplaySoloist; */ typedef void (*OH_DisplaySoloist_FrameCallback)(long long timestamp, long long targetTimestamp, void* data); +/** + * @brief Defines the native vsync callback. + * + * @param timestamp Indicates the current timestamp. + * @param data Indicates the pointer to user data. + * @since 12 + * @version 1.0 + */ +typedef void (*OH_NativeVSync_FrameCallback)(long long timestamp, void* data); + /** * @brief Defines the expected frame rate range struct. * @@ -82,13 +92,14 @@ typedef struct { * @brief Creates a OH_DisplaySoloist instance.\n * * @param useExclusiveThread Indicates whether the vsync run in a exclusive thread. + * @param autoRequestVsync Indicates whether the vsync is auto requested. * @return Returns the pointer to the OH_DisplaySoloist instance created if the execution is successful. * if nullptr is returned, the creation fails. * the possible cause of the failure is that the available memory is empty. * @since 12 * @version 1.0 */ -OH_DisplaySoloist* OH_DisplaySoloist_Create(bool useExclusiveThread); +OH_DisplaySoloist* OH_DisplaySoloist_Create(bool useExclusiveThread, bool autoRequestVsync = true); /** * @brief Destroys a OH_DisplaySoloist instance and reclaims the memory occupied by the object. @@ -105,7 +116,7 @@ int32_t OH_DisplaySoloist_Destroy(OH_DisplaySoloist* displaySoloist); * * @param displaySoloist Indicates the pointer to a native displaySoloist. * @param callback Indicates the OH_DisplaySoloist_FrameCallback which will be called when next vsync coming. - * @param data Indicates data whick will be used in callback. + * @param data Indicates data which will be used in callback. * @return Returns int32_t, returns 0 if the execution is successful. * returns -1 if displaySoloist or callback is incorrect. * @since 12 @@ -124,6 +135,39 @@ int32_t OH_DisplaySoloist_Start( */ int32_t OH_DisplaySoloist_Stop(OH_DisplaySoloist* displaySoloist); +/** + * @brief Pause requesting next vsync. + * + * @param displaySoloist Indicates the pointer to a native displaySoloist. + * @return Returns int32_t, returns 0 if the execution is successful, returns -1 if displaySoloist is incorrect. + * @since 12 + * @version 1.0 + */ +int32_t OH_DisplaySoloist_Pause(OH_DisplaySoloist* displaySoloist); + +/** + * @brief Resume to request next vsync. + * + * @param displaySoloist Indicates the pointer to a native displaySoloist. + * @return Returns int32_t, returns 0 if the execution is successful, returns -1 if displaySoloist is incorrect. + * @since 12 + * @version 1.0 + */ +int32_t OH_DisplaySoloist_Resume(OH_DisplaySoloist* displaySoloist); + +/** + * @brief Request next vsync as is needed. + * + * @param displaySoloist Indicates the pointer to a native displaySoloist. + * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. + * @param data Indicates data which will be used in callback. + * @return Returns int32_t, returns 0 if the execution is successful, returns -1 if displaySoloist is incorrect. + * @since 12 + * @version 1.0 + */ +int32_t OH_DisplaySoloist_RequestFrame( + OH_DisplaySoloist* displaySoloist, OH_NativeVSync_FrameCallback callback, void* data); + /** * @brief Set vsync expected frame rate range. * -- Gitee