• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * @library libnative_vsync.so
36  * @since 9
37  * @version 1.0
38  */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 struct OH_NativeVSync;
45 typedef struct OH_NativeVSync OH_NativeVSync;
46 typedef void (*OH_NativeVSync_FrameCallback)(long long timestamp, void *data);
47 
48 /**
49  * @brief Creates a <b>NativeVsync</b> instance.\n
50  * A new <b>NativeVsync</b> instance is created each time this function is called.
51  *
52  * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
53  * @param name Indicates the vsync connection name.
54  * @param length Indicates the name's length.
55  * @return Returns the pointer to the <b>NativeVsync</b> instance created.
56  * @since 9
57  * @version 1.0
58  */
59 OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length);
60 
61 /**
62  * @brief Delete the NativeVsync instance.
63  *
64  * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
65  * @param window Indicates the pointer to a <b>NativeVsync</b> instance.
66  * @return Returns int32_t, return value == 0, success, otherwise, failed.
67  * @since 9
68  * @version 1.0
69  */
70 void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync);
71 
72 /**
73  * @brief Request next vsync with callback.
74  *
75  * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
76  * @param nativeVsync Indicates the pointer to a NativeVsync.
77  * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming.
78  * @param data Indicates data whick will be used in callback.
79  * @return Returns int32_t, return value == 0, success, otherwise, failed.
80  * @since 9
81  * @version 1.0
82  */
83 int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data);
84 
85 /**
86  * @brief Get vsync period.
87  *
88  * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
89  * @param nativeVsync Indicates the pointer to a NativeVsync.
90  * @param period Indicates the vsync period.
91  * @return Returns int32_t, return value == 0, success, otherwise, failed.
92  * @since 10
93  * @version 1.0
94  */
95 int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period);
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif