[gnome-shell] recorder: Force full stage redraws during recording



commit d6a6e6220a6cfc635634094f54c30bcc3f12bc5e
Author: Adel Gadllah <adel gadllah gmail com>
Date:   Fri Jan 21 18:55:00 2011 +0100

    recorder: Force full stage redraws during recording
    
    Partial redraws can result into artifacts in the recording,
    so disable them while recording.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=640206

 src/shell-recorder.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-recorder.c b/src/shell-recorder.c
index a129f7d..57377bd 100644
--- a/src/shell-recorder.c
+++ b/src/shell-recorder.c
@@ -83,6 +83,7 @@ struct _ShellRecorder {
   guint redraw_idle;
   guint update_memory_used_timeout;
   guint update_pointer_timeout;
+  guint repaint_hook_id;
 };
 
 struct _RecorderPipeline
@@ -239,6 +240,22 @@ get_memory_target (void)
   return DEFAULT_MEMORY_TARGET;
 }
 
+/*
+ * Used to force full stage redraws during recording to avoid artifacts
+ *
+ * Note: That this will cause the stage to be repainted on
+ * every animation frame even if the frame wouldn't normally cause any new
+ * drawing
+ */
+static gboolean
+recorder_repaint_hook (gpointer data)
+{
+  ClutterActor *stage = data;
+  clutter_actor_queue_redraw (stage);
+
+  return TRUE;
+}
+
 static void
 shell_recorder_init (ShellRecorder *recorder)
 {
@@ -1682,6 +1699,9 @@ shell_recorder_record (ShellRecorder *recorder)
   recorder->state = RECORDER_STATE_RECORDING;
   recorder_add_update_pointer_timeout (recorder);
 
+  /* Set up repaint hook */
+  recorder->repaint_hook_id = clutter_threads_add_repaint_func(recorder_repaint_hook, recorder->stage, NULL);
+
   /* Record an initial frame and also redraw with the indicator */
   clutter_actor_queue_redraw (CLUTTER_ACTOR (recorder->stage));
 
@@ -1723,6 +1743,12 @@ shell_recorder_pause (ShellRecorder *recorder)
 
   /* Queue a redraw to remove the recording indicator */
   clutter_actor_queue_redraw (CLUTTER_ACTOR (recorder->stage));
+
+  if (recorder->repaint_hook_id != 0)
+  {
+    clutter_threads_remove_repaint_func (recorder->repaint_hook_id);
+    recorder->repaint_hook_id = 0;
+  }
 }
 
 /**



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