qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] ui/egl: use stride and y0_top
Date: Thu, 18 Jun 2015 11:37:52 +0200	[thread overview]
Message-ID: <1434620272-17689-1-git-send-email-kraxel@redhat.com> (raw)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 Makefile                         |  4 +++-
 include/ui/egl-proto.h           |  2 ++
 qemu-eglview.c                   | 14 ++++++++++++--
 ui/egl.c                         |  4 ++++
 ui/shader/texture-blit-flip.vert | 10 ++++++++++
 5 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 ui/shader/texture-blit-flip.vert

diff --git a/Makefile b/Makefile
index 67eb59a..d10133a 100644
--- a/Makefile
+++ b/Makefile
@@ -458,7 +458,9 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
 	ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h
 
 qemu-eglview.o: $(SRC_PATH) qemu-eglview.c \
-	ui/shader/texture-blit-vert.h ui/shader/texture-blit-oes-frag.h
+	ui/shader/texture-blit-vert.h \
+	ui/shader/texture-blit-flip-vert.h \
+	ui/shader/texture-blit-oes-frag.h
 
 # documentation
 MAKEINFO=makeinfo
diff --git a/include/ui/egl-proto.h b/include/ui/egl-proto.h
index 1878224..3e149ed 100644
--- a/include/ui/egl-proto.h
+++ b/include/ui/egl-proto.h
@@ -24,7 +24,9 @@ typedef struct egl_msg {
         struct egl_newbuf {
             uint32_t width;
             uint32_t height;
+            uint32_t stride;
             uint32_t fourcc;
+            bool     y0_top;
         } newbuf;
         struct egl_ptr_set {
             uint32_t x;
diff --git a/qemu-eglview.c b/qemu-eglview.c
index efe992b..ed7bee0 100644
--- a/qemu-eglview.c
+++ b/qemu-eglview.c
@@ -42,10 +42,12 @@ static GIOChannel *ioc;
 
 static uint32_t buf_width;
 static uint32_t buf_height;
+static bool buf_y0_top;
 static EGLImageKHR buf_image = EGL_NO_IMAGE_KHR;
 static GLuint buf_tex_id;
 
 static GLint texture_blit_prog;
+static GLint texture_blit_flip_prog;
 
 #define GL_CHECK_ERROR() do {                                   \
         GLint err = glGetError();                               \
@@ -56,6 +58,7 @@ static GLint texture_blit_prog;
     } while (0)
 
 #include "ui/shader/texture-blit-vert.h"
+#include "ui/shader/texture-blit-flip-vert.h"
 #include "ui/shader/texture-blit-oes-frag.h"
 
 /* ---------------------------------------------------------------------- */
@@ -106,7 +109,11 @@ static gboolean egl_draw(GtkWidget *widget, cairo_t *cr, void *opaque)
     glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
     glClear(GL_COLOR_BUFFER_BIT);
 
-    qemu_gl_run_texture_blit(texture_blit_prog);
+    if (buf_y0_top) {
+        qemu_gl_run_texture_blit(texture_blit_flip_prog);
+    } else {
+        qemu_gl_run_texture_blit(texture_blit_prog);
+    }
     eglSwapBuffers(qemu_egl_display, egl_surface);
 
     return TRUE;
@@ -131,13 +138,14 @@ static void egl_newbuf(egl_msg *msg, int msgfd)
             msgfd, msg->u.newbuf.width, msg->u.newbuf.height);
     buf_width = msg->u.newbuf.width;
     buf_height = msg->u.newbuf.height;
+    buf_y0_top = msg->u.newbuf.y0_top;
 
     gtk_widget_set_size_request(draw, buf_width, buf_height);
 
     attrs[0] = EGL_DMA_BUF_PLANE0_FD_EXT;
     attrs[1] = msgfd;
     attrs[2] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
-    attrs[3] = buf_width * 4;
+    attrs[3] = msg->u.newbuf.stride;
     attrs[4] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
     attrs[5] = 0;
     attrs[6] = EGL_WIDTH;
@@ -420,6 +428,8 @@ int main(int argc, char *argv[])
     gtk_widget_set_double_buffered(draw, FALSE);
     texture_blit_prog = qemu_gl_create_compile_link_program
         (texture_blit_vert_src, texture_blit_oes_frag_src);
+    texture_blit_flip_prog = qemu_gl_create_compile_link_program
+        (texture_blit_flip_vert_src, texture_blit_oes_frag_src);
     if (!texture_blit_prog) {
         fprintf(stderr, "shader compile/link failure\n");
         exit(1);
diff --git a/ui/egl.c b/ui/egl.c
index e420beb..c63b453 100644
--- a/ui/egl.c
+++ b/ui/egl.c
@@ -293,7 +293,9 @@ static void egl_gfx_switch(DisplayChangeListener *dcl,
         edpy->newbuf.display = edpy->idx;
         edpy->newbuf.u.newbuf.width = surface_width(edpy->ds);
         edpy->newbuf.u.newbuf.height = surface_height(edpy->ds);
+        edpy->newbuf.u.newbuf.stride = stride;
         edpy->newbuf.u.newbuf.fourcc = fourcc;
+        edpy->newbuf.u.newbuf.y0_top = false;
 
         egl_send_all(edpy->egl, &edpy->newbuf, edpy->dmabuf_fd);
     }
@@ -344,7 +346,9 @@ static void egl_scanout(DisplayChangeListener *dcl,
     edpy->newbuf.display = edpy->idx;
     edpy->newbuf.u.newbuf.width = surface_width(edpy->ds);
     edpy->newbuf.u.newbuf.height = surface_height(edpy->ds);
+    edpy->newbuf.u.newbuf.stride = stride;
     edpy->newbuf.u.newbuf.fourcc = fourcc;
+    edpy->newbuf.u.newbuf.y0_top = backing_y_0_top;
 
     egl_send_all(edpy->egl, &edpy->newbuf, edpy->dmabuf_fd);
 }
diff --git a/ui/shader/texture-blit-flip.vert b/ui/shader/texture-blit-flip.vert
new file mode 100644
index 0000000..ba081fa
--- /dev/null
+++ b/ui/shader/texture-blit-flip.vert
@@ -0,0 +1,10 @@
+
+#version 300 es
+
+in vec2  in_position;
+out vec2 ex_tex_coord;
+
+void main(void) {
+    gl_Position = vec4(in_position, 0.0, 1.0);
+    ex_tex_coord = vec2(1.0 + in_position.x, 1.0 + in_position.y) * 0.5;
+}
-- 
1.8.3.1

             reply	other threads:[~2015-06-18  9:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  9:37 Gerd Hoffmann [this message]
2015-06-18 10:16 ` [Qemu-devel] [PATCH] ui/egl: use stride and y0_top Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434620272-17689-1-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).