multiframe: Centralize handling of frame update offsets

This commit is contained in:
Kim Woelders 2022-11-14 19:21:04 +01:00
parent 6df68e3e2e
commit b1bbe1d9e8
4 changed files with 12 additions and 6 deletions

View File

@ -729,6 +729,9 @@ __imlib_LoadProgress(ImlibImage * im, int x, int y, int w, int h)
lc->area += w * h;
lc->pct = (100. * lc->area + .1) / (im->w * im->h);
x += im->frame_x;
y += im->frame_y;
rc = !lc->progress(im, lc->pct, x, y, w, h);
return rc;
@ -738,6 +741,7 @@ __EXPORT__ int
__imlib_LoadProgressRows(ImlibImage * im, int row, int nrows)
{
ImlibLdCtx *lc = im->lc;
int col = 0;
int rc = 0;
int pct, nrtot;
@ -758,7 +762,9 @@ __imlib_LoadProgressRows(ImlibImage * im, int row, int nrows)
pct = (100 * nrtot * (lc->pass + 1)) / (im->h * lc->n_pass);
if (pct == 100 || pct >= lc->pct + lc->granularity)
{
rc = !lc->progress(im, pct, 0, row, im->w, nrows);
col += im->frame_x;
row += im->frame_y;
rc = !lc->progress(im, pct, col, row, im->w, nrows);
lc->row = nrtot;
lc->pct += lc->granularity;
}

View File

@ -278,7 +278,7 @@ _load(ImlibImage * im, int load_data)
}
if (multiframe && im->lc)
__imlib_LoadProgress(im, im->frame_x, im->frame_y, im->w, im->h);
__imlib_LoadProgress(im, 0, 0, im->w, im->h);
rc = LOAD_SUCCESS;

View File

@ -261,7 +261,7 @@ row_callback(png_struct * png_ptr, png_byte * new_row,
done = pass >= 6 && (int)row_num >= PNG_PASS_ROWS(im->h, pass) - 1;
if (im->lc && done)
__imlib_LoadProgress(im, im->frame_x, im->frame_y, im->w, im->h);
__imlib_LoadProgress(im, 0, 0, im->w, im->h);
}
else
{
@ -277,9 +277,9 @@ row_callback(png_struct * png_ptr, png_byte * new_row,
if (im->frame_count > 1)
{
if (done)
__imlib_LoadProgress(im, im->frame_x, im->frame_y, im->w,
im->h);
__imlib_LoadProgress(im, 0, 0, im->w, im->h);
}
else if (__imlib_LoadProgressRows(im, y, 1))
{
png_process_data_pause(png_ptr, 0);

View File

@ -93,7 +93,7 @@ _load(ImlibImage * im, int load_data)
goto quit;
if (im->lc)
__imlib_LoadProgress(im, im->frame_x, im->frame_y, im->w, im->h);
__imlib_LoadProgress(im, 0, 0, im->w, im->h);
rc = LOAD_SUCCESS;