aboutsummaryrefslogtreecommitdiffstats
path: root/src/composite.c
diff options
context:
space:
mode:
authorRobert Pluim2020-01-24 14:11:44 +0100
committerRobert Pluim2020-03-02 09:59:34 +0100
commitfe1a447d52f548441d19af580ed11ef56d4459d2 (patch)
treebaa0419db5d8a8b7605c80b55cefe6fbefc0d7f6 /src/composite.c
parentb42b894d1def7180ab715615116fe6af65b76bd8 (diff)
downloademacs-fe1a447d52f548441d19af580ed11ef56d4459d2.tar.gz
emacs-fe1a447d52f548441d19af580ed11ef56d4459d2.zip
Don't attempt to cache glyph metrics for FONT_INVALID_CODE
This was causing massive slowdown in redisplay when eg #xfe0f (VARIATION SELECTOR-16) was present, as the cache ended up very large, unused, and being recreated on every call to font_fill_lglyph_metrics (Bug#39133). * src/composite.c (fill_gstring_body): Hoist FONT_OBJECT_P check out of loop. Calculate glyph code and check for FONT_INVALID_CODE before calling font_fill_lglyph_metrics. Pass glyph code to it. * src/font.c (font_fill_lglyph_metrics): Add code parameter, move glyph code calculation up the call stack into fill_gstring_body. * src/font.h: Adjust font_fill_lglyph_metrics prototype.
Diffstat (limited to 'src/composite.c')
-rw-r--r--src/composite.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/composite.c b/src/composite.c
index 53e6930b5f2..364d5c9316e 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -818,6 +818,11 @@ fill_gstring_body (Lisp_Object gstring)
818 Lisp_Object header = AREF (gstring, 0); 818 Lisp_Object header = AREF (gstring, 0);
819 ptrdiff_t len = LGSTRING_CHAR_LEN (gstring); 819 ptrdiff_t len = LGSTRING_CHAR_LEN (gstring);
820 ptrdiff_t i; 820 ptrdiff_t i;
821 struct font *font = NULL;
822 unsigned int code;
823
824 if (FONT_OBJECT_P (font_object))
825 font = XFONT_OBJECT (font_object);
821 826
822 for (i = 0; i < len; i++) 827 for (i = 0; i < len; i++)
823 { 828 {
@@ -832,10 +837,15 @@ fill_gstring_body (Lisp_Object gstring)
832 LGLYPH_SET_FROM (g, i); 837 LGLYPH_SET_FROM (g, i);
833 LGLYPH_SET_TO (g, i); 838 LGLYPH_SET_TO (g, i);
834 LGLYPH_SET_CHAR (g, c); 839 LGLYPH_SET_CHAR (g, c);
835 if (FONT_OBJECT_P (font_object)) 840
836 { 841 if (font != NULL)
837 font_fill_lglyph_metrics (g, font_object); 842 code = font->driver->encode_char (font, LGLYPH_CHAR (g));
838 } 843 else
844 code = FONT_INVALID_CODE;
845 if (code != FONT_INVALID_CODE)
846 {
847 font_fill_lglyph_metrics (g, font, code);
848 }
839 else 849 else
840 { 850 {
841 int width = XFIXNAT (CHAR_TABLE_REF (Vchar_width_table, c)); 851 int width = XFIXNAT (CHAR_TABLE_REF (Vchar_width_table, c));