mirror of https://github.com/GNOME/gimp.git
fixed progress feedback.
2008-08-25 Sven Neumann <sven@gimp.org> * app/paint-funcs/scale-region.c: fixed progress feedback. svn path=/trunk/; revision=26751
This commit is contained in:
parent
46ee36089c
commit
c206db2c2a
|
@ -1,8 +1,12 @@
|
||||||
|
2008-08-25 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/paint-funcs/scale-region.c: fixed progress feedback.
|
||||||
|
|
||||||
2008-08-25 Sven Neumann <sven@gimp.org>
|
2008-08-25 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/paint-funcs/scale-region.c: improved progress bar
|
* app/paint-funcs/scale-region.c: improved progress bar
|
||||||
calculations. Still buggy though.
|
calculations. Still buggy though.
|
||||||
|
|
||||||
2008-08-25 Sven Neumann <sven@gimp.org>
|
2008-08-25 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/paint-funcs/scale-region.c: some more cleanups.
|
* app/paint-funcs/scale-region.c: some more cleanups.
|
||||||
|
|
|
@ -114,11 +114,14 @@ static void interpolate_bilinear_pr (PixelRegion *srcPR,
|
||||||
const gdouble xfrac,
|
const gdouble xfrac,
|
||||||
const gdouble yfrac,
|
const gdouble yfrac,
|
||||||
guchar *pixel);
|
guchar *pixel);
|
||||||
static void determine_scale (PixelRegion *srcPR,
|
static void determine_levels (PixelRegion *srcPR,
|
||||||
PixelRegion *dstPR,
|
PixelRegion *dstPR,
|
||||||
gint *levelx,
|
gint *levelx,
|
||||||
gint *levely,
|
gint *levely);
|
||||||
gint *max_progress);
|
static gint determine_progress (PixelRegion *srcPR,
|
||||||
|
PixelRegion *dstPR,
|
||||||
|
gint levelx,
|
||||||
|
gint levely);
|
||||||
static inline void gaussan_lanczos2 (const guchar *pixels,
|
static inline void gaussan_lanczos2 (const guchar *pixels,
|
||||||
const gint bytes,
|
const gint bytes,
|
||||||
guchar *pixel);
|
guchar *pixel);
|
||||||
|
@ -160,26 +163,22 @@ static inline gdouble lanczos3_mul (const guchar *pixels,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
determine_scale (PixelRegion *srcPR,
|
determine_levels (PixelRegion *srcPR,
|
||||||
PixelRegion *dstPR,
|
PixelRegion *dstPR,
|
||||||
gint *levelx,
|
gint *levelx,
|
||||||
gint *levely,
|
gint *levely)
|
||||||
gint *max_progress)
|
|
||||||
{
|
{
|
||||||
gdouble scalex = (gdouble) dstPR->w / (gdouble) srcPR->w;
|
gdouble scalex = (gdouble) dstPR->w / (gdouble) srcPR->w;
|
||||||
gdouble scaley = (gdouble) dstPR->h / (gdouble) srcPR->h;
|
gdouble scaley = (gdouble) dstPR->h / (gdouble) srcPR->h;
|
||||||
gint width = srcPR->w;
|
gint width = srcPR->w;
|
||||||
gint height = srcPR->h;
|
gint height = srcPR->h;
|
||||||
|
|
||||||
*max_progress = NUM_TILES (dstPR->w, dstPR->h);
|
|
||||||
|
|
||||||
/* determine scaling levels */
|
/* determine scaling levels */
|
||||||
while (scalex > 2)
|
while (scalex > 2)
|
||||||
{
|
{
|
||||||
scalex /= 2;
|
scalex /= 2;
|
||||||
width *= 2;
|
width *= 2;
|
||||||
*levelx -= 1;
|
*levelx -= 1;
|
||||||
*max_progress += NUM_TILES (width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (scaley > 2)
|
while (scaley > 2)
|
||||||
|
@ -187,7 +186,6 @@ determine_scale (PixelRegion *srcPR,
|
||||||
scaley /= 2;
|
scaley /= 2;
|
||||||
height *= 2;
|
height *= 2;
|
||||||
*levely -= 1;
|
*levely -= 1;
|
||||||
*max_progress += NUM_TILES (width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (scalex < 0.5)
|
while (scalex < 0.5)
|
||||||
|
@ -195,7 +193,6 @@ determine_scale (PixelRegion *srcPR,
|
||||||
scalex *= 2;
|
scalex *= 2;
|
||||||
width /= 2;
|
width /= 2;
|
||||||
*levelx += 1;
|
*levelx += 1;
|
||||||
*max_progress += NUM_TILES (width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (scaley < 0.5)
|
while (scaley < 0.5)
|
||||||
|
@ -203,10 +200,76 @@ determine_scale (PixelRegion *srcPR,
|
||||||
scaley *= 2;
|
scaley *= 2;
|
||||||
height *= 2;
|
height *= 2;
|
||||||
*levely += 1;
|
*levely += 1;
|
||||||
*max_progress += NUM_TILES (width, height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
determine_progress (PixelRegion *srcPR,
|
||||||
|
PixelRegion *dstPR,
|
||||||
|
gint levelx,
|
||||||
|
gint levely)
|
||||||
|
{
|
||||||
|
gint width = srcPR->w;
|
||||||
|
gint height = srcPR->h;
|
||||||
|
gint tiles = 0;
|
||||||
|
|
||||||
|
while (levelx < 0 && levely < 0)
|
||||||
|
{
|
||||||
|
width <<= 1;
|
||||||
|
height <<= 1;
|
||||||
|
levelx++;
|
||||||
|
levely++;
|
||||||
|
|
||||||
|
tiles += NUM_TILES (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (levelx < 0)
|
||||||
|
{
|
||||||
|
width <<= 1;
|
||||||
|
levelx++;
|
||||||
|
|
||||||
|
tiles += NUM_TILES (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (levely < 0)
|
||||||
|
{
|
||||||
|
height <<= 1;
|
||||||
|
levely++;
|
||||||
|
|
||||||
|
tiles += NUM_TILES (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (levelx > 0 && levely > 0)
|
||||||
|
{
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
|
levelx--;
|
||||||
|
levely--;
|
||||||
|
|
||||||
|
tiles += NUM_TILES (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (levelx > 0)
|
||||||
|
{
|
||||||
|
width <<= 1;
|
||||||
|
levelx--;
|
||||||
|
|
||||||
|
tiles += NUM_TILES (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (levely > 0)
|
||||||
|
{
|
||||||
|
height <<= 1;
|
||||||
|
levely--;
|
||||||
|
|
||||||
|
tiles += NUM_TILES (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles += NUM_TILES (dstPR->w, dstPR->h);
|
||||||
|
|
||||||
|
return tiles;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scale_region_buffer (PixelRegion *srcPR,
|
scale_region_buffer (PixelRegion *srcPR,
|
||||||
PixelRegion *dstPR,
|
PixelRegion *dstPR,
|
||||||
|
@ -224,7 +287,8 @@ scale_region_buffer (PixelRegion *srcPR,
|
||||||
gint levely = 0;
|
gint levely = 0;
|
||||||
|
|
||||||
/* determine scaling levels */
|
/* determine scaling levels */
|
||||||
determine_scale (srcPR, dstPR, &levelx, &levely, &max_progress);
|
determine_levels (srcPR, dstPR, &levelx, &levely);
|
||||||
|
max_progress = determine_progress (srcPR, dstPR, levelx, levely);
|
||||||
|
|
||||||
pixel_region_init_data (&tmpPR0,
|
pixel_region_init_data (&tmpPR0,
|
||||||
g_memdup (srcPR->data, width * height * bytes),
|
g_memdup (srcPR->data, width * height * bytes),
|
||||||
|
@ -367,7 +431,8 @@ scale_region_tile (PixelRegion *srcPR,
|
||||||
gint levely = 0;
|
gint levely = 0;
|
||||||
|
|
||||||
/* determine scaling levels */
|
/* determine scaling levels */
|
||||||
determine_scale (srcPR, dstPR, &levelx, &levely, &max_progress);
|
determine_levels (srcPR, dstPR, &levelx, &levely);
|
||||||
|
max_progress = determine_progress (srcPR, dstPR, levelx, levely);
|
||||||
|
|
||||||
if (levelx == 0 && levely == 0)
|
if (levelx == 0 && levely == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue