[gimp/wip/animation: 225/373] plug-ins: warn of low framerate…
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 225/373] plug-ins: warn of low framerate…
- Date: Sat, 7 Oct 2017 02:13:38 +0000 (UTC)
commit 2bdfe4d7725c7ea5cf4c019a5484af2d45bda67c
Author: Jehan <jehan girinstud io>
Date: Wed Aug 19 16:11:38 2015 +0200
plug-ins: warn of low framerate…
useful when playing big HD animations.
plug-ins/animation-play/animation-dialog.c | 44 ++++++++++++++++++++++++++++
plug-ins/animation-play/animation.c | 14 +++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/animation-play/animation-dialog.c b/plug-ins/animation-play/animation-dialog.c
index 5447c6e..4809576 100755
--- a/plug-ins/animation-play/animation-dialog.c
+++ b/plug-ins/animation-play/animation-dialog.c
@@ -202,6 +202,9 @@ static void framerate_changed (Animation *animation,
static void disposal_changed (Animation *animation,
gint disposal,
AnimationDialog *dialog);
+static void low_framerate_cb (Animation *animation,
+ gdouble real_framerate,
+ AnimationDialog *dialog);
/* Rendering/Playing Functions */
static gboolean repaint_da (GtkWidget *darea,
@@ -772,6 +775,9 @@ animation_dialog_constructed (GObject *object)
g_signal_connect (priv->animation, "render",
G_CALLBACK (render_callback),
dialog);
+ g_signal_connect (priv->animation, "low-framerate-playback",
+ G_CALLBACK (low_framerate_cb),
+ dialog);
}
static void
@@ -1504,6 +1510,12 @@ play_callback (GtkToggleAction *action,
{
gtk_action_set_icon_name (GTK_ACTION (action), "media-playback-start");
animation_stop (priv->animation);
+
+ /* The framerate combo might have been modified to display slowness
+ * warnings. */
+ gtk_widget_modify_text (gtk_bin_get_child (GTK_BIN (priv->fpscombo)), GTK_STATE_NORMAL, NULL);
+ gimp_help_set_help_data (priv->fpscombo, _("Frame Rate"), NULL);
+ framerate_changed (priv->animation, animation_get_framerate (priv->animation), dialog);
}
g_object_set (action,
@@ -1768,6 +1780,38 @@ disposal_changed (Animation *animation,
dialog);
}
+static void
+low_framerate_cb (Animation *animation,
+ gdouble real_framerate,
+ AnimationDialog *dialog)
+{
+ AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
+ GdkColor gdk_red;
+ gchar *text;
+
+ gdk_red.red = 65535;
+ gdk_red.green = 0;
+ gdk_red.blue = 0;
+
+ g_signal_handlers_block_by_func (priv->fpscombo,
+ G_CALLBACK (fpscombo_changed),
+ dialog);
+ g_signal_handlers_block_by_func (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->fpscombo))),
+ G_CALLBACK (fpscombo_activated),
+ dialog);
+ gtk_widget_modify_text (gtk_bin_get_child (GTK_BIN (priv->fpscombo)), GTK_STATE_NORMAL, &gdk_red);
+ text = g_strdup_printf (_("%g fps"), real_framerate);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->fpscombo))), text);
+ g_signal_handlers_unblock_by_func (priv->fpscombo,
+ G_CALLBACK (fpscombo_changed),
+ dialog);
+ g_signal_handlers_unblock_by_func (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->fpscombo))),
+ G_CALLBACK (fpscombo_activated),
+ dialog);
+ gtk_widget_set_tooltip_text (priv->fpscombo,
+ _ ("Playback is too slow. We would drop a frame if frame dropping were
implemented."));
+}
+
/* Rendering Functions */
static gboolean
diff --git a/plug-ins/animation-play/animation.c b/plug-ins/animation-play/animation.c
index 7034d5f..27052bb 100644
--- a/plug-ins/animation-play/animation.c
+++ b/plug-ins/animation-play/animation.c
@@ -1354,6 +1354,7 @@ animation_time_to_next (Animation *animation,
AnimationPrivate *priv = ANIMATION_GET_PRIVATE (animation);
static gint64 start_time = -1;
static gint frames = 0;
+ static gboolean prev_low_framerate = FALSE;
gdouble expected_time_from_start = 0.0;
gdouble duration;
@@ -1381,8 +1382,21 @@ animation_time_to_next (Animation *animation,
if (duration < 1.0)
{
+ if (prev_low_framerate)
+ {
+ /* Let's only warn the user if several subsequent frames slow. */
+ gdouble real_framerate = (gdouble) frames * 1000000.0 / (g_get_monotonic_time () - start_time);
+ g_signal_emit (animation, animation_signals[LOW_FRAMERATE], 0,
+ real_framerate);
+ }
duration = 1.0;
+ prev_low_framerate = TRUE;
}
+ else
+ {
+ prev_low_framerate = FALSE;
+ }
+
}
return duration;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]