Module smithay::wayland::dmabuf[][src]

Expand description

Linux DMABUF protocol

This module provides helper to handle the linux-dmabuf protocol, which allows clients to submit their contents as dmabuf file descriptors. These handlers automate the aggregation of the metadata associated with a dma buffer, and do some basic checking of the sanity of what the client sends.

How to use

To setup the dmabuf global, you will need to provide 2 things:

  • a list of the dmabuf formats you wish to support
  • a closure to test if a dmabuf buffer can be imported by your renderer

The list of supported format is just a Vec<Format>, where you will enter all the (code, modifier) couples you support. You can typically receive a list of supported formats for one renderer by calling ImportDma::dmabuf_formats.

use smithay::{
    backend::allocator::dmabuf::Dmabuf,
    reexports::{wayland_server::protocol::wl_buffer::WlBuffer},
    wayland::dmabuf::init_dmabuf_global,
};

// define your supported formats
let formats = vec![
    /* ... */
];
let dmabuf_global = init_dmabuf_global(
    &mut display,
    formats,
    |buffer, dispatch_data| {
        /* validate the dmabuf and import it into your renderer state */
        true
    },
    None // we don't provide a logger in this example
);

Functions

Handler trait for dmabuf validation