aboutsummaryrefslogtreecommitdiff
path: root/src/backend_librsvg.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-06-15 14:28:29 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-07-03 20:50:19 +0100
commit7c7dc660e587eac1aa3c8b3405eba95ba558e682 (patch)
tree81d12d560b60d397be23c7d132e32a5de30e409a /src/backend_librsvg.c
parent20e9d23b82f55a751c3cf1166cb59ef26775ee00 (diff)
downloadimv-7c7dc660e587eac1aa3c8b3405eba95ba558e682.tar.gz
Big glfw refactor
I did a lot of this in a very ad-hoc fashion with no proper commit history. As such, the kindest thing to do seemed to be to just squash it into this one commit.
Diffstat (limited to 'src/backend_librsvg.c')
-rw-r--r--src/backend_librsvg.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/src/backend_librsvg.c b/src/backend_librsvg.c
index c8dde19..d8c4557 100644
--- a/src/backend_librsvg.c
+++ b/src/backend_librsvg.c
@@ -33,18 +33,6 @@ static void source_free(struct imv_source *src)
free(src);
}
-static struct imv_bitmap *to_imv_bitmap(GdkPixbuf *bitmap)
-{
- struct imv_bitmap *bmp = malloc(sizeof *bmp);
- bmp->width = gdk_pixbuf_get_width(bitmap);
- bmp->height = gdk_pixbuf_get_height(bitmap);
- bmp->format = IMV_ABGR;
- size_t len = bmp->width * bmp->height * 4;
- bmp->data = malloc(len);
- memcpy(bmp->data, gdk_pixbuf_get_pixels(bitmap), len);
- return bmp;
-}
-
static void report_error(struct imv_source *src)
{
assert(src->callback);
@@ -52,22 +40,21 @@ static void report_error(struct imv_source *src)
struct imv_source_message msg;
msg.source = src;
msg.user_data = src->user_data;
- msg.bitmap = NULL;
+ msg.image = NULL;
msg.error = "Internal error";
pthread_mutex_unlock(&src->busy);
src->callback(&msg);
}
-
-static void send_bitmap(struct imv_source *src, GdkPixbuf *bitmap)
+static void send_svg(struct imv_source *src, RsvgHandle *handle)
{
assert(src->callback);
struct imv_source_message msg;
msg.source = src;
msg.user_data = src->user_data;
- msg.bitmap = to_imv_bitmap(bitmap);
+ msg.image = imv_image_create_from_svg(handle);
msg.frametime = 0;
msg.error = NULL;
@@ -75,11 +62,11 @@ static void send_bitmap(struct imv_source *src, GdkPixbuf *bitmap)
src->callback(&msg);
}
-static int load_image(struct imv_source *src)
+static void *load_image(struct imv_source *src)
{
/* Don't run if this source is already active */
if (pthread_mutex_trylock(&src->busy)) {
- return -1;
+ return NULL;
}
RsvgHandle *handle = NULL;
@@ -96,7 +83,7 @@ static int load_image(struct imv_source *src)
if (!handle) {
report_error(src);
- return -1;
+ return NULL;
}
RsvgDimensionData dim;
@@ -104,16 +91,8 @@ static int load_image(struct imv_source *src)
src->width = dim.width;
src->height = dim.height;
- GdkPixbuf *buf = rsvg_handle_get_pixbuf(handle);
- if (!buf) {
- rsvg_handle_close(handle, &error);
- report_error(src);
- return -1;
- }
-
- rsvg_handle_close(handle, &error);
- send_bitmap(src, buf);
- return 0;
+ send_svg(src, handle);
+ return NULL;
}
static enum backend_result open_path(const char *path, struct imv_source **src)