aboutsummaryrefslogtreecommitdiff
path: root/ui/egl-helpers.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-09-27 13:50:31 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-09-29 10:36:33 +0200
commit74083f9c01910b1d36ddaca04db468eb326676ae (patch)
treed4a928528ba030c2afa7ee735942023becf53a8a /ui/egl-helpers.c
parente2f82e924d057935dd4c61c0c53e11b15762eda2 (diff)
egl: misc framebuffer helper improvements.
Rename the functions to to say "setup" instead of "create" because they support being called multiple times on the same egl framebuffer. Properly delete unused textures, update function interfaces to support this. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20170927115031.12063-1-kraxel@redhat.com
Diffstat (limited to 'ui/egl-helpers.c')
-rw-r--r--ui/egl-helpers.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index bb19a5eeca..cde9965dea 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -26,16 +26,23 @@ EGLConfig qemu_egl_config;
/* ------------------------------------------------------------------ */
+static void egl_fb_delete_texture(egl_fb *fb)
+{
+ if (!fb->delete_texture) {
+ return;
+ }
+
+ glDeleteTextures(1, &fb->texture);
+ fb->delete_texture = false;
+}
+
void egl_fb_destroy(egl_fb *fb)
{
if (!fb->framebuffer) {
return;
}
- if (fb->delete_texture) {
- glDeleteTextures(1, &fb->texture);
- fb->delete_texture = false;
- }
+ egl_fb_delete_texture(fb);
glDeleteFramebuffers(1, &fb->framebuffer);
fb->width = 0;
@@ -51,11 +58,15 @@ void egl_fb_setup_default(egl_fb *fb, int width, int height)
fb->framebuffer = 0; /* default framebuffer */
}
-void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint texture)
+void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
+ GLuint texture, bool delete)
{
+ egl_fb_delete_texture(fb);
+
fb->width = width;
fb->height = height;
fb->texture = texture;
+ fb->delete_texture = delete;
if (!fb->framebuffer) {
glGenFramebuffers(1, &fb->framebuffer);
}
@@ -65,7 +76,7 @@ void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint texture)
GL_TEXTURE_2D, fb->texture, 0);
}
-void egl_fb_create_new_tex(egl_fb *fb, int width, int height)
+void egl_fb_setup_new_tex(egl_fb *fb, int width, int height)
{
GLuint texture;
@@ -74,8 +85,7 @@ void egl_fb_create_new_tex(egl_fb *fb, int width, int height)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height,
0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
- egl_fb_create_for_tex(fb, width, height, texture);
- fb->delete_texture = true;
+ egl_fb_setup_for_tex(fb, width, height, texture, true);
}
void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip)