Update wlr-export-dmabuf protocol

This commit is contained in:
emersion 2018-05-23 22:11:45 +01:00
parent 7901740f94
commit 1377e551ef
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 52 additions and 28 deletions

View File

@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
</copyright> </copyright>
<description summary="a frame ready for readout"> <description summary="a protocol for low overhead screen content capturing">
An interface to capture surfaces in an efficient way. An interface to capture surfaces in an efficient way.
Overall usage: Overall usage:
@ -41,28 +41,27 @@
This object represents a frame which is ready to have its resources This object represents a frame which is ready to have its resources
fetched and used. fetched and used.
The receive callback shall be called first, followed by either the The receive callback shall be called first, followed by the "object"
"dma_object" callback once per object or the "dma_layer" callback, callback once per dmabuf object or the "layer" callback, once per dmabuf
once per layer. The "dma_plane" callback shall only be called after layer. The "plane" callback shall only be called after the "layer"
the "dma_layer" callback corresponding to the layer the plane belongs callback corresponding to the layer the plane belongs to has been called
to has been called. Finally, the "ready" event is called to indicate that Finally, the "ready" event is called to indicate that all the data has
all the data has been made available for readout, as well as the time been made available for readout, as well as the time at which presentation
at which presentation happened at. happened at. The ownership of the frame is passed to the client, who's
The ownership of the frame is passed to the client, who's responsible for responsible for destroying it via the "destroy" event once finished.
destroying it via the "destroy" event once finished.
The data the API describes has been based off of what The data the API describes has been based off of what
VASurfaceAttribExternalBuffers contains. 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="frame_flags"> <enum name="flags">
<description summary="frame flags"> <description summary="frame flags">
Special flags that must be respected by the client. Special flags that must be respected by the client.
Transient frames indicate short lifetime frames (such as swapchain Transient frames indicate short lifetime frames (such as swapchain
images from external clients). Clients are advised to copy them and do images from external clients). Clients are advised to copy them and do
all processing outside of the "ready" event. all processing outside of the "ready" event.
</description> </description>
<entry name="transient" value="1" since="1"/> <entry name="transient" value="0x1" since="1"/>
</enum> </enum>
<event name="frame"> <event name="frame">
@ -85,10 +84,10 @@
<arg name="transform" type="uint" <arg name="transform" type="uint"
summary="transform needed to correct the orientation, has the same summary="transform needed to correct the orientation, has the same
values as wl_output::transform"/> values as wl_output::transform"/>
<arg name="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="frame_flags" type="uint" enum="frame_flags" <arg name="flags" type="uint" enum="flags"
summary="indicates special frame features"/> summary="indicates special frame features"/>
<arg name="mod_high" type="uint" <arg name="mod_high" type="uint"
summary="drm format modifier, high"/> summary="drm format modifier, high"/>
@ -99,7 +98,7 @@
<arg name="num_layers" type="uint" <arg name="num_layers" type="uint"
summary="indicates how many layers the frame has (max 4)"/> summary="indicates how many layers the frame has (max 4)"/>
</event> </event>
<event name="dma_object"> <event name="object">
<description summary="object receiving callback"> <description summary="object receiving callback">
Callback which serves to supply the client with the file descriptors Callback which serves to supply the client with the file descriptors
containing the data for each object. containing the data for each object.
@ -111,7 +110,7 @@
<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="dma_layer"> <event name="layer">
<description summary="layer receiving callback"> <description summary="layer receiving callback">
Callback which serves to supply the client with information on what's Callback which serves to supply the client with information on what's
contained in each file descriptor and how its laid out. contained in each file descriptor and how its laid out.
@ -124,7 +123,7 @@
<arg name="num_planes" type="uint" <arg name="num_planes" type="uint"
summary="number of planes in the current layer (max 4)"/> summary="number of planes in the current layer (max 4)"/>
</event> </event>
<event name="dma_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. layer.
@ -158,6 +157,21 @@
<arg name="tv_nsec" type="uint" <arg name="tv_nsec" type="uint"
summary="nanoseconds part of the timestamp"/> summary="nanoseconds part of the timestamp"/>
</event> </event>
<enum name="abort_reason">
<description summary="abort reason">
Indicates reason for aborting the frame.
</description>
<entry name="invalid_source" value="0" since="1"
summary="invalid source, will not produce any (more) frames"/>
<entry name="resizing" value="1" since="1"
summary="source started being resized, this frame must be dropped,
but source is still able to be captured"/>
<entry name="security" value="2" since="1"
summary="this frame must be dropped as sensitive data was present,
however future capture may still succeed"/>
</enum>
<event name="abort"> <event name="abort">
<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,
@ -167,6 +181,8 @@
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"
summary="indicates a reason for aborting this frame capture"/>
</event> </event>
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
@ -208,23 +224,29 @@
<request name="capture_client"> <request name="capture_client">
<description summary="subscribe to start capturing"> <description summary="subscribe to start capturing">
Request to start capturing from a surface with a given id. Request to start capturing from a surface with a given id.
If an ID becomes unavailable, a NULL will be returned.
</description> </description>
<arg name="frame" type="new_id" <arg name="frame" type="new_id"
interface="zwlr_export_dmabuf_frame_v1"/> 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" <arg name="id" type="uint"
summary="an identifier to start capturing from"/> summary="an identifier to start capturing from"/>
<arg name="overlay_cursor" type="int"
summary="overlay custom client hardware cursor on top of the frame"/>
</request> </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.
If an output becomes unavailable, a NULL will be returned.
</description> </description>
<arg name="frame" type="new_id" <arg name="frame" type="new_id"
interface="zwlr_export_dmabuf_frame_v1"/> interface="zwlr_export_dmabuf_frame_v1"/>
<arg name="out" type="object" interface="wl_output" allow-null="false"/> <arg name="overlay_cursor" type="int"
summary="include custom client hardware cursor on top of the frame"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request> </request>
</interface> </interface>
</protocol> </protocol>

