GNOME Bugzilla – Bug 657840
Atlas-ed bitmaps converted too many times
Last modified: 2011-09-05 19:55:00 UTC
Quoted from a message on clutter-devel-list: When I call clutter_texture_set_from_data with an RGB-888 bitmap and I'm using the atlas, _cogl_atlas_texture_new_from_bitmap ends up being called. This one calls _cogl_atlas_texture_set_region_with_border, which calls _cogl_texture_set_region_from_bitmap **** 5 **** times. Since the bitmap is RGB and the atlas is RGBA, the bitmap gets converted to RGBA 5 times, which seems wasteful. http://lists.clutter-project.org/pipermail/clutter-devel-list/2011-August/000252.html
Created attachment 195323 [details] [review] texture: Call _cogl_texture_prepare_for_upload in set_region impl Instead of calling _cogl_texutre_prepare_for_upload in cogl_texture_set_region_from_bitmap the call is now deferred to the implementation of the virtual for set_region. This is needed if the texture backend is using a different format for the actual GL texture than what is reported by cogl_texture_get_format. This happens for example with atlas textures which report the original internal format specified when the texture was created but actually always store the data in an RGBA texture. Also when creating an atlas texture from a bitmap it was preparing the bitmap to be uploaded to the original format instead of the format of the actual texture used for the atlas. Then it was using cogl_texture_set_region_from_bitmap to upload the 5 pieces to make the copies of the edge pixels. This would end up converting the image to the actual format 5 times. The atlas textures have now been changed to prepare the bitmap for the right format.
thanks, I landed the patch in master as 503f138fb67f6c0