Tizen 2.0 Release
[profile/ivi/osmesa.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                      struct wl_visual *visual)
22 {
23         struct wl_egl_window *egl_window;
24
25         egl_window = malloc(sizeof *egl_window);
26         if (!egl_window)
27                 return NULL;
28
29         egl_window->surface = surface;
30         egl_window->visual  = visual;
31         wl_egl_window_resize(egl_window, width, height, 0, 0);
32         egl_window->attached_width  = 0;
33         egl_window->attached_height = 0;
34         
35         return egl_window;
36 }
37
38 WL_EGL_EXPORT void
39 wl_egl_window_destroy(struct wl_egl_window *egl_window)
40 {
41         free(egl_window);
42 }
43
44 WL_EGL_EXPORT void
45 wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
46                                 int *width, int *height)
47 {
48         if (width)
49                 *width = egl_window->attached_width;
50         if (height)
51                 *height = egl_window->attached_height;
52 }
53
54 WL_EGL_EXPORT struct wl_egl_pixmap *
55 wl_egl_pixmap_create(int width, int height,
56                      struct wl_visual *visual, uint32_t flags)
57 {
58         struct wl_egl_pixmap *egl_pixmap;
59
60         egl_pixmap = malloc(sizeof *egl_pixmap);
61         if (egl_pixmap == NULL)
62                 return NULL;
63
64         egl_pixmap->width   = width;
65         egl_pixmap->height  = height;
66         egl_pixmap->visual  = visual;
67
68         egl_pixmap->destroy = NULL;
69         egl_pixmap->buffer  = NULL;
70         egl_pixmap->driver_private = NULL;
71
72         return egl_pixmap;
73 }
74
75 WL_EGL_EXPORT void
76 wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap)
77 {
78         if (egl_pixmap->destroy)
79                 egl_pixmap->destroy(egl_pixmap);
80         free(egl_pixmap);
81 }
82
83 WL_EGL_EXPORT struct wl_buffer *
84 wl_egl_pixmap_create_buffer(struct wl_egl_pixmap *egl_pixmap)
85 {
86         return egl_pixmap->buffer;
87 }