void egl_fb_destroy(egl_fb *fb);
void egl_fb_setup_default(egl_fb *fb, int width, int height);
-void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint texture);
-void egl_fb_create_new_tex(egl_fb *fb, int width, int height);
+void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
+ GLuint texture, bool delete);
+void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
void egl_fb_read(void *dst, egl_fb *src);
edpy->y_0_top = backing_y_0_top;
/* source framebuffer */
- egl_fb_create_for_tex(&edpy->guest_fb,
- backing_width, backing_height, backing_id);
+ egl_fb_setup_for_tex(&edpy->guest_fb,
+ backing_width, backing_height, backing_id, false);
/* dest framebuffer */
if (edpy->blit_fb.width != backing_width ||
edpy->blit_fb.height != backing_height) {
egl_fb_destroy(&edpy->blit_fb);
- egl_fb_create_new_tex(&edpy->blit_fb, backing_width, backing_height);
+ egl_fb_setup_new_tex(&edpy->blit_fb, backing_width, backing_height);
}
}
/* ------------------------------------------------------------------ */
+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;
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);
}
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;
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)
vc->gfx.esurface, vc->gfx.ectx);
gtk_egl_set_scanout_mode(vc, true);
- egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
- backing_id);
+ egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+ backing_id, false);
}
void gd_egl_scanout_flush(DisplayChangeListener *dcl,
}
gtk_gl_area_set_scanout_mode(vc, true);
- egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
- backing_id);
+ egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+ backing_id, false);
}
void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
sdl2_set_scanout_mode(scon, true);
- egl_fb_create_for_tex(&scon->guest_fb, backing_width, backing_height,
- backing_id);
+ egl_fb_setup_for_tex(&scon->guest_fb, backing_width, backing_height,
+ backing_id, false);
}
void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,