<div dir="ltr"><div><div><div>Sorry to spam the list, but I had another idea kicking around my head this weekend that I thought was worth sharing. Please note that I don't think this is a stopper. I just think it's worth throwing out there and seeing if others think it's useful.<br>
<br>I don't think there are any major holes in commit behavior in the current protocol. That said, there seems to be some confusion on commit modes and how they interact with the tree of subalgebras that I think is justified. I think this could be (somewhat) solved by the following simplification. We could replace the explicit commit modes that then impose commit modes on the children with a single cache_child_commits request which would begin caching the data for child surfaces until commit is called on the same surface. In terms of the current mechanism, cache_child_commits would set synced and commit would automatically unset synced.<br>
<br></div>The advantage I see to this approach is that it makes it more clear that it affects the entire tree and how it does so. Also, it requires the client to explicitly put any synced commits between a cached_child_commits and commit which I personally think is cleaner. The disadvantage is that it is a little less flexible in that you can't cache single children. However, if you can have "dummy nodes" (see previous ML posts), this shouldn't be a problem in most cases.<br>
<br></div>Again, I don't think this is a show-stopper and I think the protocol as-is is ok. I just thought it might be worth mentioning.<br></div>--Jason Ekstrand<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Apr 26, 2013 at 11:38 AM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Fri, Apr 26, 2013 at 9:14 AM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">pq,<br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Apr 26, 2013 at 7:09 AM, David Herrmann <span dir="ltr"><<a href="mailto:dh.herrmann@gmail.com" target="_blank">dh.herrmann@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Pekka<br>
<div><div><br>
On Fri, Apr 26, 2013 at 1:12 PM, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>> wrote:<br>
>> > > diff --git a/protocol/subsurface.xml b/protocol/subsurface.xml<br>
>> > > new file mode 100644<br>
>> > > index 0000000..60b4002<br>
>> > > --- /dev/null<br>
>> > > +++ b/protocol/subsurface.xml<br>
>> > > @@ -0,0 +1,236 @@<br>
>> > > +<?xml version="1.0" encoding="UTF-8"?><br>
>> > > +<protocol name="subsurface"><br>
>> > > +<br>
>> > > + <copyright><br>
>> > > + Copyright © 2012-2013 Collabora, Ltd.<br>
>> > > +<br>
>> > > + Permission to use, copy, modify, distribute, and sell this<br>
>> > > + software and its documentation for any purpose is hereby granted<br>
>> > > + without fee, provided that the above copyright notice appear in<br>
>> > > + all copies and that both that copyright notice and this permission<br>
>> > > + notice appear in supporting documentation, and that the name of<br>
>> > > + the copyright holders not be used in advertising or publicity<br>
>> > > + pertaining to distribution of the software without specific,<br>
>> > > + written prior permission. The copyright holders make no<br>
>> > > + representations about the suitability of this software for any<br>
>> > > + purpose. It is provided "as is" without express or implied<br>
>> > > + warranty.<br>
>> > > +<br>
>> > > + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS<br>
>> > > + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>
>> > > + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
>> > > + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES<br>
>> > > + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN<br>
>> > > + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,<br>
>> > > + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF<br>
>> > > + THIS SOFTWARE.<br>
>> > > + </copyright><br>
>> > > +<br>
>> > > + <interface name="wl_subcompositor" version="1"><br>
>> > > + <description summary="sub-surface compositing"><br>
>> > > + The global interface exposing sub-surface compositing capabilities.<br>
>> > > + A wl_surface, that has sub-surfaces associated, is called the<br>
>> > > + parent surface. Sub-surfaces can be arbitrarily nested and create<br>
>> > > + a tree of sub-surfaces.<br>
>> > > +<br>
>> > > + The root surface in a tree of sub-surfaces is the main<br>
>> > > + surface. The main surface cannot be a sub-surface, because<br>
>> > > + sub-surfaces must always have a parent.<br>
>> > > +<br>
>> > > + A main surface with its sub-surfaces forms a (compound) window.<br>
>> > > + For window management purposes, this set of wl_surface objects is<br>
>> > > + to be considered as a single window, and it should also behave as<br>
>> > > + such.<br>
>> > > +<br>
>> > > + The aim of sub-surfaces is to offload some of the compositing work<br>
>> > > + within a window from clients to the compositor. A prime example is<br>
>> > > + a video player with decorations and video in separate wl_surface<br>
>> > > + objects. This should allow the compositor to pass YUV video buffer<br>
>> > > + processing to dedicated overlay hardware when possible.<br>
>> > > + </description><br>
>> > > +<br>
>> > > + <request name="destroy" type="destructor"><br>
>> > > + <description summary="unbind from the subcompositor interface"><br>
>> > > + Informs the server that the client will not be using this<br>
>> > > + protocol object anymore. This does not affect any other<br>
>> > > + objects, wl_subsurface objects included.<br>
>> > > + </description><br>
>> > > + </request><br>
>> > > +<br>
>> > > + <enum name="error"><br>
>> > > + <entry name="bad_surface" value="0"<br>
>> > > + summary="the to-be sub-surface is invalid"/><br>
>> > > + <entry name="bad_parent" value="1"<br>
>> > > + summary="the given parent is a sub-surface"/><br>
>> > > + </enum><br>
>> > > +<br>
>> > > + <request name="get_subsurface"><br>
>> > > + <description summary="give a surface the role sub-surface"><br>
>> > > + Create a sub-surface interface for the given surface, and<br>
>> > > + associate it with the given parent surface. This turns a<br>
>> > > + plain wl_surface into a sub-surface.<br>
>> > > +<br>
>> > > + The to-be sub-surface must not already have a dedicated<br>
>> > > + purpose, like any shell surface type, cursor image, drag icon,<br>
>> > > + or sub-surface. Otherwise a protocol error is raised.<br>
>> > > + </description><br>
>> > > +<br>
>> > > + <arg name="id" type="new_id" interface="wl_subsurface"<br>
>> > > + summary="the new subsurface object id"/><br>
>> > > + <arg name="surface" type="object" interface="wl_surface"<br>
>> > > + summary="the surface to be turned into a sub-surface"/><br>
>> > > + <arg name="parent" type="object" interface="wl_surface"<br>
>> > > + summary="the parent surface"/><br>
>> > > + </request><br>
>> > > + </interface><br>
>> > > +<br>
>> > > + <interface name="wl_subsurface" version="1"><br>
>> > > + <description summary="sub-surface interface to a wl_surface"><br>
>> > > + An additional interface to a wl_surface object, which has been<br>
>> > > + made a sub-surface. A sub-surface has one parent surface.<br>
>> > > +<br>
>> > > + A sub-surface becomes mapped, when a non-NULL wl_buffer is applied<br>
>> > > + and the parent surface is mapped. The order of which one happens<br>
>> > > + first is irrelevant. A sub-surface is hidden if the parent becomes<br>
>> > > + hidden, or if a NULL wl_buffer is applied. These rules apply<br>
>> > > + recursively through the tree of surfaces.<br>
>> > > +<br>
>> > > + The behaviour of wl_surface.commit request on a sub-surface<br>
>> > > + depends on the sub-surface's mode. The possible modes are<br>
>> > > + synchronized and desynchronized, see methods<br>
>> > > + wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized<br>
>> > > + mode caches wl_surface state to be applied on the next parent<br>
>> > > + surface's commit, and desynchronized mode applies the pending<br>
>> ><br>
>> > I had to look at the code to actually understand which implementation<br>
>> > you chose. It is not clear to me (from that description) what happens<br>
>> > in the case that you described earlier:<br>
>> ><br>
>> > C.commit<br>
>> > B.commit<br>
>> > C.commit<br>
>> > A.commit<br>
>> ><br>
>> > (assuming A<-B<-C stacking)<br>
>><br>
>> That really depends on the commit modes of each surface, but if we<br>
>> assume A is main, and B and C are synchronized (IIRC that was the<br>
>> example), then:<br>
<br>
</div></div>Sorry for not being clear, but all my comments were about the<br>
synchronized mode. The unsynchronized mode is trivial in this regard.<br>
But I think you got it right.<br>
<div><br>
>> C.commit(buffer C1)<br>
>> - C1 becomes cached in C<br>
>> B.commit(buffer B1)<br>
>> - B1 becomes cached in B<br>
>> C.commit(buffer C2)<br>
>> - C2 becomes cached in C, and C1 is released<br>
>> A.commit(buffer A1)<br>
>> - A1 becomes current in A, B1 becomes current in B, C2 becomes current<br>
>> in C<br>
>><br>
>> Actually, C's commit mode is irrelevant. As long as B is synchronized,<br>
>> C will behave as synchronized.<br>
</div>>>ehen schloß feschtle gefeiert?<br>
July 15, 2012 at 10:59pm · Like<br>
<div><div>>> > According to your implementation you apply a sub-surface state if<br>
>> > wl_surface.commit is called on _any_ ancestor. I think you should<br>
>> > mention that explicitly. This description could mean both, but your<br>
>> > description below is definitely misleading.<br>
>><br>
>> Hmm, no. I only apply the new state in children, if the children are<br>
>> effectively in synchronized mode.<br>
>><br>
>> A sub-surface has a commit mode, which is either desynchronized or<br>
>> synchronized. However, the effective commit mode is synchronized, if<br>
>> any of sub-surface's ancestors are in synchronized mode.<br>
>><br>
>> Maybe I should explain the difference between the commit mode and the<br>
>> effective commit mode here?<br>
>><br>
>> I'm uncertain how to clarify what you are asking. Can you propose<br>
>> something here?<br>
>><br>
>> > > + wl_surface state directly. A sub-surface is initially in the<br>
>> > > + synchronized mode.<br>
>> > > +<br>
>> > > + Sub-surfaces have also other kind of state, which is managed by<br>
>> > > + wl_subsurface requests, as opposed to wl_surface requests. This<br>
>> > > + state includes the sub-surface position relative to the parent<br>
>> > > + surface (wl_subsurface.set_position), and the stacking order of<br>
>> > > + the parent and its sub-surfaces (wl_subsurface.place_above and<br>
>> > > + .place_below). This state is applied when the parent surface's<br>
>> > > + wl_surface state is applied, regardless of the sub-surface's mode.<br>
>> > > + As the exception, set_sync and set_desync are effective immediately.<br>
>> > > +<br>
>> > > + The main surface can thought to be always in desynchronized mode,<br>
>> > > + since it does not have a parent in the sub-surfaces sense.<br>
>> > > +<br>
>> > > + Even if a sub-surface is in desynchronized mode, it will behave as<br>
>> > > + in synchronized mode, if its parent surface behaves as in<br>
>> > > + synchronized mode. This rule is applied recursively throughout the<br>
>> > > + tree of surfaces. This means, that one can set a sub-surface into<br>
>> > > + synchronized mode, and then assume that all its child sub-surfaces<br>
>> > > + are synchronized, too, without explicitly setting them.<br>
>> > > +<br>
>> > > + If the wl_surface associated with the wl_subsurface is destroyed, the<br>
>> > > + wl_subsurface object becomes inert. Note, that destroying either object<br>
>> > > + takes effect immediately. If you need to synchronize the removal<br>
>> > > + of a sub-surface to the parent surface update, unmap the sub-surface<br>
>> > > + first by attaching a NULL wl_buffer, update parent, and then destroy<br>
>> > > + the sub-surface.<br>
>> > > +<br>
>> > > + If the parent wl_surface object is destroyed, the sub-surface is<br>
>> > > + unmapped.<br>
>> > > + </description><br>
>> > > +<br>
>> > > + <request name="destroy" type="destructor"><br>
>> > > + <description summary="remove sub-surface interface"><br>
>> > > + The sub-surface interface is removed from the wl_surface object<br>
>> > > + that was turned into a sub-surface with<br>
>> > > + wl_subcompositor.get_subsurface request. The wl_surface's association<br>
>> > > + to the parent is deleted, and the wl_surface loses its role as<br>
>> > > + a sub-surface. The wl_surface is unmapped.<br>
>> > > + </description><br>
>> > > + </request><br>
>> > > +<br>
>> > > + <enum name="error"><br>
>> > > + <entry name="bad_surface" value="0"<br>
>> > > + summary="wl_surface is not a sibling or the parent"/><br>
>> > > + </enum><br>
>> > > +<br>
>> > > + <request name="set_position"><br>
>> > > + <description summary="reposition the sub-surface"><br>
>> > > + This schedules a sub-surface position change.<br>
>> > > + The sub-surface will be moved so, that its origin (top-left<br>
>> > > + corner pixel) will be at the location x, y of the parent surface.<br>
>> > > +<br>
>> > > + The next wl_surface.commit on the parent surface will reset<br>
>> > > + the sub-surface's position to the scheduled coordinates.<br>
>> > > +<br>
>> > > + The initial position is 0, 0.<br>
>> ><br>
>> > Your patch doesn't mention what happens if the parent doesn't fully<br>
>> > include the sub-surface. I think it should be clear whether the child<br>
>> > is clipped or not.<br>
>> ><br>
>> > I know you postponed the rotation/clipping extension, but we should<br>
>> > still define the behavior for raw sub-surfaces. I guess "no clipping"<br>
>> > is the best option. Or is that implied by not mentioning it?<br>
>><br>
>> I thought not mentioning anything implies no clipping, and that is how<br>
>> it is implemented. Sub-surface area is in no way restricted by the<br>
>> parent or ancestors.<br>
>><br>
>> No clipping is essential for stitching window decorations from<br>
>> sub-surfaces, while eliminating surface overlap, for instance.<br>
>><br>
>> I'll add a note here.<br>
>><br>
>> I never suggested rotation. It is the clipping and scaling extension<br>
>> that will follow separately, and is applicable to any wl_surface.<br>
>><br>
>> > > + </description><br>
>> > > +<br>
>> > > + <arg name="x" type="int" summary="coordinate in the parent surface"/><br>
>> > > + <arg name="y" type="int" summary="coordinate in the parent surface"/><br>
>> > > + </request><br>
>> > > +<br>
>> > > + <request name="place_above"><br>
>> > > + <description summary="restack the sub-surface"><br>
>> > > + This sub-surface is taken from the stack, and put back just<br>
>> > > + above the reference surface, changing the z-order of the sub-surfaces.<br>
>> > > + The reference surface must be one of the sibling surfaces, or the<br>
>> > > + parent surface. Using any other surface, including this sub-surface,<br>
>> > > + will cause a protocol error.<br>
>> > > +<br>
>> > > + The z-order is double-buffered state, and will be applied on the<br>
>> > > + next commit of the parent surface.<br>
>> > > + See wl_surface.commit and wl_subcompositor.get_subsurface.<br>
>> > > + </description><br>
>> > > +<br>
>> ><br>
>> > Maybe I missed it, but what's the initial z-order for new<br>
>> > sub-surfaces? I guess it's "top-most" but I think it should be<br>
>> > mentioned either here or in the wl_subsurface description.<br>
>><br>
>> Yeah, it is top-most of the particular parent's children. The logical<br>
>> place to document it is in wl_subsurface.place_above, right?<br>
>><br>
>> I'll add it.<br>
>><br>
>> > > + <arg name="sibling" type="object" interface="wl_surface"<br>
>> > > + summary="the reference surface"/><br>
>> > > + </request><br>
>> > > +<br>
>> > > + <request name="place_below"><br>
>> > > + <description summary="restack the sub-surface"><br>
>> > > + The sub-surface is placed just below of the reference surface.<br>
>> > > + See wl_subsurface.place_above.<br>
>> > > + </description><br>
>> > > +<br>
>> > > + <arg name="sibling" type="object" interface="wl_surface"<br>
>> > > + summary="the reference surface"/><br>
>> > > + </request><br>
>> > > +<br>
>> > > + <request name="set_sync"><br>
>> > > + <description summary="set sub-surface to synchronized mode"><br>
>> > > + Change the commit behaviour of the sub-surface to synchronized<br>
>> > > + mode, also described as the parent dependant mode.<br>
>> > > +<br>
>> > > + In synchronized mode, wl_surface.commit on a sub-surface will<br>
>> > > + accumulate the committed state in a cache, but the state will<br>
>> > > + not be applied and hence will not change the compositor output.<br>
>> > > + The cached state is applied to the sub-surface when<br>
>> > > + wl_surface.commit is called on the parent surface, after the<br>
>> ><br>
>> > This is the description that I was talking about. It's misleading. A<br>
>> > sub-surface state is _not_ necessarily applied _only_ when<br>
>> > wl_surface.commit is called on the parent. Instead it is applied if<br>
>> > the parent's state is applied.<br>
>><br>
>> Right, I need to fix that. Left-overs from before nesting support.<br>
>><br>
>> > On the first sight this seems to be identical scenarios, but it's not:<br>
>> ><br>
>> > wl_surface.commit causes a state and all synchronized sub-surface<br>
>> > states to be applied. That means, a state of a surface is applied when<br>
>> > wl_surface.commit is called on _any_ ancestor (direct or indirect<br>
>> > parent) not only the direct parent.<br>
>> > With the current implementation this is identical to:<br>
>> > wl_surface.commit is called on the top-most synchronized parent. All<br>
>> > other commits in between are invisible to the client.<br>
>><br>
>> Yeah.<br>
>><br>
>> > So whether "wl_surface.commit is called" or whether a "surface's state<br>
>> > is applied" are no longer identical. The first implies the second, but<br>
>> > not vice versa.<br>
>><br>
>> Actually, neither implies the other. Btw. is it clear enough, that<br>
>> commit and apply are separate steps now?<br>
<br>
</div></div>I think it is pretty clear that those are different steps now. But we<br>
need to be careful to not assume that they're identical. That's why I<br>
thought this description is misleading.<br>
<div><br>
>> > Other than these few documentation details, the extension looks really<br>
>> > nice. I doubt that we need the multi-layer-cache that we were talking<br>
>> > about with v2 so I like this proposal a lot!<br>
>><br>
>> Oh yeah, the multi-layer cache would be madness on resource usage.<br>
>><br>
>><br>
>> Thank you, David!<br>
>> - pq<br>
><br>
> How's this?<br>
> <a href="http://cgit.collabora.com/git/user/pq/weston.git/commit/?h=subsurface-wip2&id=0dce7236606e0a433390c970560c3050247c4e60&context=6" target="_blank">http://cgit.collabora.com/git/user/pq/weston.git/commit/?h=subsurface-wip2&id=0dce7236606e0a433390c970560c3050247c4e60&context=6</a><br>
<br>
</div>Perfect, that solves all my concerns.<br></blockquote><div> <br></div></div></div><div>My thoughts were basically the same as David's and those changes solve my concerns as well. I'm still not sure I'm 100% happy with how it requires you to build strange trees in certain cases. That said, I think it looks pretty good and certainly good enough to go into weston so we can all start playing with it. I'm hoping I can get sub-surfaces implemented in my java compositor soonish. Looking good!<span><font color="#888888"><br>
</font></span></div><span><font color="#888888"><div>--Jason Ekstrand<br></div></font></span></div></div></div></blockquote><div><br></div></div></div><div>Pekka asked me to send an e-mail with a little clarification as to what I meant by "strange trees". Consider an EGL video surface with SHM CSD (see attachment). To make things more complicated, let's say that the video surface is controlled by an external library or (worse yet) is a foreign surface controlled by a different process. Due to current commit behavior and the way commits cascade, the EGL surface (which really is the primary surface in this case) can't be used as the primary surface. Instead, you would have to use one of the decoration surfaces as the parent surface (again, see the picture).<br>
<br></div><div>One solution to this would be to allow some sort of surface that contains no actual pixels but gets mapped anyway. Right now you can hack this with a 1x1 transparent buffer or something similar. However, I would rather not see such hacks common place. One way to achieve this would be to have some sort of empty buffer that has a size but no data. Then you could attach one of these empty buffers to a surface to get it mapped.<br>
<br></div><div>The other advantage of an "empty buffer" is that, if it's used as the main window, could be the full size of the window instead of being 1x1. This simplifies the problem of handling input across subsurfaces as you can have the parent surface handle them. It would also allow us (if we wanted) to clip subsurfaces to the parent surface without causing any major problems. Not that we necessarily should, but it would leave open the option.<br>
<br></div><div>Hope that's more clear,<br></div><div class="im"><div>--Jason Ekstrand<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><span><font color="#888888"><div></div></font></span><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks<br>
<span><font color="#888888">David<br>
</font></span><div><div>_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div></div><br></div></div>
</blockquote></div><br></div>