Simplify halo rendering by reducing number of loop indices.

This commit is contained in:
Hermann Kraus 2013-03-30 02:34:39 +01:00
parent 6153c737e6
commit dc486e6971

View file

@ -403,26 +403,25 @@ template <typename T>
void render_halo(T & pixmap, void render_halo(T & pixmap,
FT_Bitmap *bitmap, FT_Bitmap *bitmap,
unsigned rgba, unsigned rgba,
int x, int x1,
int y, int y1,
int halo_radius, int halo_radius,
double opacity, double opacity,
composite_mode_e comp_op) composite_mode_e comp_op)
{ {
int x_max=x+bitmap->width; int width = bitmap->width;
int y_max=y+bitmap->rows; int height = bitmap->rows;
int i,p,j,q; int x, y;
for (x=0; x < width; x++)
for (i=x,p=0;i<x_max;++i,++p)
{ {
for (j=y,q=0;j<y_max;++j,++q) for (y=0; y < height; y++)
{ {
int gray = bitmap->buffer[q*bitmap->width+p]; int gray = bitmap->buffer[y*bitmap->width+x];
if (gray) if (gray)
{ {
for (int n=-halo_radius; n <=halo_radius; ++n) for (int n=-halo_radius; n <=halo_radius; ++n)
for (int m=-halo_radius;m <= halo_radius; ++m) for (int m=-halo_radius; m <= halo_radius; ++m)
pixmap.composite_pixel(comp_op, i+m, j+n, rgba, gray, opacity); pixmap.composite_pixel(comp_op, x+x1+m, y+y1+n, rgba, gray, opacity);
} }
} }
} }
@ -432,24 +431,23 @@ template <typename T>
void render_halo_id(T & pixmap, void render_halo_id(T & pixmap,
FT_Bitmap *bitmap, FT_Bitmap *bitmap,
mapnik::value_integer feature_id, mapnik::value_integer feature_id,
int x, int x1,
int y, int y1,
int halo_radius) int halo_radius)
{ {
int x_max=x+bitmap->width; int width = bitmap->width;
int y_max=y+bitmap->rows; int height = bitmap->rows;
int i,p,j,q; int x, y;
for (x=0; x < width; x++)
for (i=x,p=0;i<x_max;++i,++p)
{ {
for (j=y,q=0;j<y_max;++j,++q) for (y=0; y < height; y++)
{ {
int gray = bitmap->buffer[q*bitmap->width+p]; int gray = bitmap->buffer[y*bitmap->width+x];
if (gray) if (gray)
{ {
for (int n=-halo_radius; n <=halo_radius; ++n) for (int n=-halo_radius; n <=halo_radius; ++n)
for (int m=-halo_radius;m <= halo_radius; ++m) for (int m=-halo_radius; m <= halo_radius; ++m)
pixmap.setPixel(i+m,j+n,feature_id); pixmap.setPixel(x+x1+m,y+y1+n,feature_id);
} }
} }
} }