summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2015-07-30 11:45:38 -0400
committerChris Michael <cp.michael@samsung.com>2015-07-30 11:45:38 -0400
commitf86e04b14f99f6baba0ffd734b81f15634f182ef (patch)
treeb19acb3e157f2cb7d086476ee3693d8298bf779a
parent997e84f14e8d43f2b63e0ce38c222164fe57c9ee (diff)
wayland-shm: Introduce buffer ages
Summary: We now track each shm buffer's time since last draw so evas can tell what it needs to re-render. Reviewers: zmike, devilhorns Reviewed By: devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2893
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_engine.h3
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_outbuf.c22
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_shm.c41
3 files changed, 47 insertions, 19 deletions
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
63typedef struct _Shm_Leaf Shm_Leaf; 63typedef struct _Shm_Leaf Shm_Leaf;
64struct _Shm_Leaf 64struct _Shm_Leaf
65{ 65{
66 int w, h, busy; 66 int w, h, busy, age;
67 Shm_Data *data; 67 Shm_Data *data;
68 Shm_Pool *resize_pool; 68 Shm_Pool *resize_pool;
69 Eina_Bool valid : 1; 69 Eina_Bool valid : 1;
70 Eina_Bool reconfigure : 1; 70 Eina_Bool reconfigure : 1;
71 Eina_Bool drawn : 1;
71}; 72};
72 73
73typedef struct _Shm_Surface Shm_Surface; 74typedef 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
251Render_Engine_Swap_Mode 251Render_Engine_Swap_Mode
252_evas_outbuf_swap_mode_get(Outbuf *ob) 252_evas_outbuf_swap_mode_get(Outbuf *ob)
253{ 253{
254 int count = 0, ret = 0; 254 int age;
255 255
256 LOGFN(__FILE__, __LINE__, __FUNCTION__); 256 LOGFN(__FILE__, __LINE__, __FUNCTION__);
257 257
258 if (!_evas_shm_surface_assign(ob->surface)) return MODE_FULL; 258 if (!_evas_shm_surface_assign(ob->surface)) return MODE_FULL;
259 259
260 /* This was broken, for now we just do full redraws */ 260 age = ob->surface->current->age;
261 return MODE_FULL; 261 if (age > ob->surface->num_buff) return MODE_FULL;
262 262 else if (age == 1) return MODE_COPY;
263 if (count == ob->surface->num_buff) ret = MODE_FULL; 263 else if (age == 2) return MODE_DOUBLE;
264 else if (count == 0) ret = MODE_COPY; 264 else if (age == 3) return MODE_TRIPLE;
265 else if (count == 1) ret = MODE_DOUBLE; 265 else if (age == 4) return MODE_QUADRUPLE;
266 else if (count == 2) ret = MODE_TRIPLE;
267 else if (count == 3) ret = MODE_QUADRUPLE;
268 else ret = MODE_FULL;
269 266
270 /* DBG("SWAPMODE: %d (0=FULL, 1=COPY, 2=DOUBLE, 3=TRIPLE, 4=QUAD", ret); */ 267 return MODE_FULL;
271 /* DBG("\tBusy: %d", count); */
272
273 return ret;
274} 268}
275 269
276int 270int
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)
290 leaf->w = w; 290 leaf->w = w;
291 leaf->h = h; 291 leaf->h = h;
292 leaf->valid = EINA_TRUE; 292 leaf->valid = EINA_TRUE;
293 293 leaf->drawn = EINA_FALSE;
294 leaf->age = 0;
294 wl_buffer_add_listener(leaf->data->buffer, &_shm_buffer_listener, surface); 295 wl_buffer_add_listener(leaf->data->buffer, &_shm_buffer_listener, surface);
295 296
296 return EINA_TRUE; 297 return EINA_TRUE;
@@ -408,6 +409,7 @@ Eina_Bool
408_evas_shm_surface_assign(Shm_Surface *surface) 409_evas_shm_surface_assign(Shm_Surface *surface)
409{ 410{
410 int i; 411 int i;
412 surface->current = NULL;
411 413
412 for (i = 0; i < surface->num_buff; i++) 414 for (i = 0; i < surface->num_buff; i++)
413 { 415 {
@@ -415,10 +417,39 @@ _evas_shm_surface_assign(Shm_Surface *surface)
415 if (surface->leaf[i].valid) 417 if (surface->leaf[i].valid)
416 { 418 {
417 surface->current = &surface->leaf[i]; 419 surface->current = &surface->leaf[i];
418 return EINA_TRUE; 420 break;
421 }
422 }
423
424 /* If we ran out of buffers we're in trouble, reset all ages */
425 if (!surface->current)
426 {
427 for (i = 0; i < surface->num_buff; i++)
428 {
429 if (surface->leaf[i].valid)
430 {
431 surface->leaf[i].drawn = EINA_FALSE;
432 surface->leaf[i].age = 0;
433 }
419 } 434 }
435 return EINA_FALSE;
420 } 436 }
421 return EINA_FALSE; 437
438 /* Increment ages of all valid buffers */
439 for (i = 0; i < surface->num_buff; i++)
440 {
441 if (surface->leaf[i].valid && surface->leaf[i].drawn)
442 {
443 surface->leaf[i].age++;
444 if (surface->leaf[i].age > surface->num_buff)
445 {
446 surface->leaf[i].age = 0;
447 surface->leaf[i].drawn = EINA_FALSE;
448 }
449 }
450 }
451
452 return EINA_TRUE;
422} 453}
423 454
424void * 455void *
@@ -475,6 +506,8 @@ _evas_shm_surface_post(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int
475 506
476 wl_surface_commit(surface->surface); 507 wl_surface_commit(surface->surface);
477 508
478 leaf->busy = 1; 509 leaf->busy = EINA_TRUE;
510 leaf->drawn = EINA_TRUE;
511 leaf->age = 0;
479 surface->current = NULL; 512 surface->current = NULL;
480} 513}