wayland_shm: Move surface create into dmabuf code

These functions can be combined since there's now only the dmabuf
path.
This commit is contained in:
Derek Foreman 2017-11-27 16:08:39 -06:00
parent d1bb026195
commit e3d6626c0d
3 changed files with 23 additions and 32 deletions

View File

@ -165,37 +165,44 @@ _evas_dmabuf_surface_destroy(Surface *s)
free(surface); free(surface);
} }
Eina_Bool Surface *
_evas_dmabuf_surface_create(Surface *s) _evas_surface_create(Evas_Engine_Info_Wayland *info, Outbuf *ob)
{ {
Surface *out = NULL;
Dmabuf_Surface *surf = NULL;
Ecore_Wl2_Display *ewd; Ecore_Wl2_Display *ewd;
Ecore_Wl2_Buffer_Type types = 0; Ecore_Wl2_Buffer_Type types = 0;
Dmabuf_Surface *surf = NULL;
ewd = s->info->info.wl2_display; out = calloc(1, sizeof(*out));
if (!out) return NULL;
out->info = info;
out->ob = ob;
ewd = info->info.wl2_display;
if (ecore_wl2_display_shm_get(ewd)) if (ecore_wl2_display_shm_get(ewd))
types |= ECORE_WL2_BUFFER_SHM; types |= ECORE_WL2_BUFFER_SHM;
if (ecore_wl2_display_dmabuf_get(ewd)) if (ecore_wl2_display_dmabuf_get(ewd))
types |= ECORE_WL2_BUFFER_DMABUF; types |= ECORE_WL2_BUFFER_DMABUF;
if (!(s->surf.dmabuf = calloc(1, sizeof(Dmabuf_Surface)))) return EINA_FALSE; if (!(surf = calloc(1, sizeof(Dmabuf_Surface)))) goto err;
surf = s->surf.dmabuf; out->surf.dmabuf = surf;
surf->surface = s; surf->surface = out;
surf->alpha = s->info->info.destination_alpha; surf->alpha = info->info.destination_alpha;
/* create surface buffers */ /* create surface buffers */
if (!ecore_wl2_buffer_init(ewd, types)) goto err; if (!ecore_wl2_buffer_init(ewd, types)) goto err;
s->funcs.destroy = _evas_dmabuf_surface_destroy; out->funcs.destroy = _evas_dmabuf_surface_destroy;
s->funcs.reconfigure = _evas_dmabuf_surface_reconfigure; out->funcs.reconfigure = _evas_dmabuf_surface_reconfigure;
s->funcs.data_get = _evas_dmabuf_surface_data_get; out->funcs.data_get = _evas_dmabuf_surface_data_get;
s->funcs.assign = _evas_dmabuf_surface_assign; out->funcs.assign = _evas_dmabuf_surface_assign;
s->funcs.post = _evas_dmabuf_surface_post; out->funcs.post = _evas_dmabuf_surface_post;
return EINA_TRUE; return out;
err: err:
free(out);
free(surf); free(surf);
return EINA_FALSE; return NULL;
} }

View File

@ -129,7 +129,7 @@ struct _Outbuf
Eina_Bool dirty : 1; Eina_Bool dirty : 1;
}; };
Eina_Bool _evas_dmabuf_surface_create(Surface *s); Surface *_evas_surface_create(Evas_Engine_Info_Wayland *info, Outbuf *ob);
Outbuf *_evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland *info); Outbuf *_evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland *info);
void _evas_outbuf_free(Outbuf *ob); void _evas_outbuf_free(Outbuf *ob);

View File

@ -9,22 +9,6 @@
#define GREEN_MASK 0x00ff00 #define GREEN_MASK 0x00ff00
#define BLUE_MASK 0x0000ff #define BLUE_MASK 0x0000ff
static Surface *
_evas_surface_create(Evas_Engine_Info_Wayland *info, Outbuf *ob)
{
Surface *out;
out = calloc(1, sizeof(*out));
if (!out) return NULL;
out->info = info;
out->ob = ob;
if (_evas_dmabuf_surface_create(out)) return out;
free(out);
return NULL;
}
Outbuf * Outbuf *
_evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland *info) _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland *info)
{ {