hwc_windows: update ec of hwc_window redirect after validate 68/185668/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 1 Aug 2018 09:01:30 +0000 (18:01 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 2 Aug 2018 05:04:13 +0000 (05:04 +0000)
- render_target means hwc_window is rendered on gl_compositor
- render_target is set/unset  when hwc_window is set to DEVICE/CLIENT

Change-Id: I159945670a40eb5164f15feda2eb5ef35f660b47

src/bin/e_hwc_window.c
src/bin/e_hwc_window.h
src/bin/e_hwc_windows.c

index f898b5c..d7d6f3d 100644 (file)
@@ -1079,6 +1079,7 @@ e_hwc_window_new(E_Hwc *hwc, E_Client *ec, E_Hwc_Window_State state)
    hwc_window->hwc = hwc;
    hwc_window->ec = ec;
    hwc_window->state = state;
+   hwc_window->render_target = EINA_TRUE;
 
    hwc_window->thwc_window = tdm_hwc_create_window(thwc, &error);
    if (error != TDM_ERROR_NONE)
@@ -1743,6 +1744,87 @@ e_hwc_window_is_on_target_window(E_Hwc_Window *hwc_window)
 }
 
 
+static void
+_e_hwc_window_client_recover(E_Hwc_Window *hwc_window)
+{
+   E_Comp_Wl_Buffer *buffer = NULL, *recover_buffer = NULL;;
+   tbm_surface_h tsurface =NULL;
+   E_Client *ec = NULL;
+
+   ec = hwc_window->ec;
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   buffer = _e_hwc_window_comp_wl_buffer_get(hwc_window);
+   if (!buffer)
+     {
+        tsurface = e_hwc_window_displaying_surface_get(hwc_window);
+        if (!tsurface) return;
+
+        recover_buffer = e_comp_wl_tbm_buffer_get(tsurface);
+     }
+   else
+     recover_buffer = buffer;
+
+
+   EINA_SAFETY_ON_NULL_RETURN(recover_buffer);
+
+   EHWTRACE("Recover ts:%p -- {%s}",
+            hwc_window->ec, hwc_window, recover_buffer->tbm_surface,
+            e_hwc_window_name_get(hwc_window));
+
+   /* force update */
+   e_comp_wl_surface_attach(ec, recover_buffer);
+
+   return;
+}
+
+EINTERN Eina_Bool
+e_hwc_window_render_target_window_set(E_Hwc_Window *hwc_window, Eina_Bool set)
+{
+   E_Client *ec = NULL;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
+
+   ec = hwc_window->ec;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+
+   if (hwc_window->render_target == set) return EINA_TRUE;
+
+   if (set)
+     {
+         _e_hwc_window_client_recover(hwc_window);
+
+        if (hwc_window->need_redirect)
+          {
+             e_pixmap_image_refresh(ec->pixmap);
+             e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
+             e_comp_object_dirty(ec->frame);
+             e_comp_object_render(ec->frame);
+
+             e_client_redirected_set(ec, EINA_TRUE);
+             hwc_window->need_redirect = EINA_FALSE;
+
+             EHWTRACE("Redirect -- {%s}",
+                      hwc_window->ec, hwc_window, e_hwc_window_name_get(hwc_window));
+          }
+     }
+   else
+     {
+        if (hwc_window->ec->redirected)
+          {
+             e_client_redirected_set(hwc_window->ec, EINA_FALSE);
+             hwc_window->need_redirect = EINA_TRUE;
+
+             EHWTRACE("Unredirect -- {%s}",
+                      hwc_window->ec, hwc_window, e_hwc_window_name_get(hwc_window));
+          }
+     }
+
+   hwc_window->render_target = set;
+
+   return EINA_TRUE;
+}
+
 EINTERN const char*
 e_hwc_window_state_string_get(E_Hwc_Window_State hwc_window_state)
 {
index a110dd9..054a5bd 100644 (file)
@@ -109,7 +109,8 @@ struct _E_Hwc_Window
    E_Hwc_Window_Queue            *queue;
    struct wl_listener             queue_destroy_listener;
 
-   Eina_Bool is_device_to_client_transition;
+   Eina_Bool                      render_target;
+   Eina_Bool                      need_redirect;
 };
 
 struct _E_Hwc_Window_Target
@@ -170,8 +171,8 @@ EINTERN Eina_Bool          e_hwc_window_accepted_state_set(E_Hwc_Window *hwc_win
 EINTERN E_Hwc_Window_State e_hwc_window_accepted_state_get(E_Hwc_Window *hwc_window);
 
 EINTERN void               e_hwc_window_render_list_add(E_Hwc_Window *hwc_window);
-
 EINTERN Eina_Bool          e_hwc_window_is_on_target_window(E_Hwc_Window *hwc_window);
+EINTERN Eina_Bool          e_hwc_window_render_target_window_set(E_Hwc_Window *hwc_window, Eina_Bool set);
 
 EINTERN const char        *e_hwc_window_state_string_get(E_Hwc_Window_State hwc_window_state);
 EINTERN const char        *e_hwc_window_name_get(E_Hwc_Window *hwc_window);
index 3063329..8a50905 100644 (file)
@@ -924,6 +924,45 @@ _e_hwc_windows_activation_states_update(E_Hwc *hwc)
       }
 }
 
+static void
+_e_hwc_windows_render_target_update(E_Hwc *hwc)
+{
+   E_Hwc_Window *hwc_window = NULL;
+   const Eina_List *l = NULL;
+   E_Hwc_Window_State state;
+   E_Pointer *pointer = NULL;
+
+   EINA_LIST_FOREACH(e_hwc_windows_get(hwc), l, hwc_window)
+     {
+        if (hwc_window->is_target) continue;
+        if (!hwc_window->ec) continue;
+
+        state = e_hwc_window_state_get(hwc_window);
+
+        if (hwc_window->is_cursor)
+          pointer = e_pointer_get(hwc_window->ec);
+
+        switch(state)
+          {
+            case E_HWC_WINDOW_STATE_DEVICE:
+            case E_HWC_WINDOW_STATE_CURSOR:
+              e_hwc_window_render_target_window_set(hwc_window, EINA_FALSE);
+              if (pointer)
+                e_pointer_hwc_set(pointer, EINA_TRUE);
+              break;
+            case E_HWC_WINDOW_STATE_CLIENT:
+            case E_HWC_WINDOW_STATE_NONE:
+              e_hwc_window_render_target_window_set(hwc_window, EINA_TRUE);
+              if (pointer)
+                e_pointer_hwc_set(pointer, EINA_FALSE);
+              break;
+            case E_HWC_WINDOW_STATE_VIDEO:
+            default:
+              break;
+          }
+     }
+}
+
 static Eina_Bool
 _e_hwc_windows_accept(E_Hwc *hwc, uint32_t num_changes)
 {
@@ -980,6 +1019,8 @@ _e_hwc_windows_accept(E_Hwc *hwc, uint32_t num_changes)
         e_hwc_window_state_set(hwc_window, state);
      }
 
+   _e_hwc_windows_render_target_update(hwc);
+
 #if DBG_EVALUATE
    EHWSTRACE(" Modified after HWC Validation:", NULL);
    _e_hwc_windows_status_print(hwc, EINA_FALSE);