summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-03 15:22:02 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-03 15:22:02 +0300
commit8e8e486a2969dbc20b3c3a08023267e9eab53265 (patch)
treeee5bf60115de72b0183c34a68b6236299e05593b /src/ui/text.c
parentb02c72a21692435dd974c2b767ee3e003ed6f846 (diff)
Drawing only during window update
Glyphs were inadvertently being cached already during measuring for layout. DocumentWidget was buffering graphics too early. Now buffered draws are prepared during normal drawing, when needed.
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 674e2a72..6af7d6d1 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
24#include "color.h" 24#include "color.h"
25#include "metrics.h" 25#include "metrics.h"
26#include "embedded.h" 26#include "embedded.h"
27#include "window.h"
27#include "app.h" 28#include "app.h"
28 29
29#define STB_TRUETYPE_IMPLEMENTATION 30#define STB_TRUETYPE_IMPLEMENTATION
@@ -702,6 +703,7 @@ void cacheTextGlyphs_Font_(iFont *d, const iRangecc text) {
702 iArray * rasters = NULL; 703 iArray * rasters = NULL;
703 SDL_Texture *oldTarget = NULL; 704 SDL_Texture *oldTarget = NULL;
704 iBool isTargetChanged = iFalse; 705 iBool isTargetChanged = iFalse;
706 iAssert(isExposed_Window(get_Window()));
705 /* We'll flush the buffered rasters periodically until everything is cached. */ 707 /* We'll flush the buffered rasters periodically until everything is cached. */
706 while (chPos < text.end) { 708 while (chPos < text.end) {
707 while (chPos < text.end) { 709 while (chPos < text.end) {
@@ -1017,7 +1019,7 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1017 int x1 = iMax(xpos, xposExtend); 1019 int x1 = iMax(xpos, xposExtend);
1018 /* Which half of the pixel the glyph falls on? */ 1020 /* Which half of the pixel the glyph falls on? */
1019 const int hoff = enableHalfPixelGlyphs_Text ? (xpos - x1 > 0.5f ? 1 : 0) : 0; 1021 const int hoff = enableHalfPixelGlyphs_Text ? (xpos - x1 > 0.5f ? 1 : 0) : 0;
1020 if (!isRasterized_Glyph_(glyph, hoff)) { 1022 if (mode & draw_RunMode && !isRasterized_Glyph_(glyph, hoff)) {
1021 /* Need to pause here and make sure all glyphs have been cached in the text. */ 1023 /* Need to pause here and make sure all glyphs have been cached in the text. */
1022 cacheTextGlyphs_Font_(d, args->text); 1024 cacheTextGlyphs_Font_(d, args->text);
1023 glyph = glyph_Font_(d, ch); /* cache may have been reset */ 1025 glyph = glyph_Font_(d, ch); /* cache may have been reset */