Commit | Line | Data |
---|---|---|
d42e7319 JB |
1 | /* |
2 | * Copyright © 2012 Collabora, Ltd. | |
3 | * | |
4 | * Permission to use, copy, modify, distribute, and sell this | |
5 | * software and its documentation for any purpose is hereby granted | |
6 | * without fee, provided that the above copyright notice appear in | |
7 | * all copies and that both that copyright notice and this permission | |
8 | * notice appear in supporting documentation, and that the name of | |
9 | * the copyright holders not be used in advertising or publicity | |
10 | * pertaining to distribution of the software without specific, | |
11 | * written prior permission. The copyright holders make no | |
12 | * representations about the suitability of this software for any | |
13 | * purpose. It is provided "as is" without express or implied | |
14 | * warranty. | |
15 | * | |
16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS | |
17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | |
21 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
22 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | |
23 | * THIS SOFTWARE. | |
24 | */ | |
25 | ||
26 | #ifndef ANDROID_SERVER_PROTOCOL_H | |
27 | #define ANDROID_SERVER_PROTOCOL_H | |
28 | ||
29 | #ifdef __cplusplus | |
30 | extern "C" { | |
31 | #endif | |
32 | ||
33 | #include <stdint.h> | |
34 | #include <stddef.h> | |
35 | #include "wayland-util.h" | |
36 | ||
37 | struct wl_client; | |
38 | struct wl_resource; | |
39 | ||
40 | struct android_wlegl; | |
41 | struct android_wlegl_handle; | |
42 | ||
43 | extern const struct wl_interface android_wlegl_interface; | |
44 | extern const struct wl_interface android_wlegl_handle_interface; | |
45 | ||
46 | #ifndef ANDROID_WLEGL_ERROR_ENUM | |
47 | #define ANDROID_WLEGL_ERROR_ENUM | |
48 | enum android_wlegl_error { | |
49 | ANDROID_WLEGL_ERROR_BAD_HANDLE = 0, | |
50 | ANDROID_WLEGL_ERROR_BAD_VALUE = 1, | |
51 | }; | |
52 | #endif /* ANDROID_WLEGL_ERROR_ENUM */ | |
53 | ||
54 | /** | |
55 | * android_wlegl - Android EGL graphics buffer support | |
56 | * @create_handle: Create an Android native_handle_t object | |
57 | * @create_buffer: Create a wl_buffer from the native handle | |
58 | * | |
59 | * Interface used in the Android wrapper libEGL to share graphics buffers | |
60 | * between the server and the client. | |
61 | */ | |
62 | struct android_wlegl_interface { | |
63 | /** | |
64 | * create_handle - Create an Android native_handle_t object | |
65 | * @id: (none) | |
66 | * @num_fds: (none) | |
67 | * @ints: an array of int32_t | |
68 | * | |
69 | * This creator method initialises the native_handle_t object | |
70 | * with everything except the file descriptors, which have to be | |
71 | * submitted separately. | |
72 | */ | |
73 | void (*create_handle)(struct wl_client *client, | |
74 | struct wl_resource *resource, | |
75 | uint32_t id, | |
76 | int32_t num_fds, | |
77 | struct wl_array *ints); | |
78 | /** | |
79 | * create_buffer - Create a wl_buffer from the native handle | |
80 | * @id: (none) | |
81 | * @width: (none) | |
82 | * @height: (none) | |
83 | * @stride: (none) | |
84 | * @format: (none) | |
85 | * @usage: (none) | |
86 | * @native_handle: (none) | |
87 | * | |
88 | * Pass the Android native_handle_t to the server and attach it | |
89 | * to the new wl_buffer object. | |
90 | * | |
91 | * The android_wlegl_handle object must be destroyed immediately | |
92 | * after this request. | |
93 | */ | |
94 | void (*create_buffer)(struct wl_client *client, | |
95 | struct wl_resource *resource, | |
96 | uint32_t id, | |
97 | int32_t width, | |
98 | int32_t height, | |
99 | int32_t stride, | |
100 | int32_t format, | |
101 | int32_t usage, | |
102 | struct wl_resource *native_handle); | |
103 | }; | |
104 | ||
105 | #ifndef ANDROID_WLEGL_HANDLE_ERROR_ENUM | |
106 | #define ANDROID_WLEGL_HANDLE_ERROR_ENUM | |
107 | enum android_wlegl_handle_error { | |
108 | ANDROID_WLEGL_HANDLE_ERROR_TOO_MANY_FDS = 0, | |
109 | }; | |
110 | #endif /* ANDROID_WLEGL_HANDLE_ERROR_ENUM */ | |
111 | ||
112 | /** | |
113 | * android_wlegl_handle - An Android native_handle_t object | |
114 | * @add_fd: (none) | |
115 | * @destroy: (none) | |
116 | * | |
117 | * The Android native_handle_t is a semi-opaque object, that contains an | |
118 | * EGL implementation specific number of int32 values and file descriptors. | |
119 | * | |
120 | * We cannot send a variable size array of file descriptors over the | |
121 | * Wayland protocol, so we send them one by one. | |
122 | */ | |
123 | struct android_wlegl_handle_interface { | |
124 | /** | |
125 | * add_fd - (none) | |
126 | * @fd: (none) | |
127 | */ | |
128 | void (*add_fd)(struct wl_client *client, | |
129 | struct wl_resource *resource, | |
130 | int32_t fd); | |
131 | /** | |
132 | * destroy - (none) | |
133 | */ | |
134 | void (*destroy)(struct wl_client *client, | |
135 | struct wl_resource *resource); | |
136 | }; | |
137 | ||
138 | #ifdef __cplusplus | |
139 | } | |
140 | #endif | |
141 | ||
142 | #endif |