Sunshine master
Self-hosted game stream host for Moonlight.
wl::dmabuf_t Class Reference

Listener state for Wayland screencopy frames backed by DMA-BUFs. More...

#include <src/platform/linux/wayland.h>

Collaboration diagram for wl::dmabuf_t:
[legend]

Public Types

enum  status_e { WAITING , READY , REINIT }
 Capture state for the active screencopy request. More...
 

Public Member Functions

void buffer (zwlr_screencopy_frame_v1 *frame, std::uint32_t format, std::uint32_t width, std::uint32_t height, std::uint32_t stride)
 Record DMA-BUF buffer parameters from the compositor.
 
void buffer_done (zwlr_screencopy_frame_v1 *frame)
 Allocate or import the buffer once the compositor finished describing it.
 
void damage (zwlr_screencopy_frame_v1 *frame, std::uint32_t x, std::uint32_t y, std::uint32_t width, std::uint32_t height)
 Record damaged frame bounds reported by the compositor.
 
 dmabuf_t (const dmabuf_t &)=delete
 
 dmabuf_t (dmabuf_t &&)=delete
 
void failed (zwlr_screencopy_frame_v1 *frame)
 Mark the frame capture as failed.
 
void flags (zwlr_screencopy_frame_v1 *frame, std::uint32_t flags)
 Record frame flags reported by the compositor.
 
frame_tget_next_frame ()
 Select the inactive frame slot for the next screencopy request.
 
void linux_dmabuf (zwlr_screencopy_frame_v1 *frame, std::uint32_t format, std::uint32_t width, std::uint32_t height)
 Record Linux DMA-BUF parameters advertised for the frame.
 
void listen (zwlr_screencopy_manager_v1 *screencopy_manager, zwp_linux_dmabuf_v1 *dmabuf_interface, const std::map< std::uint32_t, std::vector< std::uint64_t > > *supported_modifiers, wl_output *output, bool blend_cursor=false)
 Start a screencopy request and attach the DMA-BUF listener callbacks.
 
dmabuf_toperator= (const dmabuf_t &)=delete
 
dmabuf_toperator= (dmabuf_t &&)=delete
 
void ready (zwlr_screencopy_frame_v1 *frame, std::uint32_t tv_sec_hi, std::uint32_t tv_sec_lo, std::uint32_t tv_nsec)
 Mark the current screencopy frame as ready and store its timestamp.
 

Static Public Member Functions

static void buffer_params_created (void *data, struct zwp_linux_buffer_params_v1 *params, struct wl_buffer *wl_buffer)
 Store the Wayland buffer created for a DMA-BUF parameter request.
 
static void buffer_params_failed (void *data, struct zwp_linux_buffer_params_v1 *params)
 Mark DMA-BUF buffer creation as failed.
 

Public Attributes

frame_tcurrent_frame
 Frame descriptor currently being filled by the compositor.
 
std::array< frame_t, 2 > frames
 Double-buffered frame descriptors.
 
zwlr_screencopy_frame_v1_listener listener
 Callback table registered on screencopy frames.
 
status_e status
 Current state of the active screencopy request.
 

Detailed Description

Listener state for Wayland screencopy frames backed by DMA-BUFs.

Member Enumeration Documentation

◆ status_e

Capture state for the active screencopy request.

Enumerator
WAITING 

Waiting for a frame.

READY 

Frame is ready.

REINIT 

Reinitialize the frame.

Member Function Documentation

◆ buffer()

void wl::dmabuf_t::buffer ( zwlr_screencopy_frame_v1 * frame,
std::uint32_t format,
std::uint32_t width,
std::uint32_t height,
std::uint32_t stride )

Record DMA-BUF buffer parameters from the compositor.

Parameters
frameScreencopy frame that advertised shared-memory fallback data.
formatDRM pixel format for the shared-memory buffer.
widthFrame width in pixels.
heightFrame height in pixels.
strideNumber of bytes per row in the buffer.

◆ buffer_done()

