ae78595b92cc578fd2e5a47e0a7bf45a29bcdeb1
[mesa.git] / src / egl / wayland / wayland-egl / wayland-egl.c
1 #include <stdlib.h>
2
3 #include <wayland-client.h>
4 #include "wayland-egl.h"
5 #include "wayland-egl-priv.h"
6
7 WL_EGL_EXPORT void
8 wl_egl_window_resize(struct wl_egl_window *egl_window,
9 int width, int height,
10 int dx, int dy)
11 {
12 if (width <= 0 || height <= 0)
13 return;
14
15 egl_window->width = width;
16 egl_window->height = height;
17 egl_window->dx = dx;
18 egl_window->dy = dy;
19
20 if (egl_window->resize_callback)
21 egl_window->resize_callback(egl_window, egl_window->private);
22 }
23
24 WL_EGL_EXPORT struct wl_egl_window *
25 wl_egl_window_create(struct wl_surface *surface,
26 int width, int height)
27 {
28 struct wl_egl_window *egl_window;
29
30 if (width <= 0 || height <= 0)
31 return NULL;
32
33 egl_window = malloc(sizeof *egl_window);
34 if (!egl_window)
35 return NULL;
36
37 egl_window->surface = surface;
38 egl_window->private = NULL;
39 egl_window->resize_callback = NULL;
40 wl_egl_window_resize(egl_window, width, height, 0, 0);
41 egl_window->attached_width = 0;
42 egl_window->attached_height = 0;
43
44 return egl_window;
45 }
46
47 WL_EGL_EXPORT void
48 wl_egl_window_destroy(struct wl_egl_window *egl_window)
49 {
50 free(egl_window);
51 }
52
53 WL_EGL_EXPORT void
54 wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
55 int *width, int *height)
56 {
57 if (width)
58 *width = egl_window->attached_width;
59 if (height)
60 *height = egl_window->attached_height;
61 }