wayland-egl.c revision eaf6884621661288624fc060974c3aa485771324
1#include <stdlib.h> 2 3#include <wayland-client.h> 4#include "wayland-egl.h" 5#include "wayland-egl-priv.h" 6 7WL_EGL_EXPORT void 8wl_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 if (egl_window->resize_callback) 18 egl_window->resize_callback(egl_window, egl_window->private); 19} 20 21WL_EGL_EXPORT struct wl_egl_window * 22wl_egl_window_create(struct wl_surface *surface, 23 int width, int height) 24{ 25 struct wl_egl_window *egl_window; 26 27 egl_window = malloc(sizeof *egl_window); 28 if (!egl_window) 29 return NULL; 30 31 egl_window->surface = surface; 32 egl_window->private = NULL; 33 egl_window->resize_callback = NULL; 34 wl_egl_window_resize(egl_window, width, height, 0, 0); 35 egl_window->attached_width = 0; 36 egl_window->attached_height = 0; 37 38 return egl_window; 39} 40 41WL_EGL_EXPORT void 42wl_egl_window_destroy(struct wl_egl_window *egl_window) 43{ 44 free(egl_window); 45} 46 47WL_EGL_EXPORT void 48wl_egl_window_get_attached_size(struct wl_egl_window *egl_window, 49 int *width, int *height) 50{ 51 if (width) 52 *width = egl_window->attached_width; 53 if (height) 54 *height = egl_window->attached_height; 55} 56