1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup NativeDisplaySoloist 18 * @{ 19 * 20 * @brief Provides the native displaySoloist capability. 21 * 22 * @since 12 23 * @version 1.0 24 */ 25 26 /** 27 * @file native_display_soloist.h 28 * 29 * @brief Defines the functions for obtaining and using a native displaySoloist. 30 * 31 * @kit ArkGraphics2D 32 * @library libnative_display_soloist.so 33 * @syscap SystemCapability.Graphic.Graphic2D.HyperGraphicManager 34 * @since 12 35 * @version 1.0 36 */ 37 38 #ifndef C_INCLUDE_NATIVE_DISPLAY_SOLOIST_H_ 39 #define C_INCLUDE_NATIVE_DISPLAY_SOLOIST_H_ 40 41 #include <stdint.h> 42 #include <stdbool.h> 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @brief Defines the native displaySoloist struct. 49 * 50 * @since 12 51 * @version 1.0 52 */ 53 typedef struct OH_DisplaySoloist OH_DisplaySoloist; 54 55 /** 56 * @brief Defines the native displaySoloist callback. 57 * 58 * @param timestamp Indicates the current timestamp. 59 * @param targetTimestamp Indicates the target timestamp. 60 * @param data Indicates the pointer to user data. 61 * @since 12 62 * @version 1.0 63 */ 64 typedef void (*OH_DisplaySoloist_FrameCallback)(long long timestamp, long long targetTimestamp, void* data); 65 66 /** 67 * @brief Defines the expected frame rate range struct. 68 * 69 * @since 12 70 * @version 1.0 71 */ 72 typedef struct { 73 /** The minimum frame rate of dynamical callback rate range. */ 74 int32_t min; 75 /** The maximum frame rate of dynamical callback rate range. */ 76 int32_t max; 77 /** The expected frame rate of dynamical callback rate range. */ 78 int32_t expected; 79 } DisplaySoloist_ExpectedRateRange; 80 81 /** 82 * @brief Creates a <b>OH_DisplaySoloist</b> instance.\n 83 * 84 * @param useExclusiveThread Indicates whether the vsync run in a exclusive thread. 85 * @return Returns the pointer to the <b>OH_DisplaySoloist</b> instance created if the execution is successful. 86 * if nullptr is returned, the creation fails. 87 * the possible cause of the failure is that the available memory is empty. 88 * @since 12 89 * @version 1.0 90 */ 91 OH_DisplaySoloist* OH_DisplaySoloist_Create(bool useExclusiveThread); 92 93 /** 94 * @brief Destroys a <b>OH_DisplaySoloist</b> instance and reclaims the memory occupied by the object. 95 * 96 * @param displaySoloist Indicates the pointer to a native displaySoloist. 97 * @return Returns int32_t, returns 0 if the execution is successful, returns -1 if displaySoloist is incorrect. 98 * @since 12 99 * @version 1.0 100 */ 101 int32_t OH_DisplaySoloist_Destroy(OH_DisplaySoloist* displaySoloist); 102 103 /** 104 * @brief Start to request next vsync with callback. 105 * 106 * @param displaySoloist Indicates the pointer to a native displaySoloist. 107 * @param callback Indicates the OH_DisplaySoloist_FrameCallback which will be called when next vsync coming. 108 * @param data Indicates data whick will be used in callback. 109 * @return Returns int32_t, returns 0 if the execution is successful. 110 * returns -1 if displaySoloist or callback is incorrect. 111 * @since 12 112 * @version 1.0 113 */ 114 int32_t OH_DisplaySoloist_Start( 115 OH_DisplaySoloist* displaySoloist, OH_DisplaySoloist_FrameCallback callback, void* data); 116 117 /** 118 * @brief Stop to request next vsync with callback. 119 * 120 * @param displaySoloist Indicates the pointer to a native displaySoloist. 121 * @return Returns int32_t, returns 0 if the execution is successful, returns -1 if displaySoloist is incorrect. 122 * @since 12 123 * @version 1.0 124 */ 125 int32_t OH_DisplaySoloist_Stop(OH_DisplaySoloist* displaySoloist); 126 127 /** 128 * @brief Set vsync expected frame rate range. 129 * 130 * @param displaySoloist Indicates the pointer to a native displaySoloist. 131 * @param range Indicates the pointer to an expected rate range. 132 * @return Returns int32_t, returns 0 if the execution is successful 133 * returns -1 if displaySoloist or range is incorrect. 134 * @since 12 135 * @version 1.0 136 */ 137 int32_t OH_DisplaySoloist_SetExpectedFrameRateRange( 138 OH_DisplaySoloist* displaySoloist, DisplaySoloist_ExpectedRateRange* range); 139 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif 145 /** @} */