e_hwc_window_queue: set backup buffer in prepare_unset 15/216615/2 accepted/tizen/unified/20191104.115020 submit/tizen/20191104.053427
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 24 Oct 2019 05:56:34 +0000 (14:56 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Mon, 4 Nov 2019 05:28:49 +0000 (05:28 +0000)
Change-Id: I9e4c1ac277aea1f3ccd7a7e76306982fa841f774

src/bin/e_hwc_window_queue.c

index ebd2ce5170433b77b096dd4bb213308833c73256..a365b5077eb189d2145ac9cc260144cb11ff1930 100644 (file)
@@ -779,6 +779,66 @@ fail:
    return EINA_FALSE;
 }
 
+static Eina_Bool
+_e_hwc_window_queue_backup_buffer_set(E_Hwc_Window *hwc_window, Eina_Bool attach)
+{
+   E_Comp_Wl_Buffer *comp_buffer = NULL, *backup_buffer = NULL;
+   tbm_surface_h tsurface = NULL;
+   uint32_t flags = 0;
+   E_Client *ec = hwc_window->ec;
+
+   if (!ec) return EINA_FALSE;
+
+   comp_buffer = _comp_wl_buffer_get(hwc_window->ec);
+   if (!comp_buffer) return EINA_FALSE;
+   if (!comp_buffer->tbm_surface) return EINA_FALSE;
+
+   tsurface = comp_buffer->tbm_surface;
+
+   if (comp_buffer->resource)
+     {
+        flags = _comp_wl_buffer_flags_get(comp_buffer);
+        if (flags !=  E_HWC_WINDOW_QUEUE_BUFFER_FLAGS)
+          return EINA_FALSE;
+     }
+   else
+     {
+        if (tsurface != hwc_window->display.buffer.tsurface)
+          return EINA_FALSE;
+
+        if (!hwc_window->display.buffer.from_queue)
+          return EINA_FALSE;
+     }
+
+   EHWQINF("Backup buffer get ehw:%p origin:%p",
+           hwc_window->ec, hwc_window->hwc, NULL, hwc_window,
+           comp_buffer->tbm_surface);
+
+   backup_buffer = _comp_wl_backup_buffer_get(tsurface);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(backup_buffer, EINA_FALSE);
+
+   if (comp_buffer)
+     backup_buffer->transform = comp_buffer->transform;
+
+   EHWQINF("Backup buffer set ehw:%p origin:%p tsurface:%p",
+           hwc_window->ec, hwc_window->hwc, NULL, hwc_window,
+           comp_buffer->tbm_surface, backup_buffer->tbm_surface);
+
+   if (attach)
+     {
+        e_comp_wl_surface_attach(ec, backup_buffer);
+     }
+   else
+     {
+        e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, backup_buffer);
+        e_pixmap_resource_set(ec->pixmap, backup_buffer);
+        e_pixmap_dirty(ec->pixmap);
+        e_pixmap_refresh(ec->pixmap);
+     }
+
+   return EINA_TRUE;
+}
+
 static Eina_Bool
 _e_hwc_window_queue_prepare_set(E_Hwc_Window_Queue *queue, E_Hwc_Window *hwc_window)
 {
@@ -874,11 +934,23 @@ _e_hwc_window_queue_prepare_unset(E_Hwc_Window_Queue *queue)
    struct wayland_tbm_client_queue *cqueue = NULL;
    E_Hwc_Window *hwc_window = queue->user;
 
-   if (hwc_window)
+   if (hwc_window && hwc_window->ec)
      {
         cqueue = _user_cqueue_get(hwc_window->ec);
         if (cqueue)
           wayland_tbm_server_client_queue_set_wait_usable_cb(cqueue, NULL, NULL);
+
+        if (_e_hwc_window_queue_backup_buffer_set(hwc_window, EINA_TRUE))
+          {
+             if(hwc_window->render_target)
+               {
+                  e_pixmap_image_refresh(hwc_window->ec->pixmap);
+                  e_comp_object_damage(hwc_window->ec->frame, 0, 0,
+                                       hwc_window->ec->w, hwc_window->ec->h);
+                  e_comp_object_dirty(hwc_window->ec->frame);
+                  e_comp_object_render(hwc_window->ec->frame);
+               }
+          }
      }
 
    tbm_surface_queue_remove_dequeuable_cb(queue->tqueue,
@@ -984,9 +1056,6 @@ static void
 _e_hwc_window_queue_cb_buffer_change(void *data, E_Client *ec)
 {
    E_Hwc_Window *hwc_window = NULL;
-   E_Comp_Wl_Buffer *comp_buffer = NULL, *backup_buffer = NULL;
-   tbm_surface_h tsurface = NULL;
-   uint32_t flags = 0;
 
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
@@ -995,45 +1064,7 @@ _e_hwc_window_queue_cb_buffer_change(void *data, E_Client *ec)
    if ((hwc_window->queue) && (e_hwc_window_device_state_available_get(hwc_window)))
      return;
 
-   comp_buffer = _comp_wl_buffer_get(ec);
-   if (!comp_buffer) return;
-   if (!comp_buffer->tbm_surface) return;
-
-   tsurface = comp_buffer->tbm_surface;
-
-   if (comp_buffer->resource)
-     {
-        flags = _comp_wl_buffer_flags_get(comp_buffer);
-        if (flags !=  E_HWC_WINDOW_QUEUE_BUFFER_FLAGS)
-          return;
-     }
-   else
-     {
-        if (tsurface != hwc_window->display.buffer.tsurface)
-          return;
-
-        if (!hwc_window->display.buffer.from_queue)
-          return;
-     }
-
-   EHWQINF("Backup buffer get ehw:%p origin:%p",
-           hwc_window->ec, hwc_window->hwc, NULL, hwc_window,
-           comp_buffer->tbm_surface);
-
-   backup_buffer = _comp_wl_backup_buffer_get(tsurface);
-   EINA_SAFETY_ON_NULL_RETURN(backup_buffer);
-
-   if (comp_buffer)
-     backup_buffer->transform = comp_buffer->transform;
-
-   EHWQINF("Backup buffer set ehw:%p origin:%p tsurface:%p",
-           hwc_window->ec, hwc_window->hwc, NULL, hwc_window,
-           comp_buffer->tbm_surface, backup_buffer->tbm_surface);
-
-   e_comp_wl_buffer_reference(&ec->comp_data->buffer_ref, backup_buffer);
-   e_pixmap_resource_set(ec->pixmap, backup_buffer);
-   e_pixmap_dirty(ec->pixmap);
-   e_pixmap_refresh(ec->pixmap);
+   _e_hwc_window_queue_backup_buffer_set(hwc_window, EINA_FALSE);
 }
 
 void