aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-10-10 15:54:52 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-10-17 10:25:42 +0200
commit0eb50c273766be80f0a6fde635c3a2bdabd199fb (patch)
tree7df553d58c76cc5caecb8949d0d460fb24773874 /ui
parent86c0522c63e84ee9a98b9cd9cf6588faba1bac23 (diff)
downloadqemu-0eb50c273766be80f0a6fde635c3a2bdabd199fb.zip
qemu-0eb50c273766be80f0a6fde635c3a2bdabd199fb.tar.gz
qemu-0eb50c273766be80f0a6fde635c3a2bdabd199fb.tar.bz2
egl-helpers: add egl_texture_blit and egl_texture_blend
egl_texture_blit() blits a texture, simliar to egl_fb_blit() but by rendering the texture to the screen instead of using a framebuffer blit. egl_texture_blend() renders a texture with alpha blending, will be used to render the cursor to the screen. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20171010135453.6704-6-kraxel@redhat.com
Diffstat (limited to 'ui')
-rw-r--r--ui/egl-helpers.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index e7ee337..5fa60ef 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -111,6 +111,33 @@ void egl_fb_read(void *dst, egl_fb *src)
GL_BGRA, GL_UNSIGNED_BYTE, dst);
}
+void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip)
+{
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, dst->framebuffer);
+ glViewport(0, 0, dst->width, dst->height);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, src->texture);
+ qemu_gl_run_texture_blit(gls, flip);
+}
+
+void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
+ int x, int y)
+{
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, dst->framebuffer);
+ if (flip) {
+ glViewport(x, y, src->width, src->height);
+ } else {
+ glViewport(x, dst->height - src->height - y,
+ src->width, src->height);
+ }
+ 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