aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorJoakim Verona2015-01-11 18:40:21 +0100
committerJoakim Verona2015-01-11 18:40:21 +0100
commitcc7cb20d6abc0f862e5513b24831bba0eaecaa5f (patch)
treeafc2fc05401504aa0c28699dc3bc155c5b0d7f58 /src/image.c
parentd972b504f30ff4300ba368940751e8736dddf0b4 (diff)
parent9a57bda31569294ecaf8138a06e5edda9c0d87e3 (diff)
downloademacs-cc7cb20d6abc0f862e5513b24831bba0eaecaa5f.tar.gz
emacs-cc7cb20d6abc0f862e5513b24831bba0eaecaa5f.zip
merge master, fix conflicts
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c109
1 files changed, 26 insertions, 83 deletions
diff --git a/src/image.c b/src/image.c
index 6240c64b201..5d08a890234 100644
--- a/src/image.c
+++ b/src/image.c
@@ -86,12 +86,6 @@ typedef struct w32_bitmap_record Bitmap_Record;
86#define x_defined_color w32_defined_color 86#define x_defined_color w32_defined_color
87#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits) 87#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
88 88
89/* Versions of libpng, libgif, and libjpeg that we were compiled with,
90 or -1 if no PNG/GIF support was compiled in. This is tested by
91 w32-win.el to correctly set up the alist used to search for the
92 respective image libraries. */
93Lisp_Object Qlibpng_version, Qlibgif_version, Qlibjpeg_version;
94
95#endif /* HAVE_NTGUI */ 89#endif /* HAVE_NTGUI */
96 90
97#ifdef HAVE_NS 91#ifdef HAVE_NS
@@ -110,11 +104,6 @@ typedef struct ns_bitmap_record Bitmap_Record;
110#define DefaultDepthOfScreen(screen) x_display_list->n_planes 104#define DefaultDepthOfScreen(screen) x_display_list->n_planes
111#endif /* HAVE_NS */ 105#endif /* HAVE_NS */
112 106
113
114/* The symbol `postscript' identifying images of this type. */
115
116static Lisp_Object Qpostscript;
117
118static void x_disable_image (struct frame *, struct image *); 107static void x_disable_image (struct frame *, struct image *);
119static void x_edge_detection (struct frame *, struct image *, Lisp_Object, 108static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
120 Lisp_Object); 109 Lisp_Object);
@@ -126,8 +115,6 @@ static void free_color_table (void);
126static unsigned long *colors_in_color_table (int *n); 115static unsigned long *colors_in_color_table (int *n);
127#endif 116#endif
128 117
129static Lisp_Object QCmax_width, QCmax_height;
130
131/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap 118/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
132 id, which is just an int that this section returns. Bitmaps are 119 id, which is just an int that this section returns. Bitmaps are
133 reference counted so they can be shared among frames. 120 reference counted so they can be shared among frames.
@@ -537,24 +524,6 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
537 524
538static struct image_type *image_types; 525static struct image_type *image_types;
539 526
540/* The symbol `xbm' which is used as the type symbol for XBM images. */
541
542static Lisp_Object Qxbm;
543
544/* Keywords. */
545
546Lisp_Object QCascent, QCmargin, QCrelief;
547Lisp_Object QCconversion;
548static Lisp_Object QCheuristic_mask;
549static Lisp_Object QCcolor_symbols;
550static Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry;
551static Lisp_Object QCcrop, QCrotation;
552
553/* Other symbols. */
554
555static Lisp_Object Qcount, Qextension_data, Qdelay;
556static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
557
558/* Forward function prototypes. */ 527/* Forward function prototypes. */
559 528
560static struct image_type *lookup_image_type (Lisp_Object); 529static struct image_type *lookup_image_type (Lisp_Object);
@@ -579,27 +548,29 @@ static struct image_type *
579define_image_type (struct image_type *type) 548define_image_type (struct image_type *type)
580{ 549{
581 struct image_type *p = NULL; 550 struct image_type *p = NULL;
582 Lisp_Object target_type = *type->type; 551 int new_type = type->type;
583 bool type_valid = 1; 552 bool type_valid = true;
584 553
585 block_input (); 554 block_input ();
586 555
587 for (p = image_types; p; p = p->next) 556 for (p = image_types; p; p = p->next)
588 if (EQ (*p->type, target_type)) 557 if (p->type == new_type)
589 goto done; 558 goto done;
590 559
591 if (type->init) 560 if (type->init)
592 { 561 {
593#if defined HAVE_NTGUI && defined WINDOWSNT 562#if defined HAVE_NTGUI && defined WINDOWSNT
594 /* If we failed to load the library before, don't try again. */ 563 /* If we failed to load the library before, don't try again. */
595 Lisp_Object tested = Fassq (target_type, Vlibrary_cache); 564 Lisp_Object tested = Fassq (builtin_lisp_symbol (new_type),
565 Vlibrary_cache);
596 if (CONSP (tested) && NILP (XCDR (tested))) 566 if (CONSP (tested) && NILP (XCDR (tested)))
597 type_valid = 0; 567 type_valid = false;
598 else 568 else
599#endif 569#endif
600 { 570 {
601 type_valid = type->init (); 571 type_valid = type->init ();
602 CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil); 572 CACHE_IMAGE_TYPE (builtin_lisp_symbol (new_type),
573 type_valid ? Qt : Qnil);
603 } 574 }
604 } 575 }
605 576
@@ -1777,7 +1748,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
1777 1748
1778 /* Do image transformations and compute masks, unless we 1749 /* Do image transformations and compute masks, unless we
1779 don't have the image yet. */ 1750 don't have the image yet. */
1780 if (!EQ (*img->type->type, Qpostscript)) 1751 if (!EQ (builtin_lisp_symbol (img->type->type), Qpostscript))
1781 postprocess_image (f, img); 1752 postprocess_image (f, img);
1782 } 1753 }
1783 1754
@@ -2362,7 +2333,7 @@ static const struct image_keyword xbm_format[XBM_LAST] =
2362 2333
2363static struct image_type xbm_type = 2334static struct image_type xbm_type =
2364{ 2335{
2365 &Qxbm, 2336 SYMBOL_INDEX (Qxbm),
2366 xbm_image_p, 2337 xbm_image_p,
2367 xbm_load, 2338 xbm_load,
2368 x_clear_image, 2339 x_clear_image,
@@ -3121,9 +3092,6 @@ static bool xpm_load (struct frame *f, struct image *img);
3121#endif /* HAVE_XPM */ 3092#endif /* HAVE_XPM */
3122 3093
3123#if defined (HAVE_XPM) || defined (HAVE_NS) 3094#if defined (HAVE_XPM) || defined (HAVE_NS)
3124/* The symbol `xpm' identifying XPM-format images. */
3125
3126static Lisp_Object Qxpm;
3127 3095
3128/* Indices of image specification fields in xpm_format, below. */ 3096/* Indices of image specification fields in xpm_format, below. */
3129 3097
@@ -3171,7 +3139,7 @@ static bool init_xpm_functions (void);
3171 3139
3172static struct image_type xpm_type = 3140static struct image_type xpm_type =
3173{ 3141{
3174 &Qxpm, 3142 SYMBOL_INDEX (Qxpm),
3175 xpm_image_p, 3143 xpm_image_p,
3176 xpm_load, 3144 xpm_load,
3177 x_clear_image, 3145 x_clear_image,
@@ -5059,10 +5027,6 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
5059static bool pbm_image_p (Lisp_Object object); 5027static bool pbm_image_p (Lisp_Object object);
5060static bool pbm_load (struct frame *f, struct image *img); 5028static bool pbm_load (struct frame *f, struct image *img);
5061 5029
5062/* The symbol `pbm' identifying images of this type. */
5063
5064static Lisp_Object Qpbm;
5065
5066/* Indices of image specification fields in gs_format, below. */ 5030/* Indices of image specification fields in gs_format, below. */
5067 5031
5068enum pbm_keyword_index 5032enum pbm_keyword_index
@@ -5103,7 +5067,7 @@ static const struct image_keyword pbm_format[PBM_LAST] =
5103 5067
5104static struct image_type pbm_type = 5068static struct image_type pbm_type =
5105{ 5069{
5106 &Qpbm, 5070 SYMBOL_INDEX (Qpbm),
5107 pbm_image_p, 5071 pbm_image_p,
5108 pbm_load, 5072 pbm_load,
5109 x_clear_image, 5073 x_clear_image,
@@ -5446,10 +5410,6 @@ pbm_load (struct frame *f, struct image *img)
5446static bool png_image_p (Lisp_Object object); 5410static bool png_image_p (Lisp_Object object);
5447static bool png_load (struct frame *f, struct image *img); 5411static bool png_load (struct frame *f, struct image *img);
5448 5412
5449/* The symbol `png' identifying images of this type. */
5450
5451static Lisp_Object Qpng;
5452
5453/* Indices of image specification fields in png_format, below. */ 5413/* Indices of image specification fields in png_format, below. */
5454 5414
5455enum png_keyword_index 5415enum png_keyword_index
@@ -5494,7 +5454,7 @@ static bool init_png_functions (void);
5494 5454
5495static struct image_type png_type = 5455static struct image_type png_type =
5496{ 5456{
5497 &Qpng, 5457 SYMBOL_INDEX (Qpng),
5498 png_image_p, 5458 png_image_p,
5499 png_load, 5459 png_load,
5500 x_clear_image, 5460 x_clear_image,
@@ -6102,10 +6062,6 @@ png_load (struct frame *f, struct image *img)
6102static bool jpeg_image_p (Lisp_Object object); 6062static bool jpeg_image_p (Lisp_Object object);
6103static bool jpeg_load (struct frame *f, struct image *img); 6063static bool jpeg_load (struct frame *f, struct image *img);
6104 6064
6105/* The symbol `jpeg' identifying images of this type. */
6106
6107static Lisp_Object Qjpeg;
6108
6109/* Indices of image specification fields in gs_format, below. */ 6065/* Indices of image specification fields in gs_format, below. */
6110 6066
6111enum jpeg_keyword_index 6067enum jpeg_keyword_index
@@ -6150,7 +6106,7 @@ static bool init_jpeg_functions (void);
6150 6106
6151static struct image_type jpeg_type = 6107static struct image_type jpeg_type =
6152{ 6108{
6153 &Qjpeg, 6109 SYMBOL_INDEX (Qjpeg),
6154 jpeg_image_p, 6110 jpeg_image_p,
6155 jpeg_load, 6111 jpeg_load,
6156 x_clear_image, 6112 x_clear_image,
@@ -6704,10 +6660,6 @@ jpeg_load (struct frame *f, struct image *img)
6704static bool tiff_image_p (Lisp_Object object); 6660static bool tiff_image_p (Lisp_Object object);
6705static bool tiff_load (struct frame *f, struct image *img); 6661static bool tiff_load (struct frame *f, struct image *img);
6706 6662
6707/* The symbol `tiff' identifying images of this type. */
6708
6709static Lisp_Object Qtiff;
6710
6711/* Indices of image specification fields in tiff_format, below. */ 6663/* Indices of image specification fields in tiff_format, below. */
6712 6664
6713enum tiff_keyword_index 6665enum tiff_keyword_index
@@ -6754,7 +6706,7 @@ static bool init_tiff_functions (void);
6754 6706
6755static struct image_type tiff_type = 6707static struct image_type tiff_type =
6756{ 6708{
6757 &Qtiff, 6709 SYMBOL_INDEX (Qtiff),
6758 tiff_image_p, 6710 tiff_image_p,
6759 tiff_load, 6711 tiff_load,
6760 x_clear_image, 6712 x_clear_image,
@@ -7167,10 +7119,6 @@ static bool gif_image_p (Lisp_Object object);
7167static bool gif_load (struct frame *f, struct image *img); 7119static bool gif_load (struct frame *f, struct image *img);
7168static void gif_clear_image (struct frame *f, struct image *img); 7120static void gif_clear_image (struct frame *f, struct image *img);
7169 7121
7170/* The symbol `gif' identifying images of this type. */
7171
7172static Lisp_Object Qgif;
7173
7174/* Indices of image specification fields in gif_format, below. */ 7122/* Indices of image specification fields in gif_format, below. */
7175 7123
7176enum gif_keyword_index 7124enum gif_keyword_index
@@ -7217,7 +7165,7 @@ static bool init_gif_functions (void);
7217 7165
7218static struct image_type gif_type = 7166static struct image_type gif_type =
7219{ 7167{
7220 &Qgif, 7168 SYMBOL_INDEX (Qgif),
7221 gif_image_p, 7169 gif_image_p,
7222 gif_load, 7170 gif_load,
7223 gif_clear_image, 7171 gif_clear_image,
@@ -7841,8 +7789,6 @@ compute_image_size (size_t width, size_t height,
7841 *d_height = desired_height; 7789 *d_height = desired_height;
7842} 7790}
7843 7791
7844static Lisp_Object Qimagemagick;
7845
7846static bool imagemagick_image_p (Lisp_Object); 7792static bool imagemagick_image_p (Lisp_Object);
7847static bool imagemagick_load (struct frame *, struct image *); 7793static bool imagemagick_load (struct frame *, struct image *);
7848static void imagemagick_clear_image (struct frame *, struct image *); 7794static void imagemagick_clear_image (struct frame *, struct image *);
@@ -7906,7 +7852,7 @@ static bool init_imagemagick_functions (void);
7906 7852
7907static struct image_type imagemagick_type = 7853static struct image_type imagemagick_type =
7908 { 7854 {
7909 &Qimagemagick, 7855 SYMBOL_INDEX (Qimagemagick),
7910 imagemagick_image_p, 7856 imagemagick_image_p,
7911 imagemagick_load, 7857 imagemagick_load,
7912 imagemagick_clear_image, 7858 imagemagick_clear_image,
@@ -8632,10 +8578,6 @@ static bool svg_load (struct frame *f, struct image *img);
8632static bool svg_load_image (struct frame *, struct image *, 8578static bool svg_load_image (struct frame *, struct image *,
8633 unsigned char *, ptrdiff_t, char *); 8579 unsigned char *, ptrdiff_t, char *);
8634 8580
8635/* The symbol `svg' identifying images of this type. */
8636
8637static Lisp_Object Qsvg;
8638
8639/* Indices of image specification fields in svg_format, below. */ 8581/* Indices of image specification fields in svg_format, below. */
8640 8582
8641enum svg_keyword_index 8583enum svg_keyword_index
@@ -8682,7 +8624,7 @@ static bool init_svg_functions (void);
8682 8624
8683static struct image_type svg_type = 8625static struct image_type svg_type =
8684{ 8626{
8685 &Qsvg, 8627 SYMBOL_INDEX (Qsvg),
8686 svg_image_p, 8628 svg_image_p,
8687 svg_load, 8629 svg_load,
8688 x_clear_image, 8630 x_clear_image,
@@ -8737,8 +8679,6 @@ DEF_DLL_FN (void, g_type_init, (void));
8737DEF_DLL_FN (void, g_object_unref, (gpointer)); 8679DEF_DLL_FN (void, g_object_unref, (gpointer));
8738DEF_DLL_FN (void, g_error_free, (GError *)); 8680DEF_DLL_FN (void, g_error_free, (GError *));
8739 8681
8740Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
8741
8742static bool 8682static bool
8743init_svg_functions (void) 8683init_svg_functions (void)
8744{ 8684{
@@ -9056,10 +8996,6 @@ static bool gs_image_p (Lisp_Object object);
9056static bool gs_load (struct frame *f, struct image *img); 8996static bool gs_load (struct frame *f, struct image *img);
9057static void gs_clear_image (struct frame *f, struct image *img); 8997static void gs_clear_image (struct frame *f, struct image *img);
9058 8998
9059/* Keyword symbols. */
9060
9061static Lisp_Object QCloader, QCbounding_box, QCpt_width, QCpt_height;
9062
9063/* Indices of image specification fields in gs_format, below. */ 8999/* Indices of image specification fields in gs_format, below. */
9064 9000
9065enum gs_keyword_index 9001enum gs_keyword_index
@@ -9104,7 +9040,7 @@ static const struct image_keyword gs_format[GS_LAST] =
9104 9040
9105static struct image_type gs_type = 9041static struct image_type gs_type =
9106{ 9042{
9107 &Qpostscript, 9043 SYMBOL_INDEX (Qpostscript),
9108 gs_image_p, 9044 gs_image_p,
9109 gs_load, 9045 gs_load,
9110 gs_clear_image, 9046 gs_clear_image,
@@ -9479,10 +9415,12 @@ as a ratio to the frame height and width. If the value is
9479non-numeric, there is no explicit limit on the size of images. */); 9415non-numeric, there is no explicit limit on the size of images. */);
9480 Vmax_image_size = make_float (MAX_IMAGE_SIZE); 9416 Vmax_image_size = make_float (MAX_IMAGE_SIZE);
9481 9417
9418 /* Other symbols. */
9482 DEFSYM (Qcount, "count"); 9419 DEFSYM (Qcount, "count");
9483 DEFSYM (Qextension_data, "extension-data"); 9420 DEFSYM (Qextension_data, "extension-data");
9484 DEFSYM (Qdelay, "delay"); 9421 DEFSYM (Qdelay, "delay");
9485 9422
9423 /* Keywords. */
9486 DEFSYM (QCascent, ":ascent"); 9424 DEFSYM (QCascent, ":ascent");
9487 DEFSYM (QCmargin, ":margin"); 9425 DEFSYM (QCmargin, ":margin");
9488 DEFSYM (QCrelief, ":relief"); 9426 DEFSYM (QCrelief, ":relief");
@@ -9497,6 +9435,7 @@ non-numeric, there is no explicit limit on the size of images. */);
9497 DEFSYM (QCcolor_adjustment, ":color-adjustment"); 9435 DEFSYM (QCcolor_adjustment, ":color-adjustment");
9498 DEFSYM (QCmask, ":mask"); 9436 DEFSYM (QCmask, ":mask");
9499 9437
9438 /* Other symbols. */
9500 DEFSYM (Qlaplace, "laplace"); 9439 DEFSYM (Qlaplace, "laplace");
9501 DEFSYM (Qemboss, "emboss"); 9440 DEFSYM (Qemboss, "emboss");
9502 DEFSYM (Qedge_detection, "edge-detection"); 9441 DEFSYM (Qedge_detection, "edge-detection");
@@ -9514,6 +9453,10 @@ non-numeric, there is no explicit limit on the size of images. */);
9514#endif /* HAVE_GHOSTSCRIPT */ 9453#endif /* HAVE_GHOSTSCRIPT */
9515 9454
9516#ifdef HAVE_NTGUI 9455#ifdef HAVE_NTGUI
9456 /* Versions of libpng, libgif, and libjpeg that we were compiled with,
9457 or -1 if no PNG/GIF support was compiled in. This is tested by
9458 w32-win.el to correctly set up the alist used to search for the
9459 respective image libraries. */
9517 DEFSYM (Qlibpng_version, "libpng-version"); 9460 DEFSYM (Qlibpng_version, "libpng-version");
9518 Fset (Qlibpng_version, 9461 Fset (Qlibpng_version,
9519#if HAVE_PNG 9462#if HAVE_PNG