gtk-egl: Blend cursor buffer within a scaled viewport
PATCH 1/1 gtk-egl: Blend cursor buffer within a scaled viewport
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().
---include/ui/egl-helpers.h | 2 ++ui/egl-helpers.c | 18 ++++++++++++++++++ui/gtk-egl.c | 8 +++++---
3 files changed, 25 insertions(+), 3 deletions(-)
include/ui/egl-helpers.h +0 -0
@@ -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
ui/egl-helpers.c +0 -0
@@ -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
ui/gtk-egl.c +0 -0
@@ -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); }
Signature · 1 line
2.7.4
The patch pasted in previous mail lost some indentations and spaces. Sorry.
From 7921a69f106233ebc0ff9bdc29d7c6182160fc6f Mon Sep 17 00:00:00 2001
From: Chen Zhang <[email protected]>
Date: Thu, 24 Jan 2019 09:16:23 +0800
Subject: [PATCH] DMABuf: Blend cursor buf within a scaled viewport
--- include/ui/egl-helpers.h | 2 ++ ui/egl-helpers.c | 18 ++++++++++++++++++ ui/gtk-egl.c | 8 +++++--- 3 files changed, 25 insertions(+), 3 deletions(-)
include/ui/egl-helpers.h +2 -0
@@ -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
ui/egl-helpers.c +18 -0
@@ -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
ui/gtk-egl.c +5 -3
@@ -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); }
Signature · 1 line
2.7.4
Quoted 74 lines · Chen Zhang
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 inegl_texture_blend2().Signed-off-by Chen Zhang <[email protected]>---
include/ui/egl-helpers.h| 2 ++ui/egl-helpers.c| 18 ++++++++++++++++++ui/gtk-egl.c| 8 +++++---3 files changed, 25 insertions(+), 3 deletions(-)include/ui/egl-helpers.h +2
-0@@ -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 ui/egl-helpers.c +18
-0@@ -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 ui/gtk-egl.c +5
-3@@ -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); }Signature · 1 line
2.7.4
include/ui/egl-helpers.h void egl_fb_read(void *dst, egl_fb *src); · line 32
Quoted 10 lines
include/ui/egl-helpers.h +2
-0@@ -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);
Why do you add egl_texture_blend2()?
How about adding scale_{x,y} parameters to egl_texture_blend() instead?
include/ui/egl-helpers.h void egl_fb_read(void *dst, egl_fb *src); · line 34
Quoted 2 lines
include/ui/egl-helpers.h +2
-0+ vc->gfx.scale_x * vc->gfx.cursor_fb.width, + vc->gfx.scale_x * vc->gfx.cursor_fb.height);
^ this should be y I guess ?
cheers,
Gerd
Hi,
Quoted 15 lines · Gerd Hoffmann
include/ui/egl-helpers.h void egl_fb_read(void *dst, egl_fb *src); · line 32
Quoted 11 lines
include/ui/egl-helpers.h +2
-0@@ -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);Why do you add
egl_texture_blend2()?
How about adding scale_{x,y} parameters toegl_texture_blend()instead?
It is valid to augment parameter list of egl_texture_blend(), however, there are two other callers: namely, spicy-display and egl-headless, neither of which seems to scale any underlying viewports. In that case, default scales (1.0, 1.0) shall be provided.
Quoted 4 lines
include/ui/egl-helpers.h void egl_fb_read(void *dst, egl_fb *src); · line 34
Quoted 3 lines
include/ui/egl-helpers.h +2
-0+ vc->gfx.scale_x * vc->gfx.cursor_fb.width, + vc->gfx.scale_x * vc->gfx.cursor_fb.height);^ this should be y I guess ?
Sorry for this typo.
Quoted 4 lines
cheers,
Gerd
Best regards,
Quoted 17 lines · Chen Zhang
Hi,
Quoted 15 lines · Gerd Hoffmann
include/ui/egl-helpers.h void egl_fb_read(void *dst, egl_fb *src); · line 32
Quoted 11 lines
include/ui/egl-helpers.h +2
-0@@ -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);Why do you add
egl_texture_blend2()?
How about adding scale_{x,y} parameters toegl_texture_blend()instead?
Quoted 4 lines
It is valid to augment parameter list of
egl_texture_blend(), however, there are two other callers: namely, spicy-display and egl-headless, neither of which seems to scale any underlying viewports. In that case, default scales (1.0, 1.0) shall be provided.
Yes, these callers can simply set scale_x and scale_y to 1.
cheers,
Gerd