• 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;|
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
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 a **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
81### OH_NativeVSync_Create()
82
83
84```
85OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length )
86```
87
88**Description**
89
90Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.
91
92\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
93
94**Parameters**
95
96| Name| Description|
97| -------- | -------- |
98| name | Pointer to the name that associates with an **OH_NativeVSync** instance.|
99| length | Length of the name.|
100
101**Returns**
102
103Returns the pointer to an **OH_NativeVSync** instance.
104
105
106### OH_NativeVSync_Destroy()
107
108
109```
110void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync)
111```
112
113**Description**
114
115Destroys an **OH_NativeVSync** instance.
116
117\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
118
119**Parameters**
120
121| Name| Description|
122| -------- | -------- |
123| nativeVsync | Pointer to an **OH_NativeVSync** instance.|
124
125
126### OH_NativeVSync_RequestFrame()
127
128
129```
130int OH_NativeVSync_RequestFrame (OH_NativeVSync * nativeVsync, OH_NativeVSync_FrameCallback callback, void * data )
131```
132
133**Description**
134
135Requests the next VSync signal. When the signal arrives, a callback function is invoked.
136
137\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
138
139**Parameters**
140
141| Name| Description|
142| -------- | -------- |
143| nativeVsync | Pointer to an **OH_NativeVSync** instance.|
144| callback | Function pointer of the **OH_NativeVSync_FrameCallback** type. This function pointer will be called when the next VSync signal arrives.|
145| data | Pointer to the user-defined data struct. The type is void\*.|
146
147**Returns**
148
149Returns **0** if the operation is successful.
150