From d8f2f583e69fa5e61395bc0e9af5a2b7c1b4a5e4 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Fri, 27 Oct 2017 16:49:55 +0300 Subject: [PATCH] cogl-texture: refuse downloading textures in cogl_texture_get_data() on GLES On drivers that do not support glGetTexImage2D (i.e. on GLES), cogl_texture_get_data() has a "feature" that allows it to download texture data by rendering the texture on an intermediate framebuffer object and then reading back the data from there. However, this feature requires the user to have previously set an "active" framebuffer object in the context, which makes this very tricky because it is not clear to the developer that he needs to do that in order for some code to work on GLES (of course it works on desktop GL, so nobody notices...) and additionally the code actually crashes if an active fbo is not set! This patch basically removes this feature in order to prevent the crash and is in line with how this code has evolved in cogl-2.0: https://git.gnome.org/browse/cogl/commit/?id=6d6a277b8e9a63a8268046e5258877ba94a1da5b https://bugzilla.gnome.org/show_bug.cgi?id=789961 --- cogl/cogl/cogl-texture.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index 729fb0c05..55104e531 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -1156,25 +1156,13 @@ cogl_texture_get_data (CoglTexture *texture, tg_data.success = FALSE; } - /* XXX: In some cases _cogl_texture_2d_download_from_gl may fail - * to read back the texture data; such as for GLES which doesn't - * support glGetTexImage, so here we fallback to drawing the - * texture and reading the pixels from the framebuffer. */ + /* XXX: In some cases this api may fail to read back the texture + * data; such as for GLES which doesn't support glGetTexImage + */ if (!tg_data.success) { - if (!_cogl_texture_draw_and_read (texture, target_bmp, - closest_gl_format, - closest_gl_type, - &ignore_error)) - { - /* We have no more fallbacks so we just give up and - * hope for the best */ - g_warning ("Failed to read texture since draw-and-read " - "fallback failed: %s", ignore_error->message); - cogl_error_free (ignore_error); - cogl_object_unref (target_bmp); - return 0; - } + cogl_object_unref (target_bmp); + return 0; } /* Was intermediate used? */