[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/33] ui: add egl_fb_read_rect()
From: |
marcandre . lureau |
Subject: |
[PULL 26/33] ui: add egl_fb_read_rect() |
Date: |
Tue, 27 Jun 2023 15:02:23 +0200 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
include/ui/egl-helpers.h | 1 +
ui/egl-helpers.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index 6c4eb5dd70..6e2f0c49a6 100644
--- a/include/ui/egl-helpers.h
+++ b/include/ui/egl-helpers.h
@@ -31,6 +31,7 @@ void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
void egl_fb_read(DisplaySurface *dst, egl_fb *src);
+void egl_fb_read_rect(DisplaySurface *dst, egl_fb *src, int x, int y, int w,
int h);
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index c2a3ace743..f38800e920 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);
--
2.41.0
- [PULL 13/33] ui/egl: export qemu_egl_get_error_string(), (continued)
- [PULL 13/33] ui/egl: export qemu_egl_get_error_string(), marcandre . lureau, 2023/06/27
- [PULL 19/33] tests: make dbus-display-test work on win32, marcandre . lureau, 2023/06/27
- [PULL 23/33] ui/dbus: use shared memory when possible on win32, marcandre . lureau, 2023/06/27
- [PULL 24/33] ui: add egl-headless support on win32, marcandre . lureau, 2023/06/27
- [PULL 22/33] virtio-gpu/win32: allocate shareable 2d resources/images, marcandre . lureau, 2023/06/27
- [PULL 11/33] virtio-gpu: OUT_OF_MEMORY if failing to create udmabuf, marcandre . lureau, 2023/06/27
- [PULL 10/33] ui/gtk: set the area of the scanout texture correctly, marcandre . lureau, 2023/06/27
- [PULL 17/33] ui/dbus: win32 support, marcandre . lureau, 2023/06/27
- [PULL 20/33] ui/dbus: introduce "Interfaces" properties, marcandre . lureau, 2023/06/27
- [PULL 26/33] ui: add egl_fb_read_rect(),
marcandre . lureau <=
- [PULL 28/33] ui/dbus: add some GL traces, marcandre . lureau, 2023/06/27
- [PULL 21/33] console/win32: allocate shareable display surface, marcandre . lureau, 2023/06/27
- [PULL 25/33] ui/egl: default to GLES on windows, marcandre . lureau, 2023/06/27
- [PULL 29/33] virtio-gpu-virgl: teach it to get the QEMU EGL display, marcandre . lureau, 2023/06/27
- [PULL 27/33] ui/dbus: add GL support on win32, marcandre . lureau, 2023/06/27
- [PULL 30/33] ui/egl: query ANGLE d3d device, marcandre . lureau, 2023/06/27
- [PULL 32/33] virtio-gpu-virgl: use D3D11_SHARE_TEXTURE when available, marcandre . lureau, 2023/06/27
- [PULL 33/33] ui/dbus: use shared D3D11 Texture2D when possible, marcandre . lureau, 2023/06/27