summaryrefslogtreecommitdiff
path: root/src/ui/visbuf.h
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-14 16:19:42 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-15 10:23:06 +0300
commitfefbd1c259c912fe126a5f34245a8b4c494cb753 (patch)
tree4f1add012361fc9c8430ee43987562252d123bb9 /src/ui/visbuf.h
parentd3b4292242dd938503a31ba68066d53b29f364a4 (diff)
Progressive document rendering
VisBuf now guarantees that all the buffers are sequentially ordered. This ensure complete utilization of all the buffers. Previously some buffers were not used at all, or allocated to the same origin as another one (!). DocumentWidget is able to progressively fill up a buffer while scrolling. After any change to the visible region has been detected (and there are no ongoing changes), prerender the remaining runs one at a time. This solves the issue where one text run would be always unnecessarily rendered while scrolling, even if the scroll distance was just one pixel.
Diffstat (limited to 'src/ui/visbuf.h')
-rw-r--r--src/ui/visbuf.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ui/visbuf.h b/src/ui/visbuf.h
index b285e90b..7efa36a7 100644
--- a/src/ui/visbuf.h
+++ b/src/ui/visbuf.h
@@ -33,12 +33,16 @@ struct Impl_VisBufTexture {
33 SDL_Texture *texture; 33 SDL_Texture *texture;
34 int origin; 34 int origin;
35 iRangei validRange; 35 iRangei validRange;
36 void *user;
36}; 37};
37 38
39#define numBuffers_VisBuf ((size_t) 4)
40
38struct Impl_VisBuf { 41struct Impl_VisBuf {
39 iInt2 texSize; 42 iInt2 texSize;
40 iRangei vis; 43 iRangei vis;
41 iVisBufTexture buffers[4]; 44 iVisBufTexture buffers[numBuffers_VisBuf];
45 void (*bufferInvalidated)(iVisBuf *, size_t index);
42}; 46};
43 47
44iDeclareTypeConstruction(VisBuf) 48iDeclareTypeConstruction(VisBuf)
@@ -46,8 +50,10 @@ iDeclareTypeConstruction(VisBuf)
46void invalidate_VisBuf (iVisBuf *); 50void invalidate_VisBuf (iVisBuf *);
47void alloc_VisBuf (iVisBuf *, const iInt2 size, int granularity); 51void alloc_VisBuf (iVisBuf *, const iInt2 size, int granularity);
48void dealloc_VisBuf (iVisBuf *); 52void dealloc_VisBuf (iVisBuf *);
49void reposition_VisBuf (iVisBuf *, const iRangei vis); 53iBool reposition_VisBuf (iVisBuf *, const iRangei vis); /* returns true if `vis` changes */
50void validate_VisBuf (iVisBuf *); 54void validate_VisBuf (iVisBuf *);
51 55
56iRangei allocRange_VisBuf (const iVisBuf *);
57iRangei bufferRange_VisBuf (const iVisBuf *, size_t index);
52void invalidRanges_VisBuf (const iVisBuf *, const iRangei full, iRangei *out_invalidRanges); 58void invalidRanges_VisBuf (const iVisBuf *, const iRangei full, iRangei *out_invalidRanges);
53void draw_VisBuf (const iVisBuf *, iInt2 topLeft); 59void draw_VisBuf (const iVisBuf *, iInt2 topLeft);