summaryrefslogtreecommitdiff
path: root/src/platform/wayland/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/wayland/buffer.c')
-rw-r--r--src/platform/wayland/buffer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/platform/wayland/buffer.c b/src/platform/wayland/buffer.c
index f5a2c0f..b906f4f 100644
--- a/src/platform/wayland/buffer.c
+++ b/src/platform/wayland/buffer.c
@@ -472,9 +472,20 @@ bool wayland_surface_present(struct wayland_surface *w, const struct yasl_frameb
return false;
commit_buffer(w, w->cur);
w->frame_presented = true;
+ w->shown = w->cur;
+ w->has_shown = true;
return true;
}
+bool wayland_surface_read_pixels(struct wayland_surface *w, uint32_t *out, size_t cap,
+ struct yasl_vector2i *size)
+{
+ if (!w || w->closed || w->frame_active || !w->has_shown) return false;
+ const struct buffer *b = &w->buffers[w->shown];
+ if (!b->pixels) return false;
+ return yasl_copy_frame(b->pixels, (struct yasl_vector2i){b->width, b->height}, out, cap, size);
+}
+
void surface_draw_frame(struct wayland_surface *w)
{
if (w->closed || !w->configured)
@@ -491,6 +502,9 @@ void surface_draw_frame(struct wayland_surface *w)
w->frames_skipped++;
return;
}
+ /* Drawing reuses the presented buffer only after the compositor released it. */
+ if (w->has_shown && idx == w->shown)
+ w->has_shown = false;
if (buffer_prepare(w, &w->buffers[idx], w->width, w->height, &buffer_listener) < 0) {
w->frames_skipped++;
return;