[gimp/wip/animation: 153/197] plug-ins: proxy ratio is a data for the AnimationPlayback.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 153/197] plug-ins: proxy ratio is a data for the AnimationPlayback.
- Date: Sat, 7 Oct 2017 03:11:18 +0000 (UTC)
commit c536d16959f4dc0201cf38a158d688679ee2bc2c
Author: Jehan <jehan girinstud io>
Date: Tue May 30 20:22:44 2017 +0200
plug-ins: proxy ratio is a data for the AnimationPlayback.
This should not be stored in the Animation.
Also there are now 2 separate animation_get_size() and
animation_playback_get_size(), the former being obviously the full size
for the animation whereas the later is the preview size after proxy
applied.
plug-ins/animation-play/core/animation-animatic.c | 10 ++--
.../animation-play/core/animation-celanimation.c | 10 ++--
plug-ins/animation-play/core/animation-playback.c | 56 ++++++++++++++++++++
plug-ins/animation-play/core/animation-playback.h | 9 +++
plug-ins/animation-play/core/animation-renderer.c | 16 ++++--
plug-ins/animation-play/core/animation.c | 52 ------------------
plug-ins/animation-play/core/animation.h | 8 +--
plug-ins/animation-play/widgets/animation-dialog.c | 39 ++++++++------
8 files changed, 112 insertions(+), 88 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation-animatic.c
b/plug-ins/animation-play/core/animation-animatic.c
index fd2e789..e2616df 100644
--- a/plug-ins/animation-play/core/animation-animatic.c
+++ b/plug-ins/animation-play/core/animation-animatic.c
@@ -90,7 +90,8 @@ static gchar * animation_animatic_get_frame_hash (Animation *animat
gint position);
static GeglBuffer * animation_animatic_create_frame (Animation *animation,
GObject *renderer,
- gint position);
+ gint position,
+ gdouble proxy_ratio);
static void animation_animatic_reset_defaults (Animation *animation);
static gchar * animation_animatic_serialize (Animation *animation,
@@ -408,7 +409,8 @@ animation_animatic_get_frame_hash (Animation *animation,
static GeglBuffer *
animation_animatic_create_frame (Animation *animation,
GObject *renderer,
- gint position)
+ gint position,
+ gdouble proxy_ratio)
{
AnimationAnimaticPrivate *priv = GET_PRIVATE (animation);
GeglBuffer *buffer;
@@ -420,7 +422,6 @@ animation_animatic_create_frame (Animation *animation,
gint preview_height;
gint32 image_id;
gint32 layer;
- gdouble proxy_ratio;
gint panel;
panel = animation_animatic_get_panel (ANIMATION_ANIMATIC (animation),
@@ -436,9 +437,10 @@ animation_animatic_create_frame (Animation *animation,
return NULL;
}
- proxy_ratio = animation_get_proxy (animation);
buffer2 = gimp_drawable_get_buffer (layer);
animation_get_size (animation, &preview_width, &preview_height);
+ preview_height *= proxy_ratio;
+ preview_width *= proxy_ratio;
gimp_drawable_offsets (layer,
&layer_offx, &layer_offy);
diff --git a/plug-ins/animation-play/core/animation-celanimation.c
b/plug-ins/animation-play/core/animation-celanimation.c
index 98272cc..eabcd4c 100644
--- a/plug-ins/animation-play/core/animation-celanimation.c
+++ b/plug-ins/animation-play/core/animation-celanimation.c
@@ -95,7 +95,8 @@ static gchar * animation_cel_animation_get_frame_hash (Animation *ani
gint position);
static GeglBuffer * animation_cel_animation_create_frame (Animation *animation,
GObject *renderer,
- gint position);
+ gint position,
+ gdouble proxy_ratio);
static void animation_cel_animation_reset_defaults (Animation *animation);
static gchar * animation_cel_animation_serialize (Animation *animation,
@@ -649,13 +650,13 @@ animation_cel_animation_get_frame_hash (Animation *animation,
static GeglBuffer *
animation_cel_animation_create_frame (Animation *animation,
GObject *renderer G_GNUC_UNUSED,
- gint position)
+ gint position,
+ gdouble proxy_ratio)
{
AnimationCelAnimation *cel_animation;
GeglBuffer *buffer = NULL;
GList *iter;
gint32 image_id;
- gdouble proxy_ratio;
gint preview_width;
gint preview_height;
gint offset_x;
@@ -663,9 +664,10 @@ animation_cel_animation_create_frame (Animation *animation,
cel_animation = ANIMATION_CEL_ANIMATION (animation);
image_id = animation_get_image_id (animation);
- proxy_ratio = animation_get_proxy (animation);
animation_get_size (animation,
&preview_width, &preview_height);
+ preview_height *= proxy_ratio;
+ preview_width *= proxy_ratio;
animation_camera_get (cel_animation->priv->camera,
position, &offset_x, &offset_y);
diff --git a/plug-ins/animation-play/core/animation-playback.c
b/plug-ins/animation-play/core/animation-playback.c
index aeb50a9..f92d4ec 100644
--- a/plug-ins/animation-play/core/animation-playback.c
+++ b/plug-ins/animation-play/core/animation-playback.c
@@ -36,6 +36,7 @@ enum
RANGE,
RENDER,
LOW_FRAMERATE,
+ PROXY_CHANGED,
LAST_SIGNAL
};
@@ -57,6 +58,8 @@ struct _AnimationPlaybackPrivate
gint stop;
gboolean stop_at_end;
+ gdouble proxy_ratio;
+
guint timer;
gint64 start_time;
gint64 frames_played;
@@ -206,6 +209,24 @@ animation_playback_class_init (AnimationPlaybackClass *klass)
1,
G_TYPE_DOUBLE);
+ /**
+ * AnimationPlayback::proxy:
+ * @playback: the #AnimationPlayback.
+ * @ratio: the current proxy ratio [0-1.0].
+ *
+ * The ::proxy signal is emitted to announce a change of proxy size.
+ */
+ animation_playback_signals[PROXY_CHANGED] =
+ g_signal_new ("proxy-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (AnimationPlaybackClass, proxy_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_DOUBLE);
+
object_class->finalize = animation_playback_finalize;
object_class->set_property = animation_playback_set_property;
object_class->get_property = animation_playback_get_property;
@@ -230,6 +251,7 @@ animation_playback_init (AnimationPlayback *playback)
playback->priv = G_TYPE_INSTANCE_GET_PRIVATE (playback,
ANIMATION_TYPE_PLAYBACK,
AnimationPlaybackPrivate);
+ playback->priv->proxy_ratio = 1.0;
}
/************ Public Functions ****************/
@@ -548,6 +570,40 @@ animation_playback_get_stop (AnimationPlayback *playback)
return playback->priv->stop;
}
+void
+animation_playback_get_size (AnimationPlayback *playback,
+ gint *width,
+ gint *height)
+{
+ animation_get_size (playback->priv->animation,
+ width, height);
+
+ /* Apply proxy ratio. */
+ *width *= playback->priv->proxy_ratio;
+ *height *= playback->priv->proxy_ratio;
+}
+
+void
+animation_playback_set_proxy (AnimationPlayback *playback,
+ gdouble ratio)
+{
+ g_return_if_fail (ratio > 0.0 && ratio <= 1.0);
+
+ if (playback->priv->proxy_ratio != ratio)
+ {
+ playback->priv->proxy_ratio = ratio;
+ g_signal_emit (playback,
+ animation_playback_signals[PROXY_CHANGED],
+ 0, ratio);
+ }
+}
+
+gdouble
+animation_playback_get_proxy (AnimationPlayback *playback)
+{
+ return playback->priv->proxy_ratio;
+}
+
/************ Private Functions ****************/
static void
diff --git a/plug-ins/animation-play/core/animation-playback.h
b/plug-ins/animation-play/core/animation-playback.h
index 145ac57..12f59ab 100644
--- a/plug-ins/animation-play/core/animation-playback.h
+++ b/plug-ins/animation-play/core/animation-playback.h
@@ -55,6 +55,8 @@ struct _AnimationPlaybackClass
gboolean must_draw_null);
void (*low_framerate) (AnimationPlayback *playback,
gdouble actual_fps);
+ void (*proxy_changed) (Animation *animation,
+ gdouble ratio);
};
GType animation_playback_get_type (void);
@@ -87,4 +89,11 @@ void animation_playback_set_stop (AnimationPlayback *playback,
gint index);
gint animation_playback_get_stop (AnimationPlayback *playback);
+void animation_playback_get_size (AnimationPlayback *playback,
+ gint *width,
+ gint *height);
+void animation_playback_set_proxy (AnimationPlayback *playback,
+ gdouble ratio);
+gdouble animation_playback_get_proxy (AnimationPlayback *playback);
+
#endif /* __ANIMATION_PLAYBACK_H__ */
diff --git a/plug-ins/animation-play/core/animation-renderer.c
b/plug-ins/animation-play/core/animation-renderer.c
index a29bb9f..6a229f7 100644
--- a/plug-ins/animation-play/core/animation-renderer.c
+++ b/plug-ins/animation-play/core/animation-renderer.c
@@ -72,9 +72,10 @@ static void animation_renderer_get_property (GObject *object,
static gpointer animation_renderer_process_queue (AnimationRenderer *renderer);
static gboolean animation_renderer_idle_update (AnimationRenderer *renderer);
-static void on_proxy_changed (Animation *animation,
+static void on_proxy_changed (AnimationPlayback *animation,
gdouble ratio,
AnimationRenderer *renderer);
+
static void on_frames_changed (Animation *animation,
gint position,
gint length,
@@ -279,9 +280,13 @@ animation_renderer_process_queue (AnimationRenderer *renderer)
if (! buffer)
{
+ gdouble proxy_ratio;
+
+ proxy_ratio = animation_playback_get_proxy (renderer->priv->playback);
buffer = ANIMATION_GET_CLASS (animation)->create_frame (animation,
G_OBJECT (renderer),
- frame);
+ frame,
+ proxy_ratio);
g_weak_ref_set (ref, buffer);
}
}
@@ -341,11 +346,12 @@ animation_renderer_idle_update (AnimationRenderer *renderer)
}
static void
-on_proxy_changed (Animation *animation,
+on_proxy_changed (AnimationPlayback *playback,
gdouble ratio,
AnimationRenderer *renderer)
{
- gint i;
+ Animation *animation = animation_playback_get_animation (playback);
+ gint i;
if (renderer->priv->idle_id)
{
@@ -508,7 +514,7 @@ animation_renderer_new (GObject *playback)
G_CALLBACK (on_duration_changed), renderer);
g_signal_connect (animation, "loaded",
G_CALLBACK (on_animation_loaded), renderer);
- g_signal_connect (animation, "proxy-changed",
+ g_signal_connect (renderer->priv->playback, "proxy-changed",
G_CALLBACK (on_proxy_changed), renderer);
return object;
diff --git a/plug-ins/animation-play/core/animation.c b/plug-ins/animation-play/core/animation.c
index d4fc4c4..9ffe2c8 100644
--- a/plug-ins/animation-play/core/animation.c
+++ b/plug-ins/animation-play/core/animation.c
@@ -49,7 +49,6 @@ enum
FRAMES_CHANGED,
DURATION_CHANGED,
FRAMERATE_CHANGED,
- PROXY_CHANGED,
LAST_SIGNAL
};
@@ -68,9 +67,6 @@ struct _AnimationPrivate
gdouble framerate;
- /* Proxy settings generates a reload. */
- gdouble proxy_ratio;
-
gboolean loaded;
};
@@ -197,23 +193,6 @@ animation_class_init (AnimationClass *klass)
G_TYPE_NONE,
1,
G_TYPE_DOUBLE);
- /**
- * Animation::proxy:
- * @animation: the animation.
- * @ratio: the current proxy ratio [0-1.0].
- *
- * The ::proxy signal is emitted to announce a change of proxy size.
- */
- animation_signals[PROXY_CHANGED] =
- g_signal_new ("proxy-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (AnimationClass, proxy),
- NULL, NULL,
- g_cclosure_marshal_VOID__DOUBLE,
- G_TYPE_NONE,
- 1,
- G_TYPE_DOUBLE);
object_class->finalize = animation_finalize;
object_class->set_property = animation_set_property;
@@ -257,7 +236,6 @@ animation_init (Animation *animation)
/* Acceptable settings for the default. */
priv->framerate = settings.framerate;
- priv->proxy_ratio = 1.0;
}
/************ Public Functions ****************/
@@ -395,32 +373,6 @@ animation_get_duration (Animation *animation)
}
void
-animation_set_proxy (Animation *animation,
- gdouble ratio)
-{
- 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_CHANGED], 0, ratio);
-
- /* A proxy change implies a reload. */
- animation_load (animation);
- }
-}
-
-gdouble
-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)
@@ -435,10 +387,6 @@ animation_get_size (Animation *animation,
/* Full preview size. */
*width = image_width;
*height = image_height;
-
- /* Apply proxy ratio. */
- *width *= priv->proxy_ratio;
- *height *= priv->proxy_ratio;
}
void
diff --git a/plug-ins/animation-play/core/animation.h b/plug-ins/animation-play/core/animation.h
index 3a17d7d..e4c9aad 100644
--- a/plug-ins/animation-play/core/animation.h
+++ b/plug-ins/animation-play/core/animation.h
@@ -52,8 +52,6 @@ struct _AnimationClass
gint duration);
void (*framerate_changed) (Animation *animation,
gdouble fps);
- void (*proxy) (Animation *animation,
- gdouble ratio);
/* These virtual methods must be implemented by any subclass. */
gint (*get_duration) (Animation *animation);
@@ -73,7 +71,8 @@ struct _AnimationClass
gint position);
GeglBuffer * (*create_frame) (Animation *animation,
GObject *renderer,
- gint position);
+ gint position,
+ gdouble proxy_ratio);
};
GType animation_get_type (void);
@@ -91,9 +90,6 @@ void animation_save_to_parasite (Animation *animation,
gint animation_get_duration (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);
diff --git a/plug-ins/animation-play/widgets/animation-dialog.c
b/plug-ins/animation-play/widgets/animation-dialog.c
index 517a3e7..1534caa 100755
--- a/plug-ins/animation-play/widgets/animation-dialog.c
+++ b/plug-ins/animation-play/widgets/animation-dialog.c
@@ -1408,9 +1408,6 @@ animation_dialog_set_animation (AnimationDialog *dialog,
dialog);
/* Animation. */
- g_signal_connect (priv->animation, "proxy-changed",
- G_CALLBACK (proxy_changed),
- dialog);
g_signal_connect (priv->animation, "framerate-changed",
G_CALLBACK (framerate_changed),
dialog);
@@ -1424,6 +1421,11 @@ animation_dialog_set_animation (AnimationDialog *dialog,
g_signal_connect_swapped (priv->animation, "loaded",
(GCallback) update_progress,
dialog);
+
+ /* Playback. */
+ g_signal_connect (priv->playback, "proxy-changed",
+ G_CALLBACK (proxy_changed),
+ dialog);
g_signal_connect (priv->playback, "render",
G_CALLBACK (render_callback),
dialog);
@@ -1730,13 +1732,13 @@ proxycombo_activated (GtkEntry *combo_entry,
g_free (text);
/* Finally set the preview size, unless they were already good. */
- if (animation_get_proxy (priv->animation) != ratio)
+ if (animation_playback_get_proxy (priv->playback) != ratio)
{
gboolean was_playing;
was_playing = animation_playback_is_playing (priv->playback);
- animation_set_proxy (priv->animation, ratio);
+ animation_playback_set_proxy (priv->playback, ratio);
update_scale (dialog, get_zoom (dialog, -1));
if (was_playing)
@@ -2209,14 +2211,14 @@ repaint_da (GtkWidget *darea,
AnimationDialog *dialog)
{
AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
- GtkStyle *style = gtk_widget_get_style (darea);
- guchar *da_data;
- gint da_width;
- gint da_height;
- gint preview_width, preview_height;
-
- animation_get_size (priv->animation, &preview_width, &preview_height);
+ GtkStyle *style = gtk_widget_get_style (darea);
+ guchar *da_data;
+ gint da_width;
+ gint da_height;
+ gint preview_width, preview_height;
+ animation_playback_get_size (priv->playback,
+ &preview_width, &preview_height);
if (darea == priv->drawing_area)
{
da_width = priv->drawing_area_width;
@@ -2324,7 +2326,8 @@ da_size_callback (GtkWidget *drawing_area,
drawing_data = &priv->drawing_area_data;
}
- animation_get_size (priv->animation, &preview_width, &preview_height);
+ animation_playback_get_size (priv->playback,
+ &preview_width, &preview_height);
priv->zoom = MIN ((gdouble) allocation->width / (gdouble) preview_width,
(gdouble) allocation->height / (gdouble) preview_height);
@@ -2608,7 +2611,8 @@ render_frame (AnimationDialog *dialog,
}
/* Display the preview buffer. */
- animation_get_size (priv->animation, &preview_width, &preview_height);
+ animation_playback_get_size (priv->playback,
+ &preview_width, &preview_height);
gdk_draw_rgb_image (gtk_widget_get_window (da),
(gtk_widget_get_style (da))->white_gc,
(gint) (((gint)drawing_width - priv->zoom * preview_width) / 2),
@@ -2884,7 +2888,8 @@ get_zoom (AnimationDialog *dialog,
gint width;
gint height;
- animation_get_size (priv->animation, &width, &height);
+ animation_playback_get_size (priv->playback,
+ &width, &height);
gtk_widget_get_allocation (priv->scrolled_drawing_area, &allocation);
if (width > allocation.width || height > allocation.height)
{
@@ -2949,8 +2954,8 @@ update_scale (AnimationDialog *dialog,
if (priv->animation == NULL)
return;
- animation_get_size (priv->animation, &preview_width, &preview_height);
-
+ animation_playback_get_size (priv->playback,
+ &preview_width, &preview_height);
expected_drawing_area_width = preview_width * scale;
expected_drawing_area_height = preview_height * scale;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]