Include cursor image to capture 21/266121/3
authorJunkyeong, Kim <jk0430.kim@samsung.com>
Mon, 8 Nov 2021 05:46:55 +0000 (14:46 +0900)
committerJunkyeong, Kim <jk0430.kim@samsung.com>
Thu, 11 Nov 2021 03:13:55 +0000 (12:13 +0900)
If cursor coordinate which is sent by rdp client treated,
the cursor image will be shown.
If capture including cursor image, this is client's cursor position.

Change-Id: If1d57ce917494d814db6c2ae1fc426255b05d705
Signed-off-by: Junkyeong, Kim <jk0430.kim@samsung.com>
src/e_mod_rdp.c

index de060ec..43c4035 100644 (file)
@@ -115,7 +115,7 @@ _e_rdp_tbm_image_create(E_Rdp_Output *output, int w, int h, int color)
 {
    tbm_surface_h tbm_surface = NULL;
 
-   tbm_surface = tbm_surface_internal_create_with_flags(w, h, TBM_FORMAT_XRGB8888, TBM_BO_SCANOUT);
+   tbm_surface = tbm_surface_internal_create_with_flags(w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
    if (!tbm_surface)
      return NULL;
 
@@ -580,6 +580,46 @@ _e_rdp_output_image_composite(pixman_image_t *src_img, pixman_image_t *dst_img,
 }
 
 static Eina_Bool
+_e_rdp_pixman_output_image_composite_cursor(E_Rdp_Output *output, E_Hwc_Window *hwc_window, pixman_image_t *pix_surface, int pix_w, int pix_h, int primary_w, int primary_h)
+{
+   Eina_Rectangle showing_pos = {0, };
+   Eina_Rectangle dst_pos = {0, };
+   Eina_Rectangle src_crop = {0, };
+   Eina_Rectangle dst_crop = {0, };
+   void *src_ptr = NULL;
+   int src_stride, img_w, img_h;
+   pixman_image_t *pix_shm_src = NULL;
+
+   if (!hwc_window->cursor.buffer)
+     return EINA_FALSE;
+
+   src_ptr = hwc_window->cursor.img_ptr;
+   src_stride = hwc_window->cursor.img_stride;
+   img_w = hwc_window->cursor.img_w;
+   img_h = hwc_window->cursor.img_h;
+
+   pix_shm_src = pixman_image_create_bits(PIXMAN_a8r8g8b8, img_w, img_h, (uint32_t*)src_ptr, src_stride);
+   if (!pix_shm_src)
+     {
+        ERR("create pixman image failed");
+        return EINA_FALSE;
+     }
+
+   _e_rdp_output_image_src_crop_get(hwc_window, &src_crop, &showing_pos, primary_w, primary_h);
+   _e_rdp_output_center_rect_get(primary_w, primary_h, pix_w, pix_h, &dst_pos);
+   _e_rdp_output_image_dst_crop_get(hwc_window, img_w, img_h, primary_w, primary_h, &dst_pos, &showing_pos, &dst_crop, 0);
+
+   _e_rdp_output_image_composite(pix_shm_src, pix_surface,
+                                 src_crop.x, src_crop.y, src_crop.w, src_crop.h,
+                                 dst_crop.x, dst_crop.y, dst_crop.w, dst_crop.h,
+                                 EINA_TRUE, 0, 0, 0);
+
+   pixman_image_unref(pix_shm_src);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
 _e_rdp_pixman_output_image_composite(E_Rdp_Output *output, E_Hwc_Window *hwc_window, pixman_image_t *pix_surface, int pix_w, int pix_h, int primary_w, int primary_h)
 {
    Eina_Rectangle showing_pos = {0, };
@@ -707,7 +747,6 @@ _e_rdp_pixman_output_image_get(E_Rdp_Output *output, tbm_surface_h tbm_surface)
         if (!hwc_window) continue;
         if (hwc_window->is_target) continue;
         if (hwc_window->is_video) continue;
-        if (hwc_window->is_cursor) continue;
         if (hwc_window->state == E_HWC_WINDOW_STATE_NONE || hwc_window->zpos == -999) continue;
 
         if (hwc_window->accepted_state == E_HWC_WINDOW_STATE_CLIENT)
@@ -719,6 +758,12 @@ _e_rdp_pixman_output_image_get(E_Rdp_Output *output, tbm_surface_h tbm_surface)
 
         if (hwc_window->accepted_state == E_HWC_WINDOW_STATE_DEVICE)
           visible_list = eina_list_append(visible_list, hwc_window);
+
+        if (hwc_window->accepted_state == E_HWC_WINDOW_STATE_CURSOR)
+          {
+             if (hwc_window->cursor.buffer)
+               visible_list = eina_list_append(visible_list, hwc_window);
+          }
      }
 
    if (eina_list_count(visible_list) == 0)
@@ -742,7 +787,10 @@ _e_rdp_pixman_output_image_get(E_Rdp_Output *output, tbm_surface_h tbm_surface)
              continue;
           }
 
-        _e_rdp_pixman_output_image_composite(output, hwc_window, pix_surface, info.width, info.height, e_output_w, e_output_h);
+        if (hwc_window->is_cursor)
+          _e_rdp_pixman_output_image_composite_cursor(output, hwc_window, pix_surface, info.width, info.height, e_output_w, e_output_h);
+        else
+          _e_rdp_pixman_output_image_composite(output, hwc_window, pix_surface, info.width, info.height, e_output_w, e_output_h);
      }
 
 out:
@@ -991,7 +1039,7 @@ e_rdp_client_activity(int fd, uint32_t mask, void *data)
 
    if (client->CheckFileDescriptor(client))
      {
-        DBG("enable client activity %p", client);
+//        DBG("enable client activity %p", client);
         return 0;
      }