aboutsummaryrefslogtreecommitdiff
path: root/ui/sdl2-gl.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-06-22 13:18:11 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-06-22 13:18:11 +0100
commit22a9e1fd63ebd7254c6618f144357def75a993cb (patch)
tree003d7a59d9bf8acf153910ac1dbe8e141c560a83 /ui/sdl2-gl.c
parent84e3d0725b06bdf8c6985788caa7776d6b7353ce (diff)
parent95e92000c8b1e81fce6a7f54ef22656a94793096 (diff)
Merge remote-tracking branch 'remotes/kraxel/tags/queue/ui-pull-request' into staging
# gpg: Signature made Wed 21 Jun 2017 14:23:31 BST # gpg: using RSA key 0x4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/queue/ui-pull-request: ui: Remove inclusion of "hw/qdev.h" console: remove do_safe_dpy_refresh gtk: use framebuffer helper functions. sdl2: use framebuffer helper functions. egl-headless: use framebuffer helper functions. egl-helpers: add helpers to handle opengl framebuffers Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/sdl2-gl.c')
-rw-r--r--ui/sdl2-gl.c36
1 files changed, 7 insertions, 29 deletions
diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index 1cd77e2c16..dcad3d0d26 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;
+ int ww, wh;
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);
+ egl_fb_setup_default(&scon->win_fb, ww, wh);
+ egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top);
SDL_GL_SwapWindow(scon->real_window);
}