diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-13 19:59:41 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-13 19:59:41 +0200 |
commit | f18c5e9a259c88f7bc3bbc9cf8afcf805ba00a60 (patch) | |
tree | e7838b803cad78eb1b0c5c0d15b4f6d639b0d400 /src/ui/documentwidget.c | |
parent | 379f8cea2044854be02622a561dd3c9cd9fb06c2 (diff) |
Text: Separate glyph caching procedure
Previously glyph caching was done during text rendering, but that would mean lots of swapping between rendering stuff to the cache and then immediately afterward rendering to the display. There would be a swap per each new glyph.
Now the entire document's glyphs are precached at once when a request is finished. Glyphs are also cached in larger batches when new text needs to be drawn.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index a7666865..9111b546 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1004,6 +1004,17 @@ static void parseUser_DocumentWidget_(iDocumentWidget *d) { | |||
1004 | setRange_String(d->titleUser, urlUser_String(d->mod.url)); | 1004 | setRange_String(d->titleUser, urlUser_String(d->mod.url)); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | static void cacheRunGlyphs_(void *data, const iGmRun *run) { | ||
1008 | iUnused(data); | ||
1009 | if (!isEmpty_Range(&run->text)) { | ||
1010 | cache_Text(run->font, run->text); | ||
1011 | } | ||
1012 | } | ||
1013 | |||
1014 | static void cacheDocumentGlyphs_DocumentWidget_(const iDocumentWidget *d) { | ||
1015 | render_GmDocument(d->doc, (iRangei){ 0, size_GmDocument(d->doc).y }, cacheRunGlyphs_, NULL); | ||
1016 | } | ||
1017 | |||
1007 | static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { | 1018 | static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { |
1008 | const iRecentUrl *recent = findUrl_History(d->mod.history, d->mod.url); | 1019 | const iRecentUrl *recent = findUrl_History(d->mod.history, d->mod.url); |
1009 | if (recent && recent->cachedResponse) { | 1020 | if (recent && recent->cachedResponse) { |
@@ -1026,6 +1037,7 @@ static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { | |||
1026 | updateSideOpacity_DocumentWidget_(d, iFalse); | 1037 | updateSideOpacity_DocumentWidget_(d, iFalse); |
1027 | updateSideIconBuf_DocumentWidget_(d); | 1038 | updateSideIconBuf_DocumentWidget_(d); |
1028 | updateVisible_DocumentWidget_(d); | 1039 | updateVisible_DocumentWidget_(d); |
1040 | cacheDocumentGlyphs_DocumentWidget_(d); | ||
1029 | postCommandf_App("document.changed doc:%p url:%s", d, cstr_String(d->mod.url)); | 1041 | postCommandf_App("document.changed doc:%p url:%s", d, cstr_String(d->mod.url)); |
1030 | return iTrue; | 1042 | return iTrue; |
1031 | } | 1043 | } |
@@ -1762,6 +1774,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1762 | scrollToHeading_DocumentWidget_(d, cstr_String(&d->pendingGotoHeading)); | 1774 | scrollToHeading_DocumentWidget_(d, cstr_String(&d->pendingGotoHeading)); |
1763 | clear_String(&d->pendingGotoHeading); | 1775 | clear_String(&d->pendingGotoHeading); |
1764 | } | 1776 | } |
1777 | cacheDocumentGlyphs_DocumentWidget_(d); | ||
1765 | return iFalse; | 1778 | return iFalse; |
1766 | } | 1779 | } |
1767 | else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) { | 1780 | else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) { |