Commit 8b34aeb6 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Change the order of the update func to make it more compatible with the

2000-01-05  Jonathan Blandford  <jrb@redhat.com>

	* gdk-pixbuf/gdk-pixbuf-io.h: Change the order of the update func
	to make it more compatible with the rest of GTK.  Added animation
	framework for progressive loading.

	* gdk-pixbuf/io-bmp.c (image_begin_load): Modified to handle new
	system.
	* gdk-pixbuf/io-ico.c (image_begin_load): ditto
	* gdk-pixbuf/io-png.c (image_begin_load): ditto
	* gdk-pixbuf/io-ras.c (image_begin_load): ditto
	* gdk-pixbuf/io-jpeg.c (image_begin_load): ditto
	* gdk-pixbuf/io-pnm.c (image_begin_load): ditto
	* gdk-pixbuf/io-tiff.c (image_begin_load): ditto
	* gdk-pixbuf/io-gif.c (image_begin_load): ditto
parent 30caacfd
/* GdkPixbuf library - Io handling
/* GdkPixbuf library - Io handling. This is an internal header for gdk-pixbuf.
* You should never use it unless you are doing developement for gdkpixbuf itself.
*
* Copyright (C) 1999 The Free Software Foundation
*
......@@ -38,9 +39,16 @@ extern "C" {
typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data,
typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf,
guint x, guint y,
guint width, guint height);
guint width, guint height,
gpointer user_data);
/* Needed only for animated images. */
typedef void (* ModuleFrameDoneNotifyFunc) (GdkPixbuf *pixbuf,
gint frame,
gpointer user_data);
typedef void (* ModuleAnimationDoneNotifyFunc) (GdkPixbuf *pixbuf,
gpointer user_data);
typedef struct _GdkPixbufModule GdkPixbufModule;
struct _GdkPixbufModule {
......@@ -54,6 +62,8 @@ struct _GdkPixbufModule {
gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
ModuleUpdatedNotifyFunc update_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void (* stop_load) (gpointer context);
gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
......
......@@ -222,7 +222,7 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
}
static void
gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, guint x, guint y, guint width, guint height, gpointer loader)
{
GdkPixbufLoaderPrivate *priv = NULL;
......@@ -276,7 +276,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
return 0;
}
priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, NULL, NULL, loader);
if (priv->context == NULL) {
g_warning("Failed to begin progressive load");
......
......@@ -173,7 +173,10 @@ struct bmp_progressive_state {
gpointer
image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func, gpointer user_data);
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void image_stop_load(gpointer data);
gboolean image_load_increment(gpointer data, guchar * buf, guint size);
......@@ -189,7 +192,7 @@ GdkPixbuf *image_load(FILE * f)
GdkPixbuf *pb;
State = image_begin_load(NULL, NULL, NULL);
State = image_begin_load(NULL, NULL, NULL, NULL, NULL);
membuf = g_malloc(4096);
g_assert(membuf != NULL);
......@@ -303,7 +306,10 @@ static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
gpointer
image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func, gpointer user_data)
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
struct bmp_progressive_state *context;
......@@ -529,11 +535,11 @@ static void OneLine(struct bmp_progressive_state *context)
if (context->updated_func != NULL) {
(*context->updated_func) (context->pixbuf,
context->user_data,
0,
context->Lines,
context->Header.width,
context->Header.height);
context->Header.height,
context->user_data);
}
}
......
......@@ -786,31 +786,31 @@ gif_get_lzw (GifContext *context)
if (lower_bound <= upper_bound && first_pass == context->draw_pass) {
(* context->update_func)
(context->pixbuf,
context->user_data,
0, lower_bound,
gdk_pixbuf_get_width (context->pixbuf),
upper_bound - lower_bound);
upper_bound - lower_bound,
context->user_data);
} else {
if (lower_bound <= upper_bound) {
(* context->update_func)
(context->pixbuf,
context->user_data,
0, 0,
gdk_pixbuf_get_width (context->pixbuf),
gdk_pixbuf_get_height (context->pixbuf));
gdk_pixbuf_get_height (context->pixbuf),
context->user_data);
} else {
(* context->update_func)
(context->pixbuf,
context->user_data,
0, 0,
gdk_pixbuf_get_width (context->pixbuf),
upper_bound);
upper_bound,
context->user_data);
(* context->update_func)
(context->pixbuf,
context->user_data,
0, lower_bound,
gdk_pixbuf_get_width (context->pixbuf),
gdk_pixbuf_get_height (context->pixbuf));
gdk_pixbuf_get_height (context->pixbuf),
context->user_data);
}
}
}
......@@ -1087,6 +1087,8 @@ image_load (FILE *file)
gpointer
image_begin_load (ModulePreparedNotifyFunc prepare_func,
ModuleUpdatedNotifyFunc update_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
GifContext *context;
......
......@@ -154,7 +154,10 @@ struct ico_progressive_state {
gpointer
image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func, gpointer user_data);
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void image_stop_load(gpointer data);
gboolean image_load_increment(gpointer data, guchar * buf, guint size);
......@@ -170,7 +173,7 @@ GdkPixbuf *image_load(FILE * f)
GdkPixbuf *pb;
State = image_begin_load(NULL, NULL, NULL);
State = image_begin_load(NULL, NULL, NULL, NULL, NULL);
membuf = g_malloc(4096);
g_assert(membuf != NULL);
......@@ -363,7 +366,10 @@ static void DecodeHeader(guchar *Data, gint Bytes,
gpointer
image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func, gpointer user_data)
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
struct ico_progressive_state *context;
......@@ -609,11 +615,11 @@ static void OneLine(struct ico_progressive_state *context)
if (context->updated_func != NULL) {
(*context->updated_func) (context->pixbuf,
context->user_data,
0,
context->Lines,
context->Header.width,
context->Header.height);
context->Header.height,
context->user_data);
}
}
......
......@@ -89,7 +89,10 @@ typedef struct {
GdkPixbuf *image_load (FILE *f);
gpointer image_begin_load (ModulePreparedNotifyFunc func,
ModuleUpdatedNotifyFunc func2, gpointer user_data);
ModuleUpdatedNotifyFunc func2,
ModuleFrameDoneNotifyFunc func3,
ModuleAnimationDoneNotifyFunc func4,
gpointer user_data);
void image_stop_load (gpointer context);
gboolean image_load_increment(gpointer context, guchar *buf, guint size);
......@@ -274,6 +277,8 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
gpointer
image_begin_load (ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
JpegProgContext *context;
......@@ -508,11 +513,11 @@ image_load_increment (gpointer data, guchar *buf, guint size)
/* send updated signal */
(* context->updated_func) (context->pixbuf,
context->user_data,
0,
cinfo->output_scanline-1,
cinfo->image_width,
nlines);
0,
cinfo->output_scanline-1,
cinfo->image_width,
nlines,
context->user_data);
#undef DEBUG_JPEG_PROGRESSIVE
#ifdef DEBUG_JPEG_PROGRESSIVE
......
......@@ -276,6 +276,8 @@ struct _LoadContext {
gpointer
image_begin_load (ModulePreparedNotifyFunc prepare_func,
ModuleUpdatedNotifyFunc update_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
LoadContext* lc;
......@@ -367,34 +369,38 @@ image_load_increment(gpointer context, guchar *buf, guint size)
if (pass_diff == 0) {
/* start and end row were in the same pass */
(lc->update_func)(lc->pixbuf, lc->notify_user_data, 0,
(lc->update_func)(lc->pixbuf, 0,
lc->first_row_seen_in_chunk,
lc->pixbuf->art_pixbuf->width,
(lc->last_row_seen_in_chunk -
lc->first_row_seen_in_chunk) + 1);
lc->first_row_seen_in_chunk) + 1,
lc->notify_user_data);
} else if (pass_diff == 1) {
/* We have from the first row seen to
the end of the image (max row
seen), then from the top of the
image to the last row seen */
/* first row to end */
(lc->update_func)(lc->pixbuf, lc->notify_user_data, 0,
(lc->update_func)(lc->pixbuf, 0,
lc->first_row_seen_in_chunk,
lc->pixbuf->art_pixbuf->width,
(lc->max_row_seen_in_chunk -
lc->first_row_seen_in_chunk) + 1);
lc->first_row_seen_in_chunk) + 1,
lc->notify_user_data);
/* top to last row */
(lc->update_func)(lc->pixbuf, lc->notify_user_data,
(lc->update_func)(lc->pixbuf,
0, 0,
lc->pixbuf->art_pixbuf->width,
lc->last_row_seen_in_chunk + 1);
lc->last_row_seen_in_chunk + 1,
lc->notify_user_data);
} else {
/* We made at least one entire pass, so update the
whole image */
(lc->update_func)(lc->pixbuf, lc->notify_user_data,
(lc->update_func)(lc->pixbuf,
0, 0,
lc->pixbuf->art_pixbuf->width,
lc->max_row_seen_in_chunk + 1);
lc->max_row_seen_in_chunk + 1,
lc->notify_user_data);
}
}
......
......@@ -77,7 +77,10 @@ typedef struct {
GdkPixbuf *image_load (FILE *f);
gpointer image_begin_load (ModulePreparedNotifyFunc func,
ModuleUpdatedNotifyFunc func2, gpointer user_data);
ModuleUpdatedNotifyFunc func2,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void image_stop_load (gpointer context);
gboolean image_load_increment(gpointer context, guchar *buf, guint size);
......@@ -686,6 +689,8 @@ image_load (FILE *f)
gpointer
image_begin_load (ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
PnmLoaderContext *context;
......@@ -836,11 +841,11 @@ image_load_increment (gpointer data, guchar *buf, guint size)
/* send updated signal */
(* context->updated_func) (context->pixbuf,
context->user_data,
0,
context->output_row-1,
context->width,
1);
0,
context->output_row-1,
context->width,
1,
context->user_data);
}
}
......
......@@ -94,7 +94,10 @@ struct ras_progressive_state {
gpointer
image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func, gpointer user_data);
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void image_stop_load(gpointer data);
gboolean image_load_increment(gpointer data, guchar * buf, guint size);
......@@ -109,7 +112,7 @@ GdkPixbuf *image_load(FILE * f)
GdkPixbuf *pb;
State = image_begin_load(NULL, NULL, NULL);
State = image_begin_load(NULL, NULL, NULL, NULL, NULL);
membuf = g_malloc(4096);
......@@ -206,7 +209,10 @@ static void RAS2State(struct rasterfile *RAS,
gpointer
image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func, gpointer user_data)
ModuleUpdatedNotifyFunc updated_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
struct ras_progressive_state *context;
......@@ -364,11 +370,11 @@ static void OneLine(struct ras_progressive_state *context)
if (context->updated_func != NULL) {
(*context->updated_func) (context->pixbuf,
context->user_data,
0,
context->Lines,
context->Header.width,
context->Header.height);
context->Header.height,
context->user_data);
}
}
......
......@@ -111,7 +111,7 @@ image_load_real (FILE *f, TiffData *context)
if (context) {
gdk_pixbuf_unref (pixbuf);
(* context->update_func) (pixbuf, context->user_data, 0, 0, w, h);
(* context->update_func) (pixbuf, 0, 0, w, h, context->user_data);
}
return pixbuf;
......@@ -139,6 +139,8 @@ image_load (FILE *f)
gpointer
image_begin_load (ModulePreparedNotifyFunc prepare_func,
ModuleUpdatedNotifyFunc update_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data)
{
TiffData *context;
......
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