Update protocol

This commit is contained in:
emersion 2018-05-26 08:15:49 +01:00
parent 65198b0aab
commit a16ad4327a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 40 additions and 101 deletions

View File

@ -42,26 +42,21 @@
fetched and used. fetched and used.
The receive callback shall be called first, followed by the "object" The receive callback shall be called first, followed by the "object"
callback once per dmabuf object or the "layer" callback, once per dmabuf callback once per dmabuf object or the "plane" callback, once per dmabuf
layer. The "plane" callback shall only be called after the "layer" plane. The "ready" event is called last to indicate that all the data has
callback corresponding to the layer the plane belongs to has been called
Finally, the "ready" event is called to indicate that all the data has
been made available for readout, as well as the time at which presentation been made available for readout, as well as the time at which presentation
happened at. The ownership of the frame is passed to the client, who's happened at. The ownership of the frame is passed to the client, who's
responsible for destroying it via the "destroy" event once finished. responsible for destroying it via the "destroy" event once finished and
The data the API describes has been based off of what by calling close() on the file descriptors received.
VASurfaceAttribExternalBuffers contains.
All frames are read-only and may not be written into or altered. All frames are read-only and may not be written into or altered.
</description> </description>
<enum name="flags"> <enum name="flags">
<description summary="frame flags"> <description summary="frame flags">
Special flags that must be respected by the client. Special flags that should be respected by the client.
Transient frames indicate short lifetime frames (such as swapchain
images from external clients). Clients are advised to copy them and do
all processing outside of the "ready" event.
</description> </description>
<entry name="transient" value="0x1" since="1"/> <entry name="transient" value="0x1" since="1"
summary="clients should copy frame before processing"/>
</enum> </enum>
<event name="frame"> <event name="frame">
@ -79,24 +74,25 @@
summary="frame width, scaling factor included"/> summary="frame width, scaling factor included"/>
<arg name="height" type="uint" <arg name="height" type="uint"
summary="frame height, scaling factor included"/> summary="frame height, scaling factor included"/>
<arg name="scale" type="uint" <arg name="offset_x" type="uint"
summary="current scaling factor of the client"/> summary="crop offset for the x axis"/>
<arg name="transform" type="uint" <arg name="offset_y" type="uint"
summary="transform needed to correct the orientation, has the same summary="crop offset for the y axis"/>
values as wl_output::transform"/>
<arg name="buffer_flags" type="uint" <arg name="buffer_flags" type="uint"
summary="flags which indicate properties (invert, interlacing), summary="flags which indicate properties (invert, interlacing),
has the same values as zwp_linux_buffer_params_v1:flags"/> has the same values as zwp_linux_buffer_params_v1:flags"/>
<arg name="flags" type="uint" enum="flags" <arg name="flags" type="uint" enum="flags"
summary="indicates special frame features"/> summary="indicates special frame features"/>
<arg name="format" type="uint"
summary="format of the frame (DRM_FORMAT_*)"/>
<arg name="mod_high" type="uint" <arg name="mod_high" type="uint"
summary="drm format modifier, high"/> summary="drm format modifier, high"/>
<arg name="mod_low" type="uint" <arg name="mod_low" type="uint"
summary="drm format modifier, low"/> summary="drm format modifier, low"/>
<arg name="num_objects" type="uint" <arg name="num_objects" type="uint"
summary="indicates how many objects (FDs) the frame has (max 4)"/> summary="indicates how many objects (FDs) the frame has (max 4)"/>
<arg name="num_layers" type="uint" <arg name="num_planes" type="uint"
summary="indicates how many layers the frame has (max 4)"/> summary="indicates how many planes the frame has (max 4)"/>
</event> </event>
<event name="object"> <event name="object">
<description summary="object receiving callback"> <description summary="object receiving callback">
@ -110,28 +106,13 @@
<arg name="size" type="uint" <arg name="size" type="uint"
summary="size in bytes for the current object"/> summary="size in bytes for the current object"/>
</event> </event>
<event name="layer">
<description summary="layer receiving callback">
Callback which serves to supply the client with information on what's
contained in each file descriptor and how its laid out.
Will be called after the main receive event, once per layer.
</description>
<arg name="index" type="uint"
summary="index of the current plane"/>
<arg name="format" type="uint"
summary="format of the layer (DRM_FORMAT_*)"/>
<arg name="num_planes" type="uint"
summary="number of planes in the current layer (max 4)"/>
</event>
<event name="plane"> <event name="plane">
<description summary="plane info receiving callback"> <description summary="plane info receiving callback">
Callback which supplies the client with plane information for each Callback which supplies the client with plane information for each
layer. plane.
</description> </description>
<arg name="index" type="uint" <arg name="index" type="uint"
summary="index of the current plane"/> summary="index of the current plane"/>
<arg name="layer_index" type="uint"
summary="index of the current layer"/>
<arg name="object_index" type="uint" <arg name="object_index" type="uint"
summary="index of the object the plane applies to"/> summary="index of the object the plane applies to"/>
<arg name="offset" type="uint" <arg name="offset" type="uint"
@ -158,21 +139,19 @@
summary="nanoseconds part of the timestamp"/> summary="nanoseconds part of the timestamp"/>
</event> </event>
<enum name="abort_reason"> <enum name="cancel_reason">
<description summary="abort reason"> <description summary="cancel reason">
Indicates reason for aborting the frame. Indicates reason for cancelling the frame.
</description> </description>
<entry name="invalid_source" value="0" since="1" <entry name="temporary" value="0" since="1"
summary="invalid source, will not produce any (more) frames"/> summary="temporary error, source will produce more frames"/>
<entry name="resizing" value="1" since="1" <entry name="pernament" value="1" since="1"
summary="source started being resized, this frame must be dropped, summary="fatal error, source will not produce frames"/>
but source is still able to be captured"/> <entry name="resizing" value="2" since="1"
<entry name="security" value="2" since="1" summary="temporary error, source will produce frames"/>
summary="this frame must be dropped as sensitive data was present,
however future capture may still succeed"/>
</enum> </enum>
<event name="abort"> <event name="cancel">
<description summary="indicates the frame is no longer valid"> <description summary="indicates the frame is no longer valid">
If the frame is no longer valid after the "frame" event has been called, If the frame is no longer valid after the "frame" event has been called,
this callback will be used to inform the client to scrap the frame. this callback will be used to inform the client to scrap the frame.
@ -181,57 +160,27 @@
This may get called if for instance the surface is in the process of This may get called if for instance the surface is in the process of
resizing. resizing.
</description> </description>
<arg name="reason" type="uint" enum="abort_reason" <arg name="reason" type="uint" enum="cancel_reason"
summary="indicates a reason for aborting this frame capture"/> summary="indicates a reason for cancelling this frame capture"/>
</event> </event>
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
<description summary="delete this object, used or not"> <description summary="delete this object, used or not">
Unreferences the frame, allowing it to be reused. Must be called as soon Unreferences the frame, allowing it to be reused. Must be called as soon
as its no longer used. as its no longer used.
Can be called at any time by the client after the "frame" event, after
which the compositor will not call any other events unless the client
resubscribes to capture more. The client will still have to close any
FDs it has been given.
</description> </description>
</request> </request>
</interface> </interface>
<interface name="zwlr_export_dmabuf_manager_v1" version="1"> <interface name="zwlr_export_dmabuf_manager_v1" version="1">
<description summary="manager to inform clients and begin capturing"> <description summary="manager to inform clients and begin capturing">
This object is a manager which informs clients about capturable windows This object is a manager with which to start capturing from sources.
and is able to create callbacks from which to begin to receive content
from. The "title" argument in the "surface_info" event shall be used
to provide a user-readable identifier such as a window title or
program name.
</description> </description>
<event name="surface_info">
<description summary="get valid surfaces for capture">
This will be called whenever a surface that's able to be captured
appears.
</description>
<arg name="title" type="string"
summary="window title or an identifier"/>
<arg name="id" type="uint"
summary="an identifier to create a context with"/>
</event>
<event name="surface_unavailable">
<description summary="notifies of a surface being unavailable to capture">
Called if a surface becomes unavailable to capture, for example if has
been closed.
</description>
<arg name="id" type="uint"
summary="an identifier of the surface"/>
</event>
<request name="capture_client">
<description summary="subscribe to start capturing">
Request to start capturing from a surface with a given id.
</description>
<arg name="frame" type="new_id"
interface="zwlr_export_dmabuf_frame_v1"/>
<arg name="overlay_cursor" type="int"
summary="include custom client hardware cursor on top of the frame"/>
<arg name="id" type="uint"
summary="an identifier to start capturing from"/>
</request>
<request name="capture_output"> <request name="capture_output">
<description summary="subscribe to start capturing"> <description summary="subscribe to start capturing">
Request to start capturing from an entire wl_output. Request to start capturing from an entire wl_output.

