Commit 626aeac6 authored by John Ellson's avatar John Ellson

make previous change condition because cairo on centos6 is too old

parent 53c4994d
Pipeline #37933190 passed with stages
in 24 minutes and 4 seconds
......@@ -52,6 +52,7 @@ reader (void *closure, unsigned char *data, unsigned int length)
}
#endif
#ifdef HAVE_CAIRO_SURFACE_SET_MIME_DATA
static void gdk_set_mimedata_from_file (cairo_surface_t *image, const char *mime_type, const char *file)
{
FILE *fp;
......@@ -78,16 +79,11 @@ static void gdk_set_mimedata_from_file (cairo_surface_t *image, const char *mime
fclose(fp);
if (data) {
cairo_surface_set_mime_data (image, mime_type, data, (unsigned long)len, free, data);
unique_id_len = strlen(id_prefix) + strlen(file) + 1;
unique_id = malloc (unique_id_len);
snprintf (unique_id, unique_id_len, "%s%s", id_prefix, file);
#if 0
cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_UNIQUE_ID, (unsigned char *)unique_id, unique_id_len, free, unique_id);
cairo_surface_set_mime_data (image, mime_type, data, (unsigned long)len, free, data);
#else
free(unique_id);
free(data);
#endif
}
}
......@@ -105,34 +101,62 @@ static void gdk_set_mimedata(cairo_surface_t *image, usershape_t *us)
}
}
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
static void gdk_freeimage(usershape_t *us)
{
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
g_object_unref((GdkPixbuf*)(us->data));
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
cairo_surface_destroy ((cairo_surface_t *)(us->data));
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
}
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
static GdkPixbuf* gdk_loadimage(GVJ_t * job, usershape_t *us)
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
static cairo_surface_t* gdk_loadimage(GVJ_t * job, usershape_t *us)
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
{
#ifdef HAVE_CAIRO_SURFACE_SET_MIME_DATA
cairo_t *cr = (cairo_t *) job->context; /* target context */
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
GdkPixbuf *image = NULL;
#ifdef HAVE_CAIRO_SURFACE_SET_MIME_DATA
cairo_surface_t *cairo_image = NULL;
cairo_pattern_t *pattern;
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
assert(job);
assert(us);
assert(us->name);
if (us->data) {
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
if (us->datafree == gdk_freeimage)
image = (GdkPixbuf*)(us->data); /* use cached data */
else {
us->datafree(us); /* free incompatible cache data */
us->datafree = NULL;
us->data = NULL;
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
if (us->datafree == gdk_freeimage) {
cairo_image = cairo_surface_reference ((cairo_surface_t *)(us->data)); /* use cached data */
} else {
us->datafree(us); /* free incompatible cache data */
us->datafree = NULL;
us->data = NULL;
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
}
}
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
if (!image) { /* read file into cache */
if (!gvusershape_file_access(us))
return NULL;
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
if (!cairo_image) { /* read file into cache */
if (!gvusershape_file_access(us))
return NULL;
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
switch (us->type) {
case FT_PNG:
case FT_JPEG:
......@@ -145,8 +169,13 @@ static cairo_surface_t* gdk_loadimage(GVJ_t * job, usershape_t *us)
default:
image = NULL;
}
#ifdef HAVE_CAIRO_SURFACE_SET_MIME_DATA
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
if (image) {
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
us->data = (void*)image;
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
cairo_save (cr);
gdk_cairo_set_source_pixbuf (cr, image, 0, 0);
pattern = cairo_get_source (cr);
......@@ -156,27 +185,46 @@ static cairo_surface_t* gdk_loadimage(GVJ_t * job, usershape_t *us)
cairo_restore (cr);
gdk_set_mimedata (cairo_image, us);
us->data = (void*)cairo_surface_reference (cairo_image);
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
us->datafree = gdk_freeimage;
}
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
gvusershape_file_release(us);
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
gvusershape_file_release(us);
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
}
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
return image;
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
return cairo_image;
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
}
static void gdk_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
cairo_t *cr = (cairo_t *) job->context; /* target context */
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
GdkPixbuf *image;
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
cairo_surface_t *image;
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
image = gdk_loadimage(job, us);
if (image) {
cairo_save(cr);
cairo_translate(cr, b.LL.x, -b.UR.y);
cairo_scale(cr, (b.UR.x - b.LL.x)/(us->w), (b.UR.y - b.LL.y)/(us->h));
#ifndef HAVE_CAIRO_SURFACE_SET_MIME_DATA
gdk_cairo_set_source_pixbuf (cr, image, 0, 0);
#else /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
cairo_set_source_surface (cr, image, 0, 0);
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
cairo_paint (cr);
cairo_restore(cr);
#ifdef HAVE_CAIRO_SURFACE_SET_MIME_DATA
cairo_surface_destroy (image);
#endif /* HAVE_CAIRO_SURFACE_SET_MIME_DATA */
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment