video: Remove backend init function, and do its job at create function. 22/204522/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 22 Apr 2019 03:51:05 +0000 (12:51 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Wed, 24 Apr 2019 06:34:30 +0000 (15:34 +0900)
Change-Id: I92bc8f63f3413543aa963261c6bfdbf6939b4eaf

src/bin/video/iface/e_video_hwc.c
src/bin/video/iface/e_video_hwc.h
src/bin/video/iface/e_video_hwc_planes.c
src/bin/video/iface/e_video_hwc_windows.c

index c087d10beca6dababb8707a9864a2248e5bbb5e5..ca8aedb1ea6ef86e63f3575c9a124e315b771f0a 100644 (file)
@@ -1562,12 +1562,14 @@ _e_video_hwc_create(E_Client *ec)
 {
    E_Video_Hwc *evh;
    E_Hwc_Policy hwc_policy;
+   E_Output *output;
 
+   output = e_output_find(ec->zone->output_id);
    hwc_policy = e_zone_video_hwc_policy_get(ec->zone);
    if (hwc_policy == E_HWC_POLICY_PLANES)
-     evh = e_video_hwc_planes_create();
+     evh = e_video_hwc_planes_create(output, ec);
    else if (hwc_policy == E_HWC_POLICY_WINDOWS)
-     evh = e_video_hwc_windows_create();
+     evh = e_video_hwc_windows_create(output, ec);
    else
      {
         VER("Unknown HWC mode %d", ec, hwc_policy);
@@ -1581,11 +1583,10 @@ _e_video_hwc_create(E_Client *ec)
      }
 
    evh->hwc_policy = hwc_policy;
+   evh->e_output = output;
    evh->ec = ec;
-   evh->pp_align = -1;
    evh->window = e_client_util_win_get(ec);
-   evh->e_output = e_output_find(ec->zone->output_id);
-   evh->output = evh->e_output->toutput;
+   evh->pp_align = -1;
 
    //TODO: shoud this function be called here?
    e_zone_video_available_size_get(ec->zone, NULL, NULL,
@@ -1662,7 +1663,6 @@ EINTERN E_Video_Comp_Iface *
 e_video_hwc_iface_create(E_Client *ec)
 {
    E_Video_Hwc *evh;
-   Eina_Bool res = EINA_FALSE;
 
    VIN("Create HWC interface", ec);
 
@@ -1672,18 +1672,6 @@ e_video_hwc_iface_create(E_Client *ec)
 
    _e_video_hwc_client_event_init(evh);
 
-   if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-     res = e_video_hwc_planes_init(evh);
-   else
-     res = e_video_hwc_windows_init(evh);
-
-   if (!res)
-     {
-        VER("Failed to init HWC backend", ec);
-        free(evh);
-        return NULL;
-     }
-
    evh->iface.destroy = _e_video_hwc_iface_destroy;
    evh->iface.follow_topmost_visibility = _e_video_hwc_iface_follow_topmost_visibility;
    evh->iface.unfollow_topmost_visibility = _e_video_hwc_iface_unfollow_topmost_visibility;
index a2a38ddf07f24aa6ec5f4154c4443141ce1227e6..99fae16693d1eef9619c9064d92c49eb01ad657d 100644 (file)
@@ -38,7 +38,6 @@ struct _E_Video_Hwc
 
    E_Client *ec;
    Ecore_Window window;
-   tdm_output *output;
    E_Output *e_output;
 
    Eina_List *ec_event_handler;
@@ -78,16 +77,14 @@ struct _E_Video_Hwc
    Eina_Bool  allowed_attribute;
 };
 
-EINTERN E_Video_Hwc *e_video_hwc_planes_create(void);
-EINTERN Eina_Bool    e_video_hwc_planes_init(E_Video_Hwc *evh);
+EINTERN E_Video_Hwc *e_video_hwc_planes_create(E_Output *output, E_Client *ec);
 EINTERN Eina_Bool    e_video_hwc_planes_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf);
 EINTERN Eina_Bool    e_video_hwc_planes_check_if_pp_needed(E_Video_Hwc *evh);
 EINTERN Eina_Bool    e_video_hwc_planes_properties_commit(E_Video_Hwc *evh);
 EINTERN Eina_Bool    e_video_hwc_planes_commit_available_check(E_Video_Hwc *evh);
 EINTERN tbm_surface_h   e_video_hwc_planes_displaying_buffer_get(E_Video_Hwc *evh);
 
-EINTERN E_Video_Hwc *e_video_hwc_windows_create(void);
-EINTERN Eina_Bool    e_video_hwc_windows_init(E_Video_Hwc *evh);
+EINTERN E_Video_Hwc *e_video_hwc_windows_create(E_Output *output, E_Client *ec);
 EINTERN Eina_Bool    e_video_hwc_windows_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf);
 EINTERN Eina_Bool    e_video_hwc_windows_check_if_pp_needed(E_Video_Hwc *evh);
 EINTERN Eina_Bool    e_video_hwc_windows_commit_available_check(E_Video_Hwc *evh);
index 6a5a5f22ae023db6c7fe4177862daa3c3394bc38..594d36ec4f83ea4cb400293e726f0d777c821c42 100644 (file)
@@ -22,6 +22,7 @@ struct _E_Video_Hwc_Planes
 
    struct
      {
+        tdm_output *output;
         tdm_layer *layer;
         /* attributes */
         Eina_List *prop_list;
@@ -350,35 +351,37 @@ _e_video_hwc_planes_available_video_tdm_layer_get(tdm_output *output)
 static Eina_Bool
 _e_video_hwc_planes_tdm_layer_set(E_Video_Hwc_Planes *evhp)
 {
+   E_Plane *plane = NULL;
    Eina_Bool need_wait;
+   tdm_layer *layer;
    tdm_error ret;
    int zpos;
 
    if (evhp->tdm.layer)
      return EINA_TRUE;
 
-   evhp->tdm.layer = _e_video_hwc_planes_available_video_tdm_layer_get(evhp->base.output);
-   if (!evhp->tdm.layer)
+   layer = _e_video_hwc_planes_available_video_tdm_layer_get(evhp->tdm.output);
+   if (!layer)
      {
-        VWR("no available layer for evhp", evhp->base.ec);
+        VWR("no available layer for evhp", NULL);
         return EINA_FALSE;
      }
-   _e_video_hwc_planes_tdm_layer_usable_set(evhp->tdm.layer, EINA_FALSE);
+   _e_video_hwc_planes_tdm_layer_usable_set(layer, EINA_FALSE);
 
-   ret = tdm_layer_get_zpos(evhp->tdm.layer, &zpos);
+   ret = tdm_layer_get_zpos(layer, &zpos);
    if (ret == TDM_ERROR_NONE)
-     evhp->e_plane = e_output_plane_get_by_zpos(evhp->base.e_output, zpos);
+     plane = e_output_plane_get_by_zpos(evhp->base.e_output, zpos);
 
-   if (!evhp->e_plane)
+   if (!plane)
      {
-        VWR("fail get e_plane", evhp->base.ec);
-        goto err_get_eplane;
+        VWR("fail get e_plane", NULL);
+        goto err_plane;
      }
 
-   if (!e_plane_video_set(evhp->e_plane, EINA_TRUE, &need_wait))
+   if (!e_plane_video_set(plane, EINA_TRUE, &need_wait))
      {
-        VWR("fail set video to e_plane", evhp->base.ec);
-        goto err_set_eplane_video;
+        VWR("fail set video to e_plane", NULL);
+        goto err_plane;
      }
 
    if (need_wait)
@@ -388,15 +391,15 @@ _e_video_hwc_planes_tdm_layer_set(E_Video_Hwc_Planes *evhp)
                             _e_video_hwc_planes_cb_eplane_video_set_hook, evhp);
      }
 
-   VIN("assign layer: %p", evhp->base.ec, evhp->tdm.layer);
+   evhp->tdm.layer = layer;
+   evhp->e_plane = plane;
+
+   VIN("assign layer: %p", NULL, evhp->tdm.layer);
 
    return EINA_TRUE;
 
-err_set_eplane_video:
-   evhp->e_plane = NULL;
-err_get_eplane:
+err_plane:
    _e_video_hwc_planes_tdm_layer_usable_set(evhp->tdm.layer, EINA_TRUE);
-   evhp->tdm.layer = NULL;
 
    return EINA_FALSE;
 }
