summaryrefslogtreecommitdiffstats
path: root/sway/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/render.c')
-rw-r--r--sway/render.c35
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 @@
1#include "render.h"
2#include <cairo.h>
3#include <stdlib.h>
4
5cairo_t *create_cairo_context(int width, int height, int channels,
6 cairo_surface_t **surf, unsigned char **buf) {
7 cairo_t *cr;
8 *buf = calloc(channels * width * height, sizeof(unsigned char));
9 if (!*buf) {
10 return NULL;
11 }
12 *surf = cairo_image_surface_create_for_data(*buf, CAIRO_FORMAT_ARGB32,
13 width, height, channels * width);
14 if (cairo_surface_status(*surf) != CAIRO_STATUS_SUCCESS) {
15 free(*buf);
16 return NULL;
17 }
18 cr = cairo_create(*surf);
19 if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) {
20 free(*buf);
21 return NULL;
22 }
23 return cr;
24}
25
26void render_view_borders(wlc_handle view) {
27 unsigned char *surf_data;
28 cairo_surface_t *surf;
29 int texture_id;
30 const struct wlc_geometry *geo = wlc_view_get_geometry(view);
31 cairo_t *cr = create_cairo_context(geo->size.w, geo->size.h, 4, &surf, &surf_data);
32 // TODO
33 cairo_destroy(cr);
34 free(surf_data);
35}