evas-wayland-shm: Fix issue of destroying & recreating wl_surfaces on hide

When a canvas gets hidden, we don't need to destroy & recreate the
wl_surface. We can simply attach a NULL wl_buffer to the surface which
achieves the same result. This saves us from having to always destroy
& recreate surfaces when we hide/show.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2016-12-02 13:24:42 -05:00
parent 725e439545
commit 9492ee21df
4 changed files with 32 additions and 15 deletions

View File

@ -390,7 +390,7 @@ _fallback(Dmabuf_Surface *s, int w, int h)
new_data = surf->funcs.data_get(surf, NULL, NULL); new_data = surf->funcs.data_get(surf, NULL, NULL);
for (y = 0; y < h; y++) for (y = 0; y < h; y++)
memcpy(new_data + y * w * 4, old_data + y * b->stride, w * 4); memcpy(new_data + y * w * 4, old_data + y * b->stride, w * 4);
surf->funcs.post(surf, NULL, 0); surf->funcs.post(surf, NULL, 0, EINA_FALSE);
buffer_manager->unmap(b); buffer_manager->unmap(b);
out: out:
@ -600,7 +600,7 @@ _evas_dmabuf_surface_assign(Surface *s)
} }
static void static void
_evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count) _evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden)
{ {
Dmabuf_Surface *surface; Dmabuf_Surface *surface;
Dmabuf_Buffer *b; Dmabuf_Buffer *b;
@ -626,9 +626,16 @@ _evas_dmabuf_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
return; return;
} }
surface->pre = NULL; surface->pre = NULL;
if (!hidden)
{
wl_surface_attach(surface->wl_surface, b->wl_buffer, 0, 0); wl_surface_attach(surface->wl_surface, b->wl_buffer, 0, 0);
_evas_surface_damage(surface->wl_surface, surface->compositor_version, _evas_surface_damage(surface->wl_surface, surface->compositor_version,
b->w, b->h, rects, count); b->w, b->h, rects, count);
}
else
wl_surface_attach(surface->wl_surface, NULL, 0, 0);
wl_surface_commit(surface->wl_surface); wl_surface_commit(surface->wl_surface);
} }

View File

@ -99,7 +99,7 @@ struct _Surface
void (*reconfigure)(Surface *surface, int w, int h, uint32_t flags); void (*reconfigure)(Surface *surface, int w, int h, uint32_t flags);
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); void (*post)(Surface *surface, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden);
} funcs; } funcs;
}; };
@ -133,6 +133,8 @@ struct _Outbuf
/* Eina_Bool redraw : 1; */ /* Eina_Bool redraw : 1; */
Eina_Bool destination_alpha : 1; Eina_Bool destination_alpha : 1;
} priv; } priv;
Eina_Bool hidden : 1;
}; };
Eina_Bool _evas_dmabuf_surface_create(Surface *s, int w, int h, int num_buff); Eina_Bool _evas_dmabuf_surface_create(Surface *s, int w, int h, int num_buff);

View File

@ -55,6 +55,7 @@ _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland *info)
ob->rotation = info->info.rotation; ob->rotation = info->info.rotation;
ob->depth = info->info.depth; ob->depth = info->info.depth;
ob->priv.destination_alpha = info->info.destination_alpha; ob->priv.destination_alpha = info->info.destination_alpha;
ob->hidden = info->info.hidden;
/* default to triple buffer */ /* default to triple buffer */
ob->num_buff = 3; ob->num_buff = 3;
@ -82,7 +83,8 @@ _evas_outbuf_setup(int w, int h, Evas_Engine_Info_Wayland *info)
sw = h; sw = h;
sh = w; sh = w;
} }
else goto unhandled_rotation; else
goto unhandled_rotation;
ob->surface = _evas_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; if (!ob->surface) goto surf_err;
@ -203,6 +205,8 @@ _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage EINA_UNUSED, Tilebuf
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (ob->hidden) return;
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return; if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
if (ob->priv.rect_count) free(ob->priv.rects); if (ob->priv.rect_count) free(ob->priv.rects);
@ -359,6 +363,8 @@ _evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth,
ob->depth = depth; ob->depth = depth;
ob->priv.destination_alpha = alpha; ob->priv.destination_alpha = alpha;
if (ob->hidden) return;
if ((ob->rotation == 0) || (ob->rotation == 180)) if ((ob->rotation == 0) || (ob->rotation == 180))
{ {
ob->surface->funcs.reconfigure(ob->surface, w, h, resize); ob->surface->funcs.reconfigure(ob->surface, w, h, resize);
@ -626,7 +632,7 @@ _evas_outbuf_redraws_clear(Outbuf *ob)
{ {
if (!ob->priv.rect_count) return; if (!ob->priv.rect_count) return;
if (ob->info->info.wl_surface) if (ob->info->info.wl_surface)
ob->surface->funcs.post(ob->surface, ob->priv.rects, ob->priv.rect_count); ob->surface->funcs.post(ob->surface, ob->priv.rects, ob->priv.rect_count, ob->hidden);
free(ob->priv.rects); free(ob->priv.rects);
ob->priv.rect_count = 0; ob->priv.rect_count = 0;
} }

View File

@ -543,9 +543,8 @@ _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) _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count, Eina_Bool hidden)
{ {
/* struct wl_callback *frame_cb; */
Shm_Surface *surf; Shm_Surface *surf;
Shm_Leaf *leaf; Shm_Leaf *leaf;
@ -557,12 +556,15 @@ _evas_shm_surface_post(Surface *s, Eina_Rectangle *rects, unsigned int count)
if (!surf->surface) return; if (!surf->surface) return;
if (!hidden)
{
wl_surface_attach(surf->surface, leaf->data->buffer, 0, 0); wl_surface_attach(surf->surface, leaf->data->buffer, 0, 0);
_evas_surface_damage(surf->surface, surf->compositor_version, _evas_surface_damage(surf->surface, surf->compositor_version,
leaf->w, leaf->h, rects, count); leaf->w, leaf->h, rects, count);
/* frame_cb = wl_surface_frame(surface->surface); */ }
/* wl_callback_add_listener(frame_cb, &_shm_frame_listener, surface); */ else
wl_surface_attach(surf->surface, NULL, 0, 0);
wl_surface_commit(surf->surface); wl_surface_commit(surf->surface);