2013-01-24 01:14:13 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
#include "Evas_Engine_Wayland_Shm.h"
|
|
|
|
#include "evas_engine.h"
|
|
|
|
#include "evas_swapbuf.h"
|
2013-01-24 01:16:55 -08:00
|
|
|
#include "evas_outbuf.h"
|
2013-01-24 01:14:16 -08:00
|
|
|
|
|
|
|
/* local structures */
|
|
|
|
typedef struct _Render_Engine Render_Engine;
|
|
|
|
|
|
|
|
struct _Render_Engine
|
|
|
|
{
|
|
|
|
Outbuf *ob;
|
|
|
|
Tilebuf *tb;
|
|
|
|
|
|
|
|
Tilebuf_Rect *rects;
|
|
|
|
Tilebuf_Rect *prev_rects[3];
|
|
|
|
Eina_Inlist *cur_rect;
|
|
|
|
|
|
|
|
short mode;
|
|
|
|
|
|
|
|
Eina_Bool end : 1;
|
|
|
|
Eina_Bool lost_back : 1;
|
|
|
|
|
|
|
|
/* function pointers for output buffer functions that we can
|
|
|
|
* override based on if we are swapping or not */
|
|
|
|
void (*outbuf_free)(Outbuf *ob);
|
|
|
|
void (*outbuf_reconfigure)(Outbuf *ob, int w, int h, unsigned int rotation, Outbuf_Depth depth, Eina_Bool alpha);
|
|
|
|
RGBA_Image *(*outbuf_update_region_new)(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch);
|
|
|
|
void (*outbuf_update_region_push)(Outbuf *ob, RGBA_Image *update, int x, int y, int w, int h);
|
|
|
|
void (*outbuf_update_region_free)(Outbuf *ob, RGBA_Image *update);
|
|
|
|
void (*outbuf_flush)(Outbuf *ob);
|
|
|
|
void (*outbuf_idle_flush)(Outbuf *ob);
|
|
|
|
};
|
2013-01-24 01:14:19 -08:00
|
|
|
|
2013-01-24 01:16:12 -08:00
|
|
|
/* local function prototypes */
|
|
|
|
static void *_output_engine_setup(int w, int h, unsigned int rotation, unsigned int depth, Eina_Bool destination_alpha, struct wl_shm *wl_shm, struct wl_surface *wl_surface, int try_swap);
|
|
|
|
|
2013-01-24 01:14:22 -08:00
|
|
|
/* engine function prototypes */
|
|
|
|
static void *eng_info(Evas *eo_evas EINA_UNUSED);
|
|
|
|
static void eng_info_free(Evas *eo_evas EINA_UNUSED, void *einfo);
|
|
|
|
static int eng_setup(Evas *eo_evas, void *einfo);
|
|
|
|
static void eng_output_free(void *data);
|
|
|
|
static void eng_output_resize(void *data, int w, int h);
|
|
|
|
static void eng_output_tile_size_set(void *data, int w, int h);
|
|
|
|
static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
|
|
|
|
static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
|
|
|
|
static void eng_output_redraws_clear(void *data);
|
|
|
|
static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
|
|
|
|
static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h, Evas_Render_Mode render_mode);
|
|
|
|
static void eng_output_flush(void *data, Evas_Render_Mode render_mode);
|
|
|
|
static void eng_output_idle_flush(void *data);
|
|
|
|
|
2013-01-24 01:14:27 -08:00
|
|
|
/* local variables */
|
|
|
|
static Evas_Func func, pfunc;
|
|
|
|
|
2013-01-24 01:14:19 -08:00
|
|
|
/* external variables */
|
|
|
|
int _evas_engine_way_shm_log_dom = -1;
|
2013-01-24 01:14:31 -08:00
|
|
|
|
2013-01-24 01:16:15 -08:00
|
|
|
/* local functions */
|
|
|
|
static void *
|
|
|
|
_output_engine_setup(int w, int h, unsigned int rotation, unsigned int depth, Eina_Bool destination_alpha, struct wl_shm *wl_shm, struct wl_surface *wl_surface, int try_swap)
|
|
|
|
{
|
2013-01-24 01:16:19 -08:00
|
|
|
Render_Engine *re = NULL;
|
|
|
|
|
|
|
|
/* try to allocate a new render engine */
|
|
|
|
if (!(re = calloc(1, sizeof(Render_Engine))))
|
|
|
|
return NULL;
|
|
|
|
|
2013-01-24 01:16:22 -08:00
|
|
|
/* try to create a new tilebuf first */
|
|
|
|
if (!(re->tb = evas_common_tilebuf_new(w, h)))
|
|
|
|
{
|
|
|
|
free(re);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-24 01:16:36 -08:00
|
|
|
/* set tile size for the tile buffer */
|
|
|
|
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
|
|
|
|
|
2013-01-24 01:16:55 -08:00
|
|
|
if (try_swap)
|
|
|
|
{
|
|
|
|
if ((re->ob = evas_swapbuf_setup(w, h, rotation, depth,
|
|
|
|
destination_alpha, wl_shm,
|
|
|
|
wl_surface)))
|
|
|
|
{
|
|
|
|
re->outbuf_free = evas_swapbuf_free;
|
|
|
|
re->outbuf_reconfigure = evas_swapbuf_reconfigure;
|
|
|
|
re->outbuf_update_region_new = evas_swapbuf_update_region_new;
|
|
|
|
re->outbuf_update_region_push = evas_swapbuf_update_region_push;
|
|
|
|
re->outbuf_update_region_free = evas_swapbuf_update_region_free;
|
|
|
|
re->outbuf_flush = evas_swapbuf_flush;
|
|
|
|
re->outbuf_idle_flush = evas_swapbuf_idle_flush;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 01:17:00 -08:00
|
|
|
/* if creating an output buffer failed, then return NULL */
|
|
|
|
if (!re->ob)
|
|
|
|
{
|
|
|
|
if (re->tb) evas_common_tilebuf_free(re->tb);
|
|
|
|
free(re);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-24 01:16:19 -08:00
|
|
|
/* return allocated render engine */
|
|
|
|
return re;
|
2013-01-24 01:16:15 -08:00
|
|
|
}
|
|
|
|
|
2013-01-24 01:14:31 -08:00
|
|
|
/* engine functions */
|
|
|
|
static void *
|
|
|
|
eng_info(Evas *eo_evas EINA_UNUSED)
|
|
|
|
{
|
2013-01-24 01:15:12 -08:00
|
|
|
Evas_Engine_Info_Wayland_Shm *info;
|
|
|
|
|
|
|
|
/* try to allocate space for engine info */
|
|
|
|
if (!(info = calloc(1, sizeof(Evas_Engine_Info_Wayland_Shm))))
|
|
|
|
return NULL;
|
|
|
|
|
2013-01-24 01:15:15 -08:00
|
|
|
/* fill in default engine info fields */
|
|
|
|
info->magic.magic = rand();
|
|
|
|
info->render_mode = EVAS_RENDER_MODE_BLOCKING;
|
|
|
|
|
2013-01-24 01:15:49 -08:00
|
|
|
/* return allocated engine info */
|
|
|
|
return info;
|
2013-01-24 01:14:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_info_free(Evas *eo_evas EINA_UNUSED, void *einfo)
|
|
|
|
{
|
2013-01-24 01:15:53 -08:00
|
|
|
Evas_Engine_Info_Wayland_Shm *info;
|
2013-01-24 01:14:31 -08:00
|
|
|
|
2013-01-24 01:15:53 -08:00
|
|
|
/* try to free previously allocated engine info */
|
|
|
|
if ((info = (Evas_Engine_Info_Wayland_Shm *)einfo))
|
|
|
|
free(info);
|
2013-01-24 01:14:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
eng_setup(Evas *eo_evas, void *einfo)
|
|
|
|
{
|
2013-01-24 01:15:56 -08:00
|
|
|
Evas_Engine_Info_Wayland_Shm *info;
|
2013-01-24 01:15:59 -08:00
|
|
|
Evas_Public_Data *epd;
|
2013-01-24 01:16:03 -08:00
|
|
|
Render_Engine *re = NULL;
|
2013-01-24 01:15:56 -08:00
|
|
|
|
|
|
|
/* try to cast the engine info to our engine info */
|
|
|
|
if (!(info = (Evas_Engine_Info_Wayland_Shm *)einfo))
|
|
|
|
return 0;
|
|
|
|
|
2013-01-24 01:15:59 -08:00
|
|
|
/* try to get evas public data from the canvas */
|
|
|
|
if (!(epd = eo_data_get(eo_evas, EVAS_CLASS)))
|
|
|
|
return 0;
|
|
|
|
|
2013-01-24 01:16:03 -08:00
|
|
|
/* test for valid engine output */
|
|
|
|
if (!(re = epd->engine.data.output))
|
|
|
|
{
|
2013-01-24 01:16:09 -08:00
|
|
|
static int try_swap = -1;
|
|
|
|
|
2013-01-24 01:16:06 -08:00
|
|
|
/* NB: If we have no valid output then assume we have not been
|
|
|
|
* initialized yet and call any needed common init routines */
|
|
|
|
evas_common_cpu_init();
|
|
|
|
evas_common_blend_init();
|
|
|
|
evas_common_image_init();
|
|
|
|
evas_common_convert_init();
|
|
|
|
evas_common_scale_init();
|
|
|
|
evas_common_rectangle_init();
|
|
|
|
evas_common_polygon_init();
|
|
|
|
evas_common_line_init();
|
|
|
|
evas_common_font_init();
|
|
|
|
evas_common_draw_init();
|
|
|
|
evas_common_tilebuf_init();
|
2013-01-24 01:16:09 -08:00
|
|
|
|
|
|
|
if (try_swap == -1)
|
|
|
|
{
|
|
|
|
/* check for env var to see if we should try swapping */
|
|
|
|
if (getenv("EVAS_NO_DRI_SWAPBUF")) try_swap = 0;
|
|
|
|
else try_swap = 1;
|
|
|
|
}
|
|
|
|
|
2013-01-24 01:17:11 -08:00
|
|
|
if (!(re =
|
|
|
|
_output_engine_setup(epd->output.w, epd->output.h,
|
|
|
|
info->info.rotation, info->info.depth,
|
|
|
|
info->info.destination_alpha,
|
|
|
|
info->info.wl_shm, info->info.wl_surface,
|
|
|
|
try_swap)))
|
|
|
|
return 0;
|
2013-01-24 01:17:15 -08:00
|
|
|
}
|
2013-01-24 01:17:11 -08:00
|
|
|
|
2013-01-24 01:17:15 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we have an existing render engine */
|
|
|
|
if (re->ob) re->outbuf_free(re->ob);
|
|
|
|
|
|
|
|
if ((re->ob = evas_swapbuf_setup(epd->output.w, epd->output.h,
|
|
|
|
info->info.rotation,
|
|
|
|
info->info.depth,
|
|
|
|
info->info.destination_alpha,
|
|
|
|
info->info.wl_shm,
|
|
|
|
info->info.wl_surface)))
|
|
|
|
{
|
|
|
|
re->outbuf_free = evas_swapbuf_free;
|
|
|
|
re->outbuf_reconfigure = evas_swapbuf_reconfigure;
|
|
|
|
re->outbuf_update_region_new = evas_swapbuf_update_region_new;
|
|
|
|
re->outbuf_update_region_push = evas_swapbuf_update_region_push;
|
|
|
|
re->outbuf_update_region_free = evas_swapbuf_update_region_free;
|
|
|
|
re->outbuf_flush = evas_swapbuf_flush;
|
|
|
|
re->outbuf_idle_flush = evas_swapbuf_idle_flush;
|
|
|
|
}
|
2013-01-24 01:16:03 -08:00
|
|
|
}
|
|
|
|
|
2013-01-24 01:14:31 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_free(void *data)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_resize(void *data, int w, int h)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_tile_size_set(void *data, int w, int h)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_redraws_clear(void *data)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h, Evas_Render_Mode render_mode)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_flush(void *data, Evas_Render_Mode render_mode)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eng_output_idle_flush(void *data)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2013-01-24 01:14:46 -08:00
|
|
|
|
|
|
|
/* module functions */
|
|
|
|
static int
|
|
|
|
module_open(Evas_Module *em)
|
|
|
|
{
|
2013-01-24 01:14:54 -08:00
|
|
|
/* check for valid evas module */
|
|
|
|
if (!em) return 0;
|
|
|
|
|
|
|
|
/* try to create our logging domain */
|
|
|
|
_evas_engine_way_shm_log_dom =
|
|
|
|
eina_log_domain_register("evas-wayland_shm", EVAS_DEFAULT_LOG_COLOR);
|
|
|
|
if (_evas_engine_way_shm_log_dom < 0)
|
|
|
|
{
|
|
|
|
/* creating the logging domain failed. notify user */
|
|
|
|
EINA_LOG_ERR("Could not create a module log domain.");
|
|
|
|
|
|
|
|
/* return failure */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-24 01:14:57 -08:00
|
|
|
/* try to inherit base functions from the software generic engine */
|
|
|
|
if (!_evas_module_engine_inherit(&pfunc, "software_generic"))
|
|
|
|
return 0;
|
|
|
|
|
2013-01-24 01:15:00 -08:00
|
|
|
/* copy base functions from the software_generic engine */
|
|
|
|
func = pfunc;
|
|
|
|
|
2013-01-24 01:15:05 -08:00
|
|
|
/* override any engine specific functions that we provide */
|
|
|
|
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
|
|
|
|
ORD(info);
|
|
|
|
ORD(info_free);
|
|
|
|
ORD(setup);
|
|
|
|
ORD(output_free);
|
|
|
|
ORD(output_resize);
|
|
|
|
ORD(output_tile_size_set);
|
|
|
|
ORD(output_redraws_rect_add);
|
|
|
|
ORD(output_redraws_rect_del);
|
|
|
|
ORD(output_redraws_clear);
|
|
|
|
ORD(output_redraws_next_update_get);
|
|
|
|
ORD(output_redraws_next_update_push);
|
|
|
|
ORD(output_flush);
|
|
|
|
ORD(output_idle_flush);
|
|
|
|
|
2013-01-24 01:15:08 -08:00
|
|
|
/* advertise out our own api */
|
|
|
|
em->functions = (void *)(&func);
|
|
|
|
|
|
|
|
/* return success */
|
|
|
|
return 1;
|
2013-01-24 01:14:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
module_close(Evas_Module *em EINA_UNUSED)
|
|
|
|
{
|
2013-01-24 01:14:50 -08:00
|
|
|
/* if we have the log domain, unregister it */
|
|
|
|
if (_evas_engine_way_shm_log_dom > -1)
|
|
|
|
eina_log_domain_unregister(_evas_engine_way_shm_log_dom);
|
2013-01-24 01:14:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Module_Api evas_modapi =
|
|
|
|
{
|
|
|
|
EVAS_MODULE_API_VERSION, "wayland_shm", "none", {module_open, module_close}
|
|
|
|
};
|
|
|
|
|
|
|
|
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, wayland_shm);
|
|
|
|
|
|
|
|
#ifndef EVAS_STATIC_BUILD_WAYLAND_SHM
|
|
|
|
EVAS_EINA_MODULE_DEFINE(engine, wayland_shm);
|
|
|
|
#endif
|