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.
This commit is contained in:
parent
4ca8825e02
commit
930744e165
7
fiv-io.c
7
fiv-io.c
|
@ -2891,11 +2891,12 @@ fiv_io_open_from_data(
|
||||||
// --- Thumbnail passing utilities ---------------------------------------------
|
// --- Thumbnail passing utilities ---------------------------------------------
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
guint64 user_data;
|
||||||
int width, height, stride, format;
|
int width, height, stride, format;
|
||||||
} CairoHeader;
|
} CairoHeader;
|
||||||
|
|
||||||
void
|
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)
|
if (!surface || cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE)
|
||||||
return;
|
return;
|
||||||
|
@ -2907,6 +2908,7 @@ fiv_io_serialize_to_stdout(cairo_surface_t *surface)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CairoHeader h = {
|
CairoHeader h = {
|
||||||
|
.user_data = user_data,
|
||||||
.width = cairo_image_surface_get_width(surface),
|
.width = cairo_image_surface_get_width(surface),
|
||||||
.height = cairo_image_surface_get_height(surface),
|
.height = cairo_image_surface_get_height(surface),
|
||||||
.stride = cairo_image_surface_get_stride(surface),
|
.stride = cairo_image_surface_get_stride(surface),
|
||||||
|
@ -2921,7 +2923,7 @@ fiv_io_serialize_to_stdout(cairo_surface_t *surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
fiv_io_deserialize(GBytes *bytes)
|
fiv_io_deserialize(GBytes *bytes, guint64 *user_data)
|
||||||
{
|
{
|
||||||
CairoHeader h = {};
|
CairoHeader h = {};
|
||||||
GByteArray *array = g_bytes_unref_to_array(bytes);
|
GByteArray *array = g_bytes_unref_to_array(bytes);
|
||||||
|
@ -2949,6 +2951,7 @@ fiv_io_deserialize(GBytes *bytes)
|
||||||
static cairo_user_data_key_t key;
|
static cairo_user_data_key_t key;
|
||||||
cairo_surface_set_user_data(
|
cairo_surface_set_user_data(
|
||||||
surface, &key, array, (cairo_destroy_func_t) g_byte_array_unref);
|
surface, &key, array, (cairo_destroy_func_t) g_byte_array_unref);
|
||||||
|
*user_data = h.user_data;
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
fiv-io.h
6
fiv-io.h
|
@ -102,8 +102,10 @@ cairo_surface_t *fiv_io_open_png_thumbnail(const char *path, GError **error);
|
||||||
|
|
||||||
// --- Thumbnail passing utilities ---------------------------------------------
|
// --- Thumbnail passing utilities ---------------------------------------------
|
||||||
|
|
||||||
void fiv_io_serialize_to_stdout(cairo_surface_t *surface);
|
enum { FIV_IO_SERIALIZE_LOW_QUALITY = 1 << 0 };
|
||||||
cairo_surface_t *fiv_io_deserialize(GBytes *bytes);
|
|
||||||
|
void fiv_io_serialize_to_stdout(cairo_surface_t *surface, guint64 user_data);
|
||||||
|
cairo_surface_t *fiv_io_deserialize(GBytes *bytes, guint64 *user_data);
|
||||||
|
|
||||||
// --- Filesystem --------------------------------------------------------------
|
// --- Filesystem --------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,10 @@ typedef struct _FivThumbnailSizeInfo {
|
||||||
const char *thumbnail_spec_name; ///< thumbnail-spec directory name
|
const char *thumbnail_spec_name; ///< thumbnail-spec directory name
|
||||||
} FivThumbnailSizeInfo;
|
} FivThumbnailSizeInfo;
|
||||||
|
|
||||||
extern FivThumbnailSizeInfo fiv_thumbnail_sizes[FIV_THUMBNAIL_SIZE_COUNT];
|
|
||||||
|
|
||||||
enum { FIV_THUMBNAIL_WIDE_COEFFICIENT = 2 };
|
enum { FIV_THUMBNAIL_WIDE_COEFFICIENT = 2 };
|
||||||
|
|
||||||
|
extern FivThumbnailSizeInfo fiv_thumbnail_sizes[FIV_THUMBNAIL_SIZE_COUNT];
|
||||||
|
|
||||||
/// If non-NULL, indicates a thumbnail of insufficient quality.
|
/// If non-NULL, indicates a thumbnail of insufficient quality.
|
||||||
extern cairo_user_data_key_t fiv_thumbnail_key_lq;
|
extern cairo_user_data_key_t fiv_thumbnail_key_lq;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue