Skip to content

Commit

Permalink
Add an event to notify the recorder client of the buffer requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
giucam committed Dec 16, 2014
1 parent 8419b75 commit ef2b64c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions protocol/lipstick-recorder.xml
Expand Up @@ -79,6 +79,25 @@
<entry name="y_inverted" value="2"/>
</enum>

<event name="setup">
<description summary="notify the requirements for the frame buffers">
This event will be sent immediately after creation of the
lipstick_recorder object. The wl_buffers the client passes
to the frame request must be big enough to store an image
with the given width, height and format.
If they are not the compositor will send the failed event.
If this event is sent again later in the lifetime of the object
the pending frames will be cancelled.

The format will be one of the values as defined in the
wl_shm::format enum.
</description>
<arg name="width" type="int" description="width of the frame, in pixels"/>
<arg name="height" type="int" description="height of the frame, in pixels"/>
<arg name="stride" type="int" description="stride of the frame"/>
<arg name="format" type="int" desciption="format of the frame"/>
</event>

<event name="frame">
<description summary="notify a frame was recorded, or an error">
The compositor will send this event after a frame was
Expand Down
5 changes: 4 additions & 1 deletion src/compositor/lipstickrecorder.cpp
Expand Up @@ -73,8 +73,10 @@ void LipstickRecorderManager::recordFrame(QWindow *window)
pixels = static_cast<uchar *>(wl_shm_buffer_get_data(buffer));
int width = wl_shm_buffer_get_width(buffer);
int height = wl_shm_buffer_get_height(buffer);
int stride = wl_shm_buffer_get_stride(buffer);
int bpp = 4;

if (width != window->width() || height != window->height()) {
if (width < window->width() || height < window->height() || stride < window->width() * bpp) {
qApp->postEvent(recorder, new FailedEvent(QtWaylandServer::lipstick_recorder::result_bad_buffer));
continue;
}
Expand Down Expand Up @@ -123,6 +125,7 @@ LipstickRecorder::LipstickRecorder(LipstickRecorderManager *manager, wl_client *
, m_client(client)
, m_window(window)
{
send_setup(window->width(), window->height(), window->width() * 4, WL_SHM_FORMAT_RGBA8888);
}

LipstickRecorder::~LipstickRecorder()
Expand Down

0 comments on commit ef2b64c

Please sign in to comment.