Resource Sharing

Updated: May 27, 2022

Resource sharing allows the access of buffers and their content within the same application and process, or between different applications and processes.

In resource sharing, the term producer is used to describe any object (e.g., process, application, window) that creates source content to provide to another object. A consumer is any object that takes its source from another object (e.g., process, application, window).

There are different ways you can share, or allow access to, buffers. How you choose to share buffers can depend on the purpose of your applications, the type of content, or both. For example, if you want to share content for the purpose of showing it on multiple displays, then you want to perform some sort of cloning. However, if you need control on the update rate between the consumer and the producer, we recommend using streams. The ways you can share resources are by:

Sharing buffers (Cloning)

When you're sharing buffers, the rendering application is the producer and Screen is ultimately always the consumer because it consumes the content of the application's window for compositing and displaying. The target of shared buffers is always a window.

The Screen API provides the following functions for sharing buffers:

Timing of updates is between the rendering applications (producers) and Screen (consumer).

Consuming buffers (Using Streams)

When you're consuming buffers, there are both producer and consumer applications. The application creating the content is the producer, and the application using the content is the consumer. Screen itself is not necessarily the consumer if the content isn't targeted to a display.

The Screen API provides support for consuming buffers through the use of streams. Refer to Streams in the library reference for more details.

Timing of updates is now between the producer and consumer applications, and not necessarily with Screen.