• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# NativeVsync
2
3
4## Overview
5
6The **NativeVsync** module provides the capabilities of native virtual synchronization (VSync).
7
8\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
9
10**Since**
11
129
13
14
15## Summary
16
17
18### Files
19
20| Name| Description|
21| -------- | -------- |
22| [native_vsync.h](native__vsync_8h.md) | Declares the functions for obtaining and using native VSync.<br>**File to include**: &lt;native_vsync/native_vsync.h&gt;<br>**Library**: libnative_vsync.so|
23
24
25### Types
26
27| Name| Description|
28| -------- | -------- |
29| [OH_NativeVSync](#oh_nativevsync) | Provides the declaration of an **OH_NativeVSync** struct.|
30| (\*[OH_NativeVSync_FrameCallback](#oh_nativevsync_framecallback)) (long long timestamp, void \*data) | Defines the pointer to a VSync callback function.|
31
32
33### Functions
34
35| Name| Description|
36| -------- | -------- |
37| [OH_NativeVSync_Create](#oh_nativevsync_create) (const char \*name, unsigned int length) | Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.|
38| [OH_NativeVSync_Destroy](#oh_nativevsync_destroy) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync) | Destroys an **OH_NativeVSync** instance.|
39| [OH_NativeVSync_RequestFrame](#oh_nativevsync_requestframe) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync, [OH_NativeVSync_FrameCallback](#oh_nativevsync_framecallback) callback, void \*data) | Requests the next VSync signal. When the signal arrives, a callback function is invoked.|
40| [OH_NativeVSync_GetPeriod](#oh_nativevsync_getperiod) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync, long long \*period) |Obtains the VSync period.|
41
42## Type Description
43
44
45### OH_NativeVSync
46
47
48```
49typedef struct OH_NativeVSync OH_NativeVSync
50```
51
52**Description**
53
54Provides the declaration of an **OH_NativeVSync** struct.
55
56
57### OH_NativeVSync_FrameCallback
58
59
60```
61typedef void(* OH_NativeVSync_FrameCallback) (long long timestamp, void *data)
62```
63
64**Description**
65
66Defines the pointer to a VSync callback function.
67
68\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
69
70**Parameters**
71
72| Name| Description|
73| -------- | -------- |
74| timestamp | VSync timestamp.|
75| data | User-defined data.|
76
77
78## Function Description
79
80### OH_NativeVSync_GetPeriod()
81
82
83```
84int OH_NativeVSync_GetPeriod (OH_NativeVSync * nativeVsync, long long * period )
85```
86
87**Description**
88
89Obtains the VSync period.
90
91\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
92
93**Parameters**
94
95| Name| Description|
96| -------- | -------- |
97| nativeVsync | Pointer to an **OH_NativeVSync** instance.|
98| period | Pointer to the VSync period.|
99
100**Returns**
101
102Returns **0** if the operation is successful.
103
104**Since**
105
10610
107
108
109### OH_NativeVSync_Create()
110
111
112```
113OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length )
114```
115
116**Description**
117
118Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.
119
120\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
121
122**Parameters**
123
124| Name| Description|
125| -------- | -------- |
126| name | Pointer to the name that associates with an **OH_NativeVSync** instance.|
127| length | Length of the name.|
128
129**Returns**
130
131Returns the pointer to an **OH_NativeVSync** instance.
132
133
134### OH_NativeVSync_Destroy()
135
136
137```
138void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync)
139```
140
141**Description**
142
143Destroys an **OH_NativeVSync** instance.
144
145\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
146
147**Parameters**
148
149| Name| Description|
150| -------- | -------- |
151| nativeVsync | Pointer to an **OH_NativeVSync** instance.|
152
153
154### OH_NativeVSync_RequestFrame()
155
156
157```
158int OH_NativeVSync_RequestFrame (OH_NativeVSync * nativeVsync, OH_NativeVSync_FrameCallback callback, void * data )
159```
160
161**Description**
162
163Requests the next VSync signal. When the signal arrives, a callback function is invoked.
164
165\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
166
167**Parameters**
168
169| Name| Description|
170| -------- | -------- |
171| nativeVsync | Pointer to an **OH_NativeVSync** instance.|
172| callback | Function pointer of the **OH_NativeVSync_FrameCallback** type. This function pointer will be called when the next VSync signal arrives.|
173| data | Pointer to the user-defined data struct. The type is void\*.|
174
175**Returns**
176
177Returns **0** if the operation is successful.
178