evas/wayland_shm: Add evas_swapper_reconfigure().

This can be used to reconfigure a swapper to another size, without the
need to destroy the swapper itself.

Although the shm pool is not being reused even when reconfiguring to a
smaller size, it could easily be.

This change is done right now only to keep the dx and dy offsets of a
previously requested swapper, which were not still used.
This commit is contained in:
Rafael Antognolli 2013-02-27 12:12:22 -03:00
parent a4026762f9
commit 3d0bd026ba
3 changed files with 62 additions and 2 deletions

View File

@ -110,8 +110,15 @@ evas_swapbuf_reconfigure(Outbuf *ob, int x, int y, int w, int h, unsigned int ro
/* check for valid swapper */
if (ob->priv.swapper)
{
/* free existing swapper */
evas_swapper_free(ob->priv.swapper);
if ((ob->rotation == 0) || (ob->rotation == 180))
ob->priv.swapper = evas_swapper_reconfigure(ob->priv.swapper,
x, y, w, h, depth,
alpha);
else if ((ob->rotation == 90) || (ob->rotation == 270))
ob->priv.swapper = evas_swapper_reconfigure(ob->priv.swapper,
x, y, h, w, depth,
alpha);
return;
}
/* create new swapper */

View File

@ -116,6 +116,56 @@ evas_swapper_setup(int dx, int dy, int w, int h, Outbuf_Depth depth, Eina_Bool a
return ws;
}
Wl_Swapper *
evas_swapper_reconfigure(Wl_Swapper *ws, int dx, int dy, int w, int h, Outbuf_Depth depth, Eina_Bool alpha)
{
int i = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!ws)
{
ERR("No swapper to reconfigure.");
return NULL;
}
/* loop the swapper's buffers and free them */
for (i = 0; i < ws->buff_num; i++)
_evas_swapper_buffer_free(&(ws->buff[i]));
/* free the shm pool */
_evas_swapper_shm_pool_free(ws);
ws->dx += dx;
ws->dy += dy;
ws->w = w;
ws->h = h;
ws->depth = depth;
ws->alpha = alpha;
/* create the shm pool */
if (!_evas_swapper_shm_pool_new(ws))
{
ERR("Could not allocate new shm pool.");
evas_swapper_free(ws);
return NULL;
}
for (i = 0; i < ws->buff_num; i++)
{
/* try to create new internal Wl_Buffer */
if (!_evas_swapper_buffer_new(ws, &(ws->buff[i])))
{
ERR("failed to create wl_buffer. free the swapper.");
evas_swapper_free(ws);
return NULL;
}
}
/* return reconfigured swapper */
return ws;
}
void
evas_swapper_swap(Wl_Swapper *ws, Eina_Rectangle *rects, unsigned int count)
{
@ -307,6 +357,8 @@ _evas_swapper_shm_pool_free(Wl_Swapper *ws)
/* destroy the shm pool */
wl_shm_pool_destroy(ws->pool);
ws->pool_size = 0;
}
static Eina_Bool

View File

@ -6,6 +6,7 @@
typedef struct _Wl_Swapper Wl_Swapper;
Wl_Swapper *evas_swapper_setup(int dx, int dy, int w, int h, Outbuf_Depth depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface);
Wl_Swapper *evas_swapper_reconfigure(Wl_Swapper *ws, int dx, int dy, int w, int h, Outbuf_Depth depth, Eina_Bool alpha);
void evas_swapper_swap(Wl_Swapper *ws, Eina_Rectangle *rects, unsigned int count);
void evas_swapper_free(Wl_Swapper *ws);
void *evas_swapper_buffer_map(Wl_Swapper *ws);