summaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2005-02-01 01:00:31 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2005-02-01 01:00:31 +0000
commitc604fbe05cfad7b054bc8a45fbcaaa4c33cf14d1 (patch)
tree0feb142bb75cae11f0acf58aaec59b8e280c75e1 /image
parentfd04e82e9b31d0ad53b0fb2fde395600af1205c1 (diff)
downloadnetsurf-c604fbe05cfad7b054bc8a45fbcaaa4c33cf14d1.tar.gz
netsurf-c604fbe05cfad7b054bc8a45fbcaaa4c33cf14d1.tar.bz2
[project @ 2005-02-01 01:00:31 by rjw]
Move clipping area cascading to redraw loop (stops progressive decoding having a negative effect.) svn path=/import/netsurf/; revision=1478
Diffstat (limited to 'image')
-rw-r--r--image/gif.c48
-rw-r--r--image/gifread.c39
2 files changed, 35 insertions, 52 deletions
diff --git a/image/gif.c b/image/gif.c
index 617723bf3..43eaf8977 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -173,21 +173,24 @@ void nsgif_animate(void *p)
{
struct content *c = p;
union content_msg_data data;
+ struct gif_animation *gif;
int delay;
+ int f;
/* Advance by a frame, updating the loop count accordingly
*/
+ gif = c->data.gif.gif;
c->data.gif.current_frame++;
- if (c->data.gif.current_frame == (int)c->data.gif.gif->frame_count_partial) {
+ if (c->data.gif.current_frame == (int)gif->frame_count_partial) {
c->data.gif.current_frame = 0;
/* A loop count of 0 has a special meaning of infinite
*/
if (c->data.gif.gif->loop_count != 0) {
- c->data.gif.gif->loop_count--;
- if (c->data.gif.gif->loop_count == 0) {
- c->data.gif.current_frame = c->data.gif.gif->frame_count_partial - 1;
- c->data.gif.gif->loop_count = -1;
+ gif->loop_count--;
+ if (gif->loop_count == 0) {
+ c->data.gif.current_frame = gif->frame_count_partial - 1;
+ gif->loop_count = -1;
}
}
}
@@ -195,7 +198,7 @@ void nsgif_animate(void *p)
/* Continue animating if we should
*/
if (c->data.gif.gif->loop_count >= 0) {
- delay = c->data.gif.gif->frames[c->data.gif.current_frame].frame_delay;
+ delay = gif->frames[c->data.gif.current_frame].frame_delay;
if (delay < option_minimum_gif_delay)
delay = option_minimum_gif_delay;
schedule(delay, nsgif_animate, c);
@@ -205,21 +208,40 @@ void nsgif_animate(void *p)
return;
/* area within gif to redraw */
- data.redraw.x = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_x;
- data.redraw.y = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_y;
- data.redraw.width = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_width;
- data.redraw.height = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_height;
+ f = c->data.gif.current_frame;
+ data.redraw.x = gif->frames[f].redraw_x;
+ data.redraw.y = gif->frames[f].redraw_y;
+ data.redraw.width = gif->frames[f].redraw_width;
+ data.redraw.height = gif->frames[f].redraw_height;
/* redraw background (true) or plot on top (false) */
if (c->data.gif.current_frame > 0) {
- data.redraw.full_redraw =
- c->data.gif.gif->frames[c->data.gif.current_frame - 1].redraw_required;
+ data.redraw.full_redraw = gif->frames[f - 1].redraw_required;
+ /* previous frame needed clearing: expand the redraw area to cover it */
+ if (data.redraw.full_redraw) {
+ if (data.redraw.x > gif->frames[f - 1].redraw_x) {
+ data.redraw.width += data.redraw.x - gif->frames[f - 1].redraw_x;
+ data.redraw.x = gif->frames[f - 1].redraw_x;
+ }
+ if (data.redraw.y > gif->frames[f - 1].redraw_y) {
+ data.redraw.height += (data.redraw.y - gif->frames[f - 1].redraw_y);
+ data.redraw.y = gif->frames[f - 1].redraw_y;
+ }
+ if ((gif->frames[f - 1].redraw_x + gif->frames[f - 1].redraw_width) >
+ (data.redraw.x + data.redraw.width))
+ data.redraw.width = gif->frames[f - 1].redraw_x - data.redraw.x +
+ gif->frames[f - 1].redraw_width;
+ if ((gif->frames[f - 1].redraw_y + gif->frames[f - 1].redraw_height) >
+ (data.redraw.y + data.redraw.height))
+ data.redraw.height = gif->frames[f - 1].redraw_y - data.redraw.y +
+ gif->frames[f - 1].redraw_height;
+ }
} else {
/* do advanced check */
if ((data.redraw.x == 0) && (data.redraw.y == 0) &&
(data.redraw.width == c->data.gif.gif->width) &&
(data.redraw.height == c->data.gif.gif->height)) {
- data.redraw.full_redraw = bitmap_get_opaque(c->data.gif.gif->frame_image);
+ data.redraw.full_redraw = !bitmap_get_opaque(c->data.gif.gif->frame_image);
} else {
data.redraw.full_redraw = true;
data.redraw.x = 0;
diff --git a/image/gifread.c b/image/gifread.c
index a7d07e319..f4dbeb665 100644
--- a/image/gifread.c
+++ b/image/gifread.c
@@ -108,7 +108,6 @@ int gif_initialise(struct gif_animation *gif) {
unsigned char *gif_data;
unsigned int index;
int return_value;
- unsigned int frame;
/* Check for sufficient data to be a GIF
*/
@@ -244,44 +243,6 @@ int gif_initialise(struct gif_animation *gif) {
*/
while ((return_value = gif_initialise_frame(gif)) == 0);
- /* Update the redraw areas now we know the full data set
- */
- if (gif->frame_count_partial > 0) {
- /* We now work backwards to update the redraw characteristics of frames
- with clear codes to stop a snowball effect of the redraw areas. It doesn't
- really make much difference for most images, and will not work as well
- (ie will not optimise as well as for a single-pass call, but still works)
- for multiple calls to this routine when decoding progressively.
- */
- for (frame = gif->frame_count_partial - 1; frame > 0; frame--) {
- if (gif->frames[frame - 1].redraw_required) {
- if (gif->frames[frame].redraw_x > gif->frames[frame - 1].redraw_x) {
- gif->frames[frame].redraw_width +=
- (gif->frames[frame].redraw_x - gif->frames[frame - 1].redraw_x);
- gif->frames[frame].redraw_x = gif->frames[frame - 1].redraw_x;
- }
- if (gif->frames[frame].redraw_y > gif->frames[frame - 1].redraw_y) {
- gif->frames[frame].redraw_height +=
- (gif->frames[frame].redraw_y - gif->frames[frame - 1].redraw_y);
- gif->frames[frame].redraw_y = gif->frames[frame - 1].redraw_y;
- }
- if ((gif->frames[frame - 1].redraw_x + gif->frames[frame - 1].redraw_width) >
- (gif->frames[frame].redraw_x + gif->frames[frame].redraw_width)) {
- gif->frames[frame].redraw_width =
- (gif->frames[frame - 1].redraw_x + gif->frames[frame - 1].redraw_width) -
- gif->frames[frame].redraw_x;
- }
- if ((gif->frames[frame - 1].redraw_y + gif->frames[frame - 1].redraw_height) >
- (gif->frames[frame].redraw_y + gif->frames[frame].redraw_height)) {
- gif->frames[frame].redraw_height =
- (gif->frames[frame - 1].redraw_y + gif->frames[frame - 1].redraw_height) -
- gif->frames[frame].redraw_y;
- }
- }
- }
-
- }
-
/* If there was a memory error tell the caller
*/
if ((return_value == GIF_INSUFFICIENT_MEMORY) ||