aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan D2015-04-05 18:34:07 +0200
committerJan D2015-04-05 18:34:07 +0200
commit69a8655d7190b1dc28de9cbc786a86e8966a45a4 (patch)
tree4ece133f665d2402720cf11bdb198cc3baa34dc0
parent74c4ce27b510b90c29d25c462d9b84b203d00252 (diff)
downloademacs-69a8655d7190b1dc28de9cbc786a86e8966a45a4.tar.gz
emacs-69a8655d7190b1dc28de9cbc786a86e8966a45a4.zip
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.
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac46
-rw-r--r--src/ChangeLog9
-rw-r--r--src/dispextern.h1
-rw-r--r--src/image.c55
5 files changed, 85 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e8cadebb15..b456cc46a54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12015-04-05 Jan Djärv <jan.h.d@swipnet.se>
2
3 * configure.ac: Allow rsvg with cairo. Move back HAVE_RSVG.
4
12015-04-03 Jan Djärv <jan.h.d@swipnet.se> 52015-04-03 Jan Djärv <jan.h.d@swipnet.se>
2 6
3 * configure.ac (HAVE_RSVG): Move after cairo. 7 * configure.ac (HAVE_RSVG): Move after cairo.
diff --git a/configure.ac b/configure.ac
index 9d4e3758fda..79619c74117 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2361,6 +2361,28 @@ fail;
2361fi 2361fi
2362 2362
2363 2363
2364### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
2365HAVE_RSVG=no
2366if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
2367 if test "${with_rsvg}" != "no"; then
2368 RSVG_REQUIRED=2.11.0
2369 RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
2370
2371 EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
2372 AC_SUBST(RSVG_CFLAGS)
2373 AC_SUBST(RSVG_LIBS)
2374
2375 if test $HAVE_RSVG = yes; then
2376 AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
2377 CFLAGS="$CFLAGS $RSVG_CFLAGS"
2378 # Windows loads librsvg dynamically
2379 if test "${opsys}" = "mingw32"; then
2380 RSVG_LIBS=
2381 fi
2382 fi
2383 fi
2384fi
2385
2364HAVE_IMAGEMAGICK=no 2386HAVE_IMAGEMAGICK=no
2365if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then 2387if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
2366 if test "${with_imagemagick}" != "no"; then 2388 if test "${with_imagemagick}" != "no"; then
@@ -3092,7 +3114,6 @@ if test "${HAVE_X11}" = "yes"; then
3092 with_jpeg=no 3114 with_jpeg=no
3093 with_gif=no 3115 with_gif=no
3094 with_tiff=no 3116 with_tiff=no
3095 with_rsvg=no
3096 3117
3097 CFLAGS="$CFLAGS $CAIRO_CFLAGS" 3118 CFLAGS="$CFLAGS $CAIRO_CFLAGS"
3098 LIBS="$LIBS $CAIRO_LIBS" 3119 LIBS="$LIBS $CAIRO_LIBS"
@@ -3101,29 +3122,6 @@ if test "${HAVE_X11}" = "yes"; then
3101 fi 3122 fi
3102fi 3123fi
3103 3124
3104### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
3105HAVE_RSVG=no
3106if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
3107 if test "${with_rsvg}" != "no"; then
3108 RSVG_REQUIRED=2.11.0
3109 RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
3110
3111 EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
3112 AC_SUBST(RSVG_CFLAGS)
3113 AC_SUBST(RSVG_LIBS)
3114
3115 if test $HAVE_RSVG = yes; then
3116 AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
3117 CFLAGS="$CFLAGS $RSVG_CFLAGS"
3118 # Windows loads librsvg dynamically
3119 if test "${opsys}" = "mingw32"; then
3120 RSVG_LIBS=
3121 fi
3122 fi
3123 fi
3124fi
3125
3126
3127### Use -lXpm if available, unless `--with-xpm=no'. 3125### Use -lXpm if available, unless `--with-xpm=no'.
3128### mingw32 doesn't use -lXpm, since it loads the library dynamically. 3126### mingw32 doesn't use -lXpm, since it loads the library dynamically.
3129### In the Cygwin-w32 build, we need to use /usr/include/noX/X11/xpm.h 3127### In the Cygwin-w32 build, we need to use /usr/include/noX/X11/xpm.h
diff --git a/src/ChangeLog b/src/ChangeLog
index 1a473e65386..18e4b343fb7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12015-04-05 Jan Djärv <jan.h.d@swipnet.se>
2
3 * image.c: #undef COLOR_TABLE_SUPPORT when USE_CAIRO.
4 (x_clear_image): Free cr_data and cr_data2 if set.
5 (xpm_load): Assign data to cr_data2.
6 (svg_load_image): Convert from GdkPixbuf to CAIRO_FORMAT_ARGB32.
7
8 * dispextern.h (struct image): add cr_data2 if cairo.
9
12015-04-03 Jan Djärv <jan.h.d@swipnet.se> 102015-04-03 Jan Djärv <jan.h.d@swipnet.se>
2 11
3 * image.c (prepare_image_for_display): Don't load if USE_CAIRO. 12 * image.c (prepare_image_for_display): Don't load if USE_CAIRO.
diff --git a/src/dispextern.h b/src/dispextern.h
index addb43275bc..d9d4d2300fa 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2943,6 +2943,7 @@ struct image
2943 2943
2944#ifdef USE_CAIRO 2944#ifdef USE_CAIRO
2945 void *cr_data; 2945 void *cr_data;
2946 void *cr_data2;
2946#endif 2947#endif
2947#ifdef HAVE_X_WINDOWS 2948#ifdef HAVE_X_WINDOWS
2948 /* X images of the image, corresponding to the above Pixmaps. 2949 /* X images of the image, corresponding to the above Pixmaps.
diff --git a/src/image.c b/src/image.c
index e24bc589ef0..895021c4b41 100644
--- a/src/image.c
+++ b/src/image.c
@@ -88,6 +88,10 @@ typedef struct w32_bitmap_record Bitmap_Record;
88 88
89#endif /* HAVE_NTGUI */ 89#endif /* HAVE_NTGUI */
90 90
91#ifdef USE_CAIRO
92#undef COLOR_TABLE_SUPPORT
93#endif
94
91#ifdef HAVE_NS 95#ifdef HAVE_NS
92#undef COLOR_TABLE_SUPPORT 96#undef COLOR_TABLE_SUPPORT
93 97
@@ -1303,10 +1307,8 @@ x_clear_image (struct frame *f, struct image *img)
1303 block_input (); 1307 block_input ();
1304#ifdef USE_CAIRO 1308#ifdef USE_CAIRO
1305 if (img->cr_data) 1309 if (img->cr_data)
1306 { 1310 cairo_surface_destroy ((cairo_surface_t *)img->cr_data);
1307 cairo_surface_destroy ((cairo_surface_t *)img->cr_data); 1311 if (img->cr_data2) xfree (img->cr_data2);
1308 if (img->ximg && img->ximg->obdata) xfree (img->ximg->obdata);
1309 }
1310#endif 1312#endif
1311 x_clear_image_1 (f, img, 1313 x_clear_image_1 (f, img,
1312 CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS); 1314 CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS);
@@ -3670,7 +3672,7 @@ xpm_load (struct frame *f, struct image *img)
3670 img->height = cairo_image_surface_get_height (surface); 3672 img->height = cairo_image_surface_get_height (surface);
3671 img->cr_data = surface; 3673 img->cr_data = surface;
3672 img->pixmap = 0; 3674 img->pixmap = 0;
3673 img->ximg->obdata = (char *)data; 3675 img->cr_data2 = data;
3674 } 3676 }
3675 else 3677 else
3676 { 3678 {
@@ -8993,6 +8995,45 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8993 eassert (gdk_pixbuf_get_has_alpha (pixbuf)); 8995 eassert (gdk_pixbuf_get_has_alpha (pixbuf));
8994 eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); 8996 eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
8995 8997
8998#ifdef USE_CAIRO
8999 {
9000 cairo_surface_t *surface;
9001 cairo_format_t format = CAIRO_FORMAT_ARGB32;
9002 int stride = cairo_format_stride_for_width (format, width);
9003 unsigned char *data = (unsigned char *) xmalloc (width*height*4);
9004 int y;
9005
9006 for (y = 0; y < height; ++y)
9007 {
9008 const guchar *iconptr = pixels + y * rowstride;
9009 uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
9010 int x;
9011
9012 for (x = 0; x < width; ++x)
9013 {
9014 *dataptr = (iconptr[0] << 16)
9015 | (iconptr[1] << 8)
9016 | iconptr[2]
9017 | (iconptr[3] << 24);
9018 iconptr += 4;
9019 ++dataptr;
9020 }
9021 }
9022
9023 surface = cairo_image_surface_create_for_data (data,
9024 format,
9025 width,
9026 height,
9027 stride);
9028
9029 g_object_unref (pixbuf);
9030 img->width = width;
9031 img->height = height;
9032 img->cr_data = surface;
9033 img->cr_data2 = data;
9034 img->pixmap = 0;
9035 }
9036#else
8996 /* Try to create a x pixmap to hold the svg pixmap. */ 9037 /* Try to create a x pixmap to hold the svg pixmap. */
8997 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 9038 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
8998 { 9039 {
@@ -9064,6 +9105,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9064 9105
9065 /* Put ximg into the image. */ 9106 /* Put ximg into the image. */
9066 image_put_x_image (f, img, ximg, 0); 9107 image_put_x_image (f, img, ximg, 0);
9108#endif /* ! USE_CAIRO */
9067 9109
9068 return 1; 9110 return 1;
9069 9111
@@ -9331,15 +9373,16 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9331 /* For each pixel of the image, look its color up in the 9373 /* For each pixel of the image, look its color up in the
9332 color table. After having done so, the color table will 9374 color table. After having done so, the color table will
9333 contain an entry for each color used by the image. */ 9375 contain an entry for each color used by the image. */
9376#ifdef COLOR_TABLE_SUPPORT
9334 for (y = 0; y < img->height; ++y) 9377 for (y = 0; y < img->height; ++y)
9335 for (x = 0; x < img->width; ++x) 9378 for (x = 0; x < img->width; ++x)
9336 { 9379 {
9337 unsigned long pixel = XGetPixel (ximg, x, y); 9380 unsigned long pixel = XGetPixel (ximg, x, y);
9381
9338 lookup_pixel_color (f, pixel); 9382 lookup_pixel_color (f, pixel);
9339 } 9383 }
9340 9384
9341 /* Record colors in the image. Free color table and XImage. */ 9385 /* Record colors in the image. Free color table and XImage. */
9342#ifdef COLOR_TABLE_SUPPORT
9343 img->colors = colors_in_color_table (&img->ncolors); 9386 img->colors = colors_in_color_table (&img->ncolors);
9344 free_color_table (); 9387 free_color_table ();
9345#endif 9388#endif