summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/wayland_shm/evas_shm.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-04-11 15:39:09 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-04-19 15:11:09 -0400
commited665ee6ee924a7596f799d2a241ee958e126349 (patch)
tree6bd875cdbc17f5dd8415e4afae40f364df864fbb /src/modules/evas/engines/wayland_shm/evas_shm.c
parent63a255750b5d46fd3d2083c76e87dec29cab2659 (diff)
wayland_shm: Abstract the actual shm operations
Make the Surface carry function pointers and the shm surface create function set them. This refactor makes implementing dmabuf operations simpler.
Diffstat (limited to 'src/modules/evas/engines/wayland_shm/evas_shm.c')
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_shm.c86
1 files changed, 46 insertions, 40 deletions
diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c
index 59aa47e647..d73f391125 100644
--- a/src/modules/evas/engines/wayland_shm/evas_shm.c
+++ b/src/modules/evas/engines/wayland_shm/evas_shm.c
@@ -394,46 +394,6 @@ _shm_leaf_destroy(Shm_Leaf *leaf)
394 leaf->resize_pool = NULL; 394 leaf->resize_pool = NULL;
395} 395}
396 396
397Surface *
398_evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, int compositor_version)
399{
400 Surface *s;
401 Shm_Surface *surf;
402 int i = 0;
403
404 LOGFN(__FILE__, __LINE__, __FUNCTION__);
405
406 if (!(s = calloc(1, sizeof(Surface)))) return NULL;
407 if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err;
408 s->type = SURFACE_SHM;
409 surf = s->surf.shm;
410
411 surf->w = w;
412 surf->h = h;
413 surf->disp = disp;
414 surf->shm = shm;
415 surf->surface = surface;
416 surf->num_buff = num_buff;
417 surf->alpha = alpha;
418 surf->compositor_version = compositor_version;
419
420 /* create surface buffers */
421 for (; i < surf->num_buff; i++)
422 {
423 if (!_shm_leaf_create(surf, &(surf->leaf[i]), w, h))
424 {
425 ERR("Could not create surface leaf");
426 goto err;
427 }
428 }
429
430 return s;
431
432err:
433 _evas_shm_surface_destroy(s);
434 return NULL;
435}
436
437void 397void
438_evas_shm_surface_destroy(Surface *surface) 398_evas_shm_surface_destroy(Surface *surface)
439{ 399{
@@ -626,3 +586,49 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
626 leaf->age = 0; 586 leaf->age = 0;
627 surface->current = NULL; 587 surface->current = NULL;
628} 588}
589
590Surface *
591_evas_shm_surface_create(struct wl_display *disp, struct wl_shm *shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha, int compositor_version)
592{
593 Surface *s;
594 Shm_Surface *surf;
595 int i = 0;
596
597 LOGFN(__FILE__, __LINE__, __FUNCTION__);
598
599 if (!(s = calloc(1, sizeof(Surface)))) return NULL;
600 if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err;
601 s->type = SURFACE_SHM;
602 surf = s->surf.shm;
603
604 surf->w = w;
605 surf->h = h;
606 surf->disp = disp;
607 surf->shm = shm;
608 surf->surface = surface;
609 surf->num_buff = num_buff;
610 surf->alpha = alpha;
611 surf->compositor_version = compositor_version;
612
613 /* create surface buffers */
614 for (; i < surf->num_buff; i++)
615 {
616 if (!_shm_leaf_create(surf, &(surf->leaf[i]), w, h))
617 {
618 ERR("Could not create surface leaf");
619 goto err;
620 }
621 }
622
623 s->funcs.destroy = _evas_shm_surface_destroy;
624 s->funcs.reconfigure = _evas_shm_surface_reconfigure;
625 s->funcs.data_get = _evas_shm_surface_data_get;
626 s->funcs.assign = _evas_shm_surface_assign;
627 s->funcs.post = _evas_shm_surface_post;
628
629 return s;
630
631err:
632 _evas_shm_surface_destroy(s);
633 return NULL;
634}