diff options
author | Drew DeVault <[email protected]> | 2016-01-28 08:39:51 -0500 |
---|---|---|
committer | Mikkel Oscar Lyderik <[email protected]> | 2016-03-30 00:47:58 +0200 |
commit | 4611bba3dbf63a5ef67bf90d5ebd192eeb07742e (patch) | |
tree | a57320e5a6d463c020986c324a4671aaeed0e415 /sway/render.c | |
parent | c3a5e00b6e70eaad3213733ff8cd69a84f06ab67 (diff) |
Initial setup of window border rendering
Please don't complain to me about the performance of this
Diffstat (limited to 'sway/render.c')
-rw-r--r-- | sway/render.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sway/render.c b/sway/render.c new file mode 100644 index 00000000..66d2e5f0 --- /dev/null +++ b/sway/render.c @@ -0,0 +1,35 @@ +#include "render.h" +#include <cairo.h> +#include <stdlib.h> + +cairo_t *create_cairo_context(int width, int height, int channels, + cairo_surface_t **surf, unsigned char **buf) { + cairo_t *cr; + *buf = calloc(channels * width * height, sizeof(unsigned char)); + if (!*buf) { + return NULL; + } + *surf = cairo_image_surface_create_for_data(*buf, CAIRO_FORMAT_ARGB32, + width, height, channels * width); + if (cairo_surface_status(*surf) != CAIRO_STATUS_SUCCESS) { + free(*buf); + return NULL; + } + cr = cairo_create(*surf); + if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) { + free(*buf); + return NULL; + } + return cr; +} + +void render_view_borders(wlc_handle view) { + unsigned char *surf_data; + cairo_surface_t *surf; + int texture_id; + const struct wlc_geometry *geo = wlc_view_get_geometry(view); + cairo_t *cr = create_cairo_context(geo->size.w, geo->size.h, 4, &surf, &surf_data); + // TODO + cairo_destroy(cr); + free(surf_data); +} |