Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
277 lines (222 loc) · 6.65 KB

File metadata and controls

277 lines (222 loc) · 6.65 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_EGLNATIVES_H
#define ANDROID_EGLNATIVES_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
struct egl_native_window_t;
struct egl_native_pixmap_t;
typedef struct egl_native_window_t* NativeWindowType;
typedef struct egl_native_pixmap_t* NativePixmapType;
typedef void* NativeDisplayType;
/*
* This a conveniance function to create a NativeWindowType surface
* that maps to the whole screen
* This function is actually implemented in libui.so
*/
NativeWindowType android_createDisplaySurface();
/* flags returned from swapBuffer */
#define EGL_NATIVES_FLAG_SIZE_CHANGED 0x00000001
/* surface flags */
#define EGL_NATIVES_FLAG_DESTROY_BACKBUFFER 0x00000001
enum native_pixel_format_t
{
NATIVE_PIXEL_FORMAT_RGBA_8888 = 1,
NATIVE_PIXEL_FORMAT_RGB_565 = 4,
NATIVE_PIXEL_FORMAT_RGBA_5551 = 6,
NATIVE_PIXEL_FORMAT_RGBA_4444 = 7,
NATIVE_PIXEL_FORMAT_YCbCr_422_SP= 0x10,
NATIVE_PIXEL_FORMAT_YCbCr_420_SP= 0x11,
};
enum native_memory_type_t
{
NATIVE_MEMORY_TYPE_PMEM = 0,
NATIVE_MEMORY_TYPE_GPU = 1,
NATIVE_MEMORY_TYPE_FB = 2,
NATIVE_MEMORY_TYPE_HEAP = 128
};
struct egl_native_window_t
{
/*
* magic must be set to 0x600913
*/
uint32_t magic;
/*
* must be sizeof(egl_native_window_t)
*/
uint32_t version;
/*
* ident is reserved for the Android platform
*/
uint32_t ident;
/*
* width, height and stride of the window in pixels
* Any of these value can be nul in which case GL commands are
* accepted and processed as usual, but not rendering occurs.
*/
int width; // w=h=0 is legal
int height;
int stride;
/*
* format of the native window (see ui/PixelFormat.h)
*/
int format;
/*
* Offset of the bits in the VRAM
*/
intptr_t offset;
/*
* flags describing some attributes of this surface
* EGL_NATIVES_FLAG_DESTROY_BACKBUFFER: backbuffer not preserved after
* eglSwapBuffers
*/
uint32_t flags;
/*
* horizontal and vertical resolution in DPI
*/
float xdpi;
float ydpi;
/*
* refresh rate in frames per second (Hz)
*/
float fps;
/*
* Base memory virtual address of the surface in the CPU side
*/
intptr_t base;
/*
* Heap the offset above is based from
*/
int fd;
/*
* Memory type the surface resides into
*/
uint8_t memory_type;
/*
* Reserved for future use. MUST BE ZERO.
*/
uint8_t reserved_pad[3];
int reserved[8];
/*
* Vertical stride (only relevant with planar formats)
*/
int vstride;
/*
* Hook called by EGL to hold a reference on this structure
*/
void (*incRef)(NativeWindowType window);
/*
* Hook called by EGL to release a reference on this structure
*/
void (*decRef)(NativeWindowType window);
/*
* Hook called by EGL to perform a page flip. This function
* may update the size attributes above, in which case it returns
* the EGL_NATIVES_FLAG_SIZE_CHANGED bit set.
*/
uint32_t (*swapBuffers)(NativeWindowType window);
/*
* Hook called by EGL to set the swap rectangle. this hook can be
* null (operation not supported)
*/
void (*setSwapRectangle)(NativeWindowType window, int l, int t, int w, int h);
/*
* Reserved for future use. MUST BE ZERO.
*/
void (*reserved_proc_0)(void);
/*
* Hook called by EGL to retrieve the next buffer to render into.
* This call updates this structure.
*/
uint32_t (*nextBuffer)(NativeWindowType window);
/*
* Hook called by EGL when the native surface is associated to EGL
* (eglCreateWindowSurface). Can be NULL.
*/
void (*connect)(NativeWindowType window);
/*
* Hook called by EGL when eglDestroySurface is called. Can be NULL.
*/
void (*disconnect)(NativeWindowType window);
/*
* Reserved for future use. MUST BE ZERO.
*/
void (*reserved_proc[11])(void);
/*
* Some storage reserved for the oem driver.
*/
intptr_t oem[4];
};
struct egl_native_pixmap_t
{
int32_t version; /* must be 32 */
int32_t width;
int32_t height;
int32_t stride;
uint8_t* data;
uint8_t format;
uint8_t rfu[3];
union {
uint32_t compressedFormat;
int32_t vstride;
};
int32_t reserved;
};
/*****************************************************************************/
/*
* OEM's egl's library (libhgl.so) must imlement these hooks to allocate
* the GPU memory they need
*/
typedef struct
{
// for internal use
void* user;
// virtual address of this area
void* base;
// size of this area in bytes
size_t size;
// physical address of this area
void* phys;
// offset in this area available to the GPU
size_t offset;
// fd of this area
int fd;
} gpu_area_t;
typedef struct
{
// area where GPU registers are mapped
gpu_area_t regs;
// number of extra areas (currently limited to 2)
int32_t count;
// extra GPU areas (currently limited to 2)
gpu_area_t gpu[2];
} request_gpu_t;
typedef request_gpu_t* (*OEM_EGL_acquire_gpu_t)(void* user);
typedef int (*OEM_EGL_release_gpu_t)(void* user, request_gpu_t* handle);
typedef void (*register_gpu_t)
(void* user, OEM_EGL_acquire_gpu_t, OEM_EGL_release_gpu_t);
void oem_register_gpu(
void* user,
OEM_EGL_acquire_gpu_t acquire,
OEM_EGL_release_gpu_t release);
/*****************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* ANDROID_EGLNATIVES_H */