hwc: create the ecore_evas at the e_output_hwc 94/170094/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 13 Feb 2018 08:28:10 +0000 (17:28 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 13 Feb 2018 08:40:07 +0000 (17:40 +0900)
ecore_evas is created at the e_output_hwc.

Change-Id: I8a53a7feb7bfbf5266013b95848e9ed4ad91320a

src/bin/e_comp_screen.c
src/bin/e_comp_screen.h
src/bin/e_output_hwc.c
src/bin/e_output_hwc.h

index 9146e1099db89ac6e852e291f24dac4ad801edbe..7ac4c6ca8622d7430bc0f15f4c8e30e0c821e08c 100644 (file)
@@ -360,12 +360,6 @@ end:
    return ECORE_CALLBACK_PASS_ON;
 }
 
-static void
-_e_comp_screen_cb_ee_resize(Ecore_Evas *ee EINA_UNUSED)
-{
-   e_comp_canvas_update();
-}
-
 static Eina_Bool
 _e_comp_screen_cb_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
 {
@@ -564,6 +558,12 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
              goto fail;
           }
 
+        if (!e_output_setup(output))
+          {
+             ERR("fail to e_output_setup.");
+             goto fail;
+          }
+
         /* update e_scale with first available output size */
         if ((e_config->scale.for_tdm) && (!scale_updated))
           {
@@ -588,25 +588,6 @@ fail:
    return EINA_FALSE;
 }
 
