Browse Source

Text: drop a workaround for zero-size items in GlyphCache reserve().

The AtlasLandfill no longer rejects those, so it's unnecessary.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
2a6ebf091f
  1. 12
      src/Magnum/Text/AbstractGlyphCache.cpp
  2. 4
      src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp

12
src/Magnum/Text/AbstractGlyphCache.cpp

@ -274,13 +274,10 @@ std::vector<Range2Di> AbstractGlyphCache::reserve(const std::vector<Vector2i>& s
state.atlas.clearFlags(TextureTools::AtlasLandfillFlag::RotatePortrait|
TextureTools::AtlasLandfillFlag::RotateLandscape);
/* Create the output array. Because the new atlas packer doesn't accept
zero sizes, change those to be (1, 1) instead. A new interface will
disallow them as well, but here we want to keep backwards
compatibility. */
/* Create the output array */
std::vector<Range2Di> out(sizes.size());
for(std::size_t i = 0; i != sizes.size(); ++i)
out[i].max() = Math::max(sizes[i], Vector2i{1});
out[i].max() = sizes[i];
const bool succeeded = state.atlas.add(
Containers::stridedArrayView(out).slice(&Range2Di::max),
@ -298,10 +295,9 @@ std::vector<Range2Di> AbstractGlyphCache::reserve(const std::vector<Vector2i>& s
return {};
}
/* Update the ranges max values to match the new offsets, undo the zero
sizes being (1, 1) */
/* Update the ranges max values to match the new offsets */
for(std::size_t i = 0; i != sizes.size(); ++i)
out[i].max() = out[i].min() + sizes[i];
out[i].max() += out[i].min();
return out;
}

4
src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp

@ -684,8 +684,8 @@ void AbstractGlyphCacheTest::reserve() {
Range2Di::fromSize({6, 12}, {5, 3}),
Range2Di::fromSize({1, 2}, {12, 6}),
Range2Di::fromSize({13, 12}, {10, 5}),
Range2Di::fromSize({1, 17}, {0, 1}),
Range2Di::fromSize({1, 12}, {3, 0}),
Range2Di::fromSize({4, 12}, {0, 1}),
Range2Di::fromSize({1, 17}, {3, 0}),
}), TestSuite::Compare::Container);
}

Loading…
Cancel
Save