From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/4] sdl2: use framebuffer helper functions.
Date: Tue, 6 Jun 2017 13:04:58 +0200 [thread overview]
Message-ID: <20170606110459.9771-4-kraxel@redhat.com> (raw)
In-Reply-To: <20170606110459.9771-1-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/ui/sdl2.h | 8 ++++++--
ui/sdl2-gl.c | 38 ++++++++------------------------------
2 files changed, 14 insertions(+), 32 deletions(-)
diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index aaf226c2c0..454367ac84 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -7,6 +7,10 @@
#include <SDL.h>
#include <SDL_syswm.h>
+#ifdef CONFIG_OPENGL
+# include "ui/egl-helpers.h"
+#endif
+
struct sdl2_console {
DisplayChangeListener dcl;
DisplaySurface *surface;
@@ -23,8 +27,8 @@ struct sdl2_console {
SDL_GLContext winctx;
#ifdef CONFIG_OPENGL
ConsoleGLState *gls;
- GLuint tex_id;
- GLuint fbo_id;
+ egl_fb guest_fb;
+ egl_fb win_fb;
bool y0_top;
bool scanout_mode;
#endif
diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index 1cd77e2c16..6640d0a9c8 100644
--- a/ui/sdl2-gl.c
+++ b/ui/sdl2-gl.c
@@ -42,14 +42,7 @@ static void sdl2_set_scanout_mode(struct sdl2_console *scon, bool scanout)
scon->scanout_mode = scanout;
if (!scon->scanout_mode) {
- if (scon->fbo_id) {
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, 0, 0);
- glDeleteFramebuffers(1, &scon->fbo_id);
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
- scon->fbo_id = 0;
- }
+ egl_fb_destroy(&scon->guest_fb);
if (scon->surface) {
surface_gl_destroy_texture(scon->gls, scon->surface);
surface_gl_create_texture(scon->gls, scon->surface);
@@ -191,7 +184,6 @@ void sdl2_gl_scanout_disable(DisplayChangeListener *dcl)
assert(scon->opengl);
scon->w = 0;
scon->h = 0;
- scon->tex_id = 0;
sdl2_set_scanout_mode(scon, false);
}
@@ -210,48 +202,34 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
scon->y = y;
scon->w = w;
scon->h = h;
- scon->tex_id = backing_id;
scon->y0_top = backing_y_0_top;
SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
sdl2_set_scanout_mode(scon, true);
- if (!scon->fbo_id) {
- glGenFramebuffers(1, &scon->fbo_id);
- }
-
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, scon->tex_id, 0);
+ egl_fb_create_for_tex(&scon->guest_fb, backing_width, backing_height,
+ backing_id);
}
void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
uint32_t x, uint32_t y, uint32_t w, uint32_t h)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
- int ww, wh, y1, y2;
assert(scon->opengl);
if (!scon->scanout_mode) {
return;
}
- if (!scon->fbo_id) {
+ if (!scon->guest_fb.framebuffer) {
return;
}
SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, scon->fbo_id);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-
- SDL_GetWindowSize(scon->real_window, &ww, &wh);
- glViewport(0, 0, ww, wh);
- y1 = scon->y0_top ? 0 : scon->h;
- y2 = scon->y0_top ? scon->h : 0;
- glBlitFramebuffer(0, y1, scon->w, y2,
- 0, 0, ww, wh,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id);
+ SDL_GetWindowSize(scon->real_window,
+ &scon->win_fb.width,
+ &scon->win_fb.height);
+ egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top);
SDL_GL_SwapWindow(scon->real_window);
}
--
2.9.3
next prev parent reply other threads:[~2017-06-06 11:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 11:04 [Qemu-devel] [PATCH 0/4] ui/opengl: add and use helper functions to handle framebuffers Gerd Hoffmann
2017-06-06 11:04 ` [Qemu-devel] [PATCH 1/4] egl-helpers: add helpers to handle opengl framebuffers Gerd Hoffmann
2017-06-07 19:16 ` Marc-André Lureau
2017-06-06 11:04 ` [Qemu-devel] [PATCH 2/4] egl-headless: use framebuffer helper functions Gerd Hoffmann
2017-06-07 21:02 ` Marc-André Lureau
2017-06-12 8:20 ` Gerd Hoffmann
2017-06-06 11:04 ` Gerd Hoffmann [this message]
2017-06-08 7:11 ` [Qemu-devel] [PATCH 3/4] sdl2: " Marc-André Lureau
2017-06-12 8:23 ` Gerd Hoffmann
2017-06-06 11:04 ` [Qemu-devel] [PATCH 4/4] gtk: " Gerd Hoffmann
-- strict thread matches above, loose matches on Subject: below --
2017-06-14 8:41 [Qemu-devel] [PATCH 0/4] ui/opengl: add and use helper functions to handle framebuffers Gerd Hoffmann
2017-06-14 8:41 ` [Qemu-devel] [PATCH 3/4] sdl2: use framebuffer helper functions 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=20170606110459.9771-4-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).