summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-02-08 11:53:06 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-02-08 11:53:06 +0200
commit1d978ce9fafd2658121a48288a6ddf16cfccecc6 (patch)
tree2b92ee234344d5f69d7458236eeae443c325d79c /src/ui
parent84c25733fc847e9488579834d86c1d41a48c89ce (diff)
DocumentWidget: Fixed continuous redraw issue
It was possible that the progressive rendering of runs repeatedly kept drawing the first run of the page (e.g., the top heading). It should still be investigated if a similar issue can occur in the other direction, when drawing downward. A run may exist on the bottom border of a buffer, too.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 7a1cdabc..dbe29c4e 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1656,7 +1656,6 @@ static iBool render_DocumentView_(const iDocumentView *d, iDrawContext *ctx, iBo
1656 ctx->viewPos = init_I2(left_Rect(ctx->docBounds) - left_Rect(bounds), -buf->origin); 1656 ctx->viewPos = init_I2(left_Rect(ctx->docBounds) - left_Rect(bounds), -buf->origin);
1657 // printf(" buffer %zu: buf vis range %d...%d\n", i, bufVisRange.start, bufVisRange.end); 1657 // printf(" buffer %zu: buf vis range %d...%d\n", i, bufVisRange.start, bufVisRange.end);
1658 if (!prerenderExtra && !isEmpty_Range(&bufVisRange)) { 1658 if (!prerenderExtra && !isEmpty_Range(&bufVisRange)) {
1659 didDraw = iTrue;
1660 if (isEmpty_Rangei(buf->validRange)) { 1659 if (isEmpty_Rangei(buf->validRange)) {
1661 /* Fill the required currently visible range (vis). */ 1660 /* Fill the required currently visible range (vis). */
1662 const iRangei bufVisRange = intersect_Rangei(bufRange, vis); 1661 const iRangei bufVisRange = intersect_Rangei(bufRange, vis);
@@ -1669,26 +1668,46 @@ static iBool render_DocumentView_(const iDocumentView *d, iDrawContext *ctx, iBo
1669 extend_GmRunRange_(&meta->runsDrawn); 1668 extend_GmRunRange_(&meta->runsDrawn);
1670 buf->validRange = bufVisRange; 1669 buf->validRange = bufVisRange;
1671 // printf(" buffer %zu valid %d...%d\n", i, bufRange.start, bufRange.end); 1670 // printf(" buffer %zu valid %d...%d\n", i, bufRange.start, bufRange.end);
1671 didDraw = iTrue;
1672 } 1672 }
1673 } 1673 }
1674 else { 1674 else {
1675 /* Progressively fill the required runs. */ 1675 /* Progressively fill the required runs. */
1676 if (meta->runsDrawn.start) { 1676 if (meta->runsDrawn.start && buf->validRange.start > bufRange.start) {
1677 beginTarget_Paint(p, buf->texture); 1677 beginTarget_Paint(p, buf->texture);
1678 meta->runsDrawn.start = renderProgressive_GmDocument(d->doc, meta->runsDrawn.start, 1678 iZap(ctx->runsDrawn);
1679 -1, iInvalidSize, 1679 const iGmRun *newStart = renderProgressive_GmDocument(d->doc,
1680 bufVisRange, 1680 meta->runsDrawn.start,
1681 drawRun_DrawContext_, 1681 -1,
1682 ctx); 1682 iInvalidSize,
1683 buf->validRange.start = bufVisRange.start; 1683 bufVisRange,
1684 drawRun_DrawContext_,
1685 ctx);
1686 if (ctx->runsDrawn.start) {
1687 /* Something was actually drawn, so update the valid range. */
1688 const int newTop = top_Rect(ctx->runsDrawn.start->visBounds);
1689 if (newTop != buf->validRange.start) {
1690 didDraw = iTrue;
1691// printf("render: valid:%d->%d run:%p->%p\n",
1692// buf->validRange.start, newTop,
1693// meta->runsDrawn.start,
1694// ctx->runsDrawn.start); fflush(stdout);
1695 buf->validRange.start = newTop;
1696 }
1697 meta->runsDrawn.start = newStart;
1698 }
1684 } 1699 }
1685 if (meta->runsDrawn.end) { 1700 if (meta->runsDrawn.end) {
1686 beginTarget_Paint(p, buf->texture); 1701 beginTarget_Paint(p, buf->texture);
1702 iZap(ctx->runsDrawn);
1687 meta->runsDrawn.end = renderProgressive_GmDocument(d->doc, meta->runsDrawn.end, 1703 meta->runsDrawn.end = renderProgressive_GmDocument(d->doc, meta->runsDrawn.end,
1688 +1, iInvalidSize, 1704 +1, iInvalidSize,
1689 bufVisRange, 1705 bufVisRange,
1690 drawRun_DrawContext_, 1706 drawRun_DrawContext_,
1691 ctx); 1707 ctx);
1708 if (ctx->runsDrawn.start) {
1709 didDraw = iTrue;
1710 }
1692 buf->validRange.end = bufVisRange.end; 1711 buf->validRange.end = bufVisRange.end;
1693 } 1712 }
1694 } 1713 }