wayland_shm: Remove direct access to wl_surface

Querying it through Ecore_Wl2_Window now
This commit is contained in:
Derek Foreman 2017-08-14 18:21:22 -05:00
parent 8f038b2591
commit 972633e7e8
5 changed files with 28 additions and 31 deletions

View File

@ -72,7 +72,6 @@ struct _Dmabuf_Surface
Surface *surface; Surface *surface;
struct wl_display *wl_display; struct wl_display *wl_display;
struct zwp_linux_dmabuf_v1 *dmabuf; struct zwp_linux_dmabuf_v1 *dmabuf;
struct wl_surface *wl_surface;
int compositor_version; int compositor_version;
Dmabuf_Buffer *current; Dmabuf_Buffer *current;
@ -480,6 +479,7 @@ _create_succeeded(void *data,
struct zwp_linux_buffer_params_v1 *params, struct zwp_linux_buffer_params_v1 *params,
struct wl_buffer *new_buffer) struct wl_buffer *new_buffer)
{ {
struct wl_surface *wls;
Dmabuf_Buffer *b = data; Dmabuf_Buffer *b = data;
b->wl_buffer = new_buffer; b->wl_buffer = new_buffer;
@ -500,10 +500,11 @@ _create_succeeded(void *data,
if (b != b->surface->pre) return; if (b != b->surface->pre) return;
/* This buffer was drawn into before it had a handle */ /* This buffer was drawn into before it had a handle */
wl_surface_attach(b->surface->wl_surface, b->wl_buffer, 0, 0); wls = ecore_wl2_window_surface_get(b->surface->surface->info->info.wl2_win);
_evas_surface_damage(b->surface->wl_surface, b->surface->compositor_version, wl_surface_attach(wls, b->wl_buffer, 0, 0);
_evas_surface_damage(wls, b->surface->compositor_version,
b->w, b->h, NULL, 0); b->w, b->h, NULL, 0);
wl_surface_commit(b->surface->wl_surface); wl_surface_commit(wls);
b->surface->pre = NULL; b->surface->pre = NULL;
b->busy = EINA_FALSE; b->busy = EINA_FALSE;
} }
@ -668,6 +669,7 @@ _evas_dmabuf_surface_assign(Surface *s)
static void static void
_evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden) _evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden)
{ {
struct wl_surface *wls;
Dmabuf_Surface *surface; Dmabuf_Surface *surface;
Dmabuf_Buffer *b; Dmabuf_Buffer *b;
@ -694,16 +696,17 @@ _evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count,
} }
surface->pre = NULL; surface->pre = NULL;
wls = ecore_wl2_window_surface_get(s->info->info.wl2_win);
if (!hidden) if (!hidden)
{ {
wl_surface_attach(surface->wl_surface, b->wl_buffer, 0, 0); wl_surface_attach(wls, b->wl_buffer, 0, 0);
_evas_surface_damage(surface->wl_surface, surface->compositor_version, _evas_surface_damage(wls, surface->compositor_version,
b->w, b->h, rects, count); b->w, b->h, rects, count);
} }
else else
wl_surface_attach(surface->wl_surface, NULL, 0, 0); wl_surface_attach(wls, NULL, 0, 0);
wl_surface_commit(surface->wl_surface); wl_surface_commit(wls);
} }
static Dmabuf_Buffer * static Dmabuf_Buffer *
@ -758,17 +761,16 @@ _evas_dmabuf_surface_destroy(Surface *s)
} }
Eina_Bool Eina_Bool
_evas_dmabuf_surface_surface_set(Surface *s, struct wl_shm *wl_shm EINA_UNUSED, struct zwp_linux_dmabuf_v1 *wl_dmabuf, struct wl_surface *wl_surface) _evas_dmabuf_surface_surface_set(Surface *s, struct wl_shm *wl_shm EINA_UNUSED, struct zwp_linux_dmabuf_v1 *wl_dmabuf)
{ {
Dmabuf_Surface *surf; Dmabuf_Surface *surf;
surf = s->surf.dmabuf; surf = s->surf.dmabuf;
if ((surf->dmabuf == wl_dmabuf) && (surf->wl_surface == wl_surface)) if ((surf->dmabuf == wl_dmabuf))
return EINA_FALSE; return EINA_FALSE;
surf->dmabuf = wl_dmabuf; surf->dmabuf = wl_dmabuf;
surf->wl_surface = wl_surface;
return EINA_TRUE; return EINA_TRUE;
} }
@ -788,7 +790,6 @@ _evas_dmabuf_surface_create(Surface *s, int w, int h, int num_buff)
surf->surface = s; surf->surface = s;
surf->wl_display = s->info->info.wl_display; surf->wl_display = s->info->info.wl_display;
surf->dmabuf = s->info->info.wl_dmabuf; surf->dmabuf = s->info->info.wl_dmabuf;
surf->wl_surface = ecore_wl2_window_surface_get(s->info->info.wl2_win);
surf->alpha = s->info->info.destination_alpha; surf->alpha = s->info->info.destination_alpha;
surf->compositor_version = s->info->info.compositor_version; surf->compositor_version = s->info->info.compositor_version;

