From 405d529f449bb3cfa7f156510a98e70e38c9e1b5 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 26 Apr 2010 12:30:37 +0100 Subject: [PATCH] cogl-texture: Don't attempt to use GL to convert formats under GLES In commit abe91784c4b I changed cogl-texture so that it would use the OpenGL mechanism to specify a different internal texture format from the image format so that it can do the conversion instead of Cogl. However under GLES the internal format and the image format must always be the same and it only supports a limited set of formats. This patch changes _cogl_texture_prepare_for_upload so that it does the conversion using the cogl bitmap code when compiling for GLES. http://bugzilla.openedhand.com/show_bug.cgi?id=2059 --- clutter/cogl/cogl/cogl-texture.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/clutter/cogl/cogl/cogl-texture.c b/clutter/cogl/cogl/cogl-texture.c index b5c0dd2..b192a8a 100644 --- a/clutter/cogl/cogl/cogl-texture.c +++ b/clutter/cogl/cogl/cogl-texture.c @@ -148,6 +148,16 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp, *copied_bitmap = FALSE; *dst_bmp = *src_bmp; + /* OpenGL supports specifying a different format for the internal + format when uploading texture data. We should use this to convert + formats because it is likely to be faster and support more types + than the Cogl bitmap code. However under GLES the internal format + must be the same as the bitmap format and it only supports a + limited number of formats so we must convert using the Cogl + bitmap code instead */ + +#ifdef HAVE_COGL_GL + /* If the source format does not have the same premult flag as the dst format then we need to copy and convert it */ if (_cogl_texture_needs_premult_conversion (src_bmp->format, @@ -178,6 +188,28 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp, NULL, NULL); +#else /* HAVE_COGL_GL */ + { + CoglPixelFormat closest_format; + + closest_format = _cogl_pixel_format_to_gl (dst_bmp->format, + out_glintformat, + out_glformat, + out_gltype); + + + if (closest_format != src_bmp->format) + { + if (!_cogl_bitmap_convert_format_and_premult (src_bmp, + dst_bmp, + closest_format)) + return FALSE; + + *copied_bitmap = TRUE; + } + } +#endif /* HAVE_COGL_GL */ + if (dst_format_out) *dst_format_out = dst_format; -- 2.7.4