wayland-drm: Drop the non-premul formats, use format codes from drm_fourcc.h
[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 egl_window->width = width;
13 egl_window->height = height;
14 egl_window->dx = dx;
15 egl_window->dy = dy;
16 }
17
18 WL_EGL_EXPORT struct wl_egl_window *
19 wl_egl_window_create(struct wl_surface *surface,
20 int width, int height)
21 {
22 struct wl_egl_window *egl_window;
23
24 egl_window = malloc(sizeof *egl_window);
25 if (!egl_window)
26 return NULL;
27
28 egl_window->surface = surface;
29 wl_egl_window_resize(egl_window, width, height, 0, 0);
30 egl_window->attached_width = 0;
31 egl_window->attached_height = 0;
32
33 return egl_window;
34 }
35
36 WL_EGL_EXPORT void
37 wl_egl_window_destroy(struct wl_egl_window *egl_window)
38 {
39 free(egl_window);
40 }
41
42 WL_EGL_EXPORT void
43 wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
44 int *width, int *height)
45 {
46 if (width)
47 *width = egl_window->attached_width;
48 if (height)
49 *height = egl_window->attached_height;
50 }
51
52 WL_EGL_EXPORT struct wl_egl_pixmap *
53 wl_egl_pixmap_create(int width, int height, uint32_t flags)
54 {
55 struct wl_egl_pixmap *egl_pixmap;
56
57 egl_pixmap = malloc(sizeof *egl_pixmap);
58 if (egl_pixmap == NULL)
59 return NULL;
60
61 egl_pixmap->width = width;
62 egl_pixmap->height = height;
63
64 egl_pixmap->destroy = NULL;
65 egl_pixmap->buffer = NULL;
66 egl_pixmap->driver_private = NULL;
67
68 return egl_pixmap;
69 }
70
71 WL_EGL_EXPORT void
72 wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap)
73 {
74 if (egl_pixmap->destroy)
75 egl_pixmap->destroy(egl_pixmap);
76 free(egl_pixmap);
77 }
78
79 WL_EGL_EXPORT struct wl_buffer *
80 wl_egl_pixmap_create_buffer(struct wl_egl_pixmap *egl_pixmap)
81 {
82 return egl_pixmap->buffer;
83 }