DynamicAtlas argument passthrough, submodule update
This commit is contained in:
parent
f6a1bc9f76
commit
39b0f28b44
|
|
@ -1 +1 @@
|
||||||
Subproject commit a3dcadb9df2b5d45db2691ceea84318c711cb3e1
|
Subproject commit 34134bde3cea35a93c2ae5703fa8d3d463793400
|
||||||
|
|
@ -24,6 +24,9 @@ public:
|
||||||
typedef int ChangeFlags;
|
typedef int ChangeFlags;
|
||||||
|
|
||||||
DynamicAtlas();
|
DynamicAtlas();
|
||||||
|
/// Initializes generator with dimensions and custom arguments for generator
|
||||||
|
template <typename... ARGS>
|
||||||
|
explicit DynamicAtlas(int minSide, ARGS... args);
|
||||||
/// Creates with a configured generator. The generator must not contain any prior glyphs!
|
/// Creates with a configured generator. The generator must not contain any prior glyphs!
|
||||||
explicit DynamicAtlas(AtlasGenerator &&generator);
|
explicit DynamicAtlas(AtlasGenerator &&generator);
|
||||||
/// Adds a batch of glyphs. Adding more than one glyph at a time may improve packing efficiency
|
/// Adds a batch of glyphs. Adding more than one glyph at a time may improve packing efficiency
|
||||||
|
|
@ -33,14 +36,14 @@ public:
|
||||||
const AtlasGenerator & atlasGenerator() const;
|
const AtlasGenerator & atlasGenerator() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AtlasGenerator generator;
|
|
||||||
RectanglePacker packer;
|
|
||||||
int glyphCount;
|
|
||||||
int side;
|
int side;
|
||||||
|
int padding;
|
||||||
|
int glyphCount;
|
||||||
|
int totalArea;
|
||||||
|
RectanglePacker packer;
|
||||||
|
AtlasGenerator generator;
|
||||||
std::vector<Rectangle> rectangles;
|
std::vector<Rectangle> rectangles;
|
||||||
std::vector<Remap> remapBuffer;
|
std::vector<Remap> remapBuffer;
|
||||||
int totalArea;
|
|
||||||
int padding;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,25 @@
|
||||||
|
|
||||||
namespace msdf_atlas {
|
namespace msdf_atlas {
|
||||||
|
|
||||||
template <class AtlasGenerator>
|
static int ceilPOT(int x) {
|
||||||
DynamicAtlas<AtlasGenerator>::DynamicAtlas() : glyphCount(0), side(0), totalArea(0), padding(0) { }
|
if (x > 0) {
|
||||||
|
int y = 1;
|
||||||
|
while (y < x)
|
||||||
|
y <<= 1;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
template <class AtlasGenerator>
|
template <class AtlasGenerator>
|
||||||
DynamicAtlas<AtlasGenerator>::DynamicAtlas(AtlasGenerator &&generator) : generator((AtlasGenerator &&) generator), glyphCount(0), side(0), totalArea(0), padding(0) { }
|
DynamicAtlas<AtlasGenerator>::DynamicAtlas() : side(0), padding(0), glyphCount(0), totalArea(0) { }
|
||||||
|
|
||||||
|
template <class AtlasGenerator>
|
||||||
|
template <typename... ARGS>
|
||||||
|
DynamicAtlas<AtlasGenerator>::DynamicAtlas(int minSide, ARGS... args) : side(ceilPOT(minSide)), padding(0), glyphCount(0), totalArea(0), packer(side+padding, side+padding), generator(side, side, args...) { }
|
||||||
|
|
||||||
|
template <class AtlasGenerator>
|
||||||
|
DynamicAtlas<AtlasGenerator>::DynamicAtlas(AtlasGenerator &&generator) : side(0), padding(0), glyphCount(0), totalArea(0), generator((AtlasGenerator &&) generator) { }
|
||||||
|
|
||||||
template <class AtlasGenerator>
|
template <class AtlasGenerator>
|
||||||
typename DynamicAtlas<AtlasGenerator>::ChangeFlags DynamicAtlas<AtlasGenerator>::add(GlyphGeometry *glyphs, int count, bool allowRearrange) {
|
typename DynamicAtlas<AtlasGenerator>::ChangeFlags DynamicAtlas<AtlasGenerator>::add(GlyphGeometry *glyphs, int count, bool allowRearrange) {
|
||||||
|
|
@ -31,7 +45,7 @@ typename DynamicAtlas<AtlasGenerator>::ChangeFlags DynamicAtlas<AtlasGenerator>:
|
||||||
int packerStart = start;
|
int packerStart = start;
|
||||||
int remaining;
|
int remaining;
|
||||||
while ((remaining = packer.pack(rectangles.data()+packerStart, rectangles.size()-packerStart)) > 0) {
|
while ((remaining = packer.pack(rectangles.data()+packerStart, rectangles.size()-packerStart)) > 0) {
|
||||||
side = (side+!side)<<1;
|
side = (side|!side)<<1;
|
||||||
while (side*side < totalArea)
|
while (side*side < totalArea)
|
||||||
side <<= 1;
|
side <<= 1;
|
||||||
if (allowRearrange) {
|
if (allowRearrange) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ class ImmediateAtlasGenerator {
|
||||||
public:
|
public:
|
||||||
ImmediateAtlasGenerator();
|
ImmediateAtlasGenerator();
|
||||||
ImmediateAtlasGenerator(int width, int height);
|
ImmediateAtlasGenerator(int width, int height);
|
||||||
|
template <typename... ARGS>
|
||||||
|
ImmediateAtlasGenerator(int width, int height, ARGS... storageArgs);
|
||||||
void generate(const GlyphGeometry *glyphs, int count);
|
void generate(const GlyphGeometry *glyphs, int count);
|
||||||
void rearrange(int width, int height, const Remap *remapping, int count);
|
void rearrange(int width, int height, const Remap *remapping, int count);
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::ImmediateAtlasGenerator() :
|
||||||
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
|
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
|
||||||
ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::ImmediateAtlasGenerator(int width, int height) : storage(width, height), threadCount(1) { }
|
ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::ImmediateAtlasGenerator(int width, int height) : storage(width, height), threadCount(1) { }
|
||||||
|
|
||||||
|
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
|
||||||
|
template <typename... ARGS>
|
||||||
|
ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::ImmediateAtlasGenerator(int width, int height, ARGS... storageArgs) : storage(width, height, storageArgs...), threadCount(1) { }
|
||||||
|
|
||||||
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
|
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
|
||||||
void ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::generate(const GlyphGeometry *glyphs, int count) {
|
void ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::generate(const GlyphGeometry *glyphs, int count) {
|
||||||
int maxBoxArea = 0;
|
int maxBoxArea = 0;
|
||||||
|
|
|
||||||
2
msdfgen
2
msdfgen
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7ff249bcd4da6678c5779d9664633c039fb50c0a
|
Subproject commit 5eef2e59854717528574619d48bec03cc88ab1c9
|
||||||
Loading…
Reference in New Issue