Make sure util::atlas size is power-of-two
This commit is contained in:
parent
eb55ad5644
commit
0791aa1096
1 changed files with 16 additions and 6 deletions
|
|
@ -53,14 +53,24 @@ namespace psemek::util
|
||||||
part.begin[1] = 0;
|
part.begin[1] = 0;
|
||||||
part.end[1] = part_height;
|
part.end[1] = part_height;
|
||||||
|
|
||||||
std::size_t new_width = std::max(array_.width(), free_start_ + part_width);
|
std::size_t new_width = array_.width();
|
||||||
std::size_t new_height = std::max(array_.height(), part_height);
|
std::size_t new_height = array_.height();
|
||||||
|
|
||||||
if (new_width > array_.width())
|
while (new_width < free_start_ + part_width)
|
||||||
new_width = std::max(new_width, array_.width() * 2);
|
{
|
||||||
|
if (new_width == 0)
|
||||||
|
new_width = 1;
|
||||||
|
else
|
||||||
|
new_width *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (new_height > array_.height())
|
while (new_height < part_height)
|
||||||
new_height = std::max(new_height, array_.height() * 2);
|
{
|
||||||
|
if (new_height == 0)
|
||||||
|
new_height = 1;
|
||||||
|
else
|
||||||
|
new_height *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
array_.resize({new_width, new_height}, default_value_);
|
array_.resize({new_width, new_height}, default_value_);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue