Commit c00e93ed authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Improve progressive loading from slow sources: (#107368)

2003-05-19  Matthias Clasen  <maclas@gmx.de>

	Improve progressive loading from slow sources:  (#107368)

	* io-gif-animation.c (gdk_pixbuf_gif_anim_get_iter): Initialize
	first_loop_slowness.
	(gdk_pixbuf_gif_anim_iter_advance): Don't wrap during loading if
	the datasource falls behind the speed of the display.

	* io-gif-animation.h: Add a loading flag to GdkPixbufGifAnim and
	first_loop_slowness to GdkPixbufGifAnimIter.
parent 28527477
......@@ -180,6 +180,7 @@ gdk_pixbuf_gif_anim_get_iter (GdkPixbufAnimation *anim,
iter->start_time = *start_time;
iter->current_time = *start_time;
iter->first_loop_slowness = 0;
return GDK_PIXBUF_ANIMATION_ITER (iter);
}
......@@ -287,8 +288,21 @@ gdk_pixbuf_gif_anim_iter_advance (GdkPixbufAnimationIter *anim_iter,
* and subtract time for that.
*/
loop = elapsed / iter->gif_anim->total_time;
elapsed = elapsed % iter->gif_anim->total_time;
if (iter->gif_anim->loading)
loop = 0;
else {
/* If current_frame is NULL at this point, we have loaded the
* animation from a source which fell behind the speed of the
* display. We remember how much slower the first loop was due
* to this and correct the position calculation in order to not
* jump in the middle of the second loop.
*/
if (iter->current_frame == NULL)
iter->first_loop_slowness = MAX(0, elapsed - iter->gif_anim->total_time);
loop = (elapsed - iter->first_loop_slowness) / iter->gif_anim->total_time;
elapsed = (elapsed - iter->first_loop_slowness) % iter->gif_anim->total_time;
}
iter->position = elapsed;
......@@ -334,9 +348,8 @@ gdk_pixbuf_gif_anim_iter_get_delay_time (GdkPixbufAnimationIter *anim_iter)
#endif
return frame->delay_time - (iter->position - frame->elapsed);
} else {
} else
return -1; /* show last frame forever */
}
}
void
......
......@@ -78,6 +78,7 @@ struct _GdkPixbufGifAnim {
guchar bg_blue;
int loop;
gboolean loading;
};
struct _GdkPixbufGifAnimClass {
......@@ -113,6 +114,8 @@ struct _GdkPixbufGifAnimIter {
gint position;
GList *current_frame;
gint first_loop_slowness;
};
struct _GdkPixbufGifAnimIterClass {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment