aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-06-06 15:56:51 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-06-27 17:08:56 +0200
commitda9eb580b7e28d70d344bb03e0fe5703c8d1892c (patch)
tree5964d330aafbb191cbbb9b86566f62725d4009ca /ui
parentafe8e0b6db2debeaf35f5bd43efa1ada90ba0847 (diff)
downloadqemu-da9eb580b7e28d70d344bb03e0fe5703c8d1892c.zip
qemu-da9eb580b7e28d70d344bb03e0fe5703c8d1892c.tar.gz
qemu-da9eb580b7e28d70d344bb03e0fe5703c8d1892c.tar.bz2
ui: add egl_fb_read_rect()
Similar to egl_fb_read(), same limitations, but with extra arguments to read a subset of the framebuffer. Used in following commits. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20230606115658.677673-15-marcandre.lureau@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/egl-helpers.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index c2a3ace..f38800e 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -169,6 +169,20 @@ void egl_fb_read(DisplaySurface *dst, egl_fb *src)
GL_BGRA, GL_UNSIGNED_BYTE, surface_data(dst));
}
+void egl_fb_read_rect(DisplaySurface *dst, egl_fb *src, int x, int y, int w, int h)
+{
+ assert(surface_width(dst) == src->width);
+ assert(surface_height(dst) == src->height);
+ assert(surface_format(dst) == PIXMAN_x8r8g8b8);
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, src->framebuffer);
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glPixelStorei(GL_PACK_ROW_LENGTH, surface_stride(dst) / 4);
+ glReadPixels(x, y, w, h,
+ GL_BGRA, GL_UNSIGNED_BYTE, surface_data(dst) + x * 4);
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+}
+
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip)
{
glBindFramebuffer(GL_FRAMEBUFFER_EXT, dst->framebuffer);