e_hwc_windows: add e_hwc_windows_pp_set/unset function 45/272845/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 22 Mar 2022 10:22:27 +0000 (19:22 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Fri, 25 Mar 2022 10:56:41 +0000 (19:56 +0900)
e_hwc_windows_zoom_set/unset function is used at two cases.
first case is zoom of output and second case is mirror mode.
it makes hard to understand mirror and zoom of hwc windows
e_hwc_windows_pp_set/unset function is added and
zoom and mirror mode use this function.

Change-Id: If942448cdbd1e1e07c7741ea4cb7bd53f1d51d66

src/bin/e_hwc.h
src/bin/e_hwc_windows.c
src/bin/e_hwc_windows.h

index 563281b..e7a0b68 100644 (file)
@@ -180,6 +180,9 @@ struct _E_Hwc
    tbm_surface_h        mirror_src_tsurface;
    Eina_List           *mirror_dst_hwc;
 
+   Eina_Rectangle       zoom_rect;
+   Eina_Bool            zoom_enabled;
+
    int                  norender;
 
    /* for fps */
index 02e502b..6a68241 100644 (file)
@@ -3757,7 +3757,7 @@ e_hwc_windows_pp_commit_possible_check(E_Hwc *hwc)
 }
 
 static void
-_e_hwc_windows_zoom_pp_aligned_value_get(E_Hwc *hwc, int *aligned_width, int *aligned_height)
+_e_hwc_windows_pp_aligned_value_get(E_Hwc *hwc, int *aligned_width, int *aligned_height)
 {
    if (hwc->pp_minw != -1)
      {
@@ -3779,32 +3779,31 @@ _e_hwc_windows_zoom_pp_aligned_value_get(E_Hwc *hwc, int *aligned_width, int *al
 }
 
 EINTERN Eina_Bool
-e_hwc_windows_zoom_set(E_Hwc *hwc, Eina_Rectangle *rect)
+e_hwc_windows_pp_set(E_Hwc *hwc, Eina_Rectangle *src_rect, Eina_Rectangle *dst_rect)
 {
    E_Comp_Screen *e_comp_screen = NULL;
    tdm_error ret = TDM_ERROR_NONE;
    int w, h;
-   Eina_Rectangle dst_rect;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
-
-   if ((hwc->pp_src_rect.x == rect->x) && (hwc->pp_src_rect.y == rect->y) &&
-       (hwc->pp_src_rect.w == rect->w) && (hwc->pp_src_rect.h == rect->h))
-     return EINA_TRUE;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(src_rect, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(dst_rect, EINA_FALSE);
 
    e_comp_screen = e_comp->e_comp_screen;
-   e_output_size_get(hwc->output, &w, &h);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+
+   if ((hwc->pp_src_rect.x == src_rect->x) && (hwc->pp_src_rect.y == src_rect->y) &&
+       (hwc->pp_src_rect.w == src_rect->w) && (hwc->pp_src_rect.h == src_rect->h) &&
+       (hwc->pp_dst_rect.x == dst_rect->x) && (hwc->pp_dst_rect.y == dst_rect->y) &&
+       (hwc->pp_dst_rect.w == dst_rect->w) && (hwc->pp_dst_rect.h == dst_rect->h))
+     return EINA_TRUE;
 
    if (e_comp_screen_pp_support())
      {
         if (!hwc->tpp)
           {
              hwc->tpp = tdm_display_create_pp(e_comp_screen->tdisplay, &ret);
-             if (ret != TDM_ERROR_NONE)
-               {
-                  EHWSERR("fail tdm pp create", hwc);
-                  goto fail;
-               }
+             EINA_SAFETY_ON_NULL_GOTO(hwc->tpp, fail);
 
              ret = tdm_pp_set_done_handler(hwc->tpp, _e_hwc_windows_pp_commit_handler, hwc);
              EINA_SAFETY_ON_FALSE_GOTO(ret == TDM_ERROR_NONE, fail);
@@ -3823,34 +3822,25 @@ e_hwc_windows_zoom_set(E_Hwc *hwc, Eina_Rectangle *rect)
 
    if (!hwc->pp_tqueue)
      {
+        e_output_size_get(hwc->output, &w, &h);
+
         if (e_comp_screen_pp_support())
-          _e_hwc_windows_zoom_pp_aligned_value_get(hwc, &w, &h);
+          _e_hwc_windows_pp_aligned_value_get(hwc, &w, &h);
 
         //TODO: Does e20 get the buffer flags from the tdm backend?
         hwc->pp_tqueue = tbm_surface_queue_create(3, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
-        if (!hwc->pp_tqueue)
-          {
-             EHWSERR("fail tbm_surface_queue_create", hwc);
-             goto fail;
-          }
+        EINA_SAFETY_ON_NULL_GOTO(hwc->pp_tqueue, fail);
+
         hwc->pp_queue = e_hwc_window_queue_get(hwc->pp_tqueue);
-        if (!hwc->pp_queue)
-          {
-             EHWSERR("fail e_hwc_window_queue_get", hwc);
-             goto fail;
-          }
+        EINA_SAFETY_ON_NULL_GOTO(hwc->pp_queue, fail);
+
         EHWSINF("PP Create pp_tqueue:%p", NULL, hwc, hwc->pp_tqueue);
      }
 
    _e_hwc_windows_target_window_pp_queue_set(hwc->target_hwc_window, hwc->pp_queue);
    e_hwc_windows_target_window_force_render(hwc->target_hwc_window);
 
-   dst_rect.x = 0;
-   dst_rect.y = 0;
-   dst_rect.w = w;
-   dst_rect.h = h;
-
-   _e_hwc_windows_pp_rect_set(hwc, rect, &dst_rect);
+   _e_hwc_windows_pp_rect_set(hwc, src_rect, dst_rect);
 
    return EINA_TRUE;
 
@@ -3871,7 +3861,7 @@ fail:
 }
 
 EINTERN void
-e_hwc_windows_zoom_unset(E_Hwc *hwc)
+e_hwc_windows_pp_unset(E_Hwc *hwc)
 {
    EINA_SAFETY_ON_NULL_RETURN(hwc);
 
@@ -3909,6 +3899,56 @@ e_hwc_windows_zoom_unset(E_Hwc *hwc)
    e_hwc_windows_target_window_force_render(hwc->target_hwc_window);
 }
 
+EINTERN Eina_Bool
+e_hwc_windows_zoom_set(E_Hwc *hwc, Eina_Rectangle *rect)
+{
+   Eina_Rectangle dst_rect;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc->output, EINA_FALSE);
+
+   if (hwc->mirror_src_hwc)
+     {
+        ERR("not support zoom in mirror mode");
+        return EINA_FALSE;
+     }
+
+   memcpy(&hwc->zoom_rect, rect, sizeof(Eina_Rectangle));
+
+   dst_rect.x = 0;
+   dst_rect.y = 0;
+   dst_rect.w = hwc->output->config.geom.w;
+   dst_rect.h = hwc->output->config.geom.h;
+
+   if (!e_hwc_windows_pp_set(hwc, rect, &dst_rect))
+     {
+        ERR("fail to e_hwc_windows_pp_set");
+        return EINA_FALSE;
+     }
+
+   hwc->zoom_enabled = EINA_TRUE;
+
+   return EINA_TRUE;
+}
+
+EINTERN void
+e_hwc_windows_zoom_unset(E_Hwc *hwc)
+{
+   EINA_SAFETY_ON_NULL_RETURN(hwc);
+
+   CLEAR(hwc->zoom_rect);
+
+   hwc->zoom_enabled = EINA_FALSE;
+
+   if (hwc->mirror_src_hwc)
+     {
+        ERR("not support zoom in mirror mode");
+        return;
+     }
+
+   e_hwc_windows_pp_unset(hwc);
+}
+
 // add hwc_window to the render_list
 EINTERN void
 e_hwc_windows_rendered_window_add(E_Hwc_Window *hwc_window)
@@ -4304,22 +4344,34 @@ e_hwc_windows_debug_info_get(Eldbus_Message_Iter *iter, E_Hwc_Wins_Debug_Cmd cmd
 EINTERN Eina_Bool
 e_hwc_windows_mirror_set(E_Hwc *hwc, E_Hwc *src_hwc)
 {
-   Eina_Rectangle rect;
+   Eina_Rectangle src_rect, dst_rect;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc->output, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(src_hwc, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(src_hwc->output, EINA_FALSE);
 
-   EHWSINF("e_hwc_windows_mirror_set src_hwc:%p", NULL, hwc, src_hwc);
+   if (hwc->zoom_enabled)
+     {
+        ERR("not support mirror in zoom mode");
+        return EINA_FALSE;
+     }
 
-   rect.x = hwc->output->config.geom.x;
-   rect.y = hwc->output->config.geom.y;
-   rect.w = hwc->output->config.geom.w;
-   rect.h = hwc->output->config.geom.h;
+   src_rect.x = src_hwc->output->config.geom.x;
+   src_rect.y = src_hwc->output->config.geom.y;
+   src_rect.w = src_hwc->output->config.geom.w;
+   src_rect.h = src_hwc->output->config.geom.h;
+
+   if (!_e_hwc_windows_capture_position_get(src_hwc->output, src_rect.w, src_rect.h,
+                                            &dst_rect))
+     {
+        ERR("fail to _e_hwc_windows_capture_position_get");
+        return EINA_FALSE;
+     }
 
-   /* set the zoom to the hwc. */
-   if (!e_hwc_windows_zoom_set(hwc, &rect))
+   if (!e_hwc_windows_pp_set(hwc, &src_rect, &dst_rect))
      {
-        EHWSERR("e_hwc_windows_zoom_set failed.", hwc);
+        EHWSERR("e_hwc_windows_pp_set failed.", hwc);
         return EINA_FALSE;
      }
 
@@ -4332,6 +4384,8 @@ e_hwc_windows_mirror_set(E_Hwc *hwc, E_Hwc *src_hwc)
    /* add mirror_dst list to the src_hwc */
    src_hwc->mirror_dst_hwc = eina_list_append(src_hwc->mirror_dst_hwc, hwc);
 
+   EHWSINF("e_hwc_windows_mirror_set src_hwc:%p", NULL, hwc, src_hwc);
+
    return EINA_TRUE;
 }
 
@@ -4345,17 +4399,21 @@ e_hwc_windows_mirror_unset(E_Hwc *hwc)
    src_hwc = hwc->mirror_src_hwc;
    EINA_SAFETY_ON_NULL_RETURN(src_hwc);
 
-   /* unset the zoom. */
-   if (e_output_display_mode_get(hwc->output) != E_OUTPUT_DISPLAY_MODE_MIRROR)
-     e_hwc_windows_zoom_unset(hwc);
+
+   /* remove mirror_src at the hwc */
+   hwc->mirror_src_hwc = NULL;
+   hwc->mirror_src_tsurface = NULL;
 
    /* remove mirror_dst list at the src_hwc */
    src_hwc->mirror_dst_hwc = eina_list_remove(src_hwc->mirror_dst_hwc, hwc);
 
-   /* remove mirror_src at the hwc */
-   hwc->mirror_src_hwc = NULL;
+   if (hwc->zoom_enabled)
+     {
+        ERR("not support mirror in zoom mode");
+        return;
+     }
 
-   hwc->mirror_src_tsurface = NULL;
+   e_hwc_windows_pp_unset(hwc);
 
    EHWSINF("e_hwc_windows_mirror_unset", NULL, hwc);
 }
index 99e5953..1745044 100644 (file)
@@ -63,5 +63,8 @@ EINTERN Eina_Bool            e_hwc_windows_fence_enabled_get(E_Hwc *hwc);
 
 EINTERN void                 e_hwc_windows_target_window_force_render(E_Hwc_Window_Target *target_hwc_window);
 
+EINTERN Eina_Bool            e_hwc_windows_pp_set(E_Hwc *hwc, Eina_Rectangle *src_rect, Eina_Rectangle *dst_rect);
+EINTERN void                 e_hwc_windows_pp_unset(E_Hwc *hwc);
+
 #endif
 #endif