XDrawPoint is too slow - Xwindows

This is a discussion on XDrawPoint is too slow - Xwindows ; Hi Hi, this two lines are too slow, how can i enhance the way to draw a lot of pixels to screen? XSetForeground(Global::display, Global::gc, color); XDrawPoint(Global::display, Global::window, Global::gc, x, y); thanks from Peter (cmk128@hotmail.com)...

+ Reply to Thread
Results 1 to 6 of 6

Thread: XDrawPoint is too slow

  1. XDrawPoint is too slow

    Hi
    Hi, this two lines are too slow, how can i enhance the way to draw
    a lot of pixels to screen?

    XSetForeground(Global::display, Global::gc, color);
    XDrawPoint(Global::display, Global::window, Global::gc, x, y);

    thanks
    from Peter (cmk128@hotmail.com)


  2. Re: XDrawPoint is too slow

    cmk128@hotmail.com writes:

    > Hi
    > Hi, this two lines are too slow, how can i enhance the way to draw
    > a lot of pixels to screen?
    >
    > XSetForeground(Global::display, Global::gc, color);
    > XDrawPoint(Global::display, Global::window, Global::gc, x, y);


    Use XCreateImage(), XPutImage() and friends or, on a local display,
    XShmCreateImage() etc.

    --
    Mns Rullgrd
    mru@inprovide.com

  3. Re: XDrawPoint is too slow

    > Hi, these two lines are too slow ...

    > XSetForeground(Global::display, Global::gc, color);
    > XDrawPoint(Global::display, Global::window, Global::gc, x, y);


    Changing one or more properties of a GraphicContext, or switching
    among more than a few [or sometimes more than one] GraphicContexts,
    often is slow in current hardware. At the minimum, do not call
    XSetForeground when the color does not change!

    Group the points by color, then use XDrawPoints() to draw several
    points of the same color at one time. If the number of points
    per color is too small for much benefit, but the number of points
    is large, then draw the points first to an in-memory pixmap, and
    transfer the pixmap to the screen later.

    --



  4. Re: XDrawPoint is too slow


    John Reiser gDG

    > > Hi, these two lines are too slow ...

    >
    > > XSetForeground(Global::display, Global::gc, color);
    > > XDrawPoint(Global::display, Global::window, Global::gc, x, y);

    >
    > Changing one or more properties of a GraphicContext, or switching
    > among more than a few [or sometimes more than one] GraphicContexts,
    > often is slow in current hardware. At the minimum, do not call
    > XSetForeground when the color does not change!
    >
    > Group the points by color, then use XDrawPoints() to draw several
    > points of the same color at one time. If the number of points
    > per color is too small for much benefit, but the number of points
    > is large, then draw the points first to an in-memory pixmap, and
    > transfer the pixmap to the screen later.
    >
    > --


    Sorry, i forgot to tell you one thing. The XSetForeground() is slow
    too, what i am doing now is to create a pthread, and that pthread is
    just drawing every pixel of my two-dimensional array to screen.
    If i XSetForeground to my pthread, the performance drop 50%, if i add
    XDrawPoint too, the performance drop 99.8%, i am running my program on
    debian with AMD3400++ cpu.
    thanks
    from Peter (cmk128@hotmail.com)


  5. Re: XDrawPoint is too slow


    cmk128@hotmail.com gDG

    > John Reiser gDG
    >
    > > > Hi, these two lines are too slow ...

    > >
    > > > XSetForeground(Global::display, Global::gc, color);
    > > > XDrawPoint(Global::display, Global::window, Global::gc, x, y);

    > >
    > > Changing one or more properties of a GraphicContext, or switching
    > > among more than a few [or sometimes more than one] GraphicContexts,
    > > often is slow in current hardware. At the minimum, do not call
    > > XSetForeground when the color does not change!
    > >
    > > Group the points by color, then use XDrawPoints() to draw several
    > > points of the same color at one time. If the number of points
    > > per color is too small for much benefit, but the number of points
    > > is large, then draw the points first to an in-memory pixmap, and
    > > transfer the pixmap to the screen later.
    > >
    > > --

    >
    > Sorry, i forgot to tell you one thing. The XSetForeground() is slow
    > too, what i am doing now is to create a pthread, and that pthread is
    > just drawing every pixel of my two-dimensional array to screen.
    > If i XSetForeground to my pthread, the performance drop 50%, if i add
    > XDrawPoint too, the performance drop 99.8%, i am running my program on
    > debian with AMD3400++ cpu.
    > thanks
    > from Peter (cmk128@hotmail.com)


    Hi
    I am better to use gprof to capture the time interval of each
    function i called.
    thanks
    from Peter


  6. Re: XDrawPoint is too slow

    In comp.os.linux.development.apps cmk128@hotmail.com wrote:

    > John Reiser ???


    > > > Hi, these two lines are too slow ...

    > >
    > > > XSetForeground(Global::display, Global::gc, color);
    > > > XDrawPoint(Global::display, Global::window, Global::gc, x, y);

    > >
    > > Changing one or more properties of a GraphicContext, or switching
    > > among more than a few [or sometimes more than one] GraphicContexts,
    > > often is slow in current hardware. At the minimum, do not call
    > > XSetForeground when the color does not change!
    > >
    > > Group the points by color, then use XDrawPoints() to draw several
    > > points of the same color at one time. If the number of points
    > > per color is too small for much benefit, but the number of points
    > > is large, then draw the points first to an in-memory pixmap, and
    > > transfer the pixmap to the screen later.
    > >
    > > --


    > Sorry, i forgot to tell you one thing. The XSetForeground() is slow
    > too, what i am doing now is to create a pthread, and that pthread is
    > just drawing every pixel of my two-dimensional array to screen.
    > If i XSetForeground to my pthread, the performance drop 50%, if i add
    > XDrawPoint too, the performance drop 99.8%, i am running my program on
    > debian with AMD3400++ cpu.


    That's no information that changes anything about the tips you have
    been given. Calling XSetForeground() or XDrawPoint() requires a
    (network) communication with the the X server - the frequency (or
    model) of your CPU is typically only of minor importance. The way
    to speed things up is to minimize the number of such calls - thus
    the tip to group the points into colors to make only the minimum
    number of calls of XSetForeground() and use XDrawPoints() (note
    the 's' at the end) to send sets of points instead of just one.
    It's like when copying a file: you also wouldn't read a single
    byte from file A and then write that to file B but read in a
    large number at once and then write out all of them in one go.
    That will be a lot faster than copying each byte individually.

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

+ Reply to Thread