-static void *
-_e_comp_screen_tbm_queue_alloc(void *data EINA_UNUSED, int w, int h)
-{
-   tbm_surface_queue_h tqueue = NULL;
-
-   tqueue = tbm_surface_queue_create(3, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
-
-   e_comp->e_comp_screen->tqueue = tqueue;
-
-   return (void *)tqueue;
-}
-
-static void
-_e_comp_screen_tbm_queue_free(void *data EINA_UNUSED, void *tbm_queue)
-{
-   tbm_surface_queue_destroy(tbm_queue);
-   e_comp->e_comp_screen->tqueue = NULL;
-}
-
 E_API void
 _e_comp_screen_keymap_set(struct xkb_context **ctx, struct xkb_keymap **map)
 {
@@ -704,12 +685,7 @@ static Eina_Bool
 _e_comp_screen_engine_init(void)
 {
    E_Comp_Screen *e_comp_screen = NULL;
-   int w = 0, h = 0, scr_w = 1, scr_h = 1;
    int screen_rotation;
-   char buf[1024];
-   E_Output *output = NULL;
-
-   INF("ecore evase engine init with TDM. HWC.");
 
    /* check the screen rotation */
    screen_rotation = (e_config->screen_rotation_pre + e_config->screen_rotation_setting) % 360;
@@ -717,15 +693,6 @@ _e_comp_screen_engine_init(void)
    INF("E_COMP_SCREEN: screen_rotation_pre %d and screen_rotation_setting %d",
        e_config->screen_rotation_pre, e_config->screen_rotation_setting);
 
-   /* 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 new */
    e_comp_screen = _e_comp_screen_new(e_comp);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
@@ -743,108 +710,6 @@ _e_comp_screen_engine_init(void)
      }
    e_main_ts_end("\tE_Outputs Init Done");
 
-   /* get the primary output */
-   output = e_comp_screen_primary_output_get(e_comp_screen);
-   if (!output)
-     {
-        e_error_message_show(_("Fail to get the primary output!\n"));
-        _e_comp_screen_engine_deinit();
-        return EINA_FALSE;
-     }
-
-   /* get the size of the primary output */
-   e_output_size_get(output, &scr_w, &scr_h);
-
-   /* if output is disconnected, set the default width, height */
-   if (scr_w == 0 || scr_h == 0)
-     {
-        scr_w = 2;
-        scr_h = 1;
-
-        if (!e_output_fake_config_set(output, scr_w, scr_h))
-          {
-             e_error_message_show(_("Fail to set the fake output config!\n"));
-             _e_comp_screen_engine_deinit();
-             return EINA_FALSE;
-          }
-     }
-
-   INF("GL available:%d config engine:%d screen size:%dx%d",
-       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_DRM New");
-        e_comp->ee = ecore_evas_tbm_allocfunc_new("gl_tbm", scr_w, scr_h, _e_comp_screen_tbm_queue_alloc, _e_comp_screen_tbm_queue_free, NULL);
-        snprintf(buf, sizeof(buf), "\tEE_GL_DRM New Done %p %dx%d", e_comp->ee, scr_w, scr_h);
-        e_main_ts_end(buf);
-
-        if (!e_comp->ee)
-          e_comp_gl_set(EINA_FALSE);
-        else
-          {
-             Evas_GL *evasgl = NULL;
-             Evas_GL_API *glapi = NULL;
-
-             e_main_ts_begin("\tEvas_GL New");
-             evasgl = evas_gl_new(ecore_evas_get(e_comp->ee));
-             if (evasgl)
-               {
-                  glapi = evas_gl_api_get(evasgl);
-                  if (!((glapi) && (glapi->evasglBindWaylandDisplay)))
-                    {
-                       e_comp_gl_set(EINA_FALSE);
-                       ecore_evas_free(e_comp->ee);
-                       e_comp->ee = NULL;
-                       e_main_ts_end("\tEvas_GL New Failed 1");
-                    }
-                  else
-                    {
-                       e_main_ts_end("\tEvas_GL New Done");
-                    }
-               }
-             else
-               {
-                  e_comp_gl_set(EINA_FALSE);
-                  ecore_evas_free(e_comp->ee);
-                  e_comp->ee = NULL;
-                  e_main_ts_end("\tEvas_GL New Failed 2");
-               }
-             evas_gl_free(evasgl);
-          }
-     }
-
-   /* fallback to framebuffer drm (non-accel) */
-   if (!e_comp->ee)
-     {
-        e_main_ts_begin("\tEE_DRM New");
-        e_comp->ee = ecore_evas_tbm_allocfunc_new("software_tbm", scr_w, scr_h, _e_comp_screen_tbm_queue_alloc, _e_comp_screen_tbm_queue_free, NULL);
-        snprintf(buf, sizeof(buf), "\tEE_DRM New Done %p %dx%d", e_comp->ee, scr_w, scr_h);
-        e_main_ts_end(buf);
-     }
-
-   if (!e_comp->ee)
-     {
-        e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
-        _e_comp_screen_engine_deinit();
-        return EINA_FALSE;
-     }
-
-   ecore_evas_data_set(e_comp->ee, "comp", e_comp);
-
-   ecore_evas_callback_resize_set(e_comp->ee, _e_comp_screen_cb_ee_resize);
-
-   if (screen_rotation)
-     {
-        /* SHOULD called with resize option after ecore_evas_resize */
-        ecore_evas_rotation_with_resize_set(e_comp->ee, screen_rotation);
-        ecore_evas_geometry_get(e_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_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
 
    ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
@@ -1097,13 +962,6 @@ e_comp_screen_init()
         goto failed_comp_screen;
      }
 
-   /* this setup function is called after e_comp_canvas_init */
-   if (!e_comp_screen_setup(e_comp->e_comp_screen))
-     {
-        ERR("fail to e_comp_screen_setup");
-        return EINA_FALSE;
-     }
-
    if (eldbus_init() == 0)
      {
         ERR("eldbus_init failed");
@@ -1181,31 +1039,6 @@ e_comp_screen_shutdown()
    e_comp->e_comp_screen = NULL;
 }
 
-EINTERN Eina_Bool
-e_comp_screen_setup(E_Comp_Screen *e_comp_screen)
-{
-   Eina_List *l, *ll;
-   E_Output *output = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
-
-   EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
-     {
-        if (!output) continue;
-        if (!output->config.enabled) continue;
-
-        if (!e_output_setup(output))
-          {
-             ERR("fail to e_output_setup.");
-             continue;
-          }
-
-        INF("Enlightenment succeeded to initialize e_output_setup()!\n");
-     }
-
-   return EINA_TRUE;
-}
-
 E_API Eina_Bool
 e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
 {
index 15f4fa2affa22cfe8b4d61b2c31f816bec002ffb..75c60460e71755623ef9bf61e22c63721a9477d6 100644 (file)
@@ -49,7 +49,6 @@ extern E_API int E_EVENT_SCREEN_CHANGE;
 
 E_API   Eina_Bool         e_comp_screen_init(void);
 E_API   void              e_comp_screen_shutdown(void);
-EINTERN Eina_Bool         e_comp_screen_setup(E_Comp_Screen *e_comp_screen);
 EINTERN void              e_comp_screen_hwc_info_debug(void);
 
 EINTERN void              e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh);
index e64472d51c7c37de5b2545f8134b0350d66d3514..afc222841bb8c6af151aaa6a4eaecc4f685485a0 100644 (file)
@@ -1,6 +1,197 @@
 #include "e.h"
 #include "services/e_service_quickpanel.h"
 
+static void
+_e_output_hwc_cb_ee_resize(Ecore_Evas *ee EINA_UNUSED)
+{
+   e_comp_canvas_update();
+}
+
+static void *
+_e_output_hwc_tbm_surface_queue_alloc(void *data, int w, int h)
+{
+   E_Output_Hwc *output_hwc = (E_Output_Hwc *)data;
+   E_Output *output = output_hwc->output;
+   E_Comp_Screen *e_comp_screen = output->e_comp_screen;
+   tdm_output *toutput = output->toutput;
+   tbm_surface_queue_h tqueue = NULL;
+   tdm_error error;
+   int scr_w, scr_h, queue_w, queue_h;
+
+   e_output_size_get(output, &scr_w, &scr_h);
+
+   if (output->tdm_hwc)
+     {
+        tqueue = tdm_output_hwc_get_target_buffer_queue(toutput, &error);
+        if (error != TDM_ERROR_NONE)
+         {
+            ERR("fail to tdm_output_hwc_get_target_buffer_queue");
+            return (void *)NULL;
+         }
+     }
+   else
+     {
+        tqueue = tbm_surface_queue_create(3, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+        if (!tqueue)
+          {
+             ERR("fail to tdm_output_hwc_get_target_buffer_queue");
+             return (void *)NULL;
+          }
+     }
+
+   queue_w = tbm_surface_queue_get_width(tqueue);
+   if (scr_w != queue_w)
+     WRN("!!!!!!WARNING::: the queue width(%d) is diffrent from output width(%d)!!!!!!", queue_w, scr_w);
+   queue_h = tbm_surface_queue_get_height(tqueue);
+   if (scr_h != queue_h)
+     WRN("!!!!!!WARNING::: the queue height(%d) is diffrent from output height(%d)!!!!!!", queue_h, scr_h);
+
+   output_hwc->target_buffer_queue = tqueue;
+
+   // TODO: change the e_comp_screen->tqueue into output_hwc->target_buffer_queue
+   e_comp_screen->tqueue = tqueue;
+
+   return (void *)tqueue;
+}
+
+static void
+_e_output_hwc_tbm_surface_queue_free(void *data, void *tqueue)
+{
+   E_Output_Hwc *output_hwc = (E_Output_Hwc *)data;
+   E_Output *output = output_hwc->output;
+   E_Comp_Screen *e_comp_screen = output->e_comp_screen;
+
+   tbm_surface_queue_destroy(tqueue);
+   output_hwc->target_buffer_queue = NULL;
+   e_comp_screen->tqueue = NULL;
+}
+
+static void
+_e_output_hwc_ee_deinit(E_Output_Hwc *output_hwc)
+{
+   // TODO:
+}
+
+// TODO: Currently E20 has only one e_output for the primary output.
+//       We need to change the ee and other logic for multiple E_Output.
+static Eina_Bool
+_e_output_hwc_ee_init(E_Output_Hwc* output_hwc)
+{
+   E_Output *output = output_hwc->output;
+   int w = 0, h = 0, scr_w = 1, scr_h = 1;
+   int screen_rotation;
+   char buf[1024];
+
+   INF("E_OUTPUT_HWC: ecore evase engine init.");
+
+   // TODO: fix me. change the screen_rotation into output_rotation.
+   screen_rotation = output->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);
+
+   /* get the size of the primary output */
+   e_output_size_get(output, &scr_w, &scr_h);
+
+   /* if output is disconnected, set the default width, height */
+   if (scr_w == 0 || scr_h == 0)
+     {
+        scr_w = 2;
+        scr_h = 1;
+
+        if (!e_output_fake_config_set(output, scr_w, scr_h))
+          {
+             e_error_message_show(_("Fail to set the fake output config!\n"));
+             _e_output_hwc_ee_deinit(output_hwc);
+             return EINA_FALSE;
+          }
+     }
+
+   INF("GL available:%d config engine:%d screen size:%dx%d",
+       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_DRM New");
+        e_comp->ee = ecore_evas_tbm_allocfunc_new("gl_tbm", scr_w, scr_h, _e_output_hwc_tbm_surface_queue_alloc, _e_output_hwc_tbm_surface_queue_free, (void *)output_hwc);
+        snprintf(buf, sizeof(buf), "\tEE_GL_DRM New Done %p %dx%d", e_comp->ee, scr_w, scr_h);
+        e_main_ts_end(buf);
+
+        if (!e_comp->ee)
+          e_comp_gl_set(EINA_FALSE);
+        else
+          {
+             Evas_GL *evasgl = NULL;
+             Evas_GL_API *glapi = NULL;
+
+             e_main_ts_begin("\tEvas_GL New");
+             evasgl = evas_gl_new(ecore_evas_get(e_comp->ee));
+             if (evasgl)
+               {
+                  glapi = evas_gl_api_get(evasgl);
+                  if (!((glapi) && (glapi->evasglBindWaylandDisplay)))
+                    {
+                       e_comp_gl_set(EINA_FALSE);
+                       ecore_evas_free(e_comp->ee);
+                       e_comp->ee = NULL;
+                       e_main_ts_end("\tEvas_GL New Failed 1");
+                    }
+                  else
+                    {
+                       e_main_ts_end("\tEvas_GL New Done");
+                    }
+               }
+             else
+               {
+                  e_comp_gl_set(EINA_FALSE);
+                  ecore_evas_free(e_comp->ee);
+                  e_comp->ee = NULL;
+                  e_main_ts_end("\tEvas_GL New Failed 2");
+               }
+             evas_gl_free(evasgl);
+          }
+     }
+
+   /* fallback to framebuffer drm (non-accel) */
+   if (!e_comp->ee)
+     {
+        e_main_ts_begin("\tEE_DRM New");
+        e_comp->ee = ecore_evas_tbm_allocfunc_new("software_tbm", scr_w, scr_h, _e_output_hwc_tbm_surface_queue_alloc, _e_output_hwc_tbm_surface_queue_free, (void *)output_hwc);
+        snprintf(buf, sizeof(buf), "\tEE_DRM New Done %p %dx%d", e_comp->ee, scr_w, scr_h);
+        e_main_ts_end(buf);
+     }
+
+   if (!e_comp->ee)
+     {
+        e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
+       _e_output_hwc_ee_deinit(output_hwc);
+        return EINA_FALSE;
+     }
+
+   ecore_evas_data_set(e_comp->ee, "comp", e_comp);
+
+   ecore_evas_callback_resize_set(e_comp->ee, _e_output_hwc_cb_ee_resize);
+
+   if (screen_rotation)
+     {
+        /* SHOULD called with resize option after ecore_evas_resize */
+        ecore_evas_rotation_with_resize_set(e_comp->ee, screen_rotation);
+        ecore_evas_geometry_get(e_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);
+     }
+
+   return EINA_TRUE;
+}
+
 EINTERN E_Output_Hwc *
 e_output_hwc_new(E_Output *output)
 {
@@ -13,6 +204,12 @@ e_output_hwc_new(E_Output *output)
 
    output_hwc->output = output;
 
+   if (!_e_output_hwc_ee_init(output_hwc))
+     {
+        ERR("hwc_opt: _e_output_hwc_ee_init failed");
+        goto fail;
+     }
+
    /*
     * E20 has two hwc policy options.
     * 1. One is the E_OUTPUT_HWC_POLICY_PLANES.
@@ -68,6 +265,8 @@ e_output_hwc_del(E_Output_Hwc *output_hwc)
 {
    if (!output_hwc) return;
 
+   _e_output_hwc_ee_deinit(output_hwc);
+
    if (output_hwc->hwc_policy == E_OUTPUT_HWC_POLICY_PLANES)
       e_output_hwc_planes_deinit();
    else
index 36f9496cead3b3c00bbdab31722422945aafdcde..f5dc049bdd9e47eb947749cb50cd4ba283ee5e02 100644 (file)
@@ -35,6 +35,7 @@ struct _E_Output_Hwc
    Eina_Bool            hwc_wins;
    Eina_List           *hwc_windows;
    E_Hwc_Window_Target *target_hwc_window;
+   tbm_surface_queue_h target_buffer_queue;
    Eina_Bool            wait_commit;
    int                  num_visible_windows;