diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-11-27 13:26:35 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-11-27 13:26:35 -0800 |
| commit | dedef4369dea1131248b56b22573d0365f321179 (patch) | |
| tree | a2f60657bca09f3d9a9224398db3a77e11ddf377 /src/cairo-image.cpp | |
| parent | 6d69b17a2001c3fb392e7cf9d8e96e585e8f5aaa (diff) | |
Simplify module naming for clarity
Diffstat (limited to 'src/cairo-image.cpp')
| -rw-r--r-- | src/cairo-image.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/cairo-image.cpp b/src/cairo-image.cpp new file mode 100644 index 0000000..1e374ea --- /dev/null +++ b/src/cairo-image.cpp @@ -0,0 +1,58 @@ +#include <err.h> +#include <stdlib.h> +#include <cairo.h> +#include <cairo-gl.h> + +struct graphics_state { + Display *dpy; + Window window; +}; + +static void +cleanup (void *data) +{ + struct graphics_state *state = (graphics_state*)data; + + /* + XDestroyWindow (state->dpy, state->window); + XCloseDisplay (state->dpy); + */ + free (state); +} + +cairo_surface_t * +create_cairo_surface_image (int width, int height) +{ + struct graphics_state *state; + cairo_surface_t *cairo_surface; + + state = (graphics_state*) malloc (sizeof (struct graphics_state)); + if (!state) { + warnx ("Out of memory\n"); + return NULL; + } + + /* + state->dpy = XOpenDisplay (NULL); + if (state->dpy == NULL) { + warnx ("Failed to open display: %s\n", XDisplayName (0)); + return NULL; + } + */ + + cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, + width, + height); + + if (cairo_surface_set_user_data (cairo_surface, + (cairo_user_data_key_t *) cleanup, + state, + cleanup)) + { + warnx ("Failed to setup cleanup callback closure\n"); + cleanup (state); + return NULL; + } + + return cairo_surface; +} |