forked from enlightenment/efl
wayland_shm: Refactor surface creation
Split this into two parts, one that makes the base surface, one that calls the potential back ends. Once the dmabuf backend is added this will allow a fallback path to re-initialize the surface as wl_shm if dmabuf fails.
This commit is contained in:
parent
8635f56aeb
commit
0d684d4559
|
@ -76,6 +76,7 @@ typedef struct _Shm_Surface Shm_Surface;
|
|||
|
||||
typedef enum _Surface_Type Surface_Type;
|
||||
enum _Surface_Type {
|
||||
SURFACE_EMPTY,
|
||||
SURFACE_SHM
|
||||
};
|
||||
|
||||
|
@ -86,6 +87,7 @@ struct _Surface
|
|||
union {
|
||||
Shm_Surface *shm;
|
||||
} surf;
|
||||
Evas_Engine_Info_Wayland_Shm *info;
|
||||
struct
|
||||
{
|
||||
void (*destroy)(Surface *surface);
|
||||
|
@ -125,7 +127,7 @@ struct _Outbuf
|
|||
} priv;
|
||||
};
|
||||
|
||||
Surface *_evas_shm_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, int h, int num_buff);
|
||||
Eina_Bool _evas_shm_surface_create(Surface *s, int w, int h, int num_buff);
|
||||
|
||||
Outbuf *_evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland_Shm *info);
|
||||
void _evas_outbuf_free(Outbuf *ob);
|
||||
|
@ -140,4 +142,6 @@ void _evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int
|
|||
void _evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
|
||||
void _evas_surface_damage(struct wl_surface *s, int compositor_version, int w, int h, Eina_Rectangle *rects, unsigned int count);
|
||||
|
||||
Eina_Bool _evas_surface_init(Surface *s, int w, int h, int num_buf);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,30 @@
|
|||
#define GREEN_MASK 0x00ff00
|
||||
#define BLUE_MASK 0x0000ff
|
||||
|
||||
Eina_Bool
|
||||
_evas_surface_init(Surface *s, int w, int h, int num_buf)
|
||||
{
|
||||
if (_evas_shm_surface_create(s, w, h, num_buf)) return EINA_TRUE;
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Surface *
|
||||
_evas_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, int h, int num_buf)
|
||||
{
|
||||
Surface *out;
|
||||
|
||||
out = calloc(1, sizeof(*out));
|
||||
if (!out) return NULL;
|
||||
out->type = SURFACE_EMPTY;
|
||||
out->info = info;
|
||||
|
||||
if (_evas_surface_init(out, w, h, num_buf)) return out;
|
||||
|
||||
free(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Outbuf *
|
||||
_evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland_Shm *info)
|
||||
{
|
||||
|
@ -57,7 +81,7 @@ _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland_Shm *info)
|
|||
}
|
||||
else goto unhandled_rotation;
|
||||
|
||||
ob->surface = _evas_shm_surface_create(info, sw, sh, ob->num_buff);
|
||||
ob->surface = _evas_surface_create(info, sw, sh, ob->num_buff);
|
||||
if (!ob->surface) goto surf_err;
|
||||
|
||||
unhandled_rotation:
|
||||
|
|
|
@ -407,7 +407,6 @@ _evas_shm_surface_destroy(Surface *surface)
|
|||
_shm_leaf_destroy(&surface->surf.shm->leaf[i]);
|
||||
|
||||
free(surface->surf.shm);
|
||||
free(surface);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -568,28 +567,25 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
|
|||
surf->current = NULL;
|
||||
}
|
||||
|
||||
Surface *
|
||||
_evas_shm_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, int h, int num_buff)
|
||||
Eina_Bool
|
||||
_evas_shm_surface_create(Surface *s, int w, int h, int num_buff)
|
||||
{
|
||||
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;
|
||||
if (!(s->surf.shm = calloc(1, sizeof(Shm_Surface)))) return EINA_FALSE;
|
||||
surf = s->surf.shm;
|
||||
|
||||
surf->w = w;
|
||||
surf->h = h;
|
||||
surf->disp = info->info.wl_disp;
|
||||
surf->shm = info->info.wl_shm;
|
||||
surf->surface = info->info.wl_surface;
|
||||
surf->disp = s->info->info.wl_disp;
|
||||
surf->shm = s->info->info.wl_shm;
|
||||
surf->surface = s->info->info.wl_surface;
|
||||
surf->num_buff = num_buff;
|
||||
surf->alpha = info->info.destination_alpha;
|
||||
surf->compositor_version = info->info.compositor_version;
|
||||
surf->alpha = s->info->info.destination_alpha;
|
||||
surf->compositor_version = s->info->info.compositor_version;
|
||||
|
||||
/* create surface buffers */
|
||||
for (; i < surf->num_buff; i++)
|
||||
|
@ -601,15 +597,16 @@ _evas_shm_surface_create(Evas_Engine_Info_Wayland_Shm *info, int w, int h, int n
|
|||
}
|
||||
}
|
||||
|
||||
s->type = SURFACE_SHM;
|
||||
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;
|
||||
return EINA_TRUE;
|
||||
|
||||
err:
|
||||
_evas_shm_surface_destroy(s);
|
||||
return NULL;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue