diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-03 18:45:43 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-03 18:46:10 +0100 |
commit | 8d0b59b71c896bd8abbd2d14ce55f4de513f11e0 (patch) | |
tree | fe34b5925466a52b8fc5ceed776ac568bbd15548 | |
parent | 551cf6053728c9cf691c443c409d3fbd936db0eb (diff) |
egl-wayland-pixmap-*: Update to wayland master
-rw-r--r-- | egl-wayland-pixmap-image.c | 73 | ||||
-rw-r--r-- | egl-wayland-pixmap-surface.c | 43 |
2 files changed, 37 insertions, 79 deletions
diff --git a/egl-wayland-pixmap-image.c b/egl-wayland-pixmap-image.c index 2908742..18ea80c 100644 --- a/egl-wayland-pixmap-image.c +++ b/egl-wayland-pixmap-image.c @@ -189,30 +189,10 @@ init_gl(struct window *window) glGetUniformLocation(window->gl.program, "rotation"); } - -static void -sync_callback(void *data) -{ - int *done = data; - - *done = 1; -} - static void create_surface(struct window *window) { struct display *display = window->display; - int done = 0; - - if (!display->premultiplied_argb_visual) { - wl_display_sync_callback(display->display, sync_callback, &done); - while (!done) - wl_display_iterate(display->display, display->mask); - if (!display->premultiplied_argb_visual) { - fprintf(stderr, "premultiplied argb visual missing\n"); - exit(1); - } - } window->surface.surface = wl_compositor_create_surface(display->compositor); @@ -220,8 +200,7 @@ create_surface(struct window *window) window->surface.egl_pixmap = wl_egl_pixmap_create(window->geometry.width, - window->geometry.height, - display->premultiplied_argb_visual, 0); + window->geometry.height, 0); window->surface.buffer = NULL; wl_shell_set_toplevel(display->shell, window->surface.surface); @@ -243,8 +222,10 @@ create_surface(struct window *window) GL_FRAMEBUFFER_COMPLETE); } +static const struct wl_callback_listener frame_listener; + static void -redraw(struct wl_surface *surface, void *data, uint32_t time) +redraw(void *data, struct wl_callback *callback, uint32_t time) { struct window *window = data; static const GLfloat verts[3][2] = { @@ -297,6 +278,12 @@ redraw(struct wl_surface *surface, void *data, uint32_t time) wl_egl_pixmap_create_buffer(window->surface.egl_pixmap); glFlush(); + + if (callback) + wl_callback_destroy(callback); + + callback = wl_surface_frame(window->surface.surface); + wl_callback_add_listener(callback, &frame_listener, window); wl_surface_attach(window->surface.surface, window->surface.buffer, window->dx, window->dy); @@ -307,11 +294,12 @@ redraw(struct wl_surface *surface, void *data, uint32_t time) wl_surface_damage(window->surface.surface, 0, 0, window->geometry.width, window->geometry.height); - - wl_display_frame_callback(window->display->display, surface, - redraw, window); } +static const struct wl_callback_listener frame_listener = { + redraw +}; + static void handle_configure(void *data, struct wl_shell *shell, uint32_t time, uint32_t edges, @@ -348,8 +336,7 @@ handle_configure(void *data, struct wl_shell *shell, window->surface.egl_pixmap = wl_egl_pixmap_create(window->geometry.width, - window->geometry.height, - d->premultiplied_argb_visual, 0); + window->geometry.height, 0); if (window->surface.buffer) { //wl_buffer_destroy(window->surface.buffer); @@ -380,38 +367,16 @@ static const struct wl_shell_listener shell_listener = { static void -compositor_handle_visual(void *data, - struct wl_compositor *compositor, - uint32_t id, uint32_t token) -{ - struct display *d = data; - - switch (token) { - case WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32: - d->premultiplied_argb_visual = - wl_visual_create(d->display, id, 1); - break; - } -} - -static const struct wl_compositor_listener compositor_listener = { - compositor_handle_visual, -}; - - - -static void display_handle_global(struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) { struct display *d = data; if (strcmp(interface, "wl_compositor") == 0) { - d->compositor = wl_compositor_create(display, id, 1); - wl_compositor_add_listener(d->compositor, - &compositor_listener, d); + d->compositor = wl_display_bind(display, id, + &wl_compositor_interface); } else if (strcmp(interface, "wl_shell") == 0) { - d->shell = wl_shell_create(display, id, 1); + d->shell = wl_display_bind(display, id, &wl_shell_interface); wl_shell_add_listener(d->shell, &shell_listener, d); } } @@ -453,7 +418,7 @@ main(int argc, char **argv) init_gl(&window); create_surface(&window); - redraw(window.surface.surface, &window, 0); + redraw(&window, NULL, 0); while (true) wl_display_iterate(display.display, display.mask); diff --git a/egl-wayland-pixmap-surface.c b/egl-wayland-pixmap-surface.c index 8db686a..e9df0d5 100644 --- a/egl-wayland-pixmap-surface.c +++ b/egl-wayland-pixmap-surface.c @@ -74,25 +74,9 @@ init_egl(struct display *display) static void create_egl_surface(struct display *display, struct window *window) { - struct wl_visual *visual; - int done = 0; - - if (!display->premultiplied_argb_visual) { - wl_display_sync_callback(display->display, sync_callback, &done); - while (!done) - wl_display_iterate(display->display, display->mask); - if (!display->premultiplied_argb_visual) { - fprintf(stderr, "premultiplied argb visual missing\n"); - exit(1); - } - } - - visual = display->premultiplied_argb_visual; - window->egl_pixmap = wl_egl_pixmap_create(window->width, - window->height, - visual, 0); + window->height, 0); window->buffer = NULL; window->egl.surf = @@ -121,8 +105,10 @@ init_gl(struct window *window) glTranslatef(0.0, 0.0, -10.0); } +static const struct wl_callback_listener frame_listener; + static void -redraw(struct wl_surface *surface, void *data, uint32_t time) +redraw(void *data, struct wl_callback *callback, uint32_t time) { struct window *window = data; static const GLfloat verts[3][2] = { @@ -185,10 +171,17 @@ redraw(struct wl_surface *surface, void *data, uint32_t time) wl_surface_damage(window->surface, 0, 0, window->width, window->height); - wl_display_frame_callback(window->display->display, window->surface, - redraw, window); + if (callback) + wl_callback_destroy(callback); + + callback = wl_surface_frame(window->surface); + wl_callback_add_listener(callback, &frame_listener, window); } +static const struct wl_callback_listener frame_listener = { + redraw +}; + enum window_location { WINDOW_INTERIOR = 0, WINDOW_RESIZING_TOP = 1, @@ -256,9 +249,10 @@ display_handle_global(struct wl_display *display, uint32_t id, struct display *d = data; if (strcmp(interface, "wl_compositor") == 0) { - d->interface.compositor = wl_compositor_create(display, id, 1); + d->interface.compositor = wl_display_bind(display, id, + &wl_compositor_interface); } else if (strcmp(interface, "wl_shell") == 0) { - d->interface.shell = wl_shell_create(display, id, 1); + d->interface.shell = wl_display_bind(display, id, &wl_shell_interface); wl_shell_add_listener(d->interface.shell, &wayland_shell_listener, d); } } @@ -301,10 +295,9 @@ main(int argc, char **argv) init_gl(&window); - wl_surface_map_toplevel(window.surface); + wl_shell_set_toplevel(display.interface.shell, window.surface); - redraw(window.surface, &window, 0); - //wl_display_frame_callback(display.display, window.surface, redraw, &window); + redraw(&window, NULL, 0); while (true) wl_display_iterate(display.display, display.mask); |