View File

@ -175,12 +175,10 @@ eng_update(void *engine, void *data, void *info, unsigned int w, unsigned int h)
{ {
Evas_Engine_Info_Wayland *einfo = info; Evas_Engine_Info_Wayland *einfo = info;
Render_Engine *re = data; Render_Engine *re = data;
struct wl_surface *surf;
surf = ecore_wl2_window_surface_get(einfo->info.wl2_win); _evas_outbuf_surface_set(re->generic.ob,
if (!surf) return 0; einfo->info.wl_shm,
einfo->info.wl_dmabuf);
_evas_outbuf_surface_set(re->generic.ob, einfo->info.wl_shm, einfo->info.wl_dmabuf, surf);
eng_output_resize(engine, data, w, h); eng_output_resize(engine, data, w, h);

View File

@ -100,7 +100,7 @@ struct _Surface
void *(*data_get)(Surface *surface, int *w, int *h); void *(*data_get)(Surface *surface, int *w, int *h);
int (*assign)(Surface *surface); int (*assign)(Surface *surface);
void (*post)(Surface *surface, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden); void (*post)(Surface *surface, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden);
Eina_Bool (*surface_set)(Surface *surface, struct wl_shm *wl_shm, struct zwp_linux_dmabuf_v1 *wl_dmabuf, struct wl_surface *wl_surface); Eina_Bool (*surface_set)(Surface *surface, struct wl_shm *wl_shm, struct zwp_linux_dmabuf_v1 *wl_dmabuf);
} funcs; } funcs;
}; };
@ -155,7 +155,7 @@ 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_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); void _evas_surface_damage(struct wl_surface *s, int compositor_version, int w, int h, Eina_Rectangle *rects, unsigned int count);
void _evas_outbuf_redraws_clear(Outbuf *ob); void _evas_outbuf_redraws_clear(Outbuf *ob);
void _evas_outbuf_surface_set(Outbuf *ob, struct wl_shm *shm, struct zwp_linux_dmabuf_v1 *dmabuf, struct wl_surface *surface); void _evas_outbuf_surface_set(Outbuf *ob, struct wl_shm *shm, struct zwp_linux_dmabuf_v1 *dmabuf);
Eina_Bool _evas_surface_init(Surface *s, int w, int h, int num_buf); Eina_Bool _evas_surface_init(Surface *s, int w, int h, int num_buf);

View File

