mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Speed-up drawing when text is not justified.
Do not cut strings at separators in RowPainter when text is not justified. This speeds-up painting by reducing the number of strings to draw. Do also a modest cleanup of paintChar (remove dubious optimization).
This commit is contained in:
parent
3013ce3716
commit
7734270163
@ -40,17 +40,17 @@ What is done:
|
|||||||
useless workarounds which disable kerning and ligatures.
|
useless workarounds which disable kerning and ligatures.
|
||||||
|
|
||||||
* when lyxrc.force_paint_single_char is false, draw also RtL text
|
* when lyxrc.force_paint_single_char is false, draw also RtL text
|
||||||
string-wise. This both speed-up drawing and prepare for code
|
string-wise. This both speeds-up drawing and prepares for code
|
||||||
removal, since we now rely on Qt to do things we use to do by
|
removal, since we now rely on Qt to do things we use to do by
|
||||||
ourselves (see isArabic* and isHebrew* code in Encodings.cpp).
|
ourselves (see isArabic* and isHebrew* code in Encodings.cpp).
|
||||||
|
|
||||||
|
* Do not cut strings at separators in RowPainter when text is not
|
||||||
|
justified. This speeds-up painting by reducing the number of strings
|
||||||
|
to draw.
|
||||||
|
|
||||||
|
|
||||||
Next steps:
|
Next steps:
|
||||||
|
|
||||||
* investigate whether strings could be cut at separators in RowPainter
|
|
||||||
only in justified text. This would speed-up painting in other cases
|
|
||||||
by lowering the number of strings to draw.
|
|
||||||
|
|
||||||
* get lots of testing.
|
* get lots of testing.
|
||||||
|
|
||||||
* Get rid of old code in cursorX and getPosNearX; it has been
|
* Get rid of old code in cursorX and getPosNearX; it has been
|
||||||
|
@ -165,10 +165,9 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font)
|
|||||||
// This method takes up 70% of time when typing
|
// This method takes up 70% of time when typing
|
||||||
pos_type pos = bidi_.vis2log(vpos);
|
pos_type pos = bidi_.vis2log(vpos);
|
||||||
// first character
|
// first character
|
||||||
char_type prev_char = par_.getChar(pos);
|
char_type c = par_.getChar(pos);
|
||||||
vector<char_type> str;
|
docstring str;
|
||||||
str.reserve(100);
|
str.reserve(100);
|
||||||
str.push_back(prev_char);
|
|
||||||
|
|
||||||
// special case for arabic
|
// special case for arabic
|
||||||
string const & lang = font.language()->lang();
|
string const & lang = font.language()->lang();
|
||||||
@ -179,13 +178,12 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font)
|
|||||||
// FIXME: Why only round brackets and why the difference to
|
// FIXME: Why only round brackets and why the difference to
|
||||||
// Hebrew? See also Paragraph::getUChar
|
// Hebrew? See also Paragraph::getUChar
|
||||||
if (swap_paren) {
|
if (swap_paren) {
|
||||||
char_type c = str[0];
|
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
c = ')';
|
c = ')';
|
||||||
else if (c == ')')
|
else if (c == ')')
|
||||||
c = '(';
|
c = '(';
|
||||||
str[0] = c;
|
|
||||||
}
|
}
|
||||||
|
str.push_back(c);
|
||||||
|
|
||||||
pos_type const end = row_.endpos();
|
pos_type const end = row_.endpos();
|
||||||
FontSpan const font_span = par_.fontSpan(pos);
|
FontSpan const font_span = par_.fontSpan(pos);
|
||||||
@ -230,7 +228,8 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font)
|
|||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!isPrintableNonspace(c))
|
if (!isPrintableNonspace(c)
|
||||||
|
&& (c != ' ' || row_.separator > 0))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// FIXME: Why only round brackets and why the difference to
|
// FIXME: Why only round brackets and why the difference to
|
||||||
@ -243,13 +242,10 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font)
|
|||||||
}
|
}
|
||||||
|
|
||||||
str.push_back(c);
|
str.push_back(c);
|
||||||
prev_char = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
docstring s(&str[0], str.size());
|
if (str[0] == '\t')
|
||||||
|
str.replace(0,1,from_ascii(" "));
|
||||||
if (s[0] == '\t')
|
|
||||||
s.replace(0,1,from_ascii(" "));
|
|
||||||
|
|
||||||
/* Because we do our own bidi, at this point the strings are
|
/* Because we do our own bidi, at this point the strings are
|
||||||
* already in visual order. However, Qt also applies its own
|
* already in visual order. However, Qt also applies its own
|
||||||
@ -267,13 +263,13 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font)
|
|||||||
// Pop directional formatting: return to previous state
|
// Pop directional formatting: return to previous state
|
||||||
char_type const PDF = 0x202C;
|
char_type const PDF = 0x202C;
|
||||||
if (font.isVisibleRightToLeft()) {
|
if (font.isVisibleRightToLeft()) {
|
||||||
reverse(s.begin(), s.end());
|
reverse(str.begin(), str.end());
|
||||||
s = RLO + s + PDF;
|
str = RLO + str + PDF;
|
||||||
} else
|
} else
|
||||||
s = LRO + s + PDF;
|
str = LRO + str + PDF;
|
||||||
|
|
||||||
if (!selection && !change_running.changed()) {
|
if (!selection && !change_running.changed()) {
|
||||||
x_ += pi_.pain.text(int(x_), yo_, s, font.fontInfo());
|
x_ += pi_.pain.text(int(x_), yo_, str, font.fontInfo());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +279,7 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font)
|
|||||||
else if (selection)
|
else if (selection)
|
||||||
copy.setPaintColor(Color_selectiontext);
|
copy.setPaintColor(Color_selectiontext);
|
||||||
|
|
||||||
x_ += pi_.pain.text(int(x_), yo_, s, copy);
|
x_ += pi_.pain.text(int(x_), yo_, str, copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user