From dc486e69710d71b18f41d2d6cb4975067ef84663 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sat, 30 Mar 2013 02:34:39 +0100 Subject: [PATCH] Simplify halo rendering by reducing number of loop indices. --- src/font_engine_freetype.cpp | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 48222fd67..6a3080669 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -403,26 +403,25 @@ template void render_halo(T & pixmap, FT_Bitmap *bitmap, unsigned rgba, - int x, - int y, + int x1, + int y1, int halo_radius, double opacity, composite_mode_e comp_op) { - int x_max=x+bitmap->width; - int y_max=y+bitmap->rows; - int i,p,j,q; - - for (i=x,p=0;iwidth; + int height = bitmap->rows; + int x, y; + for (x=0; x < width; x++) { - for (j=y,q=0;jbuffer[q*bitmap->width+p]; + int gray = bitmap->buffer[y*bitmap->width+x]; if (gray) { for (int n=-halo_radius; n <=halo_radius; ++n) - for (int m=-halo_radius;m <= halo_radius; ++m) - pixmap.composite_pixel(comp_op, i+m, j+n, rgba, gray, opacity); + for (int m=-halo_radius; m <= halo_radius; ++m) + pixmap.composite_pixel(comp_op, x+x1+m, y+y1+n, rgba, gray, opacity); } } } @@ -432,24 +431,23 @@ template void render_halo_id(T & pixmap, FT_Bitmap *bitmap, mapnik::value_integer feature_id, - int x, - int y, + int x1, + int y1, int halo_radius) { - int x_max=x+bitmap->width; - int y_max=y+bitmap->rows; - int i,p,j,q; - - for (i=x,p=0;iwidth; + int height = bitmap->rows; + int x, y; + for (x=0; x < width; x++) { - for (j=y,q=0;jbuffer[q*bitmap->width+p]; + int gray = bitmap->buffer[y*bitmap->width+x]; if (gray) { for (int n=-halo_radius; n <=halo_radius; ++n) - for (int m=-halo_radius;m <= halo_radius; ++m) - pixmap.setPixel(i+m,j+n,feature_id); + for (int m=-halo_radius; m <= halo_radius; ++m) + pixmap.setPixel(x+x1+m,y+y1+n,feature_id); } } }