@@ -516,7 +519,7 @@ _e_video_hwc_planes_buffer_commit(E_Video_Hwc_Planes *evhp, E_Comp_Wl_Video_Buf
    ret = _tdm_layer_commit(evhp->tdm.layer, _e_video_hwc_planes_cb_commit_handler, evhp);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(ret == TDM_ERROR_NONE, EINA_FALSE);
 
-   ret = tdm_output_wait_vblank(evhp->base.output, 1, 0, _e_video_hwc_planes_cb_vblank_handler, evhp);
+   ret = tdm_output_wait_vblank(evhp->tdm.output, 1, 0, _e_video_hwc_planes_cb_vblank_handler, evhp);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(ret == TDM_ERROR_NONE, EINA_FALSE);
 
    evhp->waiting_vblank = EINA_TRUE;
@@ -581,7 +584,7 @@ _e_video_hwc_planes_available_properties_get(E_Video_Hwc_Planes *evhp,
      {
 
         /* tlayer = e_output_video_available_tdm_layer_get(evhp->e_output); */
-        tlayer = _e_video_hwc_planes_available_video_tdm_layer_get(evhp->base.output);
+        tlayer = _e_video_hwc_planes_available_video_tdm_layer_get(evhp->tdm.output);
      }
    ret = tdm_layer_get_available_properties(tlayer, props, count);
 
@@ -589,26 +592,21 @@ _e_video_hwc_planes_available_properties_get(E_Video_Hwc_Planes *evhp,
 }
 
 static Eina_Bool
-_e_video_hwc_planes_set(E_Video_Hwc_Planes *evhp)
+_e_video_hwc_planes_init(E_Video_Hwc_Planes *evhp, E_Output *output)
 {
    const tdm_prop *props;
    int i, count = 0;
 
-   /* if (e_output_video_capability_get(evhp->e_output)) */
-   if (_tdm_output_video_layer_exists(evhp->base.output))
-     {
-        /* If tdm offers video layers, we will assign a tdm layer when showing */
-        ;;;
-     }
-   else if (_e_video_hwc_planes_tdm_layer_set(evhp))
+   /* If tdm offers video layers, we will assign a tdm layer when showing */
+   if (!_tdm_output_video_layer_exists(output->toutput))
      {
-        /* If tdm doesn't offer video layers, we assign a tdm layer now. If failed,
-         * video will be displayed via the UI rendering path.
-         */
-        ;;;
+        /* If tdm doesn't offer video layers, we assign a tdm layer now. If
+         * failed, video will be displayed via the UI rendering path. */
+        if (!_e_video_hwc_planes_tdm_layer_set(evhp))
+          return EINA_FALSE;
      }
-   else
-     return EINA_FALSE;
+
+   evhp->tdm.mute_id = -1;
 
    _e_video_hwc_planes_available_properties_get(evhp, &props, &count);
    for (i = 0; i < count; i++)
@@ -623,20 +621,6 @@ _e_video_hwc_planes_set(E_Video_Hwc_Planes *evhp)
    return EINA_TRUE;
 }
 
-static Eina_Bool
-_e_video_hwc_planes_init(E_Video_Hwc_Planes *evhp)
-{
-   evhp->tdm.mute_id = -1;
-
-   if (!_e_video_hwc_planes_set(evhp))
-     {
-        VER("Failed to init hwc_planes", evhp->base.ec);
-        return EINA_FALSE;
-     }
-
-   return EINA_TRUE;
-}
-
 static void
 _e_video_hwc_planes_destroy(E_Video_Hwc_Planes *evhp)
 {
@@ -772,7 +756,7 @@ _e_video_hwc_planes_prop_name_get_by_id(E_Video_Hwc_Planes *evhp, unsigned int i
    const tdm_prop *props;
    int i, count = 0;
 
-   layer = _tdm_output_video_layer_get(evhp->base.output);
+   layer = _tdm_output_video_layer_get(evhp->tdm.output);
    tdm_layer_get_available_properties(layer, &props, &count);
    for (i = 0; i < count; i++)
      {
@@ -985,28 +969,26 @@ _e_video_hwc_planes_iface_available_properties_get(E_Video_Comp_Iface *iface, co
 }
 
 EINTERN E_Video_Hwc *
-e_video_hwc_planes_create(void)
+e_video_hwc_planes_create(E_Output *output, E_Client *ec)
 {
    E_Video_Hwc_Planes *evhp;
 
-   evhp = calloc(1, sizeof *evhp);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(evhp, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
 
-   return (E_Video_Hwc *)evhp;
-}
+   VIN("Create HWC Planes backend", ec);
 
-EINTERN Eina_Bool
-e_video_hwc_planes_init(E_Video_Hwc *evh)
-{
-   E_Video_Hwc_Planes *evhp;
+   evhp = E_NEW(E_Video_Hwc_Planes, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(evhp, NULL);
 
-   INF("Initializing HWC Planes mode");
+   evhp->base.e_output = output;
+   evhp->tdm.output = output->toutput;
 
-   evhp = (E_Video_Hwc_Planes *)evh;
-   if (!_e_video_hwc_planes_init(evhp))
+   if (!_e_video_hwc_planes_init(evhp, output))
      {
         ERR("Failed to init 'E_Video_Hwc_Planes'");
-        return EINA_FALSE;
+        free(evhp);
+        return NULL;
      }
 
    _e_video_hwc_planes_ec_event_init(evhp);
@@ -1020,7 +1002,7 @@ e_video_hwc_planes_init(E_Video_Hwc *evh)
    evhp->base.backend.commit_data_release = NULL;
    evhp->base.backend.tbm_surface_get = NULL;
 
-   return EINA_TRUE;
+   return (E_Video_Hwc *)evhp;
 }
 
 EINTERN Eina_Bool
@@ -1075,7 +1057,7 @@ e_video_hwc_planes_check_if_pp_needed(E_Video_Hwc *evh)
 
    evhp = (E_Video_Hwc_Planes *)evh;
 
-   tdm_layer *layer = _tdm_output_video_layer_get(evhp->base.output);
+   tdm_layer *layer = _tdm_output_video_layer_get(evhp->tdm.output);
 
    tdm_layer_get_capabilities(layer, &capabilities);
 
index 9ecc0b0da7fe8951e5d9c59abded39a04859e13d..45bbd147a4590885a36c7334de674ed72f87b9ef 100644 (file)
@@ -92,23 +92,6 @@ _e_video_frame_buffer_show(E_Video_Hwc_Windows *evhw, E_Comp_Wl_Video_Buf *vbuf)
    return EINA_TRUE;
 }
 
-static Eina_Bool
-_e_video_hwc_windows_init(E_Video_Hwc_Windows *evhw)
-{
-   E_Hwc *hwc;
-   E_Hwc_Window *hwc_window;
-
-   hwc = evhw->base.e_output->hwc;
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
-   hwc_window = e_hwc_window_new(hwc, evhw->base.ec, E_HWC_WINDOW_STATE_VIDEO);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
-
-   evhw->hwc_window = hwc_window;
-   evhw->hwc = hwc;
-
-   return EINA_TRUE;
-}
-
 static void
 _e_video_destroy(E_Video_Hwc_Windows *evhw)
 {
@@ -387,30 +370,30 @@ _e_video_hwc_windows_iface_tbm_surface_get(E_Video_Comp_Iface *iface)
 }
 
 EINTERN E_Video_Hwc *
-e_video_hwc_windows_create(void)
+e_video_hwc_windows_create(E_Output *output, E_Client *ec)
 {
    E_Video_Hwc_Windows *evhw;
 
-   evhw = calloc(1, sizeof *evhw);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(evhw, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
 
-   return (E_Video_Hwc *)evhw;
-}
-
-EINTERN Eina_Bool
-e_video_hwc_windows_init(E_Video_Hwc *evh)
-{
-   E_Video_Hwc_Windows *evhw;
+   VIN("Create HWC Windows backend", ec);
 
-   INF("Initializing HWC Windows mode");
+   evhw = E_NEW(E_Video_Hwc_Windows, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(evhw, NULL);
 
-   evhw = (E_Video_Hwc_Windows *)evh;
-   EINA_SAFETY_ON_NULL_RETURN_VAL(evhw, EINA_FALSE);
+   evhw->hwc = output->hwc;
+   if (!evhw->hwc)
+     {
+        free(evhw);
+        return NULL;
+     }
 
-   if (!_e_video_hwc_windows_init(evhw))
+   evhw->hwc_window = e_hwc_window_new(evhw->hwc, ec, E_HWC_WINDOW_STATE_VIDEO);
+   if (!evhw->hwc_window)
      {
-        ERR("Failed to init 'E_Video_Hwc_Windows'");
-        return EINA_FALSE;
+        free(evhw);
+        return NULL;
      }
 
    _e_video_hwc_windows_ec_event_init(evhw);
@@ -424,7 +407,7 @@ e_video_hwc_windows_init(E_Video_Hwc *evh)
    evhw->base.backend.commit_data_release = _e_video_hwc_windows_iface_commit_data_release;
    evhw->base.backend.tbm_surface_get = _e_video_hwc_windows_iface_tbm_surface_get;
 
-   return EINA_TRUE;
+   return (E_Video_Hwc *)evhw;
 }
 
 EINTERN tbm_surface_h