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.23 by sf-exg, Tue Jun 5 18:48:21 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{
208 mask_c.blue = float_to_component (b); 212 mask_c.blue = float_to_component (b);
209 mask_c.alpha = float_to_component (a); 213 mask_c.alpha = float_to_component (a);
210 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 214 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1);
211 215
212 XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 216 XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
217
218 XRenderFreePicture (dpy, src);
219 XRenderFreePicture (dpy, dst);
213} 220}
214 221
215void 222void
216rxvt_img::contrast (double r, double g, double b, double a) 223rxvt_img::contrast (double r, double g, double b, double a)
217{ 224{
228 mask_c.blue = float_to_component (b); 235 mask_c.blue = float_to_component (b);
229 mask_c.alpha = float_to_component (a); 236 mask_c.alpha = float_to_component (a);
230 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 237 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1);
231 238
232 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 239 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
240
241 XRenderFreePicture (dpy, src);
242 XRenderFreePicture (dpy, dst);
233} 243}
234 244
235bool 245bool
236rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y) 246rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
237{ 247{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines