ecore_evas/wayland_shm: Fixed window resize.

Using the server_allocation/allocation to determine the resize offset
was not completely precise, and causing the window to not always resize
correctly.

Additionally, calling evas_engine_info_set() on every resize step caused
the window content to blink and resize very slow, because the swap
buffer, swapper, and everything were being destroyed and recreated. Now
only the swapbuf_reconfigure is being called during the resize, which is
way faster.
This commit is contained in:
Rafael Antognolli 2013-02-18 14:31:17 -03:00
parent cf67e69b50
commit dc0d88df9c
4 changed files with 34 additions and 42 deletions

View File

@ -299,28 +299,14 @@ _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
if (wdata->win) if (wdata->win)
{ {
Ecore_Wl_Window *win; Ecore_Wl_Window *win;
Evas_Coord x = 0, y = 0;
Evas_Engine_Info_Wayland_Shm *einfo; Evas_Engine_Info_Wayland_Shm *einfo;
win = wdata->win; win = wdata->win;
if (win->surface)
{
if (win->edges & 4)
x = win->server_allocation.w - win->allocation.w;
if (win->edges & 1)
y = win->server_allocation.h - win->allocation.h;
}
win->edges = 0;
if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas)))
{ einfo->info.edges = win->edges;
printf("Setting Resize Edges: %d %d\n", x, y);
einfo->info.edges.x = x; win->edges = 0;
einfo->info.edges.y = y;
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
}
win->server_allocation = win->allocation; win->server_allocation = win->allocation;
ecore_wl_window_update_size(wdata->win, w, h); ecore_wl_window_update_size(wdata->win, w, h);

View File

@ -18,10 +18,7 @@ struct _Evas_Engine_Info_Wayland_Shm
unsigned int rotation, depth; unsigned int rotation, depth;
Eina_Bool destination_alpha : 1; Eina_Bool destination_alpha : 1;
struct int edges;
{
int x, y;
} edges;
} info; } info;
/* non-blocking or blocking mode */ /* non-blocking or blocking mode */

View File

@ -9,6 +9,7 @@ typedef struct _Render_Engine Render_Engine;
struct _Render_Engine struct _Render_Engine
{ {
Evas_Engine_Info_Wayland_Shm *info;
Outbuf *ob; Outbuf *ob;
Tilebuf *tb; Tilebuf *tb;
@ -237,13 +238,14 @@ eng_setup(Evas *eo_evas, void *einfo)
} }
if (!(re = if (!(re =
_output_engine_setup(info->info.edges.x, info->info.edges.y, _output_engine_setup(0, 0,
epd->output.w, epd->output.h, epd->output.w, epd->output.h,
info->info.rotation, info->info.depth, info->info.rotation, info->info.depth,
info->info.destination_alpha, info->info.destination_alpha,
info->info.wl_shm, info->info.wl_surface, info->info.wl_shm, info->info.wl_surface,
try_swap))) try_swap)))
return 0; return 0;
re->info = info;
} }
else else
@ -255,13 +257,13 @@ eng_setup(Evas *eo_evas, void *einfo)
/* we have an existing render engine */ /* we have an existing render engine */
if (re->ob) re->outbuf_free(re->ob); if (re->ob) re->outbuf_free(re->ob);
if ((re->ob = evas_swapbuf_setup(info->info.edges.x, if ((re->ob = evas_swapbuf_setup(0,
info->info.edges.y, 0,
epd->output.w, epd->output.h, epd->output.w, epd->output.h,
info->info.rotation, info->info.rotation,
info->info.depth, info->info.depth,
info->info.destination_alpha, info->info.destination_alpha,
info->info.wl_shm, info->info.wl_shm,
info->info.wl_surface))) info->info.wl_surface)))
{ {
re->outbuf_free = evas_swapbuf_free; re->outbuf_free = evas_swapbuf_free;
@ -320,14 +322,23 @@ static void
eng_output_resize(void *data, int w, int h) eng_output_resize(void *data, int w, int h)
{ {
Render_Engine *re; Render_Engine *re;
Evas_Engine_Info_Wayland_Shm *info;
int dx = 0, dy = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!(re = (Render_Engine *)data)) return; if (!(re = (Render_Engine *)data)) return;
re->outbuf_reconfigure(re->ob, re->ob->x, re->ob->y, w, h, if (!(info = re->info)) return;
re->ob->rotation, re->ob->depth,
re->ob->priv.destination_alpha); if (info->info.edges & 4)
dx = re->ob->w - w;
if (info->info.edges & 1)
dy = re->ob->h - h;
re->outbuf_reconfigure(re->ob, dx, dy, w, h,
info->info.rotation, info->info.depth,
info->info.destination_alpha);
evas_common_tilebuf_free(re->tb); evas_common_tilebuf_free(re->tb);
if ((re->tb = evas_common_tilebuf_new(w, h))) if ((re->tb = evas_common_tilebuf_new(w, h)))
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);

View File

@ -17,7 +17,7 @@
typedef struct _Wl_Buffer Wl_Buffer; typedef struct _Wl_Buffer Wl_Buffer;
struct _Wl_Buffer struct _Wl_Buffer
{ {
int x, y, w, h; int w, h;
struct wl_buffer *buffer; struct wl_buffer *buffer;
void *data; void *data;
int offset; int offset;
@ -320,8 +320,6 @@ _evas_swapper_buffer_new(Wl_Swapper *ws, Wl_Buffer *wb)
/* make sure swapper has a shm */ /* make sure swapper has a shm */
if (!ws->shm) return EINA_FALSE; if (!ws->shm) return EINA_FALSE;
wb->x = ws->x;
wb->y = ws->y;
wb->w = ws->w; wb->w = ws->w;
wb->h = ws->h; wb->h = ws->h;
@ -421,9 +419,9 @@ _evas_swapper_buffer_put(Wl_Swapper *ws, Wl_Buffer *wb, Eina_Rectangle *rects, u
/* surface attach */ /* surface attach */
if (sent != wb->buffer) if (sent != wb->buffer)
{ {
wl_surface_attach(ws->surface, wb->buffer, wb->x, wb->y); wl_surface_attach(ws->surface, wb->buffer, ws->x, ws->y);
wb->x = 0; ws->x = 0;
wb->y = 0; ws->y = 0;
sent = wb->buffer; sent = wb->buffer;
} }