From 930744e1652c9ec5ad6447c0a2a1e486cae9a2a9 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Mon, 6 Jun 2022 15:22:23 +0200 Subject: Add flags to the serialization protocol It still needs no versioning, as it's not really used by anyone. An alternative method of passing a "low-quality" flag would be perusing fiv_thumbnail_key_lq from fiv-thumbnail.c, which would create a circular dependency, unless fiv_io_{de,}serialize*() were moved to fiv-thumbnail.c. --- fiv-io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'fiv-io.c') diff --git a/fiv-io.c b/fiv-io.c index b0766b9..916715b 100644 --- a/fiv-io.c +++ b/fiv-io.c @@ -2891,11 +2891,12 @@ fiv_io_open_from_data( // --- Thumbnail passing utilities --------------------------------------------- typedef struct { + guint64 user_data; int width, height, stride, format; } CairoHeader; void -fiv_io_serialize_to_stdout(cairo_surface_t *surface) +fiv_io_serialize_to_stdout(cairo_surface_t *surface, guint64 user_data) { if (!surface || cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE) return; @@ -2907,6 +2908,7 @@ fiv_io_serialize_to_stdout(cairo_surface_t *surface) #endif CairoHeader h = { + .user_data = user_data, .width = cairo_image_surface_get_width(surface), .height = cairo_image_surface_get_height(surface), .stride = cairo_image_surface_get_stride(surface), @@ -2921,7 +2923,7 @@ fiv_io_serialize_to_stdout(cairo_surface_t *surface) } cairo_surface_t * -fiv_io_deserialize(GBytes *bytes) +fiv_io_deserialize(GBytes *bytes, guint64 *user_data) { CairoHeader h = {}; GByteArray *array = g_bytes_unref_to_array(bytes); @@ -2949,6 +2951,7 @@ fiv_io_deserialize(GBytes *bytes) static cairo_user_data_key_t key; cairo_surface_set_user_data( surface, &key, array, (cairo_destroy_func_t) g_byte_array_unref); + *user_data = h.user_data; return surface; } -- cgit v1.2.3-54-g00ecf