Imported Debian patch 0.1.0+git20131207+e452e83-0ubuntu12
[deb_libhybris.git] / wayland-android-client-protocol.h
... / ...
CommitLineData
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_CLIENT_PROTOCOL_H
27#define ANDROID_CLIENT_PROTOCOL_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <stdint.h>
34#include <stddef.h>
35#include "wayland-client.h"
36
37struct wl_client;
38struct wl_resource;
39
40struct android_wlegl;
41struct android_wlegl_handle;
42
43extern const struct wl_interface android_wlegl_interface;
44extern const struct wl_interface android_wlegl_handle_interface;
45
46#ifndef ANDROID_WLEGL_ERROR_ENUM
47#define ANDROID_WLEGL_ERROR_ENUM
48enum 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#define ANDROID_WLEGL_CREATE_HANDLE 0
55#define ANDROID_WLEGL_CREATE_BUFFER 1
56
57static inline void
58android_wlegl_set_user_data(struct android_wlegl *android_wlegl, void *user_data)
59{
60 wl_proxy_set_user_data((struct wl_proxy *) android_wlegl, user_data);
61}
62
63static inline void *
64android_wlegl_get_user_data(struct android_wlegl *android_wlegl)
65{
66 return wl_proxy_get_user_data((struct wl_proxy *) android_wlegl);
67}
68
69static inline void
70android_wlegl_destroy(struct android_wlegl *android_wlegl)
71{
72 wl_proxy_destroy((struct wl_proxy *) android_wlegl);
73}
74
75static inline struct android_wlegl_handle *
76android_wlegl_create_handle(struct android_wlegl *android_wlegl, int32_t num_fds, struct wl_array *ints)
77{
78 struct wl_proxy *id;
79
80 id = wl_proxy_create((struct wl_proxy *) android_wlegl,
81 &android_wlegl_handle_interface);
82 if (!id)
83 return NULL;
84
85 wl_proxy_marshal((struct wl_proxy *) android_wlegl,
86 ANDROID_WLEGL_CREATE_HANDLE, id, num_fds, ints);
87
88 return (struct android_wlegl_handle *) id;
89}
90
91static inline struct wl_buffer *
92android_wlegl_create_buffer(struct android_wlegl *android_wlegl, int32_t width, int32_t height, int32_t stride, int32_t format, int32_t usage, struct android_wlegl_handle *native_handle)
93{
94 struct wl_proxy *id;
95
96 id = wl_proxy_create((struct wl_proxy *) android_wlegl,
97 &wl_buffer_interface);
98 if (!id)
99 return NULL;
100
101 wl_proxy_marshal((struct wl_proxy *) android_wlegl,
102 ANDROID_WLEGL_CREATE_BUFFER, id, width, height, stride, format, usage, native_handle);
103
104 return (struct wl_buffer *) id;
105}
106
107#ifndef ANDROID_WLEGL_HANDLE_ERROR_ENUM
108#define ANDROID_WLEGL_HANDLE_ERROR_ENUM
109enum android_wlegl_handle_error {
110 ANDROID_WLEGL_HANDLE_ERROR_TOO_MANY_FDS = 0,
111};
112#endif /* ANDROID_WLEGL_HANDLE_ERROR_ENUM */
113
114#define ANDROID_WLEGL_HANDLE_ADD_FD 0
115#define ANDROID_WLEGL_HANDLE_DESTROY 1
116
117static inline void
118android_wlegl_handle_set_user_data(struct android_wlegl_handle *android_wlegl_handle, void *user_data)
119{
120 wl_proxy_set_user_data((struct wl_proxy *) android_wlegl_handle, user_data);
121}
122
123static inline void *
124android_wlegl_handle_get_user_data(struct android_wlegl_handle *android_wlegl_handle)
125{
126 return wl_proxy_get_user_data((struct wl_proxy *) android_wlegl_handle);
127}
128
129static inline void
130android_wlegl_handle_add_fd(struct android_wlegl_handle *android_wlegl_handle, int32_t fd)
131{
132 wl_proxy_marshal((struct wl_proxy *) android_wlegl_handle,
133 ANDROID_WLEGL_HANDLE_ADD_FD, fd);
134}
135
136static inline void
137android_wlegl_handle_destroy(struct android_wlegl_handle *android_wlegl_handle)
138{
139 wl_proxy_marshal((struct wl_proxy *) android_wlegl_handle,
140 ANDROID_WLEGL_HANDLE_DESTROY);
141
142 wl_proxy_destroy((struct wl_proxy *) android_wlegl_handle);
143}
144
145#ifdef __cplusplus
146}
147#endif
148
149#endif