Painter code reductions....

git-svn-id: svn://ultimatepp.org/upp/trunk@809 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-01-25 23:04:38 +00:00
parent 76e27bf854
commit e02a20fcc6
12 changed files with 1986 additions and 3765 deletions

View file

@ -1,10 +1,13 @@
#include "Painter.h"
// int agg_line_counter; _DBG_
NAMESPACE_UPP
void BufferPainter::FillOp(const RGBA& c)
{
PAINTER_TIMING("FillOp");
// agg_line_counter = 0;
if(inpath)
path.close_polygon();
pixf.noaa = pathattr.noaa;
@ -36,6 +39,7 @@ void BufferPainter::FillOp(const RGBA& c)
}
}
inpath = false;
// DDUMP(agg_line_counter);
}
struct UppImageAggSpan {

View file

@ -40,8 +40,6 @@ file
agg_curves.cpp,
agg_dda_line.h,
agg_gamma_functions.h,
agg_image_filters.h,
agg_image_filters.cpp,
agg_math.h,
agg_path_storage.h,
agg_rasterizer_cells_aa.h,
@ -52,8 +50,6 @@ file
agg_rendering_buffer.h,
agg_scanline_p.h,
agg_span_allocator.h,
agg_span_image_filter.h,
agg_span_image_filter_upp.h,
agg_span_interpolator_linear.h,
agg_trans_affine.h,
agg_trans_affine.cpp,

View file

@ -1,157 +1,157 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
#ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED
#define AGG_CONV_ADAPTOR_VCGEN_INCLUDED
#include "agg_basics.h"
namespace agg
{
//------------------------------------------------------------null_markers
struct null_markers
{
void remove_all() {}
void add_vertex(double, double, unsigned) {}
void prepare_src() {}
void rewind(unsigned) {}
unsigned vertex(double*, double*) { return path_cmd_stop; }
};
//------------------------------------------------------conv_adaptor_vcgen
template<class VertexSource,
class Generator,
class Markers=null_markers> class conv_adaptor_vcgen
{
enum status
{
initial,
accumulate,
generate
};
public:
explicit conv_adaptor_vcgen(VertexSource& source) :
m_source(&source),
m_status(initial)
{}
void attach(VertexSource& source) { m_source = &source; }
Generator& generator() { return m_generator; }
const Generator& generator() const { return m_generator; }
Markers& markers() { return m_markers; }
const Markers& markers() const { return m_markers; }
void rewind(unsigned path_id)
{
m_source->rewind(path_id);
m_status = initial;
}
unsigned vertex(double* x, double* y);
private:
// Prohibit copying
conv_adaptor_vcgen(const conv_adaptor_vcgen<VertexSource, Generator, Markers>&);
const conv_adaptor_vcgen<VertexSource, Generator, Markers>&
operator = (const conv_adaptor_vcgen<VertexSource, Generator, Markers>&);
VertexSource* m_source;
Generator m_generator;
Markers m_markers;
status m_status;
unsigned m_last_cmd;
double m_start_x;
double m_start_y;
};
//------------------------------------------------------------------------
template<class VertexSource, class Generator, class Markers>
unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(double* x, double* y)
{
unsigned cmd = path_cmd_stop;
bool done = false;
while(!done)
{
switch(m_status)
{
case initial:
m_markers.remove_all();
m_last_cmd = m_source->vertex(&m_start_x, &m_start_y);
m_status = accumulate;
case accumulate:
if(is_stop(m_last_cmd)) return path_cmd_stop;
m_generator.remove_all();
m_generator.add_vertex(m_start_x, m_start_y, path_cmd_move_to);
m_markers.add_vertex(m_start_x, m_start_y, path_cmd_move_to);
for(;;)
{
cmd = m_source->vertex(x, y);
if(is_vertex(cmd))
{
m_last_cmd = cmd;
if(is_move_to(cmd))
{
m_start_x = *x;
m_start_y = *y;
break;
}
m_generator.add_vertex(*x, *y, cmd);
m_markers.add_vertex(*x, *y, path_cmd_line_to);
}
else
{
if(is_stop(cmd))
{
m_last_cmd = path_cmd_stop;
break;
}
if(is_end_poly(cmd))
{
m_generator.add_vertex(*x, *y, cmd);
break;
}
}
}
m_generator.rewind(0);
m_status = generate;
case generate:
cmd = m_generator.vertex(x, y);
if(is_stop(cmd))
{
m_status = accumulate;
break;
}
done = true;
break;
}
}
return cmd;
}
}
#endif
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
#ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED
#define AGG_CONV_ADAPTOR_VCGEN_INCLUDED
#include "agg_basics.h"
namespace agg
{
//------------------------------------------------------------null_markers
struct null_markers
{
void remove_all() {}
void add_vertex(double, double, unsigned) {}
void prepare_src() {}
void rewind(unsigned) {}
unsigned vertex(double*, double*) { return path_cmd_stop; }
};
//------------------------------------------------------conv_adaptor_vcgen
template<class VertexSource,
class Generator,
class Markers=null_markers> class conv_adaptor_vcgen
{
enum status
{
initial,
accumulate,
generate
};
public:
explicit conv_adaptor_vcgen(VertexSource& source) :
m_source(&source),
m_status(initial)
{}
void attach(VertexSource& source) { m_source = &source; }
Generator& generator() { return m_generator; }
const Generator& generator() const { return m_generator; }
Markers& markers() { return m_markers; }
const Markers& markers() const { return m_markers; }
void rewind(unsigned path_id)
{
m_source->rewind(path_id);
m_status = initial;
}
unsigned vertex(double* x, double* y);
private:
// Prohibit copying
conv_adaptor_vcgen(const conv_adaptor_vcgen<VertexSource, Generator, Markers>&);
const conv_adaptor_vcgen<VertexSource, Generator, Markers>&
operator = (const conv_adaptor_vcgen<VertexSource, Generator, Markers>&);
VertexSource* m_source;
Generator m_generator;
Markers m_markers;
status m_status;
unsigned m_last_cmd;
double m_start_x;
double m_start_y;
};
//------------------------------------------------------------------------
template<class VertexSource, class Generator, class Markers>
unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(double* x, double* y)
{
unsigned cmd = path_cmd_stop;
bool done = false;
while(!done)
{
switch(m_status)
{
case initial:
m_markers.remove_all();
m_last_cmd = m_source->vertex(&m_start_x, &m_start_y);
m_status = accumulate;
case accumulate:
if(is_stop(m_last_cmd)) return path_cmd_stop;
m_generator.remove_all();
m_generator.add_vertex(m_start_x, m_start_y, path_cmd_move_to);
m_markers.add_vertex(m_start_x, m_start_y, path_cmd_move_to);
for(;;)
{
cmd = m_source->vertex(x, y);
if(is_vertex(cmd))
{
m_last_cmd = cmd;
if(is_move_to(cmd))
{
m_start_x = *x;
m_start_y = *y;
break;
}
m_generator.add_vertex(*x, *y, cmd);
m_markers.add_vertex(*x, *y, path_cmd_line_to);
}
else
{
if(is_stop(cmd))
{
m_last_cmd = path_cmd_stop;
break;
}
if(is_end_poly(cmd))
{
m_generator.add_vertex(*x, *y, cmd);
break;
}
}
}
m_generator.rewind(0);
m_status = generate;
case generate:
cmd = m_generator.vertex(x, y);
if(is_stop(cmd))
{
m_status = accumulate;
break;
}
done = true;
break;
}
}
return cmd;
}
}
#endif

View file

@ -1,103 +0,0 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Filtering class image_filter_lut implemantation
//
//----------------------------------------------------------------------------
#include "agg_image_filters.h"
namespace agg
{
//--------------------------------------------------------------------
void image_filter_lut::realloc_lut(double radius)
{
m_radius = radius;
m_diameter = uceil(radius) * 2;
m_start = -int(m_diameter / 2 - 1);
unsigned size = m_diameter << image_subpixel_shift;
if(size > m_weight_array.size())
{
m_weight_array.resize(size);
}
}
//--------------------------------------------------------------------
// This function normalizes integer values and corrects the rounding
// errors. It doesn't do anything with the source floating point values
// (m_weight_array_dbl), it corrects only integers according to the rule
// of 1.0 which means that any sum of pixel weights must be equal to 1.0.
// So, the filter function must produce a graph of the proper shape.
//--------------------------------------------------------------------
void image_filter_lut::normalize()
{
unsigned i;
int flip = 1;
for(i = 0; i < image_subpixel_scale; i++)
{
for(;;)
{
int sum = 0;
unsigned j;
for(j = 0; j < m_diameter; j++)
{
sum += m_weight_array[j * image_subpixel_scale + i];
}
if(sum == image_filter_scale) break;
double k = double(image_filter_scale) / double(sum);
sum = 0;
for(j = 0; j < m_diameter; j++)
{
sum += m_weight_array[j * image_subpixel_scale + i] =
iround(m_weight_array[j * image_subpixel_scale + i] * k);
}
sum -= image_filter_scale;
int inc = (sum > 0) ? -1 : 1;
for(j = 0; j < m_diameter && sum; j++)
{
flip ^= 1;
unsigned idx = flip ? m_diameter/2 + j/2 : m_diameter/2 - j/2;
int v = m_weight_array[idx * image_subpixel_scale + i];
if(v < image_filter_scale)
{
m_weight_array[idx * image_subpixel_scale + i] += inc;
sum += inc;
}
}
}
}
unsigned pivot = m_diameter << (image_subpixel_shift - 1);
for(i = 0; i < pivot; i++)
{
m_weight_array[pivot + i] = m_weight_array[pivot - i];
}
unsigned end = (diameter() << image_subpixel_shift) - 1;
m_weight_array[0] = m_weight_array[end];
}
}

View file

@ -1,448 +0,0 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Image transformation filters,
// Filtering classes (image_filter_lut, image_filter),
// Basic filter shape classes
//----------------------------------------------------------------------------
#ifndef AGG_IMAGE_FILTERS_INCLUDED
#define AGG_IMAGE_FILTERS_INCLUDED
#include "agg_array.h"
#include "agg_math.h"
namespace agg
{
// See Implementation agg_image_filters.cpp
enum image_filter_scale_e
{
image_filter_shift = 14, //----image_filter_shift
image_filter_scale = 1 << image_filter_shift, //----image_filter_scale
image_filter_mask = image_filter_scale - 1 //----image_filter_mask
};
enum image_subpixel_scale_e
{
image_subpixel_shift = 8, //----image_subpixel_shift
image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale
image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask
};
//-----------------------------------------------------image_filter_lut
class image_filter_lut
{
public:
template<class FilterF> void calculate(const FilterF& filter,
bool normalization=true)
{
double r = filter.radius();
realloc_lut(r);
unsigned i;
unsigned pivot = diameter() << (image_subpixel_shift - 1);
for(i = 0; i < pivot; i++)
{
double x = double(i) / double(image_subpixel_scale);
double y = filter.calc_weight(x);
m_weight_array[pivot + i] =
m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);
}
unsigned end = (diameter() << image_subpixel_shift) - 1;
m_weight_array[0] = m_weight_array[end];
if(normalization)
{
normalize();
}
}
image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {}
template<class FilterF> image_filter_lut(const FilterF& filter,
bool normalization=true)
{
calculate(filter, normalization);
}
double radius() const { return m_radius; }
unsigned diameter() const { return m_diameter; }
int start() const { return m_start; }
const int16* weight_array() const { return &m_weight_array[0]; }
void normalize();
private:
void realloc_lut(double radius);
image_filter_lut(const image_filter_lut&);
const image_filter_lut& operator = (const image_filter_lut&);
double m_radius;
unsigned m_diameter;
int m_start;
pod_array<int16> m_weight_array;
};
//--------------------------------------------------------image_filter
template<class FilterF> class image_filter : public image_filter_lut
{
public:
image_filter()
{
calculate(m_filter_function);
}
private:
FilterF m_filter_function;
};
//-----------------------------------------------image_filter_bilinear
struct image_filter_bilinear
{
static double radius() { return 1.0; }
static double calc_weight(double x)
{
return 1.0 - x;
}
};
//-----------------------------------------------image_filter_hanning
struct image_filter_hanning
{
static double radius() { return 1.0; }
static double calc_weight(double x)
{
return 0.5 + 0.5 * cos(pi * x);
}
};
//-----------------------------------------------image_filter_hamming
struct image_filter_hamming
{
static double radius() { return 1.0; }
static double calc_weight(double x)
{
return 0.54 + 0.46 * cos(pi * x);
}
};
//-----------------------------------------------image_filter_hermite
struct image_filter_hermite
{
static double radius() { return 1.0; }
static double calc_weight(double x)
{
return (2.0 * x - 3.0) * x * x + 1.0;
}
};
//------------------------------------------------image_filter_quadric
struct image_filter_quadric
{
static double radius() { return 1.5; }
static double calc_weight(double x)
{
double t;
if(x < 0.5) return 0.75 - x * x;
if(x < 1.5) {t = x - 1.5; return 0.5 * t * t;}
return 0.0;
}
};
//------------------------------------------------image_filter_bicubic
class image_filter_bicubic
{
static double pow3(double x)
{
return (x <= 0.0) ? 0.0 : x * x * x;
}
public:
static double radius() { return 2.0; }
static double calc_weight(double x)
{
return
(1.0/6.0) *
(pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1));
}
};
//-------------------------------------------------image_filter_kaiser
class image_filter_kaiser
{
double a;
double i0a;
double epsilon;
public:
image_filter_kaiser(double b = 6.33) :
a(b), epsilon(1e-12)
{
i0a = 1.0 / bessel_i0(b);
}
static double radius() { return 1.0; }
double calc_weight(double x) const
{
return bessel_i0(a * sqrt(1. - x * x)) * i0a;
}
private:
double bessel_i0(double x) const
{
int i;
double sum, y, t;
sum = 1.;
y = x * x / 4.;
t = y;
for(i = 2; t > epsilon; i++)
{
sum += t;
t *= (double)y / (i * i);
}
return sum;
}
};
//----------------------------------------------image_filter_catrom
struct image_filter_catrom
{
static double radius() { return 2.0; }
static double calc_weight(double x)
{
if(x < 1.0) return 0.5 * (2.0 + x * x * (-5.0 + x * 3.0));
if(x < 2.0) return 0.5 * (4.0 + x * (-8.0 + x * (5.0 - x)));
return 0.;
}
};
//---------------------------------------------image_filter_mitchell
class image_filter_mitchell
{
double p0, p2, p3;
double q0, q1, q2, q3;
public:
image_filter_mitchell(double b = 1.0/3.0, double c = 1.0/3.0) :
p0((6.0 - 2.0 * b) / 6.0),
p2((-18.0 + 12.0 * b + 6.0 * c) / 6.0),
p3((12.0 - 9.0 * b - 6.0 * c) / 6.0),
q0((8.0 * b + 24.0 * c) / 6.0),
q1((-12.0 * b - 48.0 * c) / 6.0),
q2((6.0 * b + 30.0 * c) / 6.0),
q3((-b - 6.0 * c) / 6.0)
{}
static double radius() { return 2.0; }
double calc_weight(double x) const
{
if(x < 1.0) return p0 + x * x * (p2 + x * p3);
if(x < 2.0) return q0 + x * (q1 + x * (q2 + x * q3));
return 0.0;
}
};
//----------------------------------------------image_filter_spline16
struct image_filter_spline16
{
static double radius() { return 2.0; }
static double calc_weight(double x)
{
if(x < 1.0)
{
return ((x - 9.0/5.0 ) * x - 1.0/5.0 ) * x + 1.0;
}
return ((-1.0/3.0 * (x-1) + 4.0/5.0) * (x-1) - 7.0/15.0 ) * (x-1);
}
};
//---------------------------------------------image_filter_spline36
struct image_filter_spline36
{
static double radius() { return 3.0; }
static double calc_weight(double x)
{
if(x < 1.0)
{
return ((13.0/11.0 * x - 453.0/209.0) * x - 3.0/209.0) * x + 1.0;
}
if(x < 2.0)
{
return ((-6.0/11.0 * (x-1) + 270.0/209.0) * (x-1) - 156.0/ 209.0) * (x-1);
}
return ((1.0/11.0 * (x-2) - 45.0/209.0) * (x-2) + 26.0/209.0) * (x-2);
}
};
//----------------------------------------------image_filter_gaussian
struct image_filter_gaussian
{
static double radius() { return 2.0; }
static double calc_weight(double x)
{
return exp(-2.0 * x * x) * sqrt(2.0 / pi);
}
};
//------------------------------------------------image_filter_bessel
struct image_filter_bessel
{
static double radius() { return 3.2383; }
static double calc_weight(double x)
{
return (x == 0.0) ? pi / 4.0 : besj(pi * x, 1) / (2.0 * x);
}
};
//-------------------------------------------------image_filter_sinc
class image_filter_sinc
{
public:
image_filter_sinc(double r) : m_radius(r < 2.0 ? 2.0 : r) {}
double radius() const { return m_radius; }
double calc_weight(double x) const
{
if(x == 0.0) return 1.0;
x *= pi;
return sin(x) / x;
}
private:
double m_radius;
};
//-----------------------------------------------image_filter_lanczos
class image_filter_lanczos
{
public:
image_filter_lanczos(double r) : m_radius(r < 2.0 ? 2.0 : r) {}
double radius() const { return m_radius; }
double calc_weight(double x) const
{
if(x == 0.0) return 1.0;
if(x > m_radius) return 0.0;
x *= pi;
double xr = x / m_radius;
return (sin(x) / x) * (sin(xr) / xr);
}
private:
double m_radius;
};
//----------------------------------------------image_filter_blackman
class image_filter_blackman
{
public:
image_filter_blackman(double r) : m_radius(r < 2.0 ? 2.0 : r) {}
double radius() const { return m_radius; }
double calc_weight(double x) const
{
if(x == 0.0) return 1.0;
if(x > m_radius) return 0.0;
x *= pi;
double xr = x / m_radius;
return (sin(x) / x) * (0.42 + 0.5*cos(xr) + 0.08*cos(2*xr));
}
private:
double m_radius;
};
//------------------------------------------------image_filter_sinc36
class image_filter_sinc36 : public image_filter_sinc
{ public: image_filter_sinc36() : image_filter_sinc(3.0){} };
//------------------------------------------------image_filter_sinc64
class image_filter_sinc64 : public image_filter_sinc
{ public: image_filter_sinc64() : image_filter_sinc(4.0){} };
//-----------------------------------------------image_filter_sinc100
class image_filter_sinc100 : public image_filter_sinc
{ public: image_filter_sinc100() : image_filter_sinc(5.0){} };
//-----------------------------------------------image_filter_sinc144
class image_filter_sinc144 : public image_filter_sinc
{ public: image_filter_sinc144() : image_filter_sinc(6.0){} };
//-----------------------------------------------image_filter_sinc196
class image_filter_sinc196 : public image_filter_sinc
{ public: image_filter_sinc196() : image_filter_sinc(7.0){} };
//-----------------------------------------------image_filter_sinc256
class image_filter_sinc256 : public image_filter_sinc
{ public: image_filter_sinc256() : image_filter_sinc(8.0){} };
//---------------------------------------------image_filter_lanczos36
class image_filter_lanczos36 : public image_filter_lanczos
{ public: image_filter_lanczos36() : image_filter_lanczos(3.0){} };
//---------------------------------------------image_filter_lanczos64
class image_filter_lanczos64 : public image_filter_lanczos
{ public: image_filter_lanczos64() : image_filter_lanczos(4.0){} };
//--------------------------------------------image_filter_lanczos100
class image_filter_lanczos100 : public image_filter_lanczos
{ public: image_filter_lanczos100() : image_filter_lanczos(5.0){} };
//--------------------------------------------image_filter_lanczos144
class image_filter_lanczos144 : public image_filter_lanczos
{ public: image_filter_lanczos144() : image_filter_lanczos(6.0){} };
//--------------------------------------------image_filter_lanczos196
class image_filter_lanczos196 : public image_filter_lanczos
{ public: image_filter_lanczos196() : image_filter_lanczos(7.0){} };
//--------------------------------------------image_filter_lanczos256
class image_filter_lanczos256 : public image_filter_lanczos
{ public: image_filter_lanczos256() : image_filter_lanczos(8.0){} };
//--------------------------------------------image_filter_blackman36
class image_filter_blackman36 : public image_filter_blackman
{ public: image_filter_blackman36() : image_filter_blackman(3.0){} };
//--------------------------------------------image_filter_blackman64
class image_filter_blackman64 : public image_filter_blackman
{ public: image_filter_blackman64() : image_filter_blackman(4.0){} };
//-------------------------------------------image_filter_blackman100
class image_filter_blackman100 : public image_filter_blackman
{ public: image_filter_blackman100() : image_filter_blackman(5.0){} };
//-------------------------------------------image_filter_blackman144
class image_filter_blackman144 : public image_filter_blackman
{ public: image_filter_blackman144() : image_filter_blackman(6.0){} };
//-------------------------------------------image_filter_blackman196
class image_filter_blackman196 : public image_filter_blackman
{ public: image_filter_blackman196() : image_filter_blackman(7.0){} };
//-------------------------------------------image_filter_blackman256
class image_filter_blackman256 : public image_filter_blackman
{ public: image_filter_blackman256() : image_filter_blackman(8.0){} };
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -402,6 +402,8 @@ namespace agg
void rasterizer_scanline_aa<Clip>::line_to_d(double x, double y)
{
PAINTER_TIMING("line_to_d");
// extern int agg_line_counter;
// agg_line_counter++;
m_clipper.line_to(m_outline,
conv_type::upscale(x),
conv_type::upscale(y));

View file

@ -1,66 +1,66 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
#ifndef AGG_SHORTEN_PATH_INCLUDED
#define AGG_SHORTEN_PATH_INCLUDED
#include "agg_basics.h"
#include "agg_vertex_sequence.h"
namespace agg
{
//===========================================================shorten_path
template<class VertexSequence>
void shorten_path(VertexSequence& vs, double s, unsigned closed = 0)
{
typedef typename VertexSequence::value_type vertex_type;
if(s > 0.0 && vs.size() > 1)
{
double d;
int n = int(vs.size() - 2);
while(n)
{
d = vs[n].dist;
if(d > s) break;
vs.remove_last();
s -= d;
--n;
}
if(vs.size() < 2)
{
vs.remove_all();
}
else
{
n = vs.size() - 1;
vertex_type& prev = vs[n-1];
vertex_type& last = vs[n];
d = (prev.dist - s) / prev.dist;
double x = prev.x + (last.x - prev.x) * d;
double y = prev.y + (last.y - prev.y) * d;
last.x = x;
last.y = y;
if(!prev(last)) vs.remove_last();
vs.close(closed != 0);
}
}
}
}
#endif
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
#ifndef AGG_SHORTEN_PATH_INCLUDED
#define AGG_SHORTEN_PATH_INCLUDED
#include "agg_basics.h"
#include "agg_vertex_sequence.h"
namespace agg
{
//===========================================================shorten_path
template<class VertexSequence>
void shorten_path(VertexSequence& vs, double s, unsigned closed = 0)
{
typedef typename VertexSequence::value_type vertex_type;
if(s > 0.0 && vs.size() > 1)
{
double d;
int n = int(vs.size() - 2);
while(n)
{
d = vs[n].dist;
if(d > s) break;
vs.remove_last();
s -= d;
--n;
}
if(vs.size() < 2)
{
vs.remove_all();
}
else
{
n = vs.size() - 1;
vertex_type& prev = vs[n-1];
vertex_type& last = vs[n];
d = (prev.dist - s) / prev.dist;
double x = prev.x + (last.x - prev.x) * d;
double y = prev.y + (last.y - prev.y) * d;
last.x = x;
last.y = y;
if(!prev(last)) vs.remove_last();
vs.close(closed != 0);
}
}
}
}
#endif

View file

@ -1,246 +0,0 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Image transformations with filtering. Span generator base class
//
//----------------------------------------------------------------------------
#ifndef AGG_SPAN_IMAGE_FILTER_INCLUDED
#define AGG_SPAN_IMAGE_FILTER_INCLUDED
#include "agg_basics.h"
#include "agg_image_filters.h"
#include "agg_span_interpolator_linear.h"
namespace agg
{
//-------------------------------------------------------span_image_filter
template<class Source, class Interpolator> class span_image_filter
{
public:
typedef Source source_type;
typedef Interpolator interpolator_type;
//--------------------------------------------------------------------
span_image_filter() {}
span_image_filter(source_type& src,
interpolator_type& interpolator,
const image_filter_lut* filter) :
m_src(&src),
m_interpolator(&interpolator),
m_filter(filter),
m_dx_dbl(0.5),
m_dy_dbl(0.5),
m_dx_int(image_subpixel_scale / 2),
m_dy_int(image_subpixel_scale / 2)
{}
void attach(source_type& v) { m_src = &v; }
//--------------------------------------------------------------------
source_type& source() { return *m_src; }
const source_type& source() const { return *m_src; }
const image_filter_lut& filter() const { return *m_filter; }
int filter_dx_int() const { return m_dx_int; }
int filter_dy_int() const { return m_dy_int; }
double filter_dx_dbl() const { return m_dx_dbl; }
double filter_dy_dbl() const { return m_dy_dbl; }
//--------------------------------------------------------------------
void interpolator(interpolator_type& v) { m_interpolator = &v; }
void filter(const image_filter_lut& v) { m_filter = &v; }
void filter_offset(double dx, double dy)
{
m_dx_dbl = dx;
m_dy_dbl = dy;
m_dx_int = iround(dx * image_subpixel_scale);
m_dy_int = iround(dy * image_subpixel_scale);
}
void filter_offset(double d) { filter_offset(d, d); }
//--------------------------------------------------------------------
interpolator_type& interpolator() { return *m_interpolator; }
//--------------------------------------------------------------------
void prepare() {}
//--------------------------------------------------------------------
private:
source_type* m_src;
interpolator_type* m_interpolator;
const image_filter_lut* m_filter;
double m_dx_dbl;
double m_dy_dbl;
unsigned m_dx_int;
unsigned m_dy_int;
};
//==============================================span_image_resample_affine
template<class Source>
class span_image_resample_affine :
public span_image_filter<Source, span_interpolator_linear<trans_affine> >
{
public:
typedef Source source_type;
typedef span_interpolator_linear<trans_affine> interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
//--------------------------------------------------------------------
span_image_resample_affine() :
m_scale_limit(200.0),
m_blur_x(1.0),
m_blur_y(1.0)
{}
//--------------------------------------------------------------------
span_image_resample_affine(source_type& src,
interpolator_type& inter,
const image_filter_lut& filter) :
base_type(src, inter, &filter),
m_scale_limit(200.0),
m_blur_x(1.0),
m_blur_y(1.0)
{}
//--------------------------------------------------------------------
int scale_limit() const { return uround(m_scale_limit); }
void scale_limit(int v) { m_scale_limit = v; }
//--------------------------------------------------------------------
double blur_x() const { return m_blur_x; }
double blur_y() const { return m_blur_y; }
void blur_x(double v) { m_blur_x = v; }
void blur_y(double v) { m_blur_y = v; }
void blur(double v) { m_blur_x = m_blur_y = v; }
//--------------------------------------------------------------------
void prepare()
{
double scale_x;
double scale_y;
base_type::interpolator().transformer().scaling_abs(&scale_x, &scale_y);
if(scale_x * scale_y > m_scale_limit)
{
scale_x = scale_x * m_scale_limit / (scale_x * scale_y);
scale_y = scale_y * m_scale_limit / (scale_x * scale_y);
}
if(scale_x < 1) scale_x = 1;
if(scale_y < 1) scale_y = 1;
if(scale_x > m_scale_limit) scale_x = m_scale_limit;
if(scale_y > m_scale_limit) scale_y = m_scale_limit;
scale_x *= m_blur_x;
scale_y *= m_blur_y;
if(scale_x < 1) scale_x = 1;
if(scale_y < 1) scale_y = 1;
m_rx = uround( scale_x * double(image_subpixel_scale));
m_rx_inv = uround(1.0/scale_x * double(image_subpixel_scale));
m_ry = uround( scale_y * double(image_subpixel_scale));
m_ry_inv = uround(1.0/scale_y * double(image_subpixel_scale));
}
protected:
int m_rx;
int m_ry;
int m_rx_inv;
int m_ry_inv;
private:
double m_scale_limit;
double m_blur_x;
double m_blur_y;
};
//=====================================================span_image_resample
template<class Source, class Interpolator>
class span_image_resample :
public span_image_filter<Source, Interpolator>
{
public:
typedef Source source_type;
typedef Interpolator interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
//--------------------------------------------------------------------
span_image_resample() :
m_scale_limit(20),
m_blur_x(image_subpixel_scale),
m_blur_y(image_subpixel_scale)
{}
//--------------------------------------------------------------------
span_image_resample(source_type& src,
interpolator_type& inter,
const image_filter_lut& filter) :
base_type(src, inter, &filter),
m_scale_limit(20),
m_blur_x(image_subpixel_scale),
m_blur_y(image_subpixel_scale)
{}
//--------------------------------------------------------------------
int scale_limit() const { return m_scale_limit; }
void scale_limit(int v) { m_scale_limit = v; }
//--------------------------------------------------------------------
double blur_x() const { return double(m_blur_x) / double(image_subpixel_scale); }
double blur_y() const { return double(m_blur_y) / double(image_subpixel_scale); }
void blur_x(double v) { m_blur_x = uround(v * double(image_subpixel_scale)); }
void blur_y(double v) { m_blur_y = uround(v * double(image_subpixel_scale)); }
void blur(double v) { m_blur_x =
m_blur_y = uround(v * double(image_subpixel_scale)); }
protected:
AGG_INLINE void adjust_scale(int* rx, int* ry)
{
if(*rx < image_subpixel_scale) *rx = image_subpixel_scale;
if(*ry < image_subpixel_scale) *ry = image_subpixel_scale;
if(*rx > image_subpixel_scale * m_scale_limit)
{
*rx = image_subpixel_scale * m_scale_limit;
}
if(*ry > image_subpixel_scale * m_scale_limit)
{
*ry = image_subpixel_scale * m_scale_limit;
}
*rx = (*rx * m_blur_x) >> image_subpixel_shift;
*ry = (*ry * m_blur_y) >> image_subpixel_shift;
if(*rx < image_subpixel_scale) *rx = image_subpixel_scale;
if(*ry < image_subpixel_scale) *ry = image_subpixel_scale;
}
int m_scale_limit;
int m_blur_x;
int m_blur_y;
};
}
#endif

View file

@ -1,984 +0,0 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Adaptation for high precision colors has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
//
// Liberty Technology Systems, Inc. is the provider of
// PostScript and PDF technology for software developers.
//
//----------------------------------------------------------------------------
#ifndef AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED
#define AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED
#include "agg_basics.h"
#include "agg_color_rgba.h"
#include "agg_span_image_filter.h"
namespace agg
{
//==============================================span_image_filter_rgba_nn
template<class Source, class Interpolator>
class span_image_filter_rgba_nn :
public span_image_filter<Source, Interpolator>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef Interpolator interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::calc_type calc_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask
};
//--------------------------------------------------------------------
span_image_filter_rgba_nn() {}
span_image_filter_rgba_nn(source_type& src,
interpolator_type& inter) :
base_type(src, inter, 0)
{}
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
do
{
base_type::interpolator().coordinates(&x, &y);
const value_type* fg_ptr = (const value_type*)
base_type::source().span(x >> image_subpixel_shift,
y >> image_subpixel_shift,
1);
span->r = fg_ptr[order_type::R];
span->g = fg_ptr[order_type::G];
span->b = fg_ptr[order_type::B];
span->a = fg_ptr[order_type::A];
++span;
++base_type::interpolator();
} while(--len);
}
};
//=========================================span_image_filter_rgba_bilinear
template<class Source, class Interpolator>
class span_image_filter_rgba_bilinear :
public span_image_filter<Source, Interpolator>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef Interpolator interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::calc_type calc_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask
};
//--------------------------------------------------------------------
span_image_filter_rgba_bilinear() {}
span_image_filter_rgba_bilinear(source_type& src,
interpolator_type& inter) :
base_type(src, inter, 0)
{}
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
calc_type fg[4];
const value_type *fg_ptr;
do
{
int x_hr;
int y_hr;
base_type::interpolator().coordinates(&x_hr, &y_hr);
x_hr -= base_type::filter_dx_int();
y_hr -= base_type::filter_dy_int();
int x_lr = x_hr >> image_subpixel_shift;
int y_lr = y_hr >> image_subpixel_shift;
unsigned weight;
fg[0] =
fg[1] =
fg[2] =
fg[3] = image_subpixel_scale * image_subpixel_scale / 2;
x_hr &= image_subpixel_mask;
y_hr &= image_subpixel_mask;
fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2);
weight = (image_subpixel_scale - x_hr) *
(image_subpixel_scale - y_hr);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg_ptr = (const value_type*)base_type::source().next_x();
weight = x_hr * (image_subpixel_scale - y_hr);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg_ptr = (const value_type*)base_type::source().next_y();
weight = (image_subpixel_scale - x_hr) * y_hr;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg_ptr = (const value_type*)base_type::source().next_x();
weight = x_hr * y_hr;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
span->r = value_type(fg[order_type::R] >> (image_subpixel_shift * 2));
span->g = value_type(fg[order_type::G] >> (image_subpixel_shift * 2));
span->b = value_type(fg[order_type::B] >> (image_subpixel_shift * 2));
span->a = value_type(fg[order_type::A] >> (image_subpixel_shift * 2));
++span;
++base_type::interpolator();
} while(--len);
}
};
//====================================span_image_filter_rgba_bilinear_clip
template<class Source, class Interpolator>
class span_image_filter_rgba_bilinear_clip :
public span_image_filter<Source, Interpolator>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef Interpolator interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::calc_type calc_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask
};
int ax, ay, cx, cy, maxx, maxy;
bool hreflect, vreflect;
bool hrepeat, vrepeat;
bool hcopy, vcopy;
void AdjustX(int& x_lr) {
if(hcopy) {
if(x_lr > maxx)
x_lr = maxx;
if(x_lr < 0)
x_lr = 0;
}
if(hreflect)
x_lr = (x_lr + ax) / cx & 1 ? (ax - x_lr - 1) % cx : (x_lr + ax) % cx;
if(hrepeat)
x_lr = (x_lr + ax) % cx;
}
void AdjustY(int& y_lr) {
if(vcopy) {
if(y_lr > maxy)
y_lr = maxy;
if(y_lr < 0)
y_lr = 0;
}
if(vreflect)
y_lr = (y_lr + ay) / cy & 1 ? (ay - y_lr - 1) % cy : (y_lr + ay) % cy;
if(vrepeat)
y_lr = (y_lr + ay) % cy;
}
//--------------------------------------------------------------------
span_image_filter_rgba_bilinear_clip() {
alpha = 256;
tile = false;
}
span_image_filter_rgba_bilinear_clip(source_type& src,
const color_type& back_color,
interpolator_type& inter) :
base_type(src, inter, 0),
m_back_color(back_color)
{
m_alpha = 256;
hreflect = hrepeat = vreflect = vrepeat = hcopy = vcopy = false;
}
const color_type& background_color() const { return m_back_color; }
void background_color(const color_type& v) { m_back_color = v; }
void alpha(int a) { m_alpha = a + (a >> 7); }
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
calc_type fg[4];
value_type back_r = m_back_color.r;
value_type back_g = m_back_color.g;
value_type back_b = m_back_color.b;
value_type back_a = m_back_color.a;
const value_type *fg_ptr;
cx = base_type::source().width();
cy = base_type::source().height();
maxx = base_type::source().width() - 1;
maxy = base_type::source().height() - 1;
if(hreflect || hrepeat)
ax = 6000000 / cx * cx;
if(vreflect || vrepeat)
ay = 6000000 / cy * cy;
do
{
int x_hr;
int y_hr;
base_type::interpolator().coordinates(&x_hr, &y_hr);
x_hr -= base_type::filter_dx_int();
y_hr -= base_type::filter_dy_int();
int x_lr = x_hr >> image_subpixel_shift;
int y_lr = y_hr >> image_subpixel_shift;
unsigned weight;
AdjustX(x_lr);
AdjustY(y_lr);
if(x_lr >= 0 && y_lr >= 0 &&
x_lr < maxx && y_lr < maxy)
{
fg[0] =
fg[1] =
fg[2] =
fg[3] = image_subpixel_scale * image_subpixel_scale / 2;
x_hr &= image_subpixel_mask;
y_hr &= image_subpixel_mask;
fg_ptr = (const value_type*)
base_type::source().row_ptr(y_lr) + (x_lr << 2);
weight = (image_subpixel_scale - x_hr) *
(image_subpixel_scale - y_hr);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
weight = x_hr * (image_subpixel_scale - y_hr);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
++y_lr;
fg_ptr = (const value_type*)
base_type::source().row_ptr(y_lr) + (x_lr << 2);
weight = (image_subpixel_scale - x_hr) * y_hr;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
weight = x_hr * y_hr;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
fg[0] >>= image_subpixel_shift * 2;
fg[1] >>= image_subpixel_shift * 2;
fg[2] >>= image_subpixel_shift * 2;
fg[3] >>= image_subpixel_shift * 2;
}
else
{
int x0 = x_lr;
int y0 = y_lr;
if((x_lr < -1 || x_lr > maxx) && !hcopy ||
(y_lr > maxy || y_lr < -1) && !vcopy)
{
fg[order_type::R] = back_r;
fg[order_type::G] = back_g;
fg[order_type::B] = back_b;
fg[order_type::A] = back_a;
}
else
{
fg[0] =
fg[1] =
fg[2] =
fg[3] = image_subpixel_scale * image_subpixel_scale / 2;
x_hr &= image_subpixel_mask;
y_hr &= image_subpixel_mask;
weight = (image_subpixel_scale - x_hr) *
(image_subpixel_scale - y_hr);
if(x_lr >= 0 && y_lr >= 0 &&
x_lr <= maxx && y_lr <= maxy)
{
fg_ptr = (const value_type*)
base_type::source().row_ptr(y_lr) + (x_lr << 2);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
}
else
{
fg[order_type::R] += back_r * weight;
fg[order_type::G] += back_g * weight;
fg[order_type::B] += back_b * weight;
fg[order_type::A] += back_a * weight;
}
x_lr = x0 + 1;
AdjustX(x_lr);
weight = x_hr * (image_subpixel_scale - y_hr);
if(x_lr >= 0 && y_lr >= 0 &&
x_lr <= maxx && y_lr <= maxy)
{
fg_ptr = (const value_type*)
base_type::source().row_ptr(y_lr) + (x_lr << 2);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
}
else
{
fg[order_type::R] += back_r * weight;
fg[order_type::G] += back_g * weight;
fg[order_type::B] += back_b * weight;
fg[order_type::A] += back_a * weight;
}
if(!hcopy) {
x_lr = x0;
AdjustX(x_lr);
}
y_lr = y0 + 1;
AdjustY(y_lr);
weight = (image_subpixel_scale - x_hr) * y_hr;
if(x_lr >= 0 && y_lr >= 0 &&
x_lr <= maxx && y_lr <= maxy)
{
fg_ptr = (const value_type*)
base_type::source().row_ptr(y_lr) + (x_lr << 2);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
}
else
{
fg[order_type::R] += back_r * weight;
fg[order_type::G] += back_g * weight;
fg[order_type::B] += back_b * weight;
fg[order_type::A] += back_a * weight;
}
x_lr = x0 + 1;
AdjustX(x_lr);
weight = x_hr * y_hr;
if(x_lr >= 0 && y_lr >= 0 &&
x_lr <= maxx && y_lr <= maxy)
{
fg_ptr = (const value_type*)
base_type::source().row_ptr(y_lr) + (x_lr << 2);
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr++;
}
else
{
fg[order_type::R] += back_r * weight;
fg[order_type::G] += back_g * weight;
fg[order_type::B] += back_b * weight;
fg[order_type::A] += back_a * weight;
}
fg[0] >>= image_subpixel_shift * 2;
fg[1] >>= image_subpixel_shift * 2;
fg[2] >>= image_subpixel_shift * 2;
fg[3] >>= image_subpixel_shift * 2;
}
}
if(m_alpha == 255) {// AGGUPP
span->r = fg[order_type::R];
span->g = fg[order_type::G];
span->b = fg[order_type::B];
span->a = fg[order_type::A];
}
else {
span->r = (m_alpha * (value_type)fg[order_type::R]) >> 8; //AGGUPP
span->g = (m_alpha * (value_type)fg[order_type::G]) >> 8;
span->b = (m_alpha * (value_type)fg[order_type::B]) >> 8;
span->a = (m_alpha * (value_type)fg[order_type::A]) >> 8;
}
++span;
++base_type::interpolator();
} while(--len);
}
private:
color_type m_back_color;
int m_alpha;
};
//==============================================span_image_filter_rgba_2x2
template<class Source, class Interpolator>
class span_image_filter_rgba_2x2 :
public span_image_filter<Source, Interpolator>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef Interpolator interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::calc_type calc_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask
};
//--------------------------------------------------------------------
span_image_filter_rgba_2x2() {}
span_image_filter_rgba_2x2(source_type& src,
interpolator_type& inter,
const image_filter_lut& filter) :
base_type(src, inter, &filter)
{}
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
calc_type fg[4];
const value_type *fg_ptr;
const int16* weight_array = base_type::filter().weight_array() +
((base_type::filter().diameter()/2 - 1) <<
image_subpixel_shift);
do
{
int x_hr;
int y_hr;
base_type::interpolator().coordinates(&x_hr, &y_hr);
x_hr -= base_type::filter_dx_int();
y_hr -= base_type::filter_dy_int();
int x_lr = x_hr >> image_subpixel_shift;
int y_lr = y_hr >> image_subpixel_shift;
unsigned weight;
fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2;
x_hr &= image_subpixel_mask;
y_hr &= image_subpixel_mask;
fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2);
weight = (weight_array[x_hr + image_subpixel_scale] *
weight_array[y_hr + image_subpixel_scale] +
image_filter_scale / 2) >>
image_filter_shift;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg_ptr = (const value_type*)base_type::source().next_x();
weight = (weight_array[x_hr] *
weight_array[y_hr + image_subpixel_scale] +
image_filter_scale / 2) >>
image_filter_shift;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg_ptr = (const value_type*)base_type::source().next_y();
weight = (weight_array[x_hr + image_subpixel_scale] *
weight_array[y_hr] +
image_filter_scale / 2) >>
image_filter_shift;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg_ptr = (const value_type*)base_type::source().next_x();
weight = (weight_array[x_hr] *
weight_array[y_hr] +
image_filter_scale / 2) >>
image_filter_shift;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
fg[0] >>= image_filter_shift;
fg[1] >>= image_filter_shift;
fg[2] >>= image_filter_shift;
fg[3] >>= image_filter_shift;
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->g = (value_type)fg[order_type::G];
span->b = (value_type)fg[order_type::B];
span->a = (value_type)fg[order_type::A];
++span;
++base_type::interpolator();
} while(--len);
}
};
//==================================================span_image_filter_rgba
template<class Source, class Interpolator>
class span_image_filter_rgba :
public span_image_filter<Source, Interpolator>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef Interpolator interpolator_type;
typedef span_image_filter<source_type, interpolator_type> base_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::calc_type calc_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask
};
//--------------------------------------------------------------------
span_image_filter_rgba() {}
span_image_filter_rgba(source_type& src,
interpolator_type& inter,
const image_filter_lut& filter) :
base_type(src, inter, &filter)
{}
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
int fg[4];
const value_type *fg_ptr;
unsigned diameter = base_type::filter().diameter();
int start = base_type::filter().start();
const int16* weight_array = base_type::filter().weight_array();
int x_count;
int weight_y;
do
{
base_type::interpolator().coordinates(&x, &y);
x -= base_type::filter_dx_int();
y -= base_type::filter_dy_int();
int x_hr = x;
int y_hr = y;
int x_lr = x_hr >> image_subpixel_shift;
int y_lr = y_hr >> image_subpixel_shift;
fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2;
int x_fract = x_hr & image_subpixel_mask;
unsigned y_count = diameter;
y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask);
fg_ptr = (const value_type*)base_type::source().span(x_lr + start,
y_lr + start,
diameter);
for(;;)
{
x_count = diameter;
weight_y = weight_array[y_hr];
x_hr = image_subpixel_mask - x_fract;
for(;;)
{
int weight = (weight_y * weight_array[x_hr] +
image_filter_scale / 2) >>
image_filter_shift;
fg[0] += weight * *fg_ptr++;
fg[1] += weight * *fg_ptr++;
fg[2] += weight * *fg_ptr++;
fg[3] += weight * *fg_ptr;
if(--x_count == 0) break;
x_hr += image_subpixel_scale;
fg_ptr = (const value_type*)base_type::source().next_x();
}
if(--y_count == 0) break;
y_hr += image_subpixel_scale;
fg_ptr = (const value_type*)base_type::source().next_y();
}
fg[0] >>= image_filter_shift;
fg[1] >>= image_filter_shift;
fg[2] >>= image_filter_shift;
fg[3] >>= image_filter_shift;
if(fg[0] < 0) fg[0] = 0;
if(fg[1] < 0) fg[1] = 0;
if(fg[2] < 0) fg[2] = 0;
if(fg[3] < 0) fg[3] = 0;
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->g = (value_type)fg[order_type::G];
span->b = (value_type)fg[order_type::B];
span->a = (value_type)fg[order_type::A];
++span;
++base_type::interpolator();
} while(--len);
}
};
//========================================span_image_resample_rgba_affine
template<class Source>
class span_image_resample_rgba_affine :
public span_image_resample_affine<Source>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef span_image_resample_affine<source_type> base_type;
typedef typename base_type::interpolator_type interpolator_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::long_type long_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask,
downscale_shift = image_filter_shift
};
//--------------------------------------------------------------------
span_image_resample_rgba_affine() {}
span_image_resample_rgba_affine(source_type& src,
interpolator_type& inter,
const image_filter_lut& filter) :
base_type(src, inter, filter)
{}
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
long_type fg[4];
int diameter = base_type::filter().diameter();
int filter_scale = diameter << image_subpixel_shift;
int radius_x = (diameter * base_type::m_rx) >> 1;
int radius_y = (diameter * base_type::m_ry) >> 1;
int len_x_lr =
(diameter * base_type::m_rx + image_subpixel_mask) >>
image_subpixel_shift;
const int16* weight_array = base_type::filter().weight_array();
do
{
base_type::interpolator().coordinates(&x, &y);
x += base_type::filter_dx_int() - radius_x;
y += base_type::filter_dy_int() - radius_y;
fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2;
int y_lr = y >> image_subpixel_shift;
int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) *
base_type::m_ry_inv) >>
image_subpixel_shift;
int total_weight = 0;
int x_lr = x >> image_subpixel_shift;
int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) *
base_type::m_rx_inv) >>
image_subpixel_shift;
int x_hr2 = x_hr;
const value_type* fg_ptr =
(const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr);
for(;;)
{
int weight_y = weight_array[y_hr];
x_hr = x_hr2;
for(;;)
{
int weight = (weight_y * weight_array[x_hr] +
image_filter_scale / 2) >>
downscale_shift;
fg[0] += *fg_ptr++ * weight;
fg[1] += *fg_ptr++ * weight;
fg[2] += *fg_ptr++ * weight;
fg[3] += *fg_ptr++ * weight;
total_weight += weight;
x_hr += base_type::m_rx_inv;
if(x_hr >= filter_scale) break;
fg_ptr = (const value_type*)base_type::source().next_x();
}
y_hr += base_type::m_ry_inv;
if(y_hr >= filter_scale) break;
fg_ptr = (const value_type*)base_type::source().next_y();
}
fg[0] /= total_weight;
fg[1] /= total_weight;
fg[2] /= total_weight;
fg[3] /= total_weight;
if(fg[0] < 0) fg[0] = 0;
if(fg[1] < 0) fg[1] = 0;
if(fg[2] < 0) fg[2] = 0;
if(fg[3] < 0) fg[3] = 0;
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->g = (value_type)fg[order_type::G];
span->b = (value_type)fg[order_type::B];
span->a = (value_type)fg[order_type::A];
++span;
++base_type::interpolator();
} while(--len);
}
};
//==============================================span_image_resample_rgba
template<class Source, class Interpolator>
class span_image_resample_rgba :
public span_image_resample<Source, Interpolator>
{
public:
typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;
typedef Interpolator interpolator_type;
typedef span_image_resample<source_type, interpolator_type> base_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::long_type long_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask,
downscale_shift = image_filter_shift
};
//--------------------------------------------------------------------
span_image_resample_rgba() {}
span_image_resample_rgba(source_type& src,
interpolator_type& inter,
const image_filter_lut& filter) :
base_type(src, inter, filter)
{}
//--------------------------------------------------------------------
void generate(color_type* span, int x, int y, unsigned len)
{
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
y + base_type::filter_dy_dbl(), len);
long_type fg[4];
int diameter = base_type::filter().diameter();
int filter_scale = diameter << image_subpixel_shift;
const int16* weight_array = base_type::filter().weight_array();
do
{
int rx;
int ry;
int rx_inv = image_subpixel_scale;
int ry_inv = image_subpixel_scale;
base_type::interpolator().coordinates(&x, &y);
base_type::interpolator().local_scale(&rx, &ry);
base_type::adjust_scale(&rx, &ry);
rx_inv = image_subpixel_scale * image_subpixel_scale / rx;
ry_inv = image_subpixel_scale * image_subpixel_scale / ry;
int radius_x = (diameter * rx) >> 1;
int radius_y = (diameter * ry) >> 1;
int len_x_lr =
(diameter * rx + image_subpixel_mask) >>
image_subpixel_shift;
x += base_type::filter_dx_int() - radius_x;
y += base_type::filter_dy_int() - radius_y;
fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2;
int y_lr = y >> image_subpixel_shift;
int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) *
ry_inv) >>
image_subpixel_shift;
int total_weight = 0;
int x_lr = x >> image_subpixel_shift;
int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) *
rx_inv) >>
image_subpixel_shift;
int x_hr2 = x_hr;
const value_type* fg_ptr =
(const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr);
for(;;)
{
int weight_y = weight_array[y_hr];
x_hr = x_hr2;
for(;;)
{
int weight = (weight_y * weight_array[x_hr] +
image_filter_scale / 2) >>
downscale_shift;
fg[0] += *fg_ptr++ * weight;
fg[1] += *fg_ptr++ * weight;
fg[2] += *fg_ptr++ * weight;
fg[3] += *fg_ptr++ * weight;
total_weight += weight;
x_hr += rx_inv;
if(x_hr >= filter_scale) break;
fg_ptr = (const value_type*)base_type::source().next_x();
}
y_hr += ry_inv;
if(y_hr >= filter_scale) break;
fg_ptr = (const value_type*)base_type::source().next_y();
}
fg[0] /= total_weight;
fg[1] /= total_weight;
fg[2] /= total_weight;
fg[3] /= total_weight;
if(fg[0] < 0) fg[0] = 0;
if(fg[1] < 0) fg[1] = 0;
if(fg[2] < 0) fg[2] = 0;
if(fg[3] < 0) fg[3] = 0;
if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask;
if(fg[order_type::R] > fg[order_type::R]) fg[order_type::R] = fg[order_type::R];
if(fg[order_type::G] > fg[order_type::G]) fg[order_type::G] = fg[order_type::G];
if(fg[order_type::B] > fg[order_type::B]) fg[order_type::B] = fg[order_type::B];
span->r = (value_type)fg[order_type::R];
span->g = (value_type)fg[order_type::G];
span->b = (value_type)fg[order_type::B];
span->a = (value_type)fg[order_type::A];
++span;
++base_type::interpolator();
} while(--len);
}
};
}
#endif

