Graphic toolkits are complicated, but they all start by drawing a pixel, I need to repeat this basic action. Suppose there is a running Xorg, in it a program that in any way creates itself a Xorg-window, in this window you need to draw pixels.

Condition:

Only standard Linux kernel libraries. No GTK / Qt / OpenGL / Cairo and Xorg embedded methods.

Questions:

  1. What, actually, to draw? (I would like to hear a specific answer.)
  2. How to draw? (Examples / references to examples are desirable, the topic is rather unpopular, there is little information.)
  3. The advantages of one way or another.

UPD: In response to the comment by @KoVadim, everything did not fit, I will write to the main question as a general explanation.

If this is a Xorg window, then it should draw
using XDrawPoint

I want to say that most of the graph. tulkit does not draw a picture through the features of the graphic server. Qt draws with his bike, GTK does it with Cairo, and rightly so. In the same Wayland, which came to replace X, there is no such functionality at all. Wayland simply makes the window leaving the entire drawing in the window to the toolkit.

Let us dwell on Cairo, he probably uses something low-level, I want to know what. (not enough experience to dig)

I tried framebuffer, I know everything about him. Firstly it is better to use DRM. Secondly, this is all wrong. (And maybe DRM is quite suitable, but I did not find how to use it, I did not find Xorg, there is no documentation and that's it.)

    2 answers 2

    LibXCB is considered more modern and more productive than xlib, but the documentation on it is not complete. Drawing something by pixels is very unproductive, so there is a set of primitives, some of which are usually supported by hardware. There is an example of drawing some primitives except for pixmaps. Cairo uses libXCB.

    By the way, if you figure it out, maybe answer my question four years ago?

    • Does Cairo exactly use libXCB? It is written on the wiki that XCB is one of the backends where Cairo can display a picture. At the expense of performance, primitives are also drawn by pixels. Well, most of the toolkits can work without hardware rendering, so the software draws primitives. And in any case: If there is something in XCB, then it’s really possible to do it yourself. XCB is just an add-on for something. Also, I repeat - how do tulkits cope in wayland? - prish
    • @prish, not necessarily by pixels, in groups faster, and if only pixels are left out of all the primitives, then hardware acceleration will be impossible. XCB is of course an add-on to the X-protocol and extensions to it. Yes, one of the backends, and it is used by default for displaying XOrg windows. - sercxjo
    • Yeah, now I understand. Cairo describes the drawing algorithm itself, and the drawing is implemented separately for each backend, be it OpenGL or libXCB. I hope I did understand correctly. Thank. - prish
    • @prish, if the user draws a line, say, then its coordinates are transferred to the backend, and then depending on it, he either draws it on points himself, or sends it on, for example, to xlib, or even does nothing at all, but keeps the coordinates as is or recalculated for example in SVG or PDF. - sercxjo

    Since Xorg is not part of the system kernel, it’s "a little bit complicated" to draw in the XOrg window with the kernel tools. Therefore, there are two options: