[gnome-remote-desktop] rdp: Add RDP buffer



commit 12e415b05d1323fab337543bb5866b27726f0010
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sun Jan 2 10:41:16 2022 +0100

    rdp: Add RDP buffer
    
    Introduce a new structure called GrdRdpBuffer.
    This structure will contain the buffer data of a frame among other
    things, such as a registered resource, which can correspond to buffer
    data on the GPU.
    In the future, frame data might only be available on the GPU.
    This new structure enables this usage, while also still allowing the
    current usage, where the data is always available for the CPU.

 src/grd-rdp-buffer.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/grd-rdp-buffer.h | 44 ++++++++++++++++++++++++++++++++++++++
 src/grd-types.h      |  1 +
 src/meson.build      |  2 ++
 4 files changed, 107 insertions(+)
---
diff --git a/src/grd-rdp-buffer.c b/src/grd-rdp-buffer.c
new file mode 100644
index 00000000..9d1ffca5
--- /dev/null
+++ b/src/grd-rdp-buffer.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2022 Pascal Nowack
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "grd-rdp-buffer.h"
+
+#include <gio/gio.h>
+
+GrdRdpBuffer *
+grd_rdp_buffer_new (void)
+{
+  GrdRdpBuffer *buffer;
+
+  buffer = g_new0 (GrdRdpBuffer, 1);
+
+  return buffer;
+}
+
+static void
+clear_buffers (GrdRdpBuffer *buffer)
+{
+  g_clear_pointer (&buffer->local_data, g_free);
+}
+
+void
+grd_rdp_buffer_free (GrdRdpBuffer *buffer)
+{
+  clear_buffers (buffer);
+  g_free (buffer);
+}
+
+void
+grd_rdp_buffer_resize (GrdRdpBuffer *buffer,
+                       uint32_t      width,
+                       uint32_t      height,
+                       uint32_t      stride)
+{
+  clear_buffers (buffer);
+
+  buffer->width = width;
+  buffer->height = height;
+  buffer->local_data = g_malloc0 (stride * height * sizeof (uint8_t));
+}
diff --git a/src/grd-rdp-buffer.h b/src/grd-rdp-buffer.h
new file mode 100644
index 00000000..c0e3dee4
--- /dev/null
+++ b/src/grd-rdp-buffer.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2022 Pascal Nowack
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef GRD_RDP_BUFFER_H
+#define GRD_RDP_BUFFER_H
+
+#include <stdint.h>
+
+#include "grd-types.h"
+
+struct _GrdRdpBuffer
+{
+  uint32_t width;
+  uint32_t height;
+
+  uint8_t *local_data;
+};
+
+GrdRdpBuffer *grd_rdp_buffer_new (void);
+
+void grd_rdp_buffer_free (GrdRdpBuffer *buffer);
+
+void grd_rdp_buffer_resize (GrdRdpBuffer *buffer,
+                            uint32_t      width,
+                            uint32_t      height,
+                            uint32_t      stride);
+
+#endif /* GRD_RDP_BUFFER_H */
diff --git a/src/grd-types.h b/src/grd-types.h
index 96685c6b..ec039771 100644
--- a/src/grd-types.h
+++ b/src/grd-types.h
@@ -30,6 +30,7 @@ typedef struct _GrdClipboardVnc GrdClipboardVnc;
 typedef struct _GrdEglThread GrdEglThread;
 typedef struct _GrdHwAccelNvidia GrdHwAccelNvidia;
 typedef struct _GrdRdpEventQueue GrdRdpEventQueue;
+typedef struct _GrdRdpBuffer GrdRdpBuffer;
 typedef struct _GrdRdpGfxFrameLog GrdRdpGfxFrameLog;
 typedef struct _GrdRdpGfxSurface GrdRdpGfxSurface;
 typedef struct _GrdRdpGraphicsPipeline GrdRdpGraphicsPipeline;
diff --git a/src/meson.build b/src/meson.build
index 9723d4a6..a24c239c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -45,6 +45,8 @@ if have_rdp
   daemon_sources += files([
     'grd-clipboard-rdp.c',
     'grd-clipboard-rdp.h',
+    'grd-rdp-buffer.c',
+    'grd-rdp-buffer.h',
     'grd-rdp-event-queue.c',
     'grd-rdp-event-queue.h',
     'grd-rdp-frame-info.h',


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