By order of jrb: const patch for various bits, io-gif.c fixup for

By order of jrb:
	const patch for various bits,
	io-gif.c fixup for animations.
This commit is contained in:
Michael Meeks 2000-02-03 23:36:14 +00:00
parent 0f5251b51d
commit 45cb0268b9
7 changed files with 182 additions and 158 deletions

View File

@ -1,3 +1,23 @@
2000-02-04 Michael Meeks <mmeeks@gnu.org>
* gdk-pixbuf/io-gif.c (struct _GifContext): add x,y_offset.
(gif_get_frame_info): put the offsets on the context.
(gif_get_lzw): copy them off into the frame.
(new_context): no change required; will 0 offsets by default.
2000-01-28 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* gdk-pixbuf/pixops/pixops.c (pixops_process): const + nasty
un-consting cast.
* gdk-pixbuf/pixops/pixops.h: const.
* gdk-pixbuf/gdk-pixbuf-util.c: const.
* gdk-pixbuf/gdk-pixbuf-scale.c: const.
* gdk-pixbuf/gdk-pixbuf.h: constify lots of things.
2000-02-03 Federico Mena Quintero <federico@helixcode.com>
* gdk-pixbuf/gdk-pixbuf-render.c

View File

@ -22,20 +22,20 @@
* destination drawable replacing the previous contents.
**/
void
gdk_pixbuf_scale (GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level)
gdk_pixbuf_scale (const GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level)
{
offset_x = floor(offset_x + 0.5);
offset_y = floor(offset_y + 0.5);
offset_x = floor (offset_x + 0.5);
offset_y = floor (offset_y + 0.5);
pixops_scale (dest->art_pixbuf->pixels + dest_y * dest->art_pixbuf->rowstride + dest_x * dest->art_pixbuf->n_channels,
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
@ -66,21 +66,21 @@ gdk_pixbuf_scale (GdkPixbuf *src,
* destination drawable.
**/
void
gdk_pixbuf_composite (GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha)
gdk_pixbuf_composite (const GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha)
{
offset_x = floor(offset_x + 0.5);
offset_y = floor(offset_y + 0.5);
offset_x = floor (offset_x + 0.5);
offset_y = floor (offset_y + 0.5);
pixops_composite (dest->art_pixbuf->pixels + dest_y * dest->art_pixbuf->rowstride + dest_x * dest->art_pixbuf->n_channels,
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
dest->art_pixbuf->rowstride, dest->art_pixbuf->n_channels, dest->art_pixbuf->has_alpha,
@ -116,26 +116,26 @@ gdk_pixbuf_composite (GdkPixbuf *src,
* destination drawable.
**/
void
gdk_pixbuf_composite_color (GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha,
int check_x,
int check_y,
int check_size,
art_u32 color1,
art_u32 color2)
gdk_pixbuf_composite_color (const GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha,
int check_x,
int check_y,
int check_size,
art_u32 color1,
art_u32 color2)
{
offset_x = floor(offset_x + 0.5);
offset_y = floor(offset_y + 0.5);
offset_x = floor (offset_x + 0.5);
offset_y = floor (offset_y + 0.5);
pixops_composite_color (dest->art_pixbuf->pixels + dest_y * dest->art_pixbuf->rowstride + dest_x * dest->art_pixbuf->n_channels,
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
@ -158,10 +158,10 @@ gdk_pixbuf_composite_color (GdkPixbuf *src,
* Return value: the new #GdkPixbuf
**/
GdkPixbuf *
gdk_pixbuf_scale_simple (GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level)
gdk_pixbuf_scale_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level)
{
GdkPixbuf *dest = gdk_pixbuf_new (ART_PIX_RGB, src->art_pixbuf->has_alpha, 8, dest_width, dest_height);
@ -191,14 +191,14 @@ gdk_pixbuf_scale_simple (GdkPixbuf *src,
* Return value: the new #GdkPixbuf
**/
GdkPixbuf *
gdk_pixbuf_composite_color_simple (GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level,
int overall_alpha,
int check_size,
art_u32 color1,
art_u32 color2)
gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level,
int overall_alpha,
int check_size,
art_u32 color1,
art_u32 color2)
{
GdkPixbuf *dest = gdk_pixbuf_new (ART_PIX_RGB, src->art_pixbuf->has_alpha, 8, dest_width, dest_height);

View File

@ -110,13 +110,14 @@ gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color, guchar r, gu
* pixbuf formats is done automatically.
**/
void
gdk_pixbuf_copy_area (GdkPixbuf *src_pixbuf,
gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
int src_x, int src_y,
int width, int height,
GdkPixbuf *dest_pixbuf,
int dest_x, int dest_y)
{
ArtPixBuf *src_apb, *dest_apb;
const ArtPixBuf *src_apb;
ArtPixBuf *dest_apb;
g_return_if_fail (src_pixbuf != NULL);
g_return_if_fail (dest_pixbuf != NULL);

View File

@ -97,8 +97,8 @@ int gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf);
/* Reference counting */
GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf);
void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf);
void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
/* Wrap a libart pixbuf */
GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
@ -156,19 +156,19 @@ void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawab
GdkRgbDither dither,
int x_dither, int y_dither);
void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
GdkPixmap **pixmap_return, GdkBitmap **mask_return,
int alpha_threshold);
void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
GdkPixmap **pixmap_return, GdkBitmap **mask_return,
int alpha_threshold);
/* Fetching a region from a drawable */
GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
GdkDrawable *src, GdkColormap *cmap,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height);
GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
GdkDrawable *src, GdkColormap *cmap,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height);
/* Copy an area of a pixbuf onto another one */
void gdk_pixbuf_copy_area (GdkPixbuf *src_pixbuf,
void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
int src_x, int src_y,
int width, int height,
GdkPixbuf *dest_pixbuf,
@ -176,70 +176,70 @@ void gdk_pixbuf_copy_area (GdkPixbuf *src_pixbuf,
/* Scaling */
void gdk_pixbuf_scale (GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level);
void gdk_pixbuf_composite (GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha);
void gdk_pixbuf_composite_color (GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha,
int check_x,
int check_y,
int check_size,
art_u32 color1,
art_u32 color2);
void gdk_pixbuf_scale (const GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level);
void gdk_pixbuf_composite (const GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha);
void gdk_pixbuf_composite_color (const GdkPixbuf *src,
GdkPixbuf *dest,
int dest_x,
int dest_y,
int dest_width,
int dest_height,
double offset_x,
double offset_y,
double scale_x,
double scale_y,
ArtFilterLevel filter_level,
int overall_alpha,
int check_x,
int check_y,
int check_size,
art_u32 color1,
art_u32 color2);
GdkPixbuf *gdk_pixbuf_scale_simple (GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level);
GdkPixbuf *gdk_pixbuf_composite_color_simple (GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level,
int overall_alpha,
int check_size,
art_u32 color1,
art_u32 color2);
GdkPixbuf *gdk_pixbuf_scale_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level);
GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
ArtFilterLevel filter_level,
int overall_alpha,
int check_size,
art_u32 color1,
art_u32 color2);
/* Animation support */
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename);
GdkPixbufAnimation *gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
GdkPixbufAnimation *gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
/* General (presently empty) initialization hooks, primarily for gnome-libs */
void gdk_pixbuf_preinit(gpointer app, gpointer modinfo);
void gdk_pixbuf_postinit(gpointer app, gpointer modinfo);
void gdk_pixbuf_preinit (gpointer app, gpointer modinfo);
void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);

View File

@ -123,6 +123,8 @@ struct _GifContext
int frame_len;
int frame_height;
int frame_interlace;
int x_offset;
int y_offset;
/* Static read only */
FILE *file;
@ -674,8 +676,8 @@ gif_get_lzw (GifContext *context)
(* context->prepare_func) (context->pixbuf, context->user_data);
if (context->animation || context->frame_done_func) {
context->frame = g_new (GdkPixbufFrame, 1);
context->frame->x_offset = 0;
context->frame->y_offset = 0;
context->frame->x_offset = context->x_offset;
context->frame->y_offset = context->y_offset;;
context->frame->delay_time = context->gif89.delay_time;
switch (context->gif89.disposal) {
case 0:
@ -934,10 +936,9 @@ gif_get_frame_info (GifContext *context)
/* Okay, we got all the info we need. Lets record it */
context->frame_len = LM_to_uint (buf[4], buf[5]);
context->frame_height = LM_to_uint (buf[6], buf[7]);
if (context->frame) {
context->frame->x_offset = LM_to_uint (buf[0], buf[1]);
context->frame->y_offset = LM_to_uint (buf[2], buf[3]);
}
context->x_offset = LM_to_uint (buf[0], buf[1]);
context->y_offset = LM_to_uint (buf[2], buf[3]);
if (context->frame_height > context->height) {
/* we don't want to resize things. So we exit */
context->state = GIF_DONE;
@ -1063,6 +1064,7 @@ new_context (void)
GifContext *context;
context = g_new0 (GifContext, 1);
context->pixbuf = NULL;
context->file = NULL;
context->state = GIF_START;
@ -1077,6 +1079,7 @@ new_context (void)
context->gif89.delay_time = -1;
context->gif89.input_flag = -1;
context->gif89.disposal = -1;
return context;
}
/* Shared library entry point */

View File

@ -56,7 +56,7 @@ pixops_scale_nearest (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -73,7 +73,7 @@ pixops_scale_nearest (art_u8 *dest_buf,
#define INNER_LOOP(SRC_CHANNELS,DEST_CHANNELS) \
for (j=0; j < (render_x1 - render_x0); j++) \
{ \
art_u8 *p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \
const art_u8 *p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \
\
dest[0] = p[0]; \
dest[1] = p[1]; \
@ -93,8 +93,8 @@ pixops_scale_nearest (art_u8 *dest_buf,
for (i = 0; i < (render_y1 - render_y0); i++)
{
art_u8 *src = src_buf + ((i * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
art_u8 *dest = dest_buf + i * dest_rowstride;
const art_u8 *src = src_buf + ((i * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
art_u8 *dest = dest_buf + i * dest_rowstride;
x = render_x0 * x_step + x_step / 2;
@ -119,7 +119,7 @@ pixops_scale_nearest (art_u8 *dest_buf,
{
for (j=0; j < (render_x1 - render_x0); j++)
{
art_u8 *p = src + (x >> SCALE_SHIFT) * 4;
const art_u8 *p = src + (x >> SCALE_SHIFT) * 4;
*(art_u32 *)dest = *(art_u32 *)p;
@ -141,7 +141,7 @@ pixops_composite_nearest (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -158,15 +158,15 @@ pixops_composite_nearest (art_u8 *dest_buf,
for (i = 0; i < (render_y1 - render_y0); i++)
{
art_u8 *src = src_buf + (((i + render_y0) * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
art_u8 *dest = dest_buf + i * dest_rowstride + render_x0 * dest_channels;
const art_u8 *src = src_buf + (((i + render_y0) * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
art_u8 *dest = dest_buf + i * dest_rowstride + render_x0 * dest_channels;
x = render_x0 * x_step + x_step / 2;
for (j=0; j < (render_x1 - render_x0); j++)
{
art_u8 *p = src + (x >> SCALE_SHIFT) * src_channels;
unsigned int a0;
const art_u8 *p = src + (x >> SCALE_SHIFT) * src_channels;
unsigned int a0;
if (src_has_alpha)
a0 = (p[3] * overall_alpha + 0xff) >> 8;
@ -218,7 +218,7 @@ pixops_composite_color_nearest (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -242,8 +242,8 @@ pixops_composite_color_nearest (art_u8 *dest_buf,
for (i = 0; i < (render_y1 - render_y0); i++)
{
art_u8 *src = src_buf + (((i + render_y0) * y_step + y_step/2) >> SCALE_SHIFT) * src_rowstride;
art_u8 *dest = dest_buf + i * dest_rowstride;
const art_u8 *src = src_buf + (((i + render_y0) * y_step + y_step/2) >> SCALE_SHIFT) * src_rowstride;
art_u8 *dest = dest_buf + i * dest_rowstride;
x = render_x0 * x_step + x_step / 2;
@ -270,8 +270,8 @@ pixops_composite_color_nearest (art_u8 *dest_buf,
for (j=0 ; j < (render_x1 - render_x0); j++)
{
art_u8 *p = src + (x >> SCALE_SHIFT) * src_channels;
unsigned int a0;
const art_u8 *p = src + (x >> SCALE_SHIFT) * src_channels;
unsigned int a0;
if (src_has_alpha)
a0 = (p[3] * overall_alpha + 0xff) >> 8;
@ -906,7 +906,7 @@ pixops_process (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -962,11 +962,11 @@ pixops_process (art_u8 *dest_buf,
for (j=0; j<filter->n_y; j++)
{
if (y_start < 0)
line_bufs[j] = src_buf;
line_bufs[j] = (art_u8 *)src_buf;
else if (y_start < src_height)
line_bufs[j] = src_buf + src_rowstride * y_start;
line_bufs[j] = (art_u8 *)src_buf + src_rowstride * y_start;
else
line_bufs[j] = src_buf + src_rowstride * (src_height - 1);
line_bufs[j] = (art_u8 *)src_buf + src_rowstride * (src_height - 1);
y_start++;
}
@ -1296,7 +1296,7 @@ pixops_composite_color (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -1380,7 +1380,7 @@ pixops_composite (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -1463,7 +1463,7 @@ pixops_scale (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
art_boolean dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,

View File

@ -14,7 +14,7 @@ void pixops_composite (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
int dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -39,7 +39,7 @@ void pixops_composite_color (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
int dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,
@ -68,7 +68,7 @@ void pixops_scale (art_u8 *dest_buf,
int dest_rowstride,
int dest_channels,
int dest_has_alpha,
art_u8 *src_buf,
const art_u8 *src_buf,
int src_width,
int src_height,
int src_rowstride,