aboutsummaryrefslogtreecommitdiff
path: root/ui/egl-headless.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-10-19 12:09:53 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-10-19 12:09:53 +0100
commitba6f0fc25e3c14fbb36f4b5a616a89cd3f1de6d0 (patch)
tree2bbf92549c6a4d29ad93374c1bd57e169ec8d9b0 /ui/egl-headless.c
parent73b733e6907e1193e562f498272108c95c00868c (diff)
parenta35179170034b60bcfb997e06bc63258caaf5049 (diff)
Merge remote-tracking branch 'remotes/kraxel/tags/opengl-20171017-pull-request' into staging
ui: opengl updates for dma-buf support. # gpg: Signature made Tue 17 Oct 2017 12:13:36 BST # gpg: using RSA key 0x4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/opengl-20171017-pull-request: egl-headless: add dmabuf support egl-helpers: add egl_texture_blit and egl_texture_blend egl-helpers: add dmabuf import support opengl: add flipping vertex shader opengl: move shader init from console-gl.c to shader.c console: add support for dmabufs Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/egl-headless.c')
-rw-r--r--ui/egl-headless.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 12ad64e995..5d50226869 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -4,13 +4,18 @@
#include "ui/console.h"
#include "ui/egl-helpers.h"
#include "ui/egl-context.h"
+#include "ui/shader.h"
typedef struct egl_dpy {
DisplayChangeListener dcl;
DisplaySurface *ds;
+ QemuGLShader *gls;
egl_fb guest_fb;
+ egl_fb cursor_fb;
egl_fb blit_fb;
bool y_0_top;
+ uint32_t pos_x;
+ uint32_t pos_y;
} egl_dpy;
/* ------------------------------------------------------------------ */
@@ -65,6 +70,43 @@ static void egl_scanout_texture(DisplayChangeListener *dcl,
}
}
+static void egl_scanout_dmabuf(DisplayChangeListener *dcl,
+ QemuDmaBuf *dmabuf)
+{
+ egl_dmabuf_import_texture(dmabuf);
+ if (!dmabuf->texture) {
+ return;
+ }
+
+ egl_scanout_texture(dcl, dmabuf->texture,
+ false, dmabuf->width, dmabuf->height,
+ 0, 0, dmabuf->width, dmabuf->height);
+}
+
+static void egl_cursor_dmabuf(DisplayChangeListener *dcl,
+ QemuDmaBuf *dmabuf,
+ uint32_t pos_x, uint32_t pos_y)
+{
+ egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);
+
+ edpy->pos_x = pos_x;
+ edpy->pos_y = pos_y;
+
+ egl_dmabuf_import_texture(dmabuf);
+ if (!dmabuf->texture) {
+ return;
+ }
+
+ egl_fb_setup_for_tex(&edpy->cursor_fb, dmabuf->width, dmabuf->height,
+ dmabuf->texture, false);
+}
+
+static void egl_release_dmabuf(DisplayChangeListener *dcl,
+ QemuDmaBuf *dmabuf)
+{
+ egl_dmabuf_release_texture(dmabuf);
+}
+
static void egl_scanout_flush(DisplayChangeListener *dcl,
uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
@@ -78,9 +120,18 @@ static void egl_scanout_flush(DisplayChangeListener *dcl,
assert(surface_height(edpy->ds) == edpy->guest_fb.height);
assert(surface_format(edpy->ds) == PIXMAN_x8r8g8b8);
- egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top);
- egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb);
+ if (edpy->cursor_fb.texture) {
+ /* have cursor -> render using textures */
+ egl_texture_blit(edpy->gls, &edpy->blit_fb, &edpy->guest_fb,
+ !edpy->y_0_top);
+ egl_texture_blend(edpy->gls, &edpy->blit_fb, &edpy->cursor_fb,
+ !edpy->y_0_top, edpy->pos_x, edpy->pos_y);
+ } else {
+ /* no cursor -> use simple framebuffer blit */
+ egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top);
+ }
+ egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb);
dpy_gfx_update(edpy->dcl.con, x, y, w, h);
}
@@ -97,6 +148,9 @@ static const DisplayChangeListenerOps egl_ops = {
.dpy_gl_scanout_disable = egl_scanout_disable,
.dpy_gl_scanout_texture = egl_scanout_texture,
+ .dpy_gl_scanout_dmabuf = egl_scanout_dmabuf,
+ .dpy_gl_cursor_dmabuf = egl_cursor_dmabuf,
+ .dpy_gl_release_dmabuf = egl_release_dmabuf,
.dpy_gl_update = egl_scanout_flush,
};
@@ -120,6 +174,7 @@ void egl_headless_init(void)
edpy = g_new0(egl_dpy, 1);
edpy->dcl.con = con;
edpy->dcl.ops = &egl_ops;
+ edpy->gls = qemu_gl_init_shader();
register_displaychangelistener(&edpy->dcl);
}
}