diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-14 16:19:42 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-15 10:23:06 +0300 |
commit | fefbd1c259c912fe126a5f34245a8b4c494cb753 (patch) | |
tree | 4f1add012361fc9c8430ee43987562252d123bb9 /src/ui/visbuf.h | |
parent | d3b4292242dd938503a31ba68066d53b29f364a4 (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.h | 10 |
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 | |||
38 | struct Impl_VisBuf { | 41 | struct 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 | ||
44 | iDeclareTypeConstruction(VisBuf) | 48 | iDeclareTypeConstruction(VisBuf) |
@@ -46,8 +50,10 @@ iDeclareTypeConstruction(VisBuf) | |||
46 | void invalidate_VisBuf (iVisBuf *); | 50 | void invalidate_VisBuf (iVisBuf *); |
47 | void alloc_VisBuf (iVisBuf *, const iInt2 size, int granularity); | 51 | void alloc_VisBuf (iVisBuf *, const iInt2 size, int granularity); |
48 | void dealloc_VisBuf (iVisBuf *); | 52 | void dealloc_VisBuf (iVisBuf *); |
49 | void reposition_VisBuf (iVisBuf *, const iRangei vis); | 53 | iBool reposition_VisBuf (iVisBuf *, const iRangei vis); /* returns true if `vis` changes */ |
50 | void validate_VisBuf (iVisBuf *); | 54 | void validate_VisBuf (iVisBuf *); |
51 | 55 | ||
56 | iRangei allocRange_VisBuf (const iVisBuf *); | ||
57 | iRangei bufferRange_VisBuf (const iVisBuf *, size_t index); | ||
52 | void invalidRanges_VisBuf (const iVisBuf *, const iRangei full, iRangei *out_invalidRanges); | 58 | void invalidRanges_VisBuf (const iVisBuf *, const iRangei full, iRangei *out_invalidRanges); |
53 | void draw_VisBuf (const iVisBuf *, iInt2 topLeft); | 59 | void draw_VisBuf (const iVisBuf *, iInt2 topLeft); |