diff options
Diffstat (limited to 'cogl/cogl-bitmap-conversion.c')
-rw-r--r-- | cogl/cogl-bitmap-conversion.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/cogl/cogl-bitmap-conversion.c b/cogl/cogl-bitmap-conversion.c index 6a2e8507..b6d9b149 100644 --- a/cogl/cogl-bitmap-conversion.c +++ b/cogl/cogl-bitmap-conversion.c @@ -325,6 +325,7 @@ _cogl_bitmap_needs_short_temp_buffer (CoglPixelFormat format) g_assert_not_reached (); case COGL_PIXEL_FORMAT_A_8: + case COGL_PIXEL_FORMAT_RG_88: case COGL_PIXEL_FORMAT_RGB_565: case COGL_PIXEL_FORMAT_RGBA_4444: case COGL_PIXEL_FORMAT_RGBA_5551: @@ -512,6 +513,35 @@ _cogl_bitmap_convert (CoglBitmap *src_bmp, return dst_bmp; } +static CoglBool +driver_can_convert (CoglContext *ctx, + CoglPixelFormat src_format, + CoglPixelFormat internal_format) +{ + if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_FORMAT_CONVERSION)) + return FALSE; + + if (src_format == internal_format) + return TRUE; + + /* If the driver doesn't natively support alpha textures then it + * won't work correctly to convert to/from component-alpha + * textures */ + if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) && + (src_format == COGL_PIXEL_FORMAT_A_8 || + internal_format == COGL_PIXEL_FORMAT_A_8)) + return FALSE; + + /* Same for red-green textures. If red-green textures aren't + * supported then the internal format should never be RG_88 but we + * should still be able to convert from an RG source image */ + if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RG) && + src_format == COGL_PIXEL_FORMAT_RG_88) + return FALSE; + + return TRUE; +} + CoglBitmap * _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp, CoglPixelFormat internal_format, @@ -532,15 +562,7 @@ _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp, limited number of formats so we must convert using the Cogl bitmap code instead */ - /* If the driver doesn't natively support alpha textures then it - * won't work correctly to convert to/from component-alpha - * textures */ - - if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_FORMAT_CONVERSION) && - (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) || - (src_format != COGL_PIXEL_FORMAT_A_8 && - internal_format != COGL_PIXEL_FORMAT_A_8) || - src_format == internal_format)) + if (driver_can_convert (ctx, src_format, internal_format)) { /* If the source format does not have the same premult flag as the internal_format then we need to copy and convert it */ |