diff options
| author | Joakim Verona | 2010-08-17 23:19:11 +0200 |
|---|---|---|
| committer | Joakim Verona | 2010-08-17 23:19:11 +0200 |
| commit | a8101f663e6cbff953b67b8bef33bc0171818477 (patch) | |
| tree | 8f71a16188f75e91670e05379fb4de2d0136cbf4 /src/image.c | |
| parent | fe72c5b4651334677326104ec138e7cdd50f2ffe (diff) | |
| parent | 489cd5bd5a0128d6c3bee49fa2c451f2927ddea9 (diff) | |
| download | emacs-a8101f663e6cbff953b67b8bef33bc0171818477.tar.gz emacs-a8101f663e6cbff953b67b8bef33bc0171818477.zip | |
merge from trunk
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 1007 |
1 files changed, 379 insertions, 628 deletions
diff --git a/src/image.c b/src/image.c index 372f17348e9..e39c46b392a 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -126,17 +126,20 @@ typedef struct ns_bitmap_record Bitmap_Record; | |||
| 126 | 126 | ||
| 127 | Lisp_Object Vx_bitmap_file_path; | 127 | Lisp_Object Vx_bitmap_file_path; |
| 128 | 128 | ||
| 129 | /* The symbol `postscript' identifying images of this type. */ | ||
| 130 | |||
| 131 | Lisp_Object Qpostscript; | ||
| 129 | 132 | ||
| 130 | static void x_disable_image P_ ((struct frame *, struct image *)); | 133 | static void x_disable_image (struct frame *, struct image *); |
| 131 | static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object, | 134 | static void x_edge_detection (struct frame *, struct image *, Lisp_Object, |
| 132 | Lisp_Object)); | 135 | Lisp_Object); |
| 133 | 136 | ||
| 134 | static void init_color_table P_ ((void)); | 137 | static void init_color_table (void); |
| 135 | static unsigned long lookup_rgb_color P_ ((struct frame *f, int r, int g, int b)); | 138 | static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b); |
| 136 | #ifdef COLOR_TABLE_SUPPORT | 139 | #ifdef COLOR_TABLE_SUPPORT |
| 137 | static void free_color_table P_ ((void)); | 140 | static void free_color_table (void); |
| 138 | static unsigned long *colors_in_color_table P_ ((int *n)); | 141 | static unsigned long *colors_in_color_table (int *n); |
| 139 | static unsigned long lookup_pixel_color P_ ((struct frame *f, unsigned long p)); | 142 | static unsigned long lookup_pixel_color (struct frame *f, unsigned long p); |
| 140 | #endif | 143 | #endif |
| 141 | 144 | ||
| 142 | /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap | 145 | /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap |
| @@ -157,7 +160,7 @@ XGetImage (Display *display, Pixmap pixmap, int x, int y, | |||
| 157 | unsigned long plane_mask, int format) | 160 | unsigned long plane_mask, int format) |
| 158 | { | 161 | { |
| 159 | /* TODO: not sure what this function is supposed to do.. */ | 162 | /* TODO: not sure what this function is supposed to do.. */ |
| 160 | ns_retain_object(pixmap); | 163 | ns_retain_object (pixmap); |
| 161 | return pixmap; | 164 | return pixmap; |
| 162 | } | 165 | } |
| 163 | 166 | ||
| @@ -165,7 +168,7 @@ XGetImage (Display *display, Pixmap pixmap, int x, int y, | |||
| 165 | unsigned long | 168 | unsigned long |
| 166 | XGetPixel (XImagePtr ximage, int x, int y) | 169 | XGetPixel (XImagePtr ximage, int x, int y) |
| 167 | { | 170 | { |
| 168 | return ns_get_pixel(ximage, x, y); | 171 | return ns_get_pixel (ximage, x, y); |
| 169 | } | 172 | } |
| 170 | 173 | ||
| 171 | /* use with imgs created by ns_image_for_XPM; alpha set to 1; | 174 | /* use with imgs created by ns_image_for_XPM; alpha set to 1; |
| @@ -173,7 +176,7 @@ XGetPixel (XImagePtr ximage, int x, int y) | |||
| 173 | void | 176 | void |
| 174 | XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) | 177 | XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) |
| 175 | { | 178 | { |
| 176 | ns_put_pixel(ximage, x, y, pixel); | 179 | ns_put_pixel (ximage, x, y, pixel); |
| 177 | } | 180 | } |
| 178 | #endif /* HAVE_NS */ | 181 | #endif /* HAVE_NS */ |
| 179 | 182 | ||
| @@ -181,26 +184,20 @@ XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) | |||
| 181 | /* Functions to access the contents of a bitmap, given an id. */ | 184 | /* Functions to access the contents of a bitmap, given an id. */ |
| 182 | 185 | ||
| 183 | int | 186 | int |
| 184 | x_bitmap_height (f, id) | 187 | x_bitmap_height (FRAME_PTR f, int id) |
| 185 | FRAME_PTR f; | ||
| 186 | int id; | ||
| 187 | { | 188 | { |
| 188 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; | 189 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 191 | int | 192 | int |
| 192 | x_bitmap_width (f, id) | 193 | x_bitmap_width (FRAME_PTR f, int id) |
| 193 | FRAME_PTR f; | ||
| 194 | int id; | ||
| 195 | { | 194 | { |
| 196 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; | 195 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; |
| 197 | } | 196 | } |
| 198 | 197 | ||
| 199 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) | 198 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) |
| 200 | int | 199 | int |
| 201 | x_bitmap_pixmap (f, id) | 200 | x_bitmap_pixmap (FRAME_PTR f, int id) |
| 202 | FRAME_PTR f; | ||
| 203 | int id; | ||
| 204 | { | 201 | { |
| 205 | return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; | 202 | return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; |
| 206 | } | 203 | } |
| @@ -208,9 +205,7 @@ x_bitmap_pixmap (f, id) | |||
| 208 | 205 | ||
| 209 | #ifdef HAVE_X_WINDOWS | 206 | #ifdef HAVE_X_WINDOWS |
| 210 | int | 207 | int |
| 211 | x_bitmap_mask (f, id) | 208 | x_bitmap_mask (FRAME_PTR f, int id) |
| 212 | FRAME_PTR f; | ||
| 213 | int id; | ||
| 214 | { | 209 | { |
| 215 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask; | 210 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask; |
| 216 | } | 211 | } |
| @@ -219,8 +214,7 @@ x_bitmap_mask (f, id) | |||
| 219 | /* Allocate a new bitmap record. Returns index of new record. */ | 214 | /* Allocate a new bitmap record. Returns index of new record. */ |
| 220 | 215 | ||
| 221 | static int | 216 | static int |
| 222 | x_allocate_bitmap_record (f) | 217 | x_allocate_bitmap_record (FRAME_PTR f) |
| 223 | FRAME_PTR f; | ||
| 224 | { | 218 | { |
| 225 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 219 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 226 | int i; | 220 | int i; |
| @@ -251,9 +245,7 @@ x_allocate_bitmap_record (f) | |||
| 251 | /* Add one reference to the reference count of the bitmap with id ID. */ | 245 | /* Add one reference to the reference count of the bitmap with id ID. */ |
| 252 | 246 | ||
| 253 | void | 247 | void |
| 254 | x_reference_bitmap (f, id) | 248 | x_reference_bitmap (FRAME_PTR f, int id) |
| 255 | FRAME_PTR f; | ||
| 256 | int id; | ||
| 257 | { | 249 | { |
| 258 | ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; | 250 | ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; |
| 259 | } | 251 | } |
| @@ -261,10 +253,7 @@ x_reference_bitmap (f, id) | |||
| 261 | /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ | 253 | /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ |
| 262 | 254 | ||
| 263 | int | 255 | int |
| 264 | x_create_bitmap_from_data (f, bits, width, height) | 256 | x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height) |
| 265 | struct frame *f; | ||
| 266 | char *bits; | ||
| 267 | unsigned int width, height; | ||
| 268 | { | 257 | { |
| 269 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 258 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 270 | int id; | 259 | int id; |
| @@ -288,7 +277,7 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 288 | #endif /* HAVE_NTGUI */ | 277 | #endif /* HAVE_NTGUI */ |
| 289 | 278 | ||
| 290 | #ifdef HAVE_NS | 279 | #ifdef HAVE_NS |
| 291 | void *bitmap = ns_image_from_XBM(bits, width, height); | 280 | void *bitmap = ns_image_from_XBM (bits, width, height); |
| 292 | if (!bitmap) | 281 | if (!bitmap) |
| 293 | return -1; | 282 | return -1; |
| 294 | #endif | 283 | #endif |
| @@ -323,9 +312,7 @@ x_create_bitmap_from_data (f, bits, width, height) | |||
| 323 | /* Create bitmap from file FILE for frame F. */ | 312 | /* Create bitmap from file FILE for frame F. */ |
| 324 | 313 | ||
| 325 | int | 314 | int |
| 326 | x_create_bitmap_from_file (f, file) | 315 | x_create_bitmap_from_file (struct frame *f, Lisp_Object file) |
| 327 | struct frame *f; | ||
| 328 | Lisp_Object file; | ||
| 329 | { | 316 | { |
| 330 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 317 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 331 | 318 | ||
| @@ -335,7 +322,7 @@ x_create_bitmap_from_file (f, file) | |||
| 335 | 322 | ||
| 336 | #ifdef HAVE_NS | 323 | #ifdef HAVE_NS |
| 337 | int id; | 324 | int id; |
| 338 | void *bitmap = ns_image_from_file(file); | 325 | void *bitmap = ns_image_from_file (file); |
| 339 | 326 | ||
| 340 | if (!bitmap) | 327 | if (!bitmap) |
| 341 | return -1; | 328 | return -1; |
| @@ -346,8 +333,8 @@ x_create_bitmap_from_file (f, file) | |||
| 346 | dpyinfo->bitmaps[id - 1].refcount = 1; | 333 | dpyinfo->bitmaps[id - 1].refcount = 1; |
| 347 | dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); | 334 | dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); |
| 348 | dpyinfo->bitmaps[id - 1].depth = 1; | 335 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 349 | dpyinfo->bitmaps[id - 1].height = ns_image_width(bitmap); | 336 | dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap); |
| 350 | dpyinfo->bitmaps[id - 1].width = ns_image_height(bitmap); | 337 | dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap); |
| 351 | strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); | 338 | strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); |
| 352 | return id; | 339 | return id; |
| 353 | #endif | 340 | #endif |
| @@ -402,9 +389,7 @@ x_create_bitmap_from_file (f, file) | |||
| 402 | /* Free bitmap B. */ | 389 | /* Free bitmap B. */ |
| 403 | 390 | ||
| 404 | static void | 391 | static void |
| 405 | free_bitmap_record (dpyinfo, bm) | 392 | free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm) |
| 406 | Display_Info *dpyinfo; | ||
| 407 | Bitmap_Record *bm; | ||
| 408 | { | 393 | { |
| 409 | #ifdef HAVE_X_WINDOWS | 394 | #ifdef HAVE_X_WINDOWS |
| 410 | XFreePixmap (dpyinfo->display, bm->pixmap); | 395 | XFreePixmap (dpyinfo->display, bm->pixmap); |
| @@ -417,7 +402,7 @@ free_bitmap_record (dpyinfo, bm) | |||
| 417 | #endif /* HAVE_NTGUI */ | 402 | #endif /* HAVE_NTGUI */ |
| 418 | 403 | ||
| 419 | #ifdef HAVE_NS | 404 | #ifdef HAVE_NS |
| 420 | ns_release_object(bm->img); | 405 | ns_release_object (bm->img); |
| 421 | #endif | 406 | #endif |
| 422 | 407 | ||
| 423 | if (bm->file) | 408 | if (bm->file) |
| @@ -430,9 +415,7 @@ free_bitmap_record (dpyinfo, bm) | |||
| 430 | /* Remove reference to bitmap with id number ID. */ | 415 | /* Remove reference to bitmap with id number ID. */ |
| 431 | 416 | ||
| 432 | void | 417 | void |
| 433 | x_destroy_bitmap (f, id) | 418 | x_destroy_bitmap (FRAME_PTR f, int id) |
| 434 | FRAME_PTR f; | ||
| 435 | int id; | ||
| 436 | { | 419 | { |
| 437 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 420 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 438 | 421 | ||
| @@ -452,8 +435,7 @@ x_destroy_bitmap (f, id) | |||
| 452 | /* Free all the bitmaps for the display specified by DPYINFO. */ | 435 | /* Free all the bitmaps for the display specified by DPYINFO. */ |
| 453 | 436 | ||
| 454 | void | 437 | void |
| 455 | x_destroy_all_bitmaps (dpyinfo) | 438 | x_destroy_all_bitmaps (Display_Info *dpyinfo) |
| 456 | Display_Info *dpyinfo; | ||
| 457 | { | 439 | { |
| 458 | int i; | 440 | int i; |
| 459 | Bitmap_Record *bm = dpyinfo->bitmaps; | 441 | Bitmap_Record *bm = dpyinfo->bitmaps; |
| @@ -471,25 +453,23 @@ x_destroy_all_bitmaps (dpyinfo) | |||
| 471 | /* Useful functions defined in the section | 453 | /* Useful functions defined in the section |
| 472 | `Image type independent image structures' below. */ | 454 | `Image type independent image structures' below. */ |
| 473 | 455 | ||
| 474 | static unsigned long four_corners_best P_ ((XImagePtr ximg, | 456 | static unsigned long four_corners_best (XImagePtr ximg, |
| 475 | int *corners, | 457 | int *corners, |
| 476 | unsigned long width, | 458 | unsigned long width, |
| 477 | unsigned long height)); | 459 | unsigned long height); |
| 478 | 460 | ||
| 479 | static int x_create_x_image_and_pixmap P_ ((struct frame *f, int width, int height, | 461 | static int x_create_x_image_and_pixmap (struct frame *f, int width, int height, |
| 480 | int depth, XImagePtr *ximg, | 462 | int depth, XImagePtr *ximg, |
| 481 | Pixmap *pixmap)); | 463 | Pixmap *pixmap); |
| 482 | 464 | ||
| 483 | static void x_destroy_x_image P_ ((XImagePtr ximg)); | 465 | static void x_destroy_x_image (XImagePtr ximg); |
| 484 | 466 | ||
| 485 | 467 | ||
| 486 | /* Create a mask of a bitmap. Note is this not a perfect mask. | 468 | /* Create a mask of a bitmap. Note is this not a perfect mask. |
| 487 | It's nicer with some borders in this context */ | 469 | It's nicer with some borders in this context */ |
| 488 | 470 | ||
| 489 | int | 471 | int |
| 490 | x_create_bitmap_mask (f, id) | 472 | x_create_bitmap_mask (struct frame *f, int id) |
| 491 | struct frame *f; | ||
| 492 | int id; | ||
| 493 | { | 473 | { |
| 494 | Pixmap pixmap, mask; | 474 | Pixmap pixmap, mask; |
| 495 | XImagePtr ximg, mask_img; | 475 | XImagePtr ximg, mask_img; |
| @@ -601,9 +581,6 @@ Lisp_Object Qxbm; | |||
| 601 | 581 | ||
| 602 | /* Keywords. */ | 582 | /* Keywords. */ |
| 603 | 583 | ||
| 604 | extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; | ||
| 605 | extern Lisp_Object QCdata, QCtype; | ||
| 606 | extern Lisp_Object Qcenter; | ||
| 607 | Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; | 584 | Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; |
| 608 | Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; | 585 | Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; |
| 609 | Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry, QCcrop, QCrotation; | 586 | Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry, QCcrop, QCrotation; |
| @@ -619,13 +596,13 @@ Lisp_Object Vimage_cache_eviction_delay; | |||
| 619 | 596 | ||
| 620 | /* Function prototypes. */ | 597 | /* Function prototypes. */ |
| 621 | 598 | ||
| 622 | static Lisp_Object define_image_type P_ ((struct image_type *type, int loaded)); | 599 | static Lisp_Object define_image_type (struct image_type *type, int loaded); |
| 623 | static struct image_type *lookup_image_type P_ ((Lisp_Object symbol)); | 600 | static struct image_type *lookup_image_type (Lisp_Object symbol); |
| 624 | static void image_error P_ ((char *format, Lisp_Object, Lisp_Object)); | 601 | static void image_error (const char *format, Lisp_Object, Lisp_Object); |
| 625 | static void x_laplace P_ ((struct frame *, struct image *)); | 602 | static void x_laplace (struct frame *, struct image *); |
| 626 | static void x_emboss P_ ((struct frame *, struct image *)); | 603 | static void x_emboss (struct frame *, struct image *); |
| 627 | static int x_build_heuristic_mask P_ ((struct frame *, struct image *, | 604 | static int x_build_heuristic_mask (struct frame *, struct image *, |
| 628 | Lisp_Object)); | 605 | Lisp_Object); |
| 629 | 606 | ||
| 630 | #define CACHE_IMAGE_TYPE(type, status) \ | 607 | #define CACHE_IMAGE_TYPE(type, status) \ |
| 631 | do { Vimage_type_cache = Fcons (Fcons (type, status), Vimage_type_cache); } while (0) | 608 | do { Vimage_type_cache = Fcons (Fcons (type, status), Vimage_type_cache); } while (0) |
| @@ -637,9 +614,7 @@ static int x_build_heuristic_mask P_ ((struct frame *, struct image *, | |||
| 637 | image_types and caches the loading status of TYPE. */ | 614 | image_types and caches the loading status of TYPE. */ |
| 638 | 615 | ||
| 639 | static Lisp_Object | 616 | static Lisp_Object |
| 640 | define_image_type (type, loaded) | 617 | define_image_type (struct image_type *type, int loaded) |
| 641 | struct image_type *type; | ||
| 642 | int loaded; | ||
| 643 | { | 618 | { |
| 644 | Lisp_Object success; | 619 | Lisp_Object success; |
| 645 | 620 | ||
| @@ -650,7 +625,7 @@ define_image_type (type, loaded) | |||
| 650 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. | 625 | /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. |
| 651 | The initialized data segment is read-only. */ | 626 | The initialized data segment is read-only. */ |
| 652 | struct image_type *p = (struct image_type *) xmalloc (sizeof *p); | 627 | struct image_type *p = (struct image_type *) xmalloc (sizeof *p); |
| 653 | bcopy (type, p, sizeof *p); | 628 | memcpy (p, type, sizeof *p); |
| 654 | p->next = image_types; | 629 | p->next = image_types; |
| 655 | image_types = p; | 630 | image_types = p; |
| 656 | success = Qt; | 631 | success = Qt; |
| @@ -665,8 +640,7 @@ define_image_type (type, loaded) | |||
| 665 | structure. Value is null if SYMBOL is not a known image type. */ | 640 | structure. Value is null if SYMBOL is not a known image type. */ |
| 666 | 641 | ||
| 667 | static INLINE struct image_type * | 642 | static INLINE struct image_type * |
| 668 | lookup_image_type (symbol) | 643 | lookup_image_type (Lisp_Object symbol) |
| 669 | Lisp_Object symbol; | ||
| 670 | { | 644 | { |
| 671 | struct image_type *type; | 645 | struct image_type *type; |
| 672 | 646 | ||
| @@ -690,8 +664,7 @@ lookup_image_type (symbol) | |||
| 690 | image type. */ | 664 | image type. */ |
| 691 | 665 | ||
| 692 | int | 666 | int |
| 693 | valid_image_p (object) | 667 | valid_image_p (Lisp_Object object) |
| 694 | Lisp_Object object; | ||
| 695 | { | 668 | { |
| 696 | int valid_p = 0; | 669 | int valid_p = 0; |
| 697 | 670 | ||
| @@ -726,9 +699,7 @@ valid_image_p (object) | |||
| 726 | therefore simply displays a message. */ | 699 | therefore simply displays a message. */ |
| 727 | 700 | ||
| 728 | static void | 701 | static void |
| 729 | image_error (format, arg1, arg2) | 702 | image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2) |
| 730 | char *format; | ||
| 731 | Lisp_Object arg1, arg2; | ||
| 732 | { | 703 | { |
| 733 | add_to_log (format, arg1, arg2); | 704 | add_to_log (format, arg1, arg2); |
| 734 | } | 705 | } |
| @@ -760,7 +731,7 @@ enum image_value_type | |||
| 760 | struct image_keyword | 731 | struct image_keyword |
| 761 | { | 732 | { |
| 762 | /* Name of keyword. */ | 733 | /* Name of keyword. */ |
| 763 | char *name; | 734 | const char *name; |
| 764 | 735 | ||
| 765 | /* The type of value allowed. */ | 736 | /* The type of value allowed. */ |
| 766 | enum image_value_type type; | 737 | enum image_value_type type; |
| @@ -776,9 +747,9 @@ struct image_keyword | |||
| 776 | }; | 747 | }; |
| 777 | 748 | ||
| 778 | 749 | ||
| 779 | static int parse_image_spec P_ ((Lisp_Object, struct image_keyword *, | 750 | static int parse_image_spec (Lisp_Object, struct image_keyword *, |
| 780 | int, Lisp_Object)); | 751 | int, Lisp_Object); |
| 781 | static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); | 752 | static Lisp_Object image_spec_value (Lisp_Object, Lisp_Object, int *); |
| 782 | 753 | ||
| 783 | 754 | ||
| 784 | /* Parse image spec SPEC according to KEYWORDS. A valid image spec | 755 | /* Parse image spec SPEC according to KEYWORDS. A valid image spec |
| @@ -788,11 +759,8 @@ static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); | |||
| 788 | allowed keyword/value pairs. Value is non-zero if SPEC is valid. */ | 759 | allowed keyword/value pairs. Value is non-zero if SPEC is valid. */ |
| 789 | 760 | ||
| 790 | static int | 761 | static int |
| 791 | parse_image_spec (spec, keywords, nkeywords, type) | 762 | parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, |
| 792 | Lisp_Object spec; | 763 | int nkeywords, Lisp_Object type) |
| 793 | struct image_keyword *keywords; | ||
| 794 | int nkeywords; | ||
| 795 | Lisp_Object type; | ||
| 796 | { | 764 | { |
| 797 | int i; | 765 | int i; |
| 798 | Lisp_Object plist; | 766 | Lisp_Object plist; |
| @@ -928,9 +896,7 @@ parse_image_spec (spec, keywords, nkeywords, type) | |||
| 928 | to 1 if KEY was found in SPEC, set it to 0 otherwise. */ | 896 | to 1 if KEY was found in SPEC, set it to 0 otherwise. */ |
| 929 | 897 | ||
| 930 | static Lisp_Object | 898 | static Lisp_Object |
| 931 | image_spec_value (spec, key, found) | 899 | image_spec_value (Lisp_Object spec, Lisp_Object key, int *found) |
| 932 | Lisp_Object spec, key; | ||
| 933 | int *found; | ||
| 934 | { | 900 | { |
| 935 | Lisp_Object tail; | 901 | Lisp_Object tail; |
| 936 | 902 | ||
| @@ -956,12 +922,11 @@ image_spec_value (spec, key, found) | |||
| 956 | 922 | ||
| 957 | DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, | 923 | DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, |
| 958 | doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT). | 924 | doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT). |
| 959 | PIXELS non-nil means return the size in pixels, otherwise return the | 925 | PIXELS non-nil means return the size in pixels, otherwise return the |
| 960 | size in canonical character units. | 926 | size in canonical character units. |
| 961 | FRAME is the frame on which the image will be displayed. FRAME nil | 927 | FRAME is the frame on which the image will be displayed. FRAME nil |
| 962 | or omitted means use the selected frame. */) | 928 | or omitted means use the selected frame. */) |
| 963 | (spec, pixels, frame) | 929 | (Lisp_Object spec, Lisp_Object pixels, Lisp_Object frame) |
| 964 | Lisp_Object spec, pixels, frame; | ||
| 965 | { | 930 | { |
| 966 | Lisp_Object size; | 931 | Lisp_Object size; |
| 967 | 932 | ||
| @@ -989,10 +954,9 @@ DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, | |||
| 989 | 954 | ||
| 990 | DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0, | 955 | DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0, |
| 991 | doc: /* Return t if image SPEC has a mask bitmap. | 956 | doc: /* Return t if image SPEC has a mask bitmap. |
| 992 | FRAME is the frame on which the image will be displayed. FRAME nil | 957 | FRAME is the frame on which the image will be displayed. FRAME nil |
| 993 | or omitted means use the selected frame. */) | 958 | or omitted means use the selected frame. */) |
| 994 | (spec, frame) | 959 | (Lisp_Object spec, Lisp_Object frame) |
| 995 | Lisp_Object spec, frame; | ||
| 996 | { | 960 | { |
| 997 | Lisp_Object mask; | 961 | Lisp_Object mask; |
| 998 | 962 | ||
| @@ -1013,10 +977,9 @@ DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0, | |||
| 1013 | 977 | ||
| 1014 | DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0, | 978 | DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0, |
| 1015 | doc: /* Return metadata for image SPEC. | 979 | doc: /* Return metadata for image SPEC. |
| 1016 | FRAME is the frame on which the image will be displayed. FRAME nil | 980 | FRAME is the frame on which the image will be displayed. FRAME nil |
| 1017 | or omitted means use the selected frame. */) | 981 | or omitted means use the selected frame. */) |
| 1018 | (spec, frame) | 982 | (Lisp_Object spec, Lisp_Object frame) |
| 1019 | Lisp_Object spec, frame; | ||
| 1020 | { | 983 | { |
| 1021 | Lisp_Object ext; | 984 | Lisp_Object ext; |
| 1022 | 985 | ||
| @@ -1037,9 +1000,9 @@ DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0, | |||
| 1037 | Image type independent image structures | 1000 | Image type independent image structures |
| 1038 | ***********************************************************************/ | 1001 | ***********************************************************************/ |
| 1039 | 1002 | ||
| 1040 | static struct image *make_image P_ ((Lisp_Object spec, unsigned hash)); | 1003 | static struct image *make_image (Lisp_Object spec, unsigned hash); |
| 1041 | static void free_image P_ ((struct frame *f, struct image *img)); | 1004 | static void free_image (struct frame *f, struct image *img); |
| 1042 | static int check_image_size P_ ((struct frame *f, int width, int height)); | 1005 | static int check_image_size (struct frame *f, int width, int height); |
| 1043 | 1006 | ||
| 1044 | #define MAX_IMAGE_SIZE 6.0 | 1007 | #define MAX_IMAGE_SIZE 6.0 |
| 1045 | Lisp_Object Vmax_image_size; | 1008 | Lisp_Object Vmax_image_size; |
| @@ -1048,15 +1011,13 @@ Lisp_Object Vmax_image_size; | |||
| 1048 | SPEC. SPEC has a hash value of HASH. */ | 1011 | SPEC. SPEC has a hash value of HASH. */ |
| 1049 | 1012 | ||
| 1050 | static struct image * | 1013 | static struct image * |
| 1051 | make_image (spec, hash) | 1014 | make_image (Lisp_Object spec, unsigned int hash) |
| 1052 | Lisp_Object spec; | ||
| 1053 | unsigned hash; | ||
| 1054 | { | 1015 | { |
| 1055 | struct image *img = (struct image *) xmalloc (sizeof *img); | 1016 | struct image *img = (struct image *) xmalloc (sizeof *img); |
| 1056 | Lisp_Object file = image_spec_value (spec, QCfile, NULL); | 1017 | Lisp_Object file = image_spec_value (spec, QCfile, NULL); |
| 1057 | 1018 | ||
| 1058 | xassert (valid_image_p (spec)); | 1019 | xassert (valid_image_p (spec)); |
| 1059 | bzero (img, sizeof *img); | 1020 | memset (img, 0, sizeof *img); |
| 1060 | img->dependencies = NILP (file) ? Qnil : list1 (file); | 1021 | img->dependencies = NILP (file) ? Qnil : list1 (file); |
| 1061 | img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); | 1022 | img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); |
| 1062 | xassert (img->type != NULL); | 1023 | xassert (img->type != NULL); |
| @@ -1072,9 +1033,7 @@ make_image (spec, hash) | |||
| 1072 | /* Free image IMG which was used on frame F, including its resources. */ | 1033 | /* Free image IMG which was used on frame F, including its resources. */ |
| 1073 | 1034 | ||
| 1074 | static void | 1035 | static void |
| 1075 | free_image (f, img) | 1036 | free_image (struct frame *f, struct image *img) |
| 1076 | struct frame *f; | ||
| 1077 | struct image *img; | ||
| 1078 | { | 1037 | { |
| 1079 | if (img) | 1038 | if (img) |
| 1080 | { | 1039 | { |
| @@ -1094,6 +1053,10 @@ free_image (f, img) | |||
| 1094 | /* Free resources, then free IMG. */ | 1053 | /* Free resources, then free IMG. */ |
| 1095 | img->type->free (f, img); | 1054 | img->type->free (f, img); |
| 1096 | xfree (img); | 1055 | xfree (img); |
| 1056 | |||
| 1057 | /* As display glyphs may still be referring to the image ID, we | ||
| 1058 | must garbage the frame (Bug#6426). */ | ||
| 1059 | SET_FRAME_GARBAGED (f); | ||
| 1097 | } | 1060 | } |
| 1098 | } | 1061 | } |
| 1099 | 1062 | ||
| @@ -1101,10 +1064,7 @@ free_image (f, img) | |||
| 1101 | otherwise, return 0. */ | 1064 | otherwise, return 0. */ |
| 1102 | 1065 | ||
| 1103 | int | 1066 | int |
| 1104 | check_image_size (f, width, height) | 1067 | check_image_size (struct frame *f, int width, int height) |
| 1105 | struct frame *f; | ||
| 1106 | int width; | ||
| 1107 | int height; | ||
| 1108 | { | 1068 | { |
| 1109 | int w, h; | 1069 | int w, h; |
| 1110 | 1070 | ||
| @@ -1135,9 +1095,7 @@ check_image_size (f, width, height) | |||
| 1135 | drawing an image. */ | 1095 | drawing an image. */ |
| 1136 | 1096 | ||
| 1137 | void | 1097 | void |
| 1138 | prepare_image_for_display (f, img) | 1098 | prepare_image_for_display (struct frame *f, struct image *img) |
| 1139 | struct frame *f; | ||
| 1140 | struct image *img; | ||
| 1141 | { | 1099 | { |
| 1142 | EMACS_TIME t; | 1100 | EMACS_TIME t; |
| 1143 | 1101 | ||
| @@ -1157,10 +1115,7 @@ prepare_image_for_display (f, img) | |||
| 1157 | drawn in face FACE. */ | 1115 | drawn in face FACE. */ |
| 1158 | 1116 | ||
| 1159 | int | 1117 | int |
| 1160 | image_ascent (img, face, slice) | 1118 | image_ascent (struct image *img, struct face *face, struct glyph_slice *slice) |
| 1161 | struct image *img; | ||
| 1162 | struct face *face; | ||
| 1163 | struct glyph_slice *slice; | ||
| 1164 | { | 1119 | { |
| 1165 | int height; | 1120 | int height; |
| 1166 | int ascent; | 1121 | int ascent; |
| @@ -1206,10 +1161,8 @@ image_ascent (img, face, slice) | |||
| 1206 | On W32, XIMG is assumed to a device context with the bitmap selected. */ | 1161 | On W32, XIMG is assumed to a device context with the bitmap selected. */ |
| 1207 | 1162 | ||
| 1208 | static RGB_PIXEL_COLOR | 1163 | static RGB_PIXEL_COLOR |
| 1209 | four_corners_best (ximg, corners, width, height) | 1164 | four_corners_best (XImagePtr_or_DC ximg, int *corners, |
| 1210 | XImagePtr_or_DC ximg; | 1165 | unsigned long width, unsigned long height) |
| 1211 | int *corners; | ||
| 1212 | unsigned long width, height; | ||
| 1213 | { | 1166 | { |
| 1214 | RGB_PIXEL_COLOR corner_pixels[4], best; | 1167 | RGB_PIXEL_COLOR corner_pixels[4], best; |
| 1215 | int i, best_count; | 1168 | int i, best_count; |
| @@ -1258,11 +1211,11 @@ four_corners_best (ximg, corners, width, height) | |||
| 1258 | 1211 | ||
| 1259 | #elif defined (HAVE_NS) | 1212 | #elif defined (HAVE_NS) |
| 1260 | 1213 | ||
| 1261 | #define Destroy_Image(ximg, dummy) \ | 1214 | #define Destroy_Image(ximg, dummy) \ |
| 1262 | ns_release_object(ximg) | 1215 | ns_release_object (ximg) |
| 1263 | 1216 | ||
| 1264 | #define Free_Pixmap(display, pixmap) \ | 1217 | #define Free_Pixmap(display, pixmap) \ |
| 1265 | ns_release_object(pixmap) | 1218 | ns_release_object (pixmap) |
| 1266 | 1219 | ||
| 1267 | #else | 1220 | #else |
| 1268 | 1221 | ||
| @@ -1281,10 +1234,7 @@ four_corners_best (ximg, corners, width, height) | |||
| 1281 | use for the heuristic. */ | 1234 | use for the heuristic. */ |
| 1282 | 1235 | ||
| 1283 | RGB_PIXEL_COLOR | 1236 | RGB_PIXEL_COLOR |
| 1284 | image_background (img, f, ximg) | 1237 | image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg) |
| 1285 | struct image *img; | ||
| 1286 | struct frame *f; | ||
| 1287 | XImagePtr_or_DC ximg; | ||
| 1288 | { | 1238 | { |
| 1289 | if (! img->background_valid) | 1239 | if (! img->background_valid) |
| 1290 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ | 1240 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ |
| @@ -1323,10 +1273,7 @@ image_background (img, f, ximg) | |||
| 1323 | existing XImage object to use for the heuristic. */ | 1273 | existing XImage object to use for the heuristic. */ |
| 1324 | 1274 | ||
| 1325 | int | 1275 | int |
| 1326 | image_background_transparent (img, f, mask) | 1276 | image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_DC mask) |
| 1327 | struct image *img; | ||
| 1328 | struct frame *f; | ||
| 1329 | XImagePtr_or_DC mask; | ||
| 1330 | { | 1277 | { |
| 1331 | if (! img->background_transparent_valid) | 1278 | if (! img->background_transparent_valid) |
| 1332 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ | 1279 | /* IMG doesn't have a background yet, try to guess a reasonable value. */ |
| @@ -1371,13 +1318,13 @@ image_background_transparent (img, f, mask) | |||
| 1371 | Helper functions for X image types | 1318 | Helper functions for X image types |
| 1372 | ***********************************************************************/ | 1319 | ***********************************************************************/ |
| 1373 | 1320 | ||
| 1374 | static void x_clear_image_1 P_ ((struct frame *, struct image *, int, | 1321 | static void x_clear_image_1 (struct frame *, struct image *, int, |
| 1375 | int, int)); | 1322 | int, int); |
| 1376 | static void x_clear_image P_ ((struct frame *f, struct image *img)); | 1323 | static void x_clear_image (struct frame *f, struct image *img); |
| 1377 | static unsigned long x_alloc_image_color P_ ((struct frame *f, | 1324 | static unsigned long x_alloc_image_color (struct frame *f, |
| 1378 | struct image *img, | 1325 | struct image *img, |
| 1379 | Lisp_Object color_name, | 1326 | Lisp_Object color_name, |
| 1380 | unsigned long dflt)); | 1327 | unsigned long dflt); |
| 1381 | 1328 | ||
| 1382 | 1329 | ||
| 1383 | /* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means | 1330 | /* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means |
| @@ -1386,10 +1333,8 @@ static unsigned long x_alloc_image_color P_ ((struct frame *f, | |||
| 1386 | the image, if any. */ | 1333 | the image, if any. */ |
| 1387 | 1334 | ||
| 1388 | static void | 1335 | static void |
| 1389 | x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | 1336 | x_clear_image_1 (struct frame *f, struct image *img, int pixmap_p, int mask_p, |
| 1390 | struct frame *f; | 1337 | int colors_p) |
| 1391 | struct image *img; | ||
| 1392 | int pixmap_p, mask_p, colors_p; | ||
| 1393 | { | 1338 | { |
| 1394 | if (pixmap_p && img->pixmap) | 1339 | if (pixmap_p && img->pixmap) |
| 1395 | { | 1340 | { |
| @@ -1422,9 +1367,7 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) | |||
| 1422 | /* Free X resources of image IMG which is used on frame F. */ | 1367 | /* Free X resources of image IMG which is used on frame F. */ |
| 1423 | 1368 | ||
| 1424 | static void | 1369 | static void |
| 1425 | x_clear_image (f, img) | 1370 | x_clear_image (struct frame *f, struct image *img) |
| 1426 | struct frame *f; | ||
| 1427 | struct image *img; | ||
| 1428 | { | 1371 | { |
| 1429 | BLOCK_INPUT; | 1372 | BLOCK_INPUT; |
| 1430 | x_clear_image_1 (f, img, 1, 1, 1); | 1373 | x_clear_image_1 (f, img, 1, 1, 1); |
| @@ -1438,11 +1381,8 @@ x_clear_image (f, img) | |||
| 1438 | color. */ | 1381 | color. */ |
| 1439 | 1382 | ||
| 1440 | static unsigned long | 1383 | static unsigned long |
| 1441 | x_alloc_image_color (f, img, color_name, dflt) | 1384 | x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name, |
| 1442 | struct frame *f; | 1385 | unsigned long dflt) |
| 1443 | struct image *img; | ||
| 1444 | Lisp_Object color_name; | ||
| 1445 | unsigned long dflt; | ||
| 1446 | { | 1386 | { |
| 1447 | XColor color; | 1387 | XColor color; |
| 1448 | unsigned long result; | 1388 | unsigned long result; |
| @@ -1472,25 +1412,25 @@ x_alloc_image_color (f, img, color_name, dflt) | |||
| 1472 | Image Cache | 1412 | Image Cache |
| 1473 | ***********************************************************************/ | 1413 | ***********************************************************************/ |
| 1474 | 1414 | ||
| 1475 | static struct image *search_image_cache P_ ((struct frame *, Lisp_Object, unsigned)); | 1415 | static struct image *search_image_cache (struct frame *, Lisp_Object, unsigned); |
| 1476 | static void cache_image P_ ((struct frame *f, struct image *img)); | 1416 | static void cache_image (struct frame *f, struct image *img); |
| 1477 | static void postprocess_image P_ ((struct frame *, struct image *)); | 1417 | static void postprocess_image (struct frame *, struct image *); |
| 1478 | 1418 | ||
| 1479 | /* Return a new, initialized image cache that is allocated from the | 1419 | /* Return a new, initialized image cache that is allocated from the |
| 1480 | heap. Call free_image_cache to free an image cache. */ | 1420 | heap. Call free_image_cache to free an image cache. */ |
| 1481 | 1421 | ||
| 1482 | struct image_cache * | 1422 | struct image_cache * |
| 1483 | make_image_cache () | 1423 | make_image_cache (void) |
| 1484 | { | 1424 | { |
| 1485 | struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); | 1425 | struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); |
| 1486 | int size; | 1426 | int size; |
| 1487 | 1427 | ||
| 1488 | bzero (c, sizeof *c); | 1428 | memset (c, 0, sizeof *c); |
| 1489 | c->size = 50; | 1429 | c->size = 50; |
| 1490 | c->images = (struct image **) xmalloc (c->size * sizeof *c->images); | 1430 | c->images = (struct image **) xmalloc (c->size * sizeof *c->images); |
| 1491 | size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | 1431 | size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
| 1492 | c->buckets = (struct image **) xmalloc (size); | 1432 | c->buckets = (struct image **) xmalloc (size); |
| 1493 | bzero (c->buckets, size); | 1433 | memset (c->buckets, 0, size); |
| 1494 | return c; | 1434 | return c; |
| 1495 | } | 1435 | } |
| 1496 | 1436 | ||
| @@ -1498,10 +1438,7 @@ make_image_cache () | |||
| 1498 | /* Find an image matching SPEC in the cache, and return it. If no | 1438 | /* Find an image matching SPEC in the cache, and return it. If no |
| 1499 | image is found, return NULL. */ | 1439 | image is found, return NULL. */ |
| 1500 | static struct image * | 1440 | static struct image * |
| 1501 | search_image_cache (f, spec, hash) | 1441 | search_image_cache (struct frame *f, Lisp_Object spec, unsigned int hash) |
| 1502 | struct frame *f; | ||
| 1503 | Lisp_Object spec; | ||
| 1504 | unsigned hash; | ||
| 1505 | { | 1442 | { |
| 1506 | struct image *img; | 1443 | struct image *img; |
| 1507 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1444 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| @@ -1534,9 +1471,7 @@ search_image_cache (f, spec, hash) | |||
| 1534 | /* Search frame F for an image with spec SPEC, and free it. */ | 1471 | /* Search frame F for an image with spec SPEC, and free it. */ |
| 1535 | 1472 | ||
| 1536 | static void | 1473 | static void |
| 1537 | uncache_image (f, spec) | 1474 | uncache_image (struct frame *f, Lisp_Object spec) |
| 1538 | struct frame *f; | ||
| 1539 | Lisp_Object spec; | ||
| 1540 | { | 1475 | { |
| 1541 | struct image *img = search_image_cache (f, spec, sxhash (spec, 0)); | 1476 | struct image *img = search_image_cache (f, spec, sxhash (spec, 0)); |
| 1542 | if (img) | 1477 | if (img) |
| @@ -1548,8 +1483,7 @@ uncache_image (f, spec) | |||
| 1548 | caches. */ | 1483 | caches. */ |
| 1549 | 1484 | ||
| 1550 | void | 1485 | void |
| 1551 | free_image_cache (f) | 1486 | free_image_cache (struct frame *f) |
| 1552 | struct frame *f; | ||
| 1553 | { | 1487 | { |
| 1554 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1488 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1555 | if (c) | 1489 | if (c) |
| @@ -1673,12 +1607,11 @@ clear_image_caches (Lisp_Object filter) | |||
| 1673 | DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache, | 1607 | DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache, |
| 1674 | 0, 1, 0, | 1608 | 0, 1, 0, |
| 1675 | doc: /* Clear the image cache. | 1609 | doc: /* Clear the image cache. |
| 1676 | FILTER nil or a frame means clear all images in the selected frame. | 1610 | FILTER nil or a frame means clear all images in the selected frame. |
| 1677 | FILTER t means clear the image caches of all frames. | 1611 | FILTER t means clear the image caches of all frames. |
| 1678 | Anything else, means only clear those images which refer to FILTER, | 1612 | Anything else, means only clear those images which refer to FILTER, |
| 1679 | which is then usually a filename. */) | 1613 | which is then usually a filename. */) |
| 1680 | (filter) | 1614 | (Lisp_Object filter) |
| 1681 | Lisp_Object filter; | ||
| 1682 | { | 1615 | { |
| 1683 | if (!(EQ (filter, Qnil) || FRAMEP (filter))) | 1616 | if (!(EQ (filter, Qnil) || FRAMEP (filter))) |
| 1684 | clear_image_caches (filter); | 1617 | clear_image_caches (filter); |
| @@ -1696,10 +1629,9 @@ DEFUN ("image-flush", Fimage_flush, Simage_flush, | |||
| 1696 | an image file, the next redisplay of this image will read from the | 1629 | an image file, the next redisplay of this image will read from the |
| 1697 | current contents of that file. | 1630 | current contents of that file. |
| 1698 | 1631 | ||
| 1699 | FRAME nil or omitted means use the selected frame. | 1632 | FRAME nil or omitted means use the selected frame. |
| 1700 | FRAME t means refresh the image on all frames. */) | 1633 | FRAME t means refresh the image on all frames. */) |
| 1701 | (spec, frame) | 1634 | (Lisp_Object spec, Lisp_Object frame) |
| 1702 | Lisp_Object spec, frame; | ||
| 1703 | { | 1635 | { |
| 1704 | if (!valid_image_p (spec)) | 1636 | if (!valid_image_p (spec)) |
| 1705 | error ("Invalid image specification"); | 1637 | error ("Invalid image specification"); |
| @@ -1725,9 +1657,7 @@ DEFUN ("image-flush", Fimage_flush, Simage_flush, | |||
| 1725 | by the image's specification, */ | 1657 | by the image's specification, */ |
| 1726 | 1658 | ||
| 1727 | static void | 1659 | static void |
| 1728 | postprocess_image (f, img) | 1660 | postprocess_image (struct frame *f, struct image *img) |
| 1729 | struct frame *f; | ||
| 1730 | struct image *img; | ||
| 1731 | { | 1661 | { |
| 1732 | /* Manipulation of the image's mask. */ | 1662 | /* Manipulation of the image's mask. */ |
| 1733 | if (img->pixmap) | 1663 | if (img->pixmap) |
| @@ -1800,9 +1730,7 @@ postprocess_image (f, img) | |||
| 1800 | SPEC must be a valid Lisp image specification (see valid_image_p). */ | 1730 | SPEC must be a valid Lisp image specification (see valid_image_p). */ |
| 1801 | 1731 | ||
| 1802 | int | 1732 | int |
| 1803 | lookup_image (f, spec) | 1733 | lookup_image (struct frame *f, Lisp_Object spec) |
| 1804 | struct frame *f; | ||
| 1805 | Lisp_Object spec; | ||
| 1806 | { | 1734 | { |
| 1807 | struct image_cache *c; | 1735 | struct image_cache *c; |
| 1808 | struct image *img; | 1736 | struct image *img; |
| @@ -1831,8 +1759,6 @@ lookup_image (f, spec) | |||
| 1831 | /* If not found, create a new image and cache it. */ | 1759 | /* If not found, create a new image and cache it. */ |
| 1832 | if (img == NULL) | 1760 | if (img == NULL) |
| 1833 | { | 1761 | { |
| 1834 | extern Lisp_Object Qpostscript; | ||
| 1835 | |||
| 1836 | BLOCK_INPUT; | 1762 | BLOCK_INPUT; |
| 1837 | img = make_image (spec, hash); | 1763 | img = make_image (spec, hash); |
| 1838 | cache_image (f, img); | 1764 | cache_image (f, img); |
| @@ -1922,9 +1848,7 @@ lookup_image (f, spec) | |||
| 1922 | /* Cache image IMG in the image cache of frame F. */ | 1848 | /* Cache image IMG in the image cache of frame F. */ |
| 1923 | 1849 | ||
| 1924 | static void | 1850 | static void |
| 1925 | cache_image (f, img) | 1851 | cache_image (struct frame *f, struct image *img) |
| 1926 | struct frame *f; | ||
| 1927 | struct image *img; | ||
| 1928 | { | 1852 | { |
| 1929 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1853 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1930 | int i; | 1854 | int i; |
| @@ -1964,8 +1888,7 @@ cache_image (f, img) | |||
| 1964 | /* Mark Lisp objects in image IMG. */ | 1888 | /* Mark Lisp objects in image IMG. */ |
| 1965 | 1889 | ||
| 1966 | static void | 1890 | static void |
| 1967 | mark_image (img) | 1891 | mark_image (struct image *img) |
| 1968 | struct image *img; | ||
| 1969 | { | 1892 | { |
| 1970 | mark_object (img->spec); | 1893 | mark_object (img->spec); |
| 1971 | mark_object (img->dependencies); | 1894 | mark_object (img->dependencies); |
| @@ -2033,10 +1956,10 @@ w32_delayed_load (Lisp_Object libraries, Lisp_Object type) | |||
| 2033 | 1956 | ||
| 2034 | #endif /* HAVE_NTGUI */ | 1957 | #endif /* HAVE_NTGUI */ |
| 2035 | 1958 | ||
| 2036 | static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, | 1959 | static int x_create_x_image_and_pixmap (struct frame *, int, int, int, |
| 2037 | XImagePtr *, Pixmap *)); | 1960 | XImagePtr *, Pixmap *); |
| 2038 | static void x_destroy_x_image P_ ((XImagePtr)); | 1961 | static void x_destroy_x_image (XImagePtr); |
| 2039 | static void x_put_x_image P_ ((struct frame *, XImagePtr, Pixmap, int, int)); | 1962 | static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int); |
| 2040 | 1963 | ||
| 2041 | 1964 | ||
| 2042 | /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on | 1965 | /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on |
| @@ -2049,11 +1972,8 @@ static void x_put_x_image P_ ((struct frame *, XImagePtr, Pixmap, int, int)); | |||
| 2049 | should indicate the bit depth of the image. */ | 1972 | should indicate the bit depth of the image. */ |
| 2050 | 1973 | ||
| 2051 | static int | 1974 | static int |
| 2052 | x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | 1975 | x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, |
| 2053 | struct frame *f; | 1976 | XImagePtr *ximg, Pixmap *pixmap) |
| 2054 | int width, height, depth; | ||
| 2055 | XImagePtr *ximg; | ||
| 2056 | Pixmap *pixmap; | ||
| 2057 | { | 1977 | { |
| 2058 | #ifdef HAVE_X_WINDOWS | 1978 | #ifdef HAVE_X_WINDOWS |
| 2059 | Display *display = FRAME_X_DISPLAY (f); | 1979 | Display *display = FRAME_X_DISPLAY (f); |
| @@ -2125,8 +2045,8 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2125 | return 0; | 2045 | return 0; |
| 2126 | } | 2046 | } |
| 2127 | 2047 | ||
| 2128 | header = &((*ximg)->info.bmiHeader); | 2048 | header = &(*ximg)->info.bmiHeader; |
| 2129 | bzero (&((*ximg)->info), sizeof (BITMAPINFO)); | 2049 | memset (&(*ximg)->info, 0, sizeof (BITMAPINFO)); |
| 2130 | header->biSize = sizeof (*header); | 2050 | header->biSize = sizeof (*header); |
| 2131 | header->biWidth = width; | 2051 | header->biWidth = width; |
| 2132 | header->biHeight = -height; /* negative indicates a top-down bitmap. */ | 2052 | header->biHeight = -height; /* negative indicates a top-down bitmap. */ |
| @@ -2176,7 +2096,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2176 | #endif /* HAVE_NTGUI */ | 2096 | #endif /* HAVE_NTGUI */ |
| 2177 | 2097 | ||
| 2178 | #ifdef HAVE_NS | 2098 | #ifdef HAVE_NS |
| 2179 | *pixmap = ns_image_for_XPM(width, height, depth); | 2099 | *pixmap = ns_image_for_XPM (width, height, depth); |
| 2180 | if (*pixmap == 0) | 2100 | if (*pixmap == 0) |
| 2181 | { | 2101 | { |
| 2182 | *ximg = NULL; | 2102 | *ximg = NULL; |
| @@ -2192,8 +2112,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) | |||
| 2192 | /* Destroy XImage XIMG. Free XIMG->data. */ | 2112 | /* Destroy XImage XIMG. Free XIMG->data. */ |
| 2193 | 2113 | ||
| 2194 | static void | 2114 | static void |
| 2195 | x_destroy_x_image (ximg) | 2115 | x_destroy_x_image (XImagePtr ximg) |
| 2196 | XImagePtr ximg; | ||
| 2197 | { | 2116 | { |
| 2198 | xassert (interrupt_input_blocked); | 2117 | xassert (interrupt_input_blocked); |
| 2199 | if (ximg) | 2118 | if (ximg) |
| @@ -2209,7 +2128,7 @@ x_destroy_x_image (ximg) | |||
| 2209 | xfree (ximg); | 2128 | xfree (ximg); |
| 2210 | #endif /* HAVE_NTGUI */ | 2129 | #endif /* HAVE_NTGUI */ |
| 2211 | #ifdef HAVE_NS | 2130 | #ifdef HAVE_NS |
| 2212 | ns_release_object(ximg); | 2131 | ns_release_object (ximg); |
| 2213 | #endif /* HAVE_NS */ | 2132 | #endif /* HAVE_NS */ |
| 2214 | } | 2133 | } |
| 2215 | } | 2134 | } |
| @@ -2219,11 +2138,7 @@ x_destroy_x_image (ximg) | |||
| 2219 | are width and height of both the image and pixmap. */ | 2138 | are width and height of both the image and pixmap. */ |
| 2220 | 2139 | ||
| 2221 | static void | 2140 | static void |
| 2222 | x_put_x_image (f, ximg, pixmap, width, height) | 2141 | x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, int width, int height) |
| 2223 | struct frame *f; | ||
| 2224 | XImagePtr ximg; | ||
| 2225 | Pixmap pixmap; | ||
| 2226 | int width, height; | ||
| 2227 | { | 2142 | { |
| 2228 | #ifdef HAVE_X_WINDOWS | 2143 | #ifdef HAVE_X_WINDOWS |
| 2229 | GC gc; | 2144 | GC gc; |
| @@ -2244,7 +2159,7 @@ x_put_x_image (f, ximg, pixmap, width, height) | |||
| 2244 | 2159 | ||
| 2245 | #ifdef HAVE_NS | 2160 | #ifdef HAVE_NS |
| 2246 | xassert (ximg == pixmap); | 2161 | xassert (ximg == pixmap); |
| 2247 | ns_retain_object(ximg); | 2162 | ns_retain_object (ximg); |
| 2248 | #endif | 2163 | #endif |
| 2249 | } | 2164 | } |
| 2250 | 2165 | ||
| @@ -2253,7 +2168,7 @@ x_put_x_image (f, ximg, pixmap, width, height) | |||
| 2253 | File Handling | 2168 | File Handling |
| 2254 | ***********************************************************************/ | 2169 | ***********************************************************************/ |
| 2255 | 2170 | ||
| 2256 | static unsigned char *slurp_file P_ ((char *, int *)); | 2171 | static unsigned char *slurp_file (char *, int *); |
| 2257 | 2172 | ||
| 2258 | 2173 | ||
| 2259 | /* Find image file FILE. Look in data-directory/images, then | 2174 | /* Find image file FILE. Look in data-directory/images, then |
| @@ -2261,8 +2176,7 @@ static unsigned char *slurp_file P_ ((char *, int *)); | |||
| 2261 | found, or nil if not found. */ | 2176 | found, or nil if not found. */ |
| 2262 | 2177 | ||
| 2263 | Lisp_Object | 2178 | Lisp_Object |
| 2264 | x_find_image_file (file) | 2179 | x_find_image_file (Lisp_Object file) |
| 2265 | Lisp_Object file; | ||
| 2266 | { | 2180 | { |
| 2267 | Lisp_Object file_found, search_path; | 2181 | Lisp_Object file_found, search_path; |
| 2268 | struct gcpro gcpro1, gcpro2; | 2182 | struct gcpro gcpro1, gcpro2; |
| @@ -2297,9 +2211,7 @@ x_find_image_file (file) | |||
| 2297 | occurred. *SIZE is set to the size of the file. */ | 2211 | occurred. *SIZE is set to the size of the file. */ |
| 2298 | 2212 | ||
| 2299 | static unsigned char * | 2213 | static unsigned char * |
| 2300 | slurp_file (file, size) | 2214 | slurp_file (char *file, int *size) |
| 2301 | char *file; | ||
| 2302 | int *size; | ||
| 2303 | { | 2215 | { |
| 2304 | FILE *fp = NULL; | 2216 | FILE *fp = NULL; |
| 2305 | unsigned char *buf = NULL; | 2217 | unsigned char *buf = NULL; |
| @@ -2333,15 +2245,15 @@ slurp_file (file, size) | |||
| 2333 | XBM images | 2245 | XBM images |
| 2334 | ***********************************************************************/ | 2246 | ***********************************************************************/ |
| 2335 | 2247 | ||
| 2336 | static int xbm_scan P_ ((unsigned char **, unsigned char *, char *, int *)); | 2248 | static int xbm_scan (unsigned char **, unsigned char *, char *, int *); |
| 2337 | static int xbm_load P_ ((struct frame *f, struct image *img)); | 2249 | static int xbm_load (struct frame *f, struct image *img); |
| 2338 | static int xbm_load_image P_ ((struct frame *f, struct image *img, | 2250 | static int xbm_load_image (struct frame *f, struct image *img, |
| 2339 | unsigned char *, unsigned char *)); | 2251 | unsigned char *, unsigned char *); |
| 2340 | static int xbm_image_p P_ ((Lisp_Object object)); | 2252 | static int xbm_image_p (Lisp_Object object); |
| 2341 | static int xbm_read_bitmap_data P_ ((struct frame *f, | 2253 | static int xbm_read_bitmap_data (struct frame *f, |
| 2342 | unsigned char *, unsigned char *, | 2254 | unsigned char *, unsigned char *, |
| 2343 | int *, int *, unsigned char **, int)); | 2255 | int *, int *, unsigned char **, int); |
| 2344 | static int xbm_file_p P_ ((Lisp_Object)); | 2256 | static int xbm_file_p (Lisp_Object); |
| 2345 | 2257 | ||
| 2346 | 2258 | ||
| 2347 | /* Indices of image specification fields in xbm_format, below. */ | 2259 | /* Indices of image specification fields in xbm_format, below. */ |
| @@ -2434,12 +2346,11 @@ enum xbm_token | |||
| 2434 | displayed is used. */ | 2346 | displayed is used. */ |
| 2435 | 2347 | ||
| 2436 | static int | 2348 | static int |
| 2437 | xbm_image_p (object) | 2349 | xbm_image_p (Lisp_Object object) |
| 2438 | Lisp_Object object; | ||
| 2439 | { | 2350 | { |
| 2440 | struct image_keyword kw[XBM_LAST]; | 2351 | struct image_keyword kw[XBM_LAST]; |
| 2441 | 2352 | ||
| 2442 | bcopy (xbm_format, kw, sizeof kw); | 2353 | memcpy (kw, xbm_format, sizeof kw); |
| 2443 | if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) | 2354 | if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) |
| 2444 | return 0; | 2355 | return 0; |
| 2445 | 2356 | ||
| @@ -2528,10 +2439,7 @@ xbm_image_p (object) | |||
| 2528 | scanning a number, store its value in *IVAL. */ | 2439 | scanning a number, store its value in *IVAL. */ |
| 2529 | 2440 | ||
| 2530 | static int | 2441 | static int |
| 2531 | xbm_scan (s, end, sval, ival) | 2442 | xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) |
| 2532 | unsigned char **s, *end; | ||
| 2533 | char *sval; | ||
| 2534 | int *ival; | ||
| 2535 | { | 2443 | { |
| 2536 | unsigned int c; | 2444 | unsigned int c; |
| 2537 | 2445 | ||
| @@ -2632,7 +2540,7 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data) | |||
| 2632 | w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ | 2540 | w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ |
| 2633 | w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ | 2541 | w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ |
| 2634 | bits = (unsigned char *) alloca (height * w2); | 2542 | bits = (unsigned char *) alloca (height * w2); |
| 2635 | bzero (bits, height * w2); | 2543 | memset (bits, 0, height * w2); |
| 2636 | for (i = 0; i < height; i++) | 2544 | for (i = 0; i < height; i++) |
| 2637 | { | 2545 | { |
| 2638 | p = bits + i*w2; | 2546 | p = bits + i*w2; |
| @@ -2650,10 +2558,8 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data) | |||
| 2650 | } | 2558 | } |
| 2651 | 2559 | ||
| 2652 | static void | 2560 | static void |
| 2653 | convert_mono_to_color_image (f, img, foreground, background) | 2561 | convert_mono_to_color_image (struct frame *f, struct image *img, |
| 2654 | struct frame *f; | 2562 | COLORREF foreground, COLORREF background) |
| 2655 | struct image *img; | ||
| 2656 | COLORREF foreground, background; | ||
| 2657 | { | 2563 | { |
| 2658 | HDC hdc, old_img_dc, new_img_dc; | 2564 | HDC hdc, old_img_dc, new_img_dc; |
| 2659 | HGDIOBJ old_prev, new_prev; | 2565 | HGDIOBJ old_prev, new_prev; |
| @@ -2695,12 +2601,9 @@ convert_mono_to_color_image (f, img, foreground, background) | |||
| 2695 | 2601 | ||
| 2696 | 2602 | ||
| 2697 | static void | 2603 | static void |
| 2698 | Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) | 2604 | Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data, |
| 2699 | struct frame *f; | 2605 | RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg, |
| 2700 | struct image *img; | 2606 | int non_default_colors) |
| 2701 | char *data; | ||
| 2702 | RGB_PIXEL_COLOR fg, bg; | ||
| 2703 | int non_default_colors; | ||
| 2704 | { | 2607 | { |
| 2705 | #ifdef HAVE_NTGUI | 2608 | #ifdef HAVE_NTGUI |
| 2706 | img->pixmap | 2609 | img->pixmap |
| @@ -2711,7 +2614,7 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) | |||
| 2711 | convert_mono_to_color_image (f, img, fg, bg); | 2614 | convert_mono_to_color_image (f, img, fg, bg); |
| 2712 | 2615 | ||
| 2713 | #elif defined (HAVE_NS) | 2616 | #elif defined (HAVE_NS) |
| 2714 | img->pixmap = ns_image_from_XBM(data, img->width, img->height); | 2617 | img->pixmap = ns_image_from_XBM (data, img->width, img->height); |
| 2715 | 2618 | ||
| 2716 | #else | 2619 | #else |
| 2717 | img->pixmap | 2620 | img->pixmap |
| @@ -2736,12 +2639,9 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) | |||
| 2736 | invalid (the bitmap remains unread). */ | 2639 | invalid (the bitmap remains unread). */ |
| 2737 | 2640 | ||
| 2738 | static int | 2641 | static int |
| 2739 | xbm_read_bitmap_data (f, contents, end, width, height, data, inhibit_image_error) | 2642 | xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end, |
| 2740 | struct frame *f; | 2643 | int *width, int *height, unsigned char **data, |
| 2741 | unsigned char *contents, *end; | 2644 | int inhibit_image_error) |
| 2742 | int *width, *height; | ||
| 2743 | unsigned char **data; | ||
| 2744 | int inhibit_image_error; | ||
| 2745 | { | 2645 | { |
| 2746 | unsigned char *s = contents; | 2646 | unsigned char *s = contents; |
| 2747 | char buffer[BUFSIZ]; | 2647 | char buffer[BUFSIZ]; |
| @@ -2890,10 +2790,8 @@ xbm_read_bitmap_data (f, contents, end, width, height, data, inhibit_image_error | |||
| 2890 | successful. */ | 2790 | successful. */ |
| 2891 | 2791 | ||
| 2892 | static int | 2792 | static int |
| 2893 | xbm_load_image (f, img, contents, end) | 2793 | xbm_load_image (struct frame *f, struct image *img, unsigned char *contents, |
| 2894 | struct frame *f; | 2794 | unsigned char *end) |
| 2895 | struct image *img; | ||
| 2896 | unsigned char *contents, *end; | ||
| 2897 | { | 2795 | { |
| 2898 | int rc; | 2796 | int rc; |
| 2899 | unsigned char *data; | 2797 | unsigned char *data; |
| @@ -2949,8 +2847,7 @@ xbm_load_image (f, img, contents, end) | |||
| 2949 | /* Value is non-zero if DATA looks like an in-memory XBM file. */ | 2847 | /* Value is non-zero if DATA looks like an in-memory XBM file. */ |
| 2950 | 2848 | ||
| 2951 | static int | 2849 | static int |
| 2952 | xbm_file_p (data) | 2850 | xbm_file_p (Lisp_Object data) |
| 2953 | Lisp_Object data; | ||
| 2954 | { | 2851 | { |
| 2955 | int w, h; | 2852 | int w, h; |
| 2956 | return (STRINGP (data) | 2853 | return (STRINGP (data) |
| @@ -2964,9 +2861,7 @@ xbm_file_p (data) | |||
| 2964 | non-zero if successful. */ | 2861 | non-zero if successful. */ |
| 2965 | 2862 | ||
| 2966 | static int | 2863 | static int |
| 2967 | xbm_load (f, img) | 2864 | xbm_load (struct frame *f, struct image *img) |
| 2968 | struct frame *f; | ||
| 2969 | struct image *img; | ||
| 2970 | { | 2865 | { |
| 2971 | int success_p = 0; | 2866 | int success_p = 0; |
| 2972 | Lisp_Object file_name; | 2867 | Lisp_Object file_name; |
| @@ -3018,7 +2913,7 @@ xbm_load (f, img) | |||
| 3018 | in_memory_file_p = xbm_file_p (data); | 2913 | in_memory_file_p = xbm_file_p (data); |
| 3019 | 2914 | ||
| 3020 | /* Parse the image specification. */ | 2915 | /* Parse the image specification. */ |
| 3021 | bcopy (xbm_format, fmt, sizeof fmt); | 2916 | memcpy (fmt, xbm_format, sizeof fmt); |
| 3022 | parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm); | 2917 | parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm); |
| 3023 | xassert (parsed_p); | 2918 | xassert (parsed_p); |
| 3024 | 2919 | ||
| @@ -3064,9 +2959,9 @@ xbm_load (f, img) | |||
| 3064 | { | 2959 | { |
| 3065 | Lisp_Object line = XVECTOR (data)->contents[i]; | 2960 | Lisp_Object line = XVECTOR (data)->contents[i]; |
| 3066 | if (STRINGP (line)) | 2961 | if (STRINGP (line)) |
| 3067 | bcopy (SDATA (line), p, nbytes); | 2962 | memcpy (p, SDATA (line), nbytes); |
| 3068 | else | 2963 | else |
| 3069 | bcopy (XBOOL_VECTOR (line)->data, p, nbytes); | 2964 | memcpy (p, XBOOL_VECTOR (line)->data, nbytes); |
| 3070 | } | 2965 | } |
| 3071 | } | 2966 | } |
| 3072 | else if (STRINGP (data)) | 2967 | else if (STRINGP (data)) |
| @@ -3082,7 +2977,7 @@ xbm_load (f, img) | |||
| 3082 | invertedBits = bits; | 2977 | invertedBits = bits; |
| 3083 | nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR | 2978 | nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR |
| 3084 | * img->height; | 2979 | * img->height; |
| 3085 | bits = (char *) alloca(nbytes); | 2980 | bits = (char *) alloca (nbytes); |
| 3086 | for (i = 0; i < nbytes; i++) | 2981 | for (i = 0; i < nbytes; i++) |
| 3087 | bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); | 2982 | bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); |
| 3088 | } | 2983 | } |
| @@ -3114,9 +3009,9 @@ xbm_load (f, img) | |||
| 3114 | 3009 | ||
| 3115 | #if defined (HAVE_XPM) || defined (HAVE_NS) | 3010 | #if defined (HAVE_XPM) || defined (HAVE_NS) |
| 3116 | 3011 | ||
| 3117 | static int xpm_image_p P_ ((Lisp_Object object)); | 3012 | static int xpm_image_p (Lisp_Object object); |
| 3118 | static int xpm_load P_ ((struct frame *f, struct image *img)); | 3013 | static int xpm_load (struct frame *f, struct image *img); |
| 3119 | static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); | 3014 | static int xpm_valid_color_symbols_p (Lisp_Object); |
| 3120 | 3015 | ||
| 3121 | #endif /* HAVE_XPM || HAVE_NS */ | 3016 | #endif /* HAVE_XPM || HAVE_NS */ |
| 3122 | 3017 | ||
| @@ -3207,12 +3102,12 @@ static struct image_type xpm_type = | |||
| 3207 | 3102 | ||
| 3208 | #ifdef ALLOC_XPM_COLORS | 3103 | #ifdef ALLOC_XPM_COLORS |
| 3209 | 3104 | ||
| 3210 | static void xpm_init_color_cache P_ ((struct frame *, XpmAttributes *)); | 3105 | static void xpm_init_color_cache (struct frame *, XpmAttributes *); |
| 3211 | static void xpm_free_color_cache P_ ((void)); | 3106 | static void xpm_free_color_cache (void); |
| 3212 | static int xpm_lookup_color P_ ((struct frame *, char *, XColor *)); | 3107 | static int xpm_lookup_color (struct frame *, char *, XColor *); |
| 3213 | static int xpm_color_bucket P_ ((char *)); | 3108 | static int xpm_color_bucket (char *); |
| 3214 | static struct xpm_cached_color *xpm_cache_color P_ ((struct frame *, char *, | 3109 | static struct xpm_cached_color *xpm_cache_color (struct frame *, char *, |
| 3215 | XColor *, int)); | 3110 | XColor *, int); |
| 3216 | 3111 | ||
| 3217 | /* An entry in a hash table used to cache color definitions of named | 3112 | /* An entry in a hash table used to cache color definitions of named |
| 3218 | colors. This cache is necessary to speed up XPM image loading in | 3113 | colors. This cache is necessary to speed up XPM image loading in |
| @@ -3240,9 +3135,7 @@ struct xpm_cached_color **xpm_color_cache; | |||
| 3240 | /* Initialize the color cache. */ | 3135 | /* Initialize the color cache. */ |
| 3241 | 3136 | ||
| 3242 | static void | 3137 | static void |
| 3243 | xpm_init_color_cache (f, attrs) | 3138 | xpm_init_color_cache (struct frame *f, XpmAttributes *attrs) |
| 3244 | struct frame *f; | ||
| 3245 | XpmAttributes *attrs; | ||
| 3246 | { | 3139 | { |
| 3247 | size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache; | 3140 | size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache; |
| 3248 | xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes); | 3141 | xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes); |
| @@ -3268,7 +3161,7 @@ xpm_init_color_cache (f, attrs) | |||
| 3268 | /* Free the color cache. */ | 3161 | /* Free the color cache. */ |
| 3269 | 3162 | ||
| 3270 | static void | 3163 | static void |
| 3271 | xpm_free_color_cache () | 3164 | xpm_free_color_cache (void) |
| 3272 | { | 3165 | { |
| 3273 | struct xpm_cached_color *p, *next; | 3166 | struct xpm_cached_color *p, *next; |
| 3274 | int i; | 3167 | int i; |
| @@ -3289,8 +3182,7 @@ xpm_free_color_cache () | |||
| 3289 | cache. */ | 3182 | cache. */ |
| 3290 | 3183 | ||
| 3291 | static int | 3184 | static int |
| 3292 | xpm_color_bucket (color_name) | 3185 | xpm_color_bucket (char *color_name) |
| 3293 | char *color_name; | ||
| 3294 | { | 3186 | { |
| 3295 | unsigned h = 0; | 3187 | unsigned h = 0; |
| 3296 | char *s; | 3188 | char *s; |
| @@ -3306,11 +3198,7 @@ xpm_color_bucket (color_name) | |||
| 3306 | entry added. */ | 3198 | entry added. */ |
| 3307 | 3199 | ||
| 3308 | static struct xpm_cached_color * | 3200 | static struct xpm_cached_color * |
| 3309 | xpm_cache_color (f, color_name, color, bucket) | 3201 | xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket) |
| 3310 | struct frame *f; | ||
| 3311 | char *color_name; | ||
| 3312 | XColor *color; | ||
| 3313 | int bucket; | ||
| 3314 | { | 3202 | { |
| 3315 | size_t nbytes; | 3203 | size_t nbytes; |
| 3316 | struct xpm_cached_color *p; | 3204 | struct xpm_cached_color *p; |
| @@ -3333,10 +3221,7 @@ xpm_cache_color (f, color_name, color, bucket) | |||
| 3333 | allocation failed. */ | 3221 | allocation failed. */ |
| 3334 | 3222 | ||
| 3335 | static int | 3223 | static int |
| 3336 | xpm_lookup_color (f, color_name, color) | 3224 | xpm_lookup_color (struct frame *f, char *color_name, XColor *color) |
| 3337 | struct frame *f; | ||
| 3338 | char *color_name; | ||
| 3339 | XColor *color; | ||
| 3340 | { | 3225 | { |
| 3341 | struct xpm_cached_color *p; | 3226 | struct xpm_cached_color *p; |
| 3342 | int h = xpm_color_bucket (color_name); | 3227 | int h = xpm_color_bucket (color_name); |
| @@ -3358,7 +3243,7 @@ xpm_lookup_color (f, color_name, color) | |||
| 3358 | with transparency, and it's useful. */ | 3243 | with transparency, and it's useful. */ |
| 3359 | else if (strcmp ("opaque", color_name) == 0) | 3244 | else if (strcmp ("opaque", color_name) == 0) |
| 3360 | { | 3245 | { |
| 3361 | bzero (color, sizeof (XColor)); /* Is this necessary/correct? */ | 3246 | memset (color, 0, sizeof (XColor)); /* Is this necessary/correct? */ |
| 3362 | color->pixel = FRAME_FOREGROUND_PIXEL (f); | 3247 | color->pixel = FRAME_FOREGROUND_PIXEL (f); |
| 3363 | p = xpm_cache_color (f, color_name, color, h); | 3248 | p = xpm_cache_color (f, color_name, color, h); |
| 3364 | } | 3249 | } |
| @@ -3373,12 +3258,8 @@ xpm_lookup_color (f, color_name, color) | |||
| 3373 | if successful. */ | 3258 | if successful. */ |
| 3374 | 3259 | ||
| 3375 | static int | 3260 | static int |
| 3376 | xpm_alloc_color (dpy, cmap, color_name, color, closure) | 3261 | xpm_alloc_color (Display *dpy, Colormap cmap, char *color_name, XColor *color, |
| 3377 | Display *dpy; | 3262 | void *closure) |
| 3378 | Colormap cmap; | ||
| 3379 | char *color_name; | ||
| 3380 | XColor *color; | ||
| 3381 | void *closure; | ||
| 3382 | { | 3263 | { |
| 3383 | return xpm_lookup_color ((struct frame *) closure, color_name, color); | 3264 | return xpm_lookup_color ((struct frame *) closure, color_name, color); |
| 3384 | } | 3265 | } |
| @@ -3389,12 +3270,7 @@ xpm_alloc_color (dpy, cmap, color_name, color, closure) | |||
| 3389 | non-zero if successful. */ | 3270 | non-zero if successful. */ |
| 3390 | 3271 | ||
| 3391 | static int | 3272 | static int |
| 3392 | xpm_free_colors (dpy, cmap, pixels, npixels, closure) | 3273 | xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *closure) |
| 3393 | Display *dpy; | ||
| 3394 | Colormap cmap; | ||
| 3395 | Pixel *pixels; | ||
| 3396 | int npixels; | ||
| 3397 | void *closure; | ||
| 3398 | { | 3274 | { |
| 3399 | return 1; | 3275 | return 1; |
| 3400 | } | 3276 | } |
| @@ -3434,8 +3310,7 @@ init_xpm_functions (Lisp_Object libraries) | |||
| 3434 | cdr are strings. */ | 3310 | cdr are strings. */ |
| 3435 | 3311 | ||
| 3436 | static int | 3312 | static int |
| 3437 | xpm_valid_color_symbols_p (color_symbols) | 3313 | xpm_valid_color_symbols_p (Lisp_Object color_symbols) |
| 3438 | Lisp_Object color_symbols; | ||
| 3439 | { | 3314 | { |
| 3440 | while (CONSP (color_symbols)) | 3315 | while (CONSP (color_symbols)) |
| 3441 | { | 3316 | { |
| @@ -3454,11 +3329,10 @@ xpm_valid_color_symbols_p (color_symbols) | |||
| 3454 | /* Value is non-zero if OBJECT is a valid XPM image specification. */ | 3329 | /* Value is non-zero if OBJECT is a valid XPM image specification. */ |
| 3455 | 3330 | ||
| 3456 | static int | 3331 | static int |
| 3457 | xpm_image_p (object) | 3332 | xpm_image_p (Lisp_Object object) |
| 3458 | Lisp_Object object; | ||
| 3459 | { | 3333 | { |
| 3460 | struct image_keyword fmt[XPM_LAST]; | 3334 | struct image_keyword fmt[XPM_LAST]; |
| 3461 | bcopy (xpm_format, fmt, sizeof fmt); | 3335 | memcpy (fmt, xpm_format, sizeof fmt); |
| 3462 | return (parse_image_spec (object, fmt, XPM_LAST, Qxpm) | 3336 | return (parse_image_spec (object, fmt, XPM_LAST, Qxpm) |
| 3463 | /* Either `:file' or `:data' must be present. */ | 3337 | /* Either `:file' or `:data' must be present. */ |
| 3464 | && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 | 3338 | && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 |
| @@ -3472,16 +3346,14 @@ xpm_image_p (object) | |||
| 3472 | 3346 | ||
| 3473 | #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) | 3347 | #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) |
| 3474 | int | 3348 | int |
| 3475 | x_create_bitmap_from_xpm_data (f, bits) | 3349 | x_create_bitmap_from_xpm_data (struct frame *f, char **bits) |
| 3476 | struct frame *f; | ||
| 3477 | char **bits; | ||
| 3478 | { | 3350 | { |
| 3479 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 3351 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 3480 | int id, rc; | 3352 | int id, rc; |
| 3481 | XpmAttributes attrs; | 3353 | XpmAttributes attrs; |
| 3482 | Pixmap bitmap, mask; | 3354 | Pixmap bitmap, mask; |
| 3483 | 3355 | ||
| 3484 | bzero (&attrs, sizeof attrs); | 3356 | memset (&attrs, 0, sizeof attrs); |
| 3485 | 3357 | ||
| 3486 | attrs.visual = FRAME_X_VISUAL (f); | 3358 | attrs.visual = FRAME_X_VISUAL (f); |
| 3487 | attrs.colormap = FRAME_X_COLORMAP (f); | 3359 | attrs.colormap = FRAME_X_COLORMAP (f); |
| @@ -3517,9 +3389,7 @@ x_create_bitmap_from_xpm_data (f, bits) | |||
| 3517 | #ifdef HAVE_XPM | 3389 | #ifdef HAVE_XPM |
| 3518 | 3390 | ||
| 3519 | static int | 3391 | static int |
| 3520 | xpm_load (f, img) | 3392 | xpm_load (struct frame *f, struct image *img) |
| 3521 | struct frame *f; | ||
| 3522 | struct image *img; | ||
| 3523 | { | 3393 | { |
| 3524 | int rc; | 3394 | int rc; |
| 3525 | XpmAttributes attrs; | 3395 | XpmAttributes attrs; |
| @@ -3531,7 +3401,7 @@ xpm_load (f, img) | |||
| 3531 | 3401 | ||
| 3532 | /* Configure the XPM lib. Use the visual of frame F. Allocate | 3402 | /* Configure the XPM lib. Use the visual of frame F. Allocate |
| 3533 | close colors. Return colors allocated. */ | 3403 | close colors. Return colors allocated. */ |
| 3534 | bzero (&attrs, sizeof attrs); | 3404 | memset (&attrs, 0, sizeof attrs); |
| 3535 | 3405 | ||
| 3536 | #ifndef HAVE_NTGUI | 3406 | #ifndef HAVE_NTGUI |
| 3537 | attrs.visual = FRAME_X_VISUAL (f); | 3407 | attrs.visual = FRAME_X_VISUAL (f); |
| @@ -3578,7 +3448,7 @@ xpm_load (f, img) | |||
| 3578 | /* Allocate an XpmColorSymbol array. */ | 3448 | /* Allocate an XpmColorSymbol array. */ |
| 3579 | size = attrs.numsymbols * sizeof *xpm_syms; | 3449 | size = attrs.numsymbols * sizeof *xpm_syms; |
| 3580 | xpm_syms = (XpmColorSymbol *) alloca (size); | 3450 | xpm_syms = (XpmColorSymbol *) alloca (size); |
| 3581 | bzero (xpm_syms, size); | 3451 | memset (xpm_syms, 0, size); |
| 3582 | attrs.colorsymbols = xpm_syms; | 3452 | attrs.colorsymbols = xpm_syms; |
| 3583 | 3453 | ||
| 3584 | /* Fill the color symbol array. */ | 3454 | /* Fill the color symbol array. */ |
| @@ -3752,25 +3622,25 @@ xpm_load (f, img) | |||
| 3752 | /* XPM support functions for NS where libxpm is not available. | 3622 | /* XPM support functions for NS where libxpm is not available. |
| 3753 | Only XPM version 3 (without any extensions) is supported. */ | 3623 | Only XPM version 3 (without any extensions) is supported. */ |
| 3754 | 3624 | ||
| 3755 | static int xpm_scan P_ ((const unsigned char **, const unsigned char *, | 3625 | static int xpm_scan (const unsigned char **, const unsigned char *, |
| 3756 | const unsigned char **, int *)); | 3626 | const unsigned char **, int *); |
| 3757 | static Lisp_Object xpm_make_color_table_v | 3627 | static Lisp_Object xpm_make_color_table_v |
| 3758 | P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), | 3628 | (void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), |
| 3759 | Lisp_Object (**) (Lisp_Object, const unsigned char *, int))); | 3629 | Lisp_Object (**) (Lisp_Object, const unsigned char *, int)); |
| 3760 | static void xpm_put_color_table_v P_ ((Lisp_Object, const unsigned char *, | 3630 | static void xpm_put_color_table_v (Lisp_Object, const unsigned char *, |
| 3761 | int, Lisp_Object)); | 3631 | int, Lisp_Object); |
| 3762 | static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object, | 3632 | static Lisp_Object xpm_get_color_table_v (Lisp_Object, |
| 3763 | const unsigned char *, int)); | 3633 | const unsigned char *, int); |
| 3764 | static Lisp_Object xpm_make_color_table_h | 3634 | static Lisp_Object xpm_make_color_table_h |
| 3765 | P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), | 3635 | (void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), |
| 3766 | Lisp_Object (**) (Lisp_Object, const unsigned char *, int))); | 3636 | Lisp_Object (**) (Lisp_Object, const unsigned char *, int)); |
| 3767 | static void xpm_put_color_table_h P_ ((Lisp_Object, const unsigned char *, | 3637 | static void xpm_put_color_table_h (Lisp_Object, const unsigned char *, |
| 3768 | int, Lisp_Object)); | 3638 | int, Lisp_Object); |
| 3769 | static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object, | 3639 | static Lisp_Object xpm_get_color_table_h (Lisp_Object, |
| 3770 | const unsigned char *, int)); | 3640 | const unsigned char *, int); |
| 3771 | static int xpm_str_to_color_key P_ ((const char *)); | 3641 | static int xpm_str_to_color_key (const char *); |
| 3772 | static int xpm_load_image P_ ((struct frame *, struct image *, | 3642 | static int xpm_load_image (struct frame *, struct image *, |
| 3773 | const unsigned char *, const unsigned char *)); | 3643 | const unsigned char *, const unsigned char *); |
| 3774 | 3644 | ||
| 3775 | /* Tokens returned from xpm_scan. */ | 3645 | /* Tokens returned from xpm_scan. */ |
| 3776 | 3646 | ||
| @@ -3789,9 +3659,10 @@ enum xpm_token | |||
| 3789 | length of the corresponding token, respectively. */ | 3659 | length of the corresponding token, respectively. */ |
| 3790 | 3660 | ||
| 3791 | static int | 3661 | static int |
| 3792 | xpm_scan (s, end, beg, len) | 3662 | xpm_scan (const unsigned char **s, |
| 3793 | const unsigned char **s, *end, **beg; | 3663 | const unsigned char *end, |
| 3794 | int *len; | 3664 | const unsigned char **beg, |
| 3665 | int *len) | ||
| 3795 | { | 3666 | { |
| 3796 | int c; | 3667 | int c; |
| 3797 | 3668 | ||
| @@ -3855,9 +3726,13 @@ xpm_scan (s, end, beg, len) | |||
| 3855 | hash table is used. */ | 3726 | hash table is used. */ |
| 3856 | 3727 | ||
| 3857 | static Lisp_Object | 3728 | static Lisp_Object |
| 3858 | xpm_make_color_table_v (put_func, get_func) | 3729 | xpm_make_color_table_v (void (**put_func) (Lisp_Object, |
| 3859 | void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); | 3730 | const unsigned char *, |
| 3860 | Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int); | 3731 | int, |
| 3732 | Lisp_Object), | ||
| 3733 | Lisp_Object (**get_func) (Lisp_Object, | ||
| 3734 | const unsigned char *, | ||
| 3735 | int)) | ||
| 3861 | { | 3736 | { |
| 3862 | *put_func = xpm_put_color_table_v; | 3737 | *put_func = xpm_put_color_table_v; |
| 3863 | *get_func = xpm_get_color_table_v; | 3738 | *get_func = xpm_get_color_table_v; |
| @@ -3865,28 +3740,30 @@ xpm_make_color_table_v (put_func, get_func) | |||
| 3865 | } | 3740 | } |
| 3866 | 3741 | ||
| 3867 | static void | 3742 | static void |
| 3868 | xpm_put_color_table_v (color_table, chars_start, chars_len, color) | 3743 | xpm_put_color_table_v (Lisp_Object color_table, |
| 3869 | Lisp_Object color_table; | 3744 | const unsigned char *chars_start, |
| 3870 | const unsigned char *chars_start; | 3745 | int chars_len, |
| 3871 | int chars_len; | 3746 | Lisp_Object color) |
| 3872 | Lisp_Object color; | ||
| 3873 | { | 3747 | { |
| 3874 | XVECTOR (color_table)->contents[*chars_start] = color; | 3748 | XVECTOR (color_table)->contents[*chars_start] = color; |
| 3875 | } | 3749 | } |
| 3876 | 3750 | ||
| 3877 | static Lisp_Object | 3751 | static Lisp_Object |
| 3878 | xpm_get_color_table_v (color_table, chars_start, chars_len) | 3752 | xpm_get_color_table_v (Lisp_Object color_table, |
| 3879 | Lisp_Object color_table; | 3753 | const unsigned char *chars_start, |
| 3880 | const unsigned char *chars_start; | 3754 | int chars_len) |
| 3881 | int chars_len; | ||
| 3882 | { | 3755 | { |
| 3883 | return XVECTOR (color_table)->contents[*chars_start]; | 3756 | return XVECTOR (color_table)->contents[*chars_start]; |
| 3884 | } | 3757 | } |
| 3885 | 3758 | ||
| 3886 | static Lisp_Object | 3759 | static Lisp_Object |
| 3887 | xpm_make_color_table_h (put_func, get_func) | 3760 | xpm_make_color_table_h (void (**put_func) (Lisp_Object, |
| 3888 | void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); | 3761 | const unsigned char *, |
| 3889 | Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int); | 3762 | int, |
| 3763 | Lisp_Object), | ||
| 3764 | Lisp_Object (**get_func) (Lisp_Object, | ||
| 3765 | const unsigned char *, | ||
| 3766 | int)) | ||
| 3890 | { | 3767 | { |
| 3891 | *put_func = xpm_put_color_table_h; | 3768 | *put_func = xpm_put_color_table_h; |
| 3892 | *get_func = xpm_get_color_table_h; | 3769 | *get_func = xpm_get_color_table_h; |
| @@ -3897,11 +3774,10 @@ xpm_make_color_table_h (put_func, get_func) | |||
| 3897 | } | 3774 | } |
| 3898 | 3775 | ||
| 3899 | static void | 3776 | static void |
| 3900 | xpm_put_color_table_h (color_table, chars_start, chars_len, color) | 3777 | xpm_put_color_table_h (Lisp_Object color_table, |
| 3901 | Lisp_Object color_table; | 3778 | const unsigned char *chars_start, |
| 3902 | const unsigned char *chars_start; | 3779 | int chars_len, |
| 3903 | int chars_len; | 3780 | Lisp_Object color) |
| 3904 | Lisp_Object color; | ||
| 3905 | { | 3781 | { |
| 3906 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); | 3782 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); |
| 3907 | unsigned hash_code; | 3783 | unsigned hash_code; |
| @@ -3912,10 +3788,9 @@ xpm_put_color_table_h (color_table, chars_start, chars_len, color) | |||
| 3912 | } | 3788 | } |
| 3913 | 3789 | ||
| 3914 | static Lisp_Object | 3790 | static Lisp_Object |
| 3915 | xpm_get_color_table_h (color_table, chars_start, chars_len) | 3791 | xpm_get_color_table_h (Lisp_Object color_table, |
| 3916 | Lisp_Object color_table; | 3792 | const unsigned char *chars_start, |
| 3917 | const unsigned char *chars_start; | 3793 | int chars_len) |
| 3918 | int chars_len; | ||
| 3919 | { | 3794 | { |
| 3920 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); | 3795 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); |
| 3921 | int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len), | 3796 | int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len), |
| @@ -3935,8 +3810,7 @@ enum xpm_color_key { | |||
| 3935 | static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"}; | 3810 | static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"}; |
| 3936 | 3811 | ||
| 3937 | static int | 3812 | static int |
| 3938 | xpm_str_to_color_key (s) | 3813 | xpm_str_to_color_key (const char *s) |
| 3939 | const char *s; | ||
| 3940 | { | 3814 | { |
| 3941 | int i; | 3815 | int i; |
| 3942 | 3816 | ||
| @@ -3949,10 +3823,10 @@ xpm_str_to_color_key (s) | |||
| 3949 | } | 3823 | } |
| 3950 | 3824 | ||
| 3951 | static int | 3825 | static int |
| 3952 | xpm_load_image (f, img, contents, end) | 3826 | xpm_load_image (struct frame *f, |
| 3953 | struct frame *f; | 3827 | struct image *img, |
| 3954 | struct image *img; | 3828 | const unsigned char *contents, |
| 3955 | const unsigned char *contents, *end; | 3829 | const unsigned char *end) |
| 3956 | { | 3830 | { |
| 3957 | const unsigned char *s = contents, *beg, *str; | 3831 | const unsigned char *s = contents, *beg, *str; |
| 3958 | unsigned char buffer[BUFSIZ]; | 3832 | unsigned char buffer[BUFSIZ]; |
| @@ -3984,7 +3858,7 @@ xpm_load_image (f, img, contents, end) | |||
| 3984 | if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0)) | 3858 | if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0)) |
| 3985 | goto failure; | 3859 | goto failure; |
| 3986 | s += 9; | 3860 | s += 9; |
| 3987 | match(); | 3861 | match (); |
| 3988 | expect_ident ("static"); | 3862 | expect_ident ("static"); |
| 3989 | expect_ident ("char"); | 3863 | expect_ident ("char"); |
| 3990 | expect ('*'); | 3864 | expect ('*'); |
| @@ -4134,8 +4008,8 @@ xpm_load_image (f, img, contents, end) | |||
| 4134 | (!EQ (color_val, Qt) ? PIX_MASK_DRAW | 4008 | (!EQ (color_val, Qt) ? PIX_MASK_DRAW |
| 4135 | : (have_mask = 1, PIX_MASK_RETAIN))); | 4009 | : (have_mask = 1, PIX_MASK_RETAIN))); |
| 4136 | #else | 4010 | #else |
| 4137 | if (EQ(color_val, Qt)) | 4011 | if (EQ (color_val, Qt)) |
| 4138 | ns_set_alpha(ximg, x, y, 0); | 4012 | ns_set_alpha (ximg, x, y, 0); |
| 4139 | #endif | 4013 | #endif |
| 4140 | } | 4014 | } |
| 4141 | if (y + 1 < height) | 4015 | if (y + 1 < height) |
| @@ -4184,9 +4058,8 @@ xpm_load_image (f, img, contents, end) | |||
| 4184 | } | 4058 | } |
| 4185 | 4059 | ||
| 4186 | static int | 4060 | static int |
| 4187 | xpm_load (f, img) | 4061 | xpm_load (struct frame *f, |
| 4188 | struct frame *f; | 4062 | struct image *img) |
| 4189 | struct image *img; | ||
| 4190 | { | 4063 | { |
| 4191 | int success_p = 0; | 4064 | int success_p = 0; |
| 4192 | Lisp_Object file_name; | 4065 | Lisp_Object file_name; |
| @@ -4273,11 +4146,11 @@ int ct_colors_allocated; | |||
| 4273 | /* Initialize the color table. */ | 4146 | /* Initialize the color table. */ |
| 4274 | 4147 | ||
| 4275 | static void | 4148 | static void |
| 4276 | init_color_table () | 4149 | init_color_table (void) |
| 4277 | { | 4150 | { |
| 4278 | int size = CT_SIZE * sizeof (*ct_table); | 4151 | int size = CT_SIZE * sizeof (*ct_table); |
| 4279 | ct_table = (struct ct_color **) xmalloc (size); | 4152 | ct_table = (struct ct_color **) xmalloc (size); |
| 4280 | bzero (ct_table, size); | 4153 | memset (ct_table, 0, size); |
| 4281 | ct_colors_allocated = 0; | 4154 | ct_colors_allocated = 0; |
| 4282 | } | 4155 | } |
| 4283 | 4156 | ||
| @@ -4285,7 +4158,7 @@ init_color_table () | |||
| 4285 | /* Free memory associated with the color table. */ | 4158 | /* Free memory associated with the color table. */ |
| 4286 | 4159 | ||
| 4287 | static void | 4160 | static void |
| 4288 | free_color_table () | 4161 | free_color_table (void) |
| 4289 | { | 4162 | { |
| 4290 | int i; | 4163 | int i; |
| 4291 | struct ct_color *p, *next; | 4164 | struct ct_color *p, *next; |
| @@ -4308,9 +4181,7 @@ free_color_table () | |||
| 4308 | G, B, and make an entry in the color table. */ | 4181 | G, B, and make an entry in the color table. */ |
| 4309 | 4182 | ||
| 4310 | static unsigned long | 4183 | static unsigned long |
| 4311 | lookup_rgb_color (f, r, g, b) | 4184 | lookup_rgb_color (struct frame *f, int r, int g, int b) |
| 4312 | struct frame *f; | ||
| 4313 | int r, g, b; | ||
| 4314 | { | 4185 | { |
| 4315 | unsigned hash = CT_HASH_RGB (r, g, b); | 4186 | unsigned hash = CT_HASH_RGB (r, g, b); |
| 4316 | int i = hash % CT_SIZE; | 4187 | int i = hash % CT_SIZE; |
| @@ -4405,9 +4276,7 @@ lookup_rgb_color (f, r, g, b) | |||
| 4405 | table. If not already present, allocate it. Value is PIXEL. */ | 4276 | table. If not already present, allocate it. Value is PIXEL. */ |
| 4406 | 4277 | ||
| 4407 | static unsigned long | 4278 | static unsigned long |
| 4408 | lookup_pixel_color (f, pixel) | 4279 | lookup_pixel_color (struct frame *f, unsigned long pixel) |
| 4409 | struct frame *f; | ||
| 4410 | unsigned long pixel; | ||
| 4411 | { | 4280 | { |
| 4412 | int i = pixel % CT_SIZE; | 4281 | int i = pixel % CT_SIZE; |
| 4413 | struct ct_color *p; | 4282 | struct ct_color *p; |
| @@ -4459,8 +4328,7 @@ lookup_pixel_color (f, pixel) | |||
| 4459 | allocated via xmalloc. Set *N to the number of colors. */ | 4328 | allocated via xmalloc. Set *N to the number of colors. */ |
| 4460 | 4329 | ||
| 4461 | static unsigned long * | 4330 | static unsigned long * |
| 4462 | colors_in_color_table (n) | 4331 | colors_in_color_table (int *n) |
| 4463 | int *n; | ||
| 4464 | { | 4332 | { |
| 4465 | int i, j; | 4333 | int i, j; |
| 4466 | struct ct_color *p; | 4334 | struct ct_color *p; |
| @@ -4488,9 +4356,7 @@ colors_in_color_table (n) | |||
| 4488 | #else /* COLOR_TABLE_SUPPORT */ | 4356 | #else /* COLOR_TABLE_SUPPORT */ |
| 4489 | 4357 | ||
| 4490 | static unsigned long | 4358 | static unsigned long |
| 4491 | lookup_rgb_color (f, r, g, b) | 4359 | lookup_rgb_color (struct frame *f, int r, int g, int b) |
| 4492 | struct frame *f; | ||
| 4493 | int r, g, b; | ||
| 4494 | { | 4360 | { |
| 4495 | unsigned long pixel; | 4361 | unsigned long pixel; |
| 4496 | 4362 | ||
| @@ -4505,7 +4371,7 @@ lookup_rgb_color (f, r, g, b) | |||
| 4505 | } | 4371 | } |
| 4506 | 4372 | ||
| 4507 | static void | 4373 | static void |
| 4508 | init_color_table () | 4374 | init_color_table (void) |
| 4509 | { | 4375 | { |
| 4510 | } | 4376 | } |
| 4511 | #endif /* COLOR_TABLE_SUPPORT */ | 4377 | #endif /* COLOR_TABLE_SUPPORT */ |
| @@ -4515,9 +4381,9 @@ init_color_table () | |||
| 4515 | Algorithms | 4381 | Algorithms |
| 4516 | ***********************************************************************/ | 4382 | ***********************************************************************/ |
| 4517 | 4383 | ||
| 4518 | static XColor *x_to_xcolors P_ ((struct frame *, struct image *, int)); | 4384 | static XColor *x_to_xcolors (struct frame *, struct image *, int); |
| 4519 | static void x_from_xcolors P_ ((struct frame *, struct image *, XColor *)); | 4385 | static void x_from_xcolors (struct frame *, struct image *, XColor *); |
| 4520 | static void x_detect_edges P_ ((struct frame *, struct image *, int[9], int)); | 4386 | static void x_detect_edges (struct frame *, struct image *, int[9], int); |
| 4521 | 4387 | ||
| 4522 | #ifdef HAVE_NTGUI | 4388 | #ifdef HAVE_NTGUI |
| 4523 | static void XPutPixel (XImagePtr , int, int, COLORREF); | 4389 | static void XPutPixel (XImagePtr , int, int, COLORREF); |
| @@ -4558,10 +4424,7 @@ static int laplace_matrix[9] = { | |||
| 4558 | allocated with xmalloc; it must be freed by the caller. */ | 4424 | allocated with xmalloc; it must be freed by the caller. */ |
| 4559 | 4425 | ||
| 4560 | static XColor * | 4426 | static XColor * |
| 4561 | x_to_xcolors (f, img, rgb_p) | 4427 | x_to_xcolors (struct frame *f, struct image *img, int rgb_p) |
| 4562 | struct frame *f; | ||
| 4563 | struct image *img; | ||
| 4564 | int rgb_p; | ||
| 4565 | { | 4428 | { |
| 4566 | int x, y; | 4429 | int x, y; |
| 4567 | XColor *colors, *p; | 4430 | XColor *colors, *p; |
| @@ -4626,10 +4489,7 @@ x_to_xcolors (f, img, rgb_p) | |||
| 4626 | stored in ximg->data. */ | 4489 | stored in ximg->data. */ |
| 4627 | 4490 | ||
| 4628 | static void | 4491 | static void |
| 4629 | XPutPixel (ximg, x, y, color) | 4492 | XPutPixel (XImagePtr ximg, int x, int y, COLORREF color) |
| 4630 | XImagePtr ximg; | ||
| 4631 | int x, y; | ||
| 4632 | COLORREF color; | ||
| 4633 | { | 4493 | { |
| 4634 | int width = ximg->info.bmiHeader.biWidth; | 4494 | int width = ximg->info.bmiHeader.biWidth; |
| 4635 | int height = ximg->info.bmiHeader.biHeight; | 4495 | int height = ximg->info.bmiHeader.biHeight; |
| @@ -4674,10 +4534,7 @@ XPutPixel (ximg, x, y, color) | |||
| 4674 | COLORS will be freed; an existing IMG->pixmap will be freed, too. */ | 4534 | COLORS will be freed; an existing IMG->pixmap will be freed, too. */ |
| 4675 | 4535 | ||
| 4676 | static void | 4536 | static void |
| 4677 | x_from_xcolors (f, img, colors) | 4537 | x_from_xcolors (struct frame *f, struct image *img, XColor *colors) |
| 4678 | struct frame *f; | ||
| 4679 | struct image *img; | ||
| 4680 | XColor *colors; | ||
| 4681 | { | 4538 | { |
| 4682 | int x, y; | 4539 | int x, y; |
| 4683 | XImagePtr oimg = NULL; | 4540 | XImagePtr oimg = NULL; |
| @@ -4719,10 +4576,7 @@ x_from_xcolors (f, img, colors) | |||
| 4719 | outgoing image. */ | 4576 | outgoing image. */ |
| 4720 | 4577 | ||
| 4721 | static void | 4578 | static void |
| 4722 | x_detect_edges (f, img, matrix, color_adjust) | 4579 | x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjust) |
| 4723 | struct frame *f; | ||
| 4724 | struct image *img; | ||
| 4725 | int matrix[9], color_adjust; | ||
| 4726 | { | 4580 | { |
| 4727 | XColor *colors = x_to_xcolors (f, img, 1); | 4581 | XColor *colors = x_to_xcolors (f, img, 1); |
| 4728 | XColor *new, *p; | 4582 | XColor *new, *p; |
| @@ -4788,9 +4642,7 @@ x_detect_edges (f, img, matrix, color_adjust) | |||
| 4788 | on frame F. */ | 4642 | on frame F. */ |
| 4789 | 4643 | ||
| 4790 | static void | 4644 | static void |
| 4791 | x_emboss (f, img) | 4645 | x_emboss (struct frame *f, struct image *img) |
| 4792 | struct frame *f; | ||
| 4793 | struct image *img; | ||
| 4794 | { | 4646 | { |
| 4795 | x_detect_edges (f, img, emboss_matrix, 0xffff / 2); | 4647 | x_detect_edges (f, img, emboss_matrix, 0xffff / 2); |
| 4796 | } | 4648 | } |
| @@ -4801,9 +4653,7 @@ x_emboss (f, img) | |||
| 4801 | to draw disabled buttons, for example. */ | 4653 | to draw disabled buttons, for example. */ |
| 4802 | 4654 | ||
| 4803 | static void | 4655 | static void |
| 4804 | x_laplace (f, img) | 4656 | x_laplace (struct frame *f, struct image *img) |
| 4805 | struct frame *f; | ||
| 4806 | struct image *img; | ||
| 4807 | { | 4657 | { |
| 4808 | x_detect_edges (f, img, laplace_matrix, 45000); | 4658 | x_detect_edges (f, img, laplace_matrix, 45000); |
| 4809 | } | 4659 | } |
| @@ -4821,10 +4671,8 @@ x_laplace (f, img) | |||
| 4821 | number. */ | 4671 | number. */ |
| 4822 | 4672 | ||
| 4823 | static void | 4673 | static void |
| 4824 | x_edge_detection (f, img, matrix, color_adjust) | 4674 | x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix, |
| 4825 | struct frame *f; | 4675 | Lisp_Object color_adjust) |
| 4826 | struct image *img; | ||
| 4827 | Lisp_Object matrix, color_adjust; | ||
| 4828 | { | 4676 | { |
| 4829 | int i = 0; | 4677 | int i = 0; |
| 4830 | int trans[9]; | 4678 | int trans[9]; |
| @@ -4853,9 +4701,7 @@ x_edge_detection (f, img, matrix, color_adjust) | |||
| 4853 | /* Transform image IMG on frame F so that it looks disabled. */ | 4701 | /* Transform image IMG on frame F so that it looks disabled. */ |
| 4854 | 4702 | ||
| 4855 | static void | 4703 | static void |
| 4856 | x_disable_image (f, img) | 4704 | x_disable_image (struct frame *f, struct image *img) |
| 4857 | struct frame *f; | ||
| 4858 | struct image *img; | ||
| 4859 | { | 4705 | { |
| 4860 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 4706 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 4861 | #ifdef HAVE_NTGUI | 4707 | #ifdef HAVE_NTGUI |
| @@ -4957,10 +4803,7 @@ x_disable_image (f, img) | |||
| 4957 | heuristically. Value is non-zero if successful. */ | 4803 | heuristically. Value is non-zero if successful. */ |
| 4958 | 4804 | ||
| 4959 | static int | 4805 | static int |
| 4960 | x_build_heuristic_mask (f, img, how) | 4806 | x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how) |
| 4961 | struct frame *f; | ||
| 4962 | struct image *img; | ||
| 4963 | Lisp_Object how; | ||
| 4964 | { | 4807 | { |
| 4965 | XImagePtr_or_DC ximg; | 4808 | XImagePtr_or_DC ximg; |
| 4966 | #ifndef HAVE_NTGUI | 4809 | #ifndef HAVE_NTGUI |
| @@ -4998,7 +4841,7 @@ x_build_heuristic_mask (f, img, how) | |||
| 4998 | /* Create the bit array serving as mask. */ | 4841 | /* Create the bit array serving as mask. */ |
| 4999 | row_width = (img->width + 7) / 8; | 4842 | row_width = (img->width + 7) / 8; |
| 5000 | mask_img = xmalloc (row_width * img->height); | 4843 | mask_img = xmalloc (row_width * img->height); |
| 5001 | bzero (mask_img, row_width * img->height); | 4844 | memset (mask_img, 0, row_width * img->height); |
| 5002 | 4845 | ||
| 5003 | /* Create a memory device context for IMG->pixmap. */ | 4846 | /* Create a memory device context for IMG->pixmap. */ |
| 5004 | frame_dc = get_frame_dc (f); | 4847 | frame_dc = get_frame_dc (f); |
| @@ -5046,8 +4889,8 @@ x_build_heuristic_mask (f, img, how) | |||
| 5046 | XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg | 4889 | XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg |
| 5047 | ? PIX_MASK_DRAW : PIX_MASK_RETAIN)); | 4890 | ? PIX_MASK_DRAW : PIX_MASK_RETAIN)); |
| 5048 | #else | 4891 | #else |
| 5049 | if (XGetPixel (ximg, x, y) == bg) | 4892 | if (XGetPixel (ximg, x, y) == bg) |
| 5050 | ns_set_alpha(ximg, x, y, 0); | 4893 | ns_set_alpha (ximg, x, y, 0); |
| 5051 | #endif /* HAVE_NS */ | 4894 | #endif /* HAVE_NS */ |
| 5052 | #ifndef HAVE_NS | 4895 | #ifndef HAVE_NS |
| 5053 | /* Fill in the background_transparent field while we have the mask handy. */ | 4896 | /* Fill in the background_transparent field while we have the mask handy. */ |
| @@ -5087,9 +4930,9 @@ x_build_heuristic_mask (f, img, how) | |||
| 5087 | PBM (mono, gray, color) | 4930 | PBM (mono, gray, color) |
| 5088 | ***********************************************************************/ | 4931 | ***********************************************************************/ |
| 5089 | 4932 | ||
| 5090 | static int pbm_image_p P_ ((Lisp_Object object)); | 4933 | static int pbm_image_p (Lisp_Object object); |
| 5091 | static int pbm_load P_ ((struct frame *f, struct image *img)); | 4934 | static int pbm_load (struct frame *f, struct image *img); |
| 5092 | static int pbm_scan_number P_ ((unsigned char **, unsigned char *)); | 4935 | static int pbm_scan_number (unsigned char **, unsigned char *); |
| 5093 | 4936 | ||
| 5094 | /* The symbol `pbm' identifying images of this type. */ | 4937 | /* The symbol `pbm' identifying images of this type. */ |
| 5095 | 4938 | ||
| @@ -5146,12 +4989,11 @@ static struct image_type pbm_type = | |||
| 5146 | /* Return non-zero if OBJECT is a valid PBM image specification. */ | 4989 | /* Return non-zero if OBJECT is a valid PBM image specification. */ |
| 5147 | 4990 | ||
| 5148 | static int | 4991 | static int |
| 5149 | pbm_image_p (object) | 4992 | pbm_image_p (Lisp_Object object) |
| 5150 | Lisp_Object object; | ||
| 5151 | { | 4993 | { |
| 5152 | struct image_keyword fmt[PBM_LAST]; | 4994 | struct image_keyword fmt[PBM_LAST]; |
| 5153 | 4995 | ||
| 5154 | bcopy (pbm_format, fmt, sizeof fmt); | 4996 | memcpy (fmt, pbm_format, sizeof fmt); |
| 5155 | 4997 | ||
| 5156 | if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)) | 4998 | if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)) |
| 5157 | return 0; | 4999 | return 0; |
| @@ -5166,8 +5008,7 @@ pbm_image_p (object) | |||
| 5166 | end of input. */ | 5008 | end of input. */ |
| 5167 | 5009 | ||
| 5168 | static int | 5010 | static int |
| 5169 | pbm_scan_number (s, end) | 5011 | pbm_scan_number (unsigned char **s, unsigned char *end) |
| 5170 | unsigned char **s, *end; | ||
| 5171 | { | 5012 | { |
| 5172 | int c = 0, val = -1; | 5013 | int c = 0, val = -1; |
| 5173 | 5014 | ||
| @@ -5242,9 +5083,7 @@ pbm_read_file (file, size) | |||
| 5242 | /* Load PBM image IMG for use on frame F. */ | 5083 | /* Load PBM image IMG for use on frame F. */ |
| 5243 | 5084 | ||
| 5244 | static int | 5085 | static int |
| 5245 | pbm_load (f, img) | 5086 | pbm_load (struct frame *f, struct image *img) |
| 5246 | struct frame *f; | ||
| 5247 | struct image *img; | ||
| 5248 | { | 5087 | { |
| 5249 | int raw_p, x, y; | 5088 | int raw_p, x, y; |
| 5250 | int width, height, max_color_idx = 0; | 5089 | int width, height, max_color_idx = 0; |
| @@ -5366,7 +5205,7 @@ pbm_load (f, img) | |||
| 5366 | unsigned long bg = FRAME_BACKGROUND_PIXEL (f); | 5205 | unsigned long bg = FRAME_BACKGROUND_PIXEL (f); |
| 5367 | 5206 | ||
| 5368 | /* Parse the image specification. */ | 5207 | /* Parse the image specification. */ |
| 5369 | bcopy (pbm_format, fmt, sizeof fmt); | 5208 | memcpy (fmt, pbm_format, sizeof fmt); |
| 5370 | parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); | 5209 | parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); |
| 5371 | 5210 | ||
| 5372 | /* Get foreground and background colors, maybe allocate colors. */ | 5211 | /* Get foreground and background colors, maybe allocate colors. */ |
| @@ -5511,8 +5350,8 @@ pbm_load (f, img) | |||
| 5511 | 5350 | ||
| 5512 | /* Function prototypes. */ | 5351 | /* Function prototypes. */ |
| 5513 | 5352 | ||
| 5514 | static int png_image_p P_ ((Lisp_Object object)); | 5353 | static int png_image_p (Lisp_Object object); |
| 5515 | static int png_load P_ ((struct frame *f, struct image *img)); | 5354 | static int png_load (struct frame *f, struct image *img); |
| 5516 | 5355 | ||
| 5517 | /* The symbol `png' identifying images of this type. */ | 5356 | /* The symbol `png' identifying images of this type. */ |
| 5518 | 5357 | ||
| @@ -5566,11 +5405,10 @@ static struct image_type png_type = | |||
| 5566 | /* Return non-zero if OBJECT is a valid PNG image specification. */ | 5405 | /* Return non-zero if OBJECT is a valid PNG image specification. */ |
| 5567 | 5406 | ||
| 5568 | static int | 5407 | static int |
| 5569 | png_image_p (object) | 5408 | png_image_p (Lisp_Object object) |
| 5570 | Lisp_Object object; | ||
| 5571 | { | 5409 | { |
| 5572 | struct image_keyword fmt[PNG_LAST]; | 5410 | struct image_keyword fmt[PNG_LAST]; |
| 5573 | bcopy (png_format, fmt, sizeof fmt); | 5411 | memcpy (fmt, png_format, sizeof fmt); |
| 5574 | 5412 | ||
| 5575 | if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)) | 5413 | if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)) |
| 5576 | return 0; | 5414 | return 0; |
| @@ -5671,9 +5509,7 @@ init_png_functions (Lisp_Object libraries) | |||
| 5671 | is initialized. */ | 5509 | is initialized. */ |
| 5672 | 5510 | ||
| 5673 | static void | 5511 | static void |
| 5674 | my_png_error (png_ptr, msg) | 5512 | my_png_error (png_struct *png_ptr, const char *msg) |
| 5675 | png_struct *png_ptr; | ||
| 5676 | char *msg; | ||
| 5677 | { | 5513 | { |
| 5678 | xassert (png_ptr != NULL); | 5514 | xassert (png_ptr != NULL); |
| 5679 | image_error ("PNG error: %s", build_string (msg), Qnil); | 5515 | image_error ("PNG error: %s", build_string (msg), Qnil); |
| @@ -5682,9 +5518,7 @@ my_png_error (png_ptr, msg) | |||
| 5682 | 5518 | ||
| 5683 | 5519 | ||
| 5684 | static void | 5520 | static void |
| 5685 | my_png_warning (png_ptr, msg) | 5521 | my_png_warning (png_struct *png_ptr, const char *msg) |
| 5686 | png_struct *png_ptr; | ||
| 5687 | char *msg; | ||
| 5688 | { | 5522 | { |
| 5689 | xassert (png_ptr != NULL); | 5523 | xassert (png_ptr != NULL); |
| 5690 | image_error ("PNG warning: %s", build_string (msg), Qnil); | 5524 | image_error ("PNG warning: %s", build_string (msg), Qnil); |
| @@ -5705,10 +5539,7 @@ struct png_memory_storage | |||
| 5705 | bytes from the input to DATA. */ | 5539 | bytes from the input to DATA. */ |
| 5706 | 5540 | ||
| 5707 | static void | 5541 | static void |
| 5708 | png_read_from_memory (png_ptr, data, length) | 5542 | png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) |
| 5709 | png_structp png_ptr; | ||
| 5710 | png_bytep data; | ||
| 5711 | png_size_t length; | ||
| 5712 | { | 5543 | { |
| 5713 | struct png_memory_storage *tbr | 5544 | struct png_memory_storage *tbr |
| 5714 | = (struct png_memory_storage *) fn_png_get_io_ptr (png_ptr); | 5545 | = (struct png_memory_storage *) fn_png_get_io_ptr (png_ptr); |
| @@ -5716,7 +5547,7 @@ png_read_from_memory (png_ptr, data, length) | |||
| 5716 | if (length > tbr->len - tbr->index) | 5547 | if (length > tbr->len - tbr->index) |
| 5717 | fn_png_error (png_ptr, "Read error"); | 5548 | fn_png_error (png_ptr, "Read error"); |
| 5718 | 5549 | ||
| 5719 | bcopy (tbr->bytes + tbr->index, data, length); | 5550 | memcpy (data, tbr->bytes + tbr->index, length); |
| 5720 | tbr->index = tbr->index + length; | 5551 | tbr->index = tbr->index + length; |
| 5721 | } | 5552 | } |
| 5722 | 5553 | ||
| @@ -5726,10 +5557,7 @@ png_read_from_memory (png_ptr, data, length) | |||
| 5726 | bytes from the input to DATA. */ | 5557 | bytes from the input to DATA. */ |
| 5727 | 5558 | ||
| 5728 | static void | 5559 | static void |
| 5729 | png_read_from_file (png_ptr, data, length) | 5560 | png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) |
| 5730 | png_structp png_ptr; | ||
| 5731 | png_bytep data; | ||
| 5732 | png_size_t length; | ||
| 5733 | { | 5561 | { |
| 5734 | FILE *fp = (FILE *) fn_png_get_io_ptr (png_ptr); | 5562 | FILE *fp = (FILE *) fn_png_get_io_ptr (png_ptr); |
| 5735 | 5563 | ||
| @@ -5742,9 +5570,7 @@ png_read_from_file (png_ptr, data, length) | |||
| 5742 | successful. */ | 5570 | successful. */ |
| 5743 | 5571 | ||
| 5744 | static int | 5572 | static int |
| 5745 | png_load (f, img) | 5573 | png_load (struct frame *f, struct image *img) |
| 5746 | struct frame *f; | ||
| 5747 | struct image *img; | ||
| 5748 | { | 5574 | { |
| 5749 | Lisp_Object file, specified_file; | 5575 | Lisp_Object file, specified_file; |
| 5750 | Lisp_Object specified_data; | 5576 | Lisp_Object specified_data; |
| @@ -5923,7 +5749,7 @@ png_load (f, img) | |||
| 5923 | { | 5749 | { |
| 5924 | png_color_16 user_bg; | 5750 | png_color_16 user_bg; |
| 5925 | 5751 | ||
| 5926 | bzero (&user_bg, sizeof user_bg); | 5752 | memset (&user_bg, 0, sizeof user_bg); |
| 5927 | user_bg.red = color.red >> shift; | 5753 | user_bg.red = color.red >> shift; |
| 5928 | user_bg.green = color.green >> shift; | 5754 | user_bg.green = color.green >> shift; |
| 5929 | user_bg.blue = color.blue >> shift; | 5755 | user_bg.blue = color.blue >> shift; |
| @@ -5943,7 +5769,7 @@ png_load (f, img) | |||
| 5943 | color.pixel = FRAME_BACKGROUND_PIXEL (f); | 5769 | color.pixel = FRAME_BACKGROUND_PIXEL (f); |
| 5944 | x_query_color (f, &color); | 5770 | x_query_color (f, &color); |
| 5945 | 5771 | ||
| 5946 | bzero (&frame_background, sizeof frame_background); | 5772 | memset (&frame_background, 0, sizeof frame_background); |
| 5947 | frame_background.red = color.red >> shift; | 5773 | frame_background.red = color.red >> shift; |
| 5948 | frame_background.green = color.green >> shift; | 5774 | frame_background.green = color.green >> shift; |
| 5949 | frame_background.blue = color.blue >> shift; | 5775 | frame_background.blue = color.blue >> shift; |
| @@ -6113,8 +5939,8 @@ png_load (struct frame *f, struct image *img) | |||
| 6113 | 5939 | ||
| 6114 | #if defined (HAVE_JPEG) || defined (HAVE_NS) | 5940 | #if defined (HAVE_JPEG) || defined (HAVE_NS) |
| 6115 | 5941 | ||
| 6116 | static int jpeg_image_p P_ ((Lisp_Object object)); | 5942 | static int jpeg_image_p (Lisp_Object object); |
| 6117 | static int jpeg_load P_ ((struct frame *f, struct image *img)); | 5943 | static int jpeg_load (struct frame *f, struct image *img); |
| 6118 | 5944 | ||
| 6119 | /* The symbol `jpeg' identifying images of this type. */ | 5945 | /* The symbol `jpeg' identifying images of this type. */ |
| 6120 | 5946 | ||
| @@ -6168,12 +5994,11 @@ static struct image_type jpeg_type = | |||
| 6168 | /* Return non-zero if OBJECT is a valid JPEG image specification. */ | 5994 | /* Return non-zero if OBJECT is a valid JPEG image specification. */ |
| 6169 | 5995 | ||
| 6170 | static int | 5996 | static int |
| 6171 | jpeg_image_p (object) | 5997 | jpeg_image_p (Lisp_Object object) |
| 6172 | Lisp_Object object; | ||
| 6173 | { | 5998 | { |
| 6174 | struct image_keyword fmt[JPEG_LAST]; | 5999 | struct image_keyword fmt[JPEG_LAST]; |
| 6175 | 6000 | ||
| 6176 | bcopy (jpeg_format, fmt, sizeof fmt); | 6001 | memcpy (fmt, jpeg_format, sizeof fmt); |
| 6177 | 6002 | ||
| 6178 | if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)) | 6003 | if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)) |
| 6179 | return 0; | 6004 | return 0; |
| @@ -6240,9 +6065,7 @@ init_jpeg_functions (Lisp_Object libraries) | |||
| 6240 | /* Wrapper since we can't directly assign the function pointer | 6065 | /* Wrapper since we can't directly assign the function pointer |
| 6241 | to another function pointer that was declared more completely easily. */ | 6066 | to another function pointer that was declared more completely easily. */ |
| 6242 | static boolean | 6067 | static boolean |
| 6243 | jpeg_resync_to_restart_wrapper (cinfo, desired) | 6068 | jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) |
| 6244 | j_decompress_ptr cinfo; | ||
| 6245 | int desired; | ||
| 6246 | { | 6069 | { |
| 6247 | return fn_jpeg_resync_to_restart (cinfo, desired); | 6070 | return fn_jpeg_resync_to_restart (cinfo, desired); |
| 6248 | } | 6071 | } |
| @@ -6268,8 +6091,7 @@ struct my_jpeg_error_mgr | |||
| 6268 | 6091 | ||
| 6269 | 6092 | ||
| 6270 | static void | 6093 | static void |
| 6271 | my_error_exit (cinfo) | 6094 | my_error_exit (j_common_ptr cinfo) |
| 6272 | j_common_ptr cinfo; | ||
| 6273 | { | 6095 | { |
| 6274 | struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; | 6096 | struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; |
| 6275 | longjmp (mgr->setjmp_buffer, 1); | 6097 | longjmp (mgr->setjmp_buffer, 1); |
| @@ -6281,8 +6103,7 @@ my_error_exit (cinfo) | |||
| 6281 | libjpeg.doc from the JPEG lib distribution. */ | 6103 | libjpeg.doc from the JPEG lib distribution. */ |
| 6282 | 6104 | ||
| 6283 | static void | 6105 | static void |
| 6284 | our_common_init_source (cinfo) | 6106 | our_common_init_source (j_decompress_ptr cinfo) |
| 6285 | j_decompress_ptr cinfo; | ||
| 6286 | { | 6107 | { |
| 6287 | } | 6108 | } |
| 6288 | 6109 | ||
| @@ -6291,8 +6112,7 @@ our_common_init_source (cinfo) | |||
| 6291 | jpeg_finish_decompress() after all data has been processed. */ | 6112 | jpeg_finish_decompress() after all data has been processed. */ |
| 6292 | 6113 | ||
| 6293 | static void | 6114 | static void |
| 6294 | our_common_term_source (cinfo) | 6115 | our_common_term_source (j_decompress_ptr cinfo) |
| 6295 | j_decompress_ptr cinfo; | ||
| 6296 | { | 6116 | { |
| 6297 | } | 6117 | } |
| 6298 | 6118 | ||
| @@ -6304,8 +6124,7 @@ our_common_term_source (cinfo) | |||
| 6304 | static JOCTET our_memory_buffer[2]; | 6124 | static JOCTET our_memory_buffer[2]; |
| 6305 | 6125 | ||
| 6306 | static boolean | 6126 | static boolean |
| 6307 | our_memory_fill_input_buffer (cinfo) | 6127 | our_memory_fill_input_buffer (j_decompress_ptr cinfo) |
| 6308 | j_decompress_ptr cinfo; | ||
| 6309 | { | 6128 | { |
| 6310 | /* Insert a fake EOI marker. */ | 6129 | /* Insert a fake EOI marker. */ |
| 6311 | struct jpeg_source_mgr *src = cinfo->src; | 6130 | struct jpeg_source_mgr *src = cinfo->src; |
| @@ -6323,9 +6142,7 @@ our_memory_fill_input_buffer (cinfo) | |||
| 6323 | is the JPEG data source manager. */ | 6142 | is the JPEG data source manager. */ |
| 6324 | 6143 | ||
| 6325 | static void | 6144 | static void |
| 6326 | our_memory_skip_input_data (cinfo, num_bytes) | 6145 | our_memory_skip_input_data (j_decompress_ptr cinfo, long int num_bytes) |
| 6327 | j_decompress_ptr cinfo; | ||
| 6328 | long num_bytes; | ||
| 6329 | { | 6146 | { |
| 6330 | struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src; | 6147 | struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src; |
| 6331 | 6148 | ||
| @@ -6345,10 +6162,7 @@ our_memory_skip_input_data (cinfo, num_bytes) | |||
| 6345 | reading the image. */ | 6162 | reading the image. */ |
| 6346 | 6163 | ||
| 6347 | static void | 6164 | static void |
| 6348 | jpeg_memory_src (cinfo, data, len) | 6165 | jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len) |
| 6349 | j_decompress_ptr cinfo; | ||
| 6350 | JOCTET *data; | ||
| 6351 | unsigned int len; | ||
| 6352 | { | 6166 | { |
| 6353 | struct jpeg_source_mgr *src; | 6167 | struct jpeg_source_mgr *src; |
| 6354 | 6168 | ||
| @@ -6391,8 +6205,7 @@ struct jpeg_stdio_mgr | |||
| 6391 | whenever more data is needed. The data is read from a FILE *. */ | 6205 | whenever more data is needed. The data is read from a FILE *. */ |
| 6392 | 6206 | ||
| 6393 | static boolean | 6207 | static boolean |
| 6394 | our_stdio_fill_input_buffer (cinfo) | 6208 | our_stdio_fill_input_buffer (j_decompress_ptr cinfo) |
| 6395 | j_decompress_ptr cinfo; | ||
| 6396 | { | 6209 | { |
| 6397 | struct jpeg_stdio_mgr *src; | 6210 | struct jpeg_stdio_mgr *src; |
| 6398 | 6211 | ||
| @@ -6423,9 +6236,7 @@ our_stdio_fill_input_buffer (cinfo) | |||
| 6423 | is the JPEG data source manager. */ | 6236 | is the JPEG data source manager. */ |
| 6424 | 6237 | ||
| 6425 | static void | 6238 | static void |
| 6426 | our_stdio_skip_input_data (cinfo, num_bytes) | 6239 | our_stdio_skip_input_data (j_decompress_ptr cinfo, long int num_bytes) |
| 6427 | j_decompress_ptr cinfo; | ||
| 6428 | long num_bytes; | ||
| 6429 | { | 6240 | { |
| 6430 | struct jpeg_stdio_mgr *src; | 6241 | struct jpeg_stdio_mgr *src; |
| 6431 | src = (struct jpeg_stdio_mgr *) cinfo->src; | 6242 | src = (struct jpeg_stdio_mgr *) cinfo->src; |
| @@ -6455,9 +6266,7 @@ our_stdio_skip_input_data (cinfo, num_bytes) | |||
| 6455 | reading the image. */ | 6266 | reading the image. */ |
| 6456 | 6267 | ||
| 6457 | static void | 6268 | static void |
| 6458 | jpeg_file_src (cinfo, fp) | 6269 | jpeg_file_src (j_decompress_ptr cinfo, FILE *fp) |
| 6459 | j_decompress_ptr cinfo; | ||
| 6460 | FILE *fp; | ||
| 6461 | { | 6270 | { |
| 6462 | struct jpeg_stdio_mgr *src; | 6271 | struct jpeg_stdio_mgr *src; |
| 6463 | 6272 | ||
| @@ -6491,9 +6300,7 @@ jpeg_file_src (cinfo, fp) | |||
| 6491 | from the JPEG lib. */ | 6300 | from the JPEG lib. */ |
| 6492 | 6301 | ||
| 6493 | static int | 6302 | static int |
| 6494 | jpeg_load (f, img) | 6303 | jpeg_load (struct frame *f, struct image *img) |
| 6495 | struct frame *f; | ||
| 6496 | struct image *img; | ||
| 6497 | { | 6304 | { |
| 6498 | struct jpeg_decompress_struct cinfo; | 6305 | struct jpeg_decompress_struct cinfo; |
| 6499 | struct my_jpeg_error_mgr mgr; | 6306 | struct my_jpeg_error_mgr mgr; |
| @@ -6669,9 +6476,9 @@ jpeg_load (f, img) | |||
| 6669 | static int | 6476 | static int |
| 6670 | jpeg_load (struct frame *f, struct image *img) | 6477 | jpeg_load (struct frame *f, struct image *img) |
| 6671 | { | 6478 | { |
| 6672 | return ns_load_image(f, img, | 6479 | return ns_load_image (f, img, |
| 6673 | image_spec_value (img->spec, QCfile, NULL), | 6480 | image_spec_value (img->spec, QCfile, NULL), |
| 6674 | image_spec_value (img->spec, QCdata, NULL)); | 6481 | image_spec_value (img->spec, QCdata, NULL)); |
| 6675 | } | 6482 | } |
| 6676 | #endif /* HAVE_NS */ | 6483 | #endif /* HAVE_NS */ |
| 6677 | 6484 | ||
| @@ -6685,8 +6492,8 @@ jpeg_load (struct frame *f, struct image *img) | |||
| 6685 | 6492 | ||
| 6686 | #if defined (HAVE_TIFF) || defined (HAVE_NS) | 6493 | #if defined (HAVE_TIFF) || defined (HAVE_NS) |
| 6687 | 6494 | ||
| 6688 | static int tiff_image_p P_ ((Lisp_Object object)); | 6495 | static int tiff_image_p (Lisp_Object object); |
| 6689 | static int tiff_load P_ ((struct frame *f, struct image *img)); | 6496 | static int tiff_load (struct frame *f, struct image *img); |
| 6690 | 6497 | ||
| 6691 | /* The symbol `tiff' identifying images of this type. */ | 6498 | /* The symbol `tiff' identifying images of this type. */ |
| 6692 | 6499 | ||
| @@ -6742,11 +6549,10 @@ static struct image_type tiff_type = | |||
| 6742 | /* Return non-zero if OBJECT is a valid TIFF image specification. */ | 6549 | /* Return non-zero if OBJECT is a valid TIFF image specification. */ |
| 6743 | 6550 | ||
| 6744 | static int | 6551 | static int |
| 6745 | tiff_image_p (object) | 6552 | tiff_image_p (Lisp_Object object) |
| 6746 | Lisp_Object object; | ||
| 6747 | { | 6553 | { |
| 6748 | struct image_keyword fmt[TIFF_LAST]; | 6554 | struct image_keyword fmt[TIFF_LAST]; |
| 6749 | bcopy (tiff_format, fmt, sizeof fmt); | 6555 | memcpy (fmt, tiff_format, sizeof fmt); |
| 6750 | 6556 | ||
| 6751 | if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)) | 6557 | if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)) |
| 6752 | return 0; | 6558 | return 0; |
| @@ -6823,34 +6629,25 @@ typedef struct | |||
| 6823 | tiff_memory_source; | 6629 | tiff_memory_source; |
| 6824 | 6630 | ||
| 6825 | static size_t | 6631 | static size_t |
| 6826 | tiff_read_from_memory (data, buf, size) | 6632 | tiff_read_from_memory (thandle_t data, tdata_t buf, tsize_t size) |
| 6827 | thandle_t data; | ||
| 6828 | tdata_t buf; | ||
| 6829 | tsize_t size; | ||
| 6830 | { | 6633 | { |
| 6831 | tiff_memory_source *src = (tiff_memory_source *) data; | 6634 | tiff_memory_source *src = (tiff_memory_source *) data; |
| 6832 | 6635 | ||
| 6833 | if (size > src->len - src->index) | 6636 | if (size > src->len - src->index) |
| 6834 | return (size_t) -1; | 6637 | return (size_t) -1; |
| 6835 | bcopy (src->bytes + src->index, buf, size); | 6638 | memcpy (buf, src->bytes + src->index, size); |
| 6836 | src->index += size; | 6639 | src->index += size; |
| 6837 | return size; | 6640 | return size; |
| 6838 | } | 6641 | } |
| 6839 | 6642 | ||
| 6840 | static size_t | 6643 | static size_t |
| 6841 | tiff_write_from_memory (data, buf, size) | 6644 | tiff_write_from_memory (thandle_t data, tdata_t buf, tsize_t size) |
| 6842 | thandle_t data; | ||
| 6843 | tdata_t buf; | ||
| 6844 | tsize_t size; | ||
| 6845 | { | 6645 | { |
| 6846 | return (size_t) -1; | 6646 | return (size_t) -1; |
| 6847 | } | 6647 | } |
| 6848 | 6648 | ||
| 6849 | static toff_t | 6649 | static toff_t |
| 6850 | tiff_seek_in_memory (data, off, whence) | 6650 | tiff_seek_in_memory (thandle_t data, toff_t off, int whence) |
| 6851 | thandle_t data; | ||
| 6852 | toff_t off; | ||
| 6853 | int whence; | ||
| 6854 | { | 6651 | { |
| 6855 | tiff_memory_source *src = (tiff_memory_source *) data; | 6652 | tiff_memory_source *src = (tiff_memory_source *) data; |
| 6856 | int idx; | 6653 | int idx; |
| @@ -6881,44 +6678,34 @@ tiff_seek_in_memory (data, off, whence) | |||
| 6881 | } | 6678 | } |
| 6882 | 6679 | ||
| 6883 | static int | 6680 | static int |
| 6884 | tiff_close_memory (data) | 6681 | tiff_close_memory (thandle_t data) |
| 6885 | thandle_t data; | ||
| 6886 | { | 6682 | { |
| 6887 | /* NOOP */ | 6683 | /* NOOP */ |
| 6888 | return 0; | 6684 | return 0; |
| 6889 | } | 6685 | } |
| 6890 | 6686 | ||
| 6891 | static int | 6687 | static int |
| 6892 | tiff_mmap_memory (data, pbase, psize) | 6688 | tiff_mmap_memory (thandle_t data, tdata_t *pbase, toff_t *psize) |
| 6893 | thandle_t data; | ||
| 6894 | tdata_t *pbase; | ||
| 6895 | toff_t *psize; | ||
| 6896 | { | 6689 | { |
| 6897 | /* It is already _IN_ memory. */ | 6690 | /* It is already _IN_ memory. */ |
| 6898 | return 0; | 6691 | return 0; |
| 6899 | } | 6692 | } |
| 6900 | 6693 | ||
| 6901 | static void | 6694 | static void |
| 6902 | tiff_unmap_memory (data, base, size) | 6695 | tiff_unmap_memory (thandle_t data, tdata_t base, toff_t size) |
| 6903 | thandle_t data; | ||
| 6904 | tdata_t base; | ||
| 6905 | toff_t size; | ||
| 6906 | { | 6696 | { |
| 6907 | /* We don't need to do this. */ | 6697 | /* We don't need to do this. */ |
| 6908 | } | 6698 | } |
| 6909 | 6699 | ||
| 6910 | static toff_t | 6700 | static toff_t |
| 6911 | tiff_size_of_memory (data) | 6701 | tiff_size_of_memory (thandle_t data) |
| 6912 | thandle_t data; | ||
| 6913 | { | 6702 | { |
| 6914 | return ((tiff_memory_source *) data)->len; | 6703 | return ((tiff_memory_source *) data)->len; |
| 6915 | } | 6704 | } |
| 6916 | 6705 | ||
| 6917 | 6706 | ||
| 6918 | static void | 6707 | static void |
| 6919 | tiff_error_handler (title, format, ap) | 6708 | tiff_error_handler (const char *title, const char *format, va_list ap) |
| 6920 | const char *title, *format; | ||
| 6921 | va_list ap; | ||
| 6922 | { | 6709 | { |
| 6923 | char buf[512]; | 6710 | char buf[512]; |
| 6924 | int len; | 6711 | int len; |
| @@ -6930,9 +6717,7 @@ tiff_error_handler (title, format, ap) | |||
| 6930 | 6717 | ||
| 6931 | 6718 | ||
| 6932 | static void | 6719 | static void |
| 6933 | tiff_warning_handler (title, format, ap) | 6720 | tiff_warning_handler (const char *title, const char *format, va_list ap) |
| 6934 | const char *title, *format; | ||
| 6935 | va_list ap; | ||
| 6936 | { | 6721 | { |
| 6937 | char buf[512]; | 6722 | char buf[512]; |
| 6938 | int len; | 6723 | int len; |
| @@ -6947,9 +6732,7 @@ tiff_warning_handler (title, format, ap) | |||
| 6947 | successful. */ | 6732 | successful. */ |
| 6948 | 6733 | ||
| 6949 | static int | 6734 | static int |
| 6950 | tiff_load (f, img) | 6735 | tiff_load (struct frame *f, struct image *img) |
| 6951 | struct frame *f; | ||
| 6952 | struct image *img; | ||
| 6953 | { | 6736 | { |
| 6954 | Lisp_Object file, specified_file; | 6737 | Lisp_Object file, specified_file; |
| 6955 | Lisp_Object specified_data; | 6738 | Lisp_Object specified_data; |
| @@ -7120,9 +6903,9 @@ tiff_load (f, img) | |||
| 7120 | static int | 6903 | static int |
| 7121 | tiff_load (struct frame *f, struct image *img) | 6904 | tiff_load (struct frame *f, struct image *img) |
| 7122 | { | 6905 | { |
| 7123 | return ns_load_image(f, img, | 6906 | return ns_load_image (f, img, |
| 7124 | image_spec_value (img->spec, QCfile, NULL), | 6907 | image_spec_value (img->spec, QCfile, NULL), |
| 7125 | image_spec_value (img->spec, QCdata, NULL)); | 6908 | image_spec_value (img->spec, QCdata, NULL)); |
| 7126 | } | 6909 | } |
| 7127 | #endif /* HAVE_NS */ | 6910 | #endif /* HAVE_NS */ |
| 7128 | 6911 | ||
| @@ -7136,9 +6919,9 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7136 | 6919 | ||
| 7137 | #if defined (HAVE_GIF) || defined (HAVE_NS) | 6920 | #if defined (HAVE_GIF) || defined (HAVE_NS) |
| 7138 | 6921 | ||
| 7139 | static int gif_image_p P_ ((Lisp_Object object)); | 6922 | static int gif_image_p (Lisp_Object object); |
| 7140 | static int gif_load P_ ((struct frame *f, struct image *img)); | 6923 | static int gif_load (struct frame *f, struct image *img); |
| 7141 | static void gif_clear_image P_ ((struct frame *f, struct image *img)); | 6924 | static void gif_clear_image (struct frame *f, struct image *img); |
| 7142 | 6925 | ||
| 7143 | /* The symbol `gif' identifying images of this type. */ | 6926 | /* The symbol `gif' identifying images of this type. */ |
| 7144 | 6927 | ||
| @@ -7194,9 +6977,7 @@ static struct image_type gif_type = | |||
| 7194 | /* Free X resources of GIF image IMG which is used on frame F. */ | 6977 | /* Free X resources of GIF image IMG which is used on frame F. */ |
| 7195 | 6978 | ||
| 7196 | static void | 6979 | static void |
| 7197 | gif_clear_image (f, img) | 6980 | gif_clear_image (struct frame *f, struct image *img) |
| 7198 | struct frame *f; | ||
| 7199 | struct image *img; | ||
| 7200 | { | 6981 | { |
| 7201 | /* IMG->data.ptr_val may contain metadata with extension data. */ | 6982 | /* IMG->data.ptr_val may contain metadata with extension data. */ |
| 7202 | img->data.lisp_val = Qnil; | 6983 | img->data.lisp_val = Qnil; |
| @@ -7206,11 +6987,10 @@ gif_clear_image (f, img) | |||
| 7206 | /* Return non-zero if OBJECT is a valid GIF image specification. */ | 6987 | /* Return non-zero if OBJECT is a valid GIF image specification. */ |
| 7207 | 6988 | ||
| 7208 | static int | 6989 | static int |
| 7209 | gif_image_p (object) | 6990 | gif_image_p (Lisp_Object object) |
| 7210 | Lisp_Object object; | ||
| 7211 | { | 6991 | { |
| 7212 | struct image_keyword fmt[GIF_LAST]; | 6992 | struct image_keyword fmt[GIF_LAST]; |
| 7213 | bcopy (gif_format, fmt, sizeof fmt); | 6993 | memcpy (fmt, gif_format, sizeof fmt); |
| 7214 | 6994 | ||
| 7215 | if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)) | 6995 | if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)) |
| 7216 | return 0; | 6996 | return 0; |
| @@ -7290,17 +7070,14 @@ typedef struct | |||
| 7290 | static gif_memory_source *current_gif_memory_src; | 7070 | static gif_memory_source *current_gif_memory_src; |
| 7291 | 7071 | ||
| 7292 | static int | 7072 | static int |
| 7293 | gif_read_from_memory (file, buf, len) | 7073 | gif_read_from_memory (GifFileType *file, GifByteType *buf, int len) |
| 7294 | GifFileType *file; | ||
| 7295 | GifByteType *buf; | ||
| 7296 | int len; | ||
| 7297 | { | 7074 | { |
| 7298 | gif_memory_source *src = current_gif_memory_src; | 7075 | gif_memory_source *src = current_gif_memory_src; |
| 7299 | 7076 | ||
| 7300 | if (len > src->len - src->index) | 7077 | if (len > src->len - src->index) |
| 7301 | return -1; | 7078 | return -1; |
| 7302 | 7079 | ||
| 7303 | bcopy (src->bytes + src->index, buf, len); | 7080 | memcpy (buf, src->bytes + src->index, len); |
| 7304 | src->index += len; | 7081 | src->index += len; |
| 7305 | return len; | 7082 | return len; |
| 7306 | } | 7083 | } |
| @@ -7313,9 +7090,7 @@ static const int interlace_start[] = {0, 4, 2, 1}; | |||
| 7313 | static const int interlace_increment[] = {8, 8, 4, 2}; | 7090 | static const int interlace_increment[] = {8, 8, 4, 2}; |
| 7314 | 7091 | ||
| 7315 | static int | 7092 | static int |
| 7316 | gif_load (f, img) | 7093 | gif_load (struct frame *f, struct image *img) |
| 7317 | struct frame *f; | ||
| 7318 | struct image *img; | ||
| 7319 | { | 7094 | { |
| 7320 | Lisp_Object file, specified_file; | 7095 | Lisp_Object file, specified_file; |
| 7321 | Lisp_Object specified_data; | 7096 | Lisp_Object specified_data; |
| @@ -7438,7 +7213,7 @@ gif_load (f, img) | |||
| 7438 | if (!gif_color_map) | 7213 | if (!gif_color_map) |
| 7439 | gif_color_map = gif->SColorMap; | 7214 | gif_color_map = gif->SColorMap; |
| 7440 | init_color_table (); | 7215 | init_color_table (); |
| 7441 | bzero (pixel_colors, sizeof pixel_colors); | 7216 | memset (pixel_colors, 0, sizeof pixel_colors); |
| 7442 | 7217 | ||
| 7443 | if (gif_color_map) | 7218 | if (gif_color_map) |
| 7444 | for (i = 0; i < gif_color_map->ColorCount; ++i) | 7219 | for (i = 0; i < gif_color_map->ColorCount; ++i) |
| @@ -7558,9 +7333,9 @@ gif_load (f, img) | |||
| 7558 | static int | 7333 | static int |
| 7559 | gif_load (struct frame *f, struct image *img) | 7334 | gif_load (struct frame *f, struct image *img) |
| 7560 | { | 7335 | { |
| 7561 | return ns_load_image(f, img, | 7336 | return ns_load_image (f, img, |
| 7562 | image_spec_value (img->spec, QCfile, NULL), | 7337 | image_spec_value (img->spec, QCfile, NULL), |
| 7563 | image_spec_value (img->spec, QCdata, NULL)); | 7338 | image_spec_value (img->spec, QCdata, NULL)); |
| 7564 | } | 7339 | } |
| 7565 | #endif /* HAVE_NS */ | 7340 | #endif /* HAVE_NS */ |
| 7566 | 7341 | ||
| @@ -7676,8 +7451,8 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */ | |||
| 7676 | contents/size. */ | 7451 | contents/size. */ |
| 7677 | unsigned char *filename) | 7452 | unsigned char *filename) |
| 7678 | { | 7453 | { |
| 7679 | long unsigned int width; | 7454 | size_t width; |
| 7680 | long unsigned int height; | 7455 | size_t height; |
| 7681 | 7456 | ||
| 7682 | MagickBooleanType | 7457 | MagickBooleanType |
| 7683 | status; | 7458 | status; |
| @@ -8075,10 +7850,10 @@ DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, | |||
| 8075 | doc: /* Return image file types supported by ImageMagick. | 7850 | doc: /* Return image file types supported by ImageMagick. |
| 8076 | Since ImageMagick recognizes a lot of file-types that clash with Emacs, | 7851 | Since ImageMagick recognizes a lot of file-types that clash with Emacs, |
| 8077 | such as .c, we want to be able to alter the list at the lisp level. */) | 7852 | such as .c, we want to be able to alter the list at the lisp level. */) |
| 8078 | () | 7853 | (void) |
| 8079 | { | 7854 | { |
| 8080 | Lisp_Object typelist = Qnil; | 7855 | Lisp_Object typelist = Qnil; |
| 8081 | unsigned long numf; | 7856 | size_t numf; |
| 8082 | ExceptionInfo ex; | 7857 | ExceptionInfo ex; |
| 8083 | char** imtypes = GetMagickList ("*", &numf, &ex); | 7858 | char** imtypes = GetMagickList ("*", &numf, &ex); |
| 8084 | int i; | 7859 | int i; |
| @@ -8103,11 +7878,11 @@ DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, | |||
| 8103 | 7878 | ||
| 8104 | /* Function prototypes. */ | 7879 | /* Function prototypes. */ |
| 8105 | 7880 | ||
| 8106 | static int svg_image_p P_ ((Lisp_Object object)); | 7881 | static int svg_image_p (Lisp_Object object); |
| 8107 | static int svg_load P_ ((struct frame *f, struct image *img)); | 7882 | static int svg_load (struct frame *f, struct image *img); |
| 8108 | 7883 | ||
| 8109 | static int svg_load_image P_ ((struct frame *, struct image *, | 7884 | static int svg_load_image (struct frame *, struct image *, |
| 8110 | unsigned char *, unsigned int)); | 7885 | unsigned char *, unsigned int); |
| 8111 | 7886 | ||
| 8112 | /* The symbol `svg' identifying images of this type. */ | 7887 | /* The symbol `svg' identifying images of this type. */ |
| 8113 | 7888 | ||
| @@ -8172,11 +7947,10 @@ static struct image_type svg_type = | |||
| 8172 | identify the SVG format. */ | 7947 | identify the SVG format. */ |
| 8173 | 7948 | ||
| 8174 | static int | 7949 | static int |
| 8175 | svg_image_p (object) | 7950 | svg_image_p (Lisp_Object object) |
| 8176 | Lisp_Object object; | ||
| 8177 | { | 7951 | { |
| 8178 | struct image_keyword fmt[SVG_LAST]; | 7952 | struct image_keyword fmt[SVG_LAST]; |
| 8179 | bcopy (svg_format, fmt, sizeof fmt); | 7953 | memcpy (fmt, svg_format, sizeof fmt); |
| 8180 | 7954 | ||
| 8181 | if (!parse_image_spec (object, fmt, SVG_LAST, Qsvg)) | 7955 | if (!parse_image_spec (object, fmt, SVG_LAST, Qsvg)) |
| 8182 | return 0; | 7956 | return 0; |
| @@ -8275,9 +8049,7 @@ init_svg_functions (Lisp_Object libraries) | |||
| 8275 | the prototype thus needs to be compatible with that structure. */ | 8049 | the prototype thus needs to be compatible with that structure. */ |
| 8276 | 8050 | ||
| 8277 | static int | 8051 | static int |
| 8278 | svg_load (f, img) | 8052 | svg_load (struct frame *f, struct image *img) |
| 8279 | struct frame *f; | ||
| 8280 | struct image *img; | ||
| 8281 | { | 8053 | { |
| 8282 | int success_p = 0; | 8054 | int success_p = 0; |
| 8283 | Lisp_Object file_name; | 8055 | Lisp_Object file_name; |
| @@ -8334,15 +8106,10 @@ svg_load (f, img) | |||
| 8334 | 8106 | ||
| 8335 | Returns non-zero when successful. */ | 8107 | Returns non-zero when successful. */ |
| 8336 | static int | 8108 | static int |
| 8337 | svg_load_image (f, img, contents, size) | 8109 | svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */ |
| 8338 | /* Pointer to emacs frame structure. */ | 8110 | struct image *img, /* Pointer to emacs image structure. */ |
| 8339 | struct frame *f; | 8111 | unsigned char *contents, /* String containing the SVG XML data to be parsed. */ |
| 8340 | /* Pointer to emacs image structure. */ | 8112 | unsigned int size) /* Size of data in bytes. */ |
| 8341 | struct image *img; | ||
| 8342 | /* String containing the SVG XML data to be parsed. */ | ||
| 8343 | unsigned char *contents; | ||
| 8344 | /* Size of data in bytes. */ | ||
| 8345 | unsigned int size; | ||
| 8346 | { | 8113 | { |
| 8347 | RsvgHandle *rsvg_handle; | 8114 | RsvgHandle *rsvg_handle; |
| 8348 | RsvgDimensionData dimension_data; | 8115 | RsvgDimensionData dimension_data; |
| @@ -8417,7 +8184,7 @@ svg_load_image (f, img, contents, size) | |||
| 8417 | background.pixel = FRAME_BACKGROUND_PIXEL (f); | 8184 | background.pixel = FRAME_BACKGROUND_PIXEL (f); |
| 8418 | x_query_color (f, &background); | 8185 | x_query_color (f, &background); |
| 8419 | #else | 8186 | #else |
| 8420 | ns_query_color(FRAME_BACKGROUND_COLOR (f), &background, 1); | 8187 | ns_query_color (FRAME_BACKGROUND_COLOR (f), &background, 1); |
| 8421 | #endif | 8188 | #endif |
| 8422 | } | 8189 | } |
| 8423 | 8190 | ||
| @@ -8503,15 +8270,11 @@ svg_load_image (f, img, contents, size) | |||
| 8503 | #define HAVE_GHOSTSCRIPT 1 | 8270 | #define HAVE_GHOSTSCRIPT 1 |
| 8504 | #endif /* HAVE_X_WINDOWS */ | 8271 | #endif /* HAVE_X_WINDOWS */ |
| 8505 | 8272 | ||
| 8506 | /* The symbol `postscript' identifying images of this type. */ | ||
| 8507 | |||
| 8508 | Lisp_Object Qpostscript; | ||
| 8509 | |||
| 8510 | #ifdef HAVE_GHOSTSCRIPT | 8273 | #ifdef HAVE_GHOSTSCRIPT |
| 8511 | 8274 | ||
| 8512 | static int gs_image_p P_ ((Lisp_Object object)); | 8275 | static int gs_image_p (Lisp_Object object); |
| 8513 | static int gs_load P_ ((struct frame *f, struct image *img)); | 8276 | static int gs_load (struct frame *f, struct image *img); |
| 8514 | static void gs_clear_image P_ ((struct frame *f, struct image *img)); | 8277 | static void gs_clear_image (struct frame *f, struct image *img); |
| 8515 | 8278 | ||
| 8516 | /* Keyword symbols. */ | 8279 | /* Keyword symbols. */ |
| 8517 | 8280 | ||
| @@ -8572,9 +8335,7 @@ static struct image_type gs_type = | |||
| 8572 | /* Free X resources of Ghostscript image IMG which is used on frame F. */ | 8335 | /* Free X resources of Ghostscript image IMG which is used on frame F. */ |
| 8573 | 8336 | ||
| 8574 | static void | 8337 | static void |
| 8575 | gs_clear_image (f, img) | 8338 | gs_clear_image (struct frame *f, struct image *img) |
| 8576 | struct frame *f; | ||
| 8577 | struct image *img; | ||
| 8578 | { | 8339 | { |
| 8579 | /* IMG->data.ptr_val may contain a recorded colormap. */ | 8340 | /* IMG->data.ptr_val may contain a recorded colormap. */ |
| 8580 | xfree (img->data.ptr_val); | 8341 | xfree (img->data.ptr_val); |
| @@ -8586,14 +8347,13 @@ gs_clear_image (f, img) | |||
| 8586 | specification. */ | 8347 | specification. */ |
| 8587 | 8348 | ||
| 8588 | static int | 8349 | static int |
| 8589 | gs_image_p (object) | 8350 | gs_image_p (Lisp_Object object) |
| 8590 | Lisp_Object object; | ||
| 8591 | { | 8351 | { |
| 8592 | struct image_keyword fmt[GS_LAST]; | 8352 | struct image_keyword fmt[GS_LAST]; |
| 8593 | Lisp_Object tem; | 8353 | Lisp_Object tem; |
| 8594 | int i; | 8354 | int i; |
| 8595 | 8355 | ||
| 8596 | bcopy (gs_format, fmt, sizeof fmt); | 8356 | memcpy (fmt, gs_format, sizeof fmt); |
| 8597 | 8357 | ||
| 8598 | if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)) | 8358 | if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)) |
| 8599 | return 0; | 8359 | return 0; |
| @@ -8627,9 +8387,7 @@ gs_image_p (object) | |||
| 8627 | if successful. */ | 8387 | if successful. */ |
| 8628 | 8388 | ||
| 8629 | static int | 8389 | static int |
| 8630 | gs_load (f, img) | 8390 | gs_load (struct frame *f, struct image *img) |
| 8631 | struct frame *f; | ||
| 8632 | struct image *img; | ||
| 8633 | { | 8391 | { |
| 8634 | char buffer[100]; | 8392 | char buffer[100]; |
| 8635 | Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width; | 8393 | Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width; |
| @@ -8707,9 +8465,7 @@ gs_load (f, img) | |||
| 8707 | telling Emacs that Ghostscript has finished drawing. */ | 8465 | telling Emacs that Ghostscript has finished drawing. */ |
| 8708 | 8466 | ||
| 8709 | void | 8467 | void |
| 8710 | x_kill_gs_process (pixmap, f) | 8468 | x_kill_gs_process (Pixmap pixmap, struct frame *f) |
| 8711 | Pixmap pixmap; | ||
| 8712 | struct frame *f; | ||
| 8713 | { | 8469 | { |
| 8714 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | 8470 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 8715 | int class, i; | 8471 | int class, i; |
| @@ -8807,16 +8563,14 @@ x_kill_gs_process (pixmap, f) | |||
| 8807 | 8563 | ||
| 8808 | DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0, | 8564 | DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0, |
| 8809 | doc: /* Value is non-nil if SPEC is a valid image specification. */) | 8565 | doc: /* Value is non-nil if SPEC is a valid image specification. */) |
| 8810 | (spec) | 8566 | (Lisp_Object spec) |
| 8811 | Lisp_Object spec; | ||
| 8812 | { | 8567 | { |
| 8813 | return valid_image_p (spec) ? Qt : Qnil; | 8568 | return valid_image_p (spec) ? Qt : Qnil; |
| 8814 | } | 8569 | } |
| 8815 | 8570 | ||
| 8816 | 8571 | ||
| 8817 | DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") | 8572 | DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") |
| 8818 | (spec) | 8573 | (Lisp_Object spec) |
| 8819 | Lisp_Object spec; | ||
| 8820 | { | 8574 | { |
| 8821 | int id = -1; | 8575 | int id = -1; |
| 8822 | 8576 | ||
| @@ -8848,11 +8602,10 @@ DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0, | |||
| 8848 | doc: /* Initialize image library implementing image type TYPE. | 8602 | doc: /* Initialize image library implementing image type TYPE. |
| 8849 | Return non-nil if TYPE is a supported image type. | 8603 | Return non-nil if TYPE is a supported image type. |
| 8850 | 8604 | ||
| 8851 | Image types pbm and xbm are prebuilt; other types are loaded here. | 8605 | Image types pbm and xbm are prebuilt; other types are loaded here. |
| 8852 | Libraries to load are specified in alist LIBRARIES (usually, the value | 8606 | Libraries to load are specified in alist LIBRARIES (usually, the value |
| 8853 | of `image-library-alist', which see). */) | 8607 | of `image-library-alist', which see). */) |
| 8854 | (type, libraries) | 8608 | (Lisp_Object type, Lisp_Object libraries) |
| 8855 | Lisp_Object type, libraries; | ||
| 8856 | { | 8609 | { |
| 8857 | Lisp_Object tested; | 8610 | Lisp_Object tested; |
| 8858 | 8611 | ||
| @@ -8912,10 +8665,8 @@ DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 2, 2, 0, | |||
| 8912 | 8665 | ||
| 8913 | 8666 | ||
| 8914 | void | 8667 | void |
| 8915 | syms_of_image () | 8668 | syms_of_image (void) |
| 8916 | { | 8669 | { |
| 8917 | extern Lisp_Object Qrisky_local_variable; /* Syms_of_xdisp has already run. */ | ||
| 8918 | |||
| 8919 | /* Initialize this only once, since that's what we do with Vimage_types | 8670 | /* Initialize this only once, since that's what we do with Vimage_types |
| 8920 | and they are supposed to be in sync. Initializing here gives correct | 8671 | and they are supposed to be in sync. Initializing here gives correct |
| 8921 | operation on GNU/Linux of calling dump-emacs after loading some images. */ | 8672 | operation on GNU/Linux of calling dump-emacs after loading some images. */ |
| @@ -9118,7 +8869,7 @@ listed; they are always supported. */); | |||
| 9118 | 8869 | ||
| 9119 | 8870 | ||
| 9120 | void | 8871 | void |
| 9121 | init_image () | 8872 | init_image (void) |
| 9122 | { | 8873 | { |
| 9123 | 8874 | ||
| 9124 | } | 8875 | } |