mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
handle the actual update. add a update_func callback. add a update_func
1999-11-04 Jonathan Blandford <jrb@redhat.com> * src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_update): handle the actual update. * src/io-png.c (image_begin_load): add a update_func callback. * src/io-gif.c (image_begin_load): add a update_func callback. * src/io-tiff.c (image_begin_load): add a update_func callback.
This commit is contained in:
parent
567305020d
commit
d0ed72ee14
@ -1,3 +1,11 @@
|
||||
1999-11-04 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_update): handle the
|
||||
actual update.
|
||||
* src/io-png.c (image_begin_load): add a update_func callback.
|
||||
* src/io-gif.c (image_begin_load): add a update_func callback.
|
||||
* src/io-tiff.c (image_begin_load): add a update_func callback.
|
||||
|
||||
1999-11-04 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* doc/tmpl/gdk-pixbuf.sgml: Populated.
|
||||
|
@ -39,6 +39,7 @@ extern "C" {
|
||||
|
||||
|
||||
typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
|
||||
typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data, guint x, guint y, guint width, guint height);
|
||||
|
||||
typedef struct _GdkPixbufModule GdkPixbufModule;
|
||||
struct _GdkPixbufModule {
|
||||
@ -49,7 +50,7 @@ struct _GdkPixbufModule {
|
||||
GdkPixbuf *(* load_xpm_data) (const gchar **data);
|
||||
|
||||
/* Incremental loading */
|
||||
gpointer (* begin_load) (ModulePreparedNotifyFunc func, gpointer user_data);
|
||||
gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data);
|
||||
void (* stop_load) (gpointer context);
|
||||
gboolean (* load_increment)(gpointer context, const gchar *buf, guint size);
|
||||
};
|
||||
|
@ -219,6 +219,21 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
|
||||
gtk_signal_emit (GTK_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED]);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
|
||||
{
|
||||
GdkPixbufLoaderPrivate *priv = NULL;
|
||||
|
||||
priv = GDK_PIXBUF_LOADER (loader)->private;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (loader),
|
||||
pixbuf_loader_signals[AREA_UPDATED],
|
||||
x, y,
|
||||
/* sanity check in here. Defend against an errant loader */
|
||||
MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
|
||||
MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -259,7 +274,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
|
||||
return 0;
|
||||
}
|
||||
|
||||
priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
|
||||
priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
|
||||
|
||||
if (priv->context == NULL) {
|
||||
g_warning("Failed to begin progressive load");
|
||||
|
@ -59,7 +59,7 @@ struct _GdkPixbufLoaderClass {
|
||||
void (* area_prepared) (GdkPixbufLoader *loader);
|
||||
|
||||
void (* area_updated) (GdkPixbufLoader *loader,
|
||||
int x, int y, int width, int height);
|
||||
guint x, guint y, guint width, guint height);
|
||||
|
||||
void (* closed) (GdkPixbufLoader *loader);
|
||||
};
|
||||
|
@ -121,7 +121,8 @@ struct _GifContext
|
||||
FILE *file;
|
||||
|
||||
/* progressive read, only. */
|
||||
ModulePreparedNotifyFunc func;
|
||||
ModulePreparedNotifyFunc prepare_func;
|
||||
ModuleUpdatedNotifyFunc update_func;
|
||||
gpointer user_data;
|
||||
guchar *buf;
|
||||
guint ptr;
|
||||
@ -650,8 +651,8 @@ gif_get_lzw (GifContext *context)
|
||||
context->width,
|
||||
context->height);
|
||||
|
||||
if (context->func)
|
||||
(* context->func) (context->pixbuf, context->user_data);
|
||||
if (context->prepare_func)
|
||||
(* context->prepare_func) (context->pixbuf, context->user_data);
|
||||
}
|
||||
|
||||
dest = gdk_pixbuf_get_pixels (context->pixbuf);
|
||||
@ -675,7 +676,7 @@ gif_get_lzw (GifContext *context)
|
||||
*(temp+2) = context->color_map [2][(guchar) v];
|
||||
}
|
||||
|
||||
if (context->func && context->frame_interlace)
|
||||
if (context->prepare_func && context->frame_interlace)
|
||||
gif_fill_in_lines (context, dest, v);
|
||||
|
||||
context->draw_xpos++;
|
||||
@ -957,7 +958,8 @@ image_load (FILE *file)
|
||||
context->file = file;
|
||||
context->pixbuf = NULL;
|
||||
context->state = GIF_START;
|
||||
context->func = NULL;
|
||||
context->prepare_func = NULL;
|
||||
context->update_func = NULL;
|
||||
|
||||
gif_main_loop (context);
|
||||
|
||||
@ -965,7 +967,9 @@ image_load (FILE *file)
|
||||
}
|
||||
|
||||
gpointer
|
||||
image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
|
||||
image_begin_load (ModulePreparedNotifyFunc prepare_func,
|
||||
ModuleUpdatedNotifyFunc update_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GifContext *context;
|
||||
|
||||
@ -973,7 +977,7 @@ image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
|
||||
count = 0;
|
||||
#endif
|
||||
context = g_new (GifContext, 1);
|
||||
context->func = func;
|
||||
context->prepare_func = prepare_func;
|
||||
context->user_data = user_data;
|
||||
context->file = NULL;
|
||||
context->pixbuf = NULL;
|
||||
|
@ -257,7 +257,9 @@ struct _LoadContext {
|
||||
};
|
||||
|
||||
gpointer
|
||||
image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
|
||||
image_begin_load (ModulePreparedNotifyFunc prepare_func,
|
||||
ModuleUpdatedNotifyFunc update_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
LoadContext* lc;
|
||||
|
||||
@ -265,7 +267,7 @@ image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
|
||||
|
||||
lc->fatal_error_occurred = FALSE;
|
||||
|
||||
lc->notify_func = func;
|
||||
lc->notify_func = prepare_func;
|
||||
lc->notify_user_data = user_data;
|
||||
|
||||
/* Create the main PNG context struct */
|
||||
|
@ -37,7 +37,8 @@
|
||||
typedef struct _TiffData TiffData;
|
||||
struct _TiffData
|
||||
{
|
||||
ModulePreparedNotifyFunc func;
|
||||
ModulePreparedNotifyFunc prepare_func;
|
||||
ModuleUpdatedNotifyFunc update_func;
|
||||
gpointer user_data;
|
||||
|
||||
gchar *tempname;
|
||||
@ -69,7 +70,7 @@ image_load_real (FILE *f, TiffData *context)
|
||||
pixbuf = gdk_pixbuf_new (ART_PIX_RGB, TRUE, 8, w, h);
|
||||
|
||||
if (context)
|
||||
(* context->func) (pixbuf, context->user_data);
|
||||
(* context->prepare_func) (pixbuf, context->user_data);
|
||||
|
||||
/* Yes, it needs to be _TIFFMalloc... */
|
||||
rast = (uint32 *) _TIFFmalloc (num_pixs * sizeof (uint32));
|
||||
@ -108,8 +109,10 @@ image_load_real (FILE *f, TiffData *context)
|
||||
_TIFFfree (rast);
|
||||
TIFFClose (tiff);
|
||||
|
||||
if (context)
|
||||
if (context) {
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
(* context->update_func) (pixbuf, context->user_data, 0, 0, w, h);
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
@ -132,14 +135,17 @@ image_load (FILE *f)
|
||||
* the file when it's done. It's not pretty.
|
||||
*/
|
||||
|
||||
|
||||
gpointer
|
||||
image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
|
||||
image_begin_load (ModulePreparedNotifyFunc prepare_func,
|
||||
ModuleUpdatedNotifyFunc update_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
TiffData *context;
|
||||
gint fd;
|
||||
|
||||
context = g_new (TiffData, 1);
|
||||
context->func = func;
|
||||
context->prepare_func = prepare_func;
|
||||
context->user_data = user_data;
|
||||
context->all_okay = TRUE;
|
||||
context->tempname = g_strdup ("/tmp/gdkpixbuf-tif-tmp.XXXXXX");
|
||||
|
@ -219,6 +219,21 @@ gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf, gpointer loader)
|
||||
gtk_signal_emit (GTK_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED]);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
|
||||
{
|
||||
GdkPixbufLoaderPrivate *priv = NULL;
|
||||
|
||||
priv = GDK_PIXBUF_LOADER (loader)->private;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (loader),
|
||||
pixbuf_loader_signals[AREA_UPDATED],
|
||||
x, y,
|
||||
/* sanity check in here. Defend against an errant loader */
|
||||
MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
|
||||
MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -259,7 +274,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
|
||||
return 0;
|
||||
}
|
||||
|
||||
priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
|
||||
priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
|
||||
|
||||
if (priv->context == NULL) {
|
||||
g_warning("Failed to begin progressive load");
|
||||
|
@ -59,7 +59,7 @@ struct _GdkPixbufLoaderClass {
|
||||
void (* area_prepared) (GdkPixbufLoader *loader);
|
||||
|
||||
void (* area_updated) (GdkPixbufLoader *loader,
|
||||
int x, int y, int width, int height);
|
||||
guint x, guint y, guint width, guint height);
|
||||
|
||||
void (* closed) (GdkPixbufLoader *loader);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user