[RFC] protocol: Introduce logical surface protocol

Jonas Ådahl jadahl at gmail.com
Sun Mar 17 02:13:58 PDT 2013


A logical surface is a special kind of surface that never gets its own
buffer attached, or opaque region set etc. It is obtained by using a
surface handle that can be shared in some way between clients. A handle
is a server wide unique identifier retrieved from the server given a
real surface. Currently a logical surface is limited to only be usable
as a sub-surface.

A possible use case is:

There are two clients (A and B) that can communicate via some IPC
mechanism where A is the main process and B is a render process. B
renders to a surface and A decides its visibility and position. Below
follows an example how logical surfaces can be used.

1. Both A and B connects do the server
5. A creates a main surface
2. B creates a render surface
3. B acquires a surface handle
4. B sends the surface handle via IPC to A
6. A receives the surface handle via IPC from B
7. A creates a wl_surface and a wl_subsurface object given the surface
   handle
8. A positions the wl_subsurface accordingly

Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---

Hi,

This is an RFC of how to make it possible for multi process rendering
without client to client buffer sharing required. It introduces a new
kind of surface currently referred to as a logical surface. A logical
surface is created by providing a server wide unique identifier
(surface handle) that can identify "wl_surface" objects on the server.
The surface handle can typically be shared via some IPC mechanism. A
logical surface mirrors a subset of the functionality of the real
surface associated with the surface handle used to create the logical
surface. The handle is currently just an uint, but could be anything
that would be easy to transfer via IPC, for example a hash string.

Multi process rendering is a common concept amongst browser
implementations, where a web site is rendered in a separate process from
the browser UI, both for performance purposes, isolation purposes and
"damage control" (i.e. the rendering process crashes).

I have made a (somewhat) working POC implementation by kicking on the
weston code base until I could tape on a logical surface functionality;
currently by adding some signals to copy buffer references, regions
etc on commits, more or less. I put a up video[0] of the subsurface demo
client made by Pekka hacked to have the OpenGL triangle rendered by a
forked process and composited via the sub-compositor. It looks a bit odd
because the size and position of the triangle view is simply hard coded.
(The POC is based on Pekka's version 2 of the subsurface implementation).

I'm not assuming this is a proper solution to this problem, but would
like to hear peoples input on the matter, both regarding the proposed
protocol, implementation as well as suitability as a Wayland protocol.

Thanks,

Jonas

[0] https://dl.dropbox.com/u/1418565/logical-surfaces.webm



 protocol/logical-surface.xml |   90 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
 create mode 100644 protocol/logical-surface.xml

diff --git a/protocol/logical-surface.xml b/protocol/logical-surface.xml
new file mode 100644
index 0000000..2cd14d8
--- /dev/null
+++ b/protocol/logical-surface.xml
@@ -0,0 +1,90 @@
+<protocol name="logical_surface">
+
+  <copyright>
+    Copyright © 2013 Jonas Ådahl
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that the above copyright notice appear in
+    all copies and that both that copyright notice and this permission
+    notice appear in supporting documentation, and that the name of
+    the copyright holders not be used in advertising or publicity
+    pertaining to distribution of the software without specific,
+    written prior permission.  The copyright holders make no
+    representations about the suitability of this software for any
+    purpose.  It is provided "as is" without express or implied
+    warranty.
+
+    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+    THIS SOFTWARE.
+  </copyright>
+
+  <interface name="wl_logical_surface_manager" version="1">
+    <description summary="logical surface manager">
+      A logical surface is a surface mapped by one client, but rendered
+      by another. By acquiring a global surface handle a client
+      can share the handle with another client. The other client can
+      then create a logical "wl_surface" and "wl_subsurface" object
+      combinations that can be mapped in a sub-compositor. A logical
+      "wl_surface" object can only be used within this protocol and the
+      sub-surface protocol.
+    </description>
+
+    <request name="get_logical_subsurface">
+      <description summary="give a surface the role sub-surface">
+	Given a surface handle, create a logical surface and turn it into
+	a sub-surface associated with the given parent surface. The new
+	surface is a logical surface and cannot be remapped after the
+	sub-surface interface and the surface is unmapped. The
+	new sub-surface can stacked and positioned as regular sub-surface
+	by a sub-compositor.
+
+	The conditions for the parent surface are identical to them of a
+	regular sub-surface parent.
+      </description>
+
+      <arg name="surface_id" type="new_id" interface="wl_surface"
+	   summary="the new logical surface object id"/>
+      <arg name="subsurface_id" type="new_id" interface="wl_subsurface"
+	   summary="the new subsurface object id"/>
+      <arg name="surface_handle" type="uint"
+	   summary="the surface handle"/>
+      <arg name="parent" type="object" interface="wl_surface"
+	   summary="the parent surface"/>
+    </request>
+
+    <request name="acquire_handle">
+      <description summary="acquire surface handle">
+	Acquire a surface handle. The handle will be valid until
+	released by the "release_handle" request.
+      </description>
+
+      <arg name="surface" type="object" interface="wl_surface"/>
+    </request>
+
+    <request name="release_handle">
+      <description summary="release surface handle">
+	Release a surface handle. The handle wil not be valid after this.
+      </description>
+
+      <arg name="handle" type="uint"/>
+    </request>
+
+    <event name="handle">
+      <description summary="surface handle">
+	In response to the "request_handle" request, provide a unique handle
+	that can be used to generate a logical surface on another client.
+      </description>
+
+      <arg name="surface" type="object" interface="wl_surface"/>
+      <arg name="handle" type="uint"/>
+    </event>
+  </interface>
+
+</protocol>
-- 
1.7.10.4



More information about the wayland-devel mailing list