diff options
| author | Jan D | 2015-04-05 18:34:07 +0200 |
|---|---|---|
| committer | Jan D | 2015-04-05 18:34:07 +0200 |
| commit | 69a8655d7190b1dc28de9cbc786a86e8966a45a4 (patch) | |
| tree | 4ece133f665d2402720cf11bdb198cc3baa34dc0 /src | |
| parent | 74c4ce27b510b90c29d25c462d9b84b203d00252 (diff) | |
| download | emacs-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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/dispextern.h | 1 | ||||
| -rw-r--r-- | src/image.c | 55 |
3 files changed, 59 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1a473e65386..18e4b343fb7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2015-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 | |||
| 1 | 2015-04-03 Jan Djärv <jan.h.d@swipnet.se> | 10 | 2015-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 |