Quantcast
Channel: User rafalcieslak - Stack Overflow
Viewing all articles
Browse latest Browse all 25

Answer by rafalcieslak for Any way to speed up/reduce CPU usage when drawing with Cairo?

$
0
0

I finally forced to use maximally 25 fps, by using a lock flag.

bool lock = 0;bool needs_redraw = 0;void Redraw(){    if(lock){        needs_redraw = 1;        return;    }    //draw image to a surface    needs_redraw = 0;    lock = 1;    Glib::signal_timeout().connect(Unlock, 20);    queue_draw();}bool Unlock(){    lock = 0;    if(needs_redraw) Redraw();    return false;}void on_expose_event(something){    //copy image from surface to widget's context}

This is a sample code, but that's the idea. It will disallow redraw to be done more often then once per 20 ms.


Viewing all articles
Browse latest Browse all 25

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>