e_hwc_planes: support external output commit 42/213442/5
authorJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 5 Sep 2019 08:30:50 +0000 (17:30 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 5 Sep 2019 09:49:53 +0000 (18:49 +0900)
Change-Id: I1fc16a4087c5f63932925a5c5e1a22e8cea09d7e
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/bin/e_hwc_planes.c
src/bin/e_plane.c

index 8da83ff..1be7af7 100644 (file)
@@ -1,5 +1,6 @@
 #include "e.h"
 #include "services/e_service_quickpanel.h"
+#include <wayland-tbm-server.h>
 
 EINTERN Eina_Bool
 e_hwc_planes_init(void)
@@ -820,7 +821,8 @@ e_hwc_planes_mirror_unset(E_Hwc *hwc)
    ep = e_output_fb_target_get(output);
    EINA_SAFETY_ON_NULL_RETURN(ep);
 
-   e_plane_external_unset(ep);
+   if (e_output_display_mode_get(hwc->output) == E_OUTPUT_DISPLAY_MODE_NONE)
+     e_plane_external_unset(ep);
 
    /* remove mirror_dst list at the src_hwc */
    src_hwc->mirror_dst_hwc = eina_list_remove(src_hwc->mirror_dst_hwc, hwc);
@@ -838,69 +840,48 @@ EINTERN Eina_Bool
 e_hwc_planes_presentation_update(E_Hwc *hwc, E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
 
-#if 0
-   if (overlay)
-     {
-        Eina_Bool video_layer = EINA_FALSE;
-        tbm_format format;
-        Eina_Bool need_pp = EINA_FALSE;
+   E_Plane *ep = NULL;
+   E_Comp_Wl_Buffer *wl_buffer = NULL;
+   tbm_surface_h tsurface = NULL;
+   Eina_Rectangle rect = {0, };
+   int width = 0;
+   int height = 0;
 
-        E_EomBufferPtr eom_buff = _e_eom_buffer_create(eom_output, wl_buffer);
-        EINA_SAFETY_ON_NULL_RETURN_VAL(eom_buff, ECORE_CALLBACK_PASS_ON);
+   ep = e_output_default_fb_target_get(hwc->output);
 
-        format = tbm_surface_get_format(tbm_buffer);
-        video_layer = _e_eom_output_video_layer_find(eom_output, format);
-        if (!video_layer)
-          {
-             /* need pp */
-             need_pp = EINA_TRUE;
-             eom_output->need_overlay_pp = EINA_TRUE;
-             if (!_e_eom_pp_init(eom_output))
-               {
-                  EOERR("pp_init for overlay fail", eom_output->eout);
-                  _e_eom_buffer_destroy(eom_output, eom_buff);
-                  return ECORE_CALLBACK_PASS_ON;
-               }
-          }
-
-        if (need_pp)
-          {
-             if (eom_trace_debug)
-               EOINF("run _e_eom_presentation_pp_run", eom_output->eout);
-             _e_eom_presentation_pp_run(eom_output, tbm_buffer, eom_buff);
-          }
-        else
-          {
-             if (eom_trace_debug)
-               EOINF("run direct show", eom_output->eout);
-             _e_eom_layer_overlay_set(eom_output, tbm_buffer);
+   if (ec)
+     {
+        e_plane_ec_set(ep, ec);
+
+        /* update the target_buffer */
+        wl_buffer = e_pixmap_resource_get(ec->pixmap);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(wl_buffer, EINA_FALSE);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(wl_buffer->resource, EINA_FALSE);
+
+        tsurface = wayland_tbm_server_get_surface(e_comp->wl_comp_data->tbm.server, wl_buffer->resource);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(tsurface, EINA_FALSE);
+
+        ep->tsurface = tsurface;
+
+        e_output_size_get(hwc->output, &width, &height);
+        rect.x = 0;
+        rect.y = 0;
+        rect.w = width;
+        rect.h = height;
+        if (!e_plane_external_set(ep, &rect, E_OUTPUT_DISPLAY_MODE_PRESENTATION))
+           {
+              ERR("e_plane_presentation_set failed.");
+              return EINA_FALSE;
+           }
 
-             if (!_e_eom_output_show(eom_output, tbm_buffer, _e_eom_tbm_buffer_release_ext_mod, eom_buff))
-               {
-                  if (eom_trace_debug)
-                    {
-                       EOINF("===============>  EXT ENDERR  tbm_buff:%p", eom_output->eout, tbm_buffer);
-                       EOINF("_e_eom_add_buff_to_show fail tbm_buff:%p", eom_output->eout, tbm_buffer);
-                    }
-                  _e_eom_buffer_destroy(eom_output, eom_buff);
-                  return ECORE_CALLBACK_PASS_ON;
-               }
-          }
+        e_comp_object_hwc_update_set(ec->frame, EINA_TRUE);
      }
    else
      {
-        E_Plane *ep = NULL;
-
-        ep = e_output_default_fb_target_get(eom_output->eout);
-
-        if (ep->prepare_ec)
-          e_plane_ec_set(ep, ec);
-
-        e_comp_object_hwc_update_set(ec->frame, EINA_TRUE);
+        e_plane_ec_set(ep, NULL);
+        e_plane_external_unset(ep);
      }
-#endif
 
    return EINA_TRUE;
 }
index 7f7fee7..4ac96fd 100644 (file)
@@ -600,6 +600,7 @@ _e_plane_external_surface_acquire(E_Plane *plane)
    tbm_surface_h tsurface = NULL;
    tdm_error ret = TDM_ERROR_NONE;
    E_Plane *plane_primary_output_fb = NULL;
+   int w, h;
 
    if (plane->display_mode == E_OUTPUT_DISPLAY_MODE_MIRROR)
      {
@@ -635,6 +636,15 @@ _e_plane_external_surface_acquire(E_Plane *plane)
 
              if ((tbm_surface_get_width(tsurface) <= 1) || (tbm_surface_get_height(tsurface) <= 1))
                return NULL;
+
+             e_output_size_get(plane->output, &w, &h);
+             if (w == 0 || h == 0)
+               return NULL;
+
+             if (tbm_surface_get_width(tsurface) != w || tbm_surface_get_height(tsurface) != h)
+               return NULL;
+
+             return plane->tsurface;
           }
         else
           return NULL;
@@ -1386,6 +1396,7 @@ _e_plane_pp_commit(E_Plane *plane, E_Plane_Commit_Data *data)
    tbm_error_e tbm_err = TBM_ERROR_NONE;
    tdm_error tdm_err = TDM_ERROR_NONE;
    tbm_surface_h tsurface = data->tsurface;
+   tdm_pos pos = {0, };
 
    if (plane_trace_debug)
      ELOGF("E_PLANE", "PP Commit  Plane(%p) zpos(%d)   tsurface(%p) tqueue(%p) wl_buffer(%p) data(%p)",
@@ -1406,6 +1417,10 @@ _e_plane_pp_commit(E_Plane *plane, E_Plane_Commit_Data *data)
         return EINA_FALSE;
      }
 
+   pos.w = tbm_surface_get_width(pp_tsurface);
+   pos.h = tbm_surface_get_height(pp_tsurface);
+   tdm_helper_clear_buffer_color(pp_tsurface, &pos, 0xff000000);
+
    if (!_e_plane_pp_info_set(plane, pp_tsurface))
      {
         ERR("fail _e_plane_pp_info_set");
@@ -1455,6 +1470,7 @@ _e_plane_sw_commit(E_Plane *plane, E_Plane_Commit_Data *data)
    Eina_Rectangle src_crop = {0, };
    Eina_Rectangle dst_crop = {0, };
    int rotate = 0;
+   tdm_pos pos = {0, };
 
    if (plane_trace_debug)
      ELOGF("E_PLANE", "PP Convert Commit  Plane(%p) zpos(%d)   tsurface(%p) tqueue(%p) wl_buffer(%p) data(%p)",
@@ -1475,6 +1491,10 @@ _e_plane_sw_commit(E_Plane *plane, E_Plane_Commit_Data *data)
         return EINA_FALSE;
      }
 
+   pos.w = tbm_surface_get_width(dst_tsurface);
+   pos.h = tbm_surface_get_height(dst_tsurface);
+   tdm_helper_clear_buffer_color(dst_tsurface, &pos, 0xff000000);
+
    src_vbuf = e_comp_wl_video_buffer_create_tbm(src_tsurface);
    if (src_vbuf == NULL)
      {
@@ -2026,11 +2046,7 @@ e_plane_fetch(E_Plane *plane)
    if (plane->wait_commit)
      return EINA_FALSE;
 
-   if (plane->is_external)
-     {
-        tsurface = _e_plane_external_surface_acquire(plane);
-     }
-   else if (plane->is_fb && !plane->ec)
+   if (plane->is_fb && !plane->ec)
      {
         if (_e_plane_fb_target_pending_commit_sync_check(plane))
           return EINA_FALSE;
@@ -3513,7 +3529,6 @@ e_plane_external_commit(E_Plane *plane)
    int w, h;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(plane, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(plane->pp_tqueue, EINA_FALSE);
 
    data = e_plane_commit_data_aquire(plane);
    if (!data) return EINA_TRUE;
@@ -3534,6 +3549,8 @@ e_plane_external_commit(E_Plane *plane)
      }
    else /* plane->display_mode == E_OUTPUT_DISPLAY_MODE_MIRROR */
      {
+        EINA_SAFETY_ON_NULL_RETURN_VAL(plane->pp_tqueue, EINA_FALSE);
+
         if (!tbm_surface_queue_can_dequeue(plane->pp_tqueue, 0))
           {
              if (plane_trace_debug)
@@ -3592,13 +3609,24 @@ e_plane_external_set(E_Plane *plane, Eina_Rectangle *rect, E_Output_Display_Mode
    plane->mirror_rect.w = rect->w;
    plane->mirror_rect.h = rect->h;
 
-   if (plane->display_mode == E_OUTPUT_DISPLAY_MODE_NONE)
+   if (display_mode == E_OUTPUT_DISPLAY_MODE_MIRROR)
      {
+        if (plane->display_mode == E_OUTPUT_DISPLAY_MODE_MIRROR)
+          {
+             DBG("already mirror mode");
+             return EINA_TRUE;
+          }
         ret = e_plane_zoom_set(plane, &plane->mirror_rect);
         EINA_SAFETY_ON_FALSE_RETURN_VAL(ret == EINA_TRUE, EINA_FALSE);
      }
-   else if (plane->display_mode == E_OUTPUT_DISPLAY_MODE_MIRROR)
-     _e_plane_pp_pending_data_remove(plane);
+   else if (display_mode == E_OUTPUT_DISPLAY_MODE_PRESENTATION)
+     {
+        if (plane->display_mode == E_OUTPUT_DISPLAY_MODE_MIRROR)
+          {
+             _e_plane_pp_pending_data_remove(plane);
+             e_plane_zoom_unset(plane);
+          }
+     }
 
    plane->display_mode = display_mode;