summaryrefslogtreecommitdiff
path: root/src/xftdraw.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-10-19 18:00:26 -0500
committerKeith Packard <keithp@keithp.com>2014-10-22 12:55:28 -0700
commite8a83226bc10afb587f6f34daac44d2ef809c85e (patch)
tree329a083193c2d840ff27d8155c9f38c2be6764f1 /src/xftdraw.c
parent214f9b5306d833e2787c75fe41dfdc9228fcb738 (diff)
downloadxorg-lib-libXft-e8a83226bc10afb587f6f34daac44d2ef809c85e.tar.gz
XftDrawSrcPicture: Use XRenderCreateSolidFill when available
Instead of creating 1x1 pictures, use the solid pictures added in Render version 0.10 Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src/xftdraw.c')
-rw-r--r--src/xftdraw.c71
1 files changed, 42 insertions, 29 deletions
diff --git a/src/xftdraw.c b/src/xftdraw.c
index 186bcb8..dfa97fb 100644
--- a/src/xftdraw.c
+++ b/src/xftdraw.c
@@ -333,39 +333,52 @@ XftDrawSrcPicture (XftDraw *draw, _Xconst XftColor *color)
* Pick one to replace at random
*/
i = (unsigned int) rand () % XFT_NUM_SOLID_COLOR;
- /*
- * Recreate if it was for the wrong screen
- */
- if (info->colors[i].screen != draw->screen && info->colors[i].pict)
- {
- XRenderFreePicture (dpy, info->colors[i].pict);
- info->colors[i].pict = 0;
- }
- /*
- * Create picture if necessary
- */
- if (!info->colors[i].pict)
- {
- Pixmap pix;
- XRenderPictureAttributes pa;
- pix = XCreatePixmap (dpy, RootWindow (dpy, draw->screen), 1, 1,
- info->solidFormat->depth);
- pa.repeat = True;
- info->colors[i].pict = XRenderCreatePicture (draw->dpy,
- pix,
- info->solidFormat,
- CPRepeat, &pa);
- XFreePixmap (dpy, pix);
+ if (info->hasSolid) {
+ /*
+ * Free any existing entry
+ */
+ if (info->colors[i].pict)
+ XRenderFreePicture (dpy, info->colors[i].pict);
+ /*
+ * Create picture
+ */
+ info->colors[i].pict = XRenderCreateSolidFill (draw->dpy, &color->color);
+ } else {
+ if (info->colors[i].screen != draw->screen && info->colors[i].pict)
+ {
+ XRenderFreePicture (dpy, info->colors[i].pict);
+ info->colors[i].pict = 0;
+ }
+ /*
+ * Create picture if necessary
+ */
+ if (!info->colors[i].pict)
+ {
+ Pixmap pix;
+ XRenderPictureAttributes pa;
+
+ pix = XCreatePixmap (dpy, RootWindow (dpy, draw->screen), 1, 1,
+ info->solidFormat->depth);
+ pa.repeat = True;
+ info->colors[i].pict = XRenderCreatePicture (draw->dpy,
+ pix,
+ info->solidFormat,
+ CPRepeat, &pa);
+ XFreePixmap (dpy, pix);
+ }
+ /*
+ * Set to the new color
+ */
+ info->colors[i].color = color->color;
+ info->colors[i].screen = draw->screen;
+ XRenderFillRectangle (dpy, PictOpSrc,
+ info->colors[i].pict,
+ &color->color, 0, 0, 1, 1);
}
- /*
- * Set to the new color
- */
info->colors[i].color = color->color;
info->colors[i].screen = draw->screen;
- XRenderFillRectangle (dpy, PictOpSrc,
- info->colors[i].pict,
- &color->color, 0, 0, 1, 1);
+
return info->colors[i].pict;
}