<div dir="ltr"><div>I believe wl_surface.damage should be defined as "the same as w_surface.buffer_damage if the only transforms are due to an integer buffer scale and the 8 possible buffer transforms". This means it is undefined if the wl_scalar proposal is used, and avoids the need to define it for any future transform possibilities.<br><br></div><div>For very similar reasons I believe the wl_scalar and the subsurface apis will need to be changed to be in buffer coordinates. So a defined suffix (such as _buffer or _pixels) is probably a good idea so these can be fixed in a similar way.<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 9, 2015 at 7:06 AM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, 6 Nov 2015 12:55:19 -0600<br>
Derek Foreman <<a href="mailto:derekf@osg.samsung.com">derekf@osg.samsung.com</a>> wrote:<br>
<br>
> wl_surface.damage uses surface local co-ordinates.<br>
><br>
> Buffer scale and buffer transforms came along, and EGL surfaces<br>
> have no understanding of them.<br>
><br>
> Theoretically, clients pass damage rectangles - in Y-inverted surface<br>
> co-ordinates) to EGLSwapBuffersWithDamage, and the EGL implementation<br>
> passed them on to wayland. However, for this to work the EGL<br>
> implementation must be able to flip those rectangles into the space<br>
> the compositor is expecting, but it's unable to do so because it<br>
> doesn't know the height of the transformed buffer.<br>
><br>
> So, currently, EGLSwapBuffersWithDamage is unusable and EGLSwapBuffers<br>
> has to pass (0,0) - (INT32_MAX, INT32_MAX) damage to function.<br>
><br>
> wl_surface.buffer_damage allows damage to be registered on a surface<br>
> in buffer co-ordinates, avoiding this problem.<br>
><br>
> Credit where it's due, these ideas are not entirely my own:<br>
> Over a year ago the idea of changing damage co-ordinates to buffer<br>
> co-ordinates was suggested (by Jason Ekstrand), and it was at least<br>
> partially rejected and abandoned. At the time it was also suggested<br>
> (by Pekka Paalanen) that adding a new wl_surface.buffer_damage request<br>
> was another option.<br>
><br>
<br>
Hi Derek,<br>
<br>
please mention <a href="https://bugs.freedesktop.org/show_bug.cgi?id=78190" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=78190</a> in<br>
this patch.<br>
<br>
> Signed-off-by: Derek Foreman <<a href="mailto:derekf@osg.samsung.com">derekf@osg.samsung.com</a>><br>
> ---<br>
><br>
> Necro-posting on:<br>
> <a href="http://lists.freedesktop.org/archives/wayland-devel/2014-February/013440.html" rel="noreferrer" target="_blank">http://lists.freedesktop.org/archives/wayland-devel/2014-February/013440.html</a><br>
> and<br>
> <a href="http://lists.freedesktop.org/archives/wayland-devel/2014-February/013442.html" rel="noreferrer" target="_blank">http://lists.freedesktop.org/archives/wayland-devel/2014-February/013442.html</a><br>
><br>
> This came up on IRC again the other day, and it's still an unsolved problem...<br>
> I'm posting this as RFC to see if anyone's interested in it - I'll do an<br>
> implementation if we can get an agreement on the protocol text.<br>
<br>
Thanks for picking this up!<br>
<br>
> protocol/wayland.xml | 44 ++++++++++++++++++++++++++++++++++++++++++--<br>
> 1 file changed, 42 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/protocol/wayland.xml b/protocol/wayland.xml<br>
> index 9c22d45..1cb2f66 100644<br>
> --- a/protocol/wayland.xml<br>
> +++ b/protocol/wayland.xml<br>
> @@ -176,7 +176,7 @@<br>
> </event><br>
> </interface><br>
><br>
> - <interface name="wl_compositor" version="3"><br>
> + <interface name="wl_compositor" version="4"><br>
> <description summary="the compositor singleton"><br>
> A compositor. This object is a singleton global. The<br>
> compositor is in charge of combining the contents of multiple<br>
> @@ -986,7 +986,7 @@<br>
> </event><br>
> </interface><br>
><br>
> - <interface name="wl_surface" version="3"><br>
> + <interface name="wl_surface" version="4"><br>
> <description summary="an onscreen surface"><br>
> A surface is a rectangular area that is displayed on the screen.<br>
> It has a location, size and pixel contents.<br>
> @@ -1327,6 +1327,46 @@<br>
> </description><br>
> <arg name="scale" type="int"/><br>
> </request><br>
<br>
I know Jasper suggested deprecating wl_surface.damage, but I see no<br>
reason for that. wl_surface.damage is well-defined - it is only misused.<br>
<br>
We could add some wording to have both refer to each other as an<br>
alternative way to post damage. Especially to wl_surface.damage should<br>
mention buffer_damage as doing what you'd usually expect.<br>
<br>
> +<br>
> + <!-- Version 4 additions --><br>
> + <request name="buffer_damage" since="4"><br>
<br>
The name "buffer_damage" is slightly unfortunate. See:<br>
<a href="https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_swap_buffers_with_damage.txt" rel="noreferrer" target="_blank">https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_swap_buffers_with_damage.txt</a><br>
<br>
What we are doing in Wayland is always "surface damage"[*], while that<br>
EGL extension reserves "buffer damage" for a different purpose. I feel<br>
it might be confusing.<br>
<br>
Could we come up with a another name for this request?<br>
- wl_surface.damage_pixels<br>
- wl_surface.damage_by_buffer<br>
<br>
eh... buffer_damage is fine if nothing else sticks. The specification<br>
language below is clear anyway, IMO.<br>
<br>
> + <description summary="mark part of the surface damaged using buffer co-ordinates"><br>
> + This request is used to describe the regions where the pending<br>
> + buffer is different from the current surface contents, and where<br>
> + the surface therefore needs to be repainted. The pending buffer<br>
> + must be set by wl_surface.attach before sending damage. The<br>
> + compositor ignores the parts of the damage that fall outside of<br>
> + the surface.<br>
> +<br>
> + Damage is double-buffered state, see wl_surface.commit.<br>
> +<br>
> + The damage rectangle is specified in buffer coordinates.<br>
> +<br>
> + The initial value for pending damage is empty: no damage.<br>
> + wl_surface.damage adds pending damage: the new pending damage<br>
> + is the union of old pending damage and the given rectangle.<br>
> +<br>
> + wl_surface.commit assigns pending damage as the current damage,<br>
> + and clears pending damage. The server will clear the current<br>
> + damage as it repaints the surface.<br>
<br>
Essentially a copy from wl_surface.damage without changing anything but<br>
the coordinate system. Ok.<br>
<br>
> +<br>
> + This request differs from wl_surface.damage in only one way - it<br>
> + takes damage in buffer co-ordinates instead of surface local<br>
> + co-ordinates. This is desirable because EGL implementations<br>
> + are unaware of buffer scale and buffer transform and can only<br>
> + provide damage in buffer co-ordinates. Damage in buffer<br>
> + co-ordinates is required for EGLSwapBuffersWithDamage to work<br>
> + efficiently.<br>
<br>
Not sure if explaining the EGL side is needed here. Besides EGL, it<br>
could be any drawing library, and with wl_viewport there are much more<br>
use cases where buffer_damage is preferable.<br>
<br>
> + Mixing wl_surface.buffer_damage and wl_surface.damage requests<br>
> + on the same surface will result in undefined behaviour.<br>
<br>
Why undefined? The compositor will always transform between surface and<br>
buffer coordinate systems: surface to buffer for texture updates, and<br>
buffer to surface for repaint damage.<br>
<br>
I suppose you can avoid accumulating two different regions depending on<br>
the coordinate space until wl_surface.commit by saying only one<br>
coordinate space is guaranteed to work at a time. Is that reason<br>
enough, or the only reason?<br>
<br>
> + </description><br>
> +<br>
> + <arg name="x" type="int"/><br>
> + <arg name="y" type="int"/><br>
> + <arg name="width" type="int"/><br>
> + <arg name="height" type="int"/><br>
> + </request><br>
> </interface><br>
><br>
> <interface name="wl_seat" version="5"><br>
<br>
<br>
Thanks,<br>
pq<br>
<br>
<br>
[*] There is an off-topic rabbit hole to be dug here, if we would allow<br>
the compositor to cache shm-based textures... ;-)<br>
<br>_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
<br></blockquote></div><br></div>