diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-08 11:53:06 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-08 11:53:06 +0200 |
commit | 1d978ce9fafd2658121a48288a6ddf16cfccecc6 (patch) | |
tree | 2b92ee234344d5f69d7458236eeae443c325d79c /src | |
parent | 84c25733fc847e9488579834d86c1d41a48c89ce (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')
-rw-r--r-- | src/gmdocument.c | 6 | ||||
-rw-r--r-- | src/gmdocument.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 35 |
3 files changed, 33 insertions, 9 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 38077689..5ff8c72f 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -2209,7 +2209,7 @@ const iGmRun *renderProgressive_GmDocument(const iGmDocument *d, const iGmRun *f | |||
2209 | setAnsiFlags_Text(d->theme.ansiEscapes); | 2209 | setAnsiFlags_Text(d->theme.ansiEscapes); |
2210 | const iGmRun *run = first; | 2210 | const iGmRun *run = first; |
2211 | while (isValidRun_GmDocument_(d, run)) { | 2211 | while (isValidRun_GmDocument_(d, run)) { |
2212 | if ((dir < 0 && bottom_Rect(run->visBounds) < visRangeY.start) || | 2212 | if ((dir < 0 && bottom_Rect(run->visBounds) <= visRangeY.start) || |
2213 | (dir > 0 && top_Rect(run->visBounds) >= visRangeY.end)) { | 2213 | (dir > 0 && top_Rect(run->visBounds) >= visRangeY.end)) { |
2214 | break; | 2214 | break; |
2215 | } | 2215 | } |
@@ -2260,6 +2260,10 @@ const iString *source_GmDocument(const iGmDocument *d) { | |||
2260 | return &d->source; | 2260 | return &d->source; |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | iGmRunRange runRange_GmDocument(const iGmDocument *d) { | ||
2264 | return (iGmRunRange){ constFront_Array(&d->layout), constEnd_Array(&d->layout) }; | ||
2265 | } | ||
2266 | |||
2263 | size_t memorySize_GmDocument(const iGmDocument *d) { | 2267 | size_t memorySize_GmDocument(const iGmDocument *d) { |
2264 | return size_String(&d->unormSource) + | 2268 | return size_String(&d->unormSource) + |
2265 | size_String(&d->source) + | 2269 | size_String(&d->source) + |
diff --git a/src/gmdocument.h b/src/gmdocument.h index 37b99c68..0969794c 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h | |||
@@ -212,6 +212,7 @@ const iGmRun * renderProgressive_GmDocument(const iGmDocument *d, const iGmRun | |||
212 | iInt2 size_GmDocument (const iGmDocument *); | 212 | iInt2 size_GmDocument (const iGmDocument *); |
213 | const iArray * headings_GmDocument (const iGmDocument *); /* array of GmHeadings */ | 213 | const iArray * headings_GmDocument (const iGmDocument *); /* array of GmHeadings */ |
214 | const iString * source_GmDocument (const iGmDocument *); | 214 | const iString * source_GmDocument (const iGmDocument *); |
215 | iGmRunRange runRange_GmDocument (const iGmDocument *); | ||
215 | size_t memorySize_GmDocument (const iGmDocument *); /* bytes */ | 216 | size_t memorySize_GmDocument (const iGmDocument *); /* bytes */ |
216 | int warnings_GmDocument (const iGmDocument *); | 217 | int warnings_GmDocument (const iGmDocument *); |
217 | 218 | ||
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 | } |