Skip to content

Commit

Permalink
Linux/x11grab: add frame processing latency
Browse files Browse the repository at this point in the history
This commit populates the img->frame_timestamp field, so that
Moonlight is now capable of showing the "Host processing latency"
in its statistics overlay.

It's a complement to PR LizardByte#2273 which did miss the codepath for
shm_attr_t::snapshot().
  • Loading branch information
gschintgen authored and ReenigneArcher committed May 12, 2024
1 parent 2c11691 commit b6c6f04
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/platform/linux/x11grab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ namespace platf {
}
else {
auto img_cookie = xcb::shm_get_image_unchecked(xcb.get(), display->root, offset_x, offset_y, width, height, ~0, XCB_IMAGE_FORMAT_Z_PIXMAP, seg, 0);
auto frame_timestamp = std::chrono::steady_clock::now();

xcb_img_t img_reply { xcb::shm_get_image_reply(xcb.get(), img_cookie, nullptr) };
if (!img_reply) {
Expand All @@ -691,6 +692,7 @@ namespace platf {
}

std::copy_n((std::uint8_t *) data.data, frame_size(), img_out->data);
img_out->frame_timestamp = frame_timestamp;

if (cursor) {
blend_cursor(shm_xdisplay.get(), *img_out, offset_x, offset_y);
Expand Down

0 comments on commit b6c6f04

Please sign in to comment.