ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtimg.C (file contents):
Revision 1.16 by root, Mon Jun 4 16:12:55 2012 UTC vs.
Revision 1.18 by sf-exg, Tue Jun 5 12:30:37 2012 UTC

101 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 101 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
102 102
103 XRenderPictureAttributes pa; 103 XRenderPictureAttributes pa;
104 104
105 pa.repeat = RepeatPad; 105 pa.repeat = RepeatPad;
106 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); 106 Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa);
107 Pixmap tmp = XCreatePixmap (dpy, pm, w, h, format->depth); 107 Pixmap tmp = XCreatePixmap (dpy, pm, w, h, format->depth);
108 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); 108 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa);
109 XFreePixmap (dpy, tmp); 109 XFreePixmap (dpy, tmp);
110 110
111 if (kernel && params) 111 if (kernel && params)
201} 201}
202 202
203bool 203bool
204rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y) 204rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
205{ 205{
206 bool argb = format->id == PictStandardARGB32;
207
208 Display *dpy = s->display->dpy; 206 Display *dpy = s->display->dpy;
209 207
210 if (s->visual->c_class != TrueColor) 208 if (s->visual->c_class != TrueColor)
211 return false; 209 return false;
212 210
213 uint32_t red_mask, green_mask, blue_mask, alpha_mask; 211 uint32_t red_mask, green_mask, blue_mask, alpha_mask;
214 212
215 if (argb) 213 red_mask = (uint32_t)format->direct.redMask << format->direct.red;
216 { 214 green_mask = (uint32_t)format->direct.greenMask << format->direct.green;
217 red_mask = 0xff << 16; 215 blue_mask = (uint32_t)format->direct.blueMask << format->direct.blue;
218 green_mask = 0xff << 8;
219 blue_mask = 0xff;
220 alpha_mask = 0xff << 24;
221 }
222 else
223 {
224 red_mask = s->visual->red_mask;
225 green_mask = s->visual->green_mask;
226 blue_mask = s->visual->blue_mask;
227 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; 216 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha;
228 }
229 217
230 int width_r = ecb_popcount32 (red_mask); 218 int width_r = ecb_popcount32 (red_mask);
231 int width_g = ecb_popcount32 (green_mask); 219 int width_g = ecb_popcount32 (green_mask);
232 int width_b = ecb_popcount32 (blue_mask); 220 int width_b = ecb_popcount32 (blue_mask);
233 int width_a = ecb_popcount32 (alpha_mask); 221 int width_a = ecb_popcount32 (alpha_mask);
241 int sh_a = ecb_ctz32 (alpha_mask); 229 int sh_a = ecb_ctz32 (alpha_mask);
242 230
243 if (width > 32767 || height > 32767) 231 if (width > 32767 || height > 32767)
244 return false; 232 return false;
245 233
246 XImage *ximage = XCreateImage (dpy, s->visual, argb ? 32 : format->depth, ZPixmap, 0, 0, 234 XImage *ximage = XCreateImage (dpy, s->visual, format->depth, ZPixmap, 0, 0,
247 width, height, 32, 0); 235 width, height, 32, 0);
248 if (!ximage) 236 if (!ximage)
249 return false; 237 return false;
250 238
251 if (height > INT_MAX / ximage->bytes_per_line 239 if (height > INT_MAX / ximage->bytes_per_line
346 334
347 for (int i = 0; i < 3; ++i) 335 for (int i = 0; i < 3; ++i)
348 for (int j = 0; j < 3; ++j) 336 for (int j = 0; j < 3; ++j)
349 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); 337 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]);
350 338
339 XRenderSetPictureFilter (dpy, src, "good", 0, 0);
351 XRenderSetPictureTransform (dpy, src, &xfrm); 340 XRenderSetPictureTransform (dpy, src, &xfrm);
352 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); 341 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height);
353 342
354 XRenderFreePicture (dpy, src); 343 XRenderFreePicture (dpy, src);
355 XRenderFreePicture (dpy, dst); 344 XRenderFreePicture (dpy, dst);
368 357
369 return transform (new_width, new_height, RepeatNormal, matrix); 358 return transform (new_width, new_height, RepeatNormal, matrix);
370} 359}
371 360
372rxvt_img * 361rxvt_img *
362rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, double phi)
363{
364 double s = sin (phi);
365 double c = cos (phi);
366
367 double matrix[9] = {
368 c, -s, -c * x + s * y + x,
369 s, c, -s * x - c * y + y,
370 0, 0, 1
371 };
372
373 return transform (new_width, new_height, repeat, matrix);
374}
375
376rxvt_img *
373rxvt_img::convert_to (XRenderPictFormat *new_format) 377rxvt_img::convert_to (XRenderPictFormat *new_format)
374{ 378{
375 rxvt_img *img = new rxvt_img (s, new_format, w, h); 379 rxvt_img *img = new rxvt_img (s, new_format, w, h);
376 380
377 Display *dpy = s->display->dpy; 381 Display *dpy = s->display->dpy;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines