MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / AddEntry

Method AddEntry

Source/Engine/Render2D/FontTextureAtlas.cpp:48–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48FontTextureAtlasSlot* FontTextureAtlas::AddEntry(uint32 width, uint32 height, const Array<byte>& data)
49{
50 if (width == 0 || height == 0)
51 return nullptr;
52
53 // Try to find slot for the texture
54 FontTextureAtlasSlot* slot = nullptr;
55 for (int32 i = 0; i < _freeSlots.Count(); i++)
56 {
57 FontTextureAtlasSlot* e = _freeSlots[i];
58 if (e->Width == width && e->Height == height)
59 {
60 slot = e;
61 _freeSlots.RemoveAt(i);
62 break;
63 }
64 }
65 if (!slot)
66 {
67 slot = _atlas.Insert(width, height);
68 }
69
70 if (slot)
71 {
72 // Copy data to into the atlas memory
73 CopyDataIntoSlot(slot, data);
74 _isDirty = true;
75 }
76
77 return slot;
78}
79
80bool FontTextureAtlas::Invalidate(const FontTextureAtlasSlot* slot)
81{

Callers 1

AddNewEntryMethod · 0.45

Calls 3

CountMethod · 0.45
RemoveAtMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected