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/periodic.c | |
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/periodic.c')
-rw-r--r-- | src/periodic.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/periodic.c b/src/periodic.c index 29c26de9..9e9dfdba 100644 --- a/src/periodic.c +++ b/src/periodic.c | |||
@@ -21,10 +21,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | 21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ |
22 | 22 | ||
23 | #include "periodic.h" | 23 | #include "periodic.h" |
24 | #include "ui/widget.h" | ||
24 | #include "app.h" | 25 | #include "app.h" |
25 | 26 | ||
26 | #include <the_Foundation/string.h> | 27 | #include <the_Foundation/string.h> |
27 | #include <the_Foundation/thread.h> | 28 | #include <the_Foundation/thread.h> |
29 | #include <SDL_events.h> | ||
28 | #include <SDL_timer.h> | 30 | #include <SDL_timer.h> |
29 | 31 | ||
30 | iDeclareType(PeriodicCommand) | 32 | iDeclareType(PeriodicCommand) |
@@ -54,7 +56,7 @@ iDefineTypeConstructionArgs(PeriodicCommand, (iAny *ctx, const char *cmd), ctx, | |||
54 | 56 | ||
55 | static const uint32_t postingInterval_Periodic_ = 500; | 57 | static const uint32_t postingInterval_Periodic_ = 500; |
56 | 58 | ||
57 | iBool postCommands_Periodic(iPeriodic *d) { | 59 | iBool dispatchCommands_Periodic(iPeriodic *d) { |
58 | const uint32_t now = SDL_GetTicks(); | 60 | const uint32_t now = SDL_GetTicks(); |
59 | if (now - d->lastPostTime < postingInterval_Periodic_) { | 61 | if (now - d->lastPostTime < postingInterval_Periodic_) { |
60 | return iFalse; | 62 | return iFalse; |
@@ -63,7 +65,14 @@ iBool postCommands_Periodic(iPeriodic *d) { | |||
63 | iBool wasPosted = iFalse; | 65 | iBool wasPosted = iFalse; |
64 | lock_Mutex(d->mutex); | 66 | lock_Mutex(d->mutex); |
65 | iConstForEach(Array, i, &d->commands.values) { | 67 | iConstForEach(Array, i, &d->commands.values) { |
66 | postCommandString_App(&((const iPeriodicCommand *) i.value)->command); | 68 | const iPeriodicCommand *pc = i.value; |
69 | const SDL_UserEvent ev = { | ||
70 | .type = SDL_USEREVENT, | ||
71 | .code = command_UserEventCode, | ||
72 | .data1 = (void *) cstr_String(&pc->command) | ||
73 | }; | ||
74 | iAssert(isInstance_Object(pc->context, &Class_Widget)); | ||
75 | dispatchEvent_Widget(pc->context, (const SDL_Event *) &ev); | ||
67 | wasPosted = iTrue; | 76 | wasPosted = iTrue; |
68 | } | 77 | } |
69 | unlock_Mutex(d->mutex); | 78 | unlock_Mutex(d->mutex); |