cogl-texture: Don't attempt to use GL to convert formats under GLES

In commit abe91784c4 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
This commit is contained in:
Neil Roberts 2010-04-26 12:30:37 +01:00
parent 8530b7946a
commit 405d529f44

View File

@ -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;