… | |
… | |
59 | } |
59 | } |
60 | |
60 | |
61 | rxvt_img * |
61 | rxvt_img * |
62 | rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) |
62 | rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) |
63 | { |
63 | { |
|
|
64 | Display *dpy = s->display->dpy; |
|
|
65 | |
64 | int width = gdk_pixbuf_get_width (pb); |
66 | int width = gdk_pixbuf_get_width (pb); |
65 | int height = gdk_pixbuf_get_height (pb); |
67 | int height = gdk_pixbuf_get_height (pb); |
66 | |
68 | |
67 | if (width > 32767 || height > 32767) // well, we *could* upload in chunks |
69 | if (width > 32767 || height > 32767) // well, we *could* upload in chunks |
68 | rxvt_fatal ("rxvt_img::new_from_pixbuf: image too big (maximum size 32768x32768).\n"); |
70 | rxvt_fatal ("rxvt_img::new_from_pixbuf: image too big (maximum size 32768x32768).\n"); |
… | |
… | |
78 | xi.xoffset = 0; |
80 | xi.xoffset = 0; |
79 | xi.format = ZPixmap; |
81 | xi.format = ZPixmap; |
80 | xi.byte_order = MSBFirst; // maybe go for host byte order, because servers are usually local? |
82 | xi.byte_order = MSBFirst; // maybe go for host byte order, because servers are usually local? |
81 | xi.bitmap_unit = 32; |
83 | xi.bitmap_unit = 32; |
82 | xi.bitmap_bit_order = MSBFirst; |
84 | xi.bitmap_bit_order = MSBFirst; |
83 | xi.bitmap_pad = 32; |
85 | xi.bitmap_pad = BitmapPad (dpy); |
84 | xi.depth = depth; |
86 | xi.depth = depth; |
85 | xi.bytes_per_line = 0; |
87 | xi.bytes_per_line = 0; |
86 | xi.bits_per_pixel = 32; |
88 | xi.bits_per_pixel = 32; |
87 | xi.red_mask = 0x00ff0000; |
89 | xi.red_mask = 0x00ff0000; |
88 | xi.green_mask = 0x0000ff00; |
90 | xi.green_mask = 0x0000ff00; |
… | |
… | |
108 | unsigned char *data = row; |
110 | unsigned char *data = row; |
109 | |
111 | |
110 | if (depth == 24) |
112 | if (depth == 24) |
111 | for (int x = 0; x < width; x++) |
113 | for (int x = 0; x < width; x++) |
112 | { |
114 | { |
|
|
115 | asm volatile("nop"); |
113 | r = *data++; |
116 | r = *data++; |
114 | g = *data++; |
117 | g = *data++; |
115 | b = *data++; |
118 | b = *data++; |
116 | *line++ = 0; |
119 | *line++ = 0; |
117 | *line++ = r; |
120 | *line++ = r; |
118 | *line++ = g; |
121 | *line++ = g; |
119 | *line++ = b; |
122 | *line++ = b; |
|
|
123 | asm volatile("nop"); |
120 | } |
124 | } |
121 | else |
125 | else |
122 | for (int x = 0; x < width; x++) |
126 | for (int x = 0; x < width; x++) |
123 | { |
127 | { |
124 | r = *data++; |
128 | uint32_t v = *(uint32_t *)data; data += 4; |
125 | g = *data++; |
129 | v = ecb_big_endian () ? ecb_rotr32 (v, 8) : ecb_rotl32 (v, 8); |
126 | b = *data++; |
130 | *(uint32_t *)line = x; line += 4; |
127 | a = *data++; |
|
|
128 | *line++ = a; |
|
|
129 | *line++ = r; |
|
|
130 | *line++ = g; |
|
|
131 | *line++ = b; |
|
|
132 | } |
131 | } |
133 | |
132 | |
134 | row += rowstride; |
133 | row += rowstride; |
135 | } |
134 | } |
136 | |
|
|
137 | Display *dpy = s->display->dpy; |
|
|
138 | |
135 | |
139 | rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height); |
136 | rxvt_img *img = new rxvt_img (s, XRenderFindStandardFormat (dpy, depth == 24 ? PictStandardRGB24 : PictStandardARGB32), 0, 0, width, height); |
140 | img->alloc (); |
137 | img->alloc (); |
141 | |
138 | |
142 | GC gc = XCreateGC (dpy, img->pm, 0, 0); |
139 | GC gc = XCreateGC (dpy, img->pm, 0, 0); |