e_hwc_windows: remove duplication code about pp info set 56/226856/3
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 6 Mar 2020 04:22:42 +0000 (13:22 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 10 Mar 2020 11:29:10 +0000 (11:29 +0000)
use _e_hwc_windows_pp_info_set function for pp info set.

Change-Id: I98ce36d0f85490b6e8a44a671934176ba58fdd89
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/bin/e_hwc_windows.c

index b6aa2d6..1aa2150 100644 (file)
@@ -1618,57 +1618,71 @@ done:
 }
 
 static Eina_Bool
-_e_hwc_pp_windows_info_set(E_Hwc *hwc, E_Hwc_Window *hwc_window,
-                                  tbm_surface_h dst_tsurface)
+_e_hwc_windows_pp_info_set(E_Hwc *hwc, tbm_surface_h src, tbm_surface_h dst,
+                           Eina_Rectangle *src_rect, Eina_Rectangle *dst_rect)
 {
    tdm_info_pp pp_info;
    tdm_error ret = TDM_ERROR_NONE;
    unsigned int aligned_width_src = 0, aligned_width_dst = 0;
-   tbm_surface_info_s surf_info_src, surf_info_dst;
-   tbm_surface_h src_tsurface = hwc_window->commit_data->buffer.tsurface;
-
-   /* when the pp_set_info is true, change the pp set_info */
-   if (!hwc->pp_set_info) return EINA_TRUE;
-   hwc->pp_set_info = EINA_FALSE;
-
-   tbm_surface_get_info(src_tsurface, &surf_info_src);
 
-   aligned_width_src = _e_hwc_windows_aligned_width_get(src_tsurface);
-   if (aligned_width_src == 0) return EINA_FALSE;
+   aligned_width_src = _e_hwc_windows_aligned_width_get(src);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(aligned_width_src != 0, EINA_FALSE);
 
-   tbm_surface_get_info(dst_tsurface, &surf_info_dst);
-
-   aligned_width_dst = _e_hwc_windows_aligned_width_get(dst_tsurface);
-   if (aligned_width_dst == 0) return EINA_FALSE;
+   aligned_width_dst = _e_hwc_windows_aligned_width_get(dst);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(aligned_width_dst != 0, EINA_FALSE);
 
    pp_info.src_config.size.h = aligned_width_src;
-   pp_info.src_config.size.v = surf_info_src.height;
-   pp_info.src_config.format = surf_info_src.format;
+   pp_info.src_config.size.v = tbm_surface_get_height(src);
+   pp_info.src_config.format = tbm_surface_get_format(src);
+   pp_info.src_config.pos.x = src_rect->x;
+   pp_info.src_config.pos.y = src_rect->y;
+   pp_info.src_config.pos.w = src_rect->w;
+   pp_info.src_config.pos.h = src_rect->h;
 
    pp_info.dst_config.size.h = aligned_width_dst;
-   pp_info.dst_config.size.v = surf_info_dst.height;
-   pp_info.dst_config.format = surf_info_dst.format;
+   pp_info.dst_config.size.v = tbm_surface_get_height(dst);
+   pp_info.dst_config.format = tbm_surface_get_format(dst);
+   pp_info.dst_config.pos.x = dst_rect->x;
+   pp_info.dst_config.pos.y = dst_rect->y;
+   pp_info.dst_config.pos.w = dst_rect->w;
+   pp_info.dst_config.pos.h = dst_rect->h;
 
    pp_info.transform = TDM_TRANSFORM_NORMAL;
    pp_info.sync = 0;
    pp_info.flags = 0;
 
-   pp_info.src_config.pos.x = hwc->pp_rect.x;
-   pp_info.src_config.pos.y = hwc->pp_rect.y;
-   pp_info.src_config.pos.w = hwc->pp_rect.w;
-   pp_info.src_config.pos.h = hwc->pp_rect.h;
-   pp_info.dst_config.pos.x = 0;
-   pp_info.dst_config.pos.y = 0;
-   pp_info.dst_config.pos.w = surf_info_dst.width;
-   pp_info.dst_config.pos.h = surf_info_dst.height;
-
    ret = tdm_pp_set_info(hwc->tpp, &pp_info);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(ret == TDM_ERROR_NONE, EINA_FALSE);
 
-   EHWSTRACE("PP Info  src_rect(%d,%d),(%d,%d), dst_rect(%d,%d),(%d,%d)",
+   EHWSTRACE("PP Info  src(%d,%d)(%d,%d)size(%dx%d), dst(%d,%d)(%d,%d)size(%dx%d)",
              NULL, hwc,
              pp_info.src_config.pos.x, pp_info.src_config.pos.y, pp_info.src_config.pos.w, pp_info.src_config.pos.h,
-             pp_info.dst_config.pos.x, pp_info.dst_config.pos.y, pp_info.dst_config.pos.w, pp_info.dst_config.pos.h);
+             pp_info.src_config.size.h, pp_info.src_config.size.v,
+             pp_info.dst_config.pos.x, pp_info.dst_config.pos.y, pp_info.dst_config.pos.w, pp_info.dst_config.pos.h,
+             pp_info.dst_config.size.h, pp_info.dst_config.size.v);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_e_hwc_pp_windows_info_set(E_Hwc *hwc, E_Hwc_Window *hwc_window, tbm_surface_h dst_tsurface)
+{
+   tbm_surface_h src_tsurface = hwc_window->commit_data->buffer.tsurface;
+   Eina_Rectangle dst_rect;
+
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(hwc->pp_set_info == EINA_TRUE, EINA_TRUE);
+
+   dst_rect.x = 0;
+   dst_rect.y = 0;
+   dst_rect.w = tbm_surface_get_width(dst_tsurface);
+   dst_rect.h = tbm_surface_get_height(dst_tsurface);
+
+   if (_e_hwc_windows_pp_info_set(hwc, src_tsurface, dst_tsurface, &hwc->pp_rect, &dst_rect) != EINA_TRUE)
+     {
+        EHWSERR("fail pp info set", hwc);
+        return EINA_FALSE;
+     }
+   hwc->pp_set_info = EINA_FALSE;
 
    return EINA_TRUE;
 }
@@ -3108,13 +3122,11 @@ _e_hwc_windows_external_pp_commit_handler(tdm_pp *pp, tbm_surface_h src, tbm_sur
 }
 
 static Eina_Bool
-_e_hwc_windows_pp_set(E_Hwc *hwc, tbm_surface_h src, tbm_surface_h dst,
-                       Eina_Rectangle *src_rect, Eina_Rectangle *dst_rect, e_hwc_pp_done_handler func,
-                       E_Hwc_Window_Queue_Buffer *queue_buffer, E_Output_Display_Mode display_mode)
+_e_hwc_windows_external_pp_set(E_Hwc *hwc, tbm_surface_h src, tbm_surface_h dst,
+                               Eina_Rectangle *src_rect, Eina_Rectangle *dst_rect, e_hwc_pp_done_handler func,
+                               E_Hwc_Window_Queue_Buffer *queue_buffer, E_Output_Display_Mode display_mode)
 {
-   tdm_info_pp pp_info;
-   tdm_error error = TDM_ERROR_NONE;
-   tbm_surface_info_s src_info, dst_info;
+   tdm_error ret = TDM_ERROR_NONE;
    E_Hwc_Windows_Pp_Data *pp_data = NULL;
 
    pp_data = E_NEW(E_Hwc_Windows_Pp_Data, 1);
@@ -3126,51 +3138,27 @@ _e_hwc_windows_pp_set(E_Hwc *hwc, tbm_surface_h src, tbm_surface_h dst,
    /* when the pp_set_info is true, change the pp set_info */
    if (hwc->pp_set_info)
      {
-        hwc->pp_set_info = EINA_FALSE;
-
-        tbm_surface_get_info(src, &src_info);
-        tbm_surface_get_info(dst, &dst_info);
-
-        pp_info.src_config.size.h = _e_hwc_windows_aligned_width_get(src);
-        pp_info.src_config.size.v = src_info.height;
-        pp_info.src_config.format = src_info.format;
-        pp_info.src_config.pos.x = src_rect->x;
-        pp_info.src_config.pos.y = src_rect->y;
-        pp_info.src_config.pos.w = src_rect->w;
-        pp_info.src_config.pos.h = src_rect->h;
-
-        pp_info.dst_config.size.h = _e_hwc_windows_aligned_width_get(dst);
-        pp_info.dst_config.size.v = dst_info.height;
-        pp_info.dst_config.format = dst_info.format;
-        pp_info.dst_config.pos.x = dst_rect->x;
-        pp_info.dst_config.pos.y = dst_rect->y;
-        pp_info.dst_config.pos.w = dst_rect->w;
-        pp_info.dst_config.pos.h = dst_rect->h;
-
-        pp_info.transform = TDM_TRANSFORM_NORMAL;
-        pp_info.sync = 0;
-        pp_info.flags = 0;
-
-        error = tdm_pp_set_info(hwc->tpp, &pp_info);
-        EINA_SAFETY_ON_FALSE_GOTO(error == TDM_ERROR_NONE, pp_fail);
+        if (_e_hwc_windows_pp_info_set(hwc, src, dst, src_rect, dst_rect) != EINA_TRUE)
+          {
+              EHWSERR("fail pp info set", hwc);
+              goto pp_fail;
+          }
 
-        EHWSTRACE("PP Info  src_rect(%d,%d),(%d,%d), dst_rect(%d,%d),(%d,%d)",
-                  NULL, hwc,
-                  pp_info.src_config.pos.x, pp_info.src_config.pos.y, pp_info.src_config.pos.w, pp_info.src_config.pos.h,
-                  pp_info.dst_config.pos.x, pp_info.dst_config.pos.y, pp_info.dst_config.pos.w, pp_info.dst_config.pos.h);
+        hwc->pp_set_info = EINA_FALSE;
      }
 
    pp_data->hwc = hwc;
    pp_data->queue_buffer = queue_buffer;
    pp_data->func = func;
    pp_data->mode = display_mode;
-   error = tdm_pp_set_done_handler(hwc->tpp, _e_hwc_windows_external_pp_commit_handler, pp_data);
+   ret = tdm_pp_set_done_handler(hwc->tpp, _e_hwc_windows_external_pp_commit_handler, pp_data);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == TDM_ERROR_NONE, pp_fail);
 
-   error = tdm_pp_attach(hwc->tpp, src, dst);
-   EINA_SAFETY_ON_FALSE_GOTO(error == TDM_ERROR_NONE, pp_fail);
+   ret = tdm_pp_attach(hwc->tpp, src, dst);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == TDM_ERROR_NONE, pp_fail);
 
-   error = tdm_pp_commit(hwc->tpp);
-   EINA_SAFETY_ON_FALSE_GOTO(error == TDM_ERROR_NONE, pp_fail);
+   ret = tdm_pp_commit(hwc->tpp);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == TDM_ERROR_NONE, pp_fail);
 
    hwc->wait_commit = EINA_TRUE;
    hwc->pp_commit = EINA_TRUE;
@@ -3270,8 +3258,8 @@ _e_hwc_windows_external_pp_commit(E_Hwc *hwc, E_Output_Display_Mode display_mode
         hwc->pp_set_info = EINA_TRUE;
      }
 
-   if (!_e_hwc_windows_pp_set(hwc, src, dst, &src_rect, &dst_rect,
-                              _e_hwc_windows_external_pp_handler, queue_buffer, display_mode))
+   if (!_e_hwc_windows_external_pp_set(hwc, src, dst, &src_rect, &dst_rect,
+                                       _e_hwc_windows_external_pp_handler, queue_buffer, display_mode))
      {
         e_hwc_window_queue_buffer_release(queue, queue_buffer);
         return EINA_FALSE;