XDrawLine and optimization

Christopher Howard christopher.howard at frigidcode.com
Fri Mar 2 14:03:52 PST 2012


On 03/02/2012 12:41 PM, Adam Jackson wrote:
> On 3/2/12 4:21 PM, Christopher Howard wrote:
>> I don't have much (any?) Xlib programming savvy, but before diving
>> headlong into the Programming Manual I was hoping to get some
>> perspective. There is a particular application I use pretty often, and
>> one of the things it does is to draw filled line graphs on the screen,
>> which it does by calling XDrawLine() with the appropriate parameters for
>> each data point. Looking at the code, I was curious if I could optimize
>> this, by first drawing everything into some kind of local memory buffer
>> and then passing that into some Xlib function all at once.
>>
>> However, since XDrawLine() presumably draws the lines into a buffer
>> anyway, I'm wondering if there are any realistic gains (or any gains at
>> all) to be had by such an approach.
> 
> Might or might not help.  It really depends more what kind of lines
> you're drawing - in particular what the GC state is you're using to draw
> them and the characteristics of the surface you're drawing to - and
> which driver you're using.  Can you give more detail?
> 
> - ajax
> 


The code is from conky.c in conky-1.8.1. Before the loop it does one

code:
----------
XSetLineAttributes(display, window.gc, 1, LineSolid,
    CapButt, JoinMiter);
----------

And each actual line draw is preceded by a call to XSetForeground (the
color changes in different parts of the graph).

I'm not yet much familiar with how graphics contexts are set up in Xlib
but I think this is what you are referring to:

code:
----------
void create_gc(void)
{
    XGCValues values;

    values.graphics_exposures = 0;
    values.function = GXcopy;
    window.gc = XCreateGC(display, window.drawable,
            GCFunction | GCGraphicsExposures, &values);
}
----------

-- 
frigidcode.com
indicium.us

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20120302/4b29e255/attachment.pgp>


More information about the xorg mailing list