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.21 by sf-exg, Tue Jun 5 14:59:44 2012 UTC vs.
Revision 1.22 by sf-exg, Tue Jun 5 15:18:23 2012 UTC

119 119
120 for (int i = 0; i < width; i++) 120 for (int i = 0; i < width; i++)
121 params[i+2] = XDoubleToFixed (kernel[i] / sum); 121 params[i+2] = XDoubleToFixed (kernel[i] / sum);
122} 122}
123 123
124void 124rxvt_img *
125rxvt_img::blur (int rh, int rv) 125rxvt_img::blur (int rh, int rv)
126{ 126{
127 if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV)) 127 if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV))
128 return; 128 return clone ();
129 129
130 Display *dpy = s->display->dpy; 130 Display *dpy = s->display->dpy;
131 int size = max (rh, rv) * 2 + 1; 131 int size = max (rh, rv) * 2 + 1;
132 double *kernel = (double *)malloc (size * sizeof (double)); 132 double *kernel = (double *)malloc (size * sizeof (double));
133 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 133 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
134 rxvt_img *img = new rxvt_img (s, format, w, h);
134 135
135 XRenderPictureAttributes pa; 136 XRenderPictureAttributes pa;
136 137
137 pa.repeat = RepeatPad; 138 pa.repeat = RepeatPad;
138 Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa); 139 Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa);
140 Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa);
141
139 Pixmap tmp = XCreatePixmap (dpy, pm, w, h, format->depth); 142 Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth);
140 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); 143 Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa);
141 XFreePixmap (dpy, tmp); 144 XFreePixmap (dpy, tmp_pm);
142 145
143 if (kernel && params) 146 if (kernel && params)
144 { 147 {
145 size = rh * 2 + 1; 148 size = rh * 2 + 1;
146 get_gaussian_kernel (rh, size, kernel, params); 149 get_gaussian_kernel (rh, size, kernel, params);
148 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 151 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
149 XRenderComposite (dpy, 152 XRenderComposite (dpy,
150 PictOpSrc, 153 PictOpSrc,
151 src, 154 src,
152 None, 155 None,
153 dst, 156 tmp,
154 0, 0, 157 0, 0,
155 0, 0, 158 0, 0,
156 0, 0, 159 0, 0,
157 w, h); 160 w, h);
158
159 ::swap (src, dst);
160 161
161 size = rv * 2 + 1; 162 size = rv * 2 + 1;
162 get_gaussian_kernel (rv, size, kernel, params); 163 get_gaussian_kernel (rv, size, kernel, params);
163 ::swap (params[0], params[1]); 164 ::swap (params[0], params[1]);
164 165
165 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 166 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
166 XRenderComposite (dpy, 167 XRenderComposite (dpy,
167 PictOpSrc, 168 PictOpSrc,
168 src, 169 tmp,
169 None, 170 None,
170 dst, 171 dst,
171 0, 0, 172 0, 0,
172 0, 0, 173 0, 0,
173 0, 0, 174 0, 0,
176 177
177 free (kernel); 178 free (kernel);
178 free (params); 179 free (params);
179 XRenderFreePicture (dpy, src); 180 XRenderFreePicture (dpy, src);
180 XRenderFreePicture (dpy, dst); 181 XRenderFreePicture (dpy, dst);
182 XRenderFreePicture (dpy, tmp);
183
184 return img;
181} 185}
182 186
183static Picture 187static Picture
184create_xrender_mask (Display *dpy, Drawable drawable, Bool argb) 188create_xrender_mask (Display *dpy, Drawable drawable, Bool argb)
185{ 189{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines