Commit MetaInfo

Revision864bb714f2dfb73e5061076b38525a4cd5522d24 (tree)
Time2017-07-28 21:25:10
Author <exeal@user...>

Log Message

Enhanced text painting efficiency.

Change Summary

Incremental Difference

diff -r 5241c3d8e8d5 -r 864bb714f2df ascension/src/graphics/font/text-renderer.cpp
--- a/ascension/src/graphics/font/text-renderer.cpp Fri Jul 28 21:23:24 2017 +0900
+++ b/ascension/src/graphics/font/text-renderer.cpp Fri Jul 28 21:25:10 2017 +0900
@@ -339,8 +339,9 @@
339339 */
340340 void TextRenderer::paint(PaintContext& context, const TextViewport& viewport, const LineRenderingOptions* options /* = nullptr */) const {
341341 // scan lines in the text area
342- const bool horizontal = presentation::isHorizontal(blockFlowDirection());
343- const auto bpdRange(horizontal ? geometry::range<1>(context.boundsToPaint()) : geometry::range<0>(context.boundsToPaint()));
342+ presentation::FlowRelativeFourSides<graphics::Scalar> abstractBoundsToPaint;
343+ presentation::mapDimensions(writingModes(), presentation::_from = graphics::PhysicalFourSides<graphics::Scalar>(context.boundsToPaint()), presentation::_to = abstractBoundsToPaint);
344+ const auto bpdRange(presentation::blockFlowRange(abstractBoundsToPaint));
344345 struct LineToPaint {
345346 Index lineNumber;
346347 graphics::Scalar baseline;
@@ -355,7 +356,6 @@
355356 for(Index logicalLine; baseline != lastBaseline; ++baseline) {
356357 assert(baseline.line() != boost::none);
357358 logicalLine = boost::get(baseline.line()).line;
358- const TextLayout& layout = const_cast<LineLayoutVector&>(layouts()).at(logicalLine, LineLayoutVector::USE_CALCULATED_LAYOUT);
359359 if(overlaps(baseline.extentWithHalfLeadings(), bpdRange)) { // this logical line should be painted
360360 LineToPaint lineToPaint;
361361 lineToPaint.lineNumber = logicalLine;
@@ -367,13 +367,15 @@
367367 --i;
368368 lineToPaint.baseline = *i;
369369 }
370+ const TextLayout& layout = const_cast<LineLayoutVector&>(layouts()).at(logicalLine, LineLayoutVector::USE_CALCULATED_LAYOUT);
370371 lineToPaint.extent = layout.extentWithHalfLeadings();
371372 lineToPaint.extent.advance_begin(lineToPaint.baseline);
372373 lineToPaint.extent.advance_end(lineToPaint.baseline);
373374 linesToPaint.push_back(lineToPaint);
374375 if(boost::get(baseline.line()).subline < layout.numberOfLines() - 1)
375376 std::advance(baseline, layout.numberOfLines() - 1 - boost::get(baseline.line()).subline); // skip to the next logical line
376- }
377+ } else if(*boost::const_end(baseline.extentWithHalfLeadings()) >= *boost::const_end(bpdRange))
378+ break;
377379 }
378380
379381 // paint background outside of the lines
diff -r 5241c3d8e8d5 -r 864bb714f2df ascension/src/viewer/text-area.cpp
--- a/ascension/src/viewer/text-area.cpp Fri Jul 28 21:23:24 2017 +0900
+++ b/ascension/src/viewer/text-area.cpp Fri Jul 28 21:25:10 2017 +0900
@@ -923,8 +923,10 @@
923923 SignedIndex sublinesDifference, bool documentChanged, bool longestLineChanged) BOOST_NOEXCEPT {
924924 boost::optional<Index> firstLineToDraw;
925925 if(sublinesDifference == 0) { // number of visual lines was not changed
926- ASCENSION_REDRAW_TEXT_AREA_LINES(lines);
927- redrawIfNotFrozen(*this);
926+ if(boost::size(lines) > 1 || textRenderer()->layouts().at(lines.front()) != nullptr) {
927+ ASCENSION_REDRAW_TEXT_AREA_LINES(lines);
928+ redrawIfNotFrozen(*this);
929+ }
928930 } else {
929931 boost::optional<Index> firstLineToDraw;
930932 if(*boost::const_end(lines) < viewport()->firstVisibleLine().line) { // changed before visible area
Show on old repository browser