From a67894a5a71ea3ca4c90f3249e0a445f9bc1b2be Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 30 Apr 2013 07:09:16 +0100 Subject: [PATCH] Add Render_Engine structure Start on code to setup the output buffer. Add code to init evas_common functions Add override for engine setup. Signed-off-by: Chris Michael --- src/modules/evas/engines/drm/evas_engine.c | 121 +++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/src/modules/evas/engines/drm/evas_engine.c b/src/modules/evas/engines/drm/evas_engine.c index a3fa93e179..9bff302551 100644 --- a/src/modules/evas/engines/drm/evas_engine.c +++ b/src/modules/evas/engines/drm/evas_engine.c @@ -3,12 +3,65 @@ #include "Evas_Engine_Drm.h" #include "evas_engine.h" +/* local structures */ +typedef struct _Render_Engine Render_Engine; + +struct _Render_Engine +{ + Evas_Engine_Info_Drm *info; + + Tilebuf *tb; + Tilebuf_Rect *rects; + Tilebuf_Rect *prev_rects[3]; + + Outbuf *ob; + + Eina_Inlist *cur_rect; + + Eina_Bool end : 1; +}; + +/* local function prototypes */ +static void *_output_setup(int w, int h, unsigned int rotation, unsigned int depth, Eina_Bool alpha, int swap); + /* function tables - filled in later (func and parent func) */ static Evas_Func func, pfunc; /* external variables */ int _evas_engine_drm_log_dom; +/* local functions */ +static void * +_output_setup(int w, int h, unsigned int rotation, unsigned int depth, Eina_Bool alpha, int swap) +{ + Render_Engine *re; + + /* try to allocate space for our render engine structure */ + if (!(re = calloc(1, sizeof(Render_Engine)))) + return NULL; + + /* try to create a new tilebuffer */ + if (!(re->tb = evas_common_tilebuf_new(w, h))) + { + free(re); + return NULL; + } + + /* set tilesize */ + evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); + + if (swap) + { + /* free any existing outbuf */ + if (re->ob) evas_outbuf_free(re->ob); + + /* try to create new outbuf */ + } + + /* return the allocated render_engine structure */ + return re; +} + /* engine api functions */ static void * eng_info(Evas *evas EINA_UNUSED) @@ -36,6 +89,73 @@ eng_info_free(Evas *evas EINA_UNUSED, void *einfo) free(info); } +static int +eng_setup(Evas *evas, void *einfo) +{ + Evas_Engine_Info_Drm *info; + Evas_Public_Data *epd; + Render_Engine *re; + + /* try to cast to our engine info structure */ + if (!(info = (Evas_Engine_Info_Drm *)einfo)) return 0; + + /* try to get the evas public data */ + if (!(epd = eo_data_get(evas, EVAS_CLASS))) return 0; + + /* check for valid engine output */ + if (!(re = epd->engine.data.output)) + { + static int swap = -1; + + /* 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(); + + /* check if swapping is disabled */ + if (swap == -1) + { + if (getenv("EVAS_DRM_NO_SWAP")) swap = 0; + else swap = 1; + } + + /* try to create a new render_engine */ + if (!(re = _output_setup(epd->output.w, epd->output.h, + info->info.rotation, info->info.depth, + info->info.destination_alpha, swap))) + return 0; + + re->info = info; + } + else + { + + } + + /* reassign engine output */ + epd->engine.data.output = re; + if (!epd->engine.data.output) return 0; + + /* check for valid engine context */ + if (!epd->engine.data.context) + { + /* create a context if needed */ + epd->engine.data.context = + epd->engine.func->context_new(epd->engine.data.output); + } + + return 1; +} + /* module api functions */ static int module_open(Evas_Module *em) @@ -63,6 +183,7 @@ module_open(Evas_Module *em) /* override the methods we provide */ EVAS_API_OVERRIDE(info, &func, eng_); EVAS_API_OVERRIDE(info_free, &func, eng_); + EVAS_API_OVERRIDE(setup, &func, eng_); /* advertise our engine functions */ em->functions = (void *)(&func);