video: Added 'E_Video_Hwc_Iface' to make interface for HWC backend. 23/204523/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 22 Apr 2019 10:15:02 +0000 (19:15 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Wed, 24 Apr 2019 06:34:32 +0000 (15:34 +0900)
Change-Id: I510440b2c76a71394d1bd921c0b829af227d386f

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 ca8aedb1ea6ef86e63f3575c9a124e315b771f0a..3f3013820e17900e27135ad9c220cfb4b5b2d9d2 100644 (file)
@@ -69,10 +69,7 @@ _e_video_hwc_current_fb_update(E_Video_Hwc *evh)
 
    if (_e_video_hwc_can_commit(evh))
      {
-        if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-          displaying_buffer = e_video_hwc_planes_displaying_buffer_get(evh);
-        else
-          displaying_buffer = e_video_hwc_windows_displaying_buffer_get(evh);
+        displaying_buffer = evh->backend.displaying_buffer_get(evh);
 
         EINA_LIST_FOREACH(evh->committed_list, l, vbuf)
           {
@@ -127,18 +124,12 @@ static void
 _e_video_hwc_wait_buffer_commit(E_Video_Hwc *evh)
 {
    E_Comp_Wl_Video_Buf *vbuf;
-   Eina_Bool res;
 
    vbuf = _e_video_hwc_buffer_dequeue(evh);
    if (!vbuf)
      return;
 
-   if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-     res = e_video_hwc_planes_commit_available_check(evh);
-   else
-     res = e_video_hwc_windows_commit_available_check(evh);
-
-   if (!res)
+   if (!evh->backend.commit_available_check(evh))
      return;
 
    _e_video_hwc_buffer_commit(evh, vbuf);
@@ -147,19 +138,12 @@ _e_video_hwc_wait_buffer_commit(E_Video_Hwc *evh)
 static void
 _e_video_hwc_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf)
 {
-   Eina_Bool res;
-
    evh->committed_list = eina_list_append(evh->committed_list, vbuf);
 
    if (!_e_video_hwc_can_commit(evh))
      goto no_commit;
 
-   if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-     res = e_video_hwc_planes_buffer_commit(evh, vbuf);
-   else
-     res = e_video_hwc_windows_buffer_commit(evh, vbuf);
-
-   if (!res)
+   if (!evh->backend.buffer_commit(evh, vbuf))
      goto no_commit;
 
    return;
@@ -172,8 +156,6 @@ no_commit:
 static void
 _e_video_hwc_buffer_show(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf, unsigned int transform)
 {
-   Eina_Bool res;
-
    vbuf->content_t = transform;
 
    e_comp_wl_video_buffer_set_use(vbuf, EINA_TRUE);
@@ -181,12 +163,7 @@ _e_video_hwc_buffer_show(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf, unsigned i
    if (vbuf->comp_buffer)
      e_comp_wl_buffer_reference(&vbuf->buffer_ref, vbuf->comp_buffer);
 
-   if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-     res = e_video_hwc_planes_commit_available_check(evh);
-   else
-     res = e_video_hwc_windows_commit_available_check(evh);
-
-   if (!res)
+   if (!evh->backend.commit_available_check(evh))
      {
         _e_video_hwc_buffer_enqueue(evh, vbuf);
         return;
@@ -231,12 +208,7 @@ _e_video_hwc_input_buffer_cb_free(E_Comp_Wl_Video_Buf *vbuf, void *data)
      }
 
    if (need_hide)
-     {
-        if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-          e_video_hwc_planes_buffer_commit(evh, NULL);
-        else
-          e_video_hwc_windows_buffer_commit(evh, NULL);
-     }
+     evh->backend.buffer_commit(evh, NULL);
 }
 
 static E_Comp_Wl_Video_Buf *
@@ -365,12 +337,7 @@ _e_video_hwc_hide(E_Video_Hwc *evh)
    E_Comp_Wl_Video_Buf *vbuf;
 
    if (evh->current_fb || evh->committed_list)
-     {
-        if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-          e_video_hwc_planes_buffer_commit(evh, NULL);
-        else
-          e_video_hwc_windows_buffer_commit(evh, NULL);
-     }
+     evh->backend.buffer_commit(evh, NULL);
 
    if (evh->current_fb)
      {
@@ -1119,7 +1086,6 @@ _e_video_hwc_render(E_Video_Hwc *evh, const char *func)
    E_Comp_Wl_Video_Buf *pp_buffer = NULL;
    E_Comp_Wl_Video_Buf *input_buffer = NULL;
    E_Client *topmost;
-   Eina_Bool res;
 
    EINA_SAFETY_ON_NULL_RETURN(evh->ec);
 
@@ -1171,12 +1137,7 @@ _e_video_hwc_render(E_Video_Hwc *evh, const char *func)
 
    _e_video_hwc_input_buffer_valid((E_Video_Hwc *)evh, comp_buffer);
 
-   if (evh->hwc_policy == E_HWC_POLICY_PLANES)
-     res = e_video_hwc_planes_check_if_pp_needed(evh);
-   else
-     res = e_video_hwc_windows_check_if_pp_needed(evh);
-
-   if (!res)
+   if (!evh->backend.check_if_pp_needed(evh))
      {
         /* 1. non converting case */
         input_buffer = _e_video_hwc_input_buffer_get(evh, comp_buffer, EINA_TRUE);
@@ -1448,7 +1409,7 @@ _e_video_hwc_iface_destroy(E_Video_Comp_Iface *iface)
    if (evh->pp)
      tdm_pp_destroy(evh->pp);
 
-   evh->backend.destroy(&evh->backend);
+   evh->backend.destroy(evh);
 }
 
 static Eina_Bool
@@ -1492,9 +1453,7 @@ _e_video_hwc_iface_property_get(E_Video_Comp_Iface *iface, unsigned int id, tdm_
 {
    IFACE_ENTRY;
 
-   if (evh->backend.property_get)
-     return evh->backend.property_get(&evh->backend, id, value);
-   return EINA_FALSE;
+   return evh->backend.property_get(evh, id, value);
 }
 
 static Eina_Bool
@@ -1502,9 +1461,7 @@ _e_video_hwc_iface_property_set(E_Video_Comp_Iface *iface, unsigned int id, tdm_
 {
    IFACE_ENTRY;
 
-   if (evh->backend.property_set)
-     return evh->backend.property_set(&evh->backend, id, value);
-   return EINA_FALSE;
+   return evh->backend.property_set(evh, id, value);
 }
 
 static Eina_Bool
@@ -1512,9 +1469,9 @@ _e_video_hwc_iface_property_delay_set(E_Video_Comp_Iface *iface, unsigned int id
 {
    IFACE_ENTRY;
 
-   if (evh->backend.property_delay_set)
-     return evh->backend.property_delay_set(&evh->backend, id, value);
-   return EINA_FALSE;
+   if (evh->hwc_policy != E_HWC_POLICY_PLANES)
+     return EINA_FALSE;
+   return e_video_hwc_planes_property_delay_set(evh, id, value);
 }
 
 static Eina_Bool
@@ -1522,9 +1479,7 @@ _e_video_hwc_iface_available_properties_get(E_Video_Comp_Iface *iface, const tdm
 {
    IFACE_ENTRY;
 
-   if (evh->backend.available_properties_get)
-     return evh->backend.available_properties_get(&evh->backend, props, count);
-   return EINA_FALSE;
+   return evh->backend.available_properties_get(evh, props, count);
 }
 
 static Eina_Bool
@@ -1532,9 +1487,9 @@ _e_video_hwc_iface_info_get(E_Video_Comp_Iface *iface, E_Client_Video_Info *info
 {
    IFACE_ENTRY;
 
-   if (evh->backend.info_get)
-     return evh->backend.info_get(&evh->backend, info);
-   return EINA_FALSE;
+   if (evh->hwc_policy != E_HWC_POLICY_WINDOWS)
+     return EINA_FALSE;
+   return e_video_hwc_windows_info_get(evh, info);
 }
 
 static Eina_Bool
@@ -1542,9 +1497,9 @@ _e_video_hwc_iface_commit_data_release(E_Video_Comp_Iface *iface, unsigned int s
 {
    IFACE_ENTRY;
 
-   if (evh->backend.commit_data_release)
-     return evh->backend.commit_data_release(&evh->backend, sequence, tv_sec, tv_usec);
-   return EINA_FALSE;
+   if (evh->hwc_policy != E_HWC_POLICY_WINDOWS)
+     return EINA_FALSE;
+   return e_video_hwc_windows_commit_data_release(evh, sequence, tv_sec, tv_usec);
 }
 
 static tbm_surface_h
@@ -1552,9 +1507,9 @@ _e_video_hwc_iface_tbm_surface_get(E_Video_Comp_Iface *iface)
 {
    IFACE_ENTRY;
 
-   if (evh->backend.tbm_surface_get)
-     return evh->backend.tbm_surface_get(&evh->backend);
-   return NULL;
+   if (evh->hwc_policy != E_HWC_POLICY_WINDOWS)
+     return NULL;
+   return e_video_hwc_windows_tbm_surface_get(evh);
 }
 
 static E_Video_Hwc *
index 99fae16693d1eef9619c9064d92c49eb01ad657d..3bfdcf97e786f199e0ae9d0b81bb85434300804e 100644 (file)
 #endif
 
 typedef struct _E_Video_Hwc E_Video_Hwc;
+typedef struct _E_Video_Hwc_Iface E_Video_Hwc_Iface;
 typedef struct _E_Video_Hwc_Geometry E_Video_Hwc_Geometry;
 
+struct _E_Video_Hwc_Iface
+{
+   void           (*destroy)(E_Video_Hwc *evh);
+   Eina_Bool      (*property_get)(E_Video_Hwc *evh, unsigned int id, tdm_value *value);
+   Eina_Bool      (*property_set)(E_Video_Hwc *evh, unsigned int id, tdm_value value);
+   Eina_Bool      (*available_properties_get)(E_Video_Hwc *evh, const tdm_prop **props, int *count);
+   Eina_Bool      (*buffer_commit)(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf);
+   Eina_Bool      (*check_if_pp_needed)(E_Video_Hwc *evh);
+   Eina_Bool      (*commit_available_check)(E_Video_Hwc *evh);
+   tbm_surface_h  (*displaying_buffer_get)(E_Video_Hwc *evh);
+};
+
 struct _E_Video_Hwc_Geometry
 {
    int input_w, input_h;      /* input buffer's size */
@@ -31,10 +44,9 @@ struct _E_Video_Hwc_Geometry
 struct _E_Video_Hwc
 {
    E_Video_Comp_Iface iface;
+   E_Video_Hwc_Iface backend;
 
    E_Hwc_Policy hwc_policy;
-   /* FIXME: Workaround */
-   E_Video_Comp_Iface backend;
 
    E_Client *ec;
    Ecore_Window window;
@@ -77,24 +89,22 @@ struct _E_Video_Hwc
    Eina_Bool  allowed_attribute;
 };
 
-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(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);
-EINTERN tbm_surface_h   e_video_hwc_windows_displaying_buffer_get(E_Video_Hwc *evh);
-
+/* Functions for HWC */
 EINTERN void         e_video_hwc_show(E_Video_Hwc *evh);
 EINTERN void         e_video_hwc_wait_buffer_commit(E_Video_Hwc *evh);
 EINTERN void         e_video_hwc_client_mask_update(E_Video_Hwc *evh);
 EINTERN Eina_Bool    e_video_hwc_current_fb_update(E_Video_Hwc *evh);
-
 EINTERN E_Client    *e_video_hwc_client_offscreen_parent_get(E_Client *ec);
 
+/* Functions for HWC Planes */
+EINTERN E_Video_Hwc *e_video_hwc_planes_create(E_Output *output, E_Client *ec);
+EINTERN Eina_Bool    e_video_hwc_planes_properties_commit(E_Video_Hwc *evh);
+EINTERN Eina_Bool    e_video_hwc_planes_property_delay_set(E_Video_Hwc *evh, unsigned int id, tdm_value value);
+
+/* Functions for HWC Windows */
+EINTERN E_Video_Hwc *e_video_hwc_windows_create(E_Output *output, E_Client *ec);
+EINTERN Eina_Bool    e_video_hwc_windows_info_get(E_Video_Hwc *evh, E_Client_Video_Info *info);
+EINTERN Eina_Bool    e_video_hwc_windows_commit_data_release(E_Video_Hwc *evh, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec);
+EINTERN tbm_surface_h   e_video_hwc_windows_tbm_surface_get(E_Video_Hwc *evh);
+
 #endif
index 594d36ec4f83ea4cb400293e726f0d777c821c42..986669e314fab318abae9ec56bbaad9fc1830bef 100644 (file)
@@ -7,10 +7,6 @@
 
 #define CHECKING_PRIMARY_ZPOS
 
-#define IFACE_ENTRY                                      \
-   E_Video_Hwc_Planes *evhp;                              \
-   evhp = container_of(iface, E_Video_Hwc_Planes, base.backend)
-
 typedef struct _E_Video_Hwc_Planes E_Video_Hwc_Planes;
 typedef struct _E_Video_Info_Layer E_Video_Info_Layer;
 
@@ -366,6 +362,7 @@ _e_video_hwc_planes_tdm_layer_set(E_Video_Hwc_Planes *evhp)
         VWR("no available layer for evhp", NULL);
         return EINA_FALSE;
      }
+
    _e_video_hwc_planes_tdm_layer_usable_set(layer, EINA_FALSE);
 
    ret = tdm_layer_get_zpos(layer, &zpos);
@@ -870,21 +867,22 @@ _e_video_hwc_planes_ec_event_init(E_Video_Hwc_Planes *evhp)
 }
 
 static void
-_e_video_hwc_planes_iface_destroy(E_Video_Comp_Iface *iface)
+_e_video_hwc_planes_iface_destroy(E_Video_Hwc *evh)
 {
-   IFACE_ENTRY;
+   E_Video_Hwc_Planes *evhp;
 
+   evhp = (E_Video_Hwc_Planes *)evh;
    _e_video_hwc_planes_ec_event_deinit(evhp);
    _e_video_hwc_planes_destroy(evhp);
 }
 
 static Eina_Bool
-_e_video_hwc_planes_iface_property_get(E_Video_Comp_Iface *iface, unsigned int id, tdm_value *value)
+_e_video_hwc_planes_iface_property_get(E_Video_Hwc *evh, unsigned int id, tdm_value *value)
 {
+   E_Video_Hwc_Planes *evhp;
    tdm_error ret;
 
-   IFACE_ENTRY;
-
+   evhp = (E_Video_Hwc_Planes *)evh;
    ret = _tdm_layer_property_get(evhp->tdm.layer, id, value);
    if (ret != TDM_ERROR_NONE)
      return EINA_FALSE;
@@ -893,13 +891,13 @@ _e_video_hwc_planes_iface_property_get(E_Video_Comp_Iface *iface, unsigned int i
 }
 
 static Eina_Bool
-_e_video_hwc_planes_iface_property_set(E_Video_Comp_Iface *iface, unsigned int id, tdm_value value)
+_e_video_hwc_planes_iface_property_set(E_Video_Hwc *evh, unsigned int id, tdm_value value)
 {
+   E_Video_Hwc_Planes *evhp;
    Tdm_Prop_Value prop;
    const char *name;
 
-   IFACE_ENTRY;
-
+   evhp = (E_Video_Hwc_Planes *)evh;
    VIN("set layer: set_attribute", evhp->base.ec);
 
    name = _e_video_hwc_planes_prop_name_get_by_id(evhp, id);
@@ -941,26 +939,12 @@ _e_video_hwc_planes_iface_property_set(E_Video_Comp_Iface *iface, unsigned int i
 }
 
 static Eina_Bool
-_e_video_hwc_planes_iface_property_delay_set(E_Video_Comp_Iface *iface, unsigned int id, tdm_value value)
-{
-   const char *name;
-
-   IFACE_ENTRY;
-
-   name = _e_video_hwc_planes_prop_name_get_by_id(evhp, id);
-
-   _e_video_hwc_planes_property_post_set(evhp, id, name, value);
-
-   return EINA_TRUE;
-}
-
-static Eina_Bool
-_e_video_hwc_planes_iface_available_properties_get(E_Video_Comp_Iface *iface, const tdm_prop **props, int *count)
+_e_video_hwc_planes_iface_available_properties_get(E_Video_Hwc *evh, const tdm_prop **props, int *count)
 {
+   E_Video_Hwc_Planes *evhp;
    tdm_error ret;
 
-   IFACE_ENTRY;
-
+   evhp = (E_Video_Hwc_Planes *)evh;
    ret = _e_video_hwc_planes_available_properties_get(evhp, props, count);
    if (ret != TDM_ERROR_NONE)
      return EINA_FALSE;
@@ -968,77 +952,8 @@ _e_video_hwc_planes_iface_available_properties_get(E_Video_Comp_Iface *iface, co
    return EINA_TRUE;
 }
 
-EINTERN E_Video_Hwc *
-e_video_hwc_planes_create(E_Output *output, E_Client *ec)
-{
-   E_Video_Hwc_Planes *evhp;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
-
-   VIN("Create HWC Planes backend", ec);
-
-   evhp = E_NEW(E_Video_Hwc_Planes, 1);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(evhp, NULL);
-
-   evhp->base.e_output = output;
-   evhp->tdm.output = output->toutput;
-
-   if (!_e_video_hwc_planes_init(evhp, output))
-     {
-        ERR("Failed to init 'E_Video_Hwc_Planes'");
-        free(evhp);
-        return NULL;
-     }
-
-   _e_video_hwc_planes_ec_event_init(evhp);
-
-   evhp->base.backend.destroy = _e_video_hwc_planes_iface_destroy;
-   evhp->base.backend.property_get = _e_video_hwc_planes_iface_property_get;
-   evhp->base.backend.property_set = _e_video_hwc_planes_iface_property_set;
-   evhp->base.backend.property_delay_set = _e_video_hwc_planes_iface_property_delay_set;
-   evhp->base.backend.available_properties_get = _e_video_hwc_planes_iface_available_properties_get;
-   evhp->base.backend.info_get = NULL;
-   evhp->base.backend.commit_data_release = NULL;
-   evhp->base.backend.tbm_surface_get = NULL;
-
-   return (E_Video_Hwc *)evhp;
-}
-
-EINTERN Eina_Bool
-e_video_hwc_planes_properties_commit(E_Video_Hwc *evh)
-{
-   E_Video_Hwc_Planes *evhp;
-
-   evhp = (E_Video_Hwc_Planes *)evh;
-
-   /* FIXME: Is it really necessary? */
-   if (evhp->tdm.layer)
-     return EINA_TRUE;
-
-   VIN("set layer: show", evhp->base.ec);
-   if (!_e_video_hwc_planes_tdm_layer_set(evhp))
-     {
-        VER("set layer failed", evhp->base.ec);
-        return EINA_FALSE;
-     }
-
-   _tdm_layer_property_list_set(evhp->tdm.layer, evhp->tdm.prop_list);
-
-   return EINA_TRUE;
-}
-
-EINTERN tbm_surface_h
-e_video_hwc_planes_displaying_buffer_get(E_Video_Hwc *evh)
-{
-   E_Video_Hwc_Planes *evhp;
-
-   evhp = (E_Video_Hwc_Planes *)evh;
-   return _tdm_layer_displaying_buffer_get(evhp->tdm.layer, NULL);
-}
-
-EINTERN Eina_Bool
-e_video_hwc_planes_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf)
+static Eina_Bool
+_e_video_hwc_planes_iface_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf)
 {
    E_Video_Hwc_Planes *evhp;
 
@@ -1046,8 +961,8 @@ e_video_hwc_planes_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf)
    return _e_video_hwc_planes_buffer_commit(evhp, vbuf);
 }
 
-EINTERN Eina_Bool
-e_video_hwc_planes_check_if_pp_needed(E_Video_Hwc *evh)
+static Eina_Bool
+_e_video_hwc_planes_iface_check_if_pp_needed(E_Video_Hwc *evh)
 {
    E_Video_Hwc_Planes *evhp;
    int i, count = 0;
@@ -1106,11 +1021,99 @@ need_pp:
    return EINA_TRUE;
 }
 
-EINTERN Eina_Bool
-e_video_hwc_planes_commit_available_check(E_Video_Hwc *evh)
+static Eina_Bool
+_e_video_hwc_planes_iface_commit_available_check(E_Video_Hwc *evh)
 {
    E_Video_Hwc_Planes *evhp;
 
    evhp = (E_Video_Hwc_Planes *)evh;
    return !(evhp->waiting_vblank || evhp->video_plane_ready_handler);
 }
+
+static tbm_surface_h
+_e_video_hwc_planes_iface_displaying_buffer_get(E_Video_Hwc *evh)
+{
+   E_Video_Hwc_Planes *evhp;
+
+   evhp = (E_Video_Hwc_Planes *)evh;
+   return _tdm_layer_displaying_buffer_get(evhp->tdm.layer, NULL);
+}
+
+static void
+_e_video_hwc_planes_iface_set(E_Video_Hwc_Iface *iface)
+{
+   iface->destroy = _e_video_hwc_planes_iface_destroy;
+   iface->property_get = _e_video_hwc_planes_iface_property_get;
+   iface->property_set = _e_video_hwc_planes_iface_property_set;
+   iface->available_properties_get = _e_video_hwc_planes_iface_available_properties_get;
+   iface->buffer_commit = _e_video_hwc_planes_iface_buffer_commit;
+   iface->check_if_pp_needed = _e_video_hwc_planes_iface_check_if_pp_needed;
+   iface->commit_available_check = _e_video_hwc_planes_iface_commit_available_check;
+   iface->displaying_buffer_get = _e_video_hwc_planes_iface_displaying_buffer_get;
+}
+
+EINTERN E_Video_Hwc *
+e_video_hwc_planes_create(E_Output *output, E_Client *ec)
+{
+   E_Video_Hwc_Planes *evhp;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
+
+   VIN("Create HWC Planes backend", ec);
+
+   evhp = E_NEW(E_Video_Hwc_Planes, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(evhp, NULL);
+
+   evhp->base.e_output = output;
+   evhp->tdm.output = output->toutput;
+
+   if (!_e_video_hwc_planes_init(evhp, output))
+     {
+        ERR("Failed to init 'E_Video_Hwc_Planes'");
+        free(evhp);
+        return NULL;
+     }
+
+   _e_video_hwc_planes_ec_event_init(evhp);
+   _e_video_hwc_planes_iface_set(&evhp->base.backend);
+
+   return (E_Video_Hwc *)evhp;
+}
+
+EINTERN Eina_Bool
+e_video_hwc_planes_properties_commit(E_Video_Hwc *evh)
+{
+   E_Video_Hwc_Planes *evhp;
+
+   evhp = (E_Video_Hwc_Planes *)evh;
+
+   /* FIXME: Is it really necessary? */
+   if (evhp->tdm.layer)
+     return EINA_TRUE;
+
+   VIN("set layer: show", evhp->base.ec);
+   if (!_e_video_hwc_planes_tdm_layer_set(evhp))
+     {
+        VER("set layer failed", evhp->base.ec);
+        return EINA_FALSE;
+     }
+
+   _tdm_layer_property_list_set(evhp->tdm.layer, evhp->tdm.prop_list);
+
+   return EINA_TRUE;
+}
+
+EINTERN Eina_Bool
+e_video_hwc_planes_property_delay_set(E_Video_Hwc *evh, unsigned int id, tdm_value value)
+{
+   E_Video_Hwc_Planes *evhp;
+   const char *name;
+
+   evhp = (E_Video_Hwc_Planes *)evh;
+   name = _e_video_hwc_planes_prop_name_get_by_id(evhp, id);
+
+   _e_video_hwc_planes_property_post_set(evhp, id, name, value);
+
+   return EINA_TRUE;
+}
index 45bbd147a4590885a36c7334de674ed72f87b9ef..2a93ea484f1b425e713c81446c5908358d50819c 100644 (file)
@@ -5,10 +5,6 @@
 #include "e_video_internal.h"
 #include "e_video_hwc.h"
 
-#define IFACE_ENTRY                                      \
-   E_Video_Hwc_Windows *evhw;                              \
-   evhw = container_of(iface, E_Video_Hwc_Windows, base.backend)
-
 typedef struct _E_Video_Hwc_Windows E_Video_Hwc_Windows;
 
 struct _E_Video_Hwc_Windows
@@ -75,23 +71,6 @@ _e_video_hwc_windows_commit_data_set(E_Video_Hwc_Windows *evhw, E_Comp_Wl_Video_
        evhw->commit_data.info.transform);
 }
 
-static Eina_Bool
-_e_video_frame_buffer_show(E_Video_Hwc_Windows *evhw, E_Comp_Wl_Video_Buf *vbuf)
-{
-   /* show means that set the information of the buffer and the info of the hwc window */
-
-   if (!vbuf) return EINA_TRUE;
-
-   _e_video_hwc_windows_commit_data_set(evhw, vbuf);
-
-   // TODO:: this logic move to the hwc windows after hwc commit
-#if 1
-   e_video_hwc_client_mask_update((E_Video_Hwc *)evhw);
-#endif
-
-   return EINA_TRUE;
-}
-
 static void
 _e_video_destroy(E_Video_Hwc_Windows *evhw)
 {
@@ -258,21 +237,22 @@ _e_video_hwc_windows_ec_event_init(E_Video_Hwc_Windows *evhw)
 }
 
 static void
-_e_video_hwc_windows_iface_destroy(E_Video_Comp_Iface *iface)
+_e_video_hwc_windows_iface_destroy(E_Video_Hwc *evh)
 {
-   IFACE_ENTRY;
+   E_Video_Hwc_Windows *evhw;
 
+   evhw = (E_Video_Hwc_Windows *)evh;
    _e_video_hwc_windows_ec_event_deinit(evhw);
    _e_video_destroy(evhw);
 }
 
 static Eina_Bool
-_e_video_hwc_windows_iface_property_get(E_Video_Comp_Iface *iface, unsigned int id, tdm_value *value)
+_e_video_hwc_windows_iface_property_get(E_Video_Hwc *evh, unsigned int id, tdm_value *value)
 {
+   E_Video_Hwc_Windows *evhw;
    tdm_error ret;
 
-   IFACE_ENTRY;
-
+   evhw = (E_Video_Hwc_Windows *)evh;
    ret = tdm_hwc_window_get_property(evhw->hwc_window->thwc_window, id, value);
    if (ret != TDM_ERROR_NONE)
      return EINA_FALSE;
@@ -281,12 +261,12 @@ _e_video_hwc_windows_iface_property_get(E_Video_Comp_Iface *iface, unsigned int
 }
 
 static Eina_Bool
-_e_video_hwc_windows_iface_property_set(E_Video_Comp_Iface *iface, unsigned int id, tdm_value value)
+_e_video_hwc_windows_iface_property_set(E_Video_Hwc *evh, unsigned int id, tdm_value value)
 {
+   E_Video_Hwc_Windows *evhw;
    const char *name;
 
-   IFACE_ENTRY;
-
+   evhw = (E_Video_Hwc_Windows *)evh;
    VIN("set_attribute", evhw->base.ec);
 
    name = _e_video_hwc_windows_prop_name_get_by_id(evhw, id);
@@ -323,10 +303,11 @@ _e_video_hwc_windows_iface_property_set(E_Video_Comp_Iface *iface, unsigned int
 }
 
 static Eina_Bool
-_e_video_hwc_windows_iface_available_properties_get(E_Video_Comp_Iface *iface, const tdm_prop **props, int *count)
+_e_video_hwc_windows_iface_available_properties_get(E_Video_Hwc *evh, const tdm_prop **props, int *count)
 {
-   IFACE_ENTRY;
+   E_Video_Hwc_Windows *evhw;
 
+   evhw = (E_Video_Hwc_Windows *)evh;
    if (!e_hwc_windows_get_video_available_properties(evhw->hwc, props, count))
      return EINA_FALSE;
 
@@ -334,41 +315,114 @@ _e_video_hwc_windows_iface_available_properties_get(E_Video_Comp_Iface *iface, c
 }
 
 static Eina_Bool
-_e_video_hwc_windows_iface_info_get(E_Video_Comp_Iface *iface, E_Client_Video_Info *info)
+_e_video_hwc_windows_iface_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf)
 {
-   IFACE_ENTRY;
+   E_Video_Hwc_Windows *evhw;
 
-   memcpy(&info->src_config, &evhw->commit_data.info.src_config, sizeof(tdm_info_config));
-   memcpy(&info->dst_pos, &evhw->commit_data.info.dst_pos, sizeof(tdm_pos));
-   info->transform = evhw->commit_data.info.transform;
+   evhw = (E_Video_Hwc_Windows *)evh;
+
+   /* show means that set the information of the buffer and the info of the hwc window */
+
+   if (!vbuf) return EINA_TRUE;
+
+   _e_video_hwc_windows_commit_data_set(evhw, vbuf);
+
+   // TODO:: this logic move to the hwc windows after hwc commit
+#if 1
+   e_video_hwc_client_mask_update((E_Video_Hwc *)evhw);
+#endif
 
    return EINA_TRUE;
 }
 
 static Eina_Bool
-_e_video_hwc_windows_iface_commit_data_release(E_Video_Comp_Iface *iface, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec)
+_e_video_hwc_windows_iface_check_if_pp_needed(E_Video_Hwc *evh)
 {
-   E_Video_Hwc *evh;
+   E_Video_Hwc_Windows *evhw;
+   int i, count = 0;
+   const tbm_format *formats;
+   Eina_Bool found = EINA_FALSE;
+   E_Hwc *hwc;
 
-   IFACE_ENTRY;
+   evhw = (E_Video_Hwc_Windows *)evh;
+   hwc = evhw->hwc;
+   if (hwc->tdm_hwc_video_stream)
+     return EINA_FALSE;
 
-   evhw->commit_data.wait_release = EINA_FALSE;
+   if (!e_comp_screen_available_video_formats_get(&formats, &count))
+     return EINA_FALSE;
 
-   evh = (E_Video_Hwc *)evhw;
-   if (e_video_hwc_current_fb_update(evh))
-     e_video_hwc_wait_buffer_commit(evh);
+   for (i = 0; i < count; i++)
+     if (formats[i] == evhw->base.tbmfmt)
+       {
+          found = EINA_TRUE;
+          break;
+       }
+
+   if (!found)
+     {
+        if (formats && count > 0)
+          evhw->base.pp_tbmfmt = formats[0];
+        else
+          {
+             WRN("No layer format information!!!");
+             evhw->base.pp_tbmfmt = TBM_FORMAT_ARGB8888;
+          }
+        return EINA_TRUE;
+     }
+
+   if (hwc->tdm_hwc_video_scanout)
+     goto need_pp;
+
+   /* check size */
+   if (evhw->base.geo.input_r.w != evhw->base.geo.output_r.w || evhw->base.geo.input_r.h != evhw->base.geo.output_r.h)
+     if (!hwc->tdm_hwc_video_scale)
+       goto need_pp;
+
+   /* check rotate */
+   if (evhw->base.geo.transform || e_comp->e_comp_screen->rotation > 0)
+     if (!hwc->tdm_hwc_video_transform)
+       goto need_pp;
+
+   return EINA_FALSE;
+
+need_pp:
+   evhw->base.pp_tbmfmt = evhw->base.tbmfmt;
 
    return EINA_TRUE;
 }
 
+static  Eina_Bool
+_e_video_hwc_windows_iface_commit_available_check(E_Video_Hwc *evh)
+{
+   E_Video_Hwc_Windows *evhw;
+
+   evhw = (E_Video_Hwc_Windows *)evh;
+   return !evhw->commit_data.wait_release;
+}
+
 static tbm_surface_h
-_e_video_hwc_windows_iface_tbm_surface_get(E_Video_Comp_Iface *iface)
+_e_video_hwc_windows_iface_displaying_buffer_get(E_Video_Hwc *evh)
 {
-   IFACE_ENTRY;
+   E_Video_Hwc_Windows *evhw;
 
+   evhw = (E_Video_Hwc_Windows *)evh;
    return evhw->commit_data.buffer;
 }
 
+static void
+_e_video_hwc_windows_iface_set(E_Video_Hwc_Iface *iface)
+{
+   iface->destroy = _e_video_hwc_windows_iface_destroy;
+   iface->property_get = _e_video_hwc_windows_iface_property_get;
+   iface->property_set = _e_video_hwc_windows_iface_property_set;
+   iface->available_properties_get = _e_video_hwc_windows_iface_available_properties_get;
+   iface->buffer_commit = _e_video_hwc_windows_iface_buffer_commit;
+   iface->check_if_pp_needed = _e_video_hwc_windows_iface_check_if_pp_needed;
+   iface->commit_available_check = _e_video_hwc_windows_iface_commit_available_check;
+   iface->displaying_buffer_get = _e_video_hwc_windows_iface_displaying_buffer_get;
+}
+
 EINTERN E_Video_Hwc *
 e_video_hwc_windows_create(E_Output *output, E_Client *ec)
 {
@@ -397,99 +451,43 @@ e_video_hwc_windows_create(E_Output *output, E_Client *ec)
      }
 
    _e_video_hwc_windows_ec_event_init(evhw);
-
-   evhw->base.backend.destroy = _e_video_hwc_windows_iface_destroy;
-   evhw->base.backend.property_get = _e_video_hwc_windows_iface_property_get;
-   evhw->base.backend.property_set = _e_video_hwc_windows_iface_property_set;
-   evhw->base.backend.property_delay_set = NULL;
-   evhw->base.backend.available_properties_get = _e_video_hwc_windows_iface_available_properties_get;
-   evhw->base.backend.info_get = _e_video_hwc_windows_iface_info_get;
-   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;
+   _e_video_hwc_windows_iface_set(&evhw->base.backend);
 
    return (E_Video_Hwc *)evhw;
 }
 
-EINTERN tbm_surface_h
-e_video_hwc_windows_displaying_buffer_get(E_Video_Hwc *evh)
-{
-   E_Video_Hwc_Windows *evhw;
-
-   evhw = (E_Video_Hwc_Windows *)evh;
-   return evhw->commit_data.buffer;
-}
-
 EINTERN Eina_Bool
-e_video_hwc_windows_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *vbuf)
+e_video_hwc_windows_info_get(E_Video_Hwc *evh, E_Client_Video_Info *info)
 {
    E_Video_Hwc_Windows *evhw;
 
    evhw = (E_Video_Hwc_Windows *)evh;
-   return _e_video_frame_buffer_show(evhw, vbuf);
+   memcpy(&info->src_config, &evhw->commit_data.info.src_config, sizeof(tdm_info_config));
+   memcpy(&info->dst_pos, &evhw->commit_data.info.dst_pos, sizeof(tdm_pos));
+   info->transform = evhw->commit_data.info.transform;
+
+   return EINA_TRUE;
 }
 
 EINTERN Eina_Bool
-e_video_hwc_windows_check_if_pp_needed(E_Video_Hwc *evh)
+e_video_hwc_windows_commit_data_release(E_Video_Hwc *evh, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec)
 {
    E_Video_Hwc_Windows *evhw;
-   int i, count = 0;
-   const tbm_format *formats;
-   Eina_Bool found = EINA_FALSE;
-   E_Hwc *hwc;
 
    evhw = (E_Video_Hwc_Windows *)evh;
-   hwc = evhw->hwc;
-   if (hwc->tdm_hwc_video_stream)
-     return EINA_FALSE;
-
-   if (!e_comp_screen_available_video_formats_get(&formats, &count))
-     return EINA_FALSE;
-
-   for (i = 0; i < count; i++)
-     if (formats[i] == evhw->base.tbmfmt)
-       {
-          found = EINA_TRUE;
-          break;
-       }
-
-   if (!found)
-     {
-        if (formats && count > 0)
-          evhw->base.pp_tbmfmt = formats[0];
-        else
-          {
-             WRN("No layer format information!!!");
-             evhw->base.pp_tbmfmt = TBM_FORMAT_ARGB8888;
-          }
-        return EINA_TRUE;
-     }
-
-   if (hwc->tdm_hwc_video_scanout)
-     goto need_pp;
-
-   /* check size */
-   if (evhw->base.geo.input_r.w != evhw->base.geo.output_r.w || evhw->base.geo.input_r.h != evhw->base.geo.output_r.h)
-     if (!hwc->tdm_hwc_video_scale)
-       goto need_pp;
-
-   /* check rotate */
-   if (evhw->base.geo.transform || e_comp->e_comp_screen->rotation > 0)
-     if (!hwc->tdm_hwc_video_transform)
-       goto need_pp;
-
-   return EINA_FALSE;
+   evhw->commit_data.wait_release = EINA_FALSE;
 
-need_pp:
-   evhw->base.pp_tbmfmt = evhw->base.tbmfmt;
+   if (e_video_hwc_current_fb_update(evh))
+     e_video_hwc_wait_buffer_commit(evh);
 
    return EINA_TRUE;
 }
 
-EINTERN Eina_Bool
-e_video_hwc_windows_commit_available_check(E_Video_Hwc *evh)
+EINTERN tbm_surface_h
+e_video_hwc_windows_tbm_surface_get(E_Video_Hwc *evh)
 {
    E_Video_Hwc_Windows *evhw;
 
    evhw = (E_Video_Hwc_Windows *)evh;
-   return !evhw->commit_data.wait_release;
+   return evhw->commit_data.buffer;
 }