ui/egl: use stride and y0_top
PATCH 1/1 ui/egl: use stride and y0_top
Signed-off-by Gerd Hoffmann <[email protected]>
--- 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
Makefile +3 -1
@@ -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
include/ui/egl-proto.h +2 -0
@@ -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;
qemu-eglview.c +12 -2
@@ -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 );
ui/egl.c +4 -0
@@ -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); }
ui/shader/texture-blit-flip.vert new file +10 -0
@@ -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; +}
Signature · 1 line
1.8.3.1
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>
Oops, wrong patch, scratch that.
sorry,
Gerd