2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
23 #include <stddef.h> /* offsetof */
24 #include <stdio.h> /* printf */
26 #include "wayland-egl-backend.h" /* Current struct wl_egl_window implementation */
29 * Following are previous implementations of wl_egl_window.
34 /* From: 214fc6e850 - Benjamin Franzke : egl: Implement libwayland-egl */
35 struct wl_egl_window_v0
{
36 struct wl_surface
*surface
;
47 /* From: ca3ed3e024 - Ander Conselvan de Oliveira : egl/wayland: Don't invalidate drawable on swap buffers */
48 struct wl_egl_window_v1
{
49 struct wl_surface
*surface
;
60 void (*resize_callback
)(struct wl_egl_window
*, void *);
63 /* From: 690ead4a13 - Stencel, Joanna : egl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface. */
64 #define WL_EGL_WINDOW_VERSION_v2 2
65 struct wl_egl_window_v2
{
66 struct wl_surface
*surface
;
77 void (*resize_callback
)(struct wl_egl_window
*, void *);
78 void (*destroy_window_callback
)(void *);
81 /* From: 2d5d61bc49 - Miguel A. Vico : wayland-egl: Make wl_egl_window a versioned struct */
82 #define WL_EGL_WINDOW_VERSION_v3 3
83 struct wl_egl_window_v3
{
84 const intptr_t version
;
95 void (*resize_callback
)(struct wl_egl_window
*, void *);
96 void (*destroy_window_callback
)(void *);
98 struct wl_surface
*surface
;
102 /* This program checks we keep a backwards-compatible struct wl_egl_window
103 * definition whenever it is modified in wayland-egl-backend.h.
105 * The previous definition should be added above as a new struct
106 * wl_egl_window_vN, and the appropriate checks should be added below
109 #define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
111 #define CHECK_RENAMED_MEMBER(a_ver, b_ver, a_member, b_member) \
113 if (offsetof(struct wl_egl_window ## a_ver, a_member) != \
114 offsetof(struct wl_egl_window ## b_ver, b_member)) { \
115 printf("Backards incompatible change detected!\n " \
116 "offsetof(struct wl_egl_window" #a_ver "::" #a_member ") != " \
117 "offsetof(struct wl_egl_window" #b_ver "::" #b_member ")\n"); \
121 if (MEMBER_SIZE(struct wl_egl_window ## a_ver, a_member) != \
122 MEMBER_SIZE(struct wl_egl_window ## b_ver, b_member)) { \
123 printf("Backards incompatible change detected!\n " \
124 "MEMBER_SIZE(struct wl_egl_window" #a_ver "::" #a_member ") != " \
125 "MEMBER_SIZE(struct wl_egl_window" #b_ver "::" #b_member ")\n"); \
130 #define CHECK_MEMBER(a_ver, b_ver, member) CHECK_RENAMED_MEMBER(a_ver, b_ver, member, member)
131 #define CHECK_MEMBER_CURRENT(a_ver, member) CHECK_MEMBER(a_ver,, member)
133 #define CHECK_SIZE(a_ver, b_ver) \
135 if (sizeof(struct wl_egl_window ## a_ver) > \
136 sizeof(struct wl_egl_window ## b_ver)) { \
137 printf("Backards incompatible change detected!\n " \
138 "sizeof(struct wl_egl_window" #a_ver ") > " \
139 "sizeof(struct wl_egl_window" #b_ver ")\n"); \
144 #define CHECK_SIZE_CURRENT(a_ver) \
146 if (sizeof(struct wl_egl_window ## a_ver) != \
147 sizeof(struct wl_egl_window)) { \
148 printf("Backards incompatible change detected!\n " \
149 "sizeof(struct wl_egl_window" #a_ver ") != " \
150 "sizeof(struct wl_egl_window)\n"); \
155 #define CHECK_VERSION(a_ver, b_ver) \
157 if ((WL_EGL_WINDOW_VERSION ## a_ver) >= \
158 (WL_EGL_WINDOW_VERSION ## b_ver)) { \
159 printf("Backards incompatible change detected!\n " \
160 "WL_EGL_WINDOW_VERSION" #a_ver " >= " \
161 "WL_EGL_WINDOW_VERSION" #b_ver "\n"); \
166 #define CHECK_VERSION_CURRENT(a_ver) \
168 if ((WL_EGL_WINDOW_VERSION ## a_ver) != \
169 (WL_EGL_WINDOW_VERSION)) { \
170 printf("Backards incompatible change detected!\n " \
171 "WL_EGL_WINDOW_VERSION" #a_ver " != " \
172 "WL_EGL_WINDOW_VERSION\n"); \
177 int main(int argc
, char **argv
)
179 /* Check wl_egl_window_v1 ABI against wl_egl_window_v0 */
180 CHECK_MEMBER(_v0
, _v1
, surface
);
181 CHECK_MEMBER(_v0
, _v1
, width
);
182 CHECK_MEMBER(_v0
, _v1
, height
);
183 CHECK_MEMBER(_v0
, _v1
, dx
);
184 CHECK_MEMBER(_v0
, _v1
, dy
);
185 CHECK_MEMBER(_v0
, _v1
, attached_width
);
186 CHECK_MEMBER(_v0
, _v1
, attached_height
);
188 CHECK_SIZE(_v0
, _v1
);
190 /* Check wl_egl_window_v2 ABI against wl_egl_window_v1 */
191 CHECK_MEMBER(_v1
, _v2
, surface
);
192 CHECK_MEMBER(_v1
, _v2
, width
);
193 CHECK_MEMBER(_v1
, _v2
, height
);
194 CHECK_MEMBER(_v1
, _v2
, dx
);
195 CHECK_MEMBER(_v1
, _v2
, dy
);
196 CHECK_MEMBER(_v1
, _v2
, attached_width
);
197 CHECK_MEMBER(_v1
, _v2
, attached_height
);
198 CHECK_MEMBER(_v1
, _v2
, private);
199 CHECK_MEMBER(_v1
, _v2
, resize_callback
);
201 CHECK_SIZE(_v1
, _v2
);
203 /* Check wl_egl_window_v3 ABI against wl_egl_window_v2 */
204 CHECK_RENAMED_MEMBER(_v2
, _v3
, surface
, version
);
205 CHECK_MEMBER (_v2
, _v3
, width
);
206 CHECK_MEMBER (_v2
, _v3
, height
);
207 CHECK_MEMBER (_v2
, _v3
, dx
);
208 CHECK_MEMBER (_v2
, _v3
, dy
);
209 CHECK_MEMBER (_v2
, _v3
, attached_width
);
210 CHECK_MEMBER (_v2
, _v3
, attached_height
);
211 CHECK_MEMBER (_v2
, _v3
, private);
212 CHECK_MEMBER (_v2
, _v3
, resize_callback
);
213 CHECK_MEMBER (_v2
, _v3
, destroy_window_callback
);
215 CHECK_SIZE (_v2
, _v3
);
216 CHECK_VERSION(_v2
, _v3
);
218 /* Check current wl_egl_window ABI against wl_egl_window_v3 */
219 CHECK_MEMBER_CURRENT(_v3
, version
);
220 CHECK_MEMBER_CURRENT(_v3
, width
);
221 CHECK_MEMBER_CURRENT(_v3
, height
);
222 CHECK_MEMBER_CURRENT(_v3
, dx
);
223 CHECK_MEMBER_CURRENT(_v3
, dy
);
224 CHECK_MEMBER_CURRENT(_v3
, attached_width
);
225 CHECK_MEMBER_CURRENT(_v3
, attached_height
);
226 CHECK_MEMBER_CURRENT(_v3
, private);
227 CHECK_MEMBER_CURRENT(_v3
, resize_callback
);
228 CHECK_MEMBER_CURRENT(_v3
, destroy_window_callback
);
229 CHECK_MEMBER_CURRENT(_v3
, surface
);
231 CHECK_SIZE_CURRENT (_v3
);
232 CHECK_VERSION_CURRENT(_v3
);