_e_hwc_hooks_delete++;
}
-static void *
-_e_hwc_tbm_surface_queue_alloc(void *data, int w, int h)
-{
- E_Hwc *hwc = (E_Hwc *)data;
- E_Output *output = hwc->output;
- tbm_surface_queue_h tqueue = NULL;
- tdm_error error;
- int queue_w, queue_h;
-
- if ((output->tdm_hwc) && (!output->fake_config))
- {
- tqueue = tdm_hwc_get_client_target_buffer_queue(hwc->thwc, &error);
- if (error != TDM_ERROR_NONE)
- {
- EHERR("fail to tdm_hwc_get_client_target_buffer_queue", hwc);
- return (void *)NULL;
- }
- }
- else
- {
- tqueue = tbm_surface_queue_create(3, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
- if (!tqueue)
- {
- EHERR("fail to tbm_surface_queue_create", hwc);
- return (void *)NULL;
- }
- }
-
- queue_w = tbm_surface_queue_get_width(tqueue);
- queue_h = tbm_surface_queue_get_height(tqueue);
-
- if ((w != queue_w) || (h != queue_h))
- tbm_surface_queue_reset(tqueue, w, h, tbm_surface_queue_get_format(tqueue));
-
- hwc->target_buffer_queue = tqueue;
-
- EHINF("The tqueue(%p, %dx%d) is created.", hwc, tqueue, queue_w, queue_h);
-
- return (void *)tqueue;
-}
-
-static void
-_e_hwc_tbm_surface_queue_free(void *data, void *tqueue)
-{
- E_Hwc *hwc = (E_Hwc *)data;
-
- tbm_surface_queue_destroy(tqueue);
- hwc->target_buffer_queue = NULL;
-}
-
-static void *
-_e_hwc_gbm_surface_alloc(void *data, int w, int h)
-{
- E_Hwc *hwc = (E_Hwc *)data;
- E_Output *output = hwc->output;
- struct gbm_device *gdevice;
- struct gbm_surface *gsurface;
-
- if (output->tdm_hwc)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_get(), NULL);
-
- gdevice = e_display_gbm_device_get();
- EINA_SAFETY_ON_NULL_RETURN_VAL(gdevice, NULL);
-
- gsurface = gbm_surface_create(gdevice, w, h,
- hwc->gbm_format,
- GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
- EINA_SAFETY_ON_NULL_RETURN_VAL(gsurface, NULL);
- }
- else
- {
- EHERR("only tdm hwc support gbm_surface", hwc);
- return (void *) NULL;
- }
-
- hwc->gsurface = gsurface;
- hwc->gsurface_width = w;
- hwc->gsurface_height = h;
- hwc->gsurface_format = hwc->gbm_format;
-
- EHINF("The gbm_surface(%p, %dx%d) fmt(%c%c%c%c)is created.", hwc, gsurface, w, h, EHW_FOURCC_STR(hwc->gsurface_format));
-
- return (void *)gsurface;
-}
-
-static void
-_e_hwc_gbm_surface_free(void *data, void *gsurface)
-{
- E_Hwc *hwc = (E_Hwc *)data;
-
- EHINF("The gbm_surface(%p) is destroyed.", NULL, gsurface);
-
- gbm_surface_destroy(gsurface);
- hwc->gsurface = NULL;
-}
-
-static Ecore_Evas *
-_e_hwc_ecore_evas_tbm_alloc(E_Hwc *hwc, int src_w, int src_h)
-{
- E_Comp *comp;
- Ecore_Evas *ee;
-
- comp = e_comp_get();
- if (comp->avoid_afill)
- {
- ee = ecore_evas_tbm_allocfunc_new("gl_tbm_ES", src_w, src_h,
- _e_hwc_tbm_surface_queue_alloc,
- _e_hwc_tbm_surface_queue_free,
- (void *)hwc);
- }
- else
- {
- ee = ecore_evas_tbm_allocfunc_new("gl_tbm", src_w, src_h,
- _e_hwc_tbm_surface_queue_alloc,
- _e_hwc_tbm_surface_queue_free,
- (void *)hwc);
- }
-
- EHINF("ecore_evas engine:gl_tbm ee:%p avoid_afill:%d", hwc, ee, comp->avoid_afill);
-
- return ee;
-}
-
-static Ecore_Evas *
-_e_hwc_ecore_evas_gbm_alloc(E_Hwc *hwc, int src_w, int src_h)
-{
- E_Comp *comp;
- Ecore_Evas *ee;
- struct gbm_device *gdevice;
- int gbm_formats[2] = {GBM_FORMAT_ABGR8888, GBM_FORMAT_ARGB8888};
- int i, format_count;
-
- gdevice = e_display_gbm_device_get();
- if (!gdevice) return NULL;
-
- format_count = sizeof(gbm_formats) / sizeof(int);
- comp = e_comp_get();
- for (i = 0; i < format_count; i++)
- {
- hwc->gbm_format = gbm_formats[i];
-
- if (comp->avoid_afill)
- {
- ee = ecore_evas_tbm_native_allocfunc_new("gl_tbm_ES", gdevice, src_w, src_h,
- _e_hwc_gbm_surface_alloc,
- _e_hwc_gbm_surface_free,
- (void *)hwc);
- }
- else
- {
- ee = ecore_evas_tbm_native_allocfunc_new("gl_tbm", gdevice, src_w, src_h,
- _e_hwc_gbm_surface_alloc,
- _e_hwc_gbm_surface_free,
- (void *)hwc);
- }
-
- if (ee) break;
- }
-
- EHINF("ecore_evas engine:gl_tbm with gbm ee:%p avaoid_afill:%d", hwc, ee, comp->avoid_afill);
-
- return ee;
-}
-
-EINTERN void
-e_hwc_ecore_evas_deinit(void)
-{
- E_Output *primary_output = NULL;
- E_Hwc *hwc = NULL;
-
- primary_output = e_display_primary_output_get();
- if (!primary_output) return;
-
- hwc = primary_output->hwc;
- if (!hwc) return;
- if (!hwc->ee) return;
-
- ecore_evas_free(hwc->ee);
- hwc->ee =NULL;
-}
-
-static Eina_Bool
-_e_hwc_prefer_gbm_check(void)
-{
- const char *backend_name;
- struct gbm_device *gdevice;
-
- if (e_comp_hwc_is_prefer_gbm())
- return EINA_TRUE;
-
- gdevice = e_display_gbm_device_get();
- if (!gdevice) return EINA_FALSE;
-
- backend_name = gbm_device_get_backend_name(gdevice);
- if (!backend_name) return EINA_FALSE;
- if (!e_util_strcmp(backend_name, "gbm_tbm")) return EINA_FALSE;
-
- return EINA_TRUE;
-}
-
-EINTERN Eina_Bool
-e_hwc_ecore_evas_init(void)
-{
- E_Output *primary_output = NULL;
- Ecore_Evas *ee = NULL;
- int w = 0, h = 0, scr_w = 1, scr_h = 1;
- E_Comp_Screen *e_comp_screen;
- E_Hwc *hwc;
- int screen_rotation;
- char buf[1024];
- E_Comp *comp;
-
- primary_output = e_display_primary_output_get();
- EINA_SAFETY_ON_NULL_RETURN_VAL(primary_output, EINA_FALSE);
-
- hwc = primary_output->hwc;
- EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
-
- EHINF("ecore evase engine init.", hwc);
-
- // TODO: fix me. change the screen_rotation into output_rotation.
- e_comp_screen = e_comp_screen_get();
- if (!e_comp_screen) return EINA_FALSE;
-
- screen_rotation = e_comp_screen->rotation;
-
- /* set env for use tbm_surface_queue*/
- setenv("USE_EVAS_SOFTWARE_TBM_ENGINE", "1", 1);
- //setenv("USE_EVAS_GL_TBM_ENGINE", "1", 1);
-
- /* set gl available if we have ecore_evas support */
- if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_DRM) ||
- ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_TBM))
- e_comp_gl_set(EINA_TRUE);
-
- e_comp_screen_size_get(e_comp_screen, &scr_w, &scr_h);
-
- EHINF("GL available:%d config engine:%d screen size:%dx%d", hwc,
- e_comp_gl_get(), e_comp_config_get()->engine, scr_w, scr_h);
-
- if ((e_comp_gl_get()) &&
- (e_comp_config_get()->engine == E_COMP_ENGINE_GL))
- {
- e_main_ts_begin("\tEE_GL_TBM New");
- if (_e_hwc_prefer_gbm_check())
- {
- ee = _e_hwc_ecore_evas_gbm_alloc(hwc, scr_w, scr_h);
- if (!ee)
- ee = _e_hwc_ecore_evas_tbm_alloc(hwc, scr_w, scr_h);
- }
- else
- {
- ee = _e_hwc_ecore_evas_tbm_alloc(hwc, scr_w, scr_h);
- if (!ee)
- ee = _e_hwc_ecore_evas_gbm_alloc(hwc, scr_w, scr_h);
- }
-
- snprintf(buf, sizeof(buf), "\tEE_GL_TBM New Done %p %dx%d", ee, scr_w, scr_h);
- e_main_ts_end(buf);
-
- if (!ee)
- e_comp_gl_set(EINA_FALSE);
- }
-
- /* fallback to framebuffer drm (non-accel) */
- if (!ee)
- {
- e_main_ts_begin("\tEE_DRM New");
- ee = ecore_evas_tbm_allocfunc_new("software_tbm", scr_w, scr_h, _e_hwc_tbm_surface_queue_alloc, _e_hwc_tbm_surface_queue_free, (void *)hwc);
- EHINF("ecore_evas engine:software_tbm fallback to software engine.", hwc);
- snprintf(buf, sizeof(buf), "\tEE_DRM New Done %p %dx%d", ee, scr_w, scr_h);
- e_main_ts_end(buf);
- }
-
- if (!ee)
- {
- e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
- e_hwc_ecore_evas_deinit();
- return EINA_FALSE;
- }
-
- hwc->ee = ee;
- hwc->evas = ecore_evas_get(hwc->ee);
-
- EHINF("ee(%p) with the tqueue(%p) is created.", hwc, ee, hwc->target_buffer_queue);
-
- comp = e_comp_get();
- comp->ee = ee;
- ecore_evas_data_set(comp->ee, "comp", comp);
-
- if (screen_rotation)
- {
- /* SHOULD called with resize option after ecore_evas_resize */
- ecore_evas_rotation_with_resize_set(comp->ee, screen_rotation);
- ecore_evas_geometry_get(comp->ee, NULL, NULL, &w, &h);
- snprintf(buf, sizeof(buf), "\tEE Rotate and Resize %d, %dx%d", screen_rotation, w, h);
- e_main_ts(buf);
- }
-
- if (!e_hwc_windows_ecore_evas_set(hwc, ee))
- {
- ERR("fail to e_hwc_windows_ecore_evas_set");
- e_hwc_ecore_evas_deinit();
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
-}
-
EINTERN Eina_Bool
e_hwc_init(void)
{