Send pixman image to rdp client only updated area 75/272275/3
authorJunkyeong, Kim <jk0430.kim@samsung.com>
Mon, 14 Mar 2022 03:34:03 +0000 (12:34 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 22 Mar 2022 08:55:47 +0000 (08:55 +0000)
If there is only cursor moving, send only cursor updated rectangle area.
If there is window update except cursor, send full refresh.

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

index a978c56..b7158a2 100644 (file)
@@ -104,6 +104,7 @@ struct _E_Rdp_Output
 
    Eina_Bool buffer_reuse;
    Eina_Rectangle cursor_crop_dst;
+   Eina_Rectangle cursor_damage_rect;
 
    int mouse_x;
    int mouse_y;
@@ -642,6 +643,49 @@ _e_rdp_output_image_composite(pixman_image_t *src_img, pixman_image_t *dst_img,
                           dx, dy, dw, dh);
 }
 
+static void
+_e_rdp_pixman_output_image_cusror_damage_area_get(E_Rdp_Output *output, Eina_Rectangle *rect)
+{
+   if (output->cursor_crop_dst.x == 0 && output->cursor_crop_dst.y == 0 &&
+       output->cursor_crop_dst.w == 0 && output->cursor_crop_dst.h == 0)
+     {
+        output->cursor_damage_rect.x = 0;
+        output->cursor_damage_rect.y = 0;
+        output->cursor_damage_rect.w = output->w;
+        output->cursor_damage_rect.h = output->h;
+     }
+   else
+     {
+        /* x axis */
+        if (output->cursor_crop_dst.x < rect->x)
+          {
+             output->cursor_damage_rect.x = output->cursor_crop_dst.x;
+             output->cursor_damage_rect.w = rect->x - output->cursor_crop_dst.x + rect->w;
+          }
+        else
+          {
+             output->cursor_damage_rect.x = rect->x;
+             output->cursor_damage_rect.w = output->cursor_crop_dst.x - rect->x + output->cursor_crop_dst.w;
+          }
+        if (output->cursor_damage_rect.x + output->cursor_damage_rect.w > output->w)
+          output->cursor_damage_rect.w = output->w - output->cursor_damage_rect.x;
+
+        /* y axis */
+        if (output->cursor_crop_dst.y < rect->y)
+          {
+             output->cursor_damage_rect.y = output->cursor_crop_dst.y;
+             output->cursor_damage_rect.h = rect->y - output->cursor_crop_dst.y + rect->h;
+          }
+        else
+          {
+             output->cursor_damage_rect.y = rect->y;
+             output->cursor_damage_rect.h = output->cursor_crop_dst.y - rect->y + output->cursor_crop_dst.h;
+          }
+        if (output->cursor_damage_rect.y + output->cursor_damage_rect.h > output->h)
+          output->cursor_damage_rect.h = output->h - output->cursor_damage_rect.y;
+     }
+}
+
 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)
 {
@@ -686,6 +730,7 @@ _e_rdp_pixman_output_image_composite_cursor(E_Rdp_Output *output, E_Hwc_Window *
    output->mouse_x = hwc_window->current.info.dst_pos.x;
    output->mouse_y = hwc_window->current.info.dst_pos.y;
 
+   _e_rdp_pixman_output_image_cusror_damage_area_get(output, &dst_crop);
    output->cursor_crop_dst.x = dst_crop.x;
    output->cursor_crop_dst.y = dst_crop.y;
    output->cursor_crop_dst.w = dst_crop.w;
@@ -1228,11 +1273,21 @@ _e_rdp_frame_timer(void *data)
    INF("pixman capture time: %.1f ms", (end_capture - start) * 1000);
 #endif
 
-   /* sends a full refresh */
-   box.x1 = 0;
-   box.y1 = 0;
-   box.x2 = output->w;
-   box.y2 = output->h;
+   if (output->buffer_reuse)
+     {
+        box.x1 = output->cursor_damage_rect.x;
+        box.y1 = output->cursor_damage_rect.y;
+        box.x2 = output->cursor_damage_rect.x + output->cursor_damage_rect.w;
+        box.y2 = output->cursor_damage_rect.y + output->cursor_damage_rect.h;
+     }
+   else
+     {
+        box.x1 = 0;
+        box.y1 = 0;
+        box.x2 = output->w;
+        box.y2 = output->h;
+     }
+
    pixman_region32_init_with_extents(&damage, &box);
 
    wl_list_for_each_safe(rdp_peer, tmp, &output->peers, link)