1 /* 2 * Copyright (c) 2022-2022 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 #ifndef NDK_INCLUDE_NATIVE_VSYNC_H_ 17 #define NDK_INCLUDE_NATIVE_VSYNC_H_ 18 19 /** 20 * @addtogroup NativeVsync 21 * @{ 22 * 23 * @brief Provides the native vsync capability. 24 * 25 * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 26 * @since 9 27 * @version 1.0 28 */ 29 30 /** 31 * @file native_vsync.h 32 * 33 * @brief Defines the functions for obtaining and using a native vsync. 34 * 35 * @since 9 36 * @version 1.0 37 */ 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 struct OH_NativeVSync; 44 typedef struct OH_NativeVSync OH_NativeVSync; 45 typedef void (*OH_NativeVSync_FrameCallback)(long long timestamp, void *data); 46 47 /** 48 * @brief Creates a <b>NativeVsync</b> instance.\n 49 * A new <b>NativeVsync</b> instance is created each time this function is called. 50 * 51 * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 52 * @param name Indicates the vsync connection name. 53 * @param length Indicates the name's length. 54 * @return Returns the pointer to the <b>NativeVsync</b> instance created. 55 * @since 9 56 * @version 1.0 57 */ 58 OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length); 59 60 /** 61 * @brief Delete the NativeVsync instance. 62 * 63 * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 64 * @param window Indicates the pointer to a <b>NativeVsync</b> instance. 65 * @return Returns int32_t, return value == 0, success, otherwise, failed. 66 * @since 9 67 * @version 1.0 68 */ 69 void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync); 70 71 /** 72 * @brief Request next vsync with callback. 73 * 74 * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 75 * @param nativeVsync Indicates the pointer to a NativeVsync. 76 * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. 77 * @param data Indicates data whick will be used in callback. 78 * @return Returns int32_t, return value == 0, success, otherwise, failed. 79 * @since 9 80 * @version 1.0 81 */ 82 int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); 83 84 /** 85 * @brief Get vsync period. 86 * 87 * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 88 * @param nativeVsync Indicates the pointer to a NativeVsync. 89 * @param period Indicates the vsync period. 90 * @return Returns int32_t, return value == 0, success, otherwise, failed. 91 * @since 10 92 * @version 1.0 93 */ 94 int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); 95 #ifdef __cplusplus 96 } 97 #endif 98 99 #endif