_native_window.md 9.4 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4 5 6
# NativeWindow


提供NativeWindow功能,主要用来和egl对接


Z
zengyawen 已提交
7
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
8 9


Z
zengyawen 已提交
10
**自从:**
Z
zengyawen 已提交
11 12


Z
zengyawen 已提交
13
8
Z
zengyawen 已提交
14 15


Z
zengyawen 已提交
16
## 汇总
Z
zengyawen 已提交
17 18


Z
zengyawen 已提交
19 20 21
### 文件

| 文件名称 | 描述 |
Z
zengyawen 已提交
22
| -------- | -------- |
Z
zengyawen 已提交
23
| [external_window.h](external__window_8h.md) | 定义获取和使用NativeWindow的相关函数 |
Z
zengyawen 已提交
24 25


Z
zengyawen 已提交
26
### 函数
Z
zengyawen 已提交
27

Z
zengyawen 已提交
28
| 函数名称 | 描述 |
Z
zengyawen 已提交
29
| -------- | -------- |
Z
zengyawen 已提交
30 31 32 33 34 35 36 37 38 39 40 41
| [OH_NativeWindow_CreateNativeWindowFromSurface](#oh_nativewindow_createnativewindowfromsurface) (void \*pSurface) | 创建NativeWindow实例,每次调用都会产生一个新的NativeWindow实例 |
| [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) (struct NativeWindow \*window) | 将NativeWindow对象的引用计数减1,当引用计数为0的时候,该NativeWindow对象会被析构掉 |
| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | 创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindowBuffer实例 |
| [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) (struct NativeWindowBuffer \*buffer) | 将NativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该NativeWindowBuffer对象会被析构掉 |
| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) (struct NativeWindow \*window, struct NativeWindowBuffer \*\*buffer, int \*fenceFd) | 通过NativeWindow对象申请一块NativeWindowBuffer,用以内容生产 |
| [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer, int fenceFd, Region region) | 通过NativeWindow将生产好内容的NativeWindowBuffer放回到Buffer队列中,用以内容消费 |
| [OH_NativeWindow_NativeWindowCancelBuffer](#oh_nativewindow_nativewindowcancelbuffer) (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer) | 通过NativeWindow将之前申请出来的NativeWindowBuffer返还到Buffer队列中,供下次再申请 |
| [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) (struct NativeWindow \*window, int code,...) | 设置/获取NativeWindow的属性,包括设置/获取宽高、内容格式等 |
| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) (struct NativeWindowBuffer \*buffer) | 通过NativeWindowBuffer获取该buffer的BufferHandle指针 |
| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | 增加一个NativeObject的引用计数 |
| [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉 |
| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | 获取NativeObject的MagicId |
Z
zengyawen 已提交
42 43


Z
zengyawen 已提交
44
## 详细描述
Z
zengyawen 已提交
45 46


Z
zengyawen 已提交
47
## 函数说明
Z
zengyawen 已提交
48 49 50 51


### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer()

Z
zengyawen 已提交
52

Z
zengyawen 已提交
53 54 55 56
```
struct NativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void * pSurfaceBuffer)
```

Z
zengyawen 已提交
57
**描述:**
Z
zengyawen 已提交
58 59 60

创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindowBuffer实例

Z
zengyawen 已提交
61
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
62

Z
zengyawen 已提交
63
**参数:**
Z
zengyawen 已提交
64

Z
zengyawen 已提交
65
| Name | 描述 |
Z
zengyawen 已提交
66
| -------- | -------- |
Z
zengyawen 已提交
67
| pSurfaceBuffer | 参数是一个指向生产者buffer的指针,类型为sptr<OHOS::SurfaceBuffer> |
Z
zengyawen 已提交
68

Z
zengyawen 已提交
69
**返回:**
Z
zengyawen 已提交
70 71 72

返回一个指针,指向NativeWindowBuffer的结构体实例

Z
zengyawen 已提交
73 74 75 76
**自从:**

8

Z
zengyawen 已提交
77 78 79

### OH_NativeWindow_CreateNativeWindowFromSurface()

Z
zengyawen 已提交
80

Z
zengyawen 已提交
81 82 83 84
```
struct NativeWindow* OH_NativeWindow_CreateNativeWindowFromSurface (void * pSurface)
```

Z
zengyawen 已提交
85
**描述:**
Z
zengyawen 已提交
86 87 88

创建NativeWindow实例,每次调用都会产生一个新的NativeWindow实例

Z
zengyawen 已提交
89
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
90

Z
zengyawen 已提交
91
**参数:**
Z
zengyawen 已提交
92

Z
zengyawen 已提交
93
| Name | 描述 |
Z
zengyawen 已提交
94
| -------- | -------- |
Z
zengyawen 已提交
95
| pSurface | 参数是一个指向生产者ProduceSurface的指针,类型为sptr<OHOS::Surface> |
Z
zengyawen 已提交
96

Z
zengyawen 已提交
97
**返回:**
Z
zengyawen 已提交
98 99 100

返回一个指针,指向NativeWindow的结构体实例

Z
zengyawen 已提交
101 102 103 104
**自从:**

8

Z
zengyawen 已提交
105 106 107

### OH_NativeWindow_DestroyNativeWindow()

Z
zengyawen 已提交
108

Z
zengyawen 已提交
109 110 111 112
```
void OH_NativeWindow_DestroyNativeWindow (struct NativeWindow * window)
```

Z
zengyawen 已提交
113
**描述:**
Z
zengyawen 已提交
114 115 116

将NativeWindow对象的引用计数减1,当引用计数为0的时候,该NativeWindow对象会被析构掉

Z
zengyawen 已提交
117
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
118

Z
zengyawen 已提交
119
**参数:**
Z
zengyawen 已提交
120

Z
zengyawen 已提交
121
| Name | 描述 |
Z
zengyawen 已提交
122
| -------- | -------- |
Z
zengyawen 已提交
123 124 125 126 127
| window | 参数是一个NativeWindow的结构体实例的指针 |

**自从:**

8
Z
zengyawen 已提交
128 129 130 131


### OH_NativeWindow_DestroyNativeWindowBuffer()

Z
zengyawen 已提交
132

Z
zengyawen 已提交
133 134 135 136
```
void OH_NativeWindow_DestroyNativeWindowBuffer (struct NativeWindowBuffer * buffer)
```

Z
zengyawen 已提交
137
**描述:**
Z
zengyawen 已提交
138 139 140

将NativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该NativeWindowBuffer对象会被析构掉

Z
zengyawen 已提交
141
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
142

Z
zengyawen 已提交
143
**参数:**
Z
zengyawen 已提交
144

Z
zengyawen 已提交
145
| Name | 描述 |
Z
zengyawen 已提交
146
| -------- | -------- |
Z
zengyawen 已提交
147 148 149 150 151
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 |

**自从:**

8
Z
zengyawen 已提交
152 153 154 155


### OH_NativeWindow_GetBufferHandleFromNative()

Z
zengyawen 已提交
156

Z
zengyawen 已提交
157 158 159 160
```
BufferHandle* OH_NativeWindow_GetBufferHandleFromNative (struct NativeWindowBuffer * buffer)
```

Z
zengyawen 已提交
161
**描述:**
Z
zengyawen 已提交
162 163 164

通过NativeWindowBuffer获取该buffer的BufferHandle指针

Z
zengyawen 已提交
165
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
166

Z
zengyawen 已提交
167
**参数:**
Z
zengyawen 已提交
168

Z
zengyawen 已提交
169
| Name | 描述 |
Z
zengyawen 已提交
170
| -------- | -------- |
Z
zengyawen 已提交
171
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 |
Z
zengyawen 已提交
172

Z
zengyawen 已提交
173
**返回:**
Z
zengyawen 已提交
174 175 176

BufferHandle 返回一个指针,指向BufferHandle的结构体实例

Z
zengyawen 已提交
177 178 179 180
**自从:**

8

Z
zengyawen 已提交
181 182 183

### OH_NativeWindow_GetNativeObjectMagic()

Z
zengyawen 已提交
184

Z
zengyawen 已提交
185 186 187 188
```
int32_t OH_NativeWindow_GetNativeObjectMagic (void * obj)
```

Z
zengyawen 已提交
189
**描述:**
Z
zengyawen 已提交
190 191 192

获取NativeObject的MagicId

Z
zengyawen 已提交
193
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
194

Z
zengyawen 已提交
195
**参数:**
Z
zengyawen 已提交
196

Z
zengyawen 已提交
197
| Name | 描述 |
Z
zengyawen 已提交
198
| -------- | -------- |
Z
zengyawen 已提交
199
| obj | 参数是一个NativeWindow or NativeWindowBuffer的结构体实例的指针 |
Z
zengyawen 已提交
200

Z
zengyawen 已提交
201
**返回:**
Z
zengyawen 已提交
202 203 204

MagicId 返回值为魔鬼数字,每个NativeObject唯一

Z
zengyawen 已提交
205 206 207 208
**自从:**

8

Z
zengyawen 已提交
209 210 211

### OH_NativeWindow_NativeObjectReference()

Z
zengyawen 已提交
212

Z
zengyawen 已提交
213 214 215 216
```
int32_t OH_NativeWindow_NativeObjectReference (void * obj)
```

Z
zengyawen 已提交
217
**描述:**
Z
zengyawen 已提交
218 219 220

增加一个NativeObject的引用计数

Z
zengyawen 已提交
221
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
222

Z
zengyawen 已提交
223
**参数:**
Z
zengyawen 已提交
224

Z
zengyawen 已提交
225
| Name | 描述 |
Z
zengyawen 已提交
226
| -------- | -------- |
Z
zengyawen 已提交
227
| obj | 参数是一个NativeWindow or NativeWindowBuffer的结构体实例的指针 |
Z
zengyawen 已提交
228

Z
zengyawen 已提交
229
**返回:**
Z
zengyawen 已提交
230 231 232

GSError 返回值为错误码

Z
zengyawen 已提交
233 234 235 236
**自从:**

8

Z
zengyawen 已提交
237 238 239

### OH_NativeWindow_NativeObjectUnreference()

Z
zengyawen 已提交
240

Z
zengyawen 已提交
241 242 243 244
```
int32_t OH_NativeWindow_NativeObjectUnreference (void * obj)
```

Z
zengyawen 已提交
245
**描述:**
Z
zengyawen 已提交
246 247 248

减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉

Z
zengyawen 已提交
249
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
250

Z
zengyawen 已提交
251
**参数:**
Z
zengyawen 已提交
252

Z
zengyawen 已提交
253
| Name | 描述 |
Z
zengyawen 已提交
254
| -------- | -------- |
Z
zengyawen 已提交
255
| obj | 参数是一个NativeWindow or NativeWindowBuffer的结构体实例的指针 |
Z
zengyawen 已提交
256

Z
zengyawen 已提交
257
**返回:**
Z
zengyawen 已提交
258 259 260

GSError

Z
zengyawen 已提交
261 262 263 264
**自从:**

8

Z
zengyawen 已提交
265 266 267

### OH_NativeWindow_NativeWindowCancelBuffer()

Z
zengyawen 已提交
268

Z
zengyawen 已提交
269 270 271 272
```
int32_t OH_NativeWindow_NativeWindowCancelBuffer (struct NativeWindow * window, struct NativeWindowBuffer * buffer )
```

Z
zengyawen 已提交
273
**描述:**
Z
zengyawen 已提交
274 275 276

通过NativeWindow将之前申请出来的NativeWindowBuffer返还到Buffer队列中,供下次再申请

Z
zengyawen 已提交
277
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
278

Z
zengyawen 已提交
279
**参数:**
Z
zengyawen 已提交
280

Z
zengyawen 已提交
281
| Name | 描述 |
Z
zengyawen 已提交
282
| -------- | -------- |
Z
zengyawen 已提交
283 284
| window | 参数是一个NativeWindow的结构体实例的指针 |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 |
Z
zengyawen 已提交
285

Z
zengyawen 已提交
286
**返回:**
Z
zengyawen 已提交
287 288 289

GSError 返回值为错误码

Z
zengyawen 已提交
290 291 292 293
**自从:**

8

Z
zengyawen 已提交
294 295 296

### OH_NativeWindow_NativeWindowFlushBuffer()

Z
zengyawen 已提交
297

Z
zengyawen 已提交
298 299 300 301
```
int32_t OH_NativeWindow_NativeWindowFlushBuffer (struct NativeWindow * window, struct NativeWindowBuffer * buffer, int fenceFd, Region region )
```

Z
zengyawen 已提交
302
**描述:**
Z
zengyawen 已提交
303 304 305

通过NativeWindow将生产好内容的NativeWindowBuffer放回到Buffer队列中,用以内容消费

Z
zengyawen 已提交
306
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
307

Z
zengyawen 已提交
308
**参数:**
Z
zengyawen 已提交
309

Z
zengyawen 已提交
310
| Name | 描述 |
Z
zengyawen 已提交
311
| -------- | -------- |
Z
zengyawen 已提交
312 313 314 315
| window | 参数是一个NativeWindow的结构体实例的指针 |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 |
| fenceFd | 参数是一个文件描述符句柄,用以同步时序 |
| region | 参数表示一块脏区域,该区域有内容更新 |
Z
zengyawen 已提交
316

Z
zengyawen 已提交
317
**返回:**
Z
zengyawen 已提交
318 319 320

GSError 返回值为错误码

Z
zengyawen 已提交
321 322 323 324
**自从:**

8

Z
zengyawen 已提交
325 326 327

### OH_NativeWindow_NativeWindowHandleOpt()

Z
zengyawen 已提交
328

Z
zengyawen 已提交
329 330 331 332
```
int32_t OH_NativeWindow_NativeWindowHandleOpt (struct NativeWindow * window, int code,  ... )
```

Z
zengyawen 已提交
333
**描述:**
Z
zengyawen 已提交
334 335 336

设置/获取NativeWindow的属性,包括设置/获取宽高、内容格式等

Z
zengyawen 已提交
337
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
338

Z
zengyawen 已提交
339
**参数:**
Z
zengyawen 已提交
340

Z
zengyawen 已提交
341
| Name | 描述 |
Z
zengyawen 已提交
342
| -------- | -------- |
Z
zengyawen 已提交
343 344
| window | 参数是一个NativeWindow的结构体实例的指针 |
| code | 操作码 |
Z
zengyawen 已提交
345

Z
zengyawen 已提交
346
**返回:**
Z
zengyawen 已提交
347 348 349

GSError 返回值为错误码

Z
zengyawen 已提交
350 351 352 353
**自从:**

8

Z
zengyawen 已提交
354 355 356

### OH_NativeWindow_NativeWindowRequestBuffer()

Z
zengyawen 已提交
357

Z
zengyawen 已提交
358 359 360 361
```
int32_t OH_NativeWindow_NativeWindowRequestBuffer (struct NativeWindow * window, struct NativeWindowBuffer ** buffer, int * fenceFd )
```

Z
zengyawen 已提交
362
**描述:**
Z
zengyawen 已提交
363 364 365

通过NativeWindow对象申请一块NativeWindowBuffer,用以内容生产

Z
zengyawen 已提交
366
@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
Z
zengyawen 已提交
367

Z
zengyawen 已提交
368
**参数:**
Z
zengyawen 已提交
369

Z
zengyawen 已提交
370
| Name | 描述 |
Z
zengyawen 已提交
371
| -------- | -------- |
Z
zengyawen 已提交
372 373 374
| window | 参数是一个NativeWindow的结构体实例的指针 |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的二级指针 |
| fenceFd | 参数是一个文件描述符句柄 |
Z
zengyawen 已提交
375

Z
zengyawen 已提交
376
**返回:**
Z
zengyawen 已提交
377 378

GSError 返回值为错误码
Z
zengyawen 已提交
379 380 381 382

**自从:**

8