discomfitor pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=ed665ee6ee924a7596f799d2a241ee958e126349
commit ed665ee6ee924a7596f799d2a241ee958e126349 Author: Derek Foreman <der...@osg.samsung.com> Date: Mon Apr 11 15:39:09 2016 -0500 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. --- src/modules/evas/engines/wayland_shm/evas_engine.h | 13 ++-- src/modules/evas/engines/wayland_shm/evas_outbuf.c | 20 ++--- src/modules/evas/engines/wayland_shm/evas_shm.c | 86 ++++++++++++---------- 3 files changed, 64 insertions(+), 55 deletions(-) diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h b/src/modules/evas/engines/wayland_shm/evas_engine.h index 7a2a186..14c2f42 100644 --- a/src/modules/evas/engines/wayland_shm/evas_engine.h +++ b/src/modules/evas/engines/wayland_shm/evas_engine.h @@ -85,6 +85,14 @@ struct _Surface union { Shm_Surface *shm; } surf; + struct + { + void (*destroy)(Surface *surface); + void (*reconfigure)(Surface *surface, int w, int h, int num_buff, uint32_t flags); + void *(*data_get)(Surface *surface, int *w, int *h); + int (*assign)(Surface *surface); + void (*post)(Surface *surface, Eina_Rectangle *rects, unsigned int count); + } funcs; }; struct _Outbuf @@ -117,11 +125,6 @@ struct _Outbuf }; Surface *_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); -void _evas_shm_surface_destroy(Surface *surface); -void _evas_shm_surface_reconfigure(Surface *surface, int w, int h, int num_buff, uint32_t flags); -void *_evas_shm_surface_data_get(Surface *surface, int *w, int *h); -int _evas_shm_surface_assign(Surface *surface); -void _evas_shm_surface_post(Surface *surface, Eina_Rectangle *rects, unsigned int count); Outbuf *_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface, struct wl_display *disp, int compositor_version); void _evas_outbuf_free(Outbuf *ob); diff --git a/src/modules/evas/engines/wayland_shm/evas_outbuf.c b/src/modules/evas/engines/wayland_shm/evas_outbuf.c index affcf33..9839edc 100644 --- a/src/modules/evas/engines/wayland_shm/evas_outbuf.c +++ b/src/modules/evas/engines/wayland_shm/evas_outbuf.c @@ -96,7 +96,7 @@ _evas_outbuf_free(Outbuf *ob) _evas_outbuf_flush(ob, NULL, EVAS_RENDER_MODE_UNDEF); _evas_outbuf_idle_flush(ob); - if (ob->surface) _evas_shm_surface_destroy(ob->surface); + if (ob->surface) ob->surface->funcs.destroy(ob->surface); eina_array_flush(&ob->priv.onebuf_regions); @@ -176,7 +176,7 @@ _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode eina_rectangle_free(rect); } - _evas_shm_surface_post(ob->surface, result, n); + ob->surface->funcs.post(ob->surface, result, n); /* clean array */ eina_array_clean(&ob->priv.onebuf_regions); @@ -258,7 +258,7 @@ _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode i++; } - _evas_shm_surface_post(ob->surface, result, n); + ob->surface->funcs.post(ob->surface, result, n); } } @@ -269,7 +269,7 @@ _evas_outbuf_swap_mode_get(Outbuf *ob) LOGFN(__FILE__, __LINE__, __FUNCTION__); - age = _evas_shm_surface_assign(ob->surface); + age = ob->surface->funcs.assign(ob->surface); if (age == 1) return MODE_COPY; else if (age == 2) return MODE_DOUBLE; else if (age == 3) return MODE_TRIPLE; @@ -308,13 +308,13 @@ _evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth, if ((ob->rotation == 0) || (ob->rotation == 180)) { - _evas_shm_surface_reconfigure(ob->surface, w, h, - ob->num_buff, resize); + ob->surface->funcs.reconfigure(ob->surface, w, h, + ob->num_buff, resize); } else if ((ob->rotation == 90) || (ob->rotation == 270)) { - _evas_shm_surface_reconfigure(ob->surface, h, w, - ob->num_buff, resize); + ob->surface->funcs.reconfigure(ob->surface, h, w, + ob->num_buff, resize); } _evas_outbuf_idle_flush(ob); @@ -338,7 +338,7 @@ _evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx, int bw = 0, bh = 0; void *data; - if (!(data = _evas_shm_surface_data_get(ob->surface, &bw, &bh))) + if (!(data = ob->surface->funcs.data_get(ob->surface, &bw, &bh))) { /* ERR("Could not get surface data"); */ return NULL; @@ -515,7 +515,7 @@ _evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y, in if (bpp <= 0) return; /* check for valid desination data */ - if (!(dst = _evas_shm_surface_data_get(ob->surface, &ww, &hh))) + if (!(dst = ob->surface->funcs.data_get(ob->surface, &ww, &hh))) { /* ERR("Could not get surface data"); */ return; diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c index 59aa47e..d73f391 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) leaf->resize_pool = NULL; } -Surface * -_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) -{ - Surface *s; - Shm_Surface *surf; - int i = 0; - - LOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(s = calloc(1, sizeof(Surface)))) return NULL; - if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err; - s->type = SURFACE_SHM; - surf = s->surf.shm; - - surf->w = w; - surf->h = h; - surf->disp = disp; - surf->shm = shm; - surf->surface = surface; - surf->num_buff = num_buff; - surf->alpha = alpha; - surf->compositor_version = compositor_version; - - /* create surface buffers */ - for (; i < surf->num_buff; i++) - { - if (!_shm_leaf_create(surf, &(surf->leaf[i]), w, h)) - { - ERR("Could not create surface leaf"); - goto err; - } - } - - return s; - -err: - _evas_shm_surface_destroy(s); - return NULL; -} - void _evas_shm_surface_destroy(Surface *surface) { @@ -626,3 +586,49 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count) leaf->age = 0; surface->current = NULL; } + +Surface * +_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) +{ + Surface *s; + Shm_Surface *surf; + int i = 0; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if (!(s = calloc(1, sizeof(Surface)))) return NULL; + if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) goto err; + s->type = SURFACE_SHM; + surf = s->surf.shm; + + surf->w = w; + surf->h = h; + surf->disp = disp; + surf->shm = shm; + surf->surface = surface; + surf->num_buff = num_buff; + surf->alpha = alpha; + surf->compositor_version = compositor_version; + + /* create surface buffers */ + for (; i < surf->num_buff; i++) + { + if (!_shm_leaf_create(surf, &(surf->leaf[i]), w, h)) + { + ERR("Could not create surface leaf"); + goto err; + } + } + + s->funcs.destroy = _evas_shm_surface_destroy; + s->funcs.reconfigure = _evas_shm_surface_reconfigure; + s->funcs.data_get = _evas_shm_surface_data_get; + s->funcs.assign = _evas_shm_surface_assign; + s->funcs.post = _evas_shm_surface_post; + + return s; + +err: + _evas_shm_surface_destroy(s); + return NULL; +} --