View File

@ -61,12 +61,6 @@ static struct wlr_export_dmabuf_manager_v1 *manager_from_resource(
return wl_resource_get_user_data(resource); return wl_resource_get_user_data(resource);
} }
static void manager_handle_capture_client(struct wl_client *client,
struct wl_resource *manager_resource, uint32_t id,
int32_t overlay_cursor, uint32_t client_id) {
// TODO
}
static void manager_handle_capture_output(struct wl_client *client, static void manager_handle_capture_output(struct wl_client *client,
struct wl_resource *manager_resource, uint32_t id, struct wl_resource *manager_resource, uint32_t id,
int32_t overlay_cursor, struct wl_resource *output_resource) { int32_t overlay_cursor, struct wl_resource *output_resource) {
@ -98,30 +92,27 @@ static void manager_handle_capture_output(struct wl_client *client,
struct wlr_dmabuf_buffer_attribs *attribs = &frame->attribs; struct wlr_dmabuf_buffer_attribs *attribs = &frame->attribs;
if (!wlr_output_export_dmabuf(output, attribs)) { if (!wlr_output_export_dmabuf(output, attribs)) {
// TODO: abort reason zwlr_export_dmabuf_frame_v1_send_cancel(frame->resource,
zwlr_export_dmabuf_frame_v1_send_abort(frame->resource, 0); ZWLR_EXPORT_DMABUF_FRAME_V1_CANCEL_REASON_TEMPORARY);
return; return;
} }
assert(attribs->n_planes > 0); assert(attribs->n_planes > 0);
uint32_t frame_flags = 0; uint32_t frame_flags = ZWLR_EXPORT_DMABUF_FRAME_V1_FLAGS_TRANSIENT;
uint32_t mod_high = attribs->modifier[0] >> 32; uint32_t mod_high = attribs->modifier[0] >> 32;
uint32_t mod_low = attribs->modifier[0] & 0xFFFFFFFF; uint32_t mod_low = attribs->modifier[0] & 0xFFFFFFFF;
zwlr_export_dmabuf_frame_v1_send_frame(frame->resource, zwlr_export_dmabuf_frame_v1_send_frame(frame->resource,
output->width, output->height, output->scale, output->transform, output->width, output->height, 0, 0, attribs->flags, frame_flags,
attribs->flags, frame_flags, mod_high, mod_low, attribs->n_planes, 1); attribs->format, mod_high, mod_low, attribs->n_planes,
attribs->n_planes);
zwlr_export_dmabuf_frame_v1_send_layer(frame->resource, 0,
attribs->format, attribs->n_planes);
for (int i = 0; i < attribs->n_planes; ++i) { for (int i = 0; i < attribs->n_planes; ++i) {
// TODO: what to do if the kernel doesn't support seek on buffer
off_t size = lseek(attribs->fd[i], 0, SEEK_END); off_t size = lseek(attribs->fd[i], 0, SEEK_END);
zwlr_export_dmabuf_frame_v1_send_object(frame->resource, i, zwlr_export_dmabuf_frame_v1_send_object(frame->resource, i,
attribs->fd[i], size); attribs->fd[i], size);
zwlr_export_dmabuf_frame_v1_send_plane(frame->resource, i, 0, i, zwlr_export_dmabuf_frame_v1_send_plane(frame->resource, i, i,
attribs->offset[i], attribs->stride[i]); attribs->offset[i], attribs->stride[i]);
} }
@ -131,7 +122,6 @@ static void manager_handle_capture_output(struct wl_client *client,
} }
static const struct zwlr_export_dmabuf_manager_v1_interface manager_impl = { static const struct zwlr_export_dmabuf_manager_v1_interface manager_impl = {
.capture_client = manager_handle_capture_client,
.capture_output = manager_handle_capture_output, .capture_output = manager_handle_capture_output,
}; };