mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
cogl-atlas: Try the next size when there would be less than 6% waste
Previously when the atlas needs to be migrated it would start by trying with the same size as the existing atlas if there is enough space for the new texture. However even if the atlas is completely sorted there will always be some amount of waste so when the atlas needs to grow it would usually end up redundantly trying the same size when it is very unlikely to fit. This patch changes it so that there must be at least 6% waste available after the new texture is added otherwise it will start with the next atlas size.
This commit is contained in:
parent
f98be241a8
commit
2b5bb06bed
@ -496,11 +496,13 @@ _cogl_atlas_reserve_space (CoglAtlas *atlas,
|
|||||||
map_width = _cogl_rectangle_map_get_width (atlas->map);
|
map_width = _cogl_rectangle_map_get_width (atlas->map);
|
||||||
map_height = _cogl_rectangle_map_get_height (atlas->map);
|
map_height = _cogl_rectangle_map_get_height (atlas->map);
|
||||||
|
|
||||||
/* If there is enough space in the existing for the new
|
/* If there is enough space in for the new rectangle in the
|
||||||
rectangle in the existing atlas we'll start with the same
|
existing atlas with at least 6% waste we'll start with the
|
||||||
size, otherwise we'll immediately double it */
|
same size, otherwise we'll immediately double it */
|
||||||
if (_cogl_rectangle_map_get_remaining_space (atlas->map) <
|
if ((map_width * map_height -
|
||||||
width * height)
|
_cogl_rectangle_map_get_remaining_space (atlas->map) +
|
||||||
|
width * height) * 53 / 50 >
|
||||||
|
map_width * map_height)
|
||||||
_cogl_atlas_get_next_size (&map_width, &map_height);
|
_cogl_atlas_get_next_size (&map_width, &map_height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user