[LyX features/str-metrics] Revert optimization where several words are drawn at the same time

2014-07-20 Thread Jean-Marc Lasgouttes
The branch, str-metrics, has been updated.

- Log -

commit bbe6e9f593fc585ee9f5d69275487bf3ddbcaf47
Author: Jean-Marc Lasgouttes lasgout...@lyx.org
Date:   Sun Jul 20 18:54:31 2014 +0200

Revert optimization where several words are drawn at the same time

This can only be done where splitting of string is identical in row 
breaking and display. It will be possible to reintroduce this when row painting 
uses the tokenized row information.

diff --git a/00README_STR_METRICS_BRANCH b/00README_STR_METRICS_BRANCH
index e901b51..342d2f6 100644
--- a/00README_STR_METRICS_BRANCH
+++ b/00README_STR_METRICS_BRANCH
@@ -39,10 +39,6 @@ What is done:
 
 * Draw also RtL text string-wise. This speeds-up drawing.
 
-* 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 not cut strings at selection boundary in RowPainter. This avoids
   ligature/kerning breaking in latin text, and bad rendering problems
   in Arabic.
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 4dde5fd..45a5007 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -565,7 +565,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
 
Paragraph const  par = text_-getPar(pit);
 
-   double w = width - row.right_margin - row.width();
+   double const w = width - row.right_margin - row.width();
// FIXME: put back this assertion when the crash on new doc is solved.
//LASSERT(w = 0, /**/);
 
