]> git.lyx.org Git - features.git/commitdiff
Remove row crc computation
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 11 Nov 2017 11:40:39 +0000 (12:40 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 15 Feb 2018 11:29:25 +0000 (12:29 +0100)
This computation did not make sense anymore since we began to put the
contents in the Row object. The fact that it worked was a coincidence.

Instead, we set rows as changed() on creation and reset that once they
have been drawn. This will allow in the future for a finer definition
of what to redraw or not.

Also update the PAINTING_ANALYSIS document

(cherry picked from commit 9e2da4a3eac83f46ab184ea8d674f84643814017)

development/PAINTING_ANALYSIS
src/ParagraphMetrics.cpp
src/ParagraphMetrics.h
src/Row.cpp
src/Row.h
src/TextMetrics.cpp

index ec3566e06cd3d3982d857a4b364026f19c337d05..32bc93a5ff94169747bb454efeae3c96f9571b34 100644 (file)
@@ -60,6 +60,42 @@ cursor.
 
 * Clean-up of drawing code
 
+** Make SinglePar update flag useful again. 
+
+The current code can be very expensive when moving cursor inside a
+huge table, for example. We should test the flag again, although this
+will probably lead to some glitches here and there.
+
+** Set Row::changed() in a finer way
+
+*** singleParUpdate
+
+When the height of the current paragraph changes, there is no need for
+a full screen update. Only the rows after the current one need to have
+their position recomputed.
+
+This is also true when scrolling (how to do that?)
+
+*** redoParagraph
+
+It should be possible to check whether the new row is the same as the
+old one and keep its changed() status in this case. This would reduce
+a lot the amount of stuff to redraw.
+
+** Put labels and friends in the Row as elements
+
+It should not be necessary to access the Paragraph object to draw.
+Adding the static elements to Row is a lot of work, but worth it IMO.
+
+** Create a unique row by paragraph and break it afterwards
+
+This should be a performance gain (only if paragraph breaking still
+shows as expensive after the rest is done)
+
+** do not add the vertical margin of main text to first/last row
+
+Would make code cleaner. Probably no so difficult.
+
 ** When a paragraph ends with a newline, compute correctly the height of the extra row.
 ** Merging bv::updateMetrics and tm::metrics
 
index 01db6cb934b0be5c019ab2998300e84b5b56178a..1d3ce0db5cfe196c718e632629dffa21f7276265 100644 (file)
@@ -47,8 +47,6 @@
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
-#include <boost/crc.hpp>
-
 #include <algorithm>
 #include <list>
 #include <stack>
@@ -84,42 +82,6 @@ void ParagraphMetrics::reset(Paragraph const & par)
 }
 
 
