[gnome-remote-desktop] rdp: Adapt to GrdRdpDamageDetector
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] rdp: Adapt to GrdRdpDamageDetector
- Date: Thu, 3 Mar 2022 14:23:07 +0000 (UTC)
commit 174a2a191b235e02b2a504208435cbaa133cde1b
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Wed Jan 5 18:49:26 2022 +0100
rdp: Adapt to GrdRdpDamageDetector
With the damage detection class now being implemented, replace the old
damage detection with it.
src/grd-rdp-pipewire-stream.c | 11 ++++++++--
src/grd-rdp-surface.c | 6 +++++-
src/grd-rdp-surface.h | 2 +-
src/grd-session-rdp.c | 47 ++++++++++++++++++++++++++-----------------
4 files changed, 44 insertions(+), 22 deletions(-)
---
diff --git a/src/grd-rdp-pipewire-stream.c b/src/grd-rdp-pipewire-stream.c
index 92810230..d623f804 100644
--- a/src/grd-rdp-pipewire-stream.c
+++ b/src/grd-rdp-pipewire-stream.c
@@ -35,6 +35,7 @@
#include "grd-pipewire-utils.h"
#include "grd-rdp-buffer.h"
#include "grd-rdp-buffer-pool.h"
+#include "grd-rdp-damage-detector.h"
#include "grd-rdp-surface.h"
#include "grd-utils.h"
@@ -335,8 +336,6 @@ release_all_buffers (GrdRdpPipeWireStream *stream)
g_mutex_lock (&stream->rdp_surface->surface_mutex);
g_clear_pointer (&stream->rdp_surface->new_framebuffer,
grd_rdp_buffer_release);
- g_clear_pointer (&stream->rdp_surface->last_framebuffer,
- grd_rdp_buffer_release);
g_clear_pointer (&stream->rdp_surface->pending_framebuffer,
grd_rdp_buffer_release);
g_mutex_unlock (&stream->rdp_surface->surface_mutex);
@@ -371,6 +370,13 @@ on_stream_param_changed (void *user_data,
sync_egl_thread (egl_thread);
release_all_buffers (stream);
+ if (!grd_rdp_damage_detector_resize_surface (stream->rdp_surface->detector,
+ width, height))
+ {
+ grd_session_rdp_notify_error (
+ stream->session_rdp, GRD_SESSION_RDP_ERROR_GRAPHICS_SUBSYSTEM_FAILED);
+ return;
+ }
grd_rdp_buffer_pool_resize_buffers (stream->buffer_pool, width, height, stride);
pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
@@ -940,6 +946,7 @@ grd_rdp_pipewire_stream_finalize (GObject *object)
g_clear_pointer (&stream->render_source, g_source_unref);
}
+ grd_rdp_damage_detector_invalidate_surface (stream->rdp_surface->detector);
g_clear_pointer (&stream->pending_frame, grd_rdp_frame_unref);
release_all_buffers (stream);
diff --git a/src/grd-rdp-surface.c b/src/grd-rdp-surface.c
index ba78c26a..e555e180 100644
--- a/src/grd-rdp-surface.c
+++ b/src/grd-rdp-surface.c
@@ -22,6 +22,7 @@
#include "grd-rdp-surface.h"
#include "grd-rdp-buffer.h"
+#include "grd-rdp-damage-detector-memcmp.h"
GrdRdpSurface *
grd_rdp_surface_new (void)
@@ -29,6 +30,8 @@ grd_rdp_surface_new (void)
GrdRdpSurface *rdp_surface;
rdp_surface = g_malloc0 (sizeof (GrdRdpSurface));
+ rdp_surface->detector = (GrdRdpDamageDetector *)
+ grd_rdp_damage_detector_memcmp_new ();
g_mutex_init (&rdp_surface->surface_mutex);
@@ -41,10 +44,11 @@ grd_rdp_surface_free (GrdRdpSurface *rdp_surface)
g_assert (!rdp_surface->gfx_surface);
g_assert (!rdp_surface->new_framebuffer);
- g_assert (!rdp_surface->last_framebuffer);
g_assert (!rdp_surface->pending_framebuffer);
g_mutex_clear (&rdp_surface->surface_mutex);
+ g_clear_object (&rdp_surface->detector);
+
g_free (rdp_surface);
}
diff --git a/src/grd-rdp-surface.h b/src/grd-rdp-surface.h
index 9f20a641..1feabf23 100644
--- a/src/grd-rdp-surface.h
+++ b/src/grd-rdp-surface.h
@@ -34,8 +34,8 @@ struct _GrdRdpSurface
GMutex surface_mutex;
GrdRdpBuffer *new_framebuffer;
- GrdRdpBuffer *last_framebuffer;
GrdRdpBuffer *pending_framebuffer;
+ GrdRdpDamageDetector *detector;
gboolean valid;
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index c2d00873..2cb16236 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -32,6 +32,7 @@
#include "grd-context.h"
#include "grd-damage-utils.h"
#include "grd-rdp-buffer.h"
+#include "grd-rdp-damage-detector.h"
#include "grd-rdp-event-queue.h"
#include "grd-rdp-graphics-pipeline.h"
#include "grd-rdp-network-autodetection.h"
@@ -253,7 +254,6 @@ take_or_encode_frame (GrdSessionRdp *session_rdp,
{
uint16_t width = buffer->width;
uint16_t height = buffer->height;
- uint32_t stride;
cairo_region_t *region;
g_clear_pointer (&rdp_surface->pending_framebuffer, grd_rdp_buffer_release);
@@ -275,32 +275,43 @@ take_or_encode_frame (GrdSessionRdp *session_rdp,
rdp_surface->valid = FALSE;
}
- if (!rdp_surface->valid)
- g_clear_pointer (&rdp_surface->last_framebuffer, grd_rdp_buffer_release);
+ if (!rdp_surface->valid &&
+ !grd_rdp_damage_detector_invalidate_surface (rdp_surface->detector))
+ {
+ grd_rdp_buffer_release (buffer);
+ grd_session_rdp_notify_error (
+ session_rdp, GRD_SESSION_RDP_ERROR_GRAPHICS_SUBSYSTEM_FAILED);
+ return;
+ }
if (is_rdp_peer_flag_set (session_rdp, RDP_PEER_ACTIVATED) &&
is_rdp_peer_flag_set (session_rdp, RDP_PEER_OUTPUT_ENABLED) &&
!is_rdp_peer_flag_set (session_rdp, RDP_PEER_PENDING_GFX_INIT) &&
!rdp_surface->encoding_suspended)
{
- uint8_t *last_frame_local_data = NULL;
+ gboolean is_region_damaged;
- if (rdp_surface->last_framebuffer)
- last_frame_local_data = rdp_surface->last_framebuffer->local_data;
+ if (!grd_rdp_damage_detector_submit_new_framebuffer (rdp_surface->detector,
+ buffer))
+ {
+ grd_rdp_buffer_release (buffer);
+ grd_session_rdp_notify_error (
+ session_rdp, GRD_SESSION_RDP_ERROR_GRAPHICS_SUBSYSTEM_FAILED);
+ return;
+ }
- stride = grd_session_rdp_get_stride_for_width (session_rdp,
- rdp_surface->width);
- region = grd_get_damage_region (buffer->local_data,
- last_frame_local_data,
- rdp_surface->width,
- rdp_surface->height,
- 64, 64,
- stride, 4);
- if (!cairo_region_is_empty (region))
- rdp_peer_refresh_region (session_rdp, rdp_surface, region, buffer);
+ is_region_damaged =
+ grd_rdp_damage_detector_is_region_damaged (rdp_surface->detector);
- g_clear_pointer (&rdp_surface->last_framebuffer, grd_rdp_buffer_release);
- rdp_surface->last_framebuffer = buffer;
+ region = grd_rdp_damage_detector_get_damage_region (rdp_surface->detector);
+ if (!region)
+ {
+ grd_session_rdp_notify_error (
+ session_rdp, GRD_SESSION_RDP_ERROR_GRAPHICS_SUBSYSTEM_FAILED);
+ return;
+ }
+ if (is_region_damaged)
+ rdp_peer_refresh_region (session_rdp, rdp_surface, region, buffer);
cairo_region_destroy (region);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]