efl/src/modules/evas/engines/drm/evas_engine.c

90 lines
2.1 KiB
C

#include "evas_common.h"
#include "evas_private.h"
#include "Evas_Engine_Drm.h"
#include "evas_engine.h"
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
/* external variables */
int _evas_engine_drm_log_dom;
/* engine api functions */
static void *
eng_info(Evas *evas EINA_UNUSED)
{
Evas_Engine_Info_Drm *info;
/* try to allocate space for our engine info structure */
if (!(info = calloc(1, sizeof(Evas_Engine_Info_Drm))))
return NULL;
/* set some engine default properties */
info->magic.magic = rand();
info->render_mode = EVAS_RENDER_MODE_BLOCKING;
return info;
}
static void
eng_info_free(Evas *evas EINA_UNUSED, void *einfo)
{
Evas_Engine_Info_Drm *info;
/* free the engine info */
if ((info = (Evas_Engine_Info_Drm *)einfo))
free(info);
}
/* module api functions */
static int
module_open(Evas_Module *em)
{
/* check for valid evas module */
if (!em) return 0;
/* try to inherit functions from software_generic engine */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
/* try to create eina logging domain */
_evas_engine_drm_log_dom =
eina_log_domain_register("evas-drm", EVAS_DEFAULT_LOG_COLOR);
/* if we could not create a logging domain, error out */
if (_evas_engine_drm_log_dom < 0)
{
EINA_LOG_ERR("Can not create a module log domain.");
return 0;
}
/* store parent functions */
func = pfunc;
/* override the methods we provide */
EVAS_API_OVERRIDE(info, &func, eng_);
EVAS_API_OVERRIDE(info_free, &func, eng_);
/* advertise our engine functions */
em->functions = (void *)(&func);
return 1;
}
static void
module_close(Evas_Module *em EINA_UNUSED)
{
/* unregister the eina log domain for this engine */
eina_log_domain_unregister(_evas_engine_drm_log_dom);
}
static Evas_Module_Api evas_modapi =
{
EVAS_MODULE_API_VERSION, "drm", "none", { module_open, module_close }
};
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, drm);
#ifndef EVAS_STATIC_BUILD_DRM
EVAS_EINA_MODULE_DEFINE(engine, drm);
#endif