@@ -607,9 +607,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
} else if (int(row.width())  max_width_) {
// is it block, flushleft or flushright?
// set x how you need it
-   int const align = getAlign(par, row.pos());
-
-   switch (align) {
+   switch (getAlign(par, row.pos())) {
case LYX_ALIGN_BLOCK: {
int const ns = numberOfSeparators(row);
/** If we have separators, and this row has
@@ -650,12 +648,12 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
}
 #endif
 
+   // Finally,  handle hfill insets
pos_type const endpos = row.endpos();
pos_type body_pos = par.beginOfBody();
if (body_pos  0
 (body_pos  endpos || !par.isLineSeparator(body_pos - 1)))
body_pos = 0;
-
ParagraphMetrics  pm = par_metrics_[pit];
Row::iterator cit = row.begin();
Row::iterator const cend = row.end();
@@ -798,8 +796,7 @@ void TextMetrics::breakRow(Row  row, int const 
right_margin, pit_type const pit
int const width = max_width_ - right_margin;
pos_type const body_pos = par.beginOfBody();
row.clear();
-   row.x = leftMargin(max_width_, pit, pos);
-   row.dimension().wid = row.x;
+   row.dimension().wid = leftMargin(max_width_, pit, pos);
row.right_margin = right_margin;
 
if (pos = end || row.width()  width) {
diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index a33aebf..2b51f47 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -273,14 +273,14 @@ void GuiPainter::image(int x, int y, int w, int h, 
graphics::Image const  i)
 
 int GuiPainter::text(int x, int y, char_type c, FontInfo const  f)
 {
-   docstring s(1, c);
-   return text(x, y, s, f);
+   return text(x, y, docstring(1, c), f);
 }
 
 
 int GuiPainter::text(int x, int y, docstring const  s,
FontInfo const  f)
 {
+   //LYXERR0(text: x=  x  , s=  s);
if (s.empty())
return 0;
 
diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp
index ee4cd18..8c8ac4c 100644
--- a/src/rowpainter.cpp
+++ b/src/rowpainter.cpp
@@ -186,16 +186,15 @@ void RowPainter::paintChars(pos_type  vpos, Font const  
font)
}
str.push_back(c);
 
-   pos_type const end = row_.endpos();
FontSpan const font_span = par_.fontSpan(pos);
// Track-change status.
Change const  change_running = par_.lookupChange(pos);
-
// spelling correct?
bool const spell_state =
lyxrc.spellcheck_continuously  par_.isMisspelled(pos);
 
// collect as much similar chars as we can
+   pos_type const end = row_.endpos();
for (++vpos ; vpos  end ; ++vpos) {
pos = bidi_.vis2log(vpos);
 
@@ -218,11 +217,7 @@ void RowPainter::paintChars(pos_type  vpos, Font const  
font)
if (c == '\t')
break;
 
-   // When row_.separator == 0, it is possible to print a
-   // string longer than a word in one fell swoop.
-   // Therefore there is no need to break at spaces.
-   if (!isPrintableNonspace(c)
-(c != ' ' || row_.separator  0))
+   

[LyX features/str-metrics] Revert optimization where several words are drawn at the same time

2014-07-20 Thread Jean-Marc Lasgouttes
The branch, str-metrics, has been updated.

- Log -

commit bbe6e9f593fc585ee9f5d69275487bf3ddbcaf47
Author: Jean-Marc Lasgouttes 
Date:   Sun Jul 20 18:54:31 2014 +0200

Revert optimization where several words are drawn at the same time

This can only be done where splitting of string is identical in row 
breaking and display. It will be possible to reintroduce this when row painting 
uses the tokenized row information.

diff --git a/00README_STR_METRICS_BRANCH b/00README_STR_METRICS_BRANCH
index e901b51..342d2f6 100644
--- a/00README_STR_METRICS_BRANCH
+++ b/00README_STR_METRICS_BRANCH
@@ -39,10 +39,6 @@ What is done:
 
 * Draw also RtL text string-wise. This speeds-up drawing.
 
-* 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 not cut strings at selection boundary in RowPainter. This avoids
   ligature/kerning breaking in latin text, and bad rendering problems
   in Arabic.
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 4dde5fd..45a5007 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -565,7 +565,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
 
Paragraph const & par = text_->getPar(pit);
 
-   double w = width - row.right_margin - row.width();
+   double const w = width - row.right_margin - row.width();
// FIXME: put back this assertion when the crash on new doc is solved.
//LASSERT(w >= 0, /**/);
 
@@ -607,9 +607,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
} else if (int(row.width()) < max_width_) {
// is it block, flushleft or flushright?
// set x how you need it
-   int const align = getAlign(par, row.pos());
-
-   switch (align) {
+   switch (getAlign(par, row.pos())) {
case LYX_ALIGN_BLOCK: {
int const ns = numberOfSeparators(row);
/** If we have separators, and this row has
@@ -650,12 +648,12 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
}
 #endif
 
+   // Finally,  handle hfill insets
pos_type const endpos = row.endpos();
pos_type body_pos = par.beginOfBody();
if (body_pos > 0
&& (body_pos > endpos || !par.isLineSeparator(body_pos - 1)))
body_pos = 0;
-
ParagraphMetrics & pm = par_metrics_[pit];
Row::iterator cit = row.begin();
Row::iterator const cend = row.end();
@@ -798,8 +796,7 @@ void TextMetrics::breakRow(Row & row, int const 
right_margin, pit_type const pit
int const width = max_width_ - right_margin;
pos_type const body_pos = par.beginOfBody();
row.clear();
-   row.x = leftMargin(max_width_, pit, pos);
-   row.dimension().wid = row.x;
+   row.dimension().wid = leftMargin(max_width_, pit, pos);
row.right_margin = right_margin;
 
if (pos >= end || row.width() > width) {
diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp
index a33aebf..2b51f47 100644
--- a/src/frontends/qt4/GuiPainter.cpp
+++ b/src/frontends/qt4/GuiPainter.cpp
@@ -273,14 +273,14 @@ void GuiPainter::image(int x, int y, int w, int h, 
graphics::Image const & i)
 
 int GuiPainter::text(int x, int y, char_type c, FontInfo const & f)
 {
-   docstring s(1, c);
-   return text(x, y, s, f);
+   return text(x, y, docstring(1, c), f);
 }
 
 
 int GuiPainter::text(int x, int y, docstring const & s,
FontInfo const & f)
 {
+   //LYXERR0("text: x=" << x << ", s=" << s);
if (s.empty())
return 0;
 
diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp
index ee4cd18..8c8ac4c 100644
--- a/src/rowpainter.cpp
+++ b/src/rowpainter.cpp
@@ -186,16 +186,15 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
}
str.push_back(c);
 
-   pos_type const end = row_.endpos();
FontSpan const font_span = par_.fontSpan(pos);
// Track-change status.
Change const & change_running = par_.lookupChange(pos);
-
// spelling correct?
bool const spell_state =
lyxrc.spellcheck_continuously && par_.isMisspelled(pos);
 
// collect as much similar chars as we can
+   pos_type const end = row_.endpos();
for (++vpos ; vpos < end ; ++vpos) {
pos = bidi_.vis2log(vpos);
 
@@ -218,11 +217,7 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
if (c == '\t')
break;
 
-   // When row_.separator == 0, it is possible to print a
-   // string longer than a word in one fell swoop.
-   // Therefore there is no need to break at spaces.
-   if (!isPrintableNonspace(c)
-   && (c !=