void wl::dmabuf_t::buffer_done ( zwlr_screencopy_frame_v1 * frame)

Allocate or import the buffer once the compositor finished describing it.

Parameters
frameScreencopy frame whose buffer description is complete.

◆ buffer_params_created()

void wl::dmabuf_t::buffer_params_created ( void * data,
struct zwp_linux_buffer_params_v1 * params,
struct wl_buffer * wl_buffer )
static

Store the Wayland buffer created for a DMA-BUF parameter request.

Parameters
dataPointer to the dmabuf_t instance associated with the callback.
paramsDMA-BUF parameter object that completed buffer creation.
wl_bufferWayland buffer created from the DMA-BUF planes.

◆ buffer_params_failed()

void wl::dmabuf_t::buffer_params_failed ( void * data,
struct zwp_linux_buffer_params_v1 * params )
static

Mark DMA-BUF buffer creation as failed.

Parameters
dataPointer to the dmabuf_t instance associated with the callback.
paramsDMA-BUF parameter object that failed buffer creation.

◆ damage()

void wl::dmabuf_t::damage ( zwlr_screencopy_frame_v1 * frame,
std::uint32_t x,
std::uint32_t y,
std::uint32_t width,
std::uint32_t height )

Record damaged frame bounds reported by the compositor.

Parameters
frameScreencopy frame that reported damage.
xLeft edge of the damaged rectangle.
yTop edge of the damaged rectangle.
widthDamaged rectangle width in pixels.
heightDamaged rectangle height in pixels.

◆ failed()

void wl::dmabuf_t::failed ( zwlr_screencopy_frame_v1 * frame)

Mark the frame capture as failed.

Parameters
frameScreencopy frame that failed.

◆ flags()

void wl::dmabuf_t::flags ( zwlr_screencopy_frame_v1 * frame,
std::uint32_t flags )

Record frame flags reported by the compositor.

Parameters
frameScreencopy frame that reported flags.
flagsWayland screencopy flags such as vertical inversion.

◆ get_next_frame()

frame_t * wl::dmabuf_t::get_next_frame ( )
inline

Select the inactive frame slot for the next screencopy request.

Returns
Inactive frame buffer that can receive the next capture.

◆ linux_dmabuf()

void wl::dmabuf_t::linux_dmabuf ( zwlr_screencopy_frame_v1 * frame,
std::uint32_t format,
std::uint32_t width,
std::uint32_t height )

Record Linux DMA-BUF parameters advertised for the frame.

Parameters
frameScreencopy frame that advertised DMA-BUF data.
formatDRM pixel format for the DMA-BUF.
widthFrame width in pixels.
heightFrame height in pixels.

◆ listen()

void wl::dmabuf_t::listen ( zwlr_screencopy_manager_v1 * screencopy_manager,
zwp_linux_dmabuf_v1 * dmabuf_interface,
const std::map< std::uint32_t, std::vector< std::uint64_t > > * supported_modifiers,
wl_output * output,
bool blend_cursor = false )

Start a screencopy request and attach the DMA-BUF listener callbacks.

Parameters
screencopy_managerCompositor screencopy manager used to request frames.
dmabuf_interfaceCompositor DMA-BUF interface used to allocate buffers.
supported_modifiersDMA-BUF format modifiers supported by the compositor.
outputWayland output to capture.
blend_cursorWhether the compositor should include the cursor in the frame.

◆ ready()

void wl::dmabuf_t::ready ( zwlr_screencopy_frame_v1 * frame,
std::uint32_t tv_sec_hi,
std::uint32_t tv_sec_lo,
std::uint32_t tv_nsec )

Mark the current screencopy frame as ready and store its timestamp.

Parameters
frameScreencopy frame that completed.
tv_sec_hiHigh 32 bits of the compositor-provided seconds value.
tv_sec_loLow 32 bits of the compositor-provided seconds value.
tv_nsecNanosecond component of the compositor-provided timestamp.

The documentation for this class was generated from the following files: