* Evas: Remove allocation/free from the critical path.

SVN revision: 41048
This commit is contained in:
Cedric BAIL 2009-06-15 14:34:33 +00:00
parent 8cfa89c10f
commit f63beb3edf
2 changed files with 24 additions and 33 deletions

View File

@ -6,19 +6,27 @@
#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) \
P = alloca((DW + 1) * sizeof (int)); \
scale_calc_x_points(P, SW, DW);
static DATA32 **scale_calc_y_points(DATA32 *src, int sw, int sh, int dh); #define SCALE_CALC_Y_POINTS(P, SRC, SW, SH, DH) \
static int *scale_calc_x_points(int sw, int dw); P = alloca((DH + 1) * sizeof (DATA32 *)); \
static int *scale_calc_a_points(int s, int d); scale_calc_y_points(P, SRC, SW, SH, DH);
static DATA32 ** #define SCALE_CALC_A_POINTS(P, S, D) \
scale_calc_y_points(DATA32 *src, int sw, int sh, int dh) P = alloca(D * sizeof (int)); \
scale_calc_a_points(P, S, D);
static void scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh);
static void scale_calc_x_points(int *p, int sw, int dw);
static void scale_calc_a_points(int *p, int s, int d);
static void
scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh)
{ {
DATA32 **p;
int i, val, inc; int i, val, inc;
p = malloc((dh + 1) * sizeof(DATA32 *));
if (!p) return NULL;
val = 0; val = 0;
inc = (sh << 16) / dh; inc = (sh << 16) / dh;
for (i = 0; i < dh; i++) for (i = 0; i < dh; i++)
@ -27,17 +35,13 @@ scale_calc_y_points(DATA32 *src, int sw, int sh, int dh)
val += inc; val += inc;
} }
p[i] = p[i - 1]; p[i] = p[i - 1];
return p;
} }
static int * static void
scale_calc_x_points(int sw, int dw) scale_calc_x_points(int *p, int sw, int dw)
{ {
int *p;
int i, val, inc; int i, val, inc;
p = malloc((dw + 1) * sizeof(int));
if (!p) return NULL;
val = 0; val = 0;
inc = (sw << 16) / dw; inc = (sw << 16) / dw;
for (i = 0; i < dw; i++) for (i = 0; i < dw; i++)
@ -46,17 +50,13 @@ scale_calc_x_points(int sw, int dw)
val += inc; val += inc;
} }
p[i] = p[i - 1]; p[i] = p[i - 1];
return p;
} }
static int * static void
scale_calc_a_points(int s, int d) scale_calc_a_points(int *p, int s, int d)
{ {
int *p;
int i, val, inc; int i, val, inc;
p = malloc(d * sizeof(int));
if (!p) return NULL;
if (d >= s) if (d >= s)
{ {
val = 0; val = 0;
@ -83,7 +83,6 @@ scale_calc_a_points(int s, int d)
} }
} }
// sleep(1); // sleep(1);
return p;
} }
#ifdef BUILD_SCALE_SMOOTH #ifdef BUILD_SCALE_SMOOTH

View File

@ -9,12 +9,10 @@
src_data = src->image.data; src_data = src->image.data;
xpoints = scale_calc_x_points(src_region_w, dst_region_w); SCALE_CALC_X_POINTS(xpoints, src_region_w, dst_region_w);
ypoints = scale_calc_y_points(src_data, src_w, src_region_h, dst_region_h); SCALE_CALC_Y_POINTS(ypoints, src_data, src_w, src_region_h, dst_region_h);
xapoints = scale_calc_a_points(src_region_w, dst_region_w); SCALE_CALC_A_POINTS(xapoints, src_region_w, dst_region_w);
yapoints = scale_calc_a_points(src_region_h, dst_region_h); SCALE_CALC_A_POINTS(yapoints, src_region_h, dst_region_h);
if ( (!xpoints) || (!ypoints) || (!xapoints) || (!yapoints) )
goto done_scale_down;
/* a scanline buffer */ /* a scanline buffer */
buf = alloca(dst_clip_w * sizeof(DATA32)); buf = alloca(dst_clip_w * sizeof(DATA32));
@ -41,10 +39,4 @@
{ {
#include "evas_scale_smooth_scaler_downx_downy.c" #include "evas_scale_smooth_scaler_downx_downy.c"
} }
done_scale_down:
if (xpoints) free(xpoints);
if (ypoints) free(ypoints);
if (xapoints) free(xapoints);
if (yapoints) free(yapoints);
} }