Are Xlib's graphic functions fast?
I am a absolutely new GUI programmer with very little experience (except some small apps in Java). I am considering writing a small app that needs simple 2D graphs. I don't know if I should use Xlib or cairo to do the plots.
Is Xlib's graphic components fast compared to, say, cairo? If cairo is written using Xlib, then the answer would obviously be yes, but I开发者_StackOverflow don't know if it is.
Xlib doesn't do any graphics itself. If you are talking about server graphics primitives, they are usually pretty fast these days, but they are also fairly limited (lines, rectangles, polygons, elipses, trapezoids; solid color fills) and tend not to get any special acceleration by the graphics drivers.
Honestly, you ought not program against Xlib or xcb directly. Instead, use a toolkit like Qt, GTK+ or FLTK (or wxWindows, or, or....). They provide a framework for building applications, as well as abstracting away the X details into an easy to use API.
Generally all of the the libraries which leverage Xlib to do their drawing do so in an optimized manner. You would have trouble matching the performance of say, scrolling on your own. You also have no widgets and a library which makes the simplest tasks thousand-line behemoths.
精彩评论