summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-11-08 14:15:52 -0600
committerDerek Foreman <derekf@osg.samsung.com>2017-11-08 15:12:51 -0600
commita5c7fbd006b5e4e578e2a938a609c2aa79315fc2 (patch)
tree8b78871b707bf8ba74851ed493086a254289ace7
parent4adf87ae91e56a97fa85694855d90e08c41b83e2 (diff)
downloadefl-a5c7fbd006b5e4e578e2a938a609c2aa79315fc2.tar.gz
wayland_shm: Return oldest buffer for new renders
This is what the old shm code has been doing, and it's probably better than what the dmabuf code was doing. We currently allocate 3 buffers. The usual case has us swapping between two of those buffers and saving that third buffer for emergencies - if we ever need that third buffer it'll require a full redraw. If we return the oldest available buffer the usual case requires a little more damage but we should never hit the full redraw case, which can cause a frame drop on slow hardware.
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_dmabuf.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/modules/evas/engines/wayland_shm/evas_dmabuf.c b/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
index 2d263de0c1..77849a4e46 100644
--- a/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
+++ b/src/modules/evas/engines/wayland_shm/evas_dmabuf.c
@@ -600,29 +600,19 @@ _evas_dmabuf_surface_data_get(Surface *s, int *w, int *h)
static Dmabuf_Buffer *
_evas_dmabuf_surface_wait(Dmabuf_Surface *s)
{
- int iterations = 0, i;
- struct wl_display *disp;
+ int i = 0, best = -1, best_age = -1;
- disp = ecore_wl2_display_get(s->surface->info->info.wl2_display);
-
- while (iterations++ < 10)
+ for (i = 0; i < s->nbuf; i++)
{
- for (i = 0; i < s->nbuf; i++)
- if (!s->buffer[i]->locked &&
- !s->buffer[i]->busy)
- return s->buffer[i];
-
- wl_display_dispatch_pending(disp);
+ if (s->buffer[i]->locked || s->buffer[i]->busy) continue;
+ if (s->buffer[i]->age > best_age)
+ {
+ best = i;
+ best_age = s->buffer[i]->age;
+ }
}
- /* May be we have a possible render target that just hasn't been
- * given a wl_buffer yet - draw there and let the success handler
- * figure it out.
- */
- for (i = 0; i < s->nbuf; i++)
- if (!s->buffer[i]->locked && !s->buffer[i]->busy)
- return s->buffer[i];
-
+ if (best >= 0) return s->buffer[best];
return NULL;
}