typedef enum _Surface_Type Surface_Type;
enum _Surface_Type {
+ SURFACE_EMPTY,
SURFACE_SHM
};
union {
Shm_Surface *shm;
} surf;
+ Evas_Engine_Info_Wayland_Shm *info;
struct
{
void (*destroy)(Surface *surface);
} 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);
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
#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)
{
}
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:
_shm_leaf_destroy(&surface->surf.shm->leaf[i]);
free(surface->surf.shm);
- free(surface);
}
void
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++)
}
}
+ 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;
}