summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile7
-rw-r--r--cairo-egl-wayland-window-surface.c43
3 files changed, 30 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore
index d495807..447b4a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,6 @@ egl-wayland-window
egl-wayland-window-legacy
egl-wayland-pixmap-image
egl-wayland-pixmap-surface
+cairo-egl-wayland-window-surface
va-egl
va-attach
diff --git a/Makefile b/Makefile
index a21b1c3..67252c2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,10 @@
WAYLAND_EGL_PROGRAMS = egl-wayland-window egl-wayland-window-legacy \
egl-wayland-pixmap-image egl-wayland-pixmap-surface
+CAIRO_EGL_PROGRAMS = cairo-egl-wayland-window-surface
VAAPI_PROGRAMS = va-egl va-attach
.PHONY: all
-all: $(WAYLAND_EGL_PROGRAMS)
+all: $(WAYLAND_EGL_PROGRAMS) $(CAIRO_EGL_PROGRAMS)
# verbosity stuff
DEFAULT_VERBOSITY=0
@@ -14,9 +15,13 @@ v_cc_0 = @echo " CC " $@;
$(WAYLAND_EGL_PROGRAMS): %: %.c
$(V_CC) $(CC) -o $@ $< `pkg-config --cflags --libs wayland-client wayland-egl egl gl` -lm
+$(CAIRO_EGL_PROGRAMS): %: %.c
+ $(V_CC) $(CC) -o $@ $< `pkg-config --cflags --libs wayland-client wayland-egl egl gl cairo-egl`
+
$(VAAPI_PROGRAMS): %: %.c
$(V_CC) $(CC) -o $@ $< `pkg-config --cflags --libs wayland-client wayland-egl libva libva-wayland`
clean:
rm -rf $(WAYLAND_EGL_PROGRAMS)
+ rm -rf $(CAIRO_EGL_PROGRAMS)
rm -rf $(VAAPI_PROGRAMS)
diff --git a/cairo-egl-wayland-window-surface.c b/cairo-egl-wayland-window-surface.c
index 6e446d0..4bed2ae 100644
--- a/cairo-egl-wayland-window-surface.c
+++ b/cairo-egl-wayland-window-surface.c
@@ -14,7 +14,6 @@
struct display {
struct wl_display *display;
- struct wl_egl_display *egl_display;
struct {
struct wl_compositor *compositor;
struct wl_shell *shell;
@@ -58,7 +57,7 @@ init_egl(struct display *display)
EGL_NONE
};
- display->egl.dpy = eglGetDisplay(display->egl_display);
+ display->egl.dpy = eglGetDisplay(display->display);
assert(display->egl.dpy);
assert(eglInitialize(display->egl.dpy, &major, &minor));
@@ -94,12 +93,9 @@ create_cairo_window_surface(struct display *display, struct window *window)
{
struct wl_visual *visual;
- visual = wl_display_get_premultiplied_argb_visual(display->display);
- window->egl_window = wl_egl_window_create(display->egl_display,
- window->surface,
+ window->egl_window = wl_egl_window_create(window->surface,
window->width,
- window->height,
- visual);
+ window->height);
window->egl.surf =
eglCreateWindowSurface(display->egl.dpy, display->egl.conf,
@@ -117,8 +113,10 @@ create_cairo_window_surface(struct display *display, struct window *window)
}
+static const struct wl_callback_listener frame_listener;
+
static void
-redraw(void *data, uint32_t time)
+redraw(void *data, struct wl_callback *callback, uint32_t time)
{
struct window *window = data;
cairo_t *cr;
@@ -163,11 +161,18 @@ redraw(void *data, uint32_t time)
cairo_fill(cr);
cairo_destroy(cr);
- cairo_gl_surface_swapbuffers(window->cairo_surface);
+ if (callback)
+ wl_callback_destroy(callback);
- wl_display_frame_callback(window->display->display, redraw, window);
+ callback = wl_surface_frame(window->surface);
+ wl_callback_add_listener(callback, &frame_listener, window);
+ cairo_gl_surface_swapbuffers(window->cairo_surface);
}
+static const struct wl_callback_listener frame_listener = {
+ redraw
+};
+
enum window_location {
WINDOW_INTERIOR = 0,
WINDOW_RESIZING_TOP = 1,
@@ -221,10 +226,12 @@ display_handle_global(struct wl_display *display, uint32_t id,
{
struct display *d = data;
- if (strcmp(interface, "compositor") == 0) {
- d->interface.compositor = wl_compositor_create(display, id);
- } else if (strcmp(interface, "shell") == 0) {
- d->interface.shell = wl_shell_create(display, id);
+ if (strcmp(interface, "wl_compositor") == 0) {
+ d->interface.compositor = wl_display_bind(display, id,
+ &wl_compositor_interface);
+ } else if (strcmp(interface, "wl_shell") == 0) {
+ d->interface.shell = wl_display_bind(display,
+ id, &wl_shell_interface);
wl_shell_add_listener(d->interface.shell, &wayland_shell_listener, d);
}
}
@@ -252,9 +259,6 @@ main(int argc, char **argv)
display.display = wl_display_connect(NULL);
assert(display.display);
- display.egl_display = wl_egl_display_create(display.display);
- assert(display.egl_display);
-
wl_display_add_global_listener(display.display,
display_handle_global, &display);
/* process connection events */
@@ -266,11 +270,10 @@ main(int argc, char **argv)
wl_surface_set_user_data(window.surface, &window);
create_cairo_window_surface(&display, &window);
- wl_surface_map_toplevel(window.surface);
-
- wl_display_frame_callback(display.display, redraw, &window);
+ wl_shell_set_toplevel(display.interface.shell, window.surface);
wl_display_get_fd(display.display, event_mask_update, &display);
+ redraw(&window, NULL, 0);
while (true)
wl_display_iterate(display.display, display.mask);