comparison src/fringe.c @ 53955:7d8c228c1f02

(init_fringe_bitmap) [MAC_OS, WORDS_BIG_ENDIAN]: Perform byte-swapping.
author Kim F. Storm <storm@cua.dk>
date Sun, 15 Feb 2004 16:19:00 +0000
parents 33cf8d1b409d
children 26dc8943ee64
comparison
equal deleted inserted replaced
53954:7c480cd23ecc 53955:7d8c228c1f02
1015 /* Initialize bitmap bit. 1015 /* Initialize bitmap bit.
1016 1016
1017 On X, we bit-swap the built-in bitmaps and reduce bitmap 1017 On X, we bit-swap the built-in bitmaps and reduce bitmap
1018 from short to char array if width is <= 8 bits. 1018 from short to char array if width is <= 8 bits.
1019 1019
1020 On W32 and MAC, there's no need to do this. 1020 On MAC with big-endian CPU, we need to byte-swap each short.
1021
1022 On W32 and MAC (little endian), there's no need to do this.
1021 */ 1023 */
1022 1024
1023 void 1025 void
1024 init_fringe_bitmap (which, fb, once_p) 1026 init_fringe_bitmap (which, fb, once_p)
1025 enum fringe_bitmap_type which; 1027 enum fringe_bitmap_type which;
1031 #if defined (HAVE_X_WINDOWS) 1033 #if defined (HAVE_X_WINDOWS)
1032 static unsigned char swap_nibble[16] 1034 static unsigned char swap_nibble[16]
1033 = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */ 1035 = { 0x0, 0x8, 0x4, 0xc, /* 0000 1000 0100 1100 */
1034 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */ 1036 0x2, 0xa, 0x6, 0xe, /* 0010 1010 0110 1110 */
1035 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */ 1037 0x1, 0x9, 0x5, 0xd, /* 0001 1001 0101 1101 */
1036 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */ 1038 0x3, 0xb, 0x7, 0xf }; /* 0011 1011 0111 1111 */
1037 unsigned short *bits = fb->bits; 1039 unsigned short *bits = fb->bits;
1038 int j; 1040 int j;
1039 1041
1040 if (fb->width <= 8) 1042 if (fb->width <= 8)
1041 { 1043 {
1059 | (swap_nibble[(b>>8) & 0xf] << 4) 1061 | (swap_nibble[(b>>8) & 0xf] << 4)
1060 | (swap_nibble[(b>>12) & 0xf])); 1062 | (swap_nibble[(b>>12) & 0xf]));
1061 *bits++ = (b >> (16 - fb->width)); 1063 *bits++ = (b >> (16 - fb->width));
1062 } 1064 }
1063 } 1065 }
1064 #endif 1066 #endif /* HAVE_X_WINDOWS */
1067
1068 #if defined (MAC_OS) && defined (WORDS_BIG_ENDIAN)
1069 unsigned short *bits = fb->bits;
1070 for (j = 0; j < fb->height; j++)
1071 {
1072 unsigned short b = *bits;
1073 *bits++ = ((b >> 8) & 0xff) | ((b & 0xff) << 8);
1074 }
1075 #endif /* MAC_OS && WORDS_BIG_ENDIAN */
1065 } 1076 }
1066 1077
1067 if (!once_p) 1078 if (!once_p)
1068 { 1079 {
1069 Fdestroy_fringe_bitmap (make_number (which)); 1080 Fdestroy_fringe_bitmap (make_number (which));
1337 1348
1338 for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++) 1349 for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++)
1339 rif->destroy_fringe_bitmap (bt); 1350 rif->destroy_fringe_bitmap (bt);
1340 } 1351 }
1341 1352
1342 #endif 1353 #endif /* HAVE_NTGUI */
1343 1354
1344 #endif /* HAVE_WINDOW_SYSTEM */ 1355 #endif /* HAVE_WINDOW_SYSTEM */
1345 1356
1346 /* arch-tag: 04596920-43eb-473d-b319-82712338162d 1357 /* arch-tag: 04596920-43eb-473d-b319-82712338162d
1347 (do not change this comment) */ 1358 (do not change this comment) */