-size_t ParagraphMetrics::computeRowSignature(Row const & row,
-               BufferView const & bv) const
-{
-       boost::crc_32_type crc;
-       for (pos_type i = row.pos(); i < row.endpos(); ++i) {
-               if (par_->isInset(i)) {
-                       Inset const * in = par_->getInset(i);
-                       Dimension const d = in->dimension(bv);
-                       int const b[] = { d.wid, d.asc, d.des };
-                       crc.process_bytes(b, sizeof(b));
-               } else {
-                       char_type const b[] = { par_->getChar(i) };
-                       crc.process_bytes(b, sizeof(char_type));
-               }
-               if (bv.buffer().params().track_changes) {
-                       Change change = par_->lookupChange(i);
-                       char_type const b[] = { static_cast<char_type>(change.type) };
-                       // 1 byte is enough to encode Change::Type
-                       crc.process_bytes(b, 1);
-               }
-       }
-
-       pos_type const b1[] = { row.sel_beg, row.sel_end };
-       crc.process_bytes(b1, sizeof(b1));
-
-       Dimension const & d = row.dimension();
-       int const b2[] = { row.begin_margin_sel,
-                          row.end_margin_sel,
-                          d.wid, d.asc, d.des };
-       crc.process_bytes(b2, sizeof(b2));
-       crc.process_bytes(&row.separator, sizeof(row.separator));
-
-       return crc.checksum();
-}
-
-
 void ParagraphMetrics::setPosition(int position)
 {
        position_ = position;
index 55304fd9ed2b7397108ea84ad52507a96b9f9acb..63ed0f3cdf689bc6aecf3459c6430b065c228f2c 100644 (file)
@@ -85,9 +85,6 @@ public:
        ///
        bool hfillExpansion(Row const & row, pos_type pos) const;
 
-       ///
-       size_t computeRowSignature(Row const &, BufferView const & bv) const;
-
        ///
        int position() const { return position_; }
        void setPosition(int position);
index 20ff63e22a41463ddd65efa4dc261cb8a9fb89d1..ad492c1a7a53fcd2554b436ffadc5109e82011d1 100644 (file)
@@ -162,20 +162,13 @@ Row::Row()
        : separator(0), label_hfill(0), left_margin(0), right_margin(0),
          sel_beg(-1), sel_end(-1),
          begin_margin_sel(false), end_margin_sel(false),
-         changed_(false), crc_(0),
+         changed_(true),
          pit_(0), pos_(0), end_(0),
          right_boundary_(false), flushed_(false), rtl_(false),
          changebar_(false)
 {}
 
 
-void Row::setCrc(size_type crc) const
-{
-       changed_ = crc != crc_;
-       crc_ = crc;
-}
-
-
 bool Row::isMarginSelected(bool left_margin, DocIterator const & beg,
                DocIterator const & end) const
 {
index a2e77fbfb4b61b6336aa09c0c04eb4c9bb748059..a1fedd7e5da97d043f8e55936aa8e942903af27e 100644 (file)
--- a/src/Row.h
+++ b/src/Row.h
@@ -139,9 +139,7 @@ public:
        ///
        bool changed() const { return changed_; }
        ///
-       void setChanged(bool c) { changed_ = c; }
-       ///
-       void setCrc(size_type crc) const;
+       void changed(bool c) const { changed_ = c; }
        /// Set the selection begin and end.
        /**
          * This is const because we update the selection status only at draw()
@@ -315,8 +313,6 @@ private:
 
        /// has the Row appearance changed since last drawing?
        mutable bool changed_;
-       /// CRC of row contents.
-       mutable size_type crc_;
        /// Index of the paragraph that contains this row
        pit_type pit_;
        /// first pos covered by this row
index cd33f7f190e44996f065f1c24aa751ce01c6581b..1f4516f1afa436196cc650cfe712a469e569beae 100644 (file)
@@ -468,7 +468,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                row.pit(pit);
                need_new_row = breakRow(row, right_margin);
                setRowHeight(row);
-               row.setChanged(false);
+               row.changed(true);
                if (row_index || row.endpos() < par.size()
                    || (row.right_boundary() && par.inInset().lyxCode() != CELL_CODE)) {
                        /* If there is more than one row or the row has been
@@ -1888,8 +1888,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                                row.end_margin_sel = sel_end.pit() > pit;
                }
 
-               // Row signature; has row changed since last paint?
-               row.setCrc(pm.computeRowSignature(row, *bv_));
+               // has row changed since last paint?
                bool row_has_changed = row.changed()
                        || bv_->hadHorizScrollOffset(text_, pit, row.pos())
                        || bv_->needRepaint(text_, row);
@@ -1907,6 +1906,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                        // Paint only the insets if the text itself is
                        // unchanged.
                        rp.paintOnlyInsets();
+                       row.changed(false);
                        y += row.descent();
                        continue;
                }
@@ -1958,6 +1958,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
 
                // Restore full_repaint status.
                pi.full_repaint = tmp;
+
+               row.changed(false);
        }
 
        //LYXERR(Debug::PAINTING, ".");