parent
d22176c22d
commit
0bde1e25a1
|
@ -64,3 +64,13 @@
|
||||||
normal image cache to avoid excess texture uploads when
|
normal image cache to avoid excess texture uploads when
|
||||||
cycling images often. Should improve performance in some
|
cycling images often. Should improve performance in some
|
||||||
cases.
|
cases.
|
||||||
|
|
||||||
|
2011-02-12 Carsten Haitzler (The Rasterman)
|
||||||
|
|
||||||
|
* Fix "rediculous scaling size" bug, where scaling images to
|
||||||
|
sizes like 1 billion pixels high or wide caused evas to try
|
||||||
|
allocate scaletables on the stack and the stack just couldn't
|
||||||
|
handle it. Now it only allocates a table for the visible
|
||||||
|
region which will always be sane, and even has insanity
|
||||||
|
checks now. At worst you'll get an unrendered image if the
|
||||||
|
values are silly and some slowness. No crashes.
|
||||||
|
|
|
@ -2,24 +2,24 @@
|
||||||
#include "evas_scale_smooth.h"
|
#include "evas_scale_smooth.h"
|
||||||
#include "evas_blend_private.h"
|
#include "evas_blend_private.h"
|
||||||
|
|
||||||
#define SCALE_CALC_X_POINTS(P, SW, DW) \
|
#define SCALE_CALC_X_POINTS(P, SW, DW, CX, CW) \
|
||||||
P = alloca((DW + 1) * sizeof (int)); \
|
P = alloca((CW + 1) * sizeof (int)); \
|
||||||
scale_calc_x_points(P, SW, DW);
|
scale_calc_x_points(P, SW, DW, CX, CW);
|
||||||
|
|
||||||
#define SCALE_CALC_Y_POINTS(P, SRC, SW, SH, DH) \
|
#define SCALE_CALC_Y_POINTS(P, SRC, SW, SH, DH, CY, CH) \
|
||||||
P = alloca((DH + 1) * sizeof (DATA32 *)); \
|
P = alloca((CH + 1) * sizeof (DATA32 *)); \
|
||||||
scale_calc_y_points(P, SRC, SW, SH, DH);
|
scale_calc_y_points(P, SRC, SW, SH, DH, CY, CH);
|
||||||
|
|
||||||
#define SCALE_CALC_A_POINTS(P, S, D) \
|
#define SCALE_CALC_A_POINTS(P, S, D, C, CC) \
|
||||||
P = alloca(D * sizeof (int)); \
|
P = alloca(CC * sizeof (int)); \
|
||||||
scale_calc_a_points(P, S, D);
|
scale_calc_a_points(P, S, D, C, CC);
|
||||||
|
|
||||||
static void scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh);
|
static void scale_calc_y_points(DATA32 **p, DATA32 *src, int sw, int sh, int dh, int cy, int ch);
|
||||||
static void scale_calc_x_points(int *p, int sw, int dw);
|
static void scale_calc_x_points(int *p, int sw, int dw, int cx, int cw);
|
||||||
static void scale_calc_a_points(int *p, int s, int d);
|
static void scale_calc_a_points(int *p, int s, int d, int c, int cc);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh)
|
scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh, int cy, int ch)
|
||||||
{
|
{
|
||||||
int i, val, inc;
|
int i, val, inc;
|
||||||
|
|
||||||
|
@ -27,14 +27,16 @@ scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh)
|
||||||
inc = (sh << 16) / dh;
|
inc = (sh << 16) / dh;
|
||||||
for (i = 0; i < dh; i++)
|
for (i = 0; i < dh; i++)
|
||||||
{
|
{
|
||||||
p[i] = src + ((val >> 16) * sw);
|
if ((i >= cy) && (i < (cy + ch)))
|
||||||
|
p[i - cy] = src + ((val >> 16) * sw);
|
||||||
val += inc;
|
val += inc;
|
||||||
}
|
}
|
||||||
p[i] = p[i - 1];
|
if ((i >= cy) && (i < (cy + ch)))
|
||||||
|
p[i - cy] = p[i - cy - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scale_calc_x_points(int *p, int sw, int dw)
|
scale_calc_x_points(int *p, int sw, int dw, int cx, int cw)
|
||||||
{
|
{
|
||||||
int i, val, inc;
|
int i, val, inc;
|
||||||
|
|
||||||
|
@ -42,14 +44,16 @@ scale_calc_x_points(int *p, int sw, int dw)
|
||||||
inc = (sw << 16) / dw;
|
inc = (sw << 16) / dw;
|
||||||
for (i = 0; i < dw; i++)
|
for (i = 0; i < dw; i++)
|
||||||
{
|
{
|
||||||
p[i] = val >> 16;
|
if ((i >= cx) && (i < (cx + cw)))
|
||||||
|
p[i - cx] = val >> 16;
|
||||||
val += inc;
|
val += inc;
|
||||||
}
|
}
|
||||||
p[i] = p[i - 1];
|
if ((i >= cx) && (i < (cx + cw)))
|
||||||
|
p[i - cx] = p[i - cx - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scale_calc_a_points(int *p, int s, int d)
|
scale_calc_a_points(int *p, int s, int d, int c, int cc)
|
||||||
{
|
{
|
||||||
int i, val, inc;
|
int i, val, inc;
|
||||||
|
|
||||||
|
@ -59,8 +63,11 @@ scale_calc_a_points(int *p, int s, int d)
|
||||||
inc = (s << 16) / d;
|
inc = (s << 16) / d;
|
||||||
for (i = 0; i < d; i++)
|
for (i = 0; i < d; i++)
|
||||||
{
|
{
|
||||||
p[i] = (val >> 8) - ((val >> 8) & 0xffffff00);
|
if ((i >= c) && (i < (c + cc)))
|
||||||
if ((val >> 16) >= (s - 1)) p[i] = 0;
|
{
|
||||||
|
p[i - c] = (val >> 8) - ((val >> 8) & 0xffffff00);
|
||||||
|
if ((val >> 16) >= (s - 1)) p[i - c] = 0;
|
||||||
|
}
|
||||||
val += inc;
|
val += inc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,11 +81,11 @@ scale_calc_a_points(int *p, int s, int d)
|
||||||
for (i = 0; i < d; i++)
|
for (i = 0; i < d; i++)
|
||||||
{
|
{
|
||||||
ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
|
ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
|
||||||
p[i] = ap | (Cp << 16);
|
if ((i >= c) && (i < (c + cc)))
|
||||||
|
p[i - c] = ap | (Cp << 16);
|
||||||
val += inc;
|
val += inc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sleep(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BUILD_SCALE_SMOOTH
|
#ifdef BUILD_SCALE_SMOOTH
|
||||||
|
|
|
@ -136,6 +136,12 @@ SCALE_FUNC(RGBA_Image *src, RGBA_Image *dst,
|
||||||
}
|
}
|
||||||
if (dst_clip_h <= 0) return;
|
if (dst_clip_h <= 0) return;
|
||||||
|
|
||||||
|
/* some maximum region sizes to avoid insane calc point tables */
|
||||||
|
if (dst_clip_w > 65536) return;
|
||||||
|
if (dst_clip_h > 65536) return;
|
||||||
|
if (dst_region_w > (65536 * 1024)) return;
|
||||||
|
if (dst_region_h > (65536 * 1024)) return;
|
||||||
|
|
||||||
/* figure out dst jump
|
/* figure out dst jump
|
||||||
* NB: Unused currently, so commented out */
|
* NB: Unused currently, so commented out */
|
||||||
// dst_jump = dst_w - dst_clip_w;
|
// dst_jump = dst_w - dst_clip_w;
|
||||||
|
|
|
@ -8,20 +8,21 @@
|
||||||
RGBA_Gfx_Func func;
|
RGBA_Gfx_Func func;
|
||||||
|
|
||||||
src_data = src->image.data;
|
src_data = src->image.data;
|
||||||
|
|
||||||
SCALE_CALC_X_POINTS(xpoints, src_region_w, dst_region_w);
|
/* some maximum region sizes to avoid insane calc point tables */
|
||||||
SCALE_CALC_Y_POINTS(ypoints, src_data, src_w, src_region_h, dst_region_h);
|
SCALE_CALC_X_POINTS(xpoints, src_region_w, dst_region_w, dst_clip_x - dst_region_x, dst_clip_w);
|
||||||
SCALE_CALC_A_POINTS(xapoints, src_region_w, dst_region_w);
|
SCALE_CALC_Y_POINTS(ypoints, src_data, src_w, src_region_h, dst_region_h, dst_clip_y - dst_region_y, dst_clip_h);
|
||||||
SCALE_CALC_A_POINTS(yapoints, src_region_h, dst_region_h);
|
SCALE_CALC_A_POINTS(xapoints, src_region_w, dst_region_w, dst_clip_x - dst_region_x, dst_clip_w);
|
||||||
|
SCALE_CALC_A_POINTS(yapoints, src_region_h, dst_region_h, dst_clip_y - dst_region_y, dst_clip_h);
|
||||||
|
|
||||||
/* a scanline buffer */
|
/* a scanline buffer */
|
||||||
buf = alloca(dst_clip_w * sizeof(DATA32));
|
buf = alloca(dst_clip_w * sizeof(DATA32));
|
||||||
|
|
||||||
if (dc->mul.use)
|
if (dc->mul.use)
|
||||||
func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op);
|
func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, dst_clip_w, dc->render_op);
|
||||||
else
|
else
|
||||||
func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op);
|
func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst_clip_w, dc->render_op);
|
||||||
/* scaling down vertically */
|
/* scaling down vertically */
|
||||||
if ((dst_region_w >= src_region_w) &&
|
if ((dst_region_w >= src_region_w) &&
|
||||||
(dst_region_h < src_region_h))
|
(dst_region_h < src_region_h))
|
||||||
{
|
{
|
||||||
|
@ -29,13 +30,13 @@
|
||||||
}
|
}
|
||||||
/* scaling down horizontally */
|
/* scaling down horizontally */
|
||||||
else if ((dst_region_w < src_region_w) &&
|
else if ((dst_region_w < src_region_w) &&
|
||||||
(dst_region_h >= src_region_h))
|
(dst_region_h >= src_region_h))
|
||||||
{
|
{
|
||||||
#include "evas_scale_smooth_scaler_downx.c"
|
#include "evas_scale_smooth_scaler_downx.c"
|
||||||
}
|
}
|
||||||
/* scaling down both vertically & horizontally */
|
/* scaling down both vertically & horizontally */
|
||||||
else if ((dst_region_w < src_region_w) &&
|
else if ((dst_region_w < src_region_w) &&
|
||||||
(dst_region_h < src_region_h))
|
(dst_region_h < src_region_h))
|
||||||
{
|
{
|
||||||
#include "evas_scale_smooth_scaler_downx_downy.c"
|
#include "evas_scale_smooth_scaler_downx_downy.c"
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
dyy = dst_clip_y - dst_region_y;
|
dyy = dst_clip_y - dst_region_y;
|
||||||
dxx = dst_clip_x - dst_region_x;
|
dxx = dst_clip_x - dst_region_x;
|
||||||
|
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
yp = ypoints + dyy;
|
yp = ypoints;// + dyy;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
yapp = yapoints + dyy;
|
yapp = yapoints;// + dyy;
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
|
|
||||||
if (src->cache_entry.flags.alpha)
|
if (src->cache_entry.flags.alpha)
|
||||||
|
@ -97,8 +97,8 @@
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -175,8 +175,8 @@
|
||||||
|
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -251,8 +251,8 @@
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
dyy = dst_clip_y - dst_region_y;
|
dyy = dst_clip_y - dst_region_y;
|
||||||
dxx = dst_clip_x - dst_region_x;
|
dxx = dst_clip_x - dst_region_x;
|
||||||
|
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
yp = ypoints + dyy;
|
yp = ypoints;// + dyy;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
yapp = yapoints + dyy;
|
yapp = yapoints;// + dyy;
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
/*#ifndef SCALE_USING_MMX */
|
/*#ifndef SCALE_USING_MMX */
|
||||||
/* for now there's no mmx down scaling - so C only */
|
/* for now there's no mmx down scaling - so C only */
|
||||||
|
@ -145,8 +145,8 @@
|
||||||
#endif
|
#endif
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,8 +261,8 @@
|
||||||
ysli++;
|
ysli++;
|
||||||
#endif
|
#endif
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,8 +375,8 @@
|
||||||
#endif
|
#endif
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
dyy = dst_clip_y - dst_region_y;
|
dyy = dst_clip_y - dst_region_y;
|
||||||
dxx = dst_clip_x - dst_region_x;
|
dxx = dst_clip_x - dst_region_x;
|
||||||
|
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
yp = ypoints + dyy;
|
yp = ypoints;// + dyy;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
yapp = yapoints + dyy;
|
yapp = yapoints;// + dyy;
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
|
|
||||||
if (src->cache_entry.flags.alpha)
|
if (src->cache_entry.flags.alpha)
|
||||||
|
@ -98,8 +98,8 @@
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -176,8 +176,8 @@
|
||||||
#endif
|
#endif
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -252,8 +252,8 @@
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
dptr += dst_w; dst_clip_w = w;
|
dptr += dst_w; dst_clip_w = w;
|
||||||
yp++; yapp++;
|
yp++; yapp++;
|
||||||
xp = xpoints + dxx;
|
xp = xpoints;// + dxx;
|
||||||
xapp = xapoints + dxx;
|
xapp = xapoints;// + dxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue