Re: What can I replace X Pixmaps with?

2019-10-11 Thread Pekka Paalanen
On Fri, 11 Oct 2019 10:58:44 +0100
Brandon Dowdy  wrote:

> 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.

Hello,

to complement the other answers, you probably know that X11 Pixmaps are
server-side pixel storage you can manipulate by sending X11 requests.
This is useful because X11 has drawing commands, and keeping some data
stashed in the server can make things much more efficient. Wayland has
no drawing commands as such; you cannot tell the display server to do
your drawing. Hence Wayland has no concept of pixmaps either, no
server-side pixel storage you could tell the display server to operate
on.

Since on Wayland there is no concept of pixmaps at all, there is no
replacement really.

> 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.

Wayland started with client-side window decorations. Clients draw all
decorations into their own buffer as an integral part of their window,
and the server adds nothing. Since then, protocol extensions have
appeared that allow negotiating with the server to use server-side
decorations. However, I don't think there is any generic interface for
plugging a window decorator into a server. So you're not just
missing a pixel storage, you're missing everything for the interface.

You'll have to change your whole architecture, so that all the
decorating happens purely inside the client or at least never involves
the display server. This also implies that you cannot decorate
application windows without the applications having explicit support
for your decorator engine.

Or, if you are targeting Wayland display servers that do support
server-side decorations, then you need to integrate with those display
servers in particular.


Thanks,
pq


pgpWffLTUXdnq.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Re: What can I replace X Pixmaps with?

2019-10-11 Thread The Rasterman
On Fri, 11 Oct 2019 10:58:44 +0100 Brandon Dowdy  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


Re: What can I replace X Pixmaps with?

2019-10-11 Thread Simon Ser
Hi,

On Friday, October 11, 2019 12:58 PM, Brandon Dowdy  
wrote:

> 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).
>
> 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.

IMHO Cairo is a fine choice for this use-case. However, what are your
plans to make your window decorator work on Wayland? Is it tied to a
specific Wayland compositor?
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

What can I replace X Pixmaps with?

2019-10-11 Thread Brandon Dowdy
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).

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
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel