qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH]gtk-egl: Blend cursor buffer within a scaled viewpor


From: Chen Zhang
Subject: [Qemu-devel] [PATCH]gtk-egl: Blend cursor buffer within a scaled viewport
Date: Thu, 24 Jan 2019 01:31:45 GMT

When a gtk-egl window (for gvt-g DMABuf) was zoomed, the cursor plane buffer 
did not zoom covariantly, resulting in a mismatched cursor size. In this patch, 
`egl_texture_blend()` is augmented with two extra parameters to convey the size 
for a scaled viewport, as in `egl_texture_blend2()`. 

Signed-off-by: Chen Zhang <address@hidden>
---
include/ui/egl-helpers.h | 2 ++
ui/egl-helpers.c | 18 ++++++++++++++++++
ui/gtk-egl.c | 8 +++++---
3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index 3fc656a..63ffc2d 100644
--- a/include/ui/egl-helpers.h
+++ b/include/ui/egl-helpers.h
@@ -28,6 +28,8 @@ void egl_fb_read(void *dst, egl_fb *src);
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,
int x, int y);
+void egl_texture_blend2(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
+ int x, int y, int w, int h);

#ifdef CONFIG_OPENGL_DMABUF

diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 5e115b3..9dddee9 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -137,6 +137,24 @@ void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, 
egl_fb *src, bool flip,
glDisable(GL_BLEND);
}

+void egl_texture_blend2(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
+ int x, int y, int w, int h)
+{
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, dst->framebuffer);
+ if (flip) {
+ glViewport(x, y, w, h);
+ } else {
+ glViewport(x, dst->height - h - y,
+ w, h);
+ }
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, src->texture);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ qemu_gl_run_texture_blit(gls, flip);
+ glDisable(GL_BLEND);
+}
+
/* ---------------------------------------------------------------------- */

#ifdef CONFIG_OPENGL_DMABUF
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index afd1714..afff0e1 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -276,9 +276,11 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
if (vc->gfx.cursor_fb.texture) {
egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb,
vc->gfx.y0_top);
- egl_texture_blend(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.cursor_fb,
- vc->gfx.y0_top,
- vc->gfx.cursor_x, vc->gfx.cursor_y);
+ egl_texture_blend2(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.cursor_fb,
+ vc->gfx.y0_top,
+ vc->gfx.cursor_x, vc->gfx.cursor_y,
+ vc->gfx.scale_x * vc->gfx.cursor_fb.width,
+ vc->gfx.scale_x * vc->gfx.cursor_fb.height);
} else {
egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top);
}
--
2.7.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]