[gnome-remote-desktop] rdp: Copy pixels using the right destination stride



commit 4caf984778e9217b42ef756cd432721f3f532895
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Oct 13 16:51:51 2020 +0200

    rdp: Copy pixels using the right destination stride
    
    As with VNC, we're copying in a separate thread, and looking at the
    stride managed on the main thread is racy, so don't do that.

 src/grd-rdp-pipewire-stream.c |  5 +++--
 src/grd-session-rdp.c         | 16 ++++++++++++----
 src/grd-session-rdp.h         |  3 ++-
 3 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/src/grd-rdp-pipewire-stream.c b/src/grd-rdp-pipewire-stream.c
index 414d3e9..5f62267 100644
--- a/src/grd-rdp-pipewire-stream.c
+++ b/src/grd-rdp-pipewire-stream.c
@@ -321,10 +321,11 @@ process_buffer (GrdRdpPipeWireStream *stream,
       int width;
       int y;
 
-      src_stride = buffer->datas[0].chunk->stride;
-      dst_stride = grd_session_rdp_get_framebuffer_stride (stream->session_rdp);
       height = stream->spa_format.size.height;
       width = stream->spa_format.size.width;
+      src_stride = buffer->datas[0].chunk->stride;
+      dst_stride = grd_session_rdp_get_stride_for_width (stream->session_rdp,
+                                                         width);
 
       frame->data = g_malloc (height * dst_stride);
       for (y = 0; y < height; ++y)
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index 5268135..ddda618 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -165,6 +165,15 @@ grd_session_rdp_resize_framebuffer (GrdSessionRdp *session_rdp,
                      rdp_settings->DesktopHeight);
 }
 
+static int
+grd_session_rdp_get_framebuffer_stride (GrdSessionRdp *session_rdp)
+{
+  rdpSettings *rdp_settings = session_rdp->peer->settings;
+
+  return grd_session_rdp_get_stride_for_width (session_rdp,
+                                               rdp_settings->DesktopWidth);
+}
+
 void
 grd_session_rdp_take_buffer (GrdSessionRdp *session_rdp,
                              void          *data)
@@ -1211,11 +1220,10 @@ rdp_peer_context_free (freerdp_peer   *peer,
 }
 
 int
-grd_session_rdp_get_framebuffer_stride (GrdSessionRdp *session_rdp)
+grd_session_rdp_get_stride_for_width (GrdSessionRdp *session_rdp,
+                                      int            width)
 {
-  rdpSettings *rdp_settings = session_rdp->peer->settings;
-
-  return rdp_settings->DesktopWidth * 4;
+  return width * 4;
 }
 
 static void
diff --git a/src/grd-session-rdp.h b/src/grd-session-rdp.h
index cf01179..abcb37d 100644
--- a/src/grd-session-rdp.h
+++ b/src/grd-session-rdp.h
@@ -35,7 +35,8 @@ G_DECLARE_FINAL_TYPE (GrdSessionRdp,
 GrdSessionRdp *grd_session_rdp_new (GrdRdpServer      *rdp_server,
                                     GSocketConnection *connection);
 
-int grd_session_rdp_get_framebuffer_stride (GrdSessionRdp *session_rdp);
+int grd_session_rdp_get_stride_for_width (GrdSessionRdp *session_rdp,
+                                          int            width);
 
 void grd_session_rdp_resize_framebuffer (GrdSessionRdp *session_rdp,
                                          uint32_t       width,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]