On Fri, 11 Oct 2019 10:58:44 +0100 Brandon Dowdy <brandon...@gmail.com> said:

> Hi,
> 
> I know this mailing list is mainly for anything about Wayland and I know
> that Wayland doesn't deal with rendering, so this may be the wrong place to
> ask or get advice about this, but I just wanted to get some advice (and may
> be some ideas as well) for what I can replace X Pixmaps with(if I'm able to
> and if it's possible to do so, of course) since I'm feeling a bit stuck
> with that at the moment.
> 
> I am working on a fork of a window decorator and I want to replace X
> Pixmaps with something else(or at least, an equivalent to it) so I can make
> it less X-specific and less X-reliant (and kind-of more cross-platform,
> perhaps...? If I know what I'm talking about and if you know what I'm
> talking about, that is) for rendering window decorations.
> 
> Is there anything that I can replace X Pixmaps with? I was mainly thinking
> cairo_surfaces from Cairo(unless I'm missing the point with this or I'm
> missing the point with how Cairo is *supposed* to be used) or EGLSurfaces
> from EGL(but it sounds like it would be a bit complicated(and just a *tad*
> bit over-engineered, perhaps...?) to set up *just* for a window decorator,
> but I don't know, I just want your opinion on this), but I don't know if
> those would be suitable to use for a window decorator or not(kind-of my
> third concern about this).

It all depends on the use case. If it is meant to be displayed in a window
(surface) directly (this is the content of the window in a buffer) then you
will want wayland shm buffers or dmabufs (from drm). If it's for the purposes
of drawing/rendering which is what I think you want mostly (rendering *TO* a
target shm or dmabuf in the end), then this is totally tied to your rendering
system.

I suspect you are using X requests to do this (XCopyArea, XFillRectangle,
XFillPolygon etc.). All of these are requests for the XServer to do this work
for you remotely as a client, thus X provides pixmaps as pixel buffers/storage
objects. There is XPutImage/XShmPutImage and friends which which is about
copying data from a client to the server (or back the other way). As you are no
longer asking your display server to render this is no longer needed. It's all
local. It depends how you render locally in the end.

At the most basic: malloc() your own blobs of memory for pixel storage and write
your own code to process pixels by walking the memory and copying data from one
place in memory to another, write values in (draw rectangles, lines, copy 2D
regions breaking them into spans etc. etc.). This is by far the most portable
as then the only problem in the end is what pointer for what buffer to write
to and its dimensions. It has no dependencies beyond the final output
targets which you will need anyway. The final buffer you present in can be a
shm buffer itself, thus just another pointer like all your other memory but
the memory is obtained by creating a shared memory segment, not malloc. You can
run without a display system and target /dev/fb device you mmaped in, can
target a shm buffer you send to the xserver with XShmPutImage or just XPutImage
for the slower network capable path. You can also upload those pixels to a
texture with glTextImage/glTextSubImage etc. etc. ... the big downside being
that you have to write all your own rendering code, optimize it etc. ... you
will learn a lot in the process but it'll take a lot of time and effort.

There are many libraries out there that can do this for you in various ways and
at various levels. That is the point of toolkits. They tend to give you the
highest level APIs and hide almost all of the details so you don't need to know
or care. You can then look for the lower levels of those toolkits if you want
more control. There are a fair few to choose from.

You can use rendering libraries like cairo or drop one level down and use
pixman too. You could just use OpenGL (then learn EGL+Opengl-ES2 for best
portability - that's my suggestion if you plan on going down that path) or even
Vulkan if you want to be trendy. Note that these libraries will pretty much
then require a GPU accelerator. There are software implementations of OpenGL
rendering stacks but they tend to be rather slow compared to special hand
crafted 2D rendering code.

> Also, are there (available) replacements or substitutes or alternatives to
> using X Pixmaps that don't involve using X functions or do I have to try
> substituting X Pixmaps on my own (somehow?)
> 
> I think that's it for all of the information and all of the questions that
> I have written down and thought about(at least, for now). I've been
> thinking and wondering about this for a little while now and I hope all of
> this is clear and understandable to you.
> 
> I hope to seek a response from you soon.
> 
> Cheers,
> 
> Brandon Dowdy


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
Carsten Haitzler - ras...@rasterman.com

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to