From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDF5r-0008Aq-PI for qemu-devel@nongnu.org; Mon, 19 Jan 2015 11:22:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDF5n-0004xE-NX for qemu-devel@nongnu.org; Mon, 19 Jan 2015 11:22:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDF5n-0004x7-Fm for qemu-devel@nongnu.org; Mon, 19 Jan 2015 11:22:19 -0500 Message-ID: <54BD2F35.9060008@redhat.com> Date: Mon, 19 Jan 2015 11:22:13 -0500 From: Max Reitz MIME-Version: 1.0 References: <1421674603-31575-1-git-send-email-kraxel@redhat.com> <1421674603-31575-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1421674603-31575-8-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 7/7] sdl2: add support for display rendering using opengl. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann , qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori On 2015-01-19 at 08:36, Gerd Hoffmann wrote: > Add new sdl2-gl.c file, with display > rendering functions using opengl. > > Signed-off-by: Gerd Hoffmann > --- > include/ui/console.h | 1 + > include/ui/sdl2.h | 11 +++++ > ui/Makefile.objs | 3 ++ > ui/sdl.c | 11 +++++ > ui/sdl2-2d.c | 7 ++++ > ui/sdl2-gl.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++ > ui/sdl2.c | 67 ++++++++++++++++++++++++++---- > vl.c | 11 +++++ > 8 files changed, 216 insertions(+), 7 deletions(-) > create mode 100644 ui/sdl2-gl.c [snip] > diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c > new file mode 100644 > index 0000000..b604c06 > --- /dev/null > +++ b/ui/sdl2-gl.c > @@ -0,0 +1,112 @@ > +/* > + * QEMU SDL display driver -- opengl support > + * > + * Copyright (c) 2014 Red Hat > + * > + * Authors: > + * Gerd Hoffmann > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +#include "qemu-common.h" > +#include "ui/console.h" > +#include "ui/input.h" > +#include "ui/sdl2.h" > +#include "sysemu/sysemu.h" > + > +static void sdl2_gl_render_surface(struct sdl2_console *scon) > +{ > + int ww, wh; > + > + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); > + > + SDL_GetWindowSize(scon->real_window, &ww, &wh); > + surface_gl_setup_viewport(scon->gls, scon->surface, ww, wh); > + > + surface_gl_render_texture(scon->gls, scon->surface); > + SDL_GL_SwapWindow(scon->real_window); > +} > + > +void sdl2_gl_update(DisplayChangeListener *dcl, > + int x, int y, int w, int h) > +{ > + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); > + > + assert(scon->opengl); > + > + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); > + surface_gl_update_texture(scon->gls, scon->surface, x, y, w, h); > + scon->updates++; > +} > + > +void sdl2_gl_switch(DisplayChangeListener *dcl, > + DisplaySurface *new_surface) > +{ > + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); > + DisplaySurface *old_surface = scon->surface; > + > + assert(scon->opengl); > + > + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); > + surface_gl_destroy_texture(scon->gls, scon->surface); Same question as for v1: Can a surface be in use by multiple DCLs? > + > + scon->surface = new_surface; > + > + if (!new_surface) { > + console_gl_fini_context(scon->gls); > + scon->gls = NULL; > + sdl2_window_destroy(scon); > + return; > + } > + > + if (!scon->real_window) { > + sdl2_window_create(scon); > + scon->gls = console_gl_init_context(); > + } else if (old_surface && > + ((surface_width(old_surface) != surface_width(new_surface)) || > + (surface_height(old_surface) != surface_height(new_surface)))) { And as in v1: If the window is scaled, this will reset the scaling to 100 %, which is fine. However, if the new surface has the same dimensions as the old surface, the window will not be scaled. That would seem strange to me (why is the scaling reset for some surface changes but not for others?). Max