/** Draw a scaled icon. */ int PutScaledRenderIcon(IconNode *icon, ScaledIconNode *node, Drawable d, int x, int y) { #ifdef USE_XRENDER Picture dest; Picture source; XRenderPictFormat *fp; XRenderPictureAttributes pa; int width, height; Assert(icon); if(!haveRender || !icon->useRender) { return 0; } source = node->imagePicture; if(source != None) { fp = JXRenderFindVisualFormat(display, rootVisual); Assert(fp); pa.subwindow_mode = IncludeInferiors; dest = JXRenderCreatePicture(display, d, fp, CPSubwindowMode, &pa); if(node->width == 0) { width = icon->image->width; } else { width = node->width; } if(node->height == 0) { height = icon->image->height; } else { height = node->height; } JXRenderComposite(display, PictOpOver, source, node->maskPicture, dest, 0, 0, 0, 0, x, y, width, height); JXRenderFreePicture(display, dest); } return 1; #else return 0; #endif }
/** Draw a scaled icon. */ int PutScaledRenderIcon(IconNode *icon, ScaledIconNode *node, Drawable d, int x, int y) { #ifdef USE_XRENDER Picture dest; Picture source; Picture alpha; XRenderPictFormat *fp; XRenderPictureAttributes pa; XTransform xf; int width, height; int xscale, yscale; Assert(icon); if(!haveRender || !icon->useRender) { return 0; } source = node->imagePicture; alpha = node->alphaPicture; if(source != None) { fp = JXRenderFindVisualFormat(display, rootVisual); Assert(fp); pa.subwindow_mode = IncludeInferiors; dest = JXRenderCreatePicture(display, d, fp, CPSubwindowMode, &pa); if(node->width == 0) { width = icon->image->width; xscale = 65536; } else { width = node->width; xscale = (icon->image->width << 16) / width; } if(node->height == 0) { height = icon->image->height; yscale = 65536; } else { height = node->height; yscale = (icon->image->height << 16) / height; } memset(&xf, 0, sizeof(xf)); xf.matrix[0][0] = xscale; xf.matrix[1][1] = yscale; xf.matrix[2][2] = 65536; XRenderSetPictureTransform(display, source, &xf); XRenderSetPictureFilter(display, source, FilterBest, NULL, 0); XRenderSetPictureTransform(display, alpha, &xf); XRenderSetPictureFilter(display, alpha, FilterBest, NULL, 0); JXRenderComposite(display, PictOpOver, source, alpha, dest, 0, 0, 0, 0, x, y, width, height); JXRenderFreePicture(display, dest); } return 1; #else return 0; #endif }