[gimp/wip/animation: 240/373] plug-ins: improve proxy support in animation playback.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 240/373] plug-ins: improve proxy support in animation playback.
- Date: Sat, 7 Oct 2017 02:14:54 +0000 (UTC)
commit 812af0a773d857af675d0cd73cb6b86e1eb64ec9
Author: Jehan <jehan girinstud io>
Date: Wed Jul 27 06:23:36 2016 +0200
plug-ins: improve proxy support in animation playback.
- Rename label to just "Proxy".
- Toggling the expander should not enable/disable proxy.
- All proxy and preview size code moved to Animation class.
- Add animation_set_proxy(). animation_load*() do not have the proxy
ratio as parameter anymore.
plug-ins/animation-play/core/animation.c | 52 +++++++++++----
plug-ins/animation-play/core/animation.h | 17 ++---
plug-ins/animation-play/core/animationanimatic.c | 59 +++-------------
plug-ins/animation-play/widgets/animation-dialog.c | 73 +++-----------------
4 files changed, 67 insertions(+), 134 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation.c b/plug-ins/animation-play/core/animation.c
index 95d40d1..1e4d75d 100644
--- a/plug-ins/animation-play/core/animation.c
+++ b/plug-ins/animation-play/core/animation.c
@@ -368,8 +368,7 @@ animation_get_image_id (Animation *animation)
}
void
-animation_load (Animation *animation,
- gdouble proxy_ratio)
+animation_load (Animation *animation)
{
AnimationPrivate *priv = ANIMATION_GET_PRIVATE (animation);
GeglBuffer *buffer;
@@ -379,15 +378,11 @@ animation_load (Animation *animation,
priv->loaded = FALSE;
g_signal_emit (animation, animation_signals[LOADING_START], 0);
- priv->proxy_ratio = proxy_ratio;
- g_signal_emit (animation, animation_signals[PROXY], 0, proxy_ratio);
-
if (priv->xml)
ANIMATION_GET_CLASS (animation)->load_xml (animation,
- priv->xml,
- proxy_ratio);
+ priv->xml);
else
- ANIMATION_GET_CLASS (animation)->load (animation, proxy_ratio);
+ ANIMATION_GET_CLASS (animation)->load (animation);
/* XML is only used for the first load.
* Any next loads will use internal data. */
g_free (priv->xml);
@@ -447,21 +442,52 @@ animation_get_length (Animation *animation)
}
void
-animation_get_size (Animation *animation,
- gint *width,
- gint *height)
+animation_set_proxy (Animation *animation,
+ gdouble ratio)
{
- ANIMATION_GET_CLASS (animation)->get_size (animation, width, height);
+ AnimationPrivate *priv = ANIMATION_GET_PRIVATE (animation);
+
+ g_return_if_fail (ratio > 0.0 && ratio <= 1.0);
+
+ if (priv->proxy_ratio != ratio)
+ {
+ priv->proxy_ratio = ratio;
+ g_signal_emit (animation, animation_signals[PROXY], 0, ratio);
+
+ /* A proxy change implies a reload. */
+ animation_load (animation);
+ }
}
gdouble
-animation_get_proxy (Animation *animation)
+animation_get_proxy (Animation *animation)
{
AnimationPrivate *priv = ANIMATION_GET_PRIVATE (animation);
return priv->proxy_ratio;
}
+void
+animation_get_size (Animation *animation,
+ gint *width,
+ gint *height)
+{
+ AnimationPrivate *priv = ANIMATION_GET_PRIVATE (animation);
+ gint image_width;
+ gint image_height;
+
+ image_width = gimp_image_width (priv->image_id);
+ image_height = gimp_image_height (priv->image_id);
+
+ /* Full preview size. */
+ *width = image_width;
+ *height = image_height;
+
+ /* Apply proxy ratio. */
+ *width *= priv->proxy_ratio;
+ *height *= priv->proxy_ratio;
+}
+
GeglBuffer *
animation_get_frame (Animation *animation,
gint pos)
diff --git a/plug-ins/animation-play/core/animation.h b/plug-ins/animation-play/core/animation.h
index 9399156..f8e3c2f 100644
--- a/plug-ins/animation-play/core/animation.h
+++ b/plug-ins/animation-play/core/animation.h
@@ -49,18 +49,12 @@ struct _AnimationClass
gint next_pos);
/* These virtual methods must be implemented by any subclass. */
- void (*load) (Animation *animation,
- gdouble proxy_ratio);
+ void (*load) (Animation *animation);
void (*load_xml) (Animation *animation,
- const gchar *xml,
- gdouble proxy_ratio);
+ const gchar *xml);
gint (*get_length) (Animation *animation);
- void (*get_size) (Animation *animation,
- gint *width,
- gint *height);
-
GeglBuffer * (*get_frame) (Animation *animation,
gint pos);
@@ -74,8 +68,7 @@ Animation * animation_new (gint32 image_id,
gint32 animation_get_image_id (Animation *animation);
-void animation_load (Animation *animation,
- gdouble proxy_ratio);
+void animation_load (Animation *animation);
gchar * animation_serialize (Animation *animation);
@@ -83,10 +76,12 @@ gint animation_get_start_position (Animation *animation);
gint animation_get_position (Animation *animation);
gint animation_get_length (Animation *animation);
+void animation_set_proxy (Animation *animation,
+ gdouble ratio);
+gdouble animation_get_proxy (Animation *animation);
void animation_get_size (Animation *animation,
gint *width,
gint *height);
-gdouble animation_get_proxy (Animation *animation);
GeglBuffer * animation_get_frame (Animation *animation,
gint frame_number);
diff --git a/plug-ins/animation-play/core/animationanimatic.c
b/plug-ins/animation-play/core/animationanimatic.c
index 120b9a9..93762fe 100644
--- a/plug-ins/animation-play/core/animationanimatic.c
+++ b/plug-ins/animation-play/core/animationanimatic.c
@@ -60,8 +60,6 @@ typedef struct _AnimationAnimaticPrivate AnimationAnimaticPrivate;
struct _AnimationAnimaticPrivate
{
- gdouble proxy_ratio;
-
/* Panels are cached as GEGL buffers. */
GeglBuffer **cache;
/* The number of panels. */
@@ -86,15 +84,10 @@ static void animation_animatic_finalize (GObject *object);
/* Virtual methods */
static gint animation_animatic_get_length (Animation *animation);
-static void animation_animatic_get_size (Animation *animation,
- gint *width,
- gint *height);
-static void animation_animatic_load (Animation *animation,
- gdouble proxy_ratio);
+static void animation_animatic_load (Animation *animation);
static void animation_animatic_load_xml (Animation *animation,
- const gchar *xml,
- gdouble proxy_ratio);
+ const gchar *xml);
static GeglBuffer * animation_animatic_get_frame (Animation *animation,
gint pos);
static gchar * animation_animatic_serialize (Animation *animation);
@@ -177,7 +170,6 @@ animation_animatic_class_init (AnimationAnimaticClass *klass)
object_class->finalize = animation_animatic_finalize;
anim_class->get_length = animation_animatic_get_length;
- anim_class->get_size = animation_animatic_get_size;
anim_class->load = animation_animatic_load;
anim_class->load_xml = animation_animatic_load_xml;
anim_class->get_frame = animation_animatic_get_frame;
@@ -412,40 +404,13 @@ animation_animatic_get_length (Animation *animation)
}
static void
-animation_animatic_get_size (Animation *animation,
- gint *width,
- gint *height)
-{
- AnimationAnimaticPrivate *priv = GET_PRIVATE (animation);
- gint32 image_id;
- gint image_width;
- gint image_height;
-
- image_id = animation_get_image_id (animation);
-
- image_width = gimp_image_width (image_id);
- image_height = gimp_image_height (image_id);
-
- /* Full preview size. */
- *width = image_width;
- *height = image_height;
-
- /* Apply proxy ratio. */
- *width *= priv->proxy_ratio;
- *height *= priv->proxy_ratio;
-}
-
-static void
-animation_animatic_load (Animation *animation,
- gdouble proxy_ratio)
+animation_animatic_load (Animation *animation)
{
AnimationAnimaticPrivate *priv = GET_PRIVATE (animation);
gint32 *layers;
gint32 image_id;
gint i;
- g_return_if_fail (proxy_ratio > 0.0 && proxy_ratio <= 1.0);
-
/* Cleaning. */
if (priv->cache)
{
@@ -479,7 +444,6 @@ animation_animatic_load (Animation *animation,
gimp_quit ();
return;
}
- priv->proxy_ratio = proxy_ratio;
for (i = 0; i < priv->n_panels; i++)
{
@@ -510,8 +474,7 @@ animation_animatic_load (Animation *animation,
static void
animation_animatic_load_xml (Animation *animation,
- const gchar *xml,
- gdouble proxy_ratio)
+ const gchar *xml)
{
const GMarkupParser markup_parser =
{
@@ -528,7 +491,7 @@ animation_animatic_load_xml (Animation *animation,
g_return_if_fail (xml != NULL);
/* Init with a default load. */
- animation_animatic_load (animation, proxy_ratio);
+ animation_animatic_load (animation);
/* Parse XML to update. */
status.state = START_STATE;
@@ -552,7 +515,7 @@ animation_animatic_load_xml (Animation *animation,
/* If XML parsing failed, just reset the animation. */
if (error)
- animation_animatic_load (animation, proxy_ratio);
+ animation_animatic_load (animation);
}
static GeglBuffer *
@@ -910,6 +873,7 @@ animation_animatic_cache (AnimationAnimatic *animatic,
gint preview_height;
gint32 image_id;
gint32 layer;
+ gdouble proxy_ratio;
image_id = animation_get_image_id (animation);
layer = gimp_image_get_layer_by_tattoo (image_id,
@@ -927,6 +891,7 @@ animation_animatic_cache (AnimationAnimatic *animatic,
}
/* Panel image. */
+ proxy_ratio = animation_get_proxy (animation);
buffer = gimp_drawable_get_buffer (layer);
animation_get_size (animation, &preview_width, &preview_height);
priv->cache[panel - 1] = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
@@ -941,14 +906,14 @@ animation_animatic_cache (AnimationAnimatic *animatic,
scale = gegl_node_new_child (graph,
"operation", "gegl:scale-ratio",
"sampler", GEGL_SAMPLER_NEAREST,
- "x", priv->proxy_ratio,
- "y", priv->proxy_ratio,
+ "x", proxy_ratio,
+ "y", proxy_ratio,
NULL);
gimp_drawable_offsets (layer,
&layer_offx, &layer_offy);
- panel_offx = layer_offx * priv->proxy_ratio;
- panel_offy = layer_offy * priv->proxy_ratio;
+ panel_offx = layer_offx * proxy_ratio;
+ panel_offy = layer_offy * proxy_ratio;
translate = gegl_node_new_child (graph,
"operation", "gegl:translate",
"x", panel_offx,
diff --git a/plug-ins/animation-play/widgets/animation-dialog.c
b/plug-ins/animation-play/widgets/animation-dialog.c
index 7a039b7..e57c398 100755
--- a/plug-ins/animation-play/widgets/animation-dialog.c
+++ b/plug-ins/animation-play/widgets/animation-dialog.c
@@ -75,7 +75,6 @@ struct _AnimationDialogPrivate
GtkWidget *fpscombo;
GtkWidget *zoomcombo;
- GtkWidget *proxycheckbox;
GtkWidget *proxycombo;
GtkWidget *progress;
@@ -164,9 +163,6 @@ static void zoom_out_callback (GtkAction *action,
static void zoom_reset_callback (GtkAction *action,
AnimationDialog *dialog);
-static void proxy_checkbox_expanded (GtkExpander *expander,
- GParamSpec *param_spec,
- AnimationDialog *dialog);
static void proxycombo_activated (GtkEntry *combo_entry,
AnimationDialog *dialog);
static void proxycombo_changed (GtkWidget *combo,
@@ -359,8 +355,7 @@ animation_dialog_new (gint32 image_id)
NULL);
animation_dialog_set_animation (ANIMATION_DIALOG (dialog),
animation);
-
- animation_load (animation, 1.0);
+ animation_load (animation);
return dialog;
}
@@ -439,23 +434,18 @@ animation_dialog_constructed (GObject *object)
gtk_widget_show (priv->settings_bar);
/* Settings: expander to display the proxy settings. */
- priv->proxycheckbox = gtk_expander_new_with_mnemonic (_("_Proxy Quality"));
- gtk_expander_set_expanded (GTK_EXPANDER (priv->proxycheckbox), FALSE);
-
- g_signal_connect (GTK_EXPANDER (priv->proxycheckbox),
- "notify::expanded",
- G_CALLBACK (proxy_checkbox_expanded),
- dialog);
+ widget = gtk_expander_new_with_mnemonic (_("_Proxy"));
+ gtk_expander_set_expanded (GTK_EXPANDER (widget), FALSE);
- gimp_help_set_help_data (priv->proxycheckbox,
+ gimp_help_set_help_data (widget,
_("Degrade image quality for lower memory footprint"),
NULL);
- gtk_box_pack_end (GTK_BOX (priv->settings_bar), priv->proxycheckbox,
+ gtk_box_pack_end (GTK_BOX (priv->settings_bar), widget,
FALSE, FALSE, 0);
- gtk_widget_show (priv->proxycheckbox);
+ gtk_widget_show (widget);
- /* Settings: proxy image. */
+ /* Settings: proxy. */
priv->proxycombo = gtk_combo_box_text_new_with_entry ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->proxycombo),
@@ -480,7 +470,7 @@ animation_dialog_constructed (GObject *object)
gimp_help_set_help_data (priv->proxycombo, _("Proxy resolution quality"), NULL);
gtk_widget_show (priv->proxycombo);
- gtk_container_add (GTK_CONTAINER (priv->proxycheckbox),
+ gtk_container_add (GTK_CONTAINER (widget),
priv->proxycombo);
/* Settings: fps */
@@ -1096,9 +1086,6 @@ animation_dialog_set_animation (AnimationDialog *dialog,
}
/* Block all handlers on UI widgets. */
- g_signal_handlers_block_by_func (GTK_EXPANDER (priv->proxycheckbox),
- G_CALLBACK (proxy_checkbox_expanded),
- dialog);
g_signal_handlers_block_by_func (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->proxycombo))),
G_CALLBACK (proxycombo_activated),
dialog);
@@ -1137,9 +1124,6 @@ animation_dialog_set_animation (AnimationDialog *dialog,
priv->animation = animation;
/* Settings: proxy image. */
- g_signal_handlers_unblock_by_func (GTK_EXPANDER (priv->proxycheckbox),
- G_CALLBACK (proxy_checkbox_expanded),
- dialog);
g_signal_handlers_unblock_by_func (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->proxycombo))),
G_CALLBACK (proxycombo_activated),
dialog);
@@ -1518,31 +1502,6 @@ zoom_reset_callback (GtkAction *action,
}
/*
- * Callback emitted when the user toggle the proxy checkbox.
- */
-static void
-proxy_checkbox_expanded (GtkExpander *expander,
- GParamSpec *param_spec,
- AnimationDialog *dialog)
-{
- AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
-
- if (gtk_expander_get_expanded (expander))
- {
- proxycombo_activated (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->proxycombo))),
- dialog);
- }
- else if (animation_get_proxy (priv->animation) != 1.0)
- {
- /* Closing the expander. Proxy is deactived. */
- gint index = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->zoomcombo));
-
- animation_load (priv->animation, 1.0);
- update_scale (dialog, get_zoom (dialog, index));
- }
-}
-
-/*
* Callback emitted when the user hits the Enter key of the fps combo.
*/
static void
@@ -1581,7 +1540,7 @@ proxycombo_activated (GtkEntry *combo_entry,
was_playing = animation_is_playing (priv->animation);
- animation_load (priv->animation, ratio);
+ animation_set_proxy (priv->animation, ratio);
update_scale (dialog, get_zoom (dialog, -1));
if (was_playing)
@@ -1809,8 +1768,7 @@ refresh_callback (GtkAction *action,
AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
animation_dialog_refresh (dialog);
- animation_load (priv->animation,
- animation_get_proxy (priv->animation));
+ animation_load (priv->animation);
}
static void
@@ -2019,9 +1977,6 @@ proxy_changed (Animation *animation,
AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
gchar *text;
- g_signal_handlers_block_by_func (GTK_EXPANDER (priv->proxycheckbox),
- G_CALLBACK (proxy_checkbox_expanded),
- dialog);
g_signal_handlers_block_by_func (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->proxycombo))),
G_CALLBACK (proxycombo_activated),
dialog);
@@ -2033,14 +1988,6 @@ proxy_changed (Animation *animation,
gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->proxycombo))), text);
g_free (text);
- if (proxy == 1.0)
- gtk_expander_set_expanded (GTK_EXPANDER (priv->proxycheckbox), FALSE);
- else
- gtk_expander_set_expanded (GTK_EXPANDER (priv->proxycheckbox), TRUE);
-
- g_signal_handlers_unblock_by_func (GTK_EXPANDER (priv->proxycheckbox),
- G_CALLBACK (proxy_checkbox_expanded),
- dialog);
g_signal_handlers_unblock_by_func (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->proxycombo))),
G_CALLBACK (proxycombo_activated),
dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]