forked from enlightenment/efl
ecore_evas/wayland: Merge code from egl and shm engines into common.
Since the render code on both engines is using the frame callback, let's merge it to avoid code duplication. SVN revision: 83390
This commit is contained in:
parent
9afa66d722
commit
c46b096c78
|
@ -24,6 +24,12 @@ static Evas_Smart *_ecore_evas_wl_common_smart = NULL;
|
||||||
static int _ecore_evas_wl_init_count = 0;
|
static int _ecore_evas_wl_init_count = 0;
|
||||||
static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[5];
|
static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[5];
|
||||||
|
|
||||||
|
/* Frame listener */
|
||||||
|
static void _ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm);
|
||||||
|
static const struct wl_callback_listener frame_listener =
|
||||||
|
{
|
||||||
|
_ecore_evas_wl_frame_complete,
|
||||||
|
};
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
_ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
||||||
|
@ -759,12 +765,34 @@ _ecore_evas_wl_common_post_render(Ecore_Evas *ee)
|
||||||
if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
|
if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Ecore_Evas *ee = data;
|
||||||
|
Ecore_Wl_Window *win = NULL;
|
||||||
|
Ecore_Evas_Engine_Wl_Data *wdata;
|
||||||
|
|
||||||
|
if (!ee) return;
|
||||||
|
wdata = ee->engine.data;
|
||||||
|
if (!(win = wdata->win)) return;
|
||||||
|
|
||||||
|
win->frame_callback = NULL;
|
||||||
|
win->frame_pending = EINA_FALSE;
|
||||||
|
wl_callback_destroy(callback);
|
||||||
|
|
||||||
|
if (win->surface)
|
||||||
|
{
|
||||||
|
win->frame_callback = wl_surface_frame(win->surface);
|
||||||
|
wl_callback_add_listener(win->frame_callback, &frame_listener, ee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_ecore_evas_wl_common_render(Ecore_Evas *ee)
|
_ecore_evas_wl_common_render(Ecore_Evas *ee)
|
||||||
{
|
{
|
||||||
int rend = 0;
|
int rend = 0;
|
||||||
|
Ecore_Wl_Window *win = NULL;
|
||||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
Ecore_Evas_Engine_Wl_Data *wdata;
|
||||||
|
|
||||||
if (!ee) return 0;
|
if (!ee) return 0;
|
||||||
if (!ee->visible)
|
if (!ee->visible)
|
||||||
|
@ -773,10 +801,28 @@ _ecore_evas_wl_common_render(Ecore_Evas *ee)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rend = _ecore_evas_wl_common_pre_render(ee);
|
wdata = ee->engine.data;
|
||||||
rend |= _ecore_evas_wl_common_render_updates(ee);
|
if (!(win = wdata->win)) return 0;
|
||||||
_ecore_evas_wl_common_post_render(ee);
|
|
||||||
|
|
||||||
|
rend = _ecore_evas_wl_common_pre_render(ee);
|
||||||
|
if (!(win->frame_pending))
|
||||||
|
{
|
||||||
|
/* FIXME - ideally have an evas_changed_get to return the value
|
||||||
|
* of evas->changed to avoid creating this callback and
|
||||||
|
* destroying it again
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!win->frame_callback)
|
||||||
|
{
|
||||||
|
win->frame_callback = wl_surface_frame(win->surface);
|
||||||
|
wl_callback_add_listener(win->frame_callback, &frame_listener, ee);
|
||||||
|
}
|
||||||
|
|
||||||
|
rend |= _ecore_evas_wl_common_render_updates(ee);
|
||||||
|
if (rend)
|
||||||
|
win->frame_pending = EINA_TRUE;
|
||||||
|
}
|
||||||
|
_ecore_evas_wl_common_post_render(ee);
|
||||||
return rend;
|
return rend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static int _ecore_evas_wl_render(Ecore_Evas *ee);
|
|
||||||
static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
|
static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
|
||||||
static void _ecore_evas_wl_show(Ecore_Evas *ee);
|
static void _ecore_evas_wl_show(Ecore_Evas *ee);
|
||||||
static void _ecore_evas_wl_hide(Ecore_Evas *ee);
|
static void _ecore_evas_wl_hide(Ecore_Evas *ee);
|
||||||
|
@ -73,7 +72,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
|
||||||
NULL, // modal set
|
NULL, // modal set
|
||||||
NULL, // demand attention set
|
NULL, // demand attention set
|
||||||
NULL, // focus skip set
|
NULL, // focus skip set
|
||||||
_ecore_evas_wl_render,
|
_ecore_evas_wl_common_render,
|
||||||
_ecore_evas_wl_common_screen_geometry_get,
|
_ecore_evas_wl_common_screen_geometry_get,
|
||||||
_ecore_evas_wl_common_screen_dpi_get
|
_ecore_evas_wl_common_screen_dpi_get
|
||||||
};
|
};
|
||||||
|
@ -229,108 +228,6 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_ecore_evas_wl_frame_complete (void *data, struct wl_callback *callback, uint32_t time EINA_UNUSED);
|
|
||||||
|
|
||||||
static const struct wl_callback_listener frame_listener = {
|
|
||||||
_ecore_evas_wl_frame_complete,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
_ecore_evas_wl_frame_complete (void *data, struct wl_callback *callback, uint32_t time EINA_UNUSED)
|
|
||||||
{
|
|
||||||
Ecore_Evas *ee = data;
|
|
||||||
Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
|
|
||||||
|
|
||||||
wdata->win->frame_callback = NULL;
|
|
||||||
wdata->win->frame_pending = EINA_FALSE;
|
|
||||||
wl_callback_destroy(callback);
|
|
||||||
|
|
||||||
wdata->win->frame_callback =
|
|
||||||
wl_surface_frame(wdata->win->surface);
|
|
||||||
|
|
||||||
wl_callback_add_listener(wdata->win->frame_callback,
|
|
||||||
&frame_listener, ee);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
_ecore_evas_wl_render_updates(Ecore_Evas *ee)
|
|
||||||
{
|
|
||||||
int rend = 0;
|
|
||||||
Eina_List *updates = NULL;
|
|
||||||
Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
|
|
||||||
|
|
||||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
||||||
|
|
||||||
/* eglSwapBuffers is ultimately called by evas_render_updates() if
|
|
||||||
* there is some update to make. So we must pre-emptively create a
|
|
||||||
* frame callback handler. We make sure we always have one of these in
|
|
||||||
* available to track if the event is presented.
|
|
||||||
*
|
|
||||||
* This frame callback will be fired when the frame has been presented
|
|
||||||
* and we can safely call eglSwapBuffers without it blocking. Whether
|
|
||||||
* to render or not is handled by the frame_pending boolean which is
|
|
||||||
* reset on the frame callback event.
|
|
||||||
*/
|
|
||||||
if (!wdata->win->frame_pending)
|
|
||||||
{
|
|
||||||
/* FIXME - ideally have an evas_changed_get to return the value
|
|
||||||
* of evas->changed to avoid creating this callback and
|
|
||||||
* destroying it again
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!wdata->win->frame_callback)
|
|
||||||
{
|
|
||||||
wdata->win->frame_callback =
|
|
||||||
wl_surface_frame(wdata->win->surface);
|
|
||||||
|
|
||||||
wl_callback_add_listener(wdata->win->frame_callback,
|
|
||||||
&frame_listener, ee);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((updates = evas_render_updates(ee->evas)))
|
|
||||||
{
|
|
||||||
Eina_List *l = NULL;
|
|
||||||
Eina_Rectangle *r;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(updates, l, r)
|
|
||||||
ecore_wl_window_damage(wdata->win,
|
|
||||||
r->x, r->y, r->w, r->h);
|
|
||||||
|
|
||||||
ecore_wl_flush();
|
|
||||||
|
|
||||||
evas_render_updates_free(updates);
|
|
||||||
|
|
||||||
wdata->win->frame_pending = EINA_TRUE;
|
|
||||||
|
|
||||||
rend = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rend;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_ecore_evas_wl_render(Ecore_Evas *ee)
|
|
||||||
{
|
|
||||||
int rend = 0;
|
|
||||||
|
|
||||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
||||||
|
|
||||||
if (!ee) return 0;
|
|
||||||
if (!ee->visible)
|
|
||||||
{
|
|
||||||
evas_norender(ee->evas);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
rend = _ecore_evas_wl_common_pre_render(ee);
|
|
||||||
rend |= _ecore_evas_wl_render_updates(ee);
|
|
||||||
_ecore_evas_wl_common_post_render(ee);
|
|
||||||
|
|
||||||
return rend;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
|
_ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,14 +16,6 @@ static void _ecore_evas_wl_show(Ecore_Evas *ee);
|
||||||
static void _ecore_evas_wl_hide(Ecore_Evas *ee);
|
static void _ecore_evas_wl_hide(Ecore_Evas *ee);
|
||||||
static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha);
|
static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha);
|
||||||
static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent);
|
static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent);
|
||||||
static int _ecore_evas_wl_render(Ecore_Evas *ee);
|
|
||||||
|
|
||||||
/* Frame listener */
|
|
||||||
static void _ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm);
|
|
||||||
static const struct wl_callback_listener frame_listener =
|
|
||||||
{
|
|
||||||
_ecore_evas_wl_frame_complete,
|
|
||||||
};
|
|
||||||
|
|
||||||
static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
|
static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
|
||||||
{
|
{
|
||||||
|
@ -81,7 +73,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
|
||||||
NULL, // modal set
|
NULL, // modal set
|
||||||
NULL, // demand attention set
|
NULL, // demand attention set
|
||||||
NULL, // focus skip set
|
NULL, // focus skip set
|
||||||
_ecore_evas_wl_render,
|
_ecore_evas_wl_common_render,
|
||||||
_ecore_evas_wl_common_screen_geometry_get,
|
_ecore_evas_wl_common_screen_geometry_get,
|
||||||
_ecore_evas_wl_common_screen_dpi_get
|
_ecore_evas_wl_common_screen_dpi_get
|
||||||
};
|
};
|
||||||
|
@ -463,67 +455,6 @@ _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent)
|
||||||
ecore_wl_window_update_size(wdata->win, ee->w + fw, ee->h + fh);
|
ecore_wl_window_update_size(wdata->win, ee->w + fw, ee->h + fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm EINA_UNUSED)
|
|
||||||
{
|
|
||||||
Ecore_Evas *ee = data;
|
|
||||||
Ecore_Wl_Window *win = NULL;
|
|
||||||
Ecore_Evas_Engine_Wl_Data *wdata;
|
|
||||||
|
|
||||||
if (!ee) return;
|
|
||||||
wdata = ee->engine.data;
|
|
||||||
if (!(win = wdata->win)) return;
|
|
||||||
|
|
||||||
win->frame_callback = NULL;
|
|
||||||
win->frame_pending = EINA_FALSE;
|
|
||||||
wl_callback_destroy(callback);
|
|
||||||
|
|
||||||
if (win->surface)
|
|
||||||
{
|
|
||||||
win->frame_callback = wl_surface_frame(win->surface);
|
|
||||||
wl_callback_add_listener(win->frame_callback, &frame_listener, ee);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_ecore_evas_wl_render(Ecore_Evas *ee)
|
|
||||||
{
|
|
||||||
int rend = 0;
|
|
||||||
Ecore_Wl_Window *win = NULL;
|
|
||||||
Ecore_Evas_Engine_Wl_Data *wdata;
|
|
||||||
|
|
||||||
if (!ee) return 0;
|
|
||||||
if (!ee->visible)
|
|
||||||
{
|
|
||||||
evas_norender(ee->evas);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
wdata = ee->engine.data;
|
|
||||||
if (!(win = wdata->win)) return 0;
|
|
||||||
|
|
||||||
rend = _ecore_evas_wl_common_pre_render(ee);
|
|
||||||
if (!(win->frame_pending))
|
|
||||||
{
|
|
||||||
/* FIXME - ideally have an evas_changed_get to return the value
|
|
||||||
* of evas->changed to avoid creating this callback and
|
|
||||||
* destroying it again
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!win->frame_callback)
|
|
||||||
{
|
|
||||||
win->frame_callback = wl_surface_frame(win->surface);
|
|
||||||
wl_callback_add_listener(win->frame_callback, &frame_listener, ee);
|
|
||||||
}
|
|
||||||
|
|
||||||
rend |= _ecore_evas_wl_common_render_updates(ee);
|
|
||||||
if (rend)
|
|
||||||
win->frame_pending = EINA_TRUE;
|
|
||||||
}
|
|
||||||
_ecore_evas_wl_common_post_render(ee);
|
|
||||||
return rend;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location)
|
_ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue