Support RSVG and cairo.
* configure.ac: Allow rsvg with cairo. Move back HAVE_RSVG. * src/dispextern.h (struct image): add cr_data2 if cairo. * src/image.c: #undef COLOR_TABLE_SUPPORT when USE_CAIRO. (x_clear_image): Free cr_data and cr_data2 if set. (xpm_load): Assign data to cr_data2. (svg_load_image): Convert from GdkPixbuf to CAIRO_FORMAT_ARGB32.
This commit is contained in:
parent
74c4ce27b5
commit
69a8655d71
5 changed files with 85 additions and 30 deletions
|
@ -1,3 +1,7 @@
|
|||
2015-04-05 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* configure.ac: Allow rsvg with cairo. Move back HAVE_RSVG.
|
||||
|
||||
2015-04-03 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* configure.ac (HAVE_RSVG): Move after cairo.
|
||||
|
|
46
configure.ac
46
configure.ac
|
@ -2361,6 +2361,28 @@ fail;
|
|||
fi
|
||||
|
||||
|
||||
### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
|
||||
HAVE_RSVG=no
|
||||
if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
|
||||
if test "${with_rsvg}" != "no"; then
|
||||
RSVG_REQUIRED=2.11.0
|
||||
RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
|
||||
|
||||
EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
|
||||
AC_SUBST(RSVG_CFLAGS)
|
||||
AC_SUBST(RSVG_LIBS)
|
||||
|
||||
if test $HAVE_RSVG = yes; then
|
||||
AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
|
||||
CFLAGS="$CFLAGS $RSVG_CFLAGS"
|
||||
# Windows loads librsvg dynamically
|
||||
if test "${opsys}" = "mingw32"; then
|
||||
RSVG_LIBS=
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
HAVE_IMAGEMAGICK=no
|
||||
if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
|
||||
if test "${with_imagemagick}" != "no"; then
|
||||
|
@ -3092,7 +3114,6 @@ if test "${HAVE_X11}" = "yes"; then
|
|||
with_jpeg=no
|
||||
with_gif=no
|
||||
with_tiff=no
|
||||
with_rsvg=no
|
||||
|
||||
CFLAGS="$CFLAGS $CAIRO_CFLAGS"
|
||||
LIBS="$LIBS $CAIRO_LIBS"
|
||||
|
@ -3101,29 +3122,6 @@ if test "${HAVE_X11}" = "yes"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
|
||||
HAVE_RSVG=no
|
||||
if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
|
||||
if test "${with_rsvg}" != "no"; then
|
||||
RSVG_REQUIRED=2.11.0
|
||||
RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
|
||||
|
||||
EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
|
||||
AC_SUBST(RSVG_CFLAGS)
|
||||
AC_SUBST(RSVG_LIBS)
|
||||
|
||||
if test $HAVE_RSVG = yes; then
|
||||
AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
|
||||
CFLAGS="$CFLAGS $RSVG_CFLAGS"
|
||||
# Windows loads librsvg dynamically
|
||||
if test "${opsys}" = "mingw32"; then
|
||||
RSVG_LIBS=
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
### Use -lXpm if available, unless `--with-xpm=no'.
|
||||
### mingw32 doesn't use -lXpm, since it loads the library dynamically.
|
||||
### In the Cygwin-w32 build, we need to use /usr/include/noX/X11/xpm.h
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2015-04-05 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* image.c: #undef COLOR_TABLE_SUPPORT when USE_CAIRO.
|
||||
(x_clear_image): Free cr_data and cr_data2 if set.
|
||||
(xpm_load): Assign data to cr_data2.
|
||||
(svg_load_image): Convert from GdkPixbuf to CAIRO_FORMAT_ARGB32.
|
||||
|
||||
* dispextern.h (struct image): add cr_data2 if cairo.
|
||||
|
||||
2015-04-03 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* image.c (prepare_image_for_display): Don't load if USE_CAIRO.
|
||||
|
|
|
@ -2943,6 +2943,7 @@ struct image
|
|||
|
||||
#ifdef USE_CAIRO
|
||||
void *cr_data;
|
||||
void *cr_data2;
|
||||
#endif
|
||||
#ifdef HAVE_X_WINDOWS
|
||||
/* X images of the image, corresponding to the above Pixmaps.
|
||||
|
|
55
src/image.c
55
src/image.c
|
@ -88,6 +88,10 @@ typedef struct w32_bitmap_record Bitmap_Record;
|
|||
|
||||
#endif /* HAVE_NTGUI */
|
||||
|
||||
#ifdef USE_CAIRO
|
||||
#undef COLOR_TABLE_SUPPORT
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NS
|
||||
#undef COLOR_TABLE_SUPPORT
|
||||
|
||||
|
@ -1303,10 +1307,8 @@ x_clear_image (struct frame *f, struct image *img)
|
|||
block_input ();
|
||||
#ifdef USE_CAIRO
|
||||
if (img->cr_data)
|
||||
{
|
||||
cairo_surface_destroy ((cairo_surface_t *)img->cr_data);
|
||||
if (img->ximg && img->ximg->obdata) xfree (img->ximg->obdata);
|
||||
}
|
||||
cairo_surface_destroy ((cairo_surface_t *)img->cr_data);
|
||||
if (img->cr_data2) xfree (img->cr_data2);
|
||||
#endif
|
||||
x_clear_image_1 (f, img,
|
||||
CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS);
|
||||
|
@ -3670,7 +3672,7 @@ xpm_load (struct frame *f, struct image *img)
|
|||
img->height = cairo_image_surface_get_height (surface);
|
||||
img->cr_data = surface;
|
||||
img->pixmap = 0;
|
||||
img->ximg->obdata = (char *)data;
|
||||
img->cr_data2 = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8993,6 +8995,45 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
|
|||
eassert (gdk_pixbuf_get_has_alpha (pixbuf));
|
||||
eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
|
||||
|
||||
#ifdef USE_CAIRO
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_format_t format = CAIRO_FORMAT_ARGB32;
|
||||
int stride = cairo_format_stride_for_width (format, width);
|
||||
unsigned char *data = (unsigned char *) xmalloc (width*height*4);
|
||||
int y;
|
||||
|
||||
for (y = 0; y < height; ++y)
|
||||
{
|
||||
const guchar *iconptr = pixels + y * rowstride;
|
||||
uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
|
||||
int x;
|
||||
|
||||
for (x = 0; x < width; ++x)
|
||||
{
|
||||
*dataptr = (iconptr[0] << 16)
|
||||
| (iconptr[1] << 8)
|
||||
| iconptr[2]
|
||||
| (iconptr[3] << 24);
|
||||
iconptr += 4;
|
||||
++dataptr;
|
||||
}
|
||||
}
|
||||
|
||||
surface = cairo_image_surface_create_for_data (data,
|
||||
format,
|
||||
width,
|
||||
height,
|
||||
stride);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
img->width = width;
|
||||
img->height = height;
|
||||
img->cr_data = surface;
|
||||
img->cr_data2 = data;
|
||||
img->pixmap = 0;
|
||||
}
|
||||
#else
|
||||
/* Try to create a x pixmap to hold the svg pixmap. */
|
||||
if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
|
||||
{
|
||||
|
@ -9064,6 +9105,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
|
|||
|
||||
/* Put ximg into the image. */
|
||||
image_put_x_image (f, img, ximg, 0);
|
||||
#endif /* ! USE_CAIRO */
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -9331,15 +9373,16 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
|
|||
/* For each pixel of the image, look its color up in the
|
||||
color table. After having done so, the color table will
|
||||
contain an entry for each color used by the image. */
|
||||
#ifdef COLOR_TABLE_SUPPORT
|
||||
for (y = 0; y < img->height; ++y)
|
||||
for (x = 0; x < img->width; ++x)
|
||||
{
|
||||
unsigned long pixel = XGetPixel (ximg, x, y);
|
||||
|
||||
lookup_pixel_color (f, pixel);
|
||||
}
|
||||
|
||||
/* Record colors in the image. Free color table and XImage. */
|
||||
#ifdef COLOR_TABLE_SUPPORT
|
||||
img->colors = colors_in_color_table (&img->ncolors);
|
||||
free_color_table ();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue