]> git.lyx.org Git - features.git/commitdiff
* local_bidi.patch: The bidi object in the class Text is only used in
authorStefan Schimanski <sts@lyx.org>
Thu, 7 Jun 2007 20:39:14 +0000 (20:39 +0000)
committerStefan Schimanski <sts@lyx.org>
Thu, 7 Jun 2007 20:39:14 +0000 (20:39 +0000)
places now where a ParagraphMetrics::computeRowMetrics call comes
before. And this function the Bidi object is updated. So it is a
little step now to remove the Text::bidi completely and use local
Bidi objects instead without more work to do.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18706 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text.cpp
src/Text.h
src/TextMetrics.cpp
src/rowpainter.cpp

index 444c46ff98fcead47bccf51091d9f3194737a2f9..517f05384ae2e24d9775c6ed3a8116d47b566335 100644 (file)
@@ -1695,6 +1695,8 @@ int Text::cursorX(BufferView const & bv, CursorSlice const & sl,
        Buffer const & buffer = *bv.buffer();
        RowMetrics const m = tm.computeRowMetrics(pit, row);
        double x = m.x;
+       Bidi bidi;
+       bidi.computeTables(par, buffer, row);
 
        pos_type const row_pos  = row.pos();
        pos_type const end      = row.endpos();
index 503bdee356eed8a2d25706162d9ca781082f1442..5ab0864d7f9f7831116124210e058cded51ec039 100644 (file)
@@ -378,8 +378,6 @@ public:
        ///
        int background_color_;
 
-       ///
-       mutable Bidi bidi;
        ///
        ParagraphList pars_;
 
index 6f3d6a300c17e32d53b1924164b8cfb3581328d7..405c6ca88a234f90d4ffdcd74279a8a912cdd163 100644 (file)
@@ -375,7 +375,6 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit,
                }
        }
 
-       text_->bidi.computeTables(par, buffer, row);
        if (is_rtl) {
                pos_type body_pos = par.beginOfBody();
                pos_type end = row.endpos();
@@ -812,6 +811,8 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
        x -= xo;
        RowMetrics const r = computeRowMetrics(pit, row);
        Paragraph const & par = text_->getPar(pit);
+       Bidi bidi;
+       bidi.computeTables(par, buffer, row);
 
        pos_type vc = row.pos();
        pos_type end = row.endpos();
@@ -839,7 +840,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
                = theFontMetrics(text_->getLabelFont(buffer, par));
 
        while (vc < end && tmpx <= x) {
-               c = text_->bidi.vis2log(vc);
+               c = bidi.vis2log(vc);
                last_tmpx = tmpx;
                if (body_pos > 0 && c == body_pos - 1) {
                        // FIXME UNICODE
@@ -885,12 +886,12 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
             (!rtl && !left_side && vc == end  && x > tmpx + 5)))
                c = end;
        else if (vc == row.pos()) {
-               c = text_->bidi.vis2log(vc);
-               if (text_->bidi.level(c) % 2 == 1)
+               c = bidi.vis2log(vc);
+               if (bidi.level(c) % 2 == 1)
                        ++c;
        } else {
-               c = text_->bidi.vis2log(vc - 1);
-               bool const rtl = (text_->bidi.level(c) % 2 == 1);
+               c = bidi.vis2log(vc - 1);
+               bool const rtl = (bidi.level(c) % 2 == 1);
                if (left_side == rtl) {
                        ++c;
                        boundary = text_->isRTLBoundary(buffer, par, c);
@@ -906,7 +907,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
        // specially, so cursor up/down doesn't get stuck in an air gap -- MV
        // Newline inset, air gap below:
        if (row.pos() < end && c >= end && par.isNewline(end - 1)) {
-               if (text_->bidi.level(end -1) % 2 == 0)
+               if (bidi.level(end -1) % 2 == 0)
                        tmpx -= text_->singleWidth(buffer, par, end - 1);
                else
                        tmpx += text_->singleWidth(buffer, par, end - 1);
index 8f4d19599c4d42f0a407c52bfc5a20f25aecad57..a949f4d4df2a9c53051787eaaf0f9eecd1b7335f 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "rowpainter.h"
 
+#include "Bidi.h"
 #include "Buffer.h"
 #include "CoordCache.h"
 #include "Cursor.h"
@@ -113,6 +114,10 @@ private:
        ParagraphMetrics const & pm_;
        int max_width_;
 
+       /// bidi cache, static to speed up rowpaint and reduce size. 
+       /// Only one rowpainter is used at a time anyway
+       static Bidi bidi_;
+
        /// is row erased? (change tracking)
        bool erased_;
 
@@ -127,6 +132,9 @@ private:
 };
 
 
+Bidi RowPainter::bidi_;
+
+
 RowPainter::RowPainter(PainterInfo & pi,
        Text const & text, pit_type pit, Row const & row, int x, int y)
        : bv_(*pi.base.bv), pain_(pi.pain), text_(text),
@@ -135,10 +143,11 @@ RowPainter::RowPainter(PainterInfo & pi,
          row_(row), pit_(pit), par_(text.paragraphs()[pit]),
          pm_(text_metrics_.parMetrics(pit)),
          max_width_(bv_.workWidth()),
-         erased_(pi.erased_),
+               erased_(pi.erased_),
          xo_(x), yo_(y), width_(text_metrics_.width())
 {
        RowMetrics m = text_metrics_.computeRowMetrics(pit_, row_);
+       bidi_.computeTables(par_, *bv_.buffer(), row_);
        x_ = m.x + xo_;
 
        //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
@@ -180,7 +189,7 @@ void RowPainter::paintInset(pos_type const pos, Font const & font)
        pi.base.font = inset->noFontChange() ?
                bv_.buffer()->params().getFont() :
                font;
-       pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
+       pi.ltr_pos = (bidi_.level(pos) % 2 == 0);
        pi.erased_ = erased_ || par_.isDeleted(pos);
 #ifdef DEBUG_METRICS
        int const x1 = int(x_);
@@ -233,7 +242,7 @@ void RowPainter::paintInset(pos_type const pos, Font const & font)
 
 void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
 {
-       pos_type pos = text_.bidi.vis2log(vpos);
+       pos_type pos = bidi_.vis2log(vpos);
 
        docstring str;
 
@@ -267,7 +276,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
 
 void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
 {
-       pos_type pos = text_.bidi.vis2log(vpos);
+       pos_type pos = bidi_.vis2log(vpos);
        docstring str;
 
        // first char
@@ -299,7 +308,7 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font,
                            bool hebrew, bool arabic)
 {
        // This method takes up 70% of time when typing
-       pos_type pos = text_.bidi.vis2log(vpos);
+       pos_type pos = bidi_.vis2log(vpos);
        pos_type const end = row_.endpos();
        FontSpan const font_span = par_.fontSpan(pos);
        Change::Type const prev_change = par_.lookupChange(pos).type;
@@ -320,7 +329,7 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font,
 
        // collect as much similar chars as we can
        for (++vpos ; vpos < end ; ++vpos) {
-               pos = text_.bidi.vis2log(vpos);
+               pos = bidi_.vis2log(vpos);
                if (pos < font_span.first || pos > font_span.last)
                        break;
 
@@ -403,7 +412,7 @@ void RowPainter::paintForeignMark(double orig_x, Font const & font, int desc)
 
 void RowPainter::paintFromPos(pos_type & vpos)
 {
-       pos_type const pos = text_.bidi.vis2log(vpos);
+       pos_type const pos = bidi_.vis2log(vpos);
        Font orig_font = text_.getFont(*bv_.buffer(), par_, pos);
 
        double const orig_x = x_;
@@ -747,7 +756,7 @@ void RowPainter::paintText()
                if (x_ > bv_.workWidth())
                        break;
 
-               pos_type const pos = text_.bidi.vis2log(vpos);
+               pos_type const pos = bidi_.vis2log(vpos);
 
                if (pos >= par_.size()) {
                        ++vpos;