ImFont: Rearranged members toward an optimal CalcTextSize() loop. Removed comments from destructor. Made constructor more explicit.
This commit is contained in:
parent
539f69b950
commit
4b41d3b280
36
imgui.h
36
imgui.h
@ -2078,24 +2078,26 @@ struct ImFontAtlas
|
|||||||
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
||||||
struct ImFont
|
struct ImFont
|
||||||
{
|
{
|
||||||
// Members: Hot ~62/78 bytes
|
// Members: Hot ~24/32 bytes (for CalcTextSize)
|
||||||
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
|
ImVector<float> IndexAdvanceX; // 12/16 // out // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
||||||
float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
float FontSize; // 4 // in // <user set> // Height of characters, set during loading (don't change after loading)
|
||||||
ImVec2 DisplayOffset; // = (0.f,0.f) // Offset font rendering by xx pixels
|
float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX
|
||||||
ImVector<ImFontGlyph> Glyphs; // // All glyphs.
|
ImWchar FallbackChar; // 2 // in // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
||||||
ImVector<float> IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
|
||||||
ImVector<ImWchar> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
|
|
||||||
const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
|
||||||
float FallbackAdvanceX; // == FallbackGlyph->AdvanceX
|
|
||||||
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
|
||||||
|
|
||||||
// Members: Cold ~18/26 bytes
|
// Members: Hot ~36/48 bytes (for CalcTextSize + render loop)
|
||||||
short ConfigDataCount; // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
ImVector<ImWchar> IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point.
|
||||||
ImFontConfig* ConfigData; // // Pointer within ContainerAtlas->ConfigData
|
ImVector<ImFontGlyph> Glyphs; // 12-16 // out // // All glyphs.
|
||||||
ImFontAtlas* ContainerAtlas; // // What we has been loaded into
|
ImVec2 DisplayOffset; // 8 // in // = (0,0) // Offset font rendering by xx pixels
|
||||||
float Ascent, Descent; // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar)
|
||||||
bool DirtyLookupTables;
|
|
||||||
int MetricsTotalSurface;// // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
// Members: Cold ~28/40 bytes
|
||||||
|
ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
|
||||||
|
ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData
|
||||||
|
short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
||||||
|
bool DirtyLookupTables; // 1 // out //
|
||||||
|
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||||
|
float Ascent, Descent; // 8 // out // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||||
|
int MetricsTotalSurface;// 4 // out // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
IMGUI_API ImFont();
|
IMGUI_API ImFont();
|
||||||
|
@ -2390,38 +2390,36 @@ void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
|
|||||||
|
|
||||||
ImFont::ImFont()
|
ImFont::ImFont()
|
||||||
{
|
{
|
||||||
Scale = 1.0f;
|
FontSize = 0.0f;
|
||||||
|
FallbackAdvanceX = 0.0f;
|
||||||
FallbackChar = (ImWchar)'?';
|
FallbackChar = (ImWchar)'?';
|
||||||
DisplayOffset = ImVec2(0.0f, 0.0f);
|
DisplayOffset = ImVec2(0.0f, 0.0f);
|
||||||
ClearOutputData();
|
FallbackGlyph = NULL;
|
||||||
|
ContainerAtlas = NULL;
|
||||||
|
ConfigData = NULL;
|
||||||
|
ConfigDataCount = 0;
|
||||||
|
DirtyLookupTables = false;
|
||||||
|
Scale = 1.0f;
|
||||||
|
Ascent = Descent = 0.0f;
|
||||||
|
MetricsTotalSurface = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImFont::~ImFont()
|
ImFont::~ImFont()
|
||||||
{
|
{
|
||||||
// Invalidate active font so that the user gets a clear crash instead of a dangling pointer.
|
|
||||||
// If you want to delete fonts you need to do it between Render() and NewFrame().
|
|
||||||
// FIXME-CLEANUP
|
|
||||||
/*
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
if (g.Font == this)
|
|
||||||
g.Font = NULL;
|
|
||||||
*/
|
|
||||||
ClearOutputData();
|
ClearOutputData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFont::ClearOutputData()
|
void ImFont::ClearOutputData()
|
||||||
{
|
{
|
||||||
FontSize = 0.0f;
|
FontSize = 0.0f;
|
||||||
|
FallbackAdvanceX = 0.0f;
|
||||||
Glyphs.clear();
|
Glyphs.clear();
|
||||||
IndexAdvanceX.clear();
|
IndexAdvanceX.clear();
|
||||||
IndexLookup.clear();
|
IndexLookup.clear();
|
||||||
FallbackGlyph = NULL;
|
FallbackGlyph = NULL;
|
||||||
FallbackAdvanceX = 0.0f;
|
|
||||||
ConfigDataCount = 0;
|
|
||||||
ConfigData = NULL;
|
|
||||||
ContainerAtlas = NULL;
|
ContainerAtlas = NULL;
|
||||||
Ascent = Descent = 0.0f;
|
|
||||||
DirtyLookupTables = true;
|
DirtyLookupTables = true;
|
||||||
|
Ascent = Descent = 0.0f;
|
||||||
MetricsTotalSurface = 0;
|
MetricsTotalSurface = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user