View File

@ -61,13 +61,13 @@ static struct wlr_export_dmabuf_manager_v1 *manager_from_resource(
static void manager_handle_capture_client(struct wl_client *client, static void manager_handle_capture_client(struct wl_client *client,
struct wl_resource *manager_resource, uint32_t id, struct wl_resource *manager_resource, uint32_t id,
uint32_t client_id, int32_t overlay_cursor) { int32_t overlay_cursor, uint32_t client_id) {
// TODO // 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,
struct wl_resource *output_resource) { int32_t overlay_cursor, struct wl_resource *output_resource) {
struct wlr_export_dmabuf_manager_v1 *manager = struct wlr_export_dmabuf_manager_v1 *manager =
manager_from_resource(manager_resource); manager_from_resource(manager_resource);
struct wlr_output *output = wlr_output_from_resource(output_resource); struct wlr_output *output = wlr_output_from_resource(output_resource);
@ -95,7 +95,9 @@ static void manager_handle_capture_output(struct wl_client *client,
struct wlr_dmabuf_buffer_attribs attribs; struct wlr_dmabuf_buffer_attribs attribs;
if (!wlr_output_export_dmabuf(output, &attribs)) { if (!wlr_output_export_dmabuf(output, &attribs)) {
zwlr_export_dmabuf_frame_v1_send_abort(frame->resource); wl_list_init(&frame->output_swap_buffers.link);
// TODO: abort reason
zwlr_export_dmabuf_frame_v1_send_abort(frame->resource, 0);
return; return;
} }
@ -109,16 +111,16 @@ static void manager_handle_capture_output(struct wl_client *client,
output->width, output->height, output->scale, output->transform, output->width, output->height, output->scale, output->transform,
attribs.flags, frame_flags, mod_high, mod_low, attribs.n_planes, 1); attribs.flags, frame_flags, mod_high, mod_low, attribs.n_planes, 1);
zwlr_export_dmabuf_frame_v1_send_dma_layer(frame->resource, 0, zwlr_export_dmabuf_frame_v1_send_layer(frame->resource, 0,
attribs.format, 1); attribs.format, 1);
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 // 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_dma_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_dma_plane(frame->resource, i, 0, i, zwlr_export_dmabuf_frame_v1_send_plane(frame->resource, i, 0, i,
attribs.offset[i], attribs.stride[i]); attribs.offset[i], attribs.stride[i]);
} }