comparison src/glyphs.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 6240c7796c7a
children bbff43aa5eb7
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
524 static Lisp_Object 524 static Lisp_Object
525 mark_image_instance (Lisp_Object obj, void (*markobj) (Lisp_Object)) 525 mark_image_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
526 { 526 {
527 struct Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj); 527 struct Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj);
528 528
529 (markobj) (i->name); 529 markobj (i->name);
530 switch (IMAGE_INSTANCE_TYPE (i)) 530 switch (IMAGE_INSTANCE_TYPE (i))
531 { 531 {
532 case IMAGE_TEXT: 532 case IMAGE_TEXT:
533 (markobj) (IMAGE_INSTANCE_TEXT_STRING (i)); 533 markobj (IMAGE_INSTANCE_TEXT_STRING (i));
534 break; 534 break;
535 case IMAGE_MONO_PIXMAP: 535 case IMAGE_MONO_PIXMAP:
536 case IMAGE_COLOR_PIXMAP: 536 case IMAGE_COLOR_PIXMAP:
537 (markobj) (IMAGE_INSTANCE_PIXMAP_FILENAME (i)); 537 markobj (IMAGE_INSTANCE_PIXMAP_FILENAME (i));
538 (markobj) (IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (i)); 538 markobj (IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (i));
539 (markobj) (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (i)); 539 markobj (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (i));
540 (markobj) (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (i)); 540 markobj (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (i));
541 (markobj) (IMAGE_INSTANCE_PIXMAP_FG (i)); 541 markobj (IMAGE_INSTANCE_PIXMAP_FG (i));
542 (markobj) (IMAGE_INSTANCE_PIXMAP_BG (i)); 542 markobj (IMAGE_INSTANCE_PIXMAP_BG (i));
543 break; 543 break;
544 case IMAGE_SUBWINDOW: 544 case IMAGE_SUBWINDOW:
545 /* #### implement me */ 545 /* #### implement me */
546 break; 546 break;
547 default: 547 default:
671 671
672 MAYBE_DEVMETH (XDEVICE (i->device), finalize_image_instance, (i)); 672 MAYBE_DEVMETH (XDEVICE (i->device), finalize_image_instance, (i));
673 } 673 }
674 674
675 static int 675 static int
676 image_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth) 676 image_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
677 { 677 {
678 struct Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (o1); 678 struct Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (obj1);
679 struct Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (o2); 679 struct Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (obj2);
680 struct device *d1 = XDEVICE (i1->device); 680 struct device *d1 = XDEVICE (i1->device);
681 struct device *d2 = XDEVICE (i2->device); 681 struct device *d2 = XDEVICE (i2->device);
682 682
683 if (d1 != d2) 683 if (d1 != d2)
684 return 0; 684 return 0;
956 956
957 XSETDEVICE (device, decode_device (device)); 957 XSETDEVICE (device, decode_device (device));
958 /* instantiate_image_instantiator() will abort if given an 958 /* instantiate_image_instantiator() will abort if given an
959 image instance ... */ 959 image instance ... */
960 if (IMAGE_INSTANCEP (data)) 960 if (IMAGE_INSTANCEP (data))
961 signal_simple_error ("image instances not allowed here", data); 961 signal_simple_error ("Image instances not allowed here", data);
962 image_validate (data); 962 image_validate (data);
963 dest_mask = decode_image_instance_type_list (dest_types); 963 dest_mask = decode_image_instance_type_list (dest_types);
964 data = normalize_image_instantiator (data, DEVICE_TYPE (XDEVICE (device)), 964 data = normalize_image_instantiator (data, DEVICE_TYPE (XDEVICE (device)),
965 make_int (dest_mask)); 965 make_int (dest_mask));
966 GCPRO1 (data); 966 GCPRO1 (data);
967 if (VECTORP (data) && EQ (XVECTOR_DATA (data)[0], Qinherit)) 967 if (VECTORP (data) && EQ (XVECTOR_DATA (data)[0], Qinherit))
968 signal_simple_error ("inheritance not allowed here", data); 968 signal_simple_error ("Inheritance not allowed here", data);
969 ii = instantiate_image_instantiator (device, device, data, 969 ii = instantiate_image_instantiator (device, device, data,
970 Qnil, Qnil, dest_mask); 970 Qnil, Qnil, dest_mask);
971 RETURN_UNGCPRO (ii); 971 RETURN_UNGCPRO (ii);
972 } 972 }
973 973
1481 file = find_keyword_in_vector (instantiator, file_keyword); 1481 file = find_keyword_in_vector (instantiator, file_keyword);
1482 1482
1483 if (!NILP (file) && NILP (data)) 1483 if (!NILP (file) && NILP (data))
1484 { 1484 {
1485 Lisp_Object retval = MAYBE_LISP_CONTYPE_METH 1485 Lisp_Object retval = MAYBE_LISP_CONTYPE_METH
1486 (decode_console_type(console_type, ERROR_ME), 1486 (decode_console_type(console_type, ERROR_ME),
1487 locate_pixmap_file, (file)); 1487 locate_pixmap_file, (file));
1488 1488
1489 if (!NILP (retval)) 1489 if (!NILP (retval))
1490 return retval; 1490 return retval;
1491 else 1491 else
1492 return Fcons (file, Qnil); /* should have been file */ 1492 return Fcons (file, Qnil); /* should have been file */
1493 } 1493 }
1494 1494
1495 return Qnil; 1495 return Qnil;
1496 } 1496 }
1497 1497
1498 Lisp_Object 1498 Lisp_Object
1499 simple_image_type_normalize (Lisp_Object inst, Lisp_Object console_type, 1499 simple_image_type_normalize (Lisp_Object inst, Lisp_Object console_type,
1512 Qnil. 1512 Qnil.
1513 1513
1514 Note that if we cannot generate any regular inline data, we 1514 Note that if we cannot generate any regular inline data, we
1515 skip out. */ 1515 skip out. */
1516 1516
1517 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data, 1517 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
1518 console_type); 1518 console_type);
1519 1519
1520 if (CONSP (file)) /* failure locating filename */ 1520 if (CONSP (file)) /* failure locating filename */
1521 signal_double_file_error ("Opening pixmap file", 1521 signal_double_file_error ("Opening pixmap file",
1522 "no such file or directory", 1522 "no such file or directory",
1598 -- if OK_IF_DATA_INVALID is set and the data was invalid, 1598 -- if OK_IF_DATA_INVALID is set and the data was invalid,
1599 return Qt. 1599 return Qt.
1600 -- maybe return an error, or return Qnil. 1600 -- maybe return an error, or return Qnil.
1601 */ 1601 */
1602 1602
1603 #ifndef HAVE_X_WINDOWS 1603 #ifdef HAVE_X_WINDOWS
1604 #include <X11/Xlib.h>
1605 #else
1604 #define XFree(data) free(data) 1606 #define XFree(data) free(data)
1605 #endif 1607 #endif
1606 1608
1607 Lisp_Object 1609 Lisp_Object
1608 bitmap_to_lisp_data (Lisp_Object name, int *xhot, int *yhot, 1610 bitmap_to_lisp_data (Lisp_Object name, int *xhot, int *yhot,
1612 Extbyte *data; 1614 Extbyte *data;
1613 int result; 1615 int result;
1614 CONST char *filename_ext; 1616 CONST char *filename_ext;
1615 1617
1616 GET_C_STRING_FILENAME_DATA_ALLOCA (name, filename_ext); 1618 GET_C_STRING_FILENAME_DATA_ALLOCA (name, filename_ext);
1617 result = read_bitmap_data_from_file (filename_ext, &w, &h, 1619 result = read_bitmap_data_from_file (filename_ext, &w, &h,
1618 &data, xhot, yhot); 1620 &data, xhot, yhot);
1619 1621
1620 if (result == BitmapSuccess) 1622 if (result == BitmapSuccess)
1621 { 1623 {
1622 Lisp_Object retval; 1624 Lisp_Object retval;
1673 /* don't override explicitly specified mask data. */ 1675 /* don't override explicitly specified mask data. */
1674 && NILP (assq_no_quit (Q_mask_data, alist)) 1676 && NILP (assq_no_quit (Q_mask_data, alist))
1675 && !NILP (file)) 1677 && !NILP (file))
1676 { 1678 {
1677 mask_file = MAYBE_LISP_CONTYPE_METH 1679 mask_file = MAYBE_LISP_CONTYPE_METH
1678 (decode_console_type(console_type, ERROR_ME), 1680 (decode_console_type(console_type, ERROR_ME),
1679 locate_pixmap_file, (concat2 (file, build_string ("Mask")))); 1681 locate_pixmap_file, (concat2 (file, build_string ("Mask"))));
1680 if (NILP (mask_file)) 1682 if (NILP (mask_file))
1681 mask_file = MAYBE_LISP_CONTYPE_METH 1683 mask_file = MAYBE_LISP_CONTYPE_METH
1682 (decode_console_type(console_type, ERROR_ME), 1684 (decode_console_type(console_type, ERROR_ME),
1683 locate_pixmap_file, (concat2 (file, build_string ("msk")))); 1685 locate_pixmap_file, (concat2 (file, build_string ("msk"))));
1684 } 1686 }
1685 1687
1686 if (!NILP (mask_file)) 1688 if (!NILP (mask_file))
1687 { 1689 {
1772 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1774 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1773 int dest_mask, Lisp_Object domain) 1775 int dest_mask, Lisp_Object domain)
1774 { 1776 {
1775 Lisp_Object device= IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (image_instance)); 1777 Lisp_Object device= IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (image_instance));
1776 1778
1777 MAYBE_DEVMETH (XDEVICE (device), 1779 MAYBE_DEVMETH (XDEVICE (device),
1778 xbm_instantiate, 1780 xbm_instantiate,
1779 (image_instance, instantiator, pointer_fg, 1781 (image_instance, instantiator, pointer_fg,
1780 pointer_bg, dest_mask, domain)); 1782 pointer_bg, dest_mask, domain));
1781 } 1783 }
1782 1784
1783 #endif 1785 #endif
1784 1786
1941 known) or Qnil. 1943 known) or Qnil.
1942 1944
1943 Note that if we cannot generate any regular inline data, we 1945 Note that if we cannot generate any regular inline data, we
1944 skip out. */ 1946 skip out. */
1945 1947
1946 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data, 1948 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
1947 console_type); 1949 console_type);
1948 1950
1949 if (CONSP (file)) /* failure locating filename */ 1951 if (CONSP (file)) /* failure locating filename */
1950 signal_double_file_error ("Opening pixmap file", 1952 signal_double_file_error ("Opening pixmap file",
1951 "no such file or directory", 1953 "no such file or directory",
1955 Qunbound); 1957 Qunbound);
1956 1958
1957 if (NILP (file) && !UNBOUNDP (color_symbols)) 1959 if (NILP (file) && !UNBOUNDP (color_symbols))
1958 /* no conversion necessary */ 1960 /* no conversion necessary */
1959 RETURN_UNGCPRO (inst); 1961 RETURN_UNGCPRO (inst);
1960 1962
1961 alist = tagged_vector_to_alist (inst); 1963 alist = tagged_vector_to_alist (inst);
1962 1964
1963 if (!NILP (file)) 1965 if (!NILP (file))
1964 { 1966 {
1965 Lisp_Object data = pixmap_to_lisp_data (file, 0); 1967 Lisp_Object data = pixmap_to_lisp_data (file, 0);
1966 alist = remassq_no_quit (Q_file, alist); 1968 alist = remassq_no_quit (Q_file, alist);
1967 /* there can't be a :data at this point. */ 1969 /* there can't be a :data at this point. */
1968 alist = Fcons (Fcons (Q_file, file), 1970 alist = Fcons (Fcons (Q_file, file),
1969 Fcons (Fcons (Q_data, data), alist)); 1971 Fcons (Fcons (Q_data, data), alist));
1970 } 1972 }
1971 1973
1972 if (UNBOUNDP (color_symbols)) 1974 if (UNBOUNDP (color_symbols))
1973 { 1975 {
1974 color_symbols = evaluate_xpm_color_symbols (); 1976 color_symbols = evaluate_xpm_color_symbols ();
1975 alist = Fcons (Fcons (Q_color_symbols, color_symbols), 1977 alist = Fcons (Fcons (Q_color_symbols, color_symbols),
1976 alist); 1978 alist);
1997 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1999 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1998 int dest_mask, Lisp_Object domain) 2000 int dest_mask, Lisp_Object domain)
1999 { 2001 {
2000 Lisp_Object device= IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (image_instance)); 2002 Lisp_Object device= IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (image_instance));
2001 2003
2002 MAYBE_DEVMETH (XDEVICE (device), 2004 MAYBE_DEVMETH (XDEVICE (device),
2003 xpm_instantiate, 2005 xpm_instantiate,
2004 (image_instance, instantiator, pointer_fg, 2006 (image_instance, instantiator, pointer_fg,
2005 pointer_bg, dest_mask, domain)); 2007 pointer_bg, dest_mask, domain));
2006 } 2008 }
2007 2009
2008 #endif /* HAVE_XPM */ 2010 #endif /* HAVE_XPM */
2009 2011
2027 static void 2029 static void
2028 image_mark (Lisp_Object obj, void (*markobj) (Lisp_Object)) 2030 image_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
2029 { 2031 {
2030 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj); 2032 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj);
2031 2033
2032 ((markobj) (IMAGE_SPECIFIER_ATTACHEE (image))); 2034 markobj (IMAGE_SPECIFIER_ATTACHEE (image));
2033 ((markobj) (IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image))); 2035 markobj (IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image));
2034 } 2036 }
2035 2037
2036 static Lisp_Object 2038 static Lisp_Object
2037 image_instantiate_cache_result (Lisp_Object locative) 2039 image_instantiate_cache_result (Lisp_Object locative)
2038 { 2040 {
2119 use EQUAL because we massaged the instantiator into a cons3 2121 use EQUAL because we massaged the instantiator into a cons3
2120 also containing the foreground and background of the 2122 also containing the foreground and background of the
2121 pointer face. 2123 pointer face.
2122 */ 2124 */
2123 2125
2124 subtable = make_lisp_hashtable (20, 2126 subtable = make_lisp_hash_table (20,
2125 pointerp ? HASHTABLE_KEY_CAR_WEAK 2127 pointerp ? HASH_TABLE_KEY_CAR_WEAK
2126 : HASHTABLE_KEY_WEAK, 2128 : HASH_TABLE_KEY_WEAK,
2127 pointerp ? HASHTABLE_EQUAL 2129 pointerp ? HASH_TABLE_EQUAL
2128 : HASHTABLE_EQ); 2130 : HASH_TABLE_EQ);
2129 Fputhash (make_int (dest_mask), subtable, 2131 Fputhash (make_int (dest_mask), subtable,
2130 d->image_instance_cache); 2132 d->image_instance_cache);
2131 instance = Qunbound; 2133 instance = Qunbound;
2132 } 2134 }
2133 else 2135 else
2482 static Lisp_Object 2484 static Lisp_Object
2483 mark_glyph (Lisp_Object obj, void (*markobj) (Lisp_Object)) 2485 mark_glyph (Lisp_Object obj, void (*markobj) (Lisp_Object))
2484 { 2486 {
2485 struct Lisp_Glyph *glyph = XGLYPH (obj); 2487 struct Lisp_Glyph *glyph = XGLYPH (obj);
2486 2488
2487 ((markobj) (glyph->image)); 2489 markobj (glyph->image);
2488 ((markobj) (glyph->contrib_p)); 2490 markobj (glyph->contrib_p);
2489 ((markobj) (glyph->baseline)); 2491 markobj (glyph->baseline);
2490 ((markobj) (glyph->face)); 2492 markobj (glyph->face);
2491 2493
2492 return glyph->plist; 2494 return glyph->plist;
2493 } 2495 }
2494 2496
2495 static void 2497 static void
2514 be eq. 2516 be eq.
2515 2517
2516 This isn't concerned with "unspecified" attributes, that's what 2518 This isn't concerned with "unspecified" attributes, that's what
2517 #'glyph-differs-from-default-p is for. */ 2519 #'glyph-differs-from-default-p is for. */
2518 static int 2520 static int
2519 glyph_equal (Lisp_Object o1, Lisp_Object o2, int depth) 2521 glyph_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
2520 { 2522 {
2521 struct Lisp_Glyph *g1 = XGLYPH (o1); 2523 struct Lisp_Glyph *g1 = XGLYPH (obj1);
2522 struct Lisp_Glyph *g2 = XGLYPH (o2); 2524 struct Lisp_Glyph *g2 = XGLYPH (obj2);
2523 2525
2524 depth++; 2526 depth++;
2525 2527
2526 return (internal_equal (g1->image, g2->image, depth) && 2528 return (internal_equal (g1->image, g2->image, depth) &&
2527 internal_equal (g1->contrib_p, g2->contrib_p, depth) && 2529 internal_equal (g1->contrib_p, g2->contrib_p, depth) &&
2759 (glyph)) 2761 (glyph))
2760 { 2762 {
2761 CHECK_GLYPH (glyph); 2763 CHECK_GLYPH (glyph);
2762 switch (XGLYPH_TYPE (glyph)) 2764 switch (XGLYPH_TYPE (glyph))
2763 { 2765 {
2766 default: abort ();
2764 case GLYPH_BUFFER: return Qbuffer; 2767 case GLYPH_BUFFER: return Qbuffer;
2765 case GLYPH_POINTER: return Qpointer; 2768 case GLYPH_POINTER: return Qpointer;
2766 case GLYPH_ICON: return Qicon; 2769 case GLYPH_ICON: return Qicon;
2767 default:
2768 abort ();
2769 return Qnil; /* not reached */
2770 } 2770 }
2771 } 2771 }
2772 2772
2773 /***************************************************************************** 2773 /*****************************************************************************
2774 glyph_width 2774 glyph_width
3082 return; 3082 return;
3083 3083
3084 for (elt = 0; elt < Dynarr_length (elements); elt++) 3084 for (elt = 0; elt < Dynarr_length (elements); elt++)
3085 { 3085 {
3086 struct glyph_cachel *cachel = Dynarr_atp (elements, elt); 3086 struct glyph_cachel *cachel = Dynarr_atp (elements, elt);
3087 ((markobj) (cachel->glyph)); 3087 markobj (cachel->glyph);
3088 } 3088 }
3089 } 3089 }
3090 3090
3091 static void 3091 static void
3092 update_glyph_cachel_data (struct window *w, Lisp_Object glyph, 3092 update_glyph_cachel_data (struct window *w, Lisp_Object glyph,