View file

@ -1,213 +1,213 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Stroke generator
//
//----------------------------------------------------------------------------
#include <math.h>
#include "agg_vcgen_stroke.h"
#include "agg_shorten_path.h"
namespace agg
{
//------------------------------------------------------------------------
vcgen_stroke::vcgen_stroke() :
m_stroker(),
m_src_vertices(),
m_out_vertices(),
m_shorten(0.0),
m_closed(0),
m_status(initial),
m_src_vertex(0),
m_out_vertex(0)
{
}
//------------------------------------------------------------------------
void vcgen_stroke::remove_all()
{
m_src_vertices.remove_all();
m_closed = 0;
m_status = initial;
}
//------------------------------------------------------------------------
void vcgen_stroke::add_vertex(double x, double y, unsigned cmd)
{
m_status = initial;
if(is_move_to(cmd))
{
m_src_vertices.modify_last(vertex_dist(x, y));
}
else
{
if(is_vertex(cmd))
{
m_src_vertices.add(vertex_dist(x, y));
}
else
{
m_closed = get_close_flag(cmd);
}
}
}
//------------------------------------------------------------------------
void vcgen_stroke::rewind(unsigned)
{
if(m_status == initial)
{
m_src_vertices.close(m_closed != 0);
shorten_path(m_src_vertices, m_shorten, m_closed);
if(m_src_vertices.size() < 3) m_closed = 0;
}
m_status = ready;
m_src_vertex = 0;
m_out_vertex = 0;
}
//------------------------------------------------------------------------
unsigned vcgen_stroke::vertex(double* x, double* y)
{
unsigned cmd = path_cmd_line_to;
while(!is_stop(cmd))
{
switch(m_status)
{
case initial:
rewind(0);
case ready:
if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
{
cmd = path_cmd_stop;
break;
}
m_status = m_closed ? outline1 : cap1;
cmd = path_cmd_move_to;
m_src_vertex = 0;
m_out_vertex = 0;
break;
case cap1:
m_stroker.calc_cap(m_out_vertices,
m_src_vertices[0],
m_src_vertices[1],
m_src_vertices[0].dist);
m_src_vertex = 1;
m_prev_status = outline1;
m_status = out_vertices;
m_out_vertex = 0;
break;
case cap2:
m_stroker.calc_cap(m_out_vertices,
m_src_vertices[m_src_vertices.size() - 1],
m_src_vertices[m_src_vertices.size() - 2],
m_src_vertices[m_src_vertices.size() - 2].dist);
m_prev_status = outline2;
m_status = out_vertices;
m_out_vertex = 0;
break;
case outline1:
if(m_closed)
{
if(m_src_vertex >= m_src_vertices.size())
{
m_prev_status = close_first;
m_status = end_poly1;
break;
}
}
else
{
if(m_src_vertex >= m_src_vertices.size() - 1)
{
m_status = cap2;
break;
}
}
m_stroker.calc_join(m_out_vertices,
m_src_vertices.prev(m_src_vertex),
m_src_vertices.curr(m_src_vertex),
m_src_vertices.next(m_src_vertex),
m_src_vertices.prev(m_src_vertex).dist,
m_src_vertices.curr(m_src_vertex).dist);
++m_src_vertex;
m_prev_status = m_status;
m_status = out_vertices;
m_out_vertex = 0;
break;
case close_first:
m_status = outline2;
cmd = path_cmd_move_to;
case outline2:
if(m_src_vertex <= unsigned(m_closed == 0))
{
m_status = end_poly2;
m_prev_status = stop;
break;
}
--m_src_vertex;
m_stroker.calc_join(m_out_vertices,
m_src_vertices.next(m_src_vertex),
m_src_vertices.curr(m_src_vertex),
m_src_vertices.prev(m_src_vertex),
m_src_vertices.curr(m_src_vertex).dist,
m_src_vertices.prev(m_src_vertex).dist);
m_prev_status = m_status;
m_status = out_vertices;
m_out_vertex = 0;
break;
case out_vertices:
if(m_out_vertex >= m_out_vertices.size())
{
m_status = m_prev_status;
}
else
{
const point_d& c = m_out_vertices[m_out_vertex++];
*x = c.x;
*y = c.y;
return cmd;
}
break;
case end_poly1:
m_status = m_prev_status;
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
case end_poly2:
m_status = m_prev_status;
return path_cmd_end_poly | path_flags_close | path_flags_cw;
case stop:
cmd = path_cmd_stop;
break;
}
}
return cmd;
}
}
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Stroke generator
//
//----------------------------------------------------------------------------
#include <math.h>
#include "agg_vcgen_stroke.h"
#include "agg_shorten_path.h"
namespace agg
{
//------------------------------------------------------------------------
vcgen_stroke::vcgen_stroke() :
m_stroker(),
m_src_vertices(),
m_out_vertices(),
m_shorten(0.0),
m_closed(0),
m_status(initial),
m_src_vertex(0),
m_out_vertex(0)
{
}
//------------------------------------------------------------------------
void vcgen_stroke::remove_all()
{
m_src_vertices.remove_all();
m_closed = 0;
m_status = initial;
}
//------------------------------------------------------------------------
void vcgen_stroke::add_vertex(double x, double y, unsigned cmd)
{
m_status = initial;
if(is_move_to(cmd))
{
m_src_vertices.modify_last(vertex_dist(x, y));
}
else
{
if(is_vertex(cmd))
{
m_src_vertices.add(vertex_dist(x, y));
}
else
{
m_closed = get_close_flag(cmd);
}
}
}
//------------------------------------------------------------------------
void vcgen_stroke::rewind(unsigned)
{
if(m_status == initial)
{
m_src_vertices.close(m_closed != 0);
shorten_path(m_src_vertices, m_shorten, m_closed);
if(m_src_vertices.size() < 3) m_closed = 0;
}
m_status = ready;
m_src_vertex = 0;
m_out_vertex = 0;
}
//------------------------------------------------------------------------
unsigned vcgen_stroke::vertex(double* x, double* y)
{
unsigned cmd = path_cmd_line_to;
while(!is_stop(cmd))
{
switch(m_status)
{
case initial:
rewind(0);
case ready:
if(m_src_vertices.size() < 2 + unsigned(m_closed != 0))
{
cmd = path_cmd_stop;
break;
}
m_status = m_closed ? outline1 : cap1;
cmd = path_cmd_move_to;
m_src_vertex = 0;
m_out_vertex = 0;
break;
case cap1:
m_stroker.calc_cap(m_out_vertices,
m_src_vertices[0],
m_src_vertices[1],
m_src_vertices[0].dist);
m_src_vertex = 1;
m_prev_status = outline1;
m_status = out_vertices;
m_out_vertex = 0;
break;
case cap2:
m_stroker.calc_cap(m_out_vertices,
m_src_vertices[m_src_vertices.size() - 1],
m_src_vertices[m_src_vertices.size() - 2],
m_src_vertices[m_src_vertices.size() - 2].dist);
m_prev_status = outline2;
m_status = out_vertices;
m_out_vertex = 0;
break;
case outline1:
if(m_closed)
{
if(m_src_vertex >= m_src_vertices.size())
{
m_prev_status = close_first;
m_status = end_poly1;
break;
}
}
else
{
if(m_src_vertex >= m_src_vertices.size() - 1)
{
m_status = cap2;
break;
}
}
m_stroker.calc_join(m_out_vertices,
m_src_vertices.prev(m_src_vertex),
m_src_vertices.curr(m_src_vertex),
m_src_vertices.next(m_src_vertex),
m_src_vertices.prev(m_src_vertex).dist,
m_src_vertices.curr(m_src_vertex).dist);
++m_src_vertex;
m_prev_status = m_status;
m_status = out_vertices;
m_out_vertex = 0;
break;
case close_first:
m_status = outline2;
cmd = path_cmd_move_to;
case outline2:
if(m_src_vertex <= unsigned(m_closed == 0))
{
m_status = end_poly2;
m_prev_status = stop;
break;
}
--m_src_vertex;
m_stroker.calc_join(m_out_vertices,
m_src_vertices.next(m_src_vertex),
m_src_vertices.curr(m_src_vertex),
m_src_vertices.prev(m_src_vertex),
m_src_vertices.curr(m_src_vertex).dist,
m_src_vertices.prev(m_src_vertex).dist);
m_prev_status = m_status;
m_status = out_vertices;
m_out_vertex = 0;
break;
case out_vertices:
if(m_out_vertex >= m_out_vertices.size())
{
m_status = m_prev_status;
}
else
{
const point_d& c = m_out_vertices[m_out_vertex++];
*x = c.x;
*y = c.y;
return cmd;
}
break;
case end_poly1:
m_status = m_prev_status;
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
case end_poly2:
m_status = m_prev_status;
return path_cmd_end_poly | path_flags_close | path_flags_cw;
case stop:
cmd = path_cmd_stop;
break;
}
}
return cmd;
}
}

View file

@ -1,6 +1,6 @@
#ifndef _Painter_icpp_init_stub
#define _Painter_icpp_init_stub
#define BLITZ_INDEX__ F540929DEFEB017EA91C8849B43C32C36
#define BLITZ_INDEX__ F5429F8BD2A695DD5DB4F5198EB5CB4BD
#include "PaintPainting.icpp"
#undef BLITZ_INDEX__
#endif