chiark / gitweb /
terminal/screen: adjust screen age only on update
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 3 Oct 2014 13:27:25 +0000 (15:27 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Fri, 3 Oct 2014 13:57:00 +0000 (15:57 +0200)
Instead of increasing the screen-age on redraw, we now increase it only on
real updates. This is effectively the same, but avoids increased age
counters on backbuffer rendering. Therefore, we can now check age counters
against fronbuffers safely, while rendering frames in background.

src/libsystemd-terminal/term-screen.c
src/libsystemd-terminal/term.h

index 3f7ef1c..145dcda 100644 (file)
@@ -3735,6 +3735,12 @@ unsigned int term_screen_get_height(term_screen *screen) {
         return screen->page->height;
 }
 
+uint64_t term_screen_get_age(term_screen *screen) {
+        assert_return(screen, 0);
+
+        return screen->age;
+}
+
 int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
         uint32_t *ucs4_str;
         size_t i, j, ucs4_len;
@@ -3743,6 +3749,8 @@ int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
 
         assert_return(screen, -EINVAL);
 
+        ++screen->age;
+
         /* Feed bytes into utf8 decoder and handle parsed ucs4 chars. We always
          * treat data as UTF-8, but the parser makes sure to fall back to raw
          * 8bit mode if the stream is not valid UTF-8. This should be more than
@@ -4258,7 +4266,7 @@ int term_screen_draw(term_screen *screen,
         }
 
         if (fb_age)
-                *fb_age = screen->age++;
+                *fb_age = screen->age;
 
         return 0;
 }
index 8efd48b..eae6c63 100644 (file)
@@ -156,6 +156,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(term_screen*, term_screen_unref);
 
 unsigned int term_screen_get_width(term_screen *screen);
 unsigned int term_screen_get_height(term_screen *screen);
+uint64_t term_screen_get_age(term_screen *screen);
 
 int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size);
 int term_screen_feed_keyboard(term_screen *screen,