… | |
… | |
310 | } |
310 | } |
311 | |
311 | |
312 | rxvt_img * |
312 | rxvt_img * |
313 | rxvt_img::clone () |
313 | rxvt_img::clone () |
314 | { |
314 | { |
|
|
315 | rxvt_img *img = new rxvt_img (s, format, w, h); |
|
|
316 | |
315 | GC gc = XCreateGC (s->display->dpy, pm, 0, 0); |
317 | GC gc = XCreateGC (s->display->dpy, pm, 0, 0); |
316 | Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, format->depth); |
|
|
317 | XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0); |
318 | XCopyArea (s->display->dpy, pm, img->pm, gc, 0, 0, w, h, 0, 0); |
318 | XFreeGC (s->display->dpy, gc); |
319 | XFreeGC (s->display->dpy, gc); |
319 | return new rxvt_img (s, format, w, h, pm2); |
|
|
320 | } |
320 | } |
321 | |
321 | |
322 | rxvt_img * |
322 | rxvt_img * |
|
|
323 | rxvt_img::sub_rect (int x, int y, int width, int height, int repeat) |
|
|
324 | { |
|
|
325 | rxvt_img *img = new rxvt_img (s, format, width, height); |
|
|
326 | |
|
|
327 | Display *dpy = s->display->dpy; |
|
|
328 | XRenderPictureAttributes pa; |
|
|
329 | pa.repeat = repeat; |
|
|
330 | Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); |
|
|
331 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
|
|
332 | |
|
|
333 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, width, height); |
|
|
334 | |
|
|
335 | XRenderFreePicture (dpy, src); |
|
|
336 | XRenderFreePicture (dpy, dst); |
|
|
337 | |
|
|
338 | return img; |
|
|
339 | } |
|
|
340 | |
|
|
341 | rxvt_img * |
323 | rxvt_img::transform (int new_width, int new_height, int repeat, double matrix[9]) |
342 | rxvt_img::transform (int new_width, int new_height, double matrix[9], int repeat) |
324 | { |
343 | { |
325 | rxvt_img *img = new rxvt_img (s, format, new_width, new_height); |
344 | rxvt_img *img = new rxvt_img (s, format, new_width, new_height); |
326 | |
345 | |
327 | Display *dpy = s->display->dpy; |
346 | Display *dpy = s->display->dpy; |
328 | XRenderPictureAttributes pa; |
347 | XRenderPictureAttributes pa; |
… | |
… | |
353 | w / (double)new_width, 0, 0, |
372 | w / (double)new_width, 0, 0, |
354 | 0, h / (double)new_height, 0, |
373 | 0, h / (double)new_height, 0, |
355 | 0, 0, 1 |
374 | 0, 0, 1 |
356 | }; |
375 | }; |
357 | |
376 | |
358 | return transform (new_width, new_height, RepeatNormal, matrix); |
377 | return transform (new_width, new_height, matrix); |
359 | } |
378 | } |
360 | |
379 | |
361 | rxvt_img * |
380 | rxvt_img * |
362 | rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, double phi) |
381 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi, int repeat) |
363 | { |
382 | { |
364 | double s = sin (phi); |
383 | double s = sin (phi); |
365 | double c = cos (phi); |
384 | double c = cos (phi); |
366 | |
385 | |
367 | double matrix[9] = { |
386 | double matrix[9] = { |
368 | c, -s, -c * x + s * y + x, |
387 | c, -s, -c * x + s * y + x, |
369 | s, c, -s * x - c * y + y, |
388 | s, c, -s * x - c * y + y, |
370 | 0, 0, 1 |
389 | 0, 0, 1 |
371 | }; |
390 | }; |
372 | |
391 | |
373 | return transform (new_width, new_height, repeat, matrix); |
392 | return transform (new_width, new_height, matrix, repeat); |
374 | } |
393 | } |
375 | |
394 | |
376 | rxvt_img * |
395 | rxvt_img * |
377 | rxvt_img::convert_to (XRenderPictFormat *new_format) |
396 | rxvt_img::convert_to (XRenderPictFormat *new_format) |
378 | { |
397 | { |