=> cb7162be9c287497f93d9fb5aacd51fffe538040
[1mdiff --git a/src/ui/text_stb.c b/src/ui/text_stb.c[m [1mindex 3844afdb..7c5459e3 100644[m [1m--- a/src/ui/text_stb.c[m [1m+++ b/src/ui/text_stb.c[m [36m@@ -32,7 +32,7 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m - FontRunArgs : set of arguments for constructing a FontRun[m - RunArgs : input arguments for `run_Font_` (the low-level text rendering routine)[m - RunLayer : arguments for processing the glyphs of a GlyphBuffer (layers: background, foreground)[m [31m- [m [32m+[m Optimization notes:[m [m - Caching FontRuns is quite effective, but there is still plenty of unnecessary iteration[m [36m@@ -158,13 +158,13 @@[m [miLocalDef void setRasterized_Glyph_(iGlyph *d, int hoff) {[m }[m [m iDefineTypeConstructionArgs(Glyph, (iChar ch), ch)[m [31m- [m [32m+[m /*-----------------------------------------------------------------------------------------------*/[m [31m- [m [32m+[m static iGlyph *glyph_Font_(iFont *d, iChar ch);[m [m iDeclareType(GlyphTable)[m [31m- [m [32m+[m struct Impl_GlyphTable {[m iHash glyphs; /* key is glyph index in the font */[m /* TODO: `glyphs` does not need to be a Hash.[m [36m@@ -192,9 +192,9 @@[m [mstatic void deinit_GlyphTable(iGlyphTable *d) {[m }[m [m iDefineTypeConstruction(GlyphTable)[m [31m- [m [32m+[m /*-----------------------------------------------------------------------------------------------*/[m [31m- [m [32m+[m struct Impl_Font {[m iBaseFont font;[m int baseline;[m [36m@@ -270,14 +270,14 @@[m [mstatic int cmp_PrioMapItem_(const void *a, const void *b) {[m iDeclareType(FontRunArgs)[m iDeclareType(FontRun)[m iDeclareTypeConstructionArgs(FontRun, const iFontRunArgs *args, const iRangecc text, uint32_t crc)[m [31m- [m [32m+[m iDeclareType(StbText)[m iDeclareTypeConstructionArgs(StbText, SDL_Renderer *render, float documentFontSizeFactor)[m [m struct Impl_StbText {[m iText base;[m iArray fonts; /* fonts currently selected for use (incl. all styles/sizes) */[m [31m- int overrideFontId; /* always checked for glyphs first, regardless of which font is used */ [m [32m+[m[32m int overrideFontId; /* always checked for glyphs first, regardless of which font is used */[m iArray fontPriorityOrder;[m SDL_Texture * cache;[m iInt2 cacheSize;[m [36m@@ -310,7 +310,7 @@[m [mstatic void setupFontVariants_StbText_(iStbText *d, const iFontSpec *spec, int b[m iAssert(current_StbText_() == d);[m pushBack_Array(&d->fontPriorityOrder, &(iPrioMapItem){ spec->priority, baseId });[m for (enum iFontStyle style = 0; style < max_FontStyle; style++) {[m [31m- for (enum iFontSize sizeId = 0; sizeId < max_FontSize; sizeId++) { [m [32m+[m[32m for (enum iFontSize sizeId = 0; sizeId < max_FontSize; sizeId++) {[m init_Font(font_Text_(FONT_ID(baseId, style, sizeId)),[m spec,[m spec->styles[style],[m [36m@@ -453,7 +453,7 @@[m [mvoid init_StbText(iStbText *d, SDL_Renderer *render, float documentFontSizeFacto[m colors[i] = (SDL_Color){ 255, 255, 255, i < 100 ? 0 : 255 };[m }[m d->blackAndWhite = SDL_AllocPalette(256);[m [31m- SDL_SetPaletteColors(d->blackAndWhite, colors, 0, 256); [m [32m+[m[32m SDL_SetPaletteColors(d->blackAndWhite, colors, 0, 256);[m }[m initCache_StbText_(d);[m initFonts_StbText_(d);[m [36m@@ -647,7 +647,7 @@[m [miLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {[m static iGlyph *glyphByIndex_Font_(iFont *d, uint32_t glyphIndex) {[m if (!d->table) {[m d->table = new_GlyphTable();[m [31m- } [m [32m+[m[32m }[m iGlyph* glyph = NULL;[m void * node = value_Hash(&d->table->glyphs, glyphIndex);[m if (node) {[m [36m@@ -1009,7 +1009,7 @@[m [mstatic void justify_GlyphBuffer_(iGlyphBuffer *buffers, size_t numBuffers,[m if (isLast || outerSpace <= 0) {[m return;[m }[m [31m- /* TODO: This could use a utility that handles the `wrapPosRange` character span inside [m [32m+[m[32m /* TODO: This could use a utility that handles the `wrapPosRange` character span inside[m a span of runs. */[m #define CHECK_LOGPOS() \[m if (logPos < wrapPosRange.start) continue; \[m [36m@@ -1220,7 +1220,7 @@[m [mvoid process_RunLayer_(iRunLayer *d, int layerIndex) {[m }[m const iGlyphBuffer *buf = constAt_Array(buffers, runIndex);[m iAssert(run->font == (iBaseFont *) buf->font);[m [31m- /* Process all the glyphs. */ [m [32m+[m[32m /* Process all the glyphs. */[m for (unsigned int i = 0; i < buf->glyphCount; i++) {[m const hb_glyph_info_t *info = &buf->glyphInfo[i];[m const hb_codepoint_t glyphId = info->codepoint;[m [36m@@ -1273,7 +1273,7 @@[m [mvoid process_RunLayer_(iRunLayer *d, int layerIndex) {[m /* Align baselines of different fonts. */[m if (run->font != attrText->baseFont &&[m ~run->font->spec->flags & auxiliary_FontSpecFlag) {[m [31m- const int bl1 = ((iFont *) attrText->baseFont)->baseline + [m [32m+[m[32m const int bl1 = ((iFont *) attrText->baseFont)->baseline +[m ((iFont *) attrText->baseFont)->vertOffset;[m const int bl2 = runFont->baseline + runFont->vertOffset;[m dst.y += bl1 - bl2;[m [36m@@ -1351,7 +1351,7 @@[m [mvoid process_RunLayer_(iRunLayer *d, int layerIndex) {[m }[m d->xCursorMax = iMax(d->xCursorMax, d->xCursor);[m }[m [31m- } [m [32m+[m[32m }[m }[m [m static unsigned fontRunCacheHits_ = 0;[m [36m@@ -1458,7 +1458,7 @@[m [mstatic void run_Font_(iFont *d, const iRunArgs *args) {[m }[m float wrapAdvance = 0.0f;[m /* First we need to figure out how much text fits on the current line. */[m [31m- if (wrap && wrap->maxWidth > 0) {[m [32m+[m[32m if (wrap) {[m float breakAdvance = -1.0f;[m size_t breakRunIndex = iInvalidPos;[m iAssert(wrapPosRange.end == textLen);[m [36m@@ -1700,7 +1700,7 @@[m [mstatic void run_Font_(iFont *d, const iRunArgs *args) {[m }[m printf("\n");[m #endif[m [31m- [m [32m+[m }[m iAssert(size_Array(&runOrder) == size_Range(&wrapRuns));[m /* Alignment. */[m [36m@@ -1750,9 +1750,9 @@[m [mstatic void run_Font_(iFont *d, const iRunArgs *args) {[m process_RunLayer_(&layer, layerIndex);[m }[m bounds = layer.bounds;[m [31m- xCursor = layer.xCursor; [m [32m+[m[32m xCursor = layer.xCursor;[m xCursorMax = layer.xCursorMax;[m [31m- yCursor = layer.yCursor; [m [32m+[m[32m yCursor = layer.yCursor;[m deinit_Array(&runOrder);[m if (willAbortDueToWrap) {[m break;[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).