… | |
… | |
71 | |
71 | |
72 | // since we require rgb24/argb32 formats from xrender we assume |
72 | // since we require rgb24/argb32 formats from xrender we assume |
73 | // that both 24 and 32 bpp MUST be supported by any screen that supports xrender |
73 | // that both 24 and 32 bpp MUST be supported by any screen that supports xrender |
74 | int depth = gdk_pixbuf_get_has_alpha (pb) ? 32 : 24; |
74 | int depth = gdk_pixbuf_get_has_alpha (pb) ? 32 : 24; |
75 | |
75 | |
|
|
76 | int byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
|
|
77 | |
76 | XImage xi; |
78 | XImage xi; |
77 | |
79 | |
78 | xi.width = width; |
80 | xi.width = width; |
79 | xi.height = height; |
81 | xi.height = height; |
80 | xi.xoffset = 0; |
82 | xi.xoffset = 0; |
81 | xi.format = ZPixmap; |
83 | xi.format = ZPixmap; |
82 | xi.byte_order = LSBFirst; // maybe go for host byte order, because servers are usually local? |
84 | xi.byte_order = ImageByteOrder (dpy); |
83 | xi.bitmap_unit = 32; //XY only, unused |
85 | xi.bitmap_unit = 32; //XY only, unused |
84 | xi.bitmap_bit_order = LSBFirst; //XY only, unused |
86 | xi.bitmap_bit_order = LSBFirst; //XY only, unused |
85 | xi.bitmap_pad = BitmapPad (dpy); |
87 | xi.bitmap_pad = BitmapPad (dpy); |
86 | xi.depth = depth; |
88 | xi.depth = depth; |
87 | xi.bytes_per_line = 0; |
89 | xi.bytes_per_line = 0; |
88 | xi.bits_per_pixel = 32; //Z only |
90 | xi.bits_per_pixel = 32; //Z only |
89 | xi.red_mask = 0x000000ff; //Z only |
91 | xi.red_mask = 0x00000000; //Z only, unused |
90 | xi.green_mask = 0x0000ff00; //Z only |
92 | xi.green_mask = 0x00000000; //Z only, unused |
91 | xi.blue_mask = 0x00ff0000; //Z only |
93 | xi.blue_mask = 0x00000000; //Z only, unused |
92 | xi.obdata = 0; // probbaly unused |
94 | xi.obdata = 0; // probably unused |
|
|
95 | |
|
|
96 | bool byte_order_mismatch = byte_order != xi.byte_order; |
93 | |
97 | |
94 | if (!XInitImage (&xi)) |
98 | if (!XInitImage (&xi)) |
95 | rxvt_fatal ("unable to initialise ximage, please report.\n"); |
99 | rxvt_fatal ("unable to initialise ximage, please report.\n"); |
96 | |
100 | |
97 | if (height > INT_MAX / xi.bytes_per_line) |
101 | if (height > INT_MAX / xi.bytes_per_line) |
… | |
… | |
115 | { |
119 | { |
116 | uint8_t r = *src++; |
120 | uint8_t r = *src++; |
117 | uint8_t g = *src++; |
121 | uint8_t g = *src++; |
118 | uint8_t b = *src++; |
122 | uint8_t b = *src++; |
119 | |
123 | |
120 | uint32_t v = r | (g << 8) | (b << 16); |
124 | uint32_t v = (r << 16) | (g << 8) | b; |
121 | |
125 | |
122 | if (ecb_big_endian ()) |
126 | if (ecb_big_endian ()) |
|
|
127 | v = ecb_bswap32 (v); |
|
|
128 | |
|
|
129 | if (byte_order_mismatch) |
123 | v = ecb_bswap32 (v); |
130 | v = ecb_bswap32 (v); |
124 | |
131 | |
125 | *dst++ = v; |
132 | *dst++ = v; |
126 | } |
133 | } |
127 | else |
134 | else |
128 | for (int x = 0; x < width; x++) |
135 | for (int x = 0; x < width; x++) |
129 | { |
136 | { |
130 | uint32_t v = *(uint32_t *)src; src += 4; |
137 | uint32_t v = *(uint32_t *)src; src += 4; |
131 | |
138 | |
132 | if (ecb_big_endian ()) |
139 | if (ecb_little_endian ()) |
|
|
140 | v = ecb_bswap32 (v); |
|
|
141 | |
|
|
142 | v = ecb_rotr32 (v, 8); |
|
|
143 | |
|
|
144 | if (byte_order_mismatch) |
133 | v = ecb_bswap32 (v); |
145 | v = ecb_bswap32 (v); |
134 | |
146 | |
135 | *dst++ = v; |
147 | *dst++ = v; |
136 | } |
148 | } |
137 | |
149 | |