Revert "restore pristine agg2.4 agg:span_image_resample_rgba_affine - refs #1227"

This reverts commit 225678eccb.
This commit is contained in:
Dane Springmeyer 2012-05-24 14:11:42 -07:00
parent 225678eccb
commit 28b9729ae7

View file

@ -27,9 +27,9 @@ namespace mapnik {
using namespace agg; using namespace agg;
template<class Source> template<class Source>
class span_image_resample_rgba_affine : class span_image_resample_rgba_affine :
public span_image_resample_affine<Source> public span_image_resample_affine<Source>
{ {
public: public:
typedef Source source_type; typedef Source source_type;
@ -48,17 +48,17 @@ public:
//-------------------------------------------------------------------- //--------------------------------------------------------------------
span_image_resample_rgba_affine() {} span_image_resample_rgba_affine() {}
span_image_resample_rgba_affine(source_type& src, span_image_resample_rgba_affine(source_type& src,
interpolator_type& inter, interpolator_type& inter,
const image_filter_lut& filter) : const image_filter_lut& filter) :
base_type(src, inter, filter) base_type(src, inter, filter)
{} {}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len) void generate(color_type* span, int x, int y, unsigned len)
{ {
base_type::interpolator().begin(x + base_type::filter_dx_dbl(), base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len); y + base_type::filter_dy_dbl(), len);
long_type fg[4]; long_type fg[4];
@ -67,11 +67,11 @@ public:
int filter_scale = diameter << image_subpixel_shift; int filter_scale = diameter << image_subpixel_shift;
int radius_x = (diameter * base_type::m_rx) >> 1; int radius_x = (diameter * base_type::m_rx) >> 1;
int radius_y = (diameter * base_type::m_ry) >> 1; int radius_y = (diameter * base_type::m_ry) >> 1;
int len_x_lr = int len_x_lr =
(diameter * base_type::m_rx + image_subpixel_mask) >> (diameter * base_type::m_rx + image_subpixel_mask) >>
image_subpixel_shift; image_subpixel_shift;
const int16* weight_array = base_type::filter().weight_array(); const boost::int16_t* weight_array = base_type::filter().weight_array();
do do
{ {
@ -83,17 +83,17 @@ public:
fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2; fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2;
int y_lr = y >> image_subpixel_shift; int y_lr = y >> image_subpixel_shift;
int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) *
base_type::m_ry_inv) >> base_type::m_ry_inv) >>
image_subpixel_shift; image_subpixel_shift;
int total_weight = 0; int total_weight = 0;
int x_lr = x >> image_subpixel_shift; int x_lr = x >> image_subpixel_shift;
int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) *
base_type::m_rx_inv) >> base_type::m_rx_inv) >>
image_subpixel_shift; image_subpixel_shift;
int x_hr2 = x_hr; int x_hr2 = x_hr;
const value_type* fg_ptr = const value_type* fg_ptr =
(const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr);
for(;;) for(;;)
{ {
@ -101,14 +101,15 @@ public:
x_hr = x_hr2; x_hr = x_hr2;
for(;;) for(;;)
{ {
int weight = (weight_y * weight_array[x_hr] + int weight = (weight_y * weight_array[x_hr] +
image_filter_scale / 2) >> image_filter_scale / 2) >>
downscale_shift; downscale_shift;
fg[0] += *fg_ptr++ * weight; fg[0] += *fg_ptr++ * weight;
fg[1] += *fg_ptr++ * weight; fg[1] += *fg_ptr++ * weight;
fg[2] += *fg_ptr++ * weight; fg[2] += *fg_ptr++ * weight;
fg[3] += *fg_ptr++ * weight; fg[3] += *fg_ptr * weight;
total_weight += weight; total_weight += weight;
x_hr += base_type::m_rx_inv; x_hr += base_type::m_rx_inv;
if(x_hr >= filter_scale) break; if(x_hr >= filter_scale) break;
@ -119,21 +120,31 @@ public:
fg_ptr = (const value_type*)base_type::source().next_y(); fg_ptr = (const value_type*)base_type::source().next_y();
} }
fg[0] /= total_weight; if (total_weight)
fg[1] /= total_weight; {
fg[2] /= total_weight; fg[3] /= total_weight;
fg[3] /= total_weight; fg[0] /= total_weight;
fg[1] /= total_weight;
fg[2] /= total_weight;
if(fg[0] < 0) fg[0] = 0; if(fg[0] < 0) fg[0] = 0;
if(fg[1] < 0) fg[1] = 0; if(fg[1] < 0) fg[1] = 0;
if(fg[2] < 0) fg[2] = 0; if(fg[2] < 0) fg[2] = 0;
if(fg[3] < 0) fg[3] = 0; if(fg[3] < 0) fg[3] = 0;
}
else
{
fg[0] = 0;
fg[1] = 0;
fg[2] = 0;
fg[3] = 0;
}
if(fg[order_type::R] > base_mask) fg[order_type::R] = base_mask;
if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask;
if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask;
if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask; if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask;
if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A];
if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A];
if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A];
span->r = (value_type)fg[order_type::R]; span->r = (value_type)fg[order_type::R];
span->g = (value_type)fg[order_type::G]; span->g = (value_type)fg[order_type::G];
span->b = (value_type)fg[order_type::B]; span->b = (value_type)fg[order_type::B];