Populate host latency for kms/x11 grab (#2273)

This commit is contained in:
KuleRucket
2024-03-28 22:52:53 +01:00
committed by GitHub
parent e5ef0375f3
commit 526121d81d
2 changed files with 8 additions and 3 deletions

View File

@@ -1069,7 +1069,7 @@ namespace platf {
} }
inline capture_e inline capture_e
refresh(file_t *file, egl::surface_descriptor_t *sd) { refresh(file_t *file, egl::surface_descriptor_t *sd, std::optional<std::chrono::steady_clock::time_point> &frame_timestamp) {
// Check for a change in HDR metadata // Check for a change in HDR metadata
if (connector_id) { if (connector_id) {
auto connector_props = card.connector_props(*connector_id); auto connector_props = card.connector_props(*connector_id);
@@ -1080,6 +1080,7 @@ namespace platf {
} }
plane_t plane = drmModeGetPlane(card.fd.el, plane_id); plane_t plane = drmModeGetPlane(card.fd.el, plane_id);
frame_timestamp = std::chrono::steady_clock::now();
auto fb = card.fb(plane.get()); auto fb = card.fb(plane.get());
if (!fb) { if (!fb) {
@@ -1303,7 +1304,8 @@ namespace platf {
egl::surface_descriptor_t sd; egl::surface_descriptor_t sd;
auto status = refresh(fb_fd, &sd); std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
auto status = refresh(fb_fd, &sd, frame_timestamp);
if (status != capture_e::ok) { if (status != capture_e::ok) {
return status; return status;
} }
@@ -1330,6 +1332,8 @@ namespace platf {
gl::ctx.GetTextureSubImage(rgb->tex[0], 0, img_offset_x, img_offset_y, 0, width, height, 1, GL_BGRA, GL_UNSIGNED_BYTE, img_out->height * img_out->row_pitch, img_out->data); gl::ctx.GetTextureSubImage(rgb->tex[0], 0, img_offset_x, img_offset_y, 0, width, height, 1, GL_BGRA, GL_UNSIGNED_BYTE, img_out->height * img_out->row_pitch, img_out->data);
img_out->frame_timestamp = frame_timestamp;
if (cursor && captured_cursor.visible) { if (cursor && captured_cursor.visible) {
blend_cursor(*img_out); blend_cursor(*img_out);
} }
@@ -1456,7 +1460,7 @@ namespace platf {
auto img = (egl::img_descriptor_t *) img_out.get(); auto img = (egl::img_descriptor_t *) img_out.get();
img->reset(); img->reset();
auto status = refresh(fb_fd, &img->sd); auto status = refresh(fb_fd, &img->sd, img->frame_timestamp);
if (status != capture_e::ok) { if (status != capture_e::ok) {
return status; return status;
} }

View File

@@ -535,6 +535,7 @@ namespace platf {
auto img = (x11_img_t *) img_out.get(); auto img = (x11_img_t *) img_out.get();
XImage *x_img { x11::GetImage(xdisplay.get(), xwindow, offset_x, offset_y, width, height, AllPlanes, ZPixmap) }; XImage *x_img { x11::GetImage(xdisplay.get(), xwindow, offset_x, offset_y, width, height, AllPlanes, ZPixmap) };
img->frame_timestamp = std::chrono::steady_clock::now();
img->width = x_img->width; img->width = x_img->width;
img->height = x_img->height; img->height = x_img->height;