diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h b/src/modules/evas/engines/wayland_shm/evas_engine.h index b3424c55d7..71e63a4af0 100644 --- a/src/modules/evas/engines/wayland_shm/evas_engine.h +++ b/src/modules/evas/engines/wayland_shm/evas_engine.h @@ -63,11 +63,12 @@ struct _Shm_Data typedef struct _Shm_Leaf Shm_Leaf; struct _Shm_Leaf { - int w, h, busy; + int w, h, busy, age; Shm_Data *data; Shm_Pool *resize_pool; Eina_Bool valid : 1; Eina_Bool reconfigure : 1; + Eina_Bool drawn : 1; }; typedef struct _Shm_Surface Shm_Surface; diff --git a/src/modules/evas/engines/wayland_shm/evas_outbuf.c b/src/modules/evas/engines/wayland_shm/evas_outbuf.c index e1e8f63d1f..91fa1498f2 100644 --- a/src/modules/evas/engines/wayland_shm/evas_outbuf.c +++ b/src/modules/evas/engines/wayland_shm/evas_outbuf.c @@ -251,26 +251,20 @@ _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode Render_Engine_Swap_Mode _evas_outbuf_swap_mode_get(Outbuf *ob) { - int count = 0, ret = 0; + int age; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!_evas_shm_surface_assign(ob->surface)) return MODE_FULL; - /* This was broken, for now we just do full redraws */ + age = ob->surface->current->age; + if (age > ob->surface->num_buff) return MODE_FULL; + else if (age == 1) return MODE_COPY; + else if (age == 2) return MODE_DOUBLE; + else if (age == 3) return MODE_TRIPLE; + else if (age == 4) return MODE_QUADRUPLE; + return MODE_FULL; - - if (count == ob->surface->num_buff) ret = MODE_FULL; - else if (count == 0) ret = MODE_COPY; - else if (count == 1) ret = MODE_DOUBLE; - else if (count == 2) ret = MODE_TRIPLE; - else if (count == 3) ret = MODE_QUADRUPLE; - else ret = MODE_FULL; - - /* DBG("SWAPMODE: %d (0=FULL, 1=COPY, 2=DOUBLE, 3=TRIPLE, 4=QUAD", ret); */ - /* DBG("\tBusy: %d", count); */ - - return ret; } int diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c index 9860d9f3d7..30f02f8137 100644 --- a/src/modules/evas/engines/wayland_shm/evas_shm.c +++ b/src/modules/evas/engines/wayland_shm/evas_shm.c @@ -290,7 +290,8 @@ _shm_leaf_create(Shm_Surface *surface, Shm_Leaf *leaf, int w, int h) leaf->w = w; leaf->h = h; leaf->valid = EINA_TRUE; - + leaf->drawn = EINA_FALSE; + leaf->age = 0; wl_buffer_add_listener(leaf->data->buffer, &_shm_buffer_listener, surface); return EINA_TRUE; @@ -408,6 +409,7 @@ Eina_Bool _evas_shm_surface_assign(Shm_Surface *surface) { int i; + surface->current = NULL; for (i = 0; i < surface->num_buff; i++) { @@ -415,10 +417,39 @@ _evas_shm_surface_assign(Shm_Surface *surface) if (surface->leaf[i].valid) { surface->current = &surface->leaf[i]; - return EINA_TRUE; + break; } } - return EINA_FALSE; + + /* If we ran out of buffers we're in trouble, reset all ages */ + if (!surface->current) + { + for (i = 0; i < surface->num_buff; i++) + { + if (surface->leaf[i].valid) + { + surface->leaf[i].drawn = EINA_FALSE; + surface->leaf[i].age = 0; + } + } + return EINA_FALSE; + } + + /* Increment ages of all valid buffers */ + for (i = 0; i < surface->num_buff; i++) + { + if (surface->leaf[i].valid && surface->leaf[i].drawn) + { + surface->leaf[i].age++; + if (surface->leaf[i].age > surface->num_buff) + { + surface->leaf[i].age = 0; + surface->leaf[i].drawn = EINA_FALSE; + } + } + } + + return EINA_TRUE; } void * @@ -475,6 +506,8 @@ _evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int wl_surface_commit(surface->surface); - leaf->busy = 1; + leaf->busy = EINA_TRUE; + leaf->drawn = EINA_TRUE; + leaf->age = 0; surface->current = NULL; }