comparison src/image.c @ 109793:b60dcdd855f0

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sun, 08 Aug 2010 22:52:25 +0000
parents 8949aad5e992
children 3226ac2da7f7
comparison
equal deleted inserted replaced
109649:1f8f03cfcd2b 109793:b60dcdd855f0
124 124
125 /* Search path for bitmap files. */ 125 /* Search path for bitmap files. */
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 (struct frame *, struct image *); 133 static void x_disable_image (struct frame *, struct image *);
131 static void x_edge_detection (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
593 596
594 /* Function prototypes. */ 597 /* Function prototypes. */
595 598
596 static Lisp_Object define_image_type (struct image_type *type, int loaded); 599 static Lisp_Object define_image_type (struct image_type *type, int loaded);
597 static struct image_type *lookup_image_type (Lisp_Object symbol); 600 static struct image_type *lookup_image_type (Lisp_Object symbol);
598 static void image_error (char *format, Lisp_Object, Lisp_Object); 601 static void image_error (const char *format, Lisp_Object, Lisp_Object);
599 static void x_laplace (struct frame *, struct image *); 602 static void x_laplace (struct frame *, struct image *);
600 static void x_emboss (struct frame *, struct image *); 603 static void x_emboss (struct frame *, struct image *);
601 static int x_build_heuristic_mask (struct frame *, struct image *, 604 static int x_build_heuristic_mask (struct frame *, struct image *,
602 Lisp_Object); 605 Lisp_Object);
603 606
694 good idea because this would interrupt redisplay, and the error 697 good idea because this would interrupt redisplay, and the error
695 message display would lead to another redisplay. This function 698 message display would lead to another redisplay. This function
696 therefore simply displays a message. */ 699 therefore simply displays a message. */
697 700
698 static void 701 static void
699 image_error (char *format, Lisp_Object arg1, Lisp_Object arg2) 702 image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2)
700 { 703 {
701 add_to_log (format, arg1, arg2); 704 add_to_log (format, arg1, arg2);
702 } 705 }
703 706
704 707
726 /* Structure used when parsing image specifications. */ 729 /* Structure used when parsing image specifications. */
727 730
728 struct image_keyword 731 struct image_keyword
729 { 732 {
730 /* Name of keyword. */ 733 /* Name of keyword. */
731 char *name; 734 const char *name;
732 735
733 /* The type of value allowed. */ 736 /* The type of value allowed. */
734 enum image_value_type type; 737 enum image_value_type type;
735 738
736 /* Non-zero means key must be present. */ 739 /* Non-zero means key must be present. */
1754 } 1757 }
1755 1758
1756 /* If not found, create a new image and cache it. */ 1759 /* If not found, create a new image and cache it. */
1757 if (img == NULL) 1760 if (img == NULL)
1758 { 1761 {
1759 extern Lisp_Object Qpostscript;
1760
1761 BLOCK_INPUT; 1762 BLOCK_INPUT;
1762 img = make_image (spec, hash); 1763 img = make_image (spec, hash);
1763 cache_image (f, img); 1764 cache_image (f, img);
1764 img->load_failed_p = img->type->load (f, img) == 0; 1765 img->load_failed_p = img->type->load (f, img) == 0;
1765 img->frame_foreground = FRAME_FOREGROUND_PIXEL (f); 1766 img->frame_foreground = FRAME_FOREGROUND_PIXEL (f);
3656 *S while scanning. If token is either XPM_TK_IDENT or 3657 *S while scanning. If token is either XPM_TK_IDENT or
3657 XPM_TK_STRING, *BEG and *LEN are set to the start address and the 3658 XPM_TK_STRING, *BEG and *LEN are set to the start address and the
3658 length of the corresponding token, respectively. */ 3659 length of the corresponding token, respectively. */
3659 3660
3660 static int 3661 static int
3661 xpm_scan (s, end, beg, len) 3662 xpm_scan (const unsigned char **s,
3662 const unsigned char **s, *end, **beg; 3663 const unsigned char *end,
3663 int *len; 3664 const unsigned char **beg,
3665 int *len)
3664 { 3666 {
3665 int c; 3667 int c;
3666 3668
3667 while (*s < end) 3669 while (*s < end)
3668 { 3670 {
3722 transparency, or Qnil for the unspecified color. If the length of 3724 transparency, or Qnil for the unspecified color. If the length of
3723 the key string is one, a vector is used as a table. Otherwise, a 3725 the key string is one, a vector is used as a table. Otherwise, a
3724 hash table is used. */ 3726 hash table is used. */
3725 3727
3726 static Lisp_Object 3728 static Lisp_Object
3727 xpm_make_color_table_v (put_func, get_func) 3729 xpm_make_color_table_v (void (**put_func) (Lisp_Object,
3728 void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); 3730 const unsigned char *,
3729 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))
3730 { 3736 {
3731 *put_func = xpm_put_color_table_v; 3737 *put_func = xpm_put_color_table_v;
3732 *get_func = xpm_get_color_table_v; 3738 *get_func = xpm_get_color_table_v;
3733 return Fmake_vector (make_number (256), Qnil); 3739 return Fmake_vector (make_number (256), Qnil);
3734 } 3740 }
3735 3741
3736 static void 3742 static void
3737 xpm_put_color_table_v (color_table, chars_start, chars_len, color) 3743 xpm_put_color_table_v (Lisp_Object color_table,
3738 Lisp_Object color_table; 3744 const unsigned char *chars_start,
3739 const unsigned char *chars_start; 3745 int chars_len,
3740 int chars_len; 3746 Lisp_Object color)
3741 Lisp_Object color;
3742 { 3747 {
3743 XVECTOR (color_table)->contents[*chars_start] = color; 3748 XVECTOR (color_table)->contents[*chars_start] = color;
3744 } 3749 }
3745 3750
3746 static Lisp_Object 3751 static Lisp_Object
3747 xpm_get_color_table_v (color_table, chars_start, chars_len) 3752 xpm_get_color_table_v (Lisp_Object color_table,
3748 Lisp_Object color_table; 3753 const unsigned char *chars_start,
3749 const unsigned char *chars_start; 3754 int chars_len)
3750 int chars_len;
3751 { 3755 {
3752 return XVECTOR (color_table)->contents[*chars_start]; 3756 return XVECTOR (color_table)->contents[*chars_start];
3753 } 3757 }
3754 3758
3755 static Lisp_Object 3759 static Lisp_Object
3756 xpm_make_color_table_h (put_func, get_func) 3760 xpm_make_color_table_h (void (**put_func) (Lisp_Object,
3757 void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); 3761 const unsigned char *,
3758 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))
3759 { 3767 {
3760 *put_func = xpm_put_color_table_h; 3768 *put_func = xpm_put_color_table_h;
3761 *get_func = xpm_get_color_table_h; 3769 *get_func = xpm_get_color_table_h;
3762 return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), 3770 return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
3763 make_float (DEFAULT_REHASH_SIZE), 3771 make_float (DEFAULT_REHASH_SIZE),
3764 make_float (DEFAULT_REHASH_THRESHOLD), 3772 make_float (DEFAULT_REHASH_THRESHOLD),
3765 Qnil, Qnil, Qnil); 3773 Qnil, Qnil, Qnil);
3766 } 3774 }
3767 3775
3768 static void 3776 static void
3769 xpm_put_color_table_h (color_table, chars_start, chars_len, color) 3777 xpm_put_color_table_h (Lisp_Object color_table,
3770 Lisp_Object color_table; 3778 const unsigned char *chars_start,
3771 const unsigned char *chars_start; 3779 int chars_len,
3772 int chars_len; 3780 Lisp_Object color)
3773 Lisp_Object color;
3774 { 3781 {
3775 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 3782 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
3776 unsigned hash_code; 3783 unsigned hash_code;
3777 Lisp_Object chars = make_unibyte_string (chars_start, chars_len); 3784 Lisp_Object chars = make_unibyte_string (chars_start, chars_len);
3778 3785
3779 hash_lookup (table, chars, &hash_code); 3786 hash_lookup (table, chars, &hash_code);
3780 hash_put (table, chars, color, hash_code); 3787 hash_put (table, chars, color, hash_code);
3781 } 3788 }
3782 3789
3783 static Lisp_Object 3790 static Lisp_Object
3784 xpm_get_color_table_h (color_table, chars_start, chars_len) 3791 xpm_get_color_table_h (Lisp_Object color_table,
3785 Lisp_Object color_table; 3792 const unsigned char *chars_start,
3786 const unsigned char *chars_start; 3793 int chars_len)
3787 int chars_len;
3788 { 3794 {
3789 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 3795 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
3790 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),
3791 NULL); 3797 NULL);
3792 3798
3802 }; 3808 };
3803 3809
3804 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"};
3805 3811
3806 static int 3812 static int
3807 xpm_str_to_color_key (s) 3813 xpm_str_to_color_key (const char *s)
3808 const char *s;
3809 { 3814 {
3810 int i; 3815 int i;
3811 3816
3812 for (i = 0; 3817 for (i = 0;
3813 i < sizeof xpm_color_key_strings / sizeof xpm_color_key_strings[0]; 3818 i < sizeof xpm_color_key_strings / sizeof xpm_color_key_strings[0];
3816 return i; 3821 return i;
3817 return -1; 3822 return -1;
3818 } 3823 }
3819 3824
3820 static int 3825 static int
3821 xpm_load_image (f, img, contents, end) 3826 xpm_load_image (struct frame *f,
3822 struct frame *f; 3827 struct image *img,
3823 struct image *img; 3828 const unsigned char *contents,
3824 const unsigned char *contents, *end; 3829 const unsigned char *end)
3825 { 3830 {
3826 const unsigned char *s = contents, *beg, *str; 3831 const unsigned char *s = contents, *beg, *str;
3827 unsigned char buffer[BUFSIZ]; 3832 unsigned char buffer[BUFSIZ];
3828 int width, height, x, y; 3833 int width, height, x, y;
3829 int num_colors, chars_per_pixel; 3834 int num_colors, chars_per_pixel;
4051 #undef expect 4056 #undef expect
4052 #undef expect_ident 4057 #undef expect_ident
4053 } 4058 }
4054 4059
4055 static int 4060 static int
4056 xpm_load (f, img) 4061 xpm_load (struct frame *f,
4057 struct frame *f; 4062 struct image *img)
4058 struct image *img;
4059 { 4063 {
4060 int success_p = 0; 4064 int success_p = 0;
4061 Lisp_Object file_name; 4065 Lisp_Object file_name;
4062 4066
4063 /* If IMG->spec specifies a file name, create a non-file spec from it. */ 4067 /* If IMG->spec specifies a file name, create a non-file spec from it. */
7737 7741
7738 #ifdef HAVE_X_WINDOWS 7742 #ifdef HAVE_X_WINDOWS
7739 #define HAVE_GHOSTSCRIPT 1 7743 #define HAVE_GHOSTSCRIPT 1
7740 #endif /* HAVE_X_WINDOWS */ 7744 #endif /* HAVE_X_WINDOWS */
7741 7745
7742 /* The symbol `postscript' identifying images of this type. */
7743
7744 Lisp_Object Qpostscript;
7745
7746 #ifdef HAVE_GHOSTSCRIPT 7746 #ifdef HAVE_GHOSTSCRIPT
7747 7747
7748 static int gs_image_p (Lisp_Object object); 7748 static int gs_image_p (Lisp_Object object);
7749 static int gs_load (struct frame *f, struct image *img); 7749 static int gs_load (struct frame *f, struct image *img);
7750 static void gs_clear_image (struct frame *f, struct image *img); 7750 static void gs_clear_image (struct frame *f, struct image *img);