From: Chris Michael Date: Wed, 26 Oct 2016 15:53:49 +0000 (-0400) Subject: evas-wayland-shm: Improve next buffer selection algorithm X-Git-Tag: upstream/1.20.0~3870^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3d1b2d7da768a35837564a3ad2f2300f28d100c;p=platform%2Fupstream%2Fefl.git evas-wayland-shm: Improve next buffer selection algorithm When triple buffering it's possible that we'll only need two buffers at a time for long durations. When we finally call upon a third buffer it hasn't been used recently enough to do a partial redraw. By picking the oldest available buffer when multiple buffers are free we can increase the likelihood of doing partial redraws. Based on 79409757c6493738c21015708a1ba5178942ad94 by Derek Foreman. Signed-off-by: Chris Michael --- diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c index e051b25..d86d466 100644 --- a/src/modules/evas/engines/wayland_shm/evas_shm.c +++ b/src/modules/evas/engines/wayland_shm/evas_shm.c @@ -461,18 +461,19 @@ _evas_shm_surface_reconfigure(Surface *s, int w, int h, uint32_t flags) static Shm_Leaf * _evas_shm_surface_wait(Shm_Surface *surface) { - int iterations = 0, i; + int i = 0, best = -1, best_age = -1; - while (iterations++ < 10) + for (i = 0; i < surface->num_buff; i++) { - for (i = 0; i < surface->num_buff; i++) + if (surface->leaf[i].busy) continue; + if ((surface->leaf[i].valid) && (surface->leaf[i].age > best_age)) { - if (surface->leaf[i].busy) continue; - if (surface->leaf[i].valid) return &surface->leaf[i]; + best = i; + best_age = surface->leaf[i].age; } - - wl_display_dispatch_pending(surface->disp); } + + if (best >= 0) return &surface->leaf[best]; return NULL; }