All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [PATCH v2 7/7] sdl2: add support for display rendering using opengl.
Date: Mon, 19 Jan 2015 11:22:13 -0500	[thread overview]
Message-ID: <54BD2F35.9060008@redhat.com> (raw)
In-Reply-To: <1421674603-31575-8-git-send-email-kraxel@redhat.com>

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 <kraxel@redhat.com>
> ---
>   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 <kraxel@redhat.com>
> + *
> + * 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

  reply	other threads:[~2015-01-19 16:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 13:36 [Qemu-devel] [PATCH v2 0/7] sdl2: add opengl rendering support Gerd Hoffmann
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 1/7] configure: opengl overhaul Gerd Hoffmann
2015-01-19 14:43   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 2/7] Allow the use of X11 from a non standard location Gerd Hoffmann
2015-01-19 14:50   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 3/7] pixman: add a bunch of PIXMAN_BE_* defines for 32bpp Gerd Hoffmann
2015-01-19 14:54   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 4/7] console-gl: add opengl rendering helper functions Gerd Hoffmann
2015-01-19 16:05   ` Max Reitz
2015-01-20 11:00     ` Gerd Hoffmann
2015-01-20 13:54       ` Max Reitz
2015-01-20 14:44         ` Gerd Hoffmann
2015-01-20 14:52           ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 5/7] console-gl: externalize shader programs Gerd Hoffmann
2015-01-19 16:15   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 6/7] sdl2: move SDL_* includes to sdl2.h Gerd Hoffmann
2015-01-19 16:16   ` Max Reitz
2015-01-19 13:36 ` [Qemu-devel] [PATCH v2 7/7] sdl2: add support for display rendering using opengl Gerd Hoffmann
2015-01-19 16:22   ` Max Reitz [this message]
2015-01-20 11:13     ` 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=54BD2F35.9060008@redhat.com \
    --to=mreitz@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.