@ -650,8 +650,8 @@ _evas_outbuf_redraws_clear(Outbuf *ob)
} }
void void
_evas_outbuf_surface_set(Outbuf *ob, struct wl_shm *wl_shm, struct zwp_linux_dmabuf_v1 *wl_dmabuf, struct wl_surface *wl_surface) _evas_outbuf_surface_set(Outbuf *ob, struct wl_shm *wl_shm, struct zwp_linux_dmabuf_v1 *wl_dmabuf)
{ {
if (ob->surface->funcs.surface_set(ob->surface, wl_shm, wl_dmabuf, wl_surface)) if (ob->surface->funcs.surface_set(ob->surface, wl_shm, wl_dmabuf))
ob->dirty = EINA_TRUE; ob->dirty = EINA_TRUE;
} }

View File

@ -63,7 +63,6 @@ struct _Shm_Surface
{ {
struct wl_display *disp; struct wl_display *disp;
struct wl_shm *shm; struct wl_shm *shm;
struct wl_surface *surface;
int w, h; int w, h;
int num_buff; int num_buff;
int compositor_version; int compositor_version;
@ -537,6 +536,7 @@ _evas_shm_surface_data_get(Surface *s, int *w, int *h)
void void
_evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden) _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden)
{ {
struct wl_surface *wls;
Shm_Surface *surf; Shm_Surface *surf;
Shm_Leaf *leaf; Shm_Leaf *leaf;
@ -546,19 +546,19 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Ei
leaf = surf->current; leaf = surf->current;
if (!leaf) return; if (!leaf) return;
if (!surf->surface) return; wls = ecore_wl2_window_surface_get(s->info->info.wl2_win);
if (!hidden) if (!hidden)
{ {
wl_surface_attach(surf->surface, leaf->data->buffer, 0, 0); wl_surface_attach(wls, leaf->data->buffer, 0, 0);
_evas_surface_damage(surf->surface, surf->compositor_version, _evas_surface_damage(wls, surf->compositor_version,
leaf->w, leaf->h, rects, count); leaf->w, leaf->h, rects, count);
} }
else else
wl_surface_attach(surf->surface, NULL, 0, 0); wl_surface_attach(wls, NULL, 0, 0);
wl_surface_commit(surf->surface); wl_surface_commit(wls);
leaf->busy = EINA_TRUE; leaf->busy = EINA_TRUE;
leaf->drawn = EINA_TRUE; leaf->drawn = EINA_TRUE;
@ -567,17 +567,16 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Ei
} }
Eina_Bool Eina_Bool
_evas_shm_surface_surface_set(Surface *s, struct wl_shm *wl_shm, struct zwp_linux_dmabuf_v1 *wl_dmabuf EINA_UNUSED, struct wl_surface *wl_surface) _evas_shm_surface_surface_set(Surface *s, struct wl_shm *wl_shm, struct zwp_linux_dmabuf_v1 *wl_dmabuf EINA_UNUSED)
{ {
Shm_Surface *surf; Shm_Surface *surf;
surf = s->surf.shm; surf = s->surf.shm;
if ((surf->shm == wl_shm) && (surf->surface == wl_surface)) if ((surf->shm == wl_shm))
return EINA_FALSE; return EINA_FALSE;
surf->shm = wl_shm; surf->shm = wl_shm;
surf->surface = wl_surface;
return EINA_TRUE; return EINA_TRUE;
} }
@ -596,7 +595,6 @@ _evas_shm_surface_create(Surface *s, int w, int h, int num_buff)
surf->h = h; surf->h = h;
surf->disp = s->info->info.wl_display; surf->disp = s->info->info.wl_display;
surf->shm = s->info->info.wl_shm; surf->shm = s->info->info.wl_shm;
surf->surface = ecore_wl2_window_surface_get(s->info->info.wl2_win);
surf->num_buff = num_buff; surf->num_buff = num_buff;
surf->alpha = s->info->info.destination_alpha; surf->alpha = s->info->info.destination_alpha;
surf->compositor_version = s->info->info.compositor_version; surf->compositor_version = s->info->info.compositor_version;