pre-commit run -a
This commit is contained in:
parent
df141876d0
commit
e3d8e55a79
154 changed files with 44003 additions and 41746 deletions
122
deps/agg/include/agg_alpha_mask_u8.h
vendored
122
deps/agg/include/agg_alpha_mask_u8.h
vendored
|
@ -23,18 +23,23 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//===================================================one_component_mask_u8
|
||||
struct one_component_mask_u8
|
||||
{
|
||||
static unsigned calculate(const int8u* p) { return *p; }
|
||||
};
|
||||
|
||||
|
||||
//=====================================================rgb_to_gray_mask_u8
|
||||
template<unsigned R, unsigned G, unsigned B>
|
||||
struct rgb_to_gray_mask_u8
|
||||
{
|
||||
static unsigned calculate(const int8u* p) { return (p[R] * 77 + p[G] * 150 + p[B] * 29) >> 8; }
|
||||
static unsigned calculate(const int8u* p)
|
||||
{
|
||||
return (p[R]*77 + p[G]*150 + p[B]*29) >> 8;
|
||||
}
|
||||
};
|
||||
|
||||
//==========================================================alpha_mask_u8
|
||||
|
@ -44,26 +49,31 @@ class alpha_mask_u8
|
|||
public:
|
||||
typedef int8u cover_type;
|
||||
typedef alpha_mask_u8<Step, Offset, MaskF> self_type;
|
||||
enum cover_scale_e { cover_shift = 8, cover_none = 0, cover_full = 255 };
|
||||
enum cover_scale_e
|
||||
{
|
||||
cover_shift = 8,
|
||||
cover_none = 0,
|
||||
cover_full = 255
|
||||
};
|
||||
|
||||
alpha_mask_u8()
|
||||
: m_rbuf(0)
|
||||
{}
|
||||
explicit alpha_mask_u8(rendering_buffer& rbuf)
|
||||
: m_rbuf(&rbuf)
|
||||
{}
|
||||
alpha_mask_u8() : m_rbuf(0) {}
|
||||
explicit alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {}
|
||||
|
||||
void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; }
|
||||
|
||||
MaskF& mask_function() { return m_mask_function; }
|
||||
const MaskF& mask_function() const { return m_mask_function; }
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
cover_type pixel(int x, int y) const
|
||||
{
|
||||
if (x >= 0 && y >= 0 && x < (int)m_rbuf->width() && y < (int)m_rbuf->height())
|
||||
if(x >= 0 && y >= 0 &&
|
||||
x < (int)m_rbuf->width() &&
|
||||
y < (int)m_rbuf->height())
|
||||
{
|
||||
return (cover_type)m_mask_function.calculate(m_rbuf->row_ptr(y) + x * Step + Offset);
|
||||
return (cover_type)m_mask_function.calculate(
|
||||
m_rbuf->row_ptr(y) + x * Step + Offset);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -71,15 +81,19 @@ class alpha_mask_u8
|
|||
//--------------------------------------------------------------------
|
||||
cover_type combine_pixel(int x, int y, cover_type val) const
|
||||
{
|
||||
if (x >= 0 && y >= 0 && x < (int)m_rbuf->width() && y < (int)m_rbuf->height())
|
||||
if(x >= 0 && y >= 0 &&
|
||||
x < (int)m_rbuf->width() &&
|
||||
y < (int)m_rbuf->height())
|
||||
{
|
||||
return (
|
||||
cover_type)((cover_full + val * m_mask_function.calculate(m_rbuf->row_ptr(y) + x * Step + Offset)) >>
|
||||
return (cover_type)((cover_full + val *
|
||||
m_mask_function.calculate(
|
||||
m_rbuf->row_ptr(y) + x * Step + Offset)) >>
|
||||
cover_shift);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void fill_hspan(int x, int y, cover_type* dst, int num_pix) const
|
||||
{
|
||||
|
@ -125,8 +139,10 @@ class alpha_mask_u8
|
|||
{
|
||||
*covers++ = (cover_type)m_mask_function.calculate(mask);
|
||||
mask += Step;
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void combine_hspan(int x, int y, cover_type* dst, int num_pix) const
|
||||
|
@ -171,10 +187,13 @@ class alpha_mask_u8
|
|||
const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
do
|
||||
{
|
||||
*covers = (cover_type)((cover_full + (*covers) * m_mask_function.calculate(mask)) >> cover_shift);
|
||||
*covers = (cover_type)((cover_full + (*covers) *
|
||||
m_mask_function.calculate(mask)) >>
|
||||
cover_shift);
|
||||
++covers;
|
||||
mask += Step;
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -222,7 +241,8 @@ class alpha_mask_u8
|
|||
{
|
||||
*covers++ = (cover_type)m_mask_function.calculate(mask);
|
||||
mask += m_rbuf->stride();
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -268,11 +288,15 @@ class alpha_mask_u8
|
|||
const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
do
|
||||
{
|
||||
*covers = (cover_type)((cover_full + (*covers) * m_mask_function.calculate(mask)) >> cover_shift);
|
||||
*covers = (cover_type)((cover_full + (*covers) *
|
||||
m_mask_function.calculate(mask)) >>
|
||||
cover_shift);
|
||||
++covers;
|
||||
mask += m_rbuf->stride();
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
alpha_mask_u8(const self_type&);
|
||||
|
@ -282,6 +306,7 @@ class alpha_mask_u8
|
|||
MaskF m_mask_function;
|
||||
};
|
||||
|
||||
|
||||
typedef alpha_mask_u8<1, 0> alpha_mask_gray8; //----alpha_mask_gray8
|
||||
|
||||
typedef alpha_mask_u8<3, 0> alpha_mask_rgb24r; //----alpha_mask_rgb24r
|
||||
|
@ -319,6 +344,8 @@ typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2>> alpha_mask_argb32gray;
|
|||
typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgra32gray; //----alpha_mask_bgra32gray
|
||||
typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_abgr32gray; //----alpha_mask_abgr32gray
|
||||
|
||||
|
||||
|
||||
//==========================================================amask_no_clip_u8
|
||||
template<unsigned Step=1, unsigned Offset=0, class MaskF=one_component_mask_u8>
|
||||
class amask_no_clip_u8
|
||||
|
@ -326,33 +353,40 @@ class amask_no_clip_u8
|
|||
public:
|
||||
typedef int8u cover_type;
|
||||
typedef amask_no_clip_u8<Step, Offset, MaskF> self_type;
|
||||
enum cover_scale_e { cover_shift = 8, cover_none = 0, cover_full = 255 };
|
||||
enum cover_scale_e
|
||||
{
|
||||
cover_shift = 8,
|
||||
cover_none = 0,
|
||||
cover_full = 255
|
||||
};
|
||||
|
||||
amask_no_clip_u8()
|
||||
: m_rbuf(0)
|
||||
{}
|
||||
explicit amask_no_clip_u8(rendering_buffer& rbuf)
|
||||
: m_rbuf(&rbuf)
|
||||
{}
|
||||
amask_no_clip_u8() : m_rbuf(0) {}
|
||||
explicit amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {}
|
||||
|
||||
void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; }
|
||||
|
||||
MaskF& mask_function() { return m_mask_function; }
|
||||
const MaskF& mask_function() const { return m_mask_function; }
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
cover_type pixel(int x, int y) const
|
||||
{
|
||||
return (cover_type)m_mask_function.calculate(m_rbuf->row_ptr(y) + x * Step + Offset);
|
||||
return (cover_type)m_mask_function.calculate(
|
||||
m_rbuf->row_ptr(y) + x * Step + Offset);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
cover_type combine_pixel(int x, int y, cover_type val) const
|
||||
{
|
||||
return (cover_type)((cover_full + val * m_mask_function.calculate(m_rbuf->row_ptr(y) + x * Step + Offset)) >>
|
||||
return (cover_type)((cover_full + val *
|
||||
m_mask_function.calculate(
|
||||
m_rbuf->row_ptr(y) + x * Step + Offset)) >>
|
||||
cover_shift);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void fill_hspan(int x, int y, cover_type* dst, int num_pix) const
|
||||
{
|
||||
|
@ -361,8 +395,11 @@ class amask_no_clip_u8
|
|||
{
|
||||
*dst++ = (cover_type)m_mask_function.calculate(mask);
|
||||
mask += Step;
|
||||
} while (--num_pix);
|
||||
}
|
||||
while(--num_pix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void combine_hspan(int x, int y, cover_type* dst, int num_pix) const
|
||||
|
@ -370,11 +407,15 @@ class amask_no_clip_u8
|
|||
const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
do
|
||||
{
|
||||
*dst = (cover_type)((cover_full + (*dst) * m_mask_function.calculate(mask)) >> cover_shift);
|
||||
*dst = (cover_type)((cover_full + (*dst) *
|
||||
m_mask_function.calculate(mask)) >>
|
||||
cover_shift);
|
||||
++dst;
|
||||
mask += Step;
|
||||
} while (--num_pix);
|
||||
}
|
||||
while(--num_pix);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void fill_vspan(int x, int y, cover_type* dst, int num_pix) const
|
||||
|
@ -384,8 +425,10 @@ class amask_no_clip_u8
|
|||
{
|
||||
*dst++ = (cover_type)m_mask_function.calculate(mask);
|
||||
mask += m_rbuf->stride();
|
||||
} while (--num_pix);
|
||||
}
|
||||
while(--num_pix);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void combine_vspan(int x, int y, cover_type* dst, int num_pix) const
|
||||
|
@ -393,10 +436,13 @@ class amask_no_clip_u8
|
|||
const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
do
|
||||
{
|
||||
*dst = (cover_type)((cover_full + (*dst) * m_mask_function.calculate(mask)) >> cover_shift);
|
||||
*dst = (cover_type)((cover_full + (*dst) *
|
||||
m_mask_function.calculate(mask)) >>
|
||||
cover_shift);
|
||||
++dst;
|
||||
mask += m_rbuf->stride();
|
||||
} while (--num_pix);
|
||||
}
|
||||
while(--num_pix);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -407,6 +453,7 @@ class amask_no_clip_u8
|
|||
MaskF m_mask_function;
|
||||
};
|
||||
|
||||
|
||||
typedef amask_no_clip_u8<1, 0> amask_no_clip_gray8; //----amask_no_clip_gray8
|
||||
|
||||
typedef amask_no_clip_u8<3, 0> amask_no_clip_rgb24r; //----amask_no_clip_rgb24r
|
||||
|
@ -444,6 +491,9 @@ typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2>> amask_no_clip_argb3
|
|||
typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgra32gray; //----amask_no_clip_bgra32gray
|
||||
typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_abgr32gray; //----amask_no_clip_abgr32gray
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
22
deps/agg/include/agg_arc.h
vendored
22
deps/agg/include/agg_arc.h
vendored
|
@ -23,7 +23,8 @@
|
|||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=====================================================================arc
|
||||
//
|
||||
|
@ -32,13 +33,16 @@ namespace agg {
|
|||
class arc
|
||||
{
|
||||
public:
|
||||
arc()
|
||||
: m_scale(1.0)
|
||||
, m_initialized(false)
|
||||
{}
|
||||
arc(double x, double y, double rx, double ry, double a1, double a2, bool ccw = true);
|
||||
arc() : m_scale(1.0), m_initialized(false) {}
|
||||
arc(double x, double y,
|
||||
double rx, double ry,
|
||||
double a1, double a2,
|
||||
bool ccw=true);
|
||||
|
||||
void init(double x, double y, double rx, double ry, double a1, double a2, bool ccw = true);
|
||||
void init(double x, double y,
|
||||
double rx, double ry,
|
||||
double a1, double a2,
|
||||
bool ccw=true);
|
||||
|
||||
void approximation_scale(double s);
|
||||
double approximation_scale() const { return m_scale; }
|
||||
|
@ -63,6 +67,8 @@ class arc
|
|||
unsigned m_path_cmd;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
425
deps/agg/include/agg_array.h
vendored
425
deps/agg/include/agg_array.h
vendored
|
@ -19,18 +19,16 @@
|
|||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-------------------------------------------------------pod_array_adaptor
|
||||
template<class T>
|
||||
class pod_array_adaptor
|
||||
template<class T> class pod_array_adaptor
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
pod_array_adaptor(T* array, unsigned _size)
|
||||
: m_array(array)
|
||||
, m_size(_size)
|
||||
{}
|
||||
pod_array_adaptor(T* array, unsigned _size) :
|
||||
m_array(array), m_size(_size) {}
|
||||
|
||||
unsigned size() const { return m_size; }
|
||||
const T& operator [] (unsigned i) const { return m_array[i]; }
|
||||
|
@ -44,16 +42,19 @@ class pod_array_adaptor
|
|||
unsigned m_size;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------pod_auto_array
|
||||
template<class T, unsigned Size>
|
||||
class pod_auto_array
|
||||
template<class T, unsigned Size> class pod_auto_array
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef pod_auto_array<T, Size> self_type;
|
||||
|
||||
pod_auto_array() {}
|
||||
explicit pod_auto_array(const T* c) { memcpy(m_array, c, sizeof(T) * Size); }
|
||||
explicit pod_auto_array(const T* c)
|
||||
{
|
||||
memcpy(m_array, c, sizeof(T) * Size);
|
||||
}
|
||||
|
||||
const self_type& operator = (const T* c)
|
||||
{
|
||||
|
@ -72,17 +73,15 @@ class pod_auto_array
|
|||
T m_array[Size];
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------pod_auto_vector
|
||||
template<class T, unsigned Size>
|
||||
class pod_auto_vector
|
||||
template<class T, unsigned Size> class pod_auto_vector
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef pod_auto_vector<T, Size> self_type;
|
||||
|
||||
pod_auto_vector()
|
||||
: m_size(0)
|
||||
{}
|
||||
pod_auto_vector() : m_size(0) {}
|
||||
|
||||
void remove_all() { m_size = 0; }
|
||||
void clear() { m_size = 0; }
|
||||
|
@ -102,35 +101,32 @@ class pod_auto_vector
|
|||
unsigned m_size;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------pod_array
|
||||
template<class T>
|
||||
class pod_array
|
||||
template<class T> class pod_array
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef pod_array<T> self_type;
|
||||
|
||||
~pod_array() { pod_allocator<T>::deallocate(m_array, m_size); }
|
||||
pod_array()
|
||||
: m_array(0)
|
||||
, m_size(0)
|
||||
pod_array() : m_array(0), m_size(0) {}
|
||||
|
||||
pod_array(unsigned _size) :
|
||||
m_array(pod_allocator<T>::allocate(_size)),
|
||||
m_size(_size)
|
||||
{}
|
||||
|
||||
pod_array(unsigned _size)
|
||||
: m_array(pod_allocator<T>::allocate(_size))
|
||||
, m_size(_size)
|
||||
{}
|
||||
|
||||
pod_array(const self_type& v)
|
||||
: m_array(pod_allocator<T>::allocate(v.m_size))
|
||||
, m_size(v.m_size)
|
||||
pod_array(const self_type& v) :
|
||||
m_array(pod_allocator<T>::allocate(v.m_size)),
|
||||
m_size(v.m_size)
|
||||
{
|
||||
memcpy(m_array, v.m_array, sizeof(T) * m_size);
|
||||
}
|
||||
|
||||
pod_array(self_type&& rhs)
|
||||
: m_array(rhs.m_array)
|
||||
, m_size(rhs.m_size)
|
||||
pod_array(self_type && rhs) :
|
||||
m_array(rhs.m_array),
|
||||
m_size(rhs.m_size)
|
||||
{
|
||||
rhs.m_array = nullptr;
|
||||
rhs.m_size = 0;
|
||||
|
@ -160,28 +156,24 @@ class pod_array
|
|||
|
||||
const T* data() const { return m_array; }
|
||||
T* data() { return m_array; }
|
||||
|
||||
private:
|
||||
T* m_array;
|
||||
unsigned m_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------pod_vector
|
||||
// A simple class template to store Plain Old Data, a vector
|
||||
// of a fixed size. The data is continous in memory
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
class pod_vector
|
||||
template<class T> class pod_vector
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
~pod_vector() { pod_allocator<T>::deallocate(m_array, m_capacity); }
|
||||
pod_vector()
|
||||
: m_size(0)
|
||||
, m_capacity(0)
|
||||
, m_array(0)
|
||||
{}
|
||||
pod_vector() : m_size(0), m_capacity(0), m_array(0) {}
|
||||
pod_vector(unsigned cap, unsigned extra_tail=0);
|
||||
|
||||
// Copying
|
||||
|
@ -201,7 +193,10 @@ class pod_vector
|
|||
// Resize keeping the content.
|
||||
void resize(unsigned new_size);
|
||||
|
||||
void zero() { memset(m_array, 0, sizeof(T) * m_size); }
|
||||
void zero()
|
||||
{
|
||||
memset(m_array, 0, sizeof(T) * m_size);
|
||||
}
|
||||
|
||||
void add(const T& v) { m_array[m_size++] = v; }
|
||||
void push_back(const T& v) { m_array[m_size++] = v; }
|
||||
|
@ -222,11 +217,7 @@ class pod_vector
|
|||
|
||||
void remove_all() { m_size = 0; }
|
||||
void clear() { m_size = 0; }
|
||||
void cut_at(unsigned num)
|
||||
{
|
||||
if (num < m_size)
|
||||
m_size = num;
|
||||
}
|
||||
void cut_at(unsigned num) { if(num < m_size) m_size = num; }
|
||||
|
||||
private:
|
||||
unsigned m_size;
|
||||
|
@ -255,6 +246,7 @@ void pod_vector<T>::allocate(unsigned _size, unsigned extra_tail)
|
|||
m_size = _size;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
void pod_vector<T>::resize(unsigned new_size)
|
||||
|
@ -276,29 +268,25 @@ void pod_vector<T>::resize(unsigned new_size)
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
pod_vector<T>::pod_vector(unsigned cap, unsigned extra_tail)
|
||||
: m_size(0)
|
||||
, m_capacity(cap + extra_tail)
|
||||
, m_array(pod_allocator<T>::allocate(m_capacity))
|
||||
{}
|
||||
template<class T> pod_vector<T>::pod_vector(unsigned cap, unsigned extra_tail) :
|
||||
m_size(0),
|
||||
m_capacity(cap + extra_tail),
|
||||
m_array(pod_allocator<T>::allocate(m_capacity)) {}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
pod_vector<T>::pod_vector(const pod_vector<T>& v)
|
||||
: m_size(v.m_size)
|
||||
, m_capacity(v.m_capacity)
|
||||
, m_array(v.m_capacity ? pod_allocator<T>::allocate(v.m_capacity) : 0)
|
||||
template<class T> pod_vector<T>::pod_vector(const pod_vector<T>& v) :
|
||||
m_size(v.m_size),
|
||||
m_capacity(v.m_capacity),
|
||||
m_array(v.m_capacity ? pod_allocator<T>::allocate(v.m_capacity) : 0)
|
||||
{
|
||||
memcpy(m_array, v.m_array, sizeof(T) * v.m_size);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
pod_vector<T>::pod_vector(pod_vector<T>&& rhs)
|
||||
: m_size(rhs.m_size)
|
||||
, m_capacity(rhs.m_capacity)
|
||||
, m_array(rhs.m_array)
|
||||
template<class T> pod_vector<T>::pod_vector(pod_vector<T> && rhs) :
|
||||
m_size(rhs.m_size),
|
||||
m_capacity(rhs.m_capacity),
|
||||
m_array(rhs.m_array)
|
||||
{
|
||||
rhs.m_size = 0;
|
||||
rhs.m_capacity = 0;
|
||||
|
@ -306,21 +294,18 @@ pod_vector<T>::pod_vector(pod_vector<T>&& rhs)
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
const pod_vector<T>& pod_vector<T>::operator=(const pod_vector<T>& v)
|
||||
template<class T> const pod_vector<T>&
|
||||
pod_vector<T>::operator = (const pod_vector<T>&v)
|
||||
{
|
||||
allocate(v.m_size);
|
||||
if (v.m_size)
|
||||
memcpy(m_array, v.m_array, sizeof(T) * v.m_size);
|
||||
if(v.m_size) memcpy(m_array, v.m_array, sizeof(T) * v.m_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
void pod_vector<T>::serialize(int8u* ptr) const
|
||||
template<class T> void pod_vector<T>::serialize(int8u* ptr) const
|
||||
{
|
||||
if (m_size)
|
||||
memcpy(ptr, m_array, m_size * sizeof(T));
|
||||
if(m_size) memcpy(ptr, m_array, m_size * sizeof(T));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -329,8 +314,7 @@ void pod_vector<T>::deserialize(const int8u* _data, unsigned _byte_size)
|
|||
{
|
||||
_byte_size /= sizeof(T);
|
||||
allocate(_byte_size);
|
||||
if (_byte_size)
|
||||
memcpy(m_array, _data, _byte_size * sizeof(T));
|
||||
if(_byte_size) memcpy(m_array, _data, _byte_size * sizeof(T));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -360,11 +344,15 @@ void pod_vector<T>::insert_at(unsigned pos, const T& val)
|
|||
// of increment to reallocate the pointer buffer. See the second constructor.
|
||||
// By default, the incremeent value equals (1 << S), i.e., the block size.
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S = 6>
|
||||
class pod_bvector
|
||||
template<class T, unsigned S=6> class pod_bvector
|
||||
{
|
||||
public:
|
||||
enum block_scale_e { block_shift = S, block_size = 1 << block_shift, block_mask = block_size - 1 };
|
||||
enum block_scale_e
|
||||
{
|
||||
block_shift = S,
|
||||
block_size = 1 << block_shift,
|
||||
block_mask = block_size - 1
|
||||
};
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
|
@ -395,8 +383,7 @@ class pod_bvector
|
|||
}
|
||||
}
|
||||
|
||||
template<class DataAccessor>
|
||||
void add_data(DataAccessor& data)
|
||||
template<class DataAccessor> void add_data(DataAccessor& data)
|
||||
{
|
||||
while(data.size())
|
||||
{
|
||||
|
@ -407,42 +394,81 @@ class pod_bvector
|
|||
|
||||
void cut_at(unsigned _size)
|
||||
{
|
||||
if (_size < m_size)
|
||||
m_size = _size;
|
||||
if(_size < m_size) m_size = _size;
|
||||
}
|
||||
|
||||
unsigned size() const { return m_size; }
|
||||
|
||||
const T& operator[](unsigned i) const { return m_blocks[i >> block_shift][i & block_mask]; }
|
||||
const T& operator [] (unsigned i) const
|
||||
{
|
||||
return m_blocks[i >> block_shift][i & block_mask];
|
||||
}
|
||||
|
||||
T& operator[](unsigned i) { return m_blocks[i >> block_shift][i & block_mask]; }
|
||||
T& operator [] (unsigned i)
|
||||
{
|
||||
return m_blocks[i >> block_shift][i & block_mask];
|
||||
}
|
||||
|
||||
const T& at(unsigned i) const { return m_blocks[i >> block_shift][i & block_mask]; }
|
||||
const T& at(unsigned i) const
|
||||
{
|
||||
return m_blocks[i >> block_shift][i & block_mask];
|
||||
}
|
||||
|
||||
T& at(unsigned i) { return m_blocks[i >> block_shift][i & block_mask]; }
|
||||
T& at(unsigned i)
|
||||
{
|
||||
return m_blocks[i >> block_shift][i & block_mask];
|
||||
}
|
||||
|
||||
T value_at(unsigned i) const { return m_blocks[i >> block_shift][i & block_mask]; }
|
||||
T value_at(unsigned i) const
|
||||
{
|
||||
return m_blocks[i >> block_shift][i & block_mask];
|
||||
}
|
||||
|
||||
const T& curr(unsigned idx) const { return (*this)[idx]; }
|
||||
const T& curr(unsigned idx) const
|
||||
{
|
||||
return (*this)[idx];
|
||||
}
|
||||
|
||||
T& curr(unsigned idx) { return (*this)[idx]; }
|
||||
T& curr(unsigned idx)
|
||||
{
|
||||
return (*this)[idx];
|
||||
}
|
||||
|
||||
const T& prev(unsigned idx) const { return (*this)[(idx + m_size - 1) % m_size]; }
|
||||
const T& prev(unsigned idx) const
|
||||
{
|
||||
return (*this)[(idx + m_size - 1) % m_size];
|
||||
}
|
||||
|
||||
T& prev(unsigned idx) { return (*this)[(idx + m_size - 1) % m_size]; }
|
||||
T& prev(unsigned idx)
|
||||
{
|
||||
return (*this)[(idx + m_size - 1) % m_size];
|
||||
}
|
||||
|
||||
const T& next(unsigned idx) const { return (*this)[(idx + 1) % m_size]; }
|
||||
const T& next(unsigned idx) const
|
||||
{
|
||||
return (*this)[(idx + 1) % m_size];
|
||||
}
|
||||
|
||||
T& next(unsigned idx) { return (*this)[(idx + 1) % m_size]; }
|
||||
T& next(unsigned idx)
|
||||
{
|
||||
return (*this)[(idx + 1) % m_size];
|
||||
}
|
||||
|
||||
const T& last() const { return (*this)[m_size - 1]; }
|
||||
const T& last() const
|
||||
{
|
||||
return (*this)[m_size - 1];
|
||||
}
|
||||
|
||||
T& last() { return (*this)[m_size - 1]; }
|
||||
T& last()
|
||||
{
|
||||
return (*this)[m_size - 1];
|
||||
}
|
||||
|
||||
unsigned byte_size() const;
|
||||
void serialize(int8u* ptr) const;
|
||||
void deserialize(const int8u* data, unsigned byte_size);
|
||||
void deserialize(unsigned start, const T& empty_val, const int8u* data, unsigned byte_size);
|
||||
void deserialize(unsigned start, const T& empty_val,
|
||||
const int8u* data, unsigned byte_size);
|
||||
|
||||
template<class ByteAccessor>
|
||||
void deserialize(ByteAccessor data)
|
||||
|
@ -504,9 +530,9 @@ class pod_bvector
|
|||
unsigned m_block_ptr_inc;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
pod_bvector<T, S>::~pod_bvector()
|
||||
template<class T, unsigned S> pod_bvector<T, S>::~pod_bvector()
|
||||
{
|
||||
if(m_num_blocks)
|
||||
{
|
||||
|
@ -521,6 +547,7 @@ pod_bvector<T, S>::~pod_bvector()
|
|||
pod_allocator<T*>::deallocate(m_blocks, m_max_blocks);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
void pod_bvector<T, S>::free_tail(unsigned _size)
|
||||
|
@ -542,34 +569,40 @@ void pod_bvector<T, S>::free_tail(unsigned _size)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
pod_bvector<T, S>::pod_bvector()
|
||||
: m_size(0)
|
||||
, m_num_blocks(0)
|
||||
, m_max_blocks(0)
|
||||
, m_blocks(0)
|
||||
, m_block_ptr_inc(block_size)
|
||||
{}
|
||||
template<class T, unsigned S> pod_bvector<T, S>::pod_bvector() :
|
||||
m_size(0),
|
||||
m_num_blocks(0),
|
||||
m_max_blocks(0),
|
||||
m_blocks(0),
|
||||
m_block_ptr_inc(block_size)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
pod_bvector<T, S>::pod_bvector(unsigned block_ptr_inc)
|
||||
: m_size(0)
|
||||
, m_num_blocks(0)
|
||||
, m_max_blocks(0)
|
||||
, m_blocks(0)
|
||||
, m_block_ptr_inc(block_ptr_inc)
|
||||
{}
|
||||
pod_bvector<T, S>::pod_bvector(unsigned block_ptr_inc) :
|
||||
m_size(0),
|
||||
m_num_blocks(0),
|
||||
m_max_blocks(0),
|
||||
m_blocks(0),
|
||||
m_block_ptr_inc(block_ptr_inc)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
pod_bvector<T, S>::pod_bvector(const pod_bvector<T, S>& v)
|
||||
: m_size(v.m_size)
|
||||
, m_num_blocks(v.m_num_blocks)
|
||||
, m_max_blocks(v.m_max_blocks)
|
||||
, m_blocks(v.m_max_blocks ? pod_allocator<T*>::allocate(v.m_max_blocks) : 0)
|
||||
, m_block_ptr_inc(v.m_block_ptr_inc)
|
||||
pod_bvector<T, S>::pod_bvector(const pod_bvector<T, S>& v) :
|
||||
m_size(v.m_size),
|
||||
m_num_blocks(v.m_num_blocks),
|
||||
m_max_blocks(v.m_max_blocks),
|
||||
m_blocks(v.m_max_blocks ?
|
||||
pod_allocator<T*>::allocate(v.m_max_blocks) :
|
||||
0),
|
||||
m_block_ptr_inc(v.m_block_ptr_inc)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < v.m_num_blocks; ++i)
|
||||
|
@ -579,9 +612,11 @@ pod_bvector<T, S>::pod_bvector(const pod_bvector<T, S>& v)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
const pod_bvector<T, S>& pod_bvector<T, S>::operator=(const pod_bvector<T, S>& v)
|
||||
const pod_bvector<T, S>&
|
||||
pod_bvector<T, S>::operator = (const pod_bvector<T, S>& v)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = m_num_blocks; i < v.m_num_blocks; ++i)
|
||||
|
@ -596,6 +631,7 @@ const pod_bvector<T, S>& pod_bvector<T, S>::operator=(const pod_bvector<T, S>& v
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
void pod_bvector<T, S>::allocate_block(unsigned nb)
|
||||
|
@ -606,7 +642,9 @@ void pod_bvector<T, S>::allocate_block(unsigned nb)
|
|||
|
||||
if(m_blocks)
|
||||
{
|
||||
memcpy(new_blocks, m_blocks, m_num_blocks * sizeof(T*));
|
||||
memcpy(new_blocks,
|
||||
m_blocks,
|
||||
m_num_blocks * sizeof(T*));
|
||||
|
||||
pod_allocator<T*>::deallocate(m_blocks, m_max_blocks);
|
||||
}
|
||||
|
@ -617,6 +655,8 @@ void pod_bvector<T, S>::allocate_block(unsigned nb)
|
|||
m_num_blocks++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
inline T* pod_bvector<T, S>::data_ptr()
|
||||
|
@ -629,6 +669,8 @@ inline T* pod_bvector<T, S>::data_ptr()
|
|||
return m_blocks[nb] + (m_size & block_mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
inline void pod_bvector<T, S>::add(const T& val)
|
||||
|
@ -637,14 +679,15 @@ inline void pod_bvector<T, S>::add(const T& val)
|
|||
++m_size;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
inline void pod_bvector<T, S>::remove_last()
|
||||
{
|
||||
if (m_size)
|
||||
--m_size;
|
||||
if(m_size) --m_size;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
void pod_bvector<T, S>::modify_last(const T& val)
|
||||
|
@ -653,6 +696,7 @@ void pod_bvector<T, S>::modify_last(const T& val)
|
|||
add(val);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
int pod_bvector<T, S>::allocate_continuous_block(unsigned num_elements)
|
||||
|
@ -682,6 +726,7 @@ int pod_bvector<T, S>::allocate_continuous_block(unsigned num_elements)
|
|||
return -1; // Impossible to allocate
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
unsigned pod_bvector<T, S>::byte_size() const
|
||||
|
@ -689,6 +734,7 @@ unsigned pod_bvector<T, S>::byte_size() const
|
|||
return m_size * sizeof(T);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
void pod_bvector<T, S>::serialize(int8u* ptr) const
|
||||
|
@ -716,10 +762,12 @@ void pod_bvector<T, S>::deserialize(const int8u* _data, unsigned _byte_size)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Replace or add a number of elements starting from "start" position
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
void pod_bvector<T, S>::deserialize(unsigned start, const T& empty_val, const int8u* _data, unsigned _byte_size)
|
||||
void pod_bvector<T, S>::deserialize(unsigned start, const T& empty_val,
|
||||
const int8u* _data, unsigned _byte_size)
|
||||
{
|
||||
while(m_size < start)
|
||||
{
|
||||
|
@ -743,6 +791,7 @@ void pod_bvector<T, S>::deserialize(unsigned start, const T& empty_val, const in
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------block_allocator
|
||||
// Allocator for arbitrary POD data. Most usable in different cache
|
||||
// systems for efficient memory allocations.
|
||||
|
@ -779,28 +828,33 @@ class block_allocator
|
|||
m_rest = 0;
|
||||
}
|
||||
|
||||
~block_allocator() { remove_all(); }
|
||||
~block_allocator()
|
||||
{
|
||||
remove_all();
|
||||
}
|
||||
|
||||
block_allocator(unsigned block_size, unsigned block_ptr_inc=256-8) :
|
||||
m_block_size(block_size),
|
||||
m_block_ptr_inc(block_ptr_inc),
|
||||
m_num_blocks(0),
|
||||
m_max_blocks(0),
|
||||
m_blocks(0),
|
||||
m_buf_ptr(0),
|
||||
m_rest(0)
|
||||
{
|
||||
}
|
||||
|
||||
block_allocator(unsigned block_size, unsigned block_ptr_inc = 256 - 8)
|
||||
: m_block_size(block_size)
|
||||
, m_block_ptr_inc(block_ptr_inc)
|
||||
, m_num_blocks(0)
|
||||
, m_max_blocks(0)
|
||||
, m_blocks(0)
|
||||
, m_buf_ptr(0)
|
||||
, m_rest(0)
|
||||
{}
|
||||
|
||||
int8u* allocate(unsigned size, unsigned alignment=1)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
if(size == 0) return 0;
|
||||
if(size <= m_rest)
|
||||
{
|
||||
int8u* ptr = m_buf_ptr;
|
||||
if(alignment > 1)
|
||||
{
|
||||
unsigned align = (alignment - unsigned((size_t)ptr) % alignment) % alignment;
|
||||
unsigned align =
|
||||
(alignment - unsigned((size_t)ptr) % alignment) % alignment;
|
||||
|
||||
size += align;
|
||||
ptr += align;
|
||||
|
@ -821,18 +875,21 @@ class block_allocator
|
|||
return allocate(size, alignment);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void allocate_block(unsigned size)
|
||||
{
|
||||
if (size < m_block_size)
|
||||
size = m_block_size;
|
||||
if(size < m_block_size) size = m_block_size;
|
||||
if(m_num_blocks >= m_max_blocks)
|
||||
{
|
||||
block_type* new_blocks = pod_allocator<block_type>::allocate(m_max_blocks + m_block_ptr_inc);
|
||||
block_type* new_blocks =
|
||||
pod_allocator<block_type>::allocate(m_max_blocks + m_block_ptr_inc);
|
||||
|
||||
if(m_blocks)
|
||||
{
|
||||
memcpy(new_blocks, m_blocks, m_num_blocks * sizeof(block_type));
|
||||
memcpy(new_blocks,
|
||||
m_blocks,
|
||||
m_num_blocks * sizeof(block_type));
|
||||
pod_allocator<block_type>::deallocate(m_blocks, m_max_blocks);
|
||||
}
|
||||
m_blocks = new_blocks;
|
||||
|
@ -840,7 +897,9 @@ class block_allocator
|
|||
}
|
||||
|
||||
m_blocks[m_num_blocks].size = size;
|
||||
m_blocks[m_num_blocks].data = m_buf_ptr = pod_allocator<int8u>::allocate(size);
|
||||
m_blocks[m_num_blocks].data =
|
||||
m_buf_ptr =
|
||||
pod_allocator<int8u>::allocate(size);
|
||||
|
||||
m_num_blocks++;
|
||||
m_rest = size;
|
||||
|
@ -855,24 +914,34 @@ class block_allocator
|
|||
unsigned m_rest;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
enum quick_sort_threshold_e { quick_sort_threshold = 9 };
|
||||
enum quick_sort_threshold_e
|
||||
{
|
||||
quick_sort_threshold = 9
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------swap_elements
|
||||
template<class T>
|
||||
inline void swap_elements(T& a, T& b)
|
||||
template<class T> inline void swap_elements(T& a, T& b)
|
||||
{
|
||||
T temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------quick_sort
|
||||
template<class Array, class Less>
|
||||
void quick_sort(Array& arr, Less less)
|
||||
{
|
||||
if (arr.size() < 2)
|
||||
return;
|
||||
if(arr.size() < 2) return;
|
||||
|
||||
typename Array::value_type* e1;
|
||||
typename Array::value_type* e2;
|
||||
|
@ -902,27 +971,20 @@ void quick_sort(Array& arr, Less less)
|
|||
// now ensure that *i <= *base <= *j
|
||||
e1 = &(arr[j]);
|
||||
e2 = &(arr[i]);
|
||||
if (less(*e1, *e2))
|
||||
swap_elements(*e1, *e2);
|
||||
if(less(*e1, *e2)) swap_elements(*e1, *e2);
|
||||
|
||||
e1 = &(arr[base]);
|
||||
e2 = &(arr[i]);
|
||||
if (less(*e1, *e2))
|
||||
swap_elements(*e1, *e2);
|
||||
if(less(*e1, *e2)) swap_elements(*e1, *e2);
|
||||
|
||||
e1 = &(arr[j]);
|
||||
e2 = &(arr[base]);
|
||||
if (less(*e1, *e2))
|
||||
swap_elements(*e1, *e2);
|
||||
if(less(*e1, *e2)) swap_elements(*e1, *e2);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
do
|
||||
i++;
|
||||
while (less(arr[i], arr[base]));
|
||||
do
|
||||
j--;
|
||||
while (less(arr[base], arr[j]));
|
||||
do i++; while( less(arr[i], arr[base]) );
|
||||
do j--; while( less(arr[base], arr[j]) );
|
||||
|
||||
if( i > j )
|
||||
{
|
||||
|
@ -980,6 +1042,9 @@ void quick_sort(Array& arr, Less less)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------remove_duplicates
|
||||
// Remove duplicates from a sorted array. It doesn't cut the
|
||||
// tail of the array, it just returns the number of remaining elements.
|
||||
|
@ -987,8 +1052,7 @@ void quick_sort(Array& arr, Less less)
|
|||
template<class Array, class Equal>
|
||||
unsigned remove_duplicates(Array& arr, Equal equal)
|
||||
{
|
||||
if (arr.size() < 2)
|
||||
return arr.size();
|
||||
if(arr.size() < 2) return arr.size();
|
||||
|
||||
unsigned i, j;
|
||||
for(i = 1, j = 1; i < arr.size(); i++)
|
||||
|
@ -1003,8 +1067,7 @@ unsigned remove_duplicates(Array& arr, Equal equal)
|
|||
}
|
||||
|
||||
//--------------------------------------------------------invert_container
|
||||
template<class Array>
|
||||
void invert_container(Array& arr)
|
||||
template<class Array> void invert_container(Array& arr)
|
||||
{
|
||||
int i = 0;
|
||||
int j = arr.size() - 1;
|
||||
|
@ -1018,24 +1081,19 @@ void invert_container(Array& arr)
|
|||
template<class Array, class Value, class Less>
|
||||
unsigned binary_search_pos(const Array& arr, const Value& val, Less less)
|
||||
{
|
||||
if (arr.size() == 0)
|
||||
return 0;
|
||||
if(arr.size() == 0) return 0;
|
||||
|
||||
unsigned beg = 0;
|
||||
unsigned end = arr.size() - 1;
|
||||
|
||||
if (less(val, arr[0]))
|
||||
return 0;
|
||||
if (less(arr[end], val))
|
||||
return end + 1;
|
||||
if(less(val, arr[0])) return 0;
|
||||
if(less(arr[end], val)) return end + 1;
|
||||
|
||||
while(end - beg > 1)
|
||||
{
|
||||
unsigned mid = (end + beg) >> 1;
|
||||
if (less(val, arr[mid]))
|
||||
end = mid;
|
||||
else
|
||||
beg = mid;
|
||||
if(less(val, arr[mid])) end = mid;
|
||||
else beg = mid;
|
||||
}
|
||||
|
||||
//if(beg <= 0 && less(val, arr[0])) return 0;
|
||||
|
@ -1045,16 +1103,13 @@ unsigned binary_search_pos(const Array& arr, const Value& val, Less less)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------range_adaptor
|
||||
template<class Array>
|
||||
class range_adaptor
|
||||
template<class Array> class range_adaptor
|
||||
{
|
||||
public:
|
||||
typedef typename Array::value_type value_type;
|
||||
|
||||
range_adaptor(Array& array, unsigned start, unsigned _size)
|
||||
: m_array(array)
|
||||
, m_start(start)
|
||||
, m_size(_size)
|
||||
range_adaptor(Array& array, unsigned start, unsigned _size) :
|
||||
m_array(array), m_start(start), m_size(_size)
|
||||
{}
|
||||
|
||||
unsigned size() const { return m_size; }
|
||||
|
@ -1071,28 +1126,16 @@ class range_adaptor
|
|||
};
|
||||
|
||||
//---------------------------------------------------------------int_less
|
||||
inline bool int_less(int a, int b)
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
inline bool int_less(int a, int b) { return a < b; }
|
||||
|
||||
//------------------------------------------------------------int_greater
|
||||
inline bool int_greater(int a, int b)
|
||||
{
|
||||
return a > b;
|
||||
}
|
||||
inline bool int_greater(int a, int b) { return a > b; }
|
||||
|
||||
//----------------------------------------------------------unsigned_less
|
||||
inline bool unsigned_less(unsigned a, unsigned b)
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
inline bool unsigned_less(unsigned a, unsigned b) { return a < b; }
|
||||
|
||||
//-------------------------------------------------------unsigned_greater
|
||||
inline bool unsigned_greater(unsigned a, unsigned b)
|
||||
{
|
||||
return a > b;
|
||||
inline bool unsigned_greater(unsigned a, unsigned b) { return a > b; }
|
||||
}
|
||||
} // namespace agg
|
||||
|
||||
#endif
|
||||
|
|
5
deps/agg/include/agg_arrowhead.h
vendored
5
deps/agg/include/agg_arrowhead.h
vendored
|
@ -21,7 +21,8 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===============================================================arrowhead
|
||||
//
|
||||
|
@ -76,6 +77,6 @@ class arrowhead
|
|||
unsigned m_curr_coord;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
164
deps/agg/include/agg_basics.h
vendored
164
deps/agg/include/agg_basics.h
vendored
|
@ -23,7 +23,8 @@
|
|||
#ifdef AGG_CUSTOM_ALLOCATOR
|
||||
#include "agg_allocator.h"
|
||||
#else
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
// The policy of all AGG containers and memory allocation strategy
|
||||
// in general is that no allocated data requires explicit construction.
|
||||
// It means that the allocator can be really simple; you can even
|
||||
|
@ -32,8 +33,7 @@ namespace agg {
|
|||
// The second argument of deallocate() is the size of the allocated
|
||||
// block. You can use this information if you wish.
|
||||
//------------------------------------------------------------pod_allocator
|
||||
template<class T>
|
||||
struct pod_allocator
|
||||
template<class T> struct pod_allocator
|
||||
{
|
||||
//static T* allocate(unsigned num) { return static_cast<T*>(::operator new(sizeof(T)*num));}
|
||||
//static void deallocate(T* ptr, unsigned) { ::operator delete(ptr) ;}
|
||||
|
@ -49,15 +49,15 @@ struct pod_allocator
|
|||
// replace these new/delete to malloc/free make sure that the in-place
|
||||
// new is called and take care of calling the destructor too.
|
||||
//------------------------------------------------------------obj_allocator
|
||||
template<class T>
|
||||
struct obj_allocator
|
||||
template<class T> struct obj_allocator
|
||||
{
|
||||
static T* allocate() { return new T; }
|
||||
static void deallocate(T* ptr) { delete ptr; }
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//-------------------------------------------------------- Default basic types
|
||||
//
|
||||
// If the compiler has different capacity of the basic types you can redefine
|
||||
|
@ -107,7 +107,8 @@ struct obj_allocator
|
|||
#define AGG_INLINE inline
|
||||
#endif
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//-------------------------------------------------------------------------
|
||||
typedef AGG_INT8 int8; //----int8
|
||||
typedef AGG_INT8U int8u; //----int8u
|
||||
|
@ -136,22 +137,18 @@ AGG_INLINE unsigned uceil(double v)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------saturation
|
||||
template<int Limit>
|
||||
struct saturation
|
||||
template<int Limit> struct saturation
|
||||
{
|
||||
AGG_INLINE static int iround(double v)
|
||||
{
|
||||
if (v < double(-Limit))
|
||||
return -Limit;
|
||||
if (v > double(Limit))
|
||||
return Limit;
|
||||
if(v < double(-Limit)) return -Limit;
|
||||
if(v > double( Limit)) return Limit;
|
||||
return agg::iround(v);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------mul_one
|
||||
template<unsigned Shift>
|
||||
struct mul_one
|
||||
template<unsigned Shift> struct mul_one
|
||||
{
|
||||
AGG_INLINE static unsigned mul(unsigned a, unsigned b)
|
||||
{
|
||||
|
@ -162,7 +159,8 @@ struct mul_one
|
|||
|
||||
//-------------------------------------------------------------------------
|
||||
typedef unsigned char cover_type; //----cover_type
|
||||
enum cover_scale_e {
|
||||
enum cover_scale_e
|
||||
{
|
||||
cover_shift = 8, //----cover_shift
|
||||
cover_size = 1 << cover_shift, //----cover_size
|
||||
cover_mask = cover_size - 1, //----cover_mask
|
||||
|
@ -176,14 +174,19 @@ enum cover_scale_e {
|
|||
// The possible coordinate capacity in bits can be calculated by formula:
|
||||
// sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and
|
||||
// 8-bits fractional part the capacity is 24 bits.
|
||||
enum poly_subpixel_scale_e {
|
||||
enum poly_subpixel_scale_e
|
||||
{
|
||||
poly_subpixel_shift = 8, //----poly_subpixel_shift
|
||||
poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale
|
||||
poly_subpixel_mask = poly_subpixel_scale-1 //----poly_subpixel_mask
|
||||
};
|
||||
|
||||
//----------------------------------------------------------filling_rule_e
|
||||
enum filling_rule_e { fill_non_zero, fill_even_odd };
|
||||
enum filling_rule_e
|
||||
{
|
||||
fill_non_zero,
|
||||
fill_even_odd
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------pi
|
||||
const double pi = 3.14159265358979323846;
|
||||
|
@ -201,63 +204,47 @@ inline double rad2deg(double rad)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------rect_base
|
||||
template<class T>
|
||||
struct rect_base
|
||||
template<class T> struct rect_base
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef rect_base<T> self_type;
|
||||
T x1, y1, x2, y2;
|
||||
|
||||
rect_base() {}
|
||||
rect_base(T x1_, T y1_, T x2_, T y2_)
|
||||
: x1(x1_)
|
||||
, y1(y1_)
|
||||
, x2(x2_)
|
||||
, y2(y2_)
|
||||
{}
|
||||
rect_base(T x1_, T y1_, T x2_, T y2_) :
|
||||
x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
|
||||
|
||||
void init(T x1_, T y1_, T x2_, T y2_)
|
||||
{
|
||||
x1 = x1_;
|
||||
y1 = y1_;
|
||||
x2 = x2_;
|
||||
y2 = y2_;
|
||||
x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_;
|
||||
}
|
||||
|
||||
const self_type& normalize()
|
||||
{
|
||||
T t;
|
||||
if (x1 > x2)
|
||||
{
|
||||
t = x1;
|
||||
x1 = x2;
|
||||
x2 = t;
|
||||
}
|
||||
if (y1 > y2)
|
||||
{
|
||||
t = y1;
|
||||
y1 = y2;
|
||||
y2 = t;
|
||||
}
|
||||
if(x1 > x2) { t = x1; x1 = x2; x2 = t; }
|
||||
if(y1 > y2) { t = y1; y1 = y2; y2 = t; }
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool clip(const self_type& r)
|
||||
{
|
||||
if (x2 > r.x2)
|
||||
x2 = r.x2;
|
||||
if (y2 > r.y2)
|
||||
y2 = r.y2;
|
||||
if (x1 < r.x1)
|
||||
x1 = r.x1;
|
||||
if (y1 < r.y1)
|
||||
y1 = r.y1;
|
||||
if(x2 > r.x2) x2 = r.x2;
|
||||
if(y2 > r.y2) y2 = r.y2;
|
||||
if(x1 < r.x1) x1 = r.x1;
|
||||
if(y1 < r.y1) y1 = r.y1;
|
||||
return x1 <= x2 && y1 <= y2;
|
||||
}
|
||||
|
||||
bool is_valid() const { return x1 <= x2 && y1 <= y2; }
|
||||
bool is_valid() const
|
||||
{
|
||||
return x1 <= x2 && y1 <= y2;
|
||||
}
|
||||
|
||||
bool hit_test(T x, T y) const { return (x >= x1 && x <= x2 && y >= y1 && y <= y2); }
|
||||
bool hit_test(T x, T y) const
|
||||
{
|
||||
return (x >= x1 && x <= x2 && y >= y1 && y <= y2);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------intersect_rectangles
|
||||
|
@ -271,30 +258,23 @@ inline Rect intersect_rectangles(const Rect& r1, const Rect& r2)
|
|||
// Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
|
||||
// case of "Maximize Speed" optimization option.
|
||||
//-----------------
|
||||
if (r.x2 > r2.x2)
|
||||
r.x2 = r2.x2;
|
||||
if (r.y2 > r2.y2)
|
||||
r.y2 = r2.y2;
|
||||
if (r.x1 < r2.x1)
|
||||
r.x1 = r2.x1;
|
||||
if (r.y1 < r2.y1)
|
||||
r.y1 = r2.y1;
|
||||
if(r.x2 > r2.x2) r.x2 = r2.x2;
|
||||
if(r.y2 > r2.y2) r.y2 = r2.y2;
|
||||
if(r.x1 < r2.x1) r.x1 = r2.x1;
|
||||
if(r.y1 < r2.y1) r.y1 = r2.y1;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------unite_rectangles
|
||||
template<class Rect>
|
||||
inline Rect unite_rectangles(const Rect& r1, const Rect& r2)
|
||||
{
|
||||
Rect r = r1;
|
||||
if (r.x2 < r2.x2)
|
||||
r.x2 = r2.x2;
|
||||
if (r.y2 < r2.y2)
|
||||
r.y2 = r2.y2;
|
||||
if (r.x1 > r2.x1)
|
||||
r.x1 = r2.x1;
|
||||
if (r.y1 > r2.y1)
|
||||
r.y1 = r2.y1;
|
||||
if(r.x2 < r2.x2) r.x2 = r2.x2;
|
||||
if(r.y2 < r2.y2) r.y2 = r2.y2;
|
||||
if(r.x1 > r2.x1) r.x1 = r2.x1;
|
||||
if(r.y1 > r2.y1) r.y1 = r2.y1;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -303,7 +283,8 @@ typedef rect_base<float> rect_f; //----rect_f
|
|||
typedef rect_base<double> rect_d; //----rect_d
|
||||
|
||||
//---------------------------------------------------------path_commands_e
|
||||
enum path_commands_e {
|
||||
enum path_commands_e
|
||||
{
|
||||
path_cmd_stop = 0, //----path_cmd_stop
|
||||
path_cmd_move_to = 1, //----path_cmd_move_to
|
||||
path_cmd_line_to = 2, //----path_cmd_line_to
|
||||
|
@ -317,7 +298,8 @@ enum path_commands_e {
|
|||
};
|
||||
|
||||
//------------------------------------------------------------path_flags_e
|
||||
enum path_flags_e {
|
||||
enum path_flags_e
|
||||
{
|
||||
path_flags_none = 0, //----path_flags_none
|
||||
path_flags_ccw = 0x10, //----path_flags_ccw
|
||||
path_flags_cw = 0x20, //----path_flags_cw
|
||||
|
@ -441,74 +423,56 @@ inline unsigned set_orientation(unsigned c, unsigned o)
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------point_base
|
||||
template<class T>
|
||||
struct point_base
|
||||
template<class T> struct point_base
|
||||
{
|
||||
typedef T value_type;
|
||||
T x,y;
|
||||
point_base() {}
|
||||
point_base(T x_, T y_)
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
{}
|
||||
point_base(T x_, T y_) : x(x_), y(y_) {}
|
||||
};
|
||||
typedef point_base<int> point_i; //-----point_i
|
||||
typedef point_base<float> point_f; //-----point_f
|
||||
typedef point_base<double> point_d; //-----point_d
|
||||
|
||||
//-------------------------------------------------------------vertex_base
|
||||
template<class T>
|
||||
struct vertex_base
|
||||
template<class T> struct vertex_base
|
||||
{
|
||||
typedef T value_type;
|
||||
T x,y;
|
||||
unsigned cmd;
|
||||
vertex_base() {}
|
||||
vertex_base(T x_, T y_, unsigned cmd_)
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
, cmd(cmd_)
|
||||
{}
|
||||
vertex_base(T x_, T y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {}
|
||||
};
|
||||
typedef vertex_base<int> vertex_i; //-----vertex_i
|
||||
typedef vertex_base<float> vertex_f; //-----vertex_f
|
||||
typedef vertex_base<double> vertex_d; //-----vertex_d
|
||||
|
||||
//----------------------------------------------------------------row_info
|
||||
template<class T>
|
||||
struct row_info
|
||||
template<class T> struct row_info
|
||||
{
|
||||
int x1, x2;
|
||||
T* ptr;
|
||||
row_info() {}
|
||||
row_info(int x1_, int x2_, T* ptr_)
|
||||
: x1(x1_)
|
||||
, x2(x2_)
|
||||
, ptr(ptr_)
|
||||
{}
|
||||
row_info(int x1_, int x2_, T* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------const_row_info
|
||||
template<class T>
|
||||
struct const_row_info
|
||||
template<class T> struct const_row_info
|
||||
{
|
||||
int x1, x2;
|
||||
const T* ptr;
|
||||
const_row_info() {}
|
||||
const_row_info(int x1_, int x2_, const T* ptr_)
|
||||
: x1(x1_)
|
||||
, x2(x2_)
|
||||
, ptr(ptr_)
|
||||
{}
|
||||
const_row_info(int x1_, int x2_, const T* ptr_) :
|
||||
x1(x1_), x2(x2_), ptr(ptr_) {}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------is_equal_eps
|
||||
template<class T>
|
||||
inline bool is_equal_eps(T v1, T v2, T epsilon)
|
||||
template<class T> inline bool is_equal_eps(T v1, T v2, T epsilon)
|
||||
{
|
||||
return std::fabs(v1 - v2) <= double(epsilon);
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
76
deps/agg/include/agg_bezier_arc.h
vendored
76
deps/agg/include/agg_bezier_arc.h
vendored
|
@ -23,10 +23,14 @@
|
|||
|
||||
#include "agg_conv_transform.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void arc_to_bezier(double cx, double cy, double rx, double ry, double start_angle, double sweep_angle, double* curve);
|
||||
void arc_to_bezier(double cx, double cy, double rx, double ry,
|
||||
double start_angle, double sweep_angle,
|
||||
double* curve);
|
||||
|
||||
|
||||
//==============================================================bezier_arc
|
||||
//
|
||||
|
@ -36,27 +40,31 @@ class bezier_arc
|
|||
{
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
bezier_arc()
|
||||
: m_vertex(26)
|
||||
, m_num_vertices(0)
|
||||
, m_cmd(path_cmd_line_to)
|
||||
{}
|
||||
bezier_arc(double x, double y, double rx, double ry, double start_angle, double sweep_angle)
|
||||
bezier_arc() : m_vertex(26), m_num_vertices(0), m_cmd(path_cmd_line_to) {}
|
||||
bezier_arc(double x, double y,
|
||||
double rx, double ry,
|
||||
double start_angle,
|
||||
double sweep_angle)
|
||||
{
|
||||
init(x, y, rx, ry, start_angle, sweep_angle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void init(double x, double y, double rx, double ry, double start_angle, double sweep_angle);
|
||||
void init(double x, double y,
|
||||
double rx, double ry,
|
||||
double start_angle,
|
||||
double sweep_angle);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rewind(unsigned) { m_vertex = 0; }
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_vertex = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
if (m_vertex >= m_num_vertices)
|
||||
return path_cmd_stop;
|
||||
if(m_vertex >= m_num_vertices) return path_cmd_stop;
|
||||
*x = m_vertices[m_vertex];
|
||||
*y = m_vertices[m_vertex + 1];
|
||||
m_vertex += 2;
|
||||
|
@ -77,6 +85,8 @@ class bezier_arc
|
|||
unsigned m_cmd;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==========================================================bezier_arc_svg
|
||||
// Compute an SVG-style bezier arc.
|
||||
//
|
||||
|
@ -92,45 +102,41 @@ class bezier_arc_svg
|
|||
{
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
bezier_arc_svg()
|
||||
: m_arc()
|
||||
, m_radii_ok(false)
|
||||
{}
|
||||
bezier_arc_svg() : m_arc(), m_radii_ok(false) {}
|
||||
|
||||
bezier_arc_svg(double x1,
|
||||
double y1,
|
||||
double rx,
|
||||
double ry,
|
||||
bezier_arc_svg(double x1, double y1,
|
||||
double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double x2,
|
||||
double y2)
|
||||
: m_arc()
|
||||
, m_radii_ok(false)
|
||||
double x2, double y2) :
|
||||
m_arc(), m_radii_ok(false)
|
||||
{
|
||||
init(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void init(double x1,
|
||||
double y1,
|
||||
double rx,
|
||||
double ry,
|
||||
void init(double x1, double y1,
|
||||
double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double x2,
|
||||
double y2);
|
||||
double x2, double y2);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
bool radii_ok() const { return m_radii_ok; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rewind(unsigned) { m_arc.rewind(0); }
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_arc.rewind(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned vertex(double* x, double* y) { return m_arc.vertex(x, y); }
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return m_arc.vertex(x, y);
|
||||
}
|
||||
|
||||
// Supplemantary functions. num_vertices() actually returns doubled
|
||||
// number of vertices. That is, for 1 vertex it returns 2.
|
||||
|
@ -144,6 +150,10 @@ class bezier_arc_svg
|
|||
bool m_radii_ok;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
16
deps/agg/include/agg_bitset_iterator.h
vendored
16
deps/agg/include/agg_bitset_iterator.h
vendored
|
@ -18,14 +18,15 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
class bitset_iterator
|
||||
{
|
||||
public:
|
||||
bitset_iterator(const int8u* bits, unsigned offset = 0)
|
||||
: m_bits(bits + (offset >> 3))
|
||||
, m_mask(0x80 >> (offset & 7))
|
||||
bitset_iterator(const int8u* bits, unsigned offset = 0) :
|
||||
m_bits(bits + (offset >> 3)),
|
||||
m_mask(0x80 >> (offset & 7))
|
||||
{}
|
||||
|
||||
void operator ++ ()
|
||||
|
@ -38,13 +39,16 @@ class bitset_iterator
|
|||
}
|
||||
}
|
||||
|
||||
unsigned bit() const { return (*m_bits) & m_mask; }
|
||||
unsigned bit() const
|
||||
{
|
||||
return (*m_bits) & m_mask;
|
||||
}
|
||||
|
||||
private:
|
||||
const int8u* m_bits;
|
||||
int8u m_mask;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
373
deps/agg/include/agg_blur.h
vendored
373
deps/agg/include/agg_blur.h
vendored
|
@ -30,10 +30,10 @@
|
|||
#include "agg_array.h"
|
||||
#include "agg_pixfmt_transposer.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
template<class T>
|
||||
struct stack_blur_tables
|
||||
template<class T> struct stack_blur_tables
|
||||
{
|
||||
static int16u const g_stack_blur8_mul[255];
|
||||
static int8u const g_stack_blur8_shr[255];
|
||||
|
@ -41,47 +41,61 @@ struct stack_blur_tables
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
int16u const stack_blur_tables<T>::g_stack_blur8_mul[255] = {
|
||||
512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271,
|
||||
496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271,
|
||||
259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482,
|
||||
468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271,
|
||||
265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347,
|
||||
341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482,
|
||||
475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354,
|
||||
350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271,
|
||||
268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428,
|
||||
424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347,
|
||||
344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287,
|
||||
285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259};
|
||||
int16u const stack_blur_tables<T>::g_stack_blur8_mul[255] =
|
||||
{
|
||||
512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,
|
||||
454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,
|
||||
482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,
|
||||
437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,
|
||||
497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,
|
||||
320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,
|
||||
446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,
|
||||
329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,
|
||||
505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,
|
||||
399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,
|
||||
324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,
|
||||
268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,
|
||||
451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,
|
||||
385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,
|
||||
332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,
|
||||
289,287,285,282,280,278,275,273,271,269,267,265,263,261,259
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
int8u const stack_blur_tables<T>::g_stack_blur8_shr[255] = {
|
||||
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18,
|
||||
18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||
21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24};
|
||||
int8u const stack_blur_tables<T>::g_stack_blur8_shr[255] =
|
||||
{
|
||||
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==============================================================stack_blur
|
||||
template<class ColorT, class CalculatorT>
|
||||
class stack_blur
|
||||
template<class ColorT, class CalculatorT> class stack_blur
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
typedef CalculatorT calculator_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Img>
|
||||
void blur_x(Img& img, unsigned radius)
|
||||
template<class Img> void blur_x(Img& img, unsigned radius)
|
||||
{
|
||||
if (radius < 1)
|
||||
return;
|
||||
if(radius < 1) return;
|
||||
|
||||
unsigned x, y, xp, i;
|
||||
unsigned stack_ptr;
|
||||
|
@ -136,23 +150,19 @@ class stack_blur
|
|||
stack_ptr = radius;
|
||||
for(x = 0; x < w; x++)
|
||||
{
|
||||
if (mul_sum)
|
||||
sum.calc_pix(m_buf[x], mul_sum, shr_sum);
|
||||
else
|
||||
sum.calc_pix(m_buf[x], div_sum);
|
||||
if(mul_sum) sum.calc_pix(m_buf[x], mul_sum, shr_sum);
|
||||
else sum.calc_pix(m_buf[x], div_sum);
|
||||
|
||||
sum.sub(sum_out);
|
||||
|
||||
stack_start = stack_ptr + div - radius;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
stack_pix = &m_stack[stack_start];
|
||||
|
||||
sum_out.sub(*stack_pix);
|
||||
|
||||
xp = x + radius + 1;
|
||||
if (xp > wm)
|
||||
xp = wm;
|
||||
if(xp > wm) xp = wm;
|
||||
pix = img.pixel(xp, y);
|
||||
|
||||
*stack_pix = pix;
|
||||
|
@ -161,8 +171,7 @@ class stack_blur
|
|||
sum.add(sum_in);
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix = &m_stack[stack_ptr];
|
||||
|
||||
sum_out.add(*stack_pix);
|
||||
|
@ -173,16 +182,14 @@ class stack_blur
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Img>
|
||||
void blur_y(Img& img, unsigned radius)
|
||||
template<class Img> void blur_y(Img& img, unsigned radius)
|
||||
{
|
||||
pixfmt_transposer<Img> img2(img);
|
||||
blur_x(img2, radius);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Img>
|
||||
void blur(Img& img, unsigned radius)
|
||||
template<class Img> void blur(Img& img, unsigned radius)
|
||||
{
|
||||
blur_x(img, radius);
|
||||
pixfmt_transposer<Img> img2(img);
|
||||
|
@ -195,16 +202,17 @@ class stack_blur
|
|||
};
|
||||
|
||||
//====================================================stack_blur_calc_rgba
|
||||
template<class T = unsigned>
|
||||
struct stack_blur_calc_rgba
|
||||
template<class T=unsigned> struct stack_blur_calc_rgba
|
||||
{
|
||||
typedef T value_type;
|
||||
value_type r,g,b,a;
|
||||
|
||||
AGG_INLINE void clear() { r = g = b = a = 0; }
|
||||
AGG_INLINE void clear()
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void add(const ArgT& v)
|
||||
template<class ArgT> AGG_INLINE void add(const ArgT& v)
|
||||
{
|
||||
r += v.r;
|
||||
g += v.g;
|
||||
|
@ -212,8 +220,7 @@ struct stack_blur_calc_rgba
|
|||
a += v.a;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void add(const ArgT& v, unsigned k)
|
||||
template<class ArgT> AGG_INLINE void add(const ArgT& v, unsigned k)
|
||||
{
|
||||
r += v.r * k;
|
||||
g += v.g * k;
|
||||
|
@ -221,8 +228,7 @@ struct stack_blur_calc_rgba
|
|||
a += v.a * k;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void sub(const ArgT& v)
|
||||
template<class ArgT> AGG_INLINE void sub(const ArgT& v)
|
||||
{
|
||||
r -= v.r;
|
||||
g -= v.g;
|
||||
|
@ -230,8 +236,7 @@ struct stack_blur_calc_rgba
|
|||
a -= v.a;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void calc_pix(ArgT& v, unsigned div)
|
||||
template<class ArgT> AGG_INLINE void calc_pix(ArgT& v, unsigned div)
|
||||
{
|
||||
typedef typename ArgT::value_type value_type;
|
||||
v.r = value_type(r / div);
|
||||
|
@ -251,41 +256,40 @@ struct stack_blur_calc_rgba
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//=====================================================stack_blur_calc_rgb
|
||||
template<class T = unsigned>
|
||||
struct stack_blur_calc_rgb
|
||||
template<class T=unsigned> struct stack_blur_calc_rgb
|
||||
{
|
||||
typedef T value_type;
|
||||
value_type r,g,b;
|
||||
|
||||
AGG_INLINE void clear() { r = g = b = 0; }
|
||||
AGG_INLINE void clear()
|
||||
{
|
||||
r = g = b = 0;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void add(const ArgT& v)
|
||||
template<class ArgT> AGG_INLINE void add(const ArgT& v)
|
||||
{
|
||||
r += v.r;
|
||||
g += v.g;
|
||||
b += v.b;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void add(const ArgT& v, unsigned k)
|
||||
template<class ArgT> AGG_INLINE void add(const ArgT& v, unsigned k)
|
||||
{
|
||||
r += v.r * k;
|
||||
g += v.g * k;
|
||||
b += v.b * k;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void sub(const ArgT& v)
|
||||
template<class ArgT> AGG_INLINE void sub(const ArgT& v)
|
||||
{
|
||||
r -= v.r;
|
||||
g -= v.g;
|
||||
b -= v.b;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void calc_pix(ArgT& v, unsigned div)
|
||||
template<class ArgT> AGG_INLINE void calc_pix(ArgT& v, unsigned div)
|
||||
{
|
||||
typedef typename ArgT::value_type value_type;
|
||||
v.r = value_type(r / div);
|
||||
|
@ -303,35 +307,34 @@ struct stack_blur_calc_rgb
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//====================================================stack_blur_calc_gray
|
||||
template<class T = unsigned>
|
||||
struct stack_blur_calc_gray
|
||||
template<class T=unsigned> struct stack_blur_calc_gray
|
||||
{
|
||||
typedef T value_type;
|
||||
value_type v;
|
||||
|
||||
AGG_INLINE void clear() { v = 0; }
|
||||
AGG_INLINE void clear()
|
||||
{
|
||||
v = 0;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void add(const ArgT& a)
|
||||
template<class ArgT> AGG_INLINE void add(const ArgT& a)
|
||||
{
|
||||
v += a.v;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void add(const ArgT& a, unsigned k)
|
||||
template<class ArgT> AGG_INLINE void add(const ArgT& a, unsigned k)
|
||||
{
|
||||
v += a.v * k;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void sub(const ArgT& a)
|
||||
template<class ArgT> AGG_INLINE void sub(const ArgT& a)
|
||||
{
|
||||
v -= a.v;
|
||||
}
|
||||
|
||||
template<class ArgT>
|
||||
AGG_INLINE void calc_pix(ArgT& a, unsigned div)
|
||||
template<class ArgT> AGG_INLINE void calc_pix(ArgT& a, unsigned div)
|
||||
{
|
||||
typedef typename ArgT::value_type value_type;
|
||||
a.v = value_type(v / div);
|
||||
|
@ -345,6 +348,8 @@ struct stack_blur_calc_gray
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//========================================================stack_blur_gray8
|
||||
template<class Img>
|
||||
void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
||||
|
@ -374,8 +379,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
if(rx > 0)
|
||||
{
|
||||
if (rx > 254)
|
||||
rx = 254;
|
||||
if(rx > 254) rx = 254;
|
||||
div = rx * 2 + 1;
|
||||
mul_sum = stack_blur_tables<int>::g_stack_blur8_mul[rx];
|
||||
shr_sum = stack_blur_tables<int>::g_stack_blur8_shr[rx];
|
||||
|
@ -395,8 +399,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
for(i = 1; i <= rx; i++)
|
||||
{
|
||||
if (i <= wm)
|
||||
src_pix_ptr += Img::pix_step;
|
||||
if(i <= wm) src_pix_ptr += Img::pix_step;
|
||||
pix = *src_pix_ptr;
|
||||
stack[i + rx] = pix;
|
||||
sum += pix * (rx + 1 - i);
|
||||
|
@ -405,8 +408,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
stack_ptr = rx;
|
||||
xp = rx;
|
||||
if (xp > wm)
|
||||
xp = wm;
|
||||
if(xp > wm) xp = wm;
|
||||
src_pix_ptr = img.pix_ptr(xp, y);
|
||||
dst_pix_ptr = img.pix_ptr(0, y);
|
||||
for(x = 0; x < w; x++)
|
||||
|
@ -417,8 +419,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
sum -= sum_out;
|
||||
|
||||
stack_start = stack_ptr + div - rx;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
sum_out -= stack[stack_start];
|
||||
|
||||
if(xp < wm)
|
||||
|
@ -434,8 +435,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
sum += sum_in;
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix = stack[stack_ptr];
|
||||
|
||||
sum_out += stack_pix;
|
||||
|
@ -446,8 +446,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
if(ry > 0)
|
||||
{
|
||||
if (ry > 254)
|
||||
ry = 254;
|
||||
if(ry > 254) ry = 254;
|
||||
div = ry * 2 + 1;
|
||||
mul_sum = stack_blur_tables<int>::g_stack_blur8_mul[ry];
|
||||
shr_sum = stack_blur_tables<int>::g_stack_blur8_shr[ry];
|
||||
|
@ -468,8 +467,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
for(i = 1; i <= ry; i++)
|
||||
{
|
||||
if (i <= hm)
|
||||
src_pix_ptr += stride;
|
||||
if(i <= hm) src_pix_ptr += stride;
|
||||
pix = *src_pix_ptr;
|
||||
stack[i + ry] = pix;
|
||||
sum += pix * (ry + 1 - i);
|
||||
|
@ -478,8 +476,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
stack_ptr = ry;
|
||||
yp = ry;
|
||||
if (yp > hm)
|
||||
yp = hm;
|
||||
if(yp > hm) yp = hm;
|
||||
src_pix_ptr = img.pix_ptr(x, yp);
|
||||
dst_pix_ptr = img.pix_ptr(x, 0);
|
||||
for(y = 0; y < h; y++)
|
||||
|
@ -490,8 +487,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
sum -= sum_out;
|
||||
|
||||
stack_start = stack_ptr + div - ry;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
sum_out -= stack[stack_start];
|
||||
|
||||
if(yp < hm)
|
||||
|
@ -507,8 +503,7 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
sum += sum_in;
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix = stack[stack_ptr];
|
||||
|
||||
sum_out += stack_pix;
|
||||
|
@ -518,13 +513,20 @@ void stack_blur_gray8(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//========================================================stack_blur_rgb24
|
||||
template<class Img>
|
||||
void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
||||
{
|
||||
typedef typename Img::color_type color_type;
|
||||
typedef typename Img::order_type order_type;
|
||||
enum order_e { R = order_type::R, G = order_type::G, B = order_type::B };
|
||||
enum order_e
|
||||
{
|
||||
R = order_type::R,
|
||||
G = order_type::G,
|
||||
B = order_type::B
|
||||
};
|
||||
|
||||
unsigned x, y, xp, yp, i;
|
||||
unsigned stack_ptr;
|
||||
|
@ -557,8 +559,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
if(rx > 0)
|
||||
{
|
||||
if (rx > 254)
|
||||
rx = 254;
|
||||
if(rx > 254) rx = 254;
|
||||
div = rx * 2 + 1;
|
||||
mul_sum = stack_blur_tables<int>::g_stack_blur8_mul[rx];
|
||||
shr_sum = stack_blur_tables<int>::g_stack_blur8_shr[rx];
|
||||
|
@ -566,7 +567,15 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
for(y = 0; y < h; y++)
|
||||
{
|
||||
sum_r = sum_g = sum_b = sum_in_r = sum_in_g = sum_in_b = sum_out_r = sum_out_g = sum_out_b = 0;
|
||||
sum_r =
|
||||
sum_g =
|
||||
sum_b =
|
||||
sum_in_r =
|
||||
sum_in_g =
|
||||
sum_in_b =
|
||||
sum_out_r =
|
||||
sum_out_g =
|
||||
sum_out_b = 0;
|
||||
|
||||
src_pix_ptr = img.pix_ptr(0, y);
|
||||
for(i = 0; i <= rx; i++)
|
||||
|
@ -584,8 +593,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
for(i = 1; i <= rx; i++)
|
||||
{
|
||||
if (i <= wm)
|
||||
src_pix_ptr += Img::pix_width;
|
||||
if(i <= wm) src_pix_ptr += Img::pix_width;
|
||||
stack_pix_ptr = &stack[i + rx];
|
||||
stack_pix_ptr->r = src_pix_ptr[R];
|
||||
stack_pix_ptr->g = src_pix_ptr[G];
|
||||
|
@ -600,8 +608,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
stack_ptr = rx;
|
||||
xp = rx;
|
||||
if (xp > wm)
|
||||
xp = wm;
|
||||
if(xp > wm) xp = wm;
|
||||
src_pix_ptr = img.pix_ptr(xp, y);
|
||||
dst_pix_ptr = img.pix_ptr(0, y);
|
||||
for(x = 0; x < w; x++)
|
||||
|
@ -616,8 +623,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
sum_b -= sum_out_b;
|
||||
|
||||
stack_start = stack_ptr + div - rx;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
stack_pix_ptr = &stack[stack_start];
|
||||
|
||||
sum_out_r -= stack_pix_ptr->r;
|
||||
|
@ -642,8 +648,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
sum_b += sum_in_b;
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix_ptr = &stack[stack_ptr];
|
||||
|
||||
sum_out_r += stack_pix_ptr->r;
|
||||
|
@ -658,8 +663,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
if(ry > 0)
|
||||
{
|
||||
if (ry > 254)
|
||||
ry = 254;
|
||||
if(ry > 254) ry = 254;
|
||||
div = ry * 2 + 1;
|
||||
mul_sum = stack_blur_tables<int>::g_stack_blur8_mul[ry];
|
||||
shr_sum = stack_blur_tables<int>::g_stack_blur8_shr[ry];
|
||||
|
@ -668,7 +672,15 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
int stride = img.stride();
|
||||
for(x = 0; x < w; x++)
|
||||
{
|
||||
sum_r = sum_g = sum_b = sum_in_r = sum_in_g = sum_in_b = sum_out_r = sum_out_g = sum_out_b = 0;
|
||||
sum_r =
|
||||
sum_g =
|
||||
sum_b =
|
||||
sum_in_r =
|
||||
sum_in_g =
|
||||
sum_in_b =
|
||||
sum_out_r =
|
||||
sum_out_g =
|
||||
sum_out_b = 0;
|
||||
|
||||
src_pix_ptr = img.pix_ptr(x, 0);
|
||||
for(i = 0; i <= ry; i++)
|
||||
|
@ -686,8 +698,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
for(i = 1; i <= ry; i++)
|
||||
{
|
||||
if (i <= hm)
|
||||
src_pix_ptr += stride;
|
||||
if(i <= hm) src_pix_ptr += stride;
|
||||
stack_pix_ptr = &stack[i + ry];
|
||||
stack_pix_ptr->r = src_pix_ptr[R];
|
||||
stack_pix_ptr->g = src_pix_ptr[G];
|
||||
|
@ -702,8 +713,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
stack_ptr = ry;
|
||||
yp = ry;
|
||||
if (yp > hm)
|
||||
yp = hm;
|
||||
if(yp > hm) yp = hm;
|
||||
src_pix_ptr = img.pix_ptr(x, yp);
|
||||
dst_pix_ptr = img.pix_ptr(x, 0);
|
||||
for(y = 0; y < h; y++)
|
||||
|
@ -718,8 +728,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
sum_b -= sum_out_b;
|
||||
|
||||
stack_start = stack_ptr + div - ry;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
|
||||
stack_pix_ptr = &stack[stack_start];
|
||||
sum_out_r -= stack_pix_ptr->r;
|
||||
|
@ -744,8 +753,7 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
sum_b += sum_in_b;
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix_ptr = &stack[stack_ptr];
|
||||
|
||||
sum_out_r += stack_pix_ptr->r;
|
||||
|
@ -759,13 +767,21 @@ void stack_blur_rgb24(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================stack_blur_rgba32
|
||||
template<class Img>
|
||||
void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
||||
{
|
||||
typedef typename Img::color_type color_type;
|
||||
typedef typename Img::order_type order_type;
|
||||
enum order_e { R = order_type::R, G = order_type::G, B = order_type::B, A = order_type::A };
|
||||
enum order_e
|
||||
{
|
||||
R = order_type::R,
|
||||
G = order_type::G,
|
||||
B = order_type::B,
|
||||
A = order_type::A
|
||||
};
|
||||
|
||||
unsigned x, y, xp, yp, i;
|
||||
unsigned stack_ptr;
|
||||
|
@ -801,8 +817,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
if(rx > 0)
|
||||
{
|
||||
if (rx > 254)
|
||||
rx = 254;
|
||||
if(rx > 254) rx = 254;
|
||||
div = rx * 2 + 1;
|
||||
mul_sum = stack_blur_tables<int>::g_stack_blur8_mul[rx];
|
||||
shr_sum = stack_blur_tables<int>::g_stack_blur8_shr[rx];
|
||||
|
@ -810,8 +825,18 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
for(y = 0; y < h; y++)
|
||||
{
|
||||
sum_r = sum_g = sum_b = sum_a = sum_in_r = sum_in_g = sum_in_b = sum_in_a = sum_out_r = sum_out_g =
|
||||
sum_out_b = sum_out_a = 0;
|
||||
sum_r =
|
||||
sum_g =
|
||||
sum_b =
|
||||
sum_a =
|
||||
sum_in_r =
|
||||
sum_in_g =
|
||||
sum_in_b =
|
||||
sum_in_a =
|
||||
sum_out_r =
|
||||
sum_out_g =
|
||||
sum_out_b =
|
||||
sum_out_a = 0;
|
||||
|
||||
src_pix_ptr = img.pix_ptr(0, y);
|
||||
for(i = 0; i <= rx; i++)
|
||||
|
@ -832,8 +857,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
for(i = 1; i <= rx; i++)
|
||||
{
|
||||
if (i <= wm)
|
||||
src_pix_ptr += Img::pix_width;
|
||||
if(i <= wm) src_pix_ptr += Img::pix_width;
|
||||
stack_pix_ptr = &stack[i + rx];
|
||||
stack_pix_ptr->r = src_pix_ptr[R];
|
||||
stack_pix_ptr->g = src_pix_ptr[G];
|
||||
|
@ -851,8 +875,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
stack_ptr = rx;
|
||||
xp = rx;
|
||||
if (xp > wm)
|
||||
xp = wm;
|
||||
if(xp > wm) xp = wm;
|
||||
src_pix_ptr = img.pix_ptr(xp, y);
|
||||
dst_pix_ptr = img.pix_ptr(0, y);
|
||||
for(x = 0; x < w; x++)
|
||||
|
@ -869,8 +892,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
sum_a -= sum_out_a;
|
||||
|
||||
stack_start = stack_ptr + div - rx;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
stack_pix_ptr = &stack[stack_start];
|
||||
|
||||
sum_out_r -= stack_pix_ptr->r;
|
||||
|
@ -899,8 +921,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
sum_a += sum_in_a;
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix_ptr = &stack[stack_ptr];
|
||||
|
||||
sum_out_r += stack_pix_ptr->r;
|
||||
|
@ -917,8 +938,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
if(ry > 0)
|
||||
{
|
||||
if (ry > 254)
|
||||
ry = 254;
|
||||
if(ry > 254) ry = 254;
|
||||
div = ry * 2 + 1;
|
||||
mul_sum = stack_blur_tables<int>::g_stack_blur8_mul[ry];
|
||||
shr_sum = stack_blur_tables<int>::g_stack_blur8_shr[ry];
|
||||
|
@ -927,8 +947,18 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
int stride = img.stride();
|
||||
for(x = 0; x < w; x++)
|
||||
{
|
||||
sum_r = sum_g = sum_b = sum_a = sum_in_r = sum_in_g = sum_in_b = sum_in_a = sum_out_r = sum_out_g =
|
||||
sum_out_b = sum_out_a = 0;
|
||||
sum_r =
|
||||
sum_g =
|
||||
sum_b =
|
||||
sum_a =
|
||||
sum_in_r =
|
||||
sum_in_g =
|
||||
sum_in_b =
|
||||
sum_in_a =
|
||||
sum_out_r =
|
||||
sum_out_g =
|
||||
sum_out_b =
|
||||
sum_out_a = 0;
|
||||
|
||||
src_pix_ptr = img.pix_ptr(x, 0);
|
||||
for(i = 0; i <= ry; i++)
|
||||
|
@ -949,8 +979,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
for(i = 1; i <= ry; i++)
|
||||
{
|
||||
if (i <= hm)
|
||||
src_pix_ptr += stride;
|
||||
if(i <= hm) src_pix_ptr += stride;
|
||||
stack_pix_ptr = &stack[i + ry];
|
||||
stack_pix_ptr->r = src_pix_ptr[R];
|
||||
stack_pix_ptr->g = src_pix_ptr[G];
|
||||
|
@ -968,8 +997,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
|
||||
stack_ptr = ry;
|
||||
yp = ry;
|
||||
if (yp > hm)
|
||||
yp = hm;
|
||||
if(yp > hm) yp = hm;
|
||||
src_pix_ptr = img.pix_ptr(x, yp);
|
||||
dst_pix_ptr = img.pix_ptr(x, 0);
|
||||
for(y = 0; y < h; y++)
|
||||
|
@ -986,8 +1014,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
sum_a -= sum_out_a;
|
||||
|
||||
stack_start = stack_ptr + div - ry;
|
||||
if (stack_start >= div)
|
||||
stack_start -= div;
|
||||
if(stack_start >= div) stack_start -= div;
|
||||
|
||||
stack_pix_ptr = &stack[stack_start];
|
||||
sum_out_r -= stack_pix_ptr->r;
|
||||
|
@ -1016,8 +1043,7 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
sum_a += sum_in_a;
|
||||
|
||||
++stack_ptr;
|
||||
if (stack_ptr >= div)
|
||||
stack_ptr = 0;
|
||||
if(stack_ptr >= div) stack_ptr = 0;
|
||||
stack_pix_ptr = &stack[stack_ptr];
|
||||
|
||||
sum_out_r += stack_pix_ptr->r;
|
||||
|
@ -1033,9 +1059,10 @@ void stack_blur_rgba32(Img& img, unsigned rx, unsigned ry)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===========================================================recursive_blur
|
||||
template<class ColorT, class CalculatorT>
|
||||
class recursive_blur
|
||||
template<class ColorT, class CalculatorT> class recursive_blur
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
|
@ -1044,25 +1071,30 @@ class recursive_blur
|
|||
typedef typename calculator_type::value_type calc_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Img>
|
||||
void blur_x(Img& img, double radius)
|
||||
template<class Img> void blur_x(Img& img, double radius)
|
||||
{
|
||||
if (radius < 0.62)
|
||||
return;
|
||||
if (img.width() < 3)
|
||||
return;
|
||||
if(radius < 0.62) return;
|
||||
if(img.width() < 3) return;
|
||||
|
||||
calc_type s = calc_type(radius * 0.5);
|
||||
calc_type q = calc_type((s < 2.5) ? 3.97156 - 4.14554 * sqrt(1 - 0.26891 * s) : 0.98711 * s - 0.96330);
|
||||
calc_type q = calc_type((s < 2.5) ?
|
||||
3.97156 - 4.14554 * sqrt(1 - 0.26891 * s) :
|
||||
0.98711 * s - 0.96330);
|
||||
|
||||
calc_type q2 = calc_type(q * q);
|
||||
calc_type q3 = calc_type(q2 * q);
|
||||
|
||||
calc_type b0 = calc_type(1.0 / (1.578250 + 2.444130 * q + 1.428100 * q2 + 0.422205 * q3));
|
||||
calc_type b0 = calc_type(1.0 / (1.578250 +
|
||||
2.444130 * q +
|
||||
1.428100 * q2 +
|
||||
0.422205 * q3));
|
||||
|
||||
calc_type b1 = calc_type(2.44413 * q + 2.85619 * q2 + 1.26661 * q3);
|
||||
calc_type b1 = calc_type( 2.44413 * q +
|
||||
2.85619 * q2 +
|
||||
1.26661 * q3);
|
||||
|
||||
calc_type b2 = calc_type(-1.42810 * q2 + -1.26661 * q3);
|
||||
calc_type b2 = calc_type(-1.42810 * q2 +
|
||||
-1.26661 * q3);
|
||||
|
||||
calc_type b3 = calc_type(0.422205 * q3);
|
||||
|
||||
|
@ -1114,16 +1146,14 @@ class recursive_blur
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Img>
|
||||
void blur_y(Img& img, double radius)
|
||||
template<class Img> void blur_y(Img& img, double radius)
|
||||
{
|
||||
pixfmt_transposer<Img> img2(img);
|
||||
blur_x(img2, radius);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Img>
|
||||
void blur(Img& img, double radius)
|
||||
template<class Img> void blur(Img& img, double radius)
|
||||
{
|
||||
blur_x(img, radius);
|
||||
pixfmt_transposer<Img> img2(img);
|
||||
|
@ -1136,9 +1166,9 @@ class recursive_blur
|
|||
agg::pod_vector<color_type> m_buf;
|
||||
};
|
||||
|
||||
|
||||
//=================================================recursive_blur_calc_rgba
|
||||
template<class T = double>
|
||||
struct recursive_blur_calc_rgba
|
||||
template<class T=double> struct recursive_blur_calc_rgba
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef recursive_blur_calc_rgba<T> self_type;
|
||||
|
@ -1180,9 +1210,9 @@ struct recursive_blur_calc_rgba
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//=================================================recursive_blur_calc_rgb
|
||||
template<class T = double>
|
||||
struct recursive_blur_calc_rgb
|
||||
template<class T=double> struct recursive_blur_calc_rgb
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef recursive_blur_calc_rgb<T> self_type;
|
||||
|
@ -1221,9 +1251,9 @@ struct recursive_blur_calc_rgb
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//================================================recursive_blur_calc_gray
|
||||
template<class T = double>
|
||||
struct recursive_blur_calc_gray
|
||||
template<class T=double> struct recursive_blur_calc_gray
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef recursive_blur_calc_gray<T> self_type;
|
||||
|
@ -1256,6 +1286,9 @@ struct recursive_blur_calc_gray
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
45
deps/agg/include/agg_bounding_rect.h
vendored
45
deps/agg/include/agg_bounding_rect.h
vendored
|
@ -21,18 +21,14 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------bounding_rect
|
||||
template<class VertexSource, class GetId, class CoordT>
|
||||
bool bounding_rect(VertexSource& vs,
|
||||
GetId& gi,
|
||||
unsigned start,
|
||||
unsigned num,
|
||||
CoordT* x1,
|
||||
CoordT* y1,
|
||||
CoordT* x2,
|
||||
CoordT* y2)
|
||||
bool bounding_rect(VertexSource& vs, GetId& gi,
|
||||
unsigned start, unsigned num,
|
||||
CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2)
|
||||
{
|
||||
unsigned i;
|
||||
double x;
|
||||
|
@ -62,14 +58,10 @@ bool bounding_rect(VertexSource& vs,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (CoordT(x) < *x1)
|
||||
*x1 = CoordT(x);
|
||||
if (CoordT(y) < *y1)
|
||||
*y1 = CoordT(y);
|
||||
if (CoordT(x) > *x2)
|
||||
*x2 = CoordT(x);
|
||||
if (CoordT(y) > *y2)
|
||||
*y2 = CoordT(y);
|
||||
if(CoordT(x) < *x1) *x1 = CoordT(x);
|
||||
if(CoordT(y) < *y1) *y1 = CoordT(y);
|
||||
if(CoordT(x) > *x2) *x2 = CoordT(x);
|
||||
if(CoordT(y) > *y2) *y2 = CoordT(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,9 +69,11 @@ bool bounding_rect(VertexSource& vs,
|
|||
return *x1 <= *x2 && *y1 <= *y2;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------bounding_rect_single
|
||||
template<class VertexSource, class CoordT>
|
||||
bool bounding_rect_single(VertexSource& vs, unsigned path_id, CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2)
|
||||
bool bounding_rect_single(VertexSource& vs, unsigned path_id,
|
||||
CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2)
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
|
@ -106,20 +100,17 @@ bool bounding_rect_single(VertexSource& vs, unsigned path_id, CoordT* x1, CoordT
|
|||
}
|
||||
else
|
||||
{
|
||||
if (CoordT(x) < *x1)
|
||||
*x1 = CoordT(x);
|
||||
if (CoordT(y) < *y1)
|
||||
*y1 = CoordT(y);
|
||||
if (CoordT(x) > *x2)
|
||||
*x2 = CoordT(x);
|
||||
if (CoordT(y) > *y2)
|
||||
*y2 = CoordT(y);
|
||||
if(CoordT(x) < *x1) *x1 = CoordT(x);
|
||||
if(CoordT(y) < *y1) *y1 = CoordT(y);
|
||||
if(CoordT(x) > *x2) *x2 = CoordT(x);
|
||||
if(CoordT(y) > *y2) *y2 = CoordT(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return *x1 <= *x2 && *y1 <= *y2;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
6
deps/agg/include/agg_bspline.h
vendored
6
deps/agg/include/agg_bspline.h
vendored
|
@ -22,7 +22,8 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//----------------------------------------------------------------bspline
|
||||
// A very simple class of Bi-cubic Spline interpolation.
|
||||
// First call init(num, x[], y[]) where num - number of source points,
|
||||
|
@ -69,6 +70,7 @@ class bspline
|
|||
mutable int m_last_idx;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
35
deps/agg/include/agg_clip_liang_barsky.h
vendored
35
deps/agg/include/agg_clip_liang_barsky.h
vendored
|
@ -21,10 +21,12 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
enum clipping_flags_e {
|
||||
enum clipping_flags_e
|
||||
{
|
||||
clipping_flags_x1_clipped = 4,
|
||||
clipping_flags_x2_clipped = 1,
|
||||
clipping_flags_y1_clipped = 8,
|
||||
|
@ -54,7 +56,10 @@ enum clipping_flags_e {
|
|||
template<class T>
|
||||
inline unsigned clipping_flags(T x, T y, const rect_base<T>& clip_box)
|
||||
{
|
||||
return (x > clip_box.x2) | ((y > clip_box.y2) << 1) | ((x < clip_box.x1) << 2) | ((y < clip_box.y1) << 3);
|
||||
return (x > clip_box.x2) |
|
||||
((y > clip_box.y2) << 1) |
|
||||
((x < clip_box.x1) << 2) |
|
||||
((y < clip_box.y1) << 3);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------clipping_flags_x
|
||||
|
@ -64,6 +69,7 @@ inline unsigned clipping_flags_x(T x, const rect_base<T>& clip_box)
|
|||
return (x > clip_box.x2) | ((x < clip_box.x1) << 2);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------clipping_flags_y
|
||||
template<class T>
|
||||
inline unsigned clipping_flags_y(T y, const rect_base<T>& clip_box)
|
||||
|
@ -71,9 +77,12 @@ inline unsigned clipping_flags_y(T y, const rect_base<T>& clip_box)
|
|||
return ((y > clip_box.y2) << 1) | ((y < clip_box.y1) << 3);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------clip_liang_barsky
|
||||
template<class T>
|
||||
inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, const rect_base<T>& clip_box, T* x, T* y)
|
||||
inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2,
|
||||
const rect_base<T>& clip_box,
|
||||
T* x, T* y)
|
||||
{
|
||||
const double nearzero = 1e-30;
|
||||
|
||||
|
@ -219,9 +228,12 @@ inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, const rect_base<T>& cl
|
|||
return np;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template<class T>
|
||||
bool clip_move_point(T x1, T y1, T x2, T y2, const rect_base<T>& clip_box, T* x, T* y, unsigned flags)
|
||||
bool clip_move_point(T x1, T y1, T x2, T y2,
|
||||
const rect_base<T>& clip_box,
|
||||
T* x, T* y, unsigned flags)
|
||||
{
|
||||
T bound;
|
||||
|
||||
|
@ -256,7 +268,8 @@ bool clip_move_point(T x1, T y1, T x2, T y2, const rect_base<T>& clip_box, T* x,
|
|||
// (ret & 2) != 0 - Second point has been moved
|
||||
//
|
||||
template<class T>
|
||||
unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2, const rect_base<T>& clip_box)
|
||||
unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2,
|
||||
const rect_base<T>& clip_box)
|
||||
{
|
||||
unsigned f1 = clipping_flags(*x1, *y1, clip_box);
|
||||
unsigned f2 = clipping_flags(*x2, *y2, clip_box);
|
||||
|
@ -268,13 +281,15 @@ unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2, const rect_base<T>& clip_
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ((f1 & clipping_flags_x_clipped) != 0 && (f1 & clipping_flags_x_clipped) == (f2 & clipping_flags_x_clipped))
|
||||
if((f1 & clipping_flags_x_clipped) != 0 &&
|
||||
(f1 & clipping_flags_x_clipped) == (f2 & clipping_flags_x_clipped))
|
||||
{
|
||||
// Fully clipped
|
||||
return 4;
|
||||
}
|
||||
|
||||
if ((f1 & clipping_flags_y_clipped) != 0 && (f1 & clipping_flags_y_clipped) == (f2 & clipping_flags_y_clipped))
|
||||
if((f1 & clipping_flags_y_clipped) != 0 &&
|
||||
(f1 & clipping_flags_y_clipped) == (f2 & clipping_flags_y_clipped))
|
||||
{
|
||||
// Fully clipped
|
||||
return 4;
|
||||
|
@ -311,6 +326,8 @@ unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2, const rect_base<T>& clip_
|
|||
return ret;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
499
deps/agg/include/agg_color_gray.h
vendored
499
deps/agg/include/agg_color_gray.h
vendored
|
@ -31,7 +31,8 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===================================================================gray8
|
||||
template<class Colorspace>
|
||||
|
@ -40,7 +41,8 @@ struct gray8T
|
|||
typedef int8u value_type;
|
||||
typedef int32u calc_type;
|
||||
typedef int32 long_type;
|
||||
enum base_scale_e {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 8,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1,
|
||||
|
@ -103,22 +105,17 @@ struct gray8T
|
|||
gray8T() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray8T(unsigned v_, unsigned a_ = base_mask)
|
||||
: v(int8u(v_))
|
||||
, a(int8u(a_))
|
||||
{}
|
||||
gray8T(unsigned v_, unsigned a_=base_mask) :
|
||||
v(int8u(v_)), a(int8u(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray8T(const self_type& c, unsigned a_)
|
||||
: v(c.v)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
gray8T(const self_type& c, unsigned a_) :
|
||||
v(c.v), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray8T(const rgba& c)
|
||||
: v(luminance(c))
|
||||
, a(value_type(uround(c.a * base_mask)))
|
||||
{}
|
||||
gray8T(const rgba& c) :
|
||||
v(luminance(c)),
|
||||
a(value_type(uround(c.a * base_mask))) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class T>
|
||||
|
@ -150,18 +147,36 @@ struct gray8T
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba8 make_rgba8(const linear&) const { return rgba8(v, v, v, a); }
|
||||
rgba8 make_rgba8(const linear&) const
|
||||
{
|
||||
return rgba8(v, v, v, a);
|
||||
}
|
||||
|
||||
rgba8 make_rgba8(const sRGB&) const { return convert_from_sRGB<srgba8>(); }
|
||||
rgba8 make_rgba8(const sRGB&) const
|
||||
{
|
||||
return convert_from_sRGB<srgba8>();
|
||||
}
|
||||
|
||||
operator rgba8() const { return make_rgba8(Colorspace()); }
|
||||
operator rgba8() const
|
||||
{
|
||||
return make_rgba8(Colorspace());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
srgba8 make_srgba8(const linear&) const { return convert_to_sRGB<rgba8>(); }
|
||||
srgba8 make_srgba8(const linear&) const
|
||||
{
|
||||
return convert_to_sRGB<rgba8>();
|
||||
}
|
||||
|
||||
srgba8 make_srgba8(const sRGB&) const { return srgba8(v, v, v, a); }
|
||||
srgba8 make_srgba8(const sRGB&) const
|
||||
{
|
||||
return srgba8(v, v, v, a);
|
||||
}
|
||||
|
||||
operator srgba8() const { return make_rgba8(Colorspace()); }
|
||||
operator srgba8() const
|
||||
{
|
||||
return make_rgba8(Colorspace());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba16 make_rgba16(const linear&) const
|
||||
|
@ -170,9 +185,15 @@ struct gray8T
|
|||
return rgba16(rgb, rgb, rgb, (a << 8) | a);
|
||||
}
|
||||
|
||||
rgba16 make_rgba16(const sRGB&) const { return convert_from_sRGB<rgba16>(); }
|
||||
rgba16 make_rgba16(const sRGB&) const
|
||||
{
|
||||
return convert_from_sRGB<rgba16>();
|
||||
}
|
||||
|
||||
operator rgba16() const { return make_rgba16(Colorspace()); }
|
||||
operator rgba16() const
|
||||
{
|
||||
return make_rgba16(Colorspace());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32 make_rgba32(const linear&) const
|
||||
|
@ -181,27 +202,51 @@ struct gray8T
|
|||
return rgba32(v32, v32, v32, a / 255.0);
|
||||
}
|
||||
|
||||
rgba32 make_rgba32(const sRGB&) const { return convert_from_sRGB<rgba32>(); }
|
||||
rgba32 make_rgba32(const sRGB&) const
|
||||
{
|
||||
return convert_from_sRGB<rgba32>();
|
||||
}
|
||||
|
||||
operator rgba32() const { return make_rgba32(Colorspace()); }
|
||||
operator rgba32() const
|
||||
{
|
||||
return make_rgba32(Colorspace());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE double to_double(value_type a) { return double(a) / base_mask; }
|
||||
static AGG_INLINE double to_double(value_type a)
|
||||
{
|
||||
return double(a) / base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type from_double(double a) { return value_type(uround(a * base_mask)); }
|
||||
static AGG_INLINE value_type from_double(double a)
|
||||
{
|
||||
return value_type(uround(a * base_mask));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type empty_value() { return 0; }
|
||||
static AGG_INLINE value_type empty_value()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type full_value() { return base_mask; }
|
||||
static AGG_INLINE value_type full_value()
|
||||
{
|
||||
return base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_transparent() const { return a == 0; }
|
||||
AGG_INLINE bool is_transparent() const
|
||||
{
|
||||
return a == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_opaque() const { return a == base_mask; }
|
||||
AGG_INLINE bool is_opaque() const
|
||||
{
|
||||
return a == base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, exact over int8u.
|
||||
|
@ -222,8 +267,7 @@ struct gray8T
|
|||
{
|
||||
return base_mask;
|
||||
}
|
||||
else
|
||||
return value_type((a * base_mask + (b >> 1)) / b);
|
||||
else return value_type((a * base_mask + (b >> 1)) / b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -243,14 +287,23 @@ struct gray8T
|
|||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, exact over int8u.
|
||||
// Specifically for multiplying a color component by a cover.
|
||||
static AGG_INLINE value_type mult_cover(value_type a, value_type b) { return multiply(a, b); }
|
||||
static AGG_INLINE value_type mult_cover(value_type a, value_type b)
|
||||
{
|
||||
return multiply(a, b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) { return multiply(b, a); }
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b)
|
||||
{
|
||||
return multiply(b, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a, assuming q is premultiplied by a.
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) { return p + q - multiply(p, a); }
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a)
|
||||
{
|
||||
return p + q - multiply(p, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a.
|
||||
|
@ -277,27 +330,25 @@ struct gray8T
|
|||
//--------------------------------------------------------------------
|
||||
self_type& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
else if (a_ > 1)
|
||||
a = 1;
|
||||
else
|
||||
a = (value_type)uround(a_ * double(base_mask));
|
||||
if (a_ < 0) a = 0;
|
||||
else if (a_ > 1) a = 1;
|
||||
else a = (value_type)uround(a_ * double(base_mask));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return double(a) / double(base_mask); }
|
||||
double opacity() const
|
||||
{
|
||||
return double(a) / double(base_mask);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
self_type& premultiply()
|
||||
{
|
||||
if (a < base_mask)
|
||||
{
|
||||
if (a == 0)
|
||||
v = 0;
|
||||
else
|
||||
v = multiply(v, a);
|
||||
if (a == 0) v = 0;
|
||||
else v = multiply(v, a);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -363,13 +414,15 @@ struct gray8T
|
|||
typedef gray8T<linear> gray8;
|
||||
typedef gray8T<sRGB> sgray8;
|
||||
|
||||
|
||||
//==================================================================gray16
|
||||
struct gray16
|
||||
{
|
||||
typedef int16u value_type;
|
||||
typedef int32u calc_type;
|
||||
typedef int64 long_type;
|
||||
enum base_scale_e {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1,
|
||||
|
@ -383,7 +436,8 @@ struct gray16
|
|||
static value_type luminance(const rgba& c)
|
||||
{
|
||||
// Calculate grayscale value as per ITU-R BT.709.
|
||||
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * static_cast<double>(base_mask)));
|
||||
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b)
|
||||
* static_cast<double>(base_mask)));
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba16& c)
|
||||
|
@ -392,65 +446,67 @@ struct gray16
|
|||
return value_type((13933u * c.r + 46872u * c.g + 4732u * c.b) >> 16);
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba8& c) { return luminance(rgba16(c)); }
|
||||
static value_type luminance(const rgba8& c)
|
||||
{
|
||||
return luminance(rgba16(c));
|
||||
}
|
||||
|
||||
static value_type luminance(const srgba8& c) { return luminance(rgba16(c)); }
|
||||
static value_type luminance(const srgba8& c)
|
||||
{
|
||||
return luminance(rgba16(c));
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba32& c) { return luminance(rgba(c)); }
|
||||
static value_type luminance(const rgba32& c)
|
||||
{
|
||||
return luminance(rgba(c));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(unsigned v_, unsigned a_ = base_mask)
|
||||
: v(int16u(v_))
|
||||
, a(int16u(a_))
|
||||
{}
|
||||
gray16(unsigned v_, unsigned a_ = base_mask) :
|
||||
v(int16u(v_)), a(int16u(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const self_type& c, unsigned a_)
|
||||
: v(c.v)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
gray16(const self_type& c, unsigned a_) :
|
||||
v(c.v), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const rgba& c)
|
||||
: v(luminance(c))
|
||||
, a((value_type)uround(c.a * double(base_mask)))
|
||||
{}
|
||||
gray16(const rgba& c) :
|
||||
v(luminance(c)),
|
||||
a((value_type)uround(c.a * double(base_mask))) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const rgba8& c)
|
||||
: v(luminance(c))
|
||||
, a((value_type(c.a) << 8) | c.a)
|
||||
{}
|
||||
gray16(const rgba8& c) :
|
||||
v(luminance(c)),
|
||||
a((value_type(c.a) << 8) | c.a) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const srgba8& c)
|
||||
: v(luminance(c))
|
||||
, a((value_type(c.a) << 8) | c.a)
|
||||
{}
|
||||
gray16(const srgba8& c) :
|
||||
v(luminance(c)),
|
||||
a((value_type(c.a) << 8) | c.a) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const rgba16& c)
|
||||
: v(luminance(c))
|
||||
, a(c.a)
|
||||
{}
|
||||
gray16(const rgba16& c) :
|
||||
v(luminance(c)),
|
||||
a(c.a) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const gray8& c)
|
||||
: v((value_type(c.v) << 8) | c.v)
|
||||
, a((value_type(c.a) << 8) | c.a)
|
||||
{}
|
||||
gray16(const gray8& c) :
|
||||
v((value_type(c.v) << 8) | c.v),
|
||||
a((value_type(c.a) << 8) | c.a) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const sgray8& c)
|
||||
: v(sRGB_conv<value_type>::rgb_from_sRGB(c.v))
|
||||
, a(sRGB_conv<value_type>::alpha_from_sRGB(c.a))
|
||||
{}
|
||||
gray16(const sgray8& c) :
|
||||
v(sRGB_conv<value_type>::rgb_from_sRGB(c.v)),
|
||||
a(sRGB_conv<value_type>::alpha_from_sRGB(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba8() const { return rgba8(v >> 8, v >> 8, v >> 8, a >> 8); }
|
||||
operator rgba8() const
|
||||
{
|
||||
return rgba8(v >> 8, v >> 8, v >> 8, a >> 8);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator srgba8() const
|
||||
|
@ -460,19 +516,30 @@ struct gray16
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba16() const { return rgba16(v, v, v, a); }
|
||||
operator rgba16() const
|
||||
{
|
||||
return rgba16(v, v, v, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator gray8() const { return gray8(v >> 8, a >> 8); }
|
||||
operator gray8() const
|
||||
{
|
||||
return gray8(v >> 8, a >> 8);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator sgray8() const
|
||||
{
|
||||
return sgray8(sRGB_conv<value_type>::rgb_to_sRGB(v), sRGB_conv<value_type>::alpha_to_sRGB(a));
|
||||
return sgray8(
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(v),
|
||||
sRGB_conv<value_type>::alpha_to_sRGB(a));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE double to_double(value_type a) { return static_cast<double>(a) / static_cast<double>(base_mask); }
|
||||
static AGG_INLINE double to_double(value_type a)
|
||||
{
|
||||
return static_cast<double>(a) / static_cast<double>(base_mask);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type from_double(double a)
|
||||
|
@ -481,16 +548,28 @@ struct gray16
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type empty_value() { return 0; }
|
||||
static AGG_INLINE value_type empty_value()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type full_value() { return base_mask; }
|
||||
static AGG_INLINE value_type full_value()
|
||||
{
|
||||
return base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_transparent() const { return a == 0; }
|
||||
AGG_INLINE bool is_transparent() const
|
||||
{
|
||||
return a == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_opaque() const { return a == base_mask; }
|
||||
AGG_INLINE bool is_opaque() const
|
||||
{
|
||||
return a == base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, exact over int16u.
|
||||
|
@ -511,8 +590,7 @@ struct gray16
|
|||
{
|
||||
return base_mask;
|
||||
}
|
||||
else
|
||||
return value_type((a * base_mask + (b >> 1)) / b);
|
||||
else return value_type((a * base_mask + (b >> 1)) / b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -532,14 +610,23 @@ struct gray16
|
|||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, almost exact over int16u.
|
||||
// Specifically for multiplying a color component by a cover.
|
||||
static AGG_INLINE value_type mult_cover(value_type a, cover_type b) { return multiply(a, b << 8 | b); }
|
||||
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
|
||||
{
|
||||
return multiply(a, b << 8 | b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) { return mult_cover(b, a) >> 8; }
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b)
|
||||
{
|
||||
return mult_cover(b, a) >> 8;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a, assuming q is premultiplied by a.
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) { return p + q - multiply(p, a); }
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a)
|
||||
{
|
||||
return p + q - multiply(p, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a.
|
||||
|
@ -566,27 +653,26 @@ struct gray16
|
|||
//--------------------------------------------------------------------
|
||||
self_type& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
else if (a_ > 1)
|
||||
a = 1;
|
||||
else
|
||||
a = (value_type)uround(a_ * double(base_mask));
|
||||
if (a_ < 0) a = 0;
|
||||
else if(a_ > 1) a = 1;
|
||||
else a = (value_type)uround(a_ * double(base_mask));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return double(a) / double(base_mask); }
|
||||
double opacity() const
|
||||
{
|
||||
return double(a) / double(base_mask);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
self_type& premultiply()
|
||||
{
|
||||
if (a < base_mask)
|
||||
{
|
||||
if (a == 0)
|
||||
v = 0;
|
||||
else
|
||||
v = multiply(v, a);
|
||||
if(a == 0) v = 0;
|
||||
else v = multiply(v, a);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -649,6 +735,7 @@ struct gray16
|
|||
static self_type no_color() { return self_type(0,0); }
|
||||
};
|
||||
|
||||
|
||||
//===================================================================gray32
|
||||
struct gray32
|
||||
{
|
||||
|
@ -660,7 +747,8 @@ struct gray32
|
|||
value_type v;
|
||||
value_type a;
|
||||
|
||||
enum base_scale_e {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 8,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1,
|
||||
|
@ -672,92 +760,103 @@ struct gray32
|
|||
return value_type(0.2126 * r + 0.7152 * g + 0.0722 * b);
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba& c) { return luminance(c.r, c.g, c.b); }
|
||||
static value_type luminance(const rgba& c)
|
||||
{
|
||||
return luminance(c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba32& c) { return luminance(c.r, c.g, c.b); }
|
||||
static value_type luminance(const rgba32& c)
|
||||
{
|
||||
return luminance(c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba8& c) { return luminance(c.r / 255.0, c.g / 255.0, c.g / 255.0); }
|
||||
static value_type luminance(const rgba8& c)
|
||||
{
|
||||
return luminance(c.r / 255.0, c.g / 255.0, c.g / 255.0);
|
||||
}
|
||||
|
||||
static value_type luminance(const rgba16& c) { return luminance(c.r / 65535.0, c.g / 65535.0, c.g / 65535.0); }
|
||||
static value_type luminance(const rgba16& c)
|
||||
{
|
||||
return luminance(c.r / 65535.0, c.g / 65535.0, c.g / 65535.0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(value_type v_, value_type a_ = 1)
|
||||
: v(v_)
|
||||
, a(a_)
|
||||
{}
|
||||
gray32(value_type v_, value_type a_ = 1) :
|
||||
v(v_), a(a_) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const self_type& c, value_type a_)
|
||||
: v(c.v)
|
||||
, a(a_)
|
||||
{}
|
||||
gray32(const self_type& c, value_type a_) :
|
||||
v(c.v), a(a_) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const rgba& c)
|
||||
: v(luminance(c))
|
||||
, a(value_type(c.a))
|
||||
{}
|
||||
gray32(const rgba& c) :
|
||||
v(luminance(c)),
|
||||
a(value_type(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const rgba8& c)
|
||||
: v(luminance(c))
|
||||
, a(value_type(c.a / 255.0))
|
||||
{}
|
||||
gray32(const rgba8& c) :
|
||||
v(luminance(c)),
|
||||
a(value_type(c.a / 255.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const srgba8& c)
|
||||
: v(luminance(rgba32(c)))
|
||||
, a(value_type(c.a / 255.0))
|
||||
{}
|
||||
gray32(const srgba8& c) :
|
||||
v(luminance(rgba32(c))),
|
||||
a(value_type(c.a / 255.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const rgba16& c)
|
||||
: v(luminance(c))
|
||||
, a(value_type(c.a / 65535.0))
|
||||
{}
|
||||
gray32(const rgba16& c) :
|
||||
v(luminance(c)),
|
||||
a(value_type(c.a / 65535.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const rgba32& c)
|
||||
: v(luminance(c))
|
||||
, a(value_type(c.a))
|
||||
{}
|
||||
gray32(const rgba32& c) :
|
||||
v(luminance(c)),
|
||||
a(value_type(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const gray8& c)
|
||||
: v(value_type(c.v / 255.0))
|
||||
, a(value_type(c.a / 255.0))
|
||||
{}
|
||||
gray32(const gray8& c) :
|
||||
v(value_type(c.v / 255.0)),
|
||||
a(value_type(c.a / 255.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const sgray8& c)
|
||||
: v(sRGB_conv<value_type>::rgb_from_sRGB(c.v))
|
||||
, a(sRGB_conv<value_type>::alpha_from_sRGB(c.a))
|
||||
{}
|
||||
gray32(const sgray8& c) :
|
||||
v(sRGB_conv<value_type>::rgb_from_sRGB(c.v)),
|
||||
a(sRGB_conv<value_type>::alpha_from_sRGB(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const gray16& c)
|
||||
: v(value_type(c.v / 65535.0))
|
||||
, a(value_type(c.a / 65535.0))
|
||||
{}
|
||||
gray32(const gray16& c) :
|
||||
v(value_type(c.v / 65535.0)),
|
||||
a(value_type(c.a / 65535.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba() const { return rgba(v, v, v, a); }
|
||||
operator rgba() const
|
||||
{
|
||||
return rgba(v, v, v, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator gray8() const { return gray8(uround(v * 255.0), uround(a * 255.0)); }
|
||||
operator gray8() const
|
||||
{
|
||||
return gray8(uround(v * 255.0), uround(a * 255.0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator sgray8() const
|
||||
{
|
||||
// Return (non-premultiplied) sRGB values.
|
||||
return sgray8(sRGB_conv<value_type>::rgb_to_sRGB(v), sRGB_conv<value_type>::alpha_to_sRGB(a));
|
||||
return sgray8(
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(v),
|
||||
sRGB_conv<value_type>::alpha_to_sRGB(a));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator gray16() const { return gray16(uround(v * 65535.0), uround(a * 65535.0)); }
|
||||
operator gray16() const
|
||||
{
|
||||
return gray16(uround(v * 65535.0), uround(a * 65535.0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba8() const
|
||||
|
@ -781,31 +880,58 @@ struct gray32
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE double to_double(value_type a) { return a; }
|
||||
static AGG_INLINE double to_double(value_type a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type from_double(double a) { return value_type(a); }
|
||||
static AGG_INLINE value_type from_double(double a)
|
||||
{
|
||||
return value_type(a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type empty_value() { return 0; }
|
||||
static AGG_INLINE value_type empty_value()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type full_value() { return 1; }
|
||||
static AGG_INLINE value_type full_value()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_transparent() const { return a <= 0; }
|
||||
AGG_INLINE bool is_transparent() const
|
||||
{
|
||||
return a <= 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_opaque() const { return a >= 1; }
|
||||
AGG_INLINE bool is_opaque() const
|
||||
{
|
||||
return a >= 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type invert(value_type x) { return 1 - x; }
|
||||
static AGG_INLINE value_type invert(value_type x)
|
||||
{
|
||||
return 1 - x;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type multiply(value_type a, value_type b) { return value_type(a * b); }
|
||||
static AGG_INLINE value_type multiply(value_type a, value_type b)
|
||||
{
|
||||
return value_type(a * b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type demultiply(value_type a, value_type b) { return (b == 0) ? 0 : value_type(a / b); }
|
||||
static AGG_INLINE value_type demultiply(value_type a, value_type b)
|
||||
{
|
||||
return (b == 0) ? 0 : value_type(a / b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<typename T>
|
||||
|
@ -828,7 +954,10 @@ struct gray32
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) { return cover_type(uround(a * b)); }
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b)
|
||||
{
|
||||
return cover_type(uround(a * b));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a, assuming q is premultiplied by a.
|
||||
|
@ -865,47 +994,49 @@ struct gray32
|
|||
//--------------------------------------------------------------------
|
||||
self_type& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
else if (a_ > 1)
|
||||
a = 1;
|
||||
else
|
||||
a = value_type(a_);
|
||||
if (a_ < 0) a = 0;
|
||||
else if (a_ > 1) a = 1;
|
||||
else a = value_type(a_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return a; }
|
||||
double opacity() const
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
self_type& premultiply()
|
||||
{
|
||||
if (a < 0)
|
||||
v = 0;
|
||||
else if (a < 1)
|
||||
v *= a;
|
||||
if (a < 0) v = 0;
|
||||
else if(a < 1) v *= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
self_type& demultiply()
|
||||
{
|
||||
if (a < 0)
|
||||
v = 0;
|
||||
else if (a < 1)
|
||||
v /= a;
|
||||
if (a < 0) v = 0;
|
||||
else if (a < 1) v /= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
self_type gradient(self_type c, double k) const
|
||||
{
|
||||
return self_type(value_type(v + (c.v - v) * k), value_type(a + (c.a - a) * k));
|
||||
return self_type(
|
||||
value_type(v + (c.v - v) * k),
|
||||
value_type(a + (c.a - a) * k));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static self_type no_color() { return self_type(0,0); }
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
477
deps/agg/include/agg_color_rgba.h
vendored
477
deps/agg/include/agg_color_rgba.h
vendored
|
@ -28,39 +28,20 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_gamma_lut.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
// Supported byte orders for RGB and RGBA pixel formats
|
||||
//=======================================================================
|
||||
struct order_rgb
|
||||
{
|
||||
enum rgb_e { R = 0, G = 1, B = 2, rgb_tag, hasAlpha = false };
|
||||
}; //----order_rgb
|
||||
struct order_bgr
|
||||
{
|
||||
enum bgr_e { B = 0, G = 1, R = 2, rgb_tag, hasAlpha = false };
|
||||
}; //----order_bgr
|
||||
struct order_rgba
|
||||
{
|
||||
enum rgba_e { R = 0, G = 1, B = 2, A = 3, rgba_tag, hasAlpha = true };
|
||||
}; //----order_rgba
|
||||
struct order_argb
|
||||
{
|
||||
enum argb_e { A = 0, R = 1, G = 2, B = 3, rgba_tag, hasAlpha = true };
|
||||
}; //----order_argb
|
||||
struct order_abgr
|
||||
{
|
||||
enum abgr_e { A = 0, B = 1, G = 2, R = 3, rgba_tag, hasAlpha = true };
|
||||
}; //----order_abgr
|
||||
struct order_bgra
|
||||
{
|
||||
enum bgra_e { B = 0, G = 1, R = 2, A = 3, rgba_tag, hasAlpha = true };
|
||||
}; //----order_bgra
|
||||
struct order_rgb { enum rgb_e { R=0, G=1, B=2, rgb_tag, hasAlpha=false }; }; //----order_rgb
|
||||
struct order_bgr { enum bgr_e { B=0, G=1, R=2, rgb_tag, hasAlpha=false }; }; //----order_bgr
|
||||
struct order_rgba { enum rgba_e { R=0, G=1, B=2, A=3, rgba_tag, hasAlpha=true }; }; //----order_rgba
|
||||
struct order_argb { enum argb_e { A=0, R=1, G=2, B=3, rgba_tag, hasAlpha=true }; }; //----order_argb
|
||||
struct order_abgr { enum abgr_e { A=0, B=1, G=2, R=3, rgba_tag, hasAlpha=true }; }; //----order_abgr
|
||||
struct order_bgra { enum bgra_e { B=0, G=1, R=2, A=3, rgba_tag, hasAlpha=true }; }; //----order_bgra
|
||||
|
||||
// Colorspace tag types.
|
||||
struct linear
|
||||
{};
|
||||
struct sRGB
|
||||
{};
|
||||
struct linear {};
|
||||
struct sRGB {};
|
||||
|
||||
//====================================================================rgba
|
||||
struct rgba
|
||||
|
@ -76,20 +57,11 @@ struct rgba
|
|||
rgba() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba(double r_, double g_, double b_, double a_ = 1.0)
|
||||
: r(r_)
|
||||
, g(g_)
|
||||
, b(b_)
|
||||
, a(a_)
|
||||
{}
|
||||
rgba(double r_, double g_, double b_, double a_=1.0) :
|
||||
r(r_), g(g_), b(b_), a(a_) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba(const rgba& c, double a_)
|
||||
: r(c.r)
|
||||
, g(c.g)
|
||||
, b(c.b)
|
||||
, a(a_)
|
||||
{}
|
||||
rgba(const rgba& c, double a_) : r(c.r), g(c.g), b(c.b), a(a_) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba& clear()
|
||||
|
@ -108,17 +80,17 @@ struct rgba
|
|||
//--------------------------------------------------------------------
|
||||
rgba& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
else if (a_ > 1)
|
||||
a = 1;
|
||||
else
|
||||
a = a_;
|
||||
if (a_ < 0) a = 0;
|
||||
else if (a_ > 1) a = 1;
|
||||
else a = a_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return a; }
|
||||
double opacity() const
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba& premultiply()
|
||||
|
@ -164,6 +136,7 @@ struct rgba
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba gradient(rgba c, double k) const
|
||||
{
|
||||
|
@ -200,7 +173,11 @@ struct rgba
|
|||
static rgba from_wavelength(double wl, double gamma = 1.0);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
explicit rgba(double wavelen, double gamma = 1.0) { *this = from_wavelength(wavelen, gamma); }
|
||||
explicit rgba(double wavelen, double gamma=1.0)
|
||||
{
|
||||
*this = from_wavelength(wavelen, gamma);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
inline rgba operator+(const rgba& a, const rgba& b)
|
||||
|
@ -249,10 +226,8 @@ inline rgba rgba::from_wavelength(double wl, double gamma)
|
|||
}
|
||||
|
||||
double s = 1.0;
|
||||
if (wl > 700.0)
|
||||
s = 0.3 + 0.7 * (780.0 - wl) / (780.0 - 700.0);
|
||||
else if (wl < 420.0)
|
||||
s = 0.3 + 0.7 * (wl - 380.0) / (420.0 - 380.0);
|
||||
if (wl > 700.0) s = 0.3 + 0.7 * (780.0 - wl) / (780.0 - 700.0);
|
||||
else if (wl < 420.0) s = 0.3 + 0.7 * (wl - 380.0) / (420.0 - 380.0);
|
||||
|
||||
t.r = pow(t.r * s, gamma);
|
||||
t.g = pow(t.g * s, gamma);
|
||||
|
@ -265,6 +240,7 @@ inline rgba rgba_pre(double r, double g, double b, double a)
|
|||
return rgba(r, g, b, a).premultiply();
|
||||
}
|
||||
|
||||
|
||||
//===================================================================rgba8
|
||||
template<class Colorspace>
|
||||
struct rgba8T
|
||||
|
@ -272,7 +248,8 @@ struct rgba8T
|
|||
typedef int8u value_type;
|
||||
typedef int32u calc_type;
|
||||
typedef int32 long_type;
|
||||
enum base_scale_e {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 8,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1,
|
||||
|
@ -280,6 +257,7 @@ struct rgba8T
|
|||
};
|
||||
typedef rgba8T self_type;
|
||||
|
||||
|
||||
value_type r;
|
||||
value_type g;
|
||||
value_type b;
|
||||
|
@ -339,23 +317,21 @@ struct rgba8T
|
|||
rgba8T() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba8T(unsigned r_, unsigned g_, unsigned b_, unsigned a_ = base_mask)
|
||||
: r(value_type(r_))
|
||||
, g(value_type(g_))
|
||||
, b(value_type(b_))
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
rgba8T(unsigned r_, unsigned g_, unsigned b_, unsigned a_ = base_mask) :
|
||||
r(value_type(r_)),
|
||||
g(value_type(g_)),
|
||||
b(value_type(b_)),
|
||||
a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba8T(const rgba& c) { convert(*this, c); }
|
||||
rgba8T(const rgba& c)
|
||||
{
|
||||
convert(*this, c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba8T(const self_type& c, unsigned a_)
|
||||
: r(c.r)
|
||||
, g(c.g)
|
||||
, b(c.b)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
rgba8T(const self_type& c, unsigned a_) :
|
||||
r(c.r), g(c.g), b(c.b), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class T>
|
||||
|
@ -373,25 +349,46 @@ struct rgba8T
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE double to_double(value_type a) { return double(a) / base_mask; }
|
||||
static AGG_INLINE double to_double(value_type a)
|
||||
{
|
||||
return double(a) / base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type from_double(double a) { return value_type(uround(a * base_mask)); }
|
||||
static AGG_INLINE value_type from_double(double a)
|
||||
{
|
||||
return value_type(uround(a * base_mask));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type empty_value() { return 0; }
|
||||
static AGG_INLINE value_type empty_value()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type full_value() { return base_mask; }
|
||||
static AGG_INLINE value_type full_value()
|
||||
{
|
||||
return base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_transparent() const { return a == 0; }
|
||||
AGG_INLINE bool is_transparent() const
|
||||
{
|
||||
return a == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_opaque() const { return a == base_mask; }
|
||||
AGG_INLINE bool is_opaque() const
|
||||
{
|
||||
return a == base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type invert(value_type x) { return base_mask - x; }
|
||||
static AGG_INLINE value_type invert(value_type x)
|
||||
{
|
||||
return base_mask - x;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, exact over int8u.
|
||||
|
@ -412,8 +409,7 @@ struct rgba8T
|
|||
{
|
||||
return base_mask;
|
||||
}
|
||||
else
|
||||
return value_type((a * base_mask + (b >> 1)) / b);
|
||||
else return value_type((a * base_mask + (b >> 1)) / b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -433,14 +429,23 @@ struct rgba8T
|
|||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, exact over int8u.
|
||||
// Specifically for multiplying a color component by a cover.
|
||||
static AGG_INLINE value_type mult_cover(value_type a, cover_type b) { return multiply(a, b); }
|
||||
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
|
||||
{
|
||||
return multiply(a, b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) { return multiply(b, a); }
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b)
|
||||
{
|
||||
return multiply(b, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a, assuming q is premultiplied by a.
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) { return p + q - multiply(p, a); }
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a)
|
||||
{
|
||||
return p + q - multiply(p, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a.
|
||||
|
@ -467,17 +472,17 @@ struct rgba8T
|
|||
//--------------------------------------------------------------------
|
||||
self_type& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
else if (a_ > 1)
|
||||
a = 1;
|
||||
else
|
||||
a = (value_type)uround(a_ * double(base_mask));
|
||||
if (a_ < 0) a = 0;
|
||||
else if (a_ > 1) a = 1;
|
||||
else a = (value_type)uround(a_ * double(base_mask));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return double(a) / double(base_mask); }
|
||||
double opacity() const
|
||||
{
|
||||
return double(a) / double(base_mask);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE self_type& premultiply()
|
||||
|
@ -612,7 +617,8 @@ typedef rgba8T<linear> rgba8;
|
|||
typedef rgba8T<sRGB> srgba8;
|
||||
|
||||
//-------------------------------------------------------------rgba8_pre
|
||||
inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b, unsigned a = rgba8::base_mask)
|
||||
inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b,
|
||||
unsigned a = rgba8::base_mask)
|
||||
{
|
||||
return rgba8(r,g,b,a).premultiply();
|
||||
}
|
||||
|
@ -633,6 +639,9 @@ inline rgba8 rgba8_pre(const rgba& c, double a)
|
|||
return rgba8(c,a).premultiply();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------rgb8_packed
|
||||
inline rgba8 rgb8_packed(unsigned v)
|
||||
{
|
||||
|
@ -665,13 +674,16 @@ rgba8 rgba8_gamma_inv(rgba8 c, const GammaLUT& gamma)
|
|||
return rgba8(gamma.inv(c.r), gamma.inv(c.g), gamma.inv(c.b), c.a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================================rgba16
|
||||
struct rgba16
|
||||
{
|
||||
typedef int16u value_type;
|
||||
typedef int32u calc_type;
|
||||
typedef int64 long_type;
|
||||
enum base_scale_e {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1,
|
||||
|
@ -688,63 +700,69 @@ struct rgba16
|
|||
rgba16() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba16(unsigned r_, unsigned g_, unsigned b_, unsigned a_ = base_mask)
|
||||
: r(value_type(r_))
|
||||
, g(value_type(g_))
|
||||
, b(value_type(b_))
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
rgba16(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) :
|
||||
r(value_type(r_)),
|
||||
g(value_type(g_)),
|
||||
b(value_type(b_)),
|
||||
a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba16(const self_type& c, unsigned a_)
|
||||
: r(c.r)
|
||||
, g(c.g)
|
||||
, b(c.b)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
rgba16(const self_type& c, unsigned a_) :
|
||||
r(c.r), g(c.g), b(c.b), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba16(const rgba& c)
|
||||
: r((value_type)uround(c.r * double(base_mask)))
|
||||
, g((value_type)uround(c.g * double(base_mask)))
|
||||
, b((value_type)uround(c.b * double(base_mask)))
|
||||
, a((value_type)uround(c.a * double(base_mask)))
|
||||
{}
|
||||
rgba16(const rgba& c) :
|
||||
r((value_type)uround(c.r * double(base_mask))),
|
||||
g((value_type)uround(c.g * double(base_mask))),
|
||||
b((value_type)uround(c.b * double(base_mask))),
|
||||
a((value_type)uround(c.a * double(base_mask))) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba16(const rgba8& c)
|
||||
: r(value_type((value_type(c.r) << 8) | c.r))
|
||||
, g(value_type((value_type(c.g) << 8) | c.g))
|
||||
, b(value_type((value_type(c.b) << 8) | c.b))
|
||||
, a(value_type((value_type(c.a) << 8) | c.a))
|
||||
{}
|
||||
rgba16(const rgba8& c) :
|
||||
r(value_type((value_type(c.r) << 8) | c.r)),
|
||||
g(value_type((value_type(c.g) << 8) | c.g)),
|
||||
b(value_type((value_type(c.b) << 8) | c.b)),
|
||||
a(value_type((value_type(c.a) << 8) | c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba16(const srgba8& c)
|
||||
: r(sRGB_conv<value_type>::rgb_from_sRGB(c.r))
|
||||
, g(sRGB_conv<value_type>::rgb_from_sRGB(c.g))
|
||||
, b(sRGB_conv<value_type>::rgb_from_sRGB(c.b))
|
||||
, a(sRGB_conv<value_type>::alpha_from_sRGB(c.a))
|
||||
{}
|
||||
rgba16(const srgba8& c) :
|
||||
r(sRGB_conv<value_type>::rgb_from_sRGB(c.r)),
|
||||
g(sRGB_conv<value_type>::rgb_from_sRGB(c.g)),
|
||||
b(sRGB_conv<value_type>::rgb_from_sRGB(c.b)),
|
||||
a(sRGB_conv<value_type>::alpha_from_sRGB(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba() const { return rgba(r / 65535.0, g / 65535.0, b / 65535.0, a / 65535.0); }
|
||||
operator rgba() const
|
||||
{
|
||||
return rgba(
|
||||
r / 65535.0,
|
||||
g / 65535.0,
|
||||
b / 65535.0,
|
||||
a / 65535.0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba8() const { return rgba8(r >> 8, g >> 8, b >> 8, a >> 8); }
|
||||
operator rgba8() const
|
||||
{
|
||||
return rgba8(r >> 8, g >> 8, b >> 8, a >> 8);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator srgba8() const
|
||||
{
|
||||
// Return (non-premultiplied) sRGB values.
|
||||
return srgba8(sRGB_conv<value_type>::rgb_to_sRGB(r),
|
||||
return srgba8(
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(r),
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(g),
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(b),
|
||||
sRGB_conv<value_type>::alpha_to_sRGB(a));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE double to_double(value_type a) { return static_cast<double>(a) / static_cast<double>(base_mask); }
|
||||
static AGG_INLINE double to_double(value_type a)
|
||||
{
|
||||
return static_cast<double>(a) / static_cast<double>(base_mask);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type from_double(double a)
|
||||
|
@ -753,19 +771,34 @@ struct rgba16
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type empty_value() { return 0; }
|
||||
static AGG_INLINE value_type empty_value()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type full_value() { return base_mask; }
|
||||
static AGG_INLINE value_type full_value()
|
||||
{
|
||||
return base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_transparent() const { return a == 0; }
|
||||
AGG_INLINE bool is_transparent() const
|
||||
{
|
||||
return a == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_opaque() const { return a == base_mask; }
|
||||
AGG_INLINE bool is_opaque() const
|
||||
{
|
||||
return a == base_mask;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type invert(value_type x) { return base_mask - x; }
|
||||
static AGG_INLINE value_type invert(value_type x)
|
||||
{
|
||||
return base_mask - x;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, exact over int16u.
|
||||
|
@ -786,8 +819,7 @@ struct rgba16
|
|||
{
|
||||
return base_mask;
|
||||
}
|
||||
else
|
||||
return value_type((a * base_mask + (b >> 1)) / b);
|
||||
else return value_type((a * base_mask + (b >> 1)) / b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -807,14 +839,23 @@ struct rgba16
|
|||
//--------------------------------------------------------------------
|
||||
// Fixed-point multiply, almost exact over int16u.
|
||||
// Specifically for multiplying a color component by a cover.
|
||||
static AGG_INLINE value_type mult_cover(value_type a, cover_type b) { return multiply(a, (b << 8) | b); }
|
||||
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
|
||||
{
|
||||
return multiply(a, (b << 8) | b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) { return multiply((a << 8) | a, b) >> 8; }
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b)
|
||||
{
|
||||
return multiply((a << 8) | a, b) >> 8;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a, assuming q is premultiplied by a.
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a) { return p + q - multiply(p, a); }
|
||||
static AGG_INLINE value_type prelerp(value_type p, value_type q, value_type a)
|
||||
{
|
||||
return p + q - multiply(p, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a.
|
||||
|
@ -841,16 +882,17 @@ struct rgba16
|
|||
//--------------------------------------------------------------------
|
||||
AGG_INLINE self_type& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
if (a_ > 1)
|
||||
a = 1;
|
||||
if (a_ < 0) a = 0;
|
||||
if (a_ > 1) a = 1;
|
||||
a = value_type(uround(a_ * double(base_mask)));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return double(a) / double(base_mask); }
|
||||
double opacity() const
|
||||
{
|
||||
return double(a) / double(base_mask);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE self_type& premultiply()
|
||||
|
@ -981,6 +1023,7 @@ struct rgba16
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------rgba16_gamma_dir
|
||||
template<class GammaLUT>
|
||||
rgba16 rgba16_gamma_dir(rgba16 c, const GammaLUT& gamma)
|
||||
|
@ -1012,63 +1055,59 @@ struct rgba32
|
|||
rgba32() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32(value_type r_, value_type g_, value_type b_, value_type a_ = 1)
|
||||
: r(r_)
|
||||
, g(g_)
|
||||
, b(b_)
|
||||
, a(a_)
|
||||
{}
|
||||
rgba32(value_type r_, value_type g_, value_type b_, value_type a_= 1) :
|
||||
r(r_), g(g_), b(b_), a(a_) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32(const self_type& c, float a_)
|
||||
: r(c.r)
|
||||
, g(c.g)
|
||||
, b(c.b)
|
||||
, a(a_)
|
||||
{}
|
||||
rgba32(const self_type& c, float a_) :
|
||||
r(c.r), g(c.g), b(c.b), a(a_) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32(const rgba& c)
|
||||
: r(value_type(c.r))
|
||||
, g(value_type(c.g))
|
||||
, b(value_type(c.b))
|
||||
, a(value_type(c.a))
|
||||
{}
|
||||
rgba32(const rgba& c) :
|
||||
r(value_type(c.r)), g(value_type(c.g)), b(value_type(c.b)), a(value_type(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32(const rgba8& c)
|
||||
: r(value_type(c.r / 255.0))
|
||||
, g(value_type(c.g / 255.0))
|
||||
, b(value_type(c.b / 255.0))
|
||||
, a(value_type(c.a / 255.0))
|
||||
{}
|
||||
rgba32(const rgba8& c) :
|
||||
r(value_type(c.r / 255.0)),
|
||||
g(value_type(c.g / 255.0)),
|
||||
b(value_type(c.b / 255.0)),
|
||||
a(value_type(c.a / 255.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32(const srgba8& c)
|
||||
: r(sRGB_conv<value_type>::rgb_from_sRGB(c.r))
|
||||
, g(sRGB_conv<value_type>::rgb_from_sRGB(c.g))
|
||||
, b(sRGB_conv<value_type>::rgb_from_sRGB(c.b))
|
||||
, a(sRGB_conv<value_type>::alpha_from_sRGB(c.a))
|
||||
{}
|
||||
rgba32(const srgba8& c) :
|
||||
r(sRGB_conv<value_type>::rgb_from_sRGB(c.r)),
|
||||
g(sRGB_conv<value_type>::rgb_from_sRGB(c.g)),
|
||||
b(sRGB_conv<value_type>::rgb_from_sRGB(c.b)),
|
||||
a(sRGB_conv<value_type>::alpha_from_sRGB(c.a)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rgba32(const rgba16& c)
|
||||
: r(value_type(c.r / 65535.0))
|
||||
, g(value_type(c.g / 65535.0))
|
||||
, b(value_type(c.b / 65535.0))
|
||||
, a(value_type(c.a / 65535.0))
|
||||
{}
|
||||
rgba32(const rgba16& c) :
|
||||
r(value_type(c.r / 65535.0)),
|
||||
g(value_type(c.g / 65535.0)),
|
||||
b(value_type(c.b / 65535.0)),
|
||||
a(value_type(c.a / 65535.0)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba() const { return rgba(r, g, b, a); }
|
||||
operator rgba() const
|
||||
{
|
||||
return rgba(r, g, b, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator rgba8() const { return rgba8(uround(r * 255.0), uround(g * 255.0), uround(b * 255.0), uround(a * 255.0)); }
|
||||
operator rgba8() const
|
||||
{
|
||||
return rgba8(
|
||||
uround(r * 255.0),
|
||||
uround(g * 255.0),
|
||||
uround(b * 255.0),
|
||||
uround(a * 255.0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
operator srgba8() const
|
||||
{
|
||||
return srgba8(sRGB_conv<value_type>::rgb_to_sRGB(r),
|
||||
return srgba8(
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(r),
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(g),
|
||||
sRGB_conv<value_type>::rgb_to_sRGB(b),
|
||||
sRGB_conv<value_type>::alpha_to_sRGB(a));
|
||||
|
@ -1077,35 +1116,66 @@ struct rgba32
|
|||
//--------------------------------------------------------------------
|
||||
operator rgba16() const
|
||||
{
|
||||
return rgba8(uround(r * 65535.0), uround(g * 65535.0), uround(b * 65535.0), uround(a * 65535.0));
|
||||
return rgba8(
|
||||
uround(r * 65535.0),
|
||||
uround(g * 65535.0),
|
||||
uround(b * 65535.0),
|
||||
uround(a * 65535.0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE double to_double(value_type a) { return a; }
|
||||
static AGG_INLINE double to_double(value_type a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type from_double(double a) { return value_type(a); }
|
||||
static AGG_INLINE value_type from_double(double a)
|
||||
{
|
||||
return value_type(a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type empty_value() { return 0; }
|
||||
static AGG_INLINE value_type empty_value()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type full_value() { return 1; }
|
||||
static AGG_INLINE value_type full_value()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_transparent() const { return a <= 0; }
|
||||
AGG_INLINE bool is_transparent() const
|
||||
{
|
||||
return a <= 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE bool is_opaque() const { return a >= 1; }
|
||||
AGG_INLINE bool is_opaque() const
|
||||
{
|
||||
return a >= 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type invert(value_type x) { return 1 - x; }
|
||||
static AGG_INLINE value_type invert(value_type x)
|
||||
{
|
||||
return 1 - x;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type multiply(value_type a, value_type b) { return value_type(a * b); }
|
||||
static AGG_INLINE value_type multiply(value_type a, value_type b)
|
||||
{
|
||||
return value_type(a * b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE value_type demultiply(value_type a, value_type b) { return (b == 0) ? 0 : value_type(a / b); }
|
||||
static AGG_INLINE value_type demultiply(value_type a, value_type b)
|
||||
{
|
||||
return (b == 0) ? 0 : value_type(a / b);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<typename T>
|
||||
|
@ -1128,7 +1198,10 @@ struct rgba32
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b) { return cover_type(uround(a * b)); }
|
||||
static AGG_INLINE cover_type scale_cover(cover_type a, value_type b)
|
||||
{
|
||||
return cover_type(uround(a * b));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interpolate p to q by a, assuming q is premultiplied by a.
|
||||
|
@ -1165,17 +1238,17 @@ struct rgba32
|
|||
//--------------------------------------------------------------------
|
||||
AGG_INLINE self_type& opacity(double a_)
|
||||
{
|
||||
if (a_ < 0)
|
||||
a = 0;
|
||||
else if (a_ > 1)
|
||||
a = 1;
|
||||
else
|
||||
a = value_type(a_);
|
||||
if (a_ < 0) a = 0;
|
||||
else if (a_ > 1) a = 1;
|
||||
else a = value_type(a_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const { return a; }
|
||||
double opacity() const
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE self_type& premultiply()
|
||||
|
@ -1251,14 +1324,10 @@ struct rgba32
|
|||
b += mult_cover(c.b, cover);
|
||||
a += mult_cover(c.a, cover);
|
||||
}
|
||||
if (a > 1)
|
||||
a = 1;
|
||||
if (r > a)
|
||||
r = a;
|
||||
if (g > a)
|
||||
g = a;
|
||||
if (b > a)
|
||||
b = a;
|
||||
if (a > 1) a = 1;
|
||||
if (r > a) r = a;
|
||||
if (g > a) g = a;
|
||||
if (b > a) b = a;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -1288,6 +1357,8 @@ struct rgba32
|
|||
return self_type(rgba::from_wavelength(wl, gamma));
|
||||
}
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
1
deps/agg/include/agg_config.h
vendored
1
deps/agg/include/agg_config.h
vendored
|
@ -26,6 +26,7 @@
|
|||
// but it won't result any crash and the rest of the library will remain
|
||||
// fully functional.
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
// 2. Default rendering_buffer type. Can be:
|
||||
//
|
||||
|
|
31
deps/agg/include/agg_conv_adaptor_vcgen.h
vendored
31
deps/agg/include/agg_conv_adaptor_vcgen.h
vendored
|
@ -18,7 +18,8 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//------------------------------------------------------------null_markers
|
||||
struct null_markers
|
||||
{
|
||||
|
@ -31,16 +32,23 @@ struct null_markers
|
|||
unsigned type() const { return 0; }
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------conv_adaptor_vcgen
|
||||
template<class VertexSource, class Generator, class Markers = null_markers>
|
||||
class conv_adaptor_vcgen
|
||||
template<class VertexSource,
|
||||
class Generator,
|
||||
class Markers=null_markers> class conv_adaptor_vcgen
|
||||
{
|
||||
enum status { initial, accumulate, generate };
|
||||
enum status
|
||||
{
|
||||
initial,
|
||||
accumulate,
|
||||
generate
|
||||
};
|
||||
|
||||
public:
|
||||
explicit conv_adaptor_vcgen(VertexSource& source)
|
||||
: m_source(&source)
|
||||
, m_status(initial)
|
||||
explicit conv_adaptor_vcgen(VertexSource& source) :
|
||||
m_source(&source),
|
||||
m_status(initial)
|
||||
{}
|
||||
|
||||
conv_adaptor_vcgen(conv_adaptor_vcgen<VertexSource, Generator, Markers> &&) = default;
|
||||
|
@ -77,6 +85,10 @@ class conv_adaptor_vcgen
|
|||
double m_start_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource, class Generator, class Markers>
|
||||
unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(double* x, double* y)
|
||||
|
@ -93,8 +105,7 @@ unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(double* x,
|
|||
m_status = accumulate;
|
||||
|
||||
case accumulate:
|
||||
if (is_stop(m_last_cmd))
|
||||
return path_cmd_stop;
|
||||
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);
|
||||
|
@ -146,6 +157,6 @@ unsigned conv_adaptor_vcgen<VertexSource, Generator, Markers>::vertex(double* x,
|
|||
return cmd;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
32
deps/agg/include/agg_conv_adaptor_vpgen.h
vendored
32
deps/agg/include/agg_conv_adaptor_vpgen.h
vendored
|
@ -18,16 +18,14 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//======================================================conv_adaptor_vpgen
|
||||
template<class VertexSource, class VPGen>
|
||||
class conv_adaptor_vpgen
|
||||
template<class VertexSource, class VPGen> class conv_adaptor_vpgen
|
||||
{
|
||||
public:
|
||||
explicit conv_adaptor_vpgen(VertexSource& source)
|
||||
: m_source(&source)
|
||||
{}
|
||||
explicit conv_adaptor_vpgen(VertexSource& source) : m_source(&source) {}
|
||||
void attach(VertexSource& source) { m_source = &source; }
|
||||
|
||||
VPGen& vpgen() { return m_vpgen; }
|
||||
|
@ -39,7 +37,8 @@ class conv_adaptor_vpgen
|
|||
|
||||
private:
|
||||
conv_adaptor_vpgen(const conv_adaptor_vpgen<VertexSource, VPGen>&);
|
||||
const conv_adaptor_vpgen<VertexSource, VPGen>& operator=(const conv_adaptor_vpgen<VertexSource, VPGen>&);
|
||||
const conv_adaptor_vpgen<VertexSource, VPGen>&
|
||||
operator = (const conv_adaptor_vpgen<VertexSource, VPGen>&);
|
||||
|
||||
VertexSource* m_source;
|
||||
VPGen m_vpgen;
|
||||
|
@ -49,6 +48,8 @@ class conv_adaptor_vpgen
|
|||
int m_vertices;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource, class VPGen>
|
||||
void conv_adaptor_vpgen<VertexSource, VPGen>::rewind(unsigned path_id)
|
||||
|
@ -61,6 +62,7 @@ void conv_adaptor_vpgen<VertexSource, VPGen>::rewind(unsigned path_id)
|
|||
m_vertices = 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource, class VPGen>
|
||||
unsigned conv_adaptor_vpgen<VertexSource, VPGen>::vertex(double* x, double* y)
|
||||
|
@ -69,8 +71,7 @@ unsigned conv_adaptor_vpgen<VertexSource, VPGen>::vertex(double* x, double* y)
|
|||
for(;;)
|
||||
{
|
||||
cmd = m_vpgen.vertex(x, y);
|
||||
if (!is_stop(cmd))
|
||||
break;
|
||||
if(!is_stop(cmd)) break;
|
||||
|
||||
if(m_poly_flags && !m_vpgen.auto_unclose())
|
||||
{
|
||||
|
@ -102,7 +103,8 @@ unsigned conv_adaptor_vpgen<VertexSource, VPGen>::vertex(double* x, double* y)
|
|||
if(m_vpgen.auto_close() && m_vertices > 2)
|
||||
{
|
||||
m_vpgen.line_to(m_start_x, m_start_y);
|
||||
m_poly_flags = path_cmd_end_poly | static_cast<path_commands_e>(path_flags_close);
|
||||
m_poly_flags = path_cmd_end_poly
|
||||
| static_cast<path_commands_e>(path_flags_close);
|
||||
m_start_x = tx;
|
||||
m_start_y = ty;
|
||||
m_vertices = -1;
|
||||
|
@ -126,8 +128,7 @@ unsigned conv_adaptor_vpgen<VertexSource, VPGen>::vertex(double* x, double* y)
|
|||
m_poly_flags = cmd;
|
||||
if(is_closed(cmd) || m_vpgen.auto_close())
|
||||
{
|
||||
if (m_vpgen.auto_close())
|
||||
m_poly_flags |= path_flags_close;
|
||||
if(m_vpgen.auto_close()) m_poly_flags |= path_flags_close;
|
||||
if(m_vertices > 2)
|
||||
{
|
||||
m_vpgen.line_to(m_start_x, m_start_y);
|
||||
|
@ -141,7 +142,8 @@ unsigned conv_adaptor_vpgen<VertexSource, VPGen>::vertex(double* x, double* y)
|
|||
if(m_vpgen.auto_close() && m_vertices > 2)
|
||||
{
|
||||
m_vpgen.line_to(m_start_x, m_start_y);
|
||||
m_poly_flags = path_cmd_end_poly | static_cast<path_commands_e>(path_flags_close);
|
||||
m_poly_flags = path_cmd_end_poly
|
||||
| static_cast<path_commands_e>(path_flags_close);
|
||||
m_vertices = -2;
|
||||
continue;
|
||||
}
|
||||
|
@ -152,6 +154,8 @@ unsigned conv_adaptor_vpgen<VertexSource, VPGen>::vertex(double* x, double* y)
|
|||
return cmd;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
16
deps/agg/include/agg_conv_bspline.h
vendored
16
deps/agg/include/agg_conv_bspline.h
vendored
|
@ -19,7 +19,9 @@
|
|||
#include "agg_vcgen_bspline.h"
|
||||
#include "agg_conv_adaptor_vcgen.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//---------------------------------------------------------conv_bspline
|
||||
template<class VertexSource>
|
||||
|
@ -27,18 +29,20 @@ struct conv_bspline : public conv_adaptor_vcgen<VertexSource, vcgen_bspline>
|
|||
{
|
||||
typedef conv_adaptor_vcgen<VertexSource, vcgen_bspline> base_type;
|
||||
|
||||
conv_bspline(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, vcgen_bspline>(vs)
|
||||
{}
|
||||
conv_bspline(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, vcgen_bspline>(vs) {}
|
||||
|
||||
void interpolation_step(double v) { base_type::generator().interpolation_step(v); }
|
||||
double interpolation_step() const { return base_type::generator().interpolation_step(); }
|
||||
|
||||
private:
|
||||
conv_bspline(const conv_bspline<VertexSource>&);
|
||||
const conv_bspline<VertexSource>& operator=(const conv_bspline<VertexSource>&);
|
||||
const conv_bspline<VertexSource>&
|
||||
operator = (const conv_bspline<VertexSource>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
18
deps/agg/include/agg_conv_clip_polygon.h
vendored
18
deps/agg/include/agg_conv_clip_polygon.h
vendored
|
@ -30,7 +30,8 @@
|
|||
#include "agg_conv_adaptor_vpgen.h"
|
||||
#include "agg_vpgen_clip_polygon.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=======================================================conv_clip_polygon
|
||||
template<class VertexSource>
|
||||
|
@ -38,11 +39,13 @@ struct conv_clip_polygon : public conv_adaptor_vpgen<VertexSource, vpgen_clip_po
|
|||
{
|
||||
typedef conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon> base_type;
|
||||
|
||||
conv_clip_polygon(VertexSource& vs)
|
||||
: conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon>(vs)
|
||||
{}
|
||||
conv_clip_polygon(VertexSource& vs) :
|
||||
conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon>(vs) {}
|
||||
|
||||
void clip_box(double _x1, double _y1, double _x2, double _y2) { base_type::vpgen().clip_box(_x1, _y1, _x2, _y2); }
|
||||
void clip_box(double _x1, double _y1, double _x2, double _y2)
|
||||
{
|
||||
base_type::vpgen().clip_box(_x1, _y1, _x2, _y2);
|
||||
}
|
||||
|
||||
double x1() const { return base_type::vpgen().x1(); }
|
||||
double y1() const { return base_type::vpgen().y1(); }
|
||||
|
@ -52,9 +55,10 @@ struct conv_clip_polygon : public conv_adaptor_vpgen<VertexSource, vpgen_clip_po
|
|||
|
||||
private:
|
||||
conv_clip_polygon(const conv_clip_polygon<VertexSource>&);
|
||||
const conv_clip_polygon<VertexSource>& operator=(const conv_clip_polygon<VertexSource>&);
|
||||
const conv_clip_polygon<VertexSource>&
|
||||
operator = (const conv_clip_polygon<VertexSource>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
18
deps/agg/include/agg_conv_clip_polyline.h
vendored
18
deps/agg/include/agg_conv_clip_polyline.h
vendored
|
@ -30,7 +30,8 @@
|
|||
#include "agg_conv_adaptor_vpgen.h"
|
||||
#include "agg_vpgen_clip_polyline.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=======================================================conv_clip_polyline
|
||||
template<class VertexSource>
|
||||
|
@ -38,11 +39,13 @@ struct conv_clip_polyline : public conv_adaptor_vpgen<VertexSource, vpgen_clip_p
|
|||
{
|
||||
typedef conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline> base_type;
|
||||
|
||||
conv_clip_polyline(VertexSource& vs)
|
||||
: conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline>(vs)
|
||||
{}
|
||||
conv_clip_polyline(VertexSource& vs) :
|
||||
conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline>(vs) {}
|
||||
|
||||
void clip_box(double _x1, double _y1, double _x2, double _y2) { base_type::vpgen().clip_box(_x1, _y1, _x2, _y2); }
|
||||
void clip_box(double _x1, double _y1, double _x2, double _y2)
|
||||
{
|
||||
base_type::vpgen().clip_box(_x1, _y1, _x2, _y2);
|
||||
}
|
||||
|
||||
double x1() const { return base_type::vpgen().x1(); }
|
||||
double y1() const { return base_type::vpgen().y1(); }
|
||||
|
@ -52,9 +55,10 @@ struct conv_clip_polyline : public conv_adaptor_vpgen<VertexSource, vpgen_clip_p
|
|||
|
||||
private:
|
||||
conv_clip_polyline(const conv_clip_polyline<VertexSource>&);
|
||||
const conv_clip_polyline<VertexSource>& operator=(const conv_clip_polyline<VertexSource>&);
|
||||
const conv_clip_polyline<VertexSource>&
|
||||
operator = (const conv_clip_polyline<VertexSource>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
19
deps/agg/include/agg_conv_close_polygon.h
vendored
19
deps/agg/include/agg_conv_close_polygon.h
vendored
|
@ -18,16 +18,14 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//======================================================conv_close_polygon
|
||||
template<class VertexSource>
|
||||
class conv_close_polygon
|
||||
template<class VertexSource> class conv_close_polygon
|
||||
{
|
||||
public:
|
||||
explicit conv_close_polygon(VertexSource& vs)
|
||||
: m_source(&vs)
|
||||
{}
|
||||
explicit conv_close_polygon(VertexSource& vs) : m_source(&vs) {}
|
||||
void attach(VertexSource& source) { m_source = &source; }
|
||||
|
||||
void rewind(unsigned path_id);
|
||||
|
@ -35,7 +33,8 @@ class conv_close_polygon
|
|||
|
||||
private:
|
||||
conv_close_polygon(const conv_close_polygon<VertexSource>&);
|
||||
const conv_close_polygon<VertexSource>& operator=(const conv_close_polygon<VertexSource>&);
|
||||
const conv_close_polygon<VertexSource>&
|
||||
operator = (const conv_close_polygon<VertexSource>&);
|
||||
|
||||
VertexSource* m_source;
|
||||
unsigned m_cmd[2];
|
||||
|
@ -45,6 +44,8 @@ class conv_close_polygon
|
|||
bool m_line_to;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource>
|
||||
void conv_close_polygon<VertexSource>::rewind(unsigned path_id)
|
||||
|
@ -54,6 +55,8 @@ void conv_close_polygon<VertexSource>::rewind(unsigned path_id)
|
|||
m_line_to = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource>
|
||||
unsigned conv_close_polygon<VertexSource>::vertex(double* x, double* y)
|
||||
|
@ -117,6 +120,6 @@ unsigned conv_close_polygon<VertexSource>::vertex(double* x, double* y)
|
|||
return cmd;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
27
deps/agg/include/agg_conv_concat.h
vendored
27
deps/agg/include/agg_conv_concat.h
vendored
|
@ -18,22 +18,20 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//=============================================================conv_concat
|
||||
// Concatenation of two paths. Usually used to combine lines or curves
|
||||
// with markers such as arrowheads
|
||||
template<class VS1, class VS2>
|
||||
class conv_concat
|
||||
template<class VS1, class VS2> class conv_concat
|
||||
{
|
||||
public:
|
||||
conv_concat(VS1& source1, VS2& source2)
|
||||
: m_source1(&source1)
|
||||
, m_source2(&source2)
|
||||
, m_status(2)
|
||||
{}
|
||||
conv_concat(VS1& source1, VS2& source2) :
|
||||
m_source1(&source1), m_source2(&source2), m_status(2) {}
|
||||
void attach1(VS1& source) { m_source1 = &source; }
|
||||
void attach2(VS2& source) { m_source2 = &source; }
|
||||
|
||||
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
m_source1->rewind(path_id);
|
||||
|
@ -47,15 +45,13 @@ class conv_concat
|
|||
if(m_status == 0)
|
||||
{
|
||||
cmd = m_source1->vertex(x, y);
|
||||
if (!is_stop(cmd))
|
||||
return cmd;
|
||||
if(!is_stop(cmd)) return cmd;
|
||||
m_status = 1;
|
||||
}
|
||||
if(m_status == 1)
|
||||
{
|
||||
cmd = m_source2->vertex(x, y);
|
||||
if (!is_stop(cmd))
|
||||
return cmd;
|
||||
if(!is_stop(cmd)) return cmd;
|
||||
m_status = 2;
|
||||
}
|
||||
return path_cmd_stop;
|
||||
|
@ -63,12 +59,15 @@ class conv_concat
|
|||
|
||||
private:
|
||||
conv_concat(const conv_concat<VS1, VS2>&);
|
||||
const conv_concat<VS1, VS2>& operator=(const conv_concat<VS1, VS2>&);
|
||||
const conv_concat<VS1, VS2>&
|
||||
operator = (const conv_concat<VS1, VS2>&);
|
||||
|
||||
VS1* m_source1;
|
||||
VS2* m_source2;
|
||||
int m_status;
|
||||
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
15
deps/agg/include/agg_conv_contour.h
vendored
15
deps/agg/include/agg_conv_contour.h
vendored
|
@ -23,7 +23,8 @@
|
|||
#include "agg_vcgen_contour.h"
|
||||
#include "agg_conv_adaptor_vcgen.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------conv_contour
|
||||
template<class VertexSource>
|
||||
|
@ -31,9 +32,10 @@ struct conv_contour : public conv_adaptor_vcgen<VertexSource, vcgen_contour>
|
|||
{
|
||||
typedef conv_adaptor_vcgen<VertexSource, vcgen_contour> base_type;
|
||||
|
||||
conv_contour(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, vcgen_contour>(vs)
|
||||
{}
|
||||
conv_contour(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, vcgen_contour>(vs)
|
||||
{
|
||||
}
|
||||
|
||||
void line_join(line_join_e lj) { base_type::generator().line_join(lj); }
|
||||
void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); }
|
||||
|
@ -54,9 +56,10 @@ struct conv_contour : public conv_adaptor_vcgen<VertexSource, vcgen_contour>
|
|||
|
||||
private:
|
||||
conv_contour(const conv_contour<VertexSource>&);
|
||||
const conv_contour<VertexSource>& operator=(const conv_contour<VertexSource>&);
|
||||
const conv_contour<VertexSource>&
|
||||
operator = (const conv_contour<VertexSource>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
53
deps/agg/include/agg_conv_curve.h
vendored
53
deps/agg/include/agg_conv_curve.h
vendored
|
@ -23,7 +23,9 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_curves.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
|
||||
//---------------------------------------------------------------conv_curve
|
||||
// Curve converter class. Any path storage can have Bezier curves defined
|
||||
|
@ -49,19 +51,17 @@ namespace agg {
|
|||
// Class conv_curve recognizes commands path_cmd_curve3 and path_cmd_curve4
|
||||
// and converts these vertices into a move_to/line_to sequence.
|
||||
//-----------------------------------------------------------------------
|
||||
template<class VertexSource, class Curve3 = curve3, class Curve4 = curve4>
|
||||
class conv_curve
|
||||
template<class VertexSource,
|
||||
class Curve3=curve3,
|
||||
class Curve4=curve4> class conv_curve
|
||||
{
|
||||
public:
|
||||
typedef Curve3 curve3_type;
|
||||
typedef Curve4 curve4_type;
|
||||
typedef conv_curve<VertexSource, Curve3, Curve4> self_type;
|
||||
|
||||
explicit conv_curve(VertexSource& source)
|
||||
: m_source(&source)
|
||||
, m_last_x(0.0)
|
||||
, m_last_y(0.0)
|
||||
{}
|
||||
explicit conv_curve(VertexSource& source) :
|
||||
m_source(&source), m_last_x(0.0), m_last_y(0.0) {}
|
||||
|
||||
conv_curve(self_type &&) = default;
|
||||
|
||||
|
@ -73,7 +73,10 @@ class conv_curve
|
|||
m_curve4.approximation_method(v);
|
||||
}
|
||||
|
||||
curve_approximation_method_e approximation_method() const { return m_curve4.approximation_method(); }
|
||||
curve_approximation_method_e approximation_method() const
|
||||
{
|
||||
return m_curve4.approximation_method();
|
||||
}
|
||||
|
||||
void approximation_scale(double s)
|
||||
{
|
||||
|
@ -81,7 +84,10 @@ class conv_curve
|
|||
m_curve4.approximation_scale(s);
|
||||
}
|
||||
|
||||
double approximation_scale() const { return m_curve4.approximation_scale(); }
|
||||
double approximation_scale() const
|
||||
{
|
||||
return m_curve4.approximation_scale();
|
||||
}
|
||||
|
||||
void angle_tolerance(double v)
|
||||
{
|
||||
|
@ -89,7 +95,10 @@ class conv_curve
|
|||
m_curve4.angle_tolerance(v);
|
||||
}
|
||||
|
||||
double angle_tolerance() const { return m_curve4.angle_tolerance(); }
|
||||
double angle_tolerance() const
|
||||
{
|
||||
return m_curve4.angle_tolerance();
|
||||
}
|
||||
|
||||
void cusp_limit(double v)
|
||||
{
|
||||
|
@ -97,7 +106,10 @@ class conv_curve
|
|||
m_curve4.cusp_limit(v);
|
||||
}
|
||||
|
||||
double cusp_limit() const { return m_curve4.cusp_limit(); }
|
||||
double cusp_limit() const
|
||||
{
|
||||
return m_curve4.cusp_limit();
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
@ -113,6 +125,8 @@ class conv_curve
|
|||
curve4_type m_curve4;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource, class Curve3, class Curve4>
|
||||
void conv_curve<VertexSource, Curve3, Curve4>::rewind(unsigned path_id)
|
||||
|
@ -124,6 +138,7 @@ void conv_curve<VertexSource, Curve3, Curve4>::rewind(unsigned path_id)
|
|||
m_curve4.reset();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource, class Curve3, class Curve4>
|
||||
unsigned conv_curve<VertexSource, Curve3, Curve4>::vertex(double* x, double* y)
|
||||
|
@ -153,7 +168,9 @@ unsigned conv_curve<VertexSource, Curve3, Curve4>::vertex(double* x, double* y)
|
|||
case path_cmd_curve3:
|
||||
m_source->vertex(&end_x, &end_y);
|
||||
|
||||
m_curve3.init(m_last_x, m_last_y, *x, *y, end_x, end_y);
|
||||
m_curve3.init(m_last_x, m_last_y,
|
||||
*x, *y,
|
||||
end_x, end_y);
|
||||
|
||||
m_curve3.vertex(x, y); // First call returns path_cmd_move_to
|
||||
m_curve3.vertex(x, y); // This is the first vertex of the curve
|
||||
|
@ -164,7 +181,10 @@ unsigned conv_curve<VertexSource, Curve3, Curve4>::vertex(double* x, double* y)
|
|||
m_source->vertex(&ct2_x, &ct2_y);
|
||||
m_source->vertex(&end_x, &end_y);
|
||||
|
||||
m_curve4.init(m_last_x, m_last_y, *x, *y, ct2_x, ct2_y, end_x, end_y);
|
||||
m_curve4.init(m_last_x, m_last_y,
|
||||
*x, *y,
|
||||
ct2_x, ct2_y,
|
||||
end_x, end_y);
|
||||
|
||||
m_curve4.vertex(x, y); // First call returns path_cmd_move_to
|
||||
m_curve4.vertex(x, y); // This is the first vertex of the curve
|
||||
|
@ -176,6 +196,9 @@ unsigned conv_curve<VertexSource, Curve3, Curve4>::vertex(double* x, double* y)
|
|||
return cmd;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
31
deps/agg/include/agg_conv_dash.h
vendored
31
deps/agg/include/agg_conv_dash.h
vendored
|
@ -23,7 +23,8 @@
|
|||
#include "agg_vcgen_dash.h"
|
||||
#include "agg_conv_adaptor_vcgen.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//---------------------------------------------------------------conv_dash
|
||||
template<class VertexSource, class Markers=null_markers>
|
||||
|
@ -32,24 +33,36 @@ struct conv_dash : public conv_adaptor_vcgen<VertexSource, vcgen_dash, Markers>
|
|||
typedef Markers marker_type;
|
||||
typedef conv_adaptor_vcgen<VertexSource, vcgen_dash, Markers> base_type;
|
||||
|
||||
conv_dash(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, vcgen_dash, Markers>(vs)
|
||||
{}
|
||||
conv_dash(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, vcgen_dash, Markers>(vs)
|
||||
{
|
||||
}
|
||||
|
||||
void remove_all_dashes() { base_type::generator().remove_all_dashes(); }
|
||||
void remove_all_dashes()
|
||||
{
|
||||
base_type::generator().remove_all_dashes();
|
||||
}
|
||||
|
||||
void add_dash(double dash_len, double gap_len) { base_type::generator().add_dash(dash_len, gap_len); }
|
||||
void add_dash(double dash_len, double gap_len)
|
||||
{
|
||||
base_type::generator().add_dash(dash_len, gap_len);
|
||||
}
|
||||
|
||||
void dash_start(double ds) { base_type::generator().dash_start(ds); }
|
||||
void dash_start(double ds)
|
||||
{
|
||||
base_type::generator().dash_start(ds);
|
||||
}
|
||||
|
||||
void shorten(double s) { base_type::generator().shorten(s); }
|
||||
double shorten() const { return base_type::generator().shorten(); }
|
||||
|
||||
private:
|
||||
conv_dash(const conv_dash<VertexSource, Markers>&);
|
||||
const conv_dash<VertexSource, Markers>& operator=(const conv_dash<VertexSource, Markers>&);
|
||||
const conv_dash<VertexSource, Markers>&
|
||||
operator = (const conv_dash<VertexSource, Markers>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
101
deps/agg/include/agg_conv_gpc.h
vendored
101
deps/agg/include/agg_conv_gpc.h
vendored
|
@ -28,18 +28,32 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_array.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include "gpc.h"
|
||||
}
|
||||
|
||||
namespace agg {
|
||||
enum gpc_op_e { gpc_or, gpc_and, gpc_xor, gpc_a_minus_b, gpc_b_minus_a };
|
||||
namespace agg
|
||||
{
|
||||
enum gpc_op_e
|
||||
{
|
||||
gpc_or,
|
||||
gpc_and,
|
||||
gpc_xor,
|
||||
gpc_a_minus_b,
|
||||
gpc_b_minus_a
|
||||
};
|
||||
|
||||
|
||||
//================================================================conv_gpc
|
||||
template<class VSA, class VSB>
|
||||
class conv_gpc
|
||||
template<class VSA, class VSB> class conv_gpc
|
||||
{
|
||||
enum status { status_move_to, status_line_to, status_stop };
|
||||
enum status
|
||||
{
|
||||
status_move_to,
|
||||
status_line_to,
|
||||
status_stop
|
||||
};
|
||||
|
||||
struct contour_header_type
|
||||
{
|
||||
|
@ -51,20 +65,24 @@ class conv_gpc
|
|||
typedef pod_bvector<gpc_vertex, 8> vertex_array_type;
|
||||
typedef pod_bvector<contour_header_type, 6> contour_header_array_type;
|
||||
|
||||
|
||||
public:
|
||||
typedef VSA source_a_type;
|
||||
typedef VSB source_b_type;
|
||||
typedef conv_gpc<source_a_type, source_b_type> self_type;
|
||||
|
||||
~conv_gpc() { free_gpc_data(); }
|
||||
~conv_gpc()
|
||||
{
|
||||
free_gpc_data();
|
||||
}
|
||||
|
||||
conv_gpc(source_a_type& a, source_b_type& b, gpc_op_e op = gpc_or)
|
||||
: m_src_a(&a)
|
||||
, m_src_b(&b)
|
||||
, m_status(status_move_to)
|
||||
, m_vertex(-1)
|
||||
, m_contour(-1)
|
||||
, m_operation(op)
|
||||
conv_gpc(source_a_type& a, source_b_type& b, gpc_op_e op = gpc_or) :
|
||||
m_src_a(&a),
|
||||
m_src_b(&b),
|
||||
m_status(status_move_to),
|
||||
m_vertex(-1),
|
||||
m_contour(-1),
|
||||
m_operation(op)
|
||||
{
|
||||
memset(&m_poly_a, 0, sizeof(m_poly_a));
|
||||
memset(&m_poly_b, 0, sizeof(m_poly_b));
|
||||
|
@ -96,9 +114,9 @@ class conv_gpc
|
|||
bool next_contour();
|
||||
bool next_vertex(double* x, double* y);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class VS>
|
||||
void add(VS& src, gpc_polygon& p)
|
||||
template<class VS> void add(VS& src, gpc_polygon& p)
|
||||
{
|
||||
unsigned cmd;
|
||||
double x, y;
|
||||
|
@ -146,6 +164,7 @@ class conv_gpc
|
|||
make_polygon(p);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
source_a_type* m_src_a;
|
||||
|
@ -161,6 +180,10 @@ class conv_gpc
|
|||
gpc_polygon m_result;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::free_polygon(gpc_polygon& p)
|
||||
|
@ -168,12 +191,14 @@ void conv_gpc<VSA, VSB>::free_polygon(gpc_polygon& p)
|
|||
int i;
|
||||
for(i = 0; i < p.num_contours; i++)
|
||||
{
|
||||
pod_allocator<gpc_vertex>::deallocate(p.contour[i].vertex, p.contour[i].num_vertices);
|
||||
pod_allocator<gpc_vertex>::deallocate(p.contour[i].vertex,
|
||||
p.contour[i].num_vertices);
|
||||
}
|
||||
pod_allocator<gpc_vertex_list>::deallocate(p.contour, p.num_contours);
|
||||
memset(&p, 0, sizeof(gpc_polygon));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::free_result()
|
||||
|
@ -185,6 +210,7 @@ void conv_gpc<VSA, VSB>::free_result()
|
|||
memset(&m_result, 0, sizeof(m_result));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::free_gpc_data()
|
||||
|
@ -194,6 +220,7 @@ void conv_gpc<VSA, VSB>::free_gpc_data()
|
|||
free_result();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::start_contour()
|
||||
|
@ -204,6 +231,7 @@ void conv_gpc<VSA, VSB>::start_contour()
|
|||
m_vertex_accumulator.remove_all();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
inline void conv_gpc<VSA, VSB>::add_vertex(double x, double y)
|
||||
|
@ -214,6 +242,7 @@ inline void conv_gpc<VSA, VSB>::add_vertex(double x, double y)
|
|||
m_vertex_accumulator.add(v);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::end_contour(unsigned orientation)
|
||||
|
@ -222,7 +251,8 @@ void conv_gpc<VSA, VSB>::end_contour(unsigned orientation)
|
|||
{
|
||||
if(m_vertex_accumulator.size() > 2)
|
||||
{
|
||||
contour_header_type& h = m_contour_accumulator[m_contour_accumulator.size() - 1];
|
||||
contour_header_type& h =
|
||||
m_contour_accumulator[m_contour_accumulator.size() - 1];
|
||||
|
||||
h.num_vertices = m_vertex_accumulator.size();
|
||||
h.hole_flag = 0;
|
||||
|
@ -248,6 +278,7 @@ void conv_gpc<VSA, VSB>::end_contour(unsigned orientation)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::make_polygon(gpc_polygon& p)
|
||||
|
@ -272,6 +303,7 @@ void conv_gpc<VSA, VSB>::make_polygon(gpc_polygon& p)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::start_extracting()
|
||||
|
@ -281,6 +313,7 @@ void conv_gpc<VSA, VSB>::start_extracting()
|
|||
m_vertex = -1;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
bool conv_gpc<VSA, VSB>::next_contour()
|
||||
|
@ -293,6 +326,7 @@ bool conv_gpc<VSA, VSB>::next_contour()
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
inline bool conv_gpc<VSA, VSB>::next_vertex(double* x, double* y)
|
||||
|
@ -308,6 +342,7 @@ inline bool conv_gpc<VSA, VSB>::next_vertex(double* x, double* y)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
void conv_gpc<VSA, VSB>::rewind(unsigned path_id)
|
||||
|
@ -320,28 +355,44 @@ void conv_gpc<VSA, VSB>::rewind(unsigned path_id)
|
|||
switch(m_operation)
|
||||
{
|
||||
case gpc_or:
|
||||
gpc_polygon_clip(GPC_UNION, &m_poly_a, &m_poly_b, &m_result);
|
||||
gpc_polygon_clip(GPC_UNION,
|
||||
&m_poly_a,
|
||||
&m_poly_b,
|
||||
&m_result);
|
||||
break;
|
||||
|
||||
case gpc_and:
|
||||
gpc_polygon_clip(GPC_INT, &m_poly_a, &m_poly_b, &m_result);
|
||||
gpc_polygon_clip(GPC_INT,
|
||||
&m_poly_a,
|
||||
&m_poly_b,
|
||||
&m_result);
|
||||
break;
|
||||
|
||||
case gpc_xor:
|
||||
gpc_polygon_clip(GPC_XOR, &m_poly_a, &m_poly_b, &m_result);
|
||||
gpc_polygon_clip(GPC_XOR,
|
||||
&m_poly_a,
|
||||
&m_poly_b,
|
||||
&m_result);
|
||||
break;
|
||||
|
||||
case gpc_a_minus_b:
|
||||
gpc_polygon_clip(GPC_DIFF, &m_poly_a, &m_poly_b, &m_result);
|
||||
gpc_polygon_clip(GPC_DIFF,
|
||||
&m_poly_a,
|
||||
&m_poly_b,
|
||||
&m_result);
|
||||
break;
|
||||
|
||||
case gpc_b_minus_a:
|
||||
gpc_polygon_clip(GPC_DIFF, &m_poly_b, &m_poly_a, &m_result);
|
||||
gpc_polygon_clip(GPC_DIFF,
|
||||
&m_poly_b,
|
||||
&m_poly_a,
|
||||
&m_result);
|
||||
break;
|
||||
}
|
||||
start_extracting();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VSA, class VSB>
|
||||
unsigned conv_gpc<VSA, VSB>::vertex(double* x, double* y)
|
||||
|
@ -374,6 +425,8 @@ unsigned conv_gpc<VSA, VSB>::vertex(double* x, double* y)
|
|||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
36
deps/agg/include/agg_conv_marker.h
vendored
36
deps/agg/include/agg_conv_marker.h
vendored
|
@ -22,7 +22,8 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//-------------------------------------------------------------conv_marker
|
||||
template<class MarkerLocator, class MarkerShapes>
|
||||
class conv_marker
|
||||
|
@ -38,9 +39,16 @@ class conv_marker
|
|||
|
||||
private:
|
||||
conv_marker(const conv_marker<MarkerLocator, MarkerShapes>&);
|
||||
const conv_marker<MarkerLocator, MarkerShapes>& operator=(const conv_marker<MarkerLocator, MarkerShapes>&);
|
||||
const conv_marker<MarkerLocator, MarkerShapes>&
|
||||
operator = (const conv_marker<MarkerLocator, MarkerShapes>&);
|
||||
|
||||
enum status_e { initial, markers, polygon, stop };
|
||||
enum status_e
|
||||
{
|
||||
initial,
|
||||
markers,
|
||||
polygon,
|
||||
stop
|
||||
};
|
||||
|
||||
MarkerLocator* m_marker_locator;
|
||||
MarkerShapes* m_marker_shapes;
|
||||
|
@ -51,15 +59,18 @@ class conv_marker
|
|||
unsigned m_num_markers;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class MarkerLocator, class MarkerShapes>
|
||||
conv_marker<MarkerLocator, MarkerShapes>::conv_marker(MarkerLocator& ml, MarkerShapes& ms)
|
||||
: m_marker_locator(&ml)
|
||||
, m_marker_shapes(&ms)
|
||||
, m_status(initial)
|
||||
, m_marker(0)
|
||||
, m_num_markers(1)
|
||||
{}
|
||||
conv_marker<MarkerLocator, MarkerShapes>::conv_marker(MarkerLocator& ml, MarkerShapes& ms) :
|
||||
m_marker_locator(&ml),
|
||||
m_marker_shapes(&ms),
|
||||
m_status(initial),
|
||||
m_marker(0),
|
||||
m_num_markers(1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class MarkerLocator, class MarkerShapes>
|
||||
|
@ -70,6 +81,7 @@ void conv_marker<MarkerLocator, MarkerShapes>::rewind(unsigned)
|
|||
m_num_markers = 1;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class MarkerLocator, class MarkerShapes>
|
||||
unsigned conv_marker<MarkerLocator, MarkerShapes>::vertex(double* x, double* y)
|
||||
|
@ -129,6 +141,8 @@ unsigned conv_marker<MarkerLocator, MarkerShapes>::vertex(double* x, double* y)
|
|||
return cmd;
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
19
deps/agg/include/agg_conv_marker_adaptor.h
vendored
19
deps/agg/include/agg_conv_marker_adaptor.h
vendored
|
@ -20,27 +20,32 @@
|
|||
#include "agg_conv_adaptor_vcgen.h"
|
||||
#include "agg_vcgen_vertex_sequence.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=====================================================conv_marker_adaptor
|
||||
template<class VertexSource, class Markers=null_markers>
|
||||
struct conv_marker_adaptor : public conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence, Markers>
|
||||
struct conv_marker_adaptor :
|
||||
public conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence, Markers>
|
||||
{
|
||||
typedef Markers marker_type;
|
||||
typedef conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence, Markers> base_type;
|
||||
|
||||
conv_marker_adaptor(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence, Markers>(vs)
|
||||
{}
|
||||
conv_marker_adaptor(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence, Markers>(vs)
|
||||
{
|
||||
}
|
||||
|
||||
void shorten(double s) { base_type::generator().shorten(s); }
|
||||
double shorten() const { return base_type::generator().shorten(); }
|
||||
|
||||
private:
|
||||
conv_marker_adaptor(const conv_marker_adaptor<VertexSource, Markers>&);
|
||||
const conv_marker_adaptor<VertexSource, Markers>& operator=(const conv_marker_adaptor<VertexSource, Markers>&);
|
||||
const conv_marker_adaptor<VertexSource, Markers>&
|
||||
operator = (const conv_marker_adaptor<VertexSource, Markers>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
59
deps/agg/include/agg_conv_offset.h
vendored
59
deps/agg/include/agg_conv_offset.h
vendored
|
@ -22,10 +22,10 @@
|
|||
#include "agg_array.h"
|
||||
#include "clipper.hpp"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
template<class VSA>
|
||||
class conv_offset
|
||||
template<class VSA> class conv_offset
|
||||
{
|
||||
enum status { status_move_to, status_line_to, status_stop };
|
||||
typedef VSA source_a_type;
|
||||
|
@ -45,30 +45,36 @@ class conv_offset
|
|||
|
||||
int Round(double val)
|
||||
{
|
||||
if ((val < 0))
|
||||
return (int)(val - 0.5);
|
||||
else
|
||||
return (int)(val + 0.5);
|
||||
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
|
||||
}
|
||||
|
||||
public:
|
||||
conv_offset(source_a_type& a, double offset = 0.0, int scaling_factor = 0)
|
||||
: m_src_a(&a)
|
||||
, m_offset(offset)
|
||||
, m_status(status_move_to)
|
||||
, m_vertex(-1)
|
||||
, m_contour(-1)
|
||||
conv_offset(source_a_type &a, double offset = 0.0,
|
||||
int scaling_factor = 0)
|
||||
: m_src_a(&a),
|
||||
m_offset(offset),
|
||||
m_status(status_move_to),
|
||||
m_vertex(-1),
|
||||
m_contour(-1)
|
||||
{
|
||||
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
|
||||
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
|
||||
}
|
||||
|
||||
~conv_offset() {}
|
||||
~conv_offset()
|
||||
{
|
||||
}
|
||||
|
||||
void set_offset(double offset) { m_offset = offset;}
|
||||
unsigned type() const { return static_cast<unsigned>(m_src_a->type()); }
|
||||
unsigned type() const
|
||||
{
|
||||
return static_cast<unsigned>(m_src_a->type());
|
||||
}
|
||||
|
||||
double get_offset() const { return m_offset; }
|
||||
double get_offset() const
|
||||
{
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
@ -79,14 +85,10 @@ class conv_offset
|
|||
void add_vertex_(double &x, double &y);
|
||||
void end_contour(ClipperLib::Paths &p);
|
||||
|
||||
template<class VS>
|
||||
void add(VS& src, ClipperLib::Paths& p)
|
||||
template<class VS> void add(VS &src, ClipperLib::Paths &p)
|
||||
{
|
||||
unsigned cmd;
|
||||
double x;
|
||||
double y;
|
||||
double start_x;
|
||||
double start_y;
|
||||
double x; double y; double start_x; double start_y;
|
||||
bool starting_first_line;
|
||||
|
||||
start_x = 0.0;
|
||||
|
@ -101,8 +103,7 @@ class conv_offset
|
|||
{
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
if (!starting_first_line)
|
||||
end_contour(p);
|
||||
if(!starting_first_line ) end_contour(p);
|
||||
start_x = x;
|
||||
start_y = y;
|
||||
}
|
||||
|
@ -152,8 +153,7 @@ void conv_offset<VSA>::end_contour(ClipperLib::Paths& p)
|
|||
{
|
||||
unsigned i, len;
|
||||
|
||||
if (m_vertex_accumulator.size() < 3)
|
||||
return;
|
||||
if( m_vertex_accumulator.size() < 3 ) return;
|
||||
len = p.size();
|
||||
p.resize(len+1);
|
||||
p[len].resize(m_vertex_accumulator.size());
|
||||
|
@ -178,8 +178,7 @@ template<class VSA>
|
|||
bool conv_offset<VSA>::next_contour()
|
||||
{
|
||||
m_contour++;
|
||||
if (m_contour >= (int)m_result.size())
|
||||
return false;
|
||||
if(m_contour >= (int)m_result.size()) return false;
|
||||
m_vertex =-1;
|
||||
return true;
|
||||
}
|
||||
|
@ -189,8 +188,7 @@ template<class VSA>
|
|||
bool conv_offset<VSA>::next_vertex(double *x, double *y)
|
||||
{
|
||||
m_vertex++;
|
||||
if (m_vertex >= (int)m_result[m_contour].size())
|
||||
return false;
|
||||
if(m_vertex >= (int)m_result[m_contour].size()) return false;
|
||||
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
|
||||
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
|
||||
return true;
|
||||
|
@ -233,5 +231,6 @@ unsigned conv_offset<VSA>::vertex(double* x, double* y)
|
|||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
} //namespace agg
|
||||
#endif //AGG_CONV_OFFSET_INCLUDED
|
||||
|
|
15
deps/agg/include/agg_conv_segmentator.h
vendored
15
deps/agg/include/agg_conv_segmentator.h
vendored
|
@ -20,7 +20,8 @@
|
|||
#include "agg_conv_adaptor_vpgen.h"
|
||||
#include "agg_vpgen_segmentator.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//========================================================conv_segmentator
|
||||
template<class VertexSource>
|
||||
|
@ -28,18 +29,20 @@ struct conv_segmentator : public conv_adaptor_vpgen<VertexSource, vpgen_segmenta
|
|||
{
|
||||
typedef conv_adaptor_vpgen<VertexSource, vpgen_segmentator> base_type;
|
||||
|
||||
conv_segmentator(VertexSource& vs)
|
||||
: conv_adaptor_vpgen<VertexSource, vpgen_segmentator>(vs)
|
||||
{}
|
||||
conv_segmentator(VertexSource& vs) :
|
||||
conv_adaptor_vpgen<VertexSource, vpgen_segmentator>(vs) {}
|
||||
|
||||
void approximation_scale(double s) { base_type::vpgen().approximation_scale(s); }
|
||||
double approximation_scale() const { return base_type::vpgen().approximation_scale(); }
|
||||
|
||||
private:
|
||||
conv_segmentator(const conv_segmentator<VertexSource>&);
|
||||
const conv_segmentator<VertexSource>& operator=(const conv_segmentator<VertexSource>&);
|
||||
const conv_segmentator<VertexSource>&
|
||||
operator = (const conv_segmentator<VertexSource>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
20
deps/agg/include/agg_conv_shorten_path.h
vendored
20
deps/agg/include/agg_conv_shorten_path.h
vendored
|
@ -20,27 +20,31 @@
|
|||
#include "agg_conv_adaptor_vcgen.h"
|
||||
#include "agg_vcgen_vertex_sequence.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=======================================================conv_shorten_path
|
||||
template<class VertexSource>
|
||||
class conv_shorten_path : public conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence>
|
||||
template<class VertexSource> class conv_shorten_path :
|
||||
public conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence>
|
||||
{
|
||||
public:
|
||||
typedef conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence> base_type;
|
||||
|
||||
conv_shorten_path(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence>(vs)
|
||||
{}
|
||||
conv_shorten_path(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, vcgen_vertex_sequence>(vs)
|
||||
{
|
||||
}
|
||||
|
||||
void shorten(double s) { base_type::generator().shorten(s); }
|
||||
double shorten() const { return base_type::generator().shorten(); }
|
||||
|
||||
private:
|
||||
conv_shorten_path(const conv_shorten_path<VertexSource>&);
|
||||
const conv_shorten_path<VertexSource>& operator=(const conv_shorten_path<VertexSource>&);
|
||||
const conv_shorten_path<VertexSource>&
|
||||
operator = (const conv_shorten_path<VertexSource>&);
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
36
deps/agg/include/agg_conv_smooth_poly1.h
vendored
36
deps/agg/include/agg_conv_smooth_poly1.h
vendored
|
@ -24,17 +24,21 @@
|
|||
#include "agg_conv_adaptor_vcgen.h"
|
||||
#include "agg_conv_curve.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-------------------------------------------------------conv_smooth
|
||||
template<class VertexSource, class VertexGenerator>
|
||||
struct conv_smooth : public conv_adaptor_vcgen<VertexSource, VertexGenerator>
|
||||
struct conv_smooth :
|
||||
public conv_adaptor_vcgen<VertexSource, VertexGenerator>
|
||||
{
|
||||
typedef conv_adaptor_vcgen<VertexSource, VertexGenerator> base_type;
|
||||
|
||||
conv_smooth(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, VertexGenerator>(vs)
|
||||
{}
|
||||
conv_smooth(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, VertexGenerator>(vs)
|
||||
{
|
||||
}
|
||||
|
||||
conv_smooth(conv_smooth<VertexSource, VertexGenerator> &&) = default;
|
||||
|
||||
|
@ -52,16 +56,18 @@ using conv_smooth_poly1 = conv_smooth<VertexSource, vcgen_smooth_poly1>;
|
|||
|
||||
//-------------------------------------------------conv_smooth_curve
|
||||
template<class VertexSource, class VertexGenerator>
|
||||
struct conv_smooth_curve : public conv_curve<conv_smooth<VertexSource, VertexGenerator>>
|
||||
struct conv_smooth_curve :
|
||||
public conv_curve<conv_smooth<VertexSource, VertexGenerator>>
|
||||
{
|
||||
conv_smooth_curve(VertexSource& vs)
|
||||
: conv_curve<conv_smooth<VertexSource, VertexGenerator>>(m_smooth)
|
||||
, m_smooth(vs)
|
||||
{}
|
||||
conv_smooth_curve(VertexSource& vs) :
|
||||
conv_curve<conv_smooth<VertexSource, VertexGenerator>>(m_smooth),
|
||||
m_smooth(vs)
|
||||
{
|
||||
}
|
||||
|
||||
conv_smooth_curve(conv_smooth_curve<VertexSource, VertexGenerator>&& rhs)
|
||||
: conv_curve<conv_smooth<VertexSource, VertexGenerator>>(std::move(rhs))
|
||||
, m_smooth(std::move(rhs.m_smooth))
|
||||
conv_smooth_curve(conv_smooth_curve<VertexSource, VertexGenerator> && rhs) :
|
||||
conv_curve<conv_smooth<VertexSource, VertexGenerator>>(std::move(rhs)),
|
||||
m_smooth(std::move(rhs.m_smooth))
|
||||
{
|
||||
this->attach(m_smooth);
|
||||
}
|
||||
|
@ -80,6 +86,8 @@ struct conv_smooth_curve : public conv_curve<conv_smooth<VertexSource, VertexGen
|
|||
|
||||
template<class VertexSource>
|
||||
using conv_smooth_poly1_curve = conv_smooth_curve<VertexSource, vcgen_smooth_poly1>;
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
19
deps/agg/include/agg_conv_stroke.h
vendored
19
deps/agg/include/agg_conv_stroke.h
vendored
|
@ -23,18 +23,21 @@
|
|||
#include "agg_vcgen_stroke.h"
|
||||
#include "agg_conv_adaptor_vcgen.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-------------------------------------------------------------conv_stroke
|
||||
template<class VertexSource, class Markers=null_markers>
|
||||
struct conv_stroke : public conv_adaptor_vcgen<VertexSource, vcgen_stroke, Markers>
|
||||
struct conv_stroke :
|
||||
public conv_adaptor_vcgen<VertexSource, vcgen_stroke, Markers>
|
||||
{
|
||||
typedef Markers marker_type;
|
||||
typedef conv_adaptor_vcgen<VertexSource, vcgen_stroke, Markers> base_type;
|
||||
|
||||
conv_stroke(VertexSource& vs)
|
||||
: conv_adaptor_vcgen<VertexSource, vcgen_stroke, Markers>(vs)
|
||||
{}
|
||||
conv_stroke(VertexSource& vs) :
|
||||
conv_adaptor_vcgen<VertexSource, vcgen_stroke, Markers>(vs)
|
||||
{
|
||||
}
|
||||
|
||||
void line_cap(line_cap_e lc) { base_type::generator().line_cap(lc); }
|
||||
void line_join(line_join_e lj) { base_type::generator().line_join(lj); }
|
||||
|
@ -60,9 +63,11 @@ struct conv_stroke : public conv_adaptor_vcgen<VertexSource, vcgen_stroke, Marke
|
|||
|
||||
private:
|
||||
conv_stroke(const conv_stroke<VertexSource, Markers>&);
|
||||
const conv_stroke<VertexSource, Markers>& operator=(const conv_stroke<VertexSource, Markers>&);
|
||||
const conv_stroke<VertexSource, Markers>&
|
||||
operator = (const conv_stroke<VertexSource, Markers>&);
|
||||
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
28
deps/agg/include/agg_conv_transform.h
vendored
28
deps/agg/include/agg_conv_transform.h
vendored
|
@ -22,21 +22,22 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//----------------------------------------------------------conv_transform
|
||||
template<class VertexSource, class Transformer = trans_affine>
|
||||
class conv_transform
|
||||
template<class VertexSource, class Transformer=trans_affine> class conv_transform
|
||||
{
|
||||
public:
|
||||
conv_transform(VertexSource& source, Transformer& tr)
|
||||
: m_source(&source)
|
||||
, m_trans(&tr)
|
||||
{}
|
||||
conv_transform(VertexSource& source, Transformer& tr) :
|
||||
m_source(&source), m_trans(&tr) {}
|
||||
|
||||
void attach(VertexSource& source) { m_source = &source; }
|
||||
|
||||
void rewind(unsigned path_id) { m_source->rewind(path_id); }
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
m_source->rewind(path_id);
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
|
@ -48,18 +49,23 @@ class conv_transform
|
|||
return cmd;
|
||||
}
|
||||
|
||||
void transformer(Transformer& tr) { m_trans = &tr; }
|
||||
void transformer(Transformer& tr)
|
||||
{
|
||||
m_trans = &tr;
|
||||
}
|
||||
|
||||
unsigned type() const { return m_source->type(); }
|
||||
|
||||
private:
|
||||
conv_transform(const conv_transform<VertexSource>&);
|
||||
const conv_transform<VertexSource>& operator=(const conv_transform<VertexSource>&);
|
||||
const conv_transform<VertexSource>&
|
||||
operator = (const conv_transform<VertexSource>&);
|
||||
|
||||
VertexSource* m_source;
|
||||
const Transformer* m_trans;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
23
deps/agg/include/agg_conv_unclose_polygon.h
vendored
23
deps/agg/include/agg_conv_unclose_polygon.h
vendored
|
@ -18,34 +18,35 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//====================================================conv_unclose_polygon
|
||||
template<class VertexSource>
|
||||
class conv_unclose_polygon
|
||||
template<class VertexSource> class conv_unclose_polygon
|
||||
{
|
||||
public:
|
||||
explicit conv_unclose_polygon(VertexSource& vs)
|
||||
: m_source(&vs)
|
||||
{}
|
||||
explicit conv_unclose_polygon(VertexSource& vs) : m_source(&vs) {}
|
||||
void attach(VertexSource& source) { m_source = &source; }
|
||||
|
||||
void rewind(unsigned path_id) { m_source->rewind(path_id); }
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
m_source->rewind(path_id);
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
unsigned cmd = m_source->vertex(x, y);
|
||||
if (is_end_poly(cmd))
|
||||
cmd &= ~path_flags_close;
|
||||
if(is_end_poly(cmd)) cmd &= ~path_flags_close;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private:
|
||||
conv_unclose_polygon(const conv_unclose_polygon<VertexSource>&);
|
||||
const conv_unclose_polygon<VertexSource>& operator=(const conv_unclose_polygon<VertexSource>&);
|
||||
const conv_unclose_polygon<VertexSource>&
|
||||
operator = (const conv_unclose_polygon<VertexSource>&);
|
||||
|
||||
VertexSource* m_source;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
424
deps/agg/include/agg_curves.h
vendored
424
deps/agg/include/agg_curves.h
vendored
|
@ -21,37 +21,37 @@
|
|||
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
// See Implementation agg_curves.cpp
|
||||
|
||||
//--------------------------------------------curve_approximation_method_e
|
||||
enum curve_approximation_method_e { curve_inc, curve_div };
|
||||
enum curve_approximation_method_e
|
||||
{
|
||||
curve_inc,
|
||||
curve_div
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------curve3_inc
|
||||
class MAPNIK_DECL curve3_inc
|
||||
{
|
||||
public:
|
||||
curve3_inc()
|
||||
: m_num_steps(0)
|
||||
, m_step(0)
|
||||
, m_scale(1.0)
|
||||
{}
|
||||
curve3_inc() :
|
||||
m_num_steps(0), m_step(0), m_scale(1.0) { }
|
||||
|
||||
curve3_inc(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
: m_num_steps(0)
|
||||
, m_step(0)
|
||||
, m_scale(1.0)
|
||||
curve3_inc(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3) :
|
||||
m_num_steps(0), m_step(0), m_scale(1.0)
|
||||
{
|
||||
init(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
m_num_steps = 0;
|
||||
m_step = -1;
|
||||
}
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
void reset() { m_num_steps = 0; m_step = -1; }
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3);
|
||||
|
||||
void approximation_method(curve_approximation_method_e) {}
|
||||
curve_approximation_method_e approximation_method() const { return curve_inc; }
|
||||
|
@ -88,30 +88,34 @@ class MAPNIK_DECL curve3_inc
|
|||
double m_saved_dfy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------curve3_div
|
||||
class MAPNIK_DECL curve3_div
|
||||
{
|
||||
public:
|
||||
curve3_div()
|
||||
: m_approximation_scale(1.0)
|
||||
, m_angle_tolerance(0.0)
|
||||
, m_count(0)
|
||||
curve3_div() :
|
||||
m_approximation_scale(1.0),
|
||||
m_angle_tolerance(0.0),
|
||||
m_count(0)
|
||||
{}
|
||||
|
||||
curve3_div(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
: m_approximation_scale(1.0)
|
||||
, m_angle_tolerance(0.0)
|
||||
, m_count(0)
|
||||
curve3_div(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3) :
|
||||
m_approximation_scale(1.0),
|
||||
m_angle_tolerance(0.0),
|
||||
m_count(0)
|
||||
{
|
||||
init(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
m_points.remove_all();
|
||||
m_count = 0;
|
||||
}
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
void reset() { m_points.remove_all(); m_count = 0; }
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3);
|
||||
|
||||
void approximation_method(curve_approximation_method_e) {}
|
||||
curve_approximation_method_e approximation_method() const { return curve_div; }
|
||||
|
@ -125,12 +129,14 @@ class MAPNIK_DECL curve3_div
|
|||
void cusp_limit(double) {}
|
||||
double cusp_limit() const { return 0.0; }
|
||||
|
||||
void rewind(unsigned) { m_count = 0; }
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
if (m_count >= m_points.size())
|
||||
return path_cmd_stop;
|
||||
if(m_count >= m_points.size()) return path_cmd_stop;
|
||||
const point_d& p = m_points[m_count++];
|
||||
*x = p.x;
|
||||
*y = p.y;
|
||||
|
@ -138,8 +144,13 @@ class MAPNIK_DECL curve3_div
|
|||
}
|
||||
|
||||
private:
|
||||
void bezier(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
void recursive_bezier(double x1, double y1, double x2, double y2, double x3, double y3, unsigned level);
|
||||
void bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3);
|
||||
void recursive_bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
unsigned level);
|
||||
|
||||
double m_approximation_scale;
|
||||
double m_distance_tolerance_square;
|
||||
|
@ -148,71 +159,71 @@ class MAPNIK_DECL curve3_div
|
|||
pod_bvector<point_d> m_points;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------curve4_points
|
||||
struct MAPNIK_DECL curve4_points
|
||||
{
|
||||
double cp[8];
|
||||
curve4_points() {}
|
||||
curve4_points(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
curve4_points(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4)
|
||||
{
|
||||
cp[0] = x1;
|
||||
cp[1] = y1;
|
||||
cp[2] = x2;
|
||||
cp[3] = y2;
|
||||
cp[4] = x3;
|
||||
cp[5] = y3;
|
||||
cp[6] = x4;
|
||||
cp[7] = y4;
|
||||
cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2;
|
||||
cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4;
|
||||
}
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4)
|
||||
{
|
||||
cp[0] = x1;
|
||||
cp[1] = y1;
|
||||
cp[2] = x2;
|
||||
cp[3] = y2;
|
||||
cp[4] = x3;
|
||||
cp[5] = y3;
|
||||
cp[6] = x4;
|
||||
cp[7] = y4;
|
||||
cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2;
|
||||
cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4;
|
||||
}
|
||||
double operator [] (unsigned i) const { return cp[i]; }
|
||||
double& operator [] (unsigned i) { return cp[i]; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------curve4_inc
|
||||
class MAPNIK_DECL curve4_inc
|
||||
{
|
||||
public:
|
||||
curve4_inc()
|
||||
: m_num_steps(0)
|
||||
, m_step(0)
|
||||
, m_scale(1.0)
|
||||
{}
|
||||
curve4_inc() :
|
||||
m_num_steps(0), m_step(0), m_scale(1.0) { }
|
||||
|
||||
curve4_inc(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
: m_num_steps(0)
|
||||
, m_step(0)
|
||||
, m_scale(1.0)
|
||||
curve4_inc(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4) :
|
||||
m_num_steps(0), m_step(0), m_scale(1.0)
|
||||
{
|
||||
init(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
curve4_inc(const curve4_points& cp)
|
||||
: m_num_steps(0)
|
||||
, m_step(0)
|
||||
, m_scale(1.0)
|
||||
curve4_inc(const curve4_points& cp) :
|
||||
m_num_steps(0), m_step(0), m_scale(1.0)
|
||||
{
|
||||
init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
m_num_steps = 0;
|
||||
m_step = -1;
|
||||
}
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
|
||||
void reset() { m_num_steps = 0; m_step = -1; }
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4);
|
||||
|
||||
void init(const curve4_points& cp) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); }
|
||||
void init(const curve4_points& cp)
|
||||
{
|
||||
init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
void approximation_method(curve_approximation_method_e) {}
|
||||
curve_approximation_method_e approximation_method() const { return curve_inc; }
|
||||
|
@ -253,9 +264,13 @@ class MAPNIK_DECL curve4_inc
|
|||
double m_saved_ddfy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------catrom_to_bezier
|
||||
inline curve4_points
|
||||
catrom_to_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
inline curve4_points catrom_to_bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4)
|
||||
{
|
||||
// Trans. matrix Catmull-Rom to Bezier
|
||||
//
|
||||
|
@ -264,7 +279,8 @@ inline curve4_points
|
|||
// 0 1/6 1 -1/6
|
||||
// 0 0 1 0
|
||||
//
|
||||
return curve4_points(x2,
|
||||
return curve4_points(
|
||||
x2,
|
||||
y2,
|
||||
(-x1 + 6*x2 + x3) / 6,
|
||||
(-y1 + 6*y2 + y3) / 6,
|
||||
|
@ -274,15 +290,22 @@ inline curve4_points
|
|||
y3);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
inline curve4_points catrom_to_bezier(const curve4_points& cp)
|
||||
inline curve4_points
|
||||
catrom_to_bezier(const curve4_points& cp)
|
||||
{
|
||||
return catrom_to_bezier(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
return catrom_to_bezier(cp[0], cp[1], cp[2], cp[3],
|
||||
cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------ubspline_to_bezier
|
||||
inline curve4_points
|
||||
ubspline_to_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
inline curve4_points ubspline_to_bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4)
|
||||
{
|
||||
// Trans. matrix Uniform BSpline to Bezier
|
||||
//
|
||||
|
@ -291,7 +314,8 @@ inline curve4_points
|
|||
// 0 2/6 4/6 0
|
||||
// 0 1/6 4/6 1/6
|
||||
//
|
||||
return curve4_points((x1 + 4 * x2 + x3) / 6,
|
||||
return curve4_points(
|
||||
(x1 + 4*x2 + x3) / 6,
|
||||
(y1 + 4*y2 + y3) / 6,
|
||||
(4*x2 + 2*x3) / 6,
|
||||
(4*y2 + 2*y3) / 6,
|
||||
|
@ -301,15 +325,23 @@ inline curve4_points
|
|||
(y2 + 4*y3 + y4) / 6);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
inline curve4_points ubspline_to_bezier(const curve4_points& cp)
|
||||
inline curve4_points
|
||||
ubspline_to_bezier(const curve4_points& cp)
|
||||
{
|
||||
return ubspline_to_bezier(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
return ubspline_to_bezier(cp[0], cp[1], cp[2], cp[3],
|
||||
cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------hermite_to_bezier
|
||||
inline curve4_points
|
||||
hermite_to_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
inline curve4_points hermite_to_bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4)
|
||||
{
|
||||
// Trans. matrix Hermite to Bezier
|
||||
//
|
||||
|
@ -318,55 +350,76 @@ inline curve4_points
|
|||
// 0 1 0 -1/3
|
||||
// 0 1 0 0
|
||||
//
|
||||
return curve4_points(x1, y1, (3 * x1 + x3) / 3, (3 * y1 + y3) / 3, (3 * x2 - x4) / 3, (3 * y2 - y4) / 3, x2, y2);
|
||||
return curve4_points(
|
||||
x1,
|
||||
y1,
|
||||
(3*x1 + x3) / 3,
|
||||
(3*y1 + y3) / 3,
|
||||
(3*x2 - x4) / 3,
|
||||
(3*y2 - y4) / 3,
|
||||
x2,
|
||||
y2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
inline curve4_points hermite_to_bezier(const curve4_points& cp)
|
||||
inline curve4_points
|
||||
hermite_to_bezier(const curve4_points& cp)
|
||||
{
|
||||
return hermite_to_bezier(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
return hermite_to_bezier(cp[0], cp[1], cp[2], cp[3],
|
||||
cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------curve4_div
|
||||
class MAPNIK_DECL curve4_div
|
||||
{
|
||||
public:
|
||||
curve4_div()
|
||||
: m_approximation_scale(1.0)
|
||||
, m_angle_tolerance(0.0)
|
||||
, m_cusp_limit(0.0)
|
||||
, m_count(0)
|
||||
curve4_div() :
|
||||
m_approximation_scale(1.0),
|
||||
m_angle_tolerance(0.0),
|
||||
m_cusp_limit(0.0),
|
||||
m_count(0)
|
||||
{}
|
||||
|
||||
curve4_div(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
: m_approximation_scale(1.0)
|
||||
, m_angle_tolerance(0.0)
|
||||
, m_cusp_limit(0.0)
|
||||
, m_count(0)
|
||||
curve4_div(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4) :
|
||||
m_approximation_scale(1.0),
|
||||
m_angle_tolerance(0.0),
|
||||
m_cusp_limit(0.0),
|
||||
m_count(0)
|
||||
{
|
||||
init(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
curve4_div(const curve4_points& cp)
|
||||
: m_approximation_scale(1.0)
|
||||
, m_angle_tolerance(0.0)
|
||||
, m_count(0)
|
||||
curve4_div(const curve4_points& cp) :
|
||||
m_approximation_scale(1.0),
|
||||
m_angle_tolerance(0.0),
|
||||
m_count(0)
|
||||
{
|
||||
init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
m_points.remove_all();
|
||||
m_count = 0;
|
||||
}
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
|
||||
void reset() { m_points.remove_all(); m_count = 0; }
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4);
|
||||
|
||||
void init(const curve4_points& cp) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); }
|
||||
void init(const curve4_points& cp)
|
||||
{
|
||||
init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
void approximation_method(curve_approximation_method_e) {}
|
||||
|
||||
curve_approximation_method_e approximation_method() const { return curve_div; }
|
||||
curve_approximation_method_e approximation_method() const
|
||||
{
|
||||
return curve_div;
|
||||
}
|
||||
|
||||
void approximation_scale(double s) { m_approximation_scale = s; }
|
||||
double approximation_scale() const { return m_approximation_scale; }
|
||||
|
@ -374,16 +427,24 @@ class MAPNIK_DECL curve4_div
|
|||
void angle_tolerance(double a) { m_angle_tolerance = a; }
|
||||
double angle_tolerance() const { return m_angle_tolerance; }
|
||||
|
||||
void cusp_limit(double v) { m_cusp_limit = (v == 0.0) ? 0.0 : pi - v; }
|
||||
void cusp_limit(double v)
|
||||
{
|
||||
m_cusp_limit = (v == 0.0) ? 0.0 : pi - v;
|
||||
}
|
||||
|
||||
double cusp_limit() const { return (m_cusp_limit == 0.0) ? 0.0 : pi - m_cusp_limit; }
|
||||
double cusp_limit() const
|
||||
{
|
||||
return (m_cusp_limit == 0.0) ? 0.0 : pi - m_cusp_limit;
|
||||
}
|
||||
|
||||
void rewind(unsigned) { m_count = 0; }
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
if (m_count >= m_points.size())
|
||||
return path_cmd_stop;
|
||||
if(m_count >= m_points.size()) return path_cmd_stop;
|
||||
const point_d& p = m_points[m_count++];
|
||||
*x = p.x;
|
||||
*y = p.y;
|
||||
|
@ -391,16 +452,15 @@ class MAPNIK_DECL curve4_div
|
|||
}
|
||||
|
||||
private:
|
||||
void bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
|
||||
void bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4);
|
||||
|
||||
void recursive_bezier(double x1,
|
||||
double y1,
|
||||
double x2,
|
||||
double y2,
|
||||
double x3,
|
||||
double y3,
|
||||
double x4,
|
||||
double y4,
|
||||
void recursive_bezier(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4,
|
||||
unsigned level);
|
||||
|
||||
double m_approximation_scale;
|
||||
|
@ -411,15 +471,16 @@ class MAPNIK_DECL curve4_div
|
|||
pod_bvector<point_d> m_points;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------curve3
|
||||
class MAPNIK_DECL curve3
|
||||
{
|
||||
public:
|
||||
curve3()
|
||||
: m_approximation_method(curve_div)
|
||||
{}
|
||||
curve3(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
: m_approximation_method(curve_div)
|
||||
curve3() : m_approximation_method(curve_div) {}
|
||||
curve3(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3) :
|
||||
m_approximation_method(curve_div)
|
||||
{
|
||||
init(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
@ -430,7 +491,9 @@ class MAPNIK_DECL curve3
|
|||
m_curve_div.reset();
|
||||
}
|
||||
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3)
|
||||
{
|
||||
if(m_approximation_method == curve_inc)
|
||||
{
|
||||
|
@ -442,9 +505,15 @@ class MAPNIK_DECL curve3
|
|||
}
|
||||
}
|
||||
|
||||
void approximation_method(curve_approximation_method_e v) { m_approximation_method = v; }
|
||||
void approximation_method(curve_approximation_method_e v)
|
||||
{
|
||||
m_approximation_method = v;
|
||||
}
|
||||
|
||||
curve_approximation_method_e approximation_method() const { return m_approximation_method; }
|
||||
curve_approximation_method_e approximation_method() const
|
||||
{
|
||||
return m_approximation_method;
|
||||
}
|
||||
|
||||
void approximation_scale(double s)
|
||||
{
|
||||
|
@ -452,15 +521,30 @@ class MAPNIK_DECL curve3
|
|||
m_curve_div.approximation_scale(s);
|
||||
}
|
||||
|
||||
double approximation_scale() const { return m_curve_inc.approximation_scale(); }
|
||||
double approximation_scale() const
|
||||
{
|
||||
return m_curve_inc.approximation_scale();
|
||||
}
|
||||
|
||||
void angle_tolerance(double a) { m_curve_div.angle_tolerance(a); }
|
||||
void angle_tolerance(double a)
|
||||
{
|
||||
m_curve_div.angle_tolerance(a);
|
||||
}
|
||||
|
||||
double angle_tolerance() const { return m_curve_div.angle_tolerance(); }
|
||||
double angle_tolerance() const
|
||||
{
|
||||
return m_curve_div.angle_tolerance();
|
||||
}
|
||||
|
||||
void cusp_limit(double v) { m_curve_div.cusp_limit(v); }
|
||||
void cusp_limit(double v)
|
||||
{
|
||||
m_curve_div.cusp_limit(v);
|
||||
}
|
||||
|
||||
double cusp_limit() const { return m_curve_div.cusp_limit(); }
|
||||
double cusp_limit() const
|
||||
{
|
||||
return m_curve_div.cusp_limit();
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
|
@ -489,21 +573,26 @@ class MAPNIK_DECL curve3
|
|||
curve_approximation_method_e m_approximation_method;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------curve4
|
||||
class MAPNIK_DECL curve4
|
||||
{
|
||||
public:
|
||||
curve4()
|
||||
: m_approximation_method(curve_div)
|
||||
{}
|
||||
curve4(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
: m_approximation_method(curve_div)
|
||||
curve4() : m_approximation_method(curve_div) {}
|
||||
curve4(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4) :
|
||||
m_approximation_method(curve_div)
|
||||
{
|
||||
init(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
curve4(const curve4_points& cp)
|
||||
: m_approximation_method(curve_div)
|
||||
curve4(const curve4_points& cp) :
|
||||
m_approximation_method(curve_div)
|
||||
{
|
||||
init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
@ -514,7 +603,10 @@ class MAPNIK_DECL curve4
|
|||
m_curve_div.reset();
|
||||
}
|
||||
|
||||
void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
void init(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x4, double y4)
|
||||
{
|
||||
if(m_approximation_method == curve_inc)
|
||||
{
|
||||
|
@ -526,11 +618,20 @@ class MAPNIK_DECL curve4
|
|||
}
|
||||
}
|
||||
|
||||
void init(const curve4_points& cp) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); }
|
||||
void init(const curve4_points& cp)
|
||||
{
|
||||
init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]);
|
||||
}
|
||||
|
||||
void approximation_method(curve_approximation_method_e v) { m_approximation_method = v; }
|
||||
void approximation_method(curve_approximation_method_e v)
|
||||
{
|
||||
m_approximation_method = v;
|
||||
}
|
||||
|
||||
curve_approximation_method_e approximation_method() const { return m_approximation_method; }
|
||||
curve_approximation_method_e approximation_method() const
|
||||
{
|
||||
return m_approximation_method;
|
||||
}
|
||||
|
||||
void approximation_scale(double s)
|
||||
{
|
||||
|
@ -539,13 +640,25 @@ class MAPNIK_DECL curve4
|
|||
}
|
||||
double approximation_scale() const { return m_curve_inc.approximation_scale(); }
|
||||
|
||||
void angle_tolerance(double v) { m_curve_div.angle_tolerance(v); }
|
||||
void angle_tolerance(double v)
|
||||
{
|
||||
m_curve_div.angle_tolerance(v);
|
||||
}
|
||||
|
||||
double angle_tolerance() const { return m_curve_div.angle_tolerance(); }
|
||||
double angle_tolerance() const
|
||||
{
|
||||
return m_curve_div.angle_tolerance();
|
||||
}
|
||||
|
||||
void cusp_limit(double v) { m_curve_div.cusp_limit(v); }
|
||||
void cusp_limit(double v)
|
||||
{
|
||||
m_curve_div.cusp_limit(v);
|
||||
}
|
||||
|
||||
double cusp_limit() const { return m_curve_div.cusp_limit(); }
|
||||
double cusp_limit() const
|
||||
{
|
||||
return m_curve_div.cusp_limit();
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
|
@ -574,6 +687,9 @@ class MAPNIK_DECL curve4
|
|||
curve_approximation_method_e m_approximation_method;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
129
deps/agg/include/agg_dda_line.h
vendored
129
deps/agg/include/agg_dda_line.h
vendored
|
@ -23,36 +23,49 @@
|
|||
#include <cstdlib>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===================================================dda_line_interpolator
|
||||
template<int FractionShift, int YShift = 0>
|
||||
class dda_line_interpolator
|
||||
template<int FractionShift, int YShift = 0> class dda_line_interpolator
|
||||
{
|
||||
static constexpr int factor = 2 << (FractionShift - 1);
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
dda_line_interpolator() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
dda_line_interpolator(int y1, int y2, unsigned count)
|
||||
: m_y(y1)
|
||||
, m_inc(((y2 - y1) * factor) / static_cast<int>(count))
|
||||
, m_dy(0)
|
||||
{}
|
||||
dda_line_interpolator(int y1, int y2, unsigned count) :
|
||||
m_y(y1),
|
||||
m_inc(((y2 - y1) * factor) / static_cast<int>(count)),
|
||||
m_dy(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void operator++() { m_dy += m_inc; }
|
||||
void operator ++ ()
|
||||
{
|
||||
m_dy += m_inc;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void operator--() { m_dy -= m_inc; }
|
||||
void operator -- ()
|
||||
{
|
||||
m_dy -= m_inc;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void operator+=(unsigned n) { m_dy += m_inc * n; }
|
||||
void operator += (unsigned n)
|
||||
{
|
||||
m_dy += m_inc * n;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void operator-=(unsigned n) { m_dy -= m_inc * n; }
|
||||
void operator -= (unsigned n)
|
||||
{
|
||||
m_dy -= m_inc * n;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
int y() const { return m_y + (m_dy >> (FractionShift - YShift)); }
|
||||
|
@ -64,6 +77,10 @@ class dda_line_interpolator
|
|||
int m_dy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=================================================dda2_line_interpolator
|
||||
class dda2_line_interpolator
|
||||
{
|
||||
|
@ -75,12 +92,12 @@ class dda2_line_interpolator
|
|||
dda2_line_interpolator() {}
|
||||
|
||||
//-------------------------------------------- Forward-adjusted line
|
||||
dda2_line_interpolator(int y1, int y2, int count)
|
||||
: m_cnt(count <= 0 ? 1 : count)
|
||||
, m_lft((y2 - y1) / m_cnt)
|
||||
, m_rem((y2 - y1) % m_cnt)
|
||||
, m_mod(m_rem)
|
||||
, m_y(y1)
|
||||
dda2_line_interpolator(int y1, int y2, int count) :
|
||||
m_cnt(count <= 0 ? 1 : count),
|
||||
m_lft((y2 - y1) / m_cnt),
|
||||
m_rem((y2 - y1) % m_cnt),
|
||||
m_mod(m_rem),
|
||||
m_y(y1)
|
||||
{
|
||||
if(m_mod <= 0)
|
||||
{
|
||||
|
@ -92,12 +109,12 @@ class dda2_line_interpolator
|
|||
}
|
||||
|
||||
//-------------------------------------------- Backward-adjusted line
|
||||
dda2_line_interpolator(int y1, int y2, int count, int)
|
||||
: m_cnt(count <= 0 ? 1 : count)
|
||||
, m_lft((y2 - y1) / m_cnt)
|
||||
, m_rem((y2 - y1) % m_cnt)
|
||||
, m_mod(m_rem)
|
||||
, m_y(y1)
|
||||
dda2_line_interpolator(int y1, int y2, int count, int) :
|
||||
m_cnt(count <= 0 ? 1 : count),
|
||||
m_lft((y2 - y1) / m_cnt),
|
||||
m_rem((y2 - y1) % m_cnt),
|
||||
m_mod(m_rem),
|
||||
m_y(y1)
|
||||
{
|
||||
if(m_mod <= 0)
|
||||
{
|
||||
|
@ -108,12 +125,12 @@ class dda2_line_interpolator
|
|||
}
|
||||
|
||||
//-------------------------------------------- Backward-adjusted line
|
||||
dda2_line_interpolator(int y, int count)
|
||||
: m_cnt(count <= 0 ? 1 : count)
|
||||
, m_lft(y / m_cnt)
|
||||
, m_rem(y % m_cnt)
|
||||
, m_mod(m_rem)
|
||||
, m_y(0)
|
||||
dda2_line_interpolator(int y, int count) :
|
||||
m_cnt(count <= 0 ? 1 : count),
|
||||
m_lft(y / m_cnt),
|
||||
m_rem(y % m_cnt),
|
||||
m_mod(m_rem),
|
||||
m_y(0)
|
||||
{
|
||||
if(m_mod <= 0)
|
||||
{
|
||||
|
@ -123,6 +140,7 @@ class dda2_line_interpolator
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void save(save_data_type* data) const
|
||||
{
|
||||
|
@ -162,10 +180,16 @@ class dda2_line_interpolator
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void adjust_forward() { m_mod -= m_cnt; }
|
||||
void adjust_forward()
|
||||
{
|
||||
m_mod -= m_cnt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void adjust_backward() { m_mod += m_cnt; }
|
||||
void adjust_backward()
|
||||
{
|
||||
m_mod += m_cnt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
int mod() const { return m_mod; }
|
||||
|
@ -183,11 +207,18 @@ class dda2_line_interpolator
|
|||
int m_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------line_bresenham_interpolator
|
||||
class line_bresenham_interpolator
|
||||
{
|
||||
public:
|
||||
enum subpixel_scale_e {
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = 8,
|
||||
subpixel_scale = 1 << subpixel_shift,
|
||||
subpixel_mask = subpixel_scale - 1
|
||||
|
@ -197,16 +228,20 @@ class line_bresenham_interpolator
|
|||
static int line_lr(int v) { return v >> subpixel_shift; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
line_bresenham_interpolator(int x1, int y1, int x2, int y2)
|
||||
: m_x1_lr(line_lr(x1))
|
||||
, m_y1_lr(line_lr(y1))
|
||||
, m_x2_lr(line_lr(x2))
|
||||
, m_y2_lr(line_lr(y2))
|
||||
, m_ver(std::abs(m_x2_lr - m_x1_lr) < std::abs(m_y2_lr - m_y1_lr))
|
||||
, m_len(m_ver ? std::abs(m_y2_lr - m_y1_lr) : std::abs(m_x2_lr - m_x1_lr))
|
||||
, m_inc(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1))
|
||||
, m_interpolator(m_ver ? x1 : y1, m_ver ? x2 : y2, m_len)
|
||||
{}
|
||||
line_bresenham_interpolator(int x1, int y1, int x2, int y2) :
|
||||
m_x1_lr(line_lr(x1)),
|
||||
m_y1_lr(line_lr(y1)),
|
||||
m_x2_lr(line_lr(x2)),
|
||||
m_y2_lr(line_lr(y2)),
|
||||
m_ver(std::abs(m_x2_lr - m_x1_lr) < std::abs(m_y2_lr - m_y1_lr)),
|
||||
m_len(m_ver ? std::abs(m_y2_lr - m_y1_lr) :
|
||||
std::abs(m_x2_lr - m_x1_lr)),
|
||||
m_inc(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1)),
|
||||
m_interpolator(m_ver ? x1 : y1,
|
||||
m_ver ? x2 : y2,
|
||||
m_len)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
bool is_ver() const { return m_ver; }
|
||||
|
@ -244,8 +279,12 @@ class line_bresenham_interpolator
|
|||
unsigned m_len;
|
||||
int m_inc;
|
||||
dda2_line_interpolator m_interpolator;
|
||||
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
53
deps/agg/include/agg_ellipse.h
vendored
53
deps/agg/include/agg_ellipse.h
vendored
|
@ -23,38 +23,27 @@
|
|||
#include "agg_basics.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------ellipse
|
||||
class ellipse
|
||||
{
|
||||
public:
|
||||
ellipse()
|
||||
: m_x(0.0)
|
||||
, m_y(0.0)
|
||||
, m_rx(1.0)
|
||||
, m_ry(1.0)
|
||||
, m_scale(1.0)
|
||||
, m_num(4)
|
||||
, m_step(0)
|
||||
, m_cw(false)
|
||||
{}
|
||||
ellipse() :
|
||||
m_x(0.0), m_y(0.0), m_rx(1.0), m_ry(1.0), m_scale(1.0),
|
||||
m_num(4), m_step(0), m_cw(false) {}
|
||||
|
||||
ellipse(double x, double y, double rx, double ry, unsigned num_steps = 0, bool cw = false)
|
||||
: m_x(x)
|
||||
, m_y(y)
|
||||
, m_rx(rx)
|
||||
, m_ry(ry)
|
||||
, m_scale(1.0)
|
||||
, m_num(num_steps)
|
||||
, m_step(0)
|
||||
, m_cw(cw)
|
||||
ellipse(double x, double y, double rx, double ry,
|
||||
unsigned num_steps=0, bool cw=false) :
|
||||
m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0),
|
||||
m_num(num_steps), m_step(0), m_cw(cw)
|
||||
{
|
||||
if (m_num == 0)
|
||||
calc_num_steps();
|
||||
if(m_num == 0) calc_num_steps();
|
||||
}
|
||||
|
||||
void init(double x, double y, double rx, double ry, unsigned num_steps = 0, bool cw = false);
|
||||
void init(double x, double y, double rx, double ry,
|
||||
unsigned num_steps=0, bool cw=false);
|
||||
|
||||
void approximation_scale(double scale);
|
||||
void rewind(unsigned path_id);
|
||||
|
@ -75,7 +64,8 @@ class ellipse
|
|||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
inline void ellipse::init(double x, double y, double rx, double ry, unsigned num_steps, bool cw)
|
||||
inline void ellipse::init(double x, double y, double rx, double ry,
|
||||
unsigned num_steps, bool cw)
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
|
@ -84,8 +74,7 @@ inline void ellipse::init(double x, double y, double rx, double ry, unsigned num
|
|||
m_num = num_steps;
|
||||
m_step = 0;
|
||||
m_cw = cw;
|
||||
if (m_num == 0)
|
||||
calc_num_steps();
|
||||
if(m_num == 0) calc_num_steps();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -117,17 +106,19 @@ inline unsigned ellipse::vertex(double* x, double* y)
|
|||
++m_step;
|
||||
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
|
||||
}
|
||||
if (m_step > m_num)
|
||||
return path_cmd_stop;
|
||||
if(m_step > m_num) return path_cmd_stop;
|
||||
double angle = double(m_step) / double(m_num) * 2.0 * pi;
|
||||
if (m_cw)
|
||||
angle = 2.0 * pi - angle;
|
||||
if(m_cw) angle = 2.0 * pi - angle;
|
||||
*x = m_x + std::cos(angle) * m_rx;
|
||||
*y = m_y + std::sin(angle) * m_ry;
|
||||
m_step++;
|
||||
return ((m_step == 1) ? path_cmd_move_to : path_cmd_line_to);
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
38
deps/agg/include/agg_ellipse_bresenham.h
vendored
38
deps/agg/include/agg_ellipse_bresenham.h
vendored
|
@ -20,24 +20,27 @@
|
|||
#ifndef AGG_ELLIPSE_BRESENHAM_INCLUDED
|
||||
#define AGG_ELLIPSE_BRESENHAM_INCLUDED
|
||||
|
||||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------ellipse_bresenham_interpolator
|
||||
class ellipse_bresenham_interpolator
|
||||
{
|
||||
public:
|
||||
ellipse_bresenham_interpolator(int rx, int ry)
|
||||
: m_rx2(rx * rx)
|
||||
, m_ry2(ry * ry)
|
||||
, m_two_rx2(m_rx2 << 1)
|
||||
, m_two_ry2(m_ry2 << 1)
|
||||
, m_dx(0)
|
||||
, m_dy(0)
|
||||
, m_inc_x(0)
|
||||
, m_inc_y(-ry * m_two_rx2)
|
||||
, m_cur_f(0)
|
||||
ellipse_bresenham_interpolator(int rx, int ry) :
|
||||
m_rx2(rx * rx),
|
||||
m_ry2(ry * ry),
|
||||
m_two_rx2(m_rx2 << 1),
|
||||
m_two_ry2(m_ry2 << 1),
|
||||
m_dx(0),
|
||||
m_dy(0),
|
||||
m_inc_x(0),
|
||||
m_inc_y(-ry * m_two_rx2),
|
||||
m_cur_f(0)
|
||||
{}
|
||||
|
||||
int dx() const { return m_dx; }
|
||||
|
@ -49,16 +52,13 @@ class ellipse_bresenham_interpolator
|
|||
int fx, fy, fxy;
|
||||
|
||||
mx = fx = m_cur_f + m_inc_x + m_ry2;
|
||||
if (mx < 0)
|
||||
mx = -mx;
|
||||
if(mx < 0) mx = -mx;
|
||||
|
||||
my = fy = m_cur_f + m_inc_y + m_rx2;
|
||||
if (my < 0)
|
||||
my = -my;
|
||||
if(my < 0) my = -my;
|
||||
|
||||
mxy = fxy = m_cur_f + m_inc_x + m_ry2 + m_inc_y + m_rx2;
|
||||
if (mxy < 0)
|
||||
mxy = -mxy;
|
||||
if(mxy < 0) mxy = -mxy;
|
||||
|
||||
min_m = mx;
|
||||
bool flag = true;
|
||||
|
@ -104,8 +104,10 @@ class ellipse_bresenham_interpolator
|
|||
int m_inc_x;
|
||||
int m_inc_y;
|
||||
int m_cur_f;
|
||||
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
5
deps/agg/include/agg_embedded_raster_fonts.h
vendored
5
deps/agg/include/agg_embedded_raster_fonts.h
vendored
|
@ -18,7 +18,8 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
extern const int8u gse4x6[];
|
||||
extern const int8u gse4x8[];
|
||||
extern const int8u gse5x7[];
|
||||
|
@ -53,6 +54,6 @@ extern const int8u verdana17[];
|
|||
extern const int8u verdana17_bold[];
|
||||
extern const int8u verdana18[];
|
||||
extern const int8u verdana18_bold[];
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
123
deps/agg/include/agg_font_cache_manager.h
vendored
123
deps/agg/include/agg_font_cache_manager.h
vendored
|
@ -19,10 +19,18 @@
|
|||
#include <cstring>
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//---------------------------------------------------------glyph_data_type
|
||||
enum glyph_data_type { glyph_data_invalid = 0, glyph_data_mono = 1, glyph_data_gray8 = 2, glyph_data_outline = 3 };
|
||||
enum glyph_data_type
|
||||
{
|
||||
glyph_data_invalid = 0,
|
||||
glyph_data_mono = 1,
|
||||
glyph_data_gray8 = 2,
|
||||
glyph_data_outline = 3
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------glyph_cache
|
||||
struct glyph_cache
|
||||
|
@ -36,6 +44,7 @@ struct glyph_cache
|
|||
double advance_y;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------font_cache
|
||||
class font_cache
|
||||
{
|
||||
|
@ -43,9 +52,9 @@ class font_cache
|
|||
enum block_size_e { block_size = 16384-16 };
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
font_cache()
|
||||
: m_allocator(block_size)
|
||||
, m_font_signature(0)
|
||||
font_cache() :
|
||||
m_allocator(block_size),
|
||||
m_font_signature(0)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -57,7 +66,10 @@ class font_cache
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
bool font_is(const char* font_signature) const { return strcmp(font_signature, m_font_signature) == 0; }
|
||||
bool font_is(const char* font_signature) const
|
||||
{
|
||||
return strcmp(font_signature, m_font_signature) == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const glyph_cache* find_glyph(unsigned glyph_code) const
|
||||
|
@ -82,15 +94,18 @@ class font_cache
|
|||
unsigned msb = (glyph_code >> 8) & 0xFF;
|
||||
if(m_glyphs[msb] == 0)
|
||||
{
|
||||
m_glyphs[msb] = (glyph_cache**)m_allocator.allocate(sizeof(glyph_cache*) * 256, sizeof(glyph_cache*));
|
||||
m_glyphs[msb] =
|
||||
(glyph_cache**)m_allocator.allocate(sizeof(glyph_cache*) * 256,
|
||||
sizeof(glyph_cache*));
|
||||
memset(m_glyphs[msb], 0, sizeof(glyph_cache*) * 256);
|
||||
}
|
||||
|
||||
unsigned lsb = glyph_code & 0xFF;
|
||||
if (m_glyphs[msb][lsb])
|
||||
return 0; // Already exists, do not overwrite
|
||||
if(m_glyphs[msb][lsb]) return 0; // Already exists, do not overwrite
|
||||
|
||||
glyph_cache* glyph = (glyph_cache*)m_allocator.allocate(sizeof(glyph_cache), sizeof(double));
|
||||
glyph_cache* glyph =
|
||||
(glyph_cache*)m_allocator.allocate(sizeof(glyph_cache),
|
||||
sizeof(double));
|
||||
|
||||
glyph->glyph_index = glyph_index;
|
||||
glyph->data = m_allocator.allocate(data_size);
|
||||
|
@ -108,6 +123,12 @@ class font_cache
|
|||
char* m_font_signature;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------font_cache_pool
|
||||
class font_cache_pool
|
||||
{
|
||||
|
@ -124,13 +145,14 @@ class font_cache_pool
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
font_cache_pool(unsigned max_fonts = 32)
|
||||
: m_fonts(pod_allocator<font_cache*>::allocate(max_fonts))
|
||||
, m_max_fonts(max_fonts)
|
||||
, m_num_fonts(0)
|
||||
, m_cur_font(0)
|
||||
font_cache_pool(unsigned max_fonts=32) :
|
||||
m_fonts(pod_allocator<font_cache*>::allocate(max_fonts)),
|
||||
m_max_fonts(max_fonts),
|
||||
m_num_fonts(0),
|
||||
m_cur_font(0)
|
||||
{}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void font(const char* font_signature, bool reset_cache = false)
|
||||
{
|
||||
|
@ -150,7 +172,9 @@ class font_cache_pool
|
|||
if(m_num_fonts >= m_max_fonts)
|
||||
{
|
||||
obj_allocator<font_cache>::deallocate(m_fonts[0]);
|
||||
memcpy(m_fonts, m_fonts + 1, (m_max_fonts - 1) * sizeof(font_cache*));
|
||||
memcpy(m_fonts,
|
||||
m_fonts + 1,
|
||||
(m_max_fonts - 1) * sizeof(font_cache*));
|
||||
m_num_fonts = m_max_fonts - 1;
|
||||
}
|
||||
m_fonts[m_num_fonts] = obj_allocator<font_cache>::allocate();
|
||||
|
@ -161,13 +185,15 @@ class font_cache_pool
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const font_cache* font() const { return m_cur_font; }
|
||||
const font_cache* font() const
|
||||
{
|
||||
return m_cur_font;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const glyph_cache* find_glyph(unsigned glyph_code) const
|
||||
{
|
||||
if (m_cur_font)
|
||||
return m_cur_font->find_glyph(glyph_code);
|
||||
if(m_cur_font) return m_cur_font->find_glyph(glyph_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,19 +208,25 @@ class font_cache_pool
|
|||
{
|
||||
if(m_cur_font)
|
||||
{
|
||||
return m_cur_font->cache_glyph(glyph_code, glyph_index, data_size, data_type, bounds, advance_x, advance_y);
|
||||
return m_cur_font->cache_glyph(glyph_code,
|
||||
glyph_index,
|
||||
data_size,
|
||||
data_type,
|
||||
bounds,
|
||||
advance_x,
|
||||
advance_y);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
int find_font(const char* font_signature)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < m_num_fonts; i++)
|
||||
{
|
||||
if (m_fonts[i]->font_is(font_signature))
|
||||
return int(i);
|
||||
if(m_fonts[i]->font_is(font_signature)) return int(i);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -206,8 +238,12 @@ class font_cache_pool
|
|||
font_cache* m_cur_font;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
enum glyph_rendering {
|
||||
enum glyph_rendering
|
||||
{
|
||||
glyph_ren_native_mono,
|
||||
glyph_ren_native_gray8,
|
||||
glyph_ren_outline,
|
||||
|
@ -215,9 +251,11 @@ enum glyph_rendering {
|
|||
glyph_ren_agg_gray8
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------font_cache_manager
|
||||
template<class FontEngine>
|
||||
class font_cache_manager
|
||||
template<class FontEngine> class font_cache_manager
|
||||
{
|
||||
public:
|
||||
typedef FontEngine font_engine_type;
|
||||
|
@ -229,16 +267,19 @@ class font_cache_manager
|
|||
typedef typename mono_adaptor_type::embedded_scanline mono_scanline_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
font_cache_manager(font_engine_type& engine, unsigned max_fonts = 32)
|
||||
: m_fonts(max_fonts)
|
||||
, m_engine(engine)
|
||||
, m_change_stamp(-1)
|
||||
, m_prev_glyph(0)
|
||||
, m_last_glyph(0)
|
||||
font_cache_manager(font_engine_type& engine, unsigned max_fonts=32) :
|
||||
m_fonts(max_fonts),
|
||||
m_engine(engine),
|
||||
m_change_stamp(-1),
|
||||
m_prev_glyph(0),
|
||||
m_last_glyph(0)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_last_glyph() { m_prev_glyph = m_last_glyph = 0; }
|
||||
void reset_last_glyph()
|
||||
{
|
||||
m_prev_glyph = m_last_glyph = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const glyph_cache* glyph(unsigned glyph_code)
|
||||
|
@ -270,14 +311,15 @@ class font_cache_manager
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void init_embedded_adaptors(const glyph_cache* gl, double x, double y, double scale = 1.0)
|
||||
void init_embedded_adaptors(const glyph_cache* gl,
|
||||
double x, double y,
|
||||
double scale=1.0)
|
||||
{
|
||||
if(gl)
|
||||
{
|
||||
switch(gl->data_type)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
default: return;
|
||||
case glyph_data_mono:
|
||||
m_mono_adaptor.init(gl->data, gl->data_size, x, y);
|
||||
break;
|
||||
|
@ -293,6 +335,7 @@ class font_cache_manager
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
path_adaptor_type& path_adaptor() { return m_path_adaptor; }
|
||||
gray8_adaptor_type& gray8_adaptor() { return m_gray8_adaptor; }
|
||||
|
@ -309,7 +352,9 @@ class font_cache_manager
|
|||
{
|
||||
if(m_prev_glyph && m_last_glyph)
|
||||
{
|
||||
return m_engine.add_kerning(m_prev_glyph->glyph_index, m_last_glyph->glyph_index, x, y);
|
||||
return m_engine.add_kerning(m_prev_glyph->glyph_index,
|
||||
m_last_glyph->glyph_index,
|
||||
x, y);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -317,8 +362,7 @@ class font_cache_manager
|
|||
//--------------------------------------------------------------------
|
||||
void precache(unsigned from, unsigned to)
|
||||
{
|
||||
for (; from <= to; ++from)
|
||||
glyph(from);
|
||||
for(; from <= to; ++from) glyph(from);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -359,6 +403,7 @@ class font_cache_manager
|
|||
mono_scanline_type m_mono_scanline;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
69
deps/agg/include/agg_gamma_functions.h
vendored
69
deps/agg/include/agg_gamma_functions.h
vendored
|
@ -19,31 +19,28 @@
|
|||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//===============================================================gamma_none
|
||||
struct gamma_none
|
||||
{
|
||||
double operator()(double x) const { return x; }
|
||||
};
|
||||
|
||||
|
||||
//==============================================================gamma_power
|
||||
class gamma_power
|
||||
{
|
||||
public:
|
||||
gamma_power()
|
||||
: m_gamma(1.0)
|
||||
{}
|
||||
gamma_power(double g)
|
||||
: m_gamma(g)
|
||||
{}
|
||||
gamma_power() : m_gamma(1.0) {}
|
||||
gamma_power(double g) : m_gamma(g) {}
|
||||
|
||||
void gamma(double g) { m_gamma = g; }
|
||||
double gamma() const { return m_gamma; }
|
||||
|
||||
double operator() (double x) const
|
||||
{
|
||||
if (x == 0.0)
|
||||
return 0.0;
|
||||
if (x == 0.0) return 0.0;
|
||||
return pow(x, m_gamma);
|
||||
}
|
||||
|
||||
|
@ -51,44 +48,35 @@ class gamma_power
|
|||
double m_gamma;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================gamma_threshold
|
||||
class gamma_threshold
|
||||
{
|
||||
public:
|
||||
gamma_threshold()
|
||||
: m_threshold(0.5)
|
||||
{}
|
||||
gamma_threshold(double t)
|
||||
: m_threshold(t)
|
||||
{}
|
||||
gamma_threshold() : m_threshold(0.5) {}
|
||||
gamma_threshold(double t) : m_threshold(t) {}
|
||||
|
||||
void threshold(double t) { m_threshold = t; }
|
||||
double threshold() const { return m_threshold; }
|
||||
|
||||
double operator()(double x) const { return (x < m_threshold) ? 0.0 : 1.0; }
|
||||
double operator() (double x) const
|
||||
{
|
||||
return (x < m_threshold) ? 0.0 : 1.0;
|
||||
}
|
||||
|
||||
private:
|
||||
double m_threshold;
|
||||
};
|
||||
|
||||
|
||||
//============================================================gamma_linear
|
||||
class gamma_linear
|
||||
{
|
||||
public:
|
||||
gamma_linear()
|
||||
: m_start(0.0)
|
||||
, m_end(1.0)
|
||||
{}
|
||||
gamma_linear(double s, double e)
|
||||
: m_start(s)
|
||||
, m_end(e)
|
||||
{}
|
||||
gamma_linear() : m_start(0.0), m_end(1.0) {}
|
||||
gamma_linear(double s, double e) : m_start(s), m_end(e) {}
|
||||
|
||||
void set(double s, double e)
|
||||
{
|
||||
m_start = s;
|
||||
m_end = e;
|
||||
}
|
||||
void set(double s, double e) { m_start = s; m_end = e; }
|
||||
void start(double s) { m_start = s; }
|
||||
void end(double e) { m_end = e; }
|
||||
double start() const { return m_start; }
|
||||
|
@ -96,15 +84,12 @@ class gamma_linear
|
|||
|
||||
double operator() (double x) const
|
||||
{
|
||||
if (x < m_start)
|
||||
return 0.0;
|
||||
if (x > m_end)
|
||||
return 1.0;
|
||||
if(x < m_start) return 0.0;
|
||||
if(x > m_end) return 1.0;
|
||||
double delta = m_end - m_start;
|
||||
// avoid nan from potential zero division
|
||||
// https://github.com/mapnik/mapnik/issues/761
|
||||
if (delta <= 0.0)
|
||||
return 0.0;
|
||||
if (delta <= 0.0) return 0.0;
|
||||
return (x - m_start) / delta;
|
||||
}
|
||||
|
||||
|
@ -113,16 +98,13 @@ class gamma_linear
|
|||
double m_end;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================gamma_multiply
|
||||
class gamma_multiply
|
||||
{
|
||||
public:
|
||||
gamma_multiply()
|
||||
: m_mul(1.0)
|
||||
{}
|
||||
gamma_multiply(double v)
|
||||
: m_mul(v)
|
||||
{}
|
||||
gamma_multiply() : m_mul(1.0) {}
|
||||
gamma_multiply(double v) : m_mul(v) {}
|
||||
|
||||
void value(double v) { m_mul = v; }
|
||||
double value() const { return m_mul; }
|
||||
|
@ -130,8 +112,7 @@ class gamma_multiply
|
|||
double operator() (double x) const
|
||||
{
|
||||
double y = x * m_mul;
|
||||
if (y > 1.0)
|
||||
y = 1.0;
|
||||
if(y > 1.0) y = 1.0;
|
||||
return y;
|
||||
}
|
||||
|
||||
|
@ -148,6 +129,6 @@ inline double linear_to_sRGB(double x)
|
|||
{
|
||||
return (x <= 0.0031308) ? (x * 12.92) : (1.055 * pow(x, 1 / 2.4) - 0.055);
|
||||
}
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
139
deps/agg/include/agg_gamma_lut.h
vendored
139
deps/agg/include/agg_gamma_lut.h
vendored
|
@ -20,16 +20,29 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_gamma_functions.h"
|
||||
|
||||
namespace agg {
|
||||
template<class LoResT = int8u, class HiResT = int8u, unsigned GammaShift = 8, unsigned HiResShift = 8>
|
||||
class gamma_lut
|
||||
namespace agg
|
||||
{
|
||||
template<class LoResT=int8u,
|
||||
class HiResT=int8u,
|
||||
unsigned GammaShift=8,
|
||||
unsigned HiResShift=8> class gamma_lut
|
||||
{
|
||||
public:
|
||||
typedef gamma_lut<LoResT, HiResT, GammaShift, HiResShift> self_type;
|
||||
|
||||
enum gamma_scale_e { gamma_shift = GammaShift, gamma_size = 1 << gamma_shift, gamma_mask = gamma_size - 1 };
|
||||
enum gamma_scale_e
|
||||
{
|
||||
gamma_shift = GammaShift,
|
||||
gamma_size = 1 << gamma_shift,
|
||||
gamma_mask = gamma_size - 1
|
||||
};
|
||||
|
||||
enum hi_res_scale_e { hi_res_shift = HiResShift, hi_res_size = 1 << hi_res_shift, hi_res_mask = hi_res_size - 1 };
|
||||
enum hi_res_scale_e
|
||||
{
|
||||
hi_res_shift = HiResShift,
|
||||
hi_res_size = 1 << hi_res_shift,
|
||||
hi_res_mask = hi_res_size - 1
|
||||
};
|
||||
|
||||
~gamma_lut()
|
||||
{
|
||||
|
@ -37,10 +50,10 @@ class gamma_lut
|
|||
pod_allocator<HiResT>::deallocate(m_dir_gamma, gamma_size);
|
||||
}
|
||||
|
||||
gamma_lut()
|
||||
: m_gamma(1.0)
|
||||
, m_dir_gamma(pod_allocator<HiResT>::allocate(gamma_size))
|
||||
, m_inv_gamma(pod_allocator<LoResT>::allocate(hi_res_size))
|
||||
gamma_lut() :
|
||||
m_gamma(1.0),
|
||||
m_dir_gamma(pod_allocator<HiResT>::allocate(gamma_size)),
|
||||
m_inv_gamma(pod_allocator<LoResT>::allocate(hi_res_size))
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < gamma_size; i++)
|
||||
|
@ -54,10 +67,10 @@ class gamma_lut
|
|||
}
|
||||
}
|
||||
|
||||
gamma_lut(double g)
|
||||
: m_gamma(1.0)
|
||||
, m_dir_gamma(pod_allocator<HiResT>::allocate(gamma_size))
|
||||
, m_inv_gamma(pod_allocator<LoResT>::allocate(hi_res_size))
|
||||
gamma_lut(double g) :
|
||||
m_gamma(1.0),
|
||||
m_dir_gamma(pod_allocator<HiResT>::allocate(gamma_size)),
|
||||
m_inv_gamma(pod_allocator<LoResT>::allocate(hi_res_size))
|
||||
{
|
||||
gamma(g);
|
||||
}
|
||||
|
@ -69,21 +82,32 @@ class gamma_lut
|
|||
unsigned i;
|
||||
for(i = 0; i < gamma_size; i++)
|
||||
{
|
||||
m_dir_gamma[i] = (HiResT)uround(pow(i / double(gamma_mask), m_gamma) * double(hi_res_mask));
|
||||
m_dir_gamma[i] = (HiResT)
|
||||
uround(pow(i / double(gamma_mask), m_gamma) * double(hi_res_mask));
|
||||
}
|
||||
|
||||
double inv_g = 1.0 / g;
|
||||
for(i = 0; i < hi_res_size; i++)
|
||||
{
|
||||
m_inv_gamma[i] = (LoResT)uround(pow(i / double(hi_res_mask), inv_g) * double(gamma_mask));
|
||||
m_inv_gamma[i] = (LoResT)
|
||||
uround(pow(i / double(hi_res_mask), inv_g) * double(gamma_mask));
|
||||
}
|
||||
}
|
||||
|
||||
double gamma() const { return m_gamma; }
|
||||
double gamma() const
|
||||
{
|
||||
return m_gamma;
|
||||
}
|
||||
|
||||
HiResT dir(LoResT v) const { return m_dir_gamma[unsigned(v)]; }
|
||||
HiResT dir(LoResT v) const
|
||||
{
|
||||
return m_dir_gamma[unsigned(v)];
|
||||
}
|
||||
|
||||
LoResT inv(HiResT v) const { return m_inv_gamma[unsigned(v)]; }
|
||||
LoResT inv(HiResT v) const
|
||||
{
|
||||
return m_inv_gamma[unsigned(v)];
|
||||
}
|
||||
|
||||
private:
|
||||
gamma_lut(const self_type&);
|
||||
|
@ -105,28 +129,23 @@ template<class LinearType>
|
|||
class sRGB_lut_base
|
||||
{
|
||||
public:
|
||||
LinearType dir(int8u v) const { return m_dir_table[v]; }
|
||||
LinearType dir(int8u v) const
|
||||
{
|
||||
return m_dir_table[v];
|
||||
}
|
||||
|
||||
int8u inv(LinearType v) const
|
||||
{
|
||||
// Unrolled binary search.
|
||||
int8u x = 0;
|
||||
if (v > m_inv_table[128])
|
||||
x = 128;
|
||||
if (v > m_inv_table[x + 64])
|
||||
x += 64;
|
||||
if (v > m_inv_table[x + 32])
|
||||
x += 32;
|
||||
if (v > m_inv_table[x + 16])
|
||||
x += 16;
|
||||
if (v > m_inv_table[x + 8])
|
||||
x += 8;
|
||||
if (v > m_inv_table[x + 4])
|
||||
x += 4;
|
||||
if (v > m_inv_table[x + 2])
|
||||
x += 2;
|
||||
if (v > m_inv_table[x + 1])
|
||||
x += 1;
|
||||
if (v > m_inv_table[128]) x = 128;
|
||||
if (v > m_inv_table[x + 64]) x += 64;
|
||||
if (v > m_inv_table[x + 32]) x += 32;
|
||||
if (v > m_inv_table[x + 16]) x += 16;
|
||||
if (v > m_inv_table[x + 8]) x += 8;
|
||||
if (v > m_inv_table[x + 4]) x += 4;
|
||||
if (v > m_inv_table[x + 2]) x += 2;
|
||||
if (v > m_inv_table[x + 1]) x += 1;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -135,7 +154,9 @@ class sRGB_lut_base
|
|||
LinearType m_inv_table[256];
|
||||
|
||||
// Only derived classes may instantiate.
|
||||
sRGB_lut_base() {}
|
||||
sRGB_lut_base()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// sRGB_lut - implements sRGB conversion for the various types.
|
||||
|
@ -209,9 +230,15 @@ template<class T>
|
|||
class sRGB_conv_base
|
||||
{
|
||||
public:
|
||||
static T rgb_from_sRGB(int8u x) { return lut.dir(x); }
|
||||
static T rgb_from_sRGB(int8u x)
|
||||
{
|
||||
return lut.dir(x);
|
||||
}
|
||||
|
||||
static int8u rgb_to_sRGB(T x) { return lut.inv(x); }
|
||||
static int8u rgb_to_sRGB(T x)
|
||||
{
|
||||
return lut.inv(x);
|
||||
}
|
||||
|
||||
private:
|
||||
static sRGB_lut<T> lut;
|
||||
|
@ -231,16 +258,16 @@ template<>
|
|||
class sRGB_conv<float> : public sRGB_conv_base<float>
|
||||
{
|
||||
public:
|
||||
static float alpha_from_sRGB(int8u x) { return float(x / 255.0); }
|
||||
static float alpha_from_sRGB(int8u x)
|
||||
{
|
||||
return float(x / 255.0);
|
||||
}
|
||||
|
||||
static int8u alpha_to_sRGB(float x)
|
||||
{
|
||||
if (x <= 0)
|
||||
return 0;
|
||||
else if (x >= 1)
|
||||
return 255;
|
||||
else
|
||||
return int8u(0.5 + x * 255);
|
||||
if (x <= 0) return 0;
|
||||
else if (x >= 1) return 255;
|
||||
else return int8u(0.5 + x * 255);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -248,19 +275,31 @@ template<>
|
|||
class sRGB_conv<int16u> : public sRGB_conv_base<int16u>
|
||||
{
|
||||
public:
|
||||
static int16u alpha_from_sRGB(int8u x) { return (x << 8) | x; }
|
||||
static int16u alpha_from_sRGB(int8u x)
|
||||
{
|
||||
return (x << 8) | x;
|
||||
}
|
||||
|
||||
static int8u alpha_to_sRGB(int16u x) { return x >> 8; }
|
||||
static int8u alpha_to_sRGB(int16u x)
|
||||
{
|
||||
return x >> 8;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class sRGB_conv<int8u> : public sRGB_conv_base<int8u>
|
||||
{
|
||||
public:
|
||||
static int8u alpha_from_sRGB(int8u x) { return x; }
|
||||
static int8u alpha_from_sRGB(int8u x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
static int8u alpha_to_sRGB(int8u x) { return x; }
|
||||
static int8u alpha_to_sRGB(int8u x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
25
deps/agg/include/agg_glyph_raster_bin.h
vendored
25
deps/agg/include/agg_glyph_raster_bin.h
vendored
|
@ -19,11 +19,11 @@
|
|||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//========================================================glyph_raster_bin
|
||||
template<class ColorT>
|
||||
class glyph_raster_bin
|
||||
template<class ColorT> class glyph_raster_bin
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
|
@ -36,13 +36,12 @@ class glyph_raster_bin
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
glyph_raster_bin(const int8u* font)
|
||||
: m_font(font)
|
||||
, m_big_endian(false)
|
||||
glyph_raster_bin(const int8u* font) :
|
||||
m_font(font),
|
||||
m_big_endian(false)
|
||||
{
|
||||
int t = 1;
|
||||
if (*(char*)&t == 0)
|
||||
m_big_endian = true;
|
||||
if(*(char*)&t == 0) m_big_endian = true;
|
||||
memset(m_span, 0, sizeof(m_span));
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,8 @@ class glyph_raster_bin
|
|||
while(*str)
|
||||
{
|
||||
unsigned glyph = *str;
|
||||
const int8u* bits = m_font + 4 + num_chars * 2 + value(m_font + 4 + (glyph - start_char) * 2);
|
||||
const int8u* bits = m_font + 4 + num_chars * 2 +
|
||||
value(m_font + 4 + (glyph - start_char) * 2);
|
||||
w += *bits;
|
||||
++str;
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ class glyph_raster_bin
|
|||
unsigned start_char = m_font[2];
|
||||
unsigned num_chars = m_font[3];
|
||||
|
||||
m_bits = m_font + 4 + num_chars * 2 + value(m_font + 4 + (glyph - start_char) * 2);
|
||||
m_bits = m_font + 4 + num_chars * 2 +
|
||||
value(m_font + 4 + (glyph - start_char) * 2);
|
||||
|
||||
m_glyph_width = *m_bits++;
|
||||
m_glyph_byte_width = (m_glyph_width + 7) >> 3;
|
||||
|
@ -138,6 +139,7 @@ class glyph_raster_bin
|
|||
return v;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const int8u* m_font;
|
||||
bool m_big_endian;
|
||||
|
@ -147,6 +149,7 @@ class glyph_raster_bin
|
|||
unsigned m_glyph_byte_width;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
122
deps/agg/include/agg_gradient_lut.h
vendored
122
deps/agg/include/agg_gradient_lut.h
vendored
|
@ -21,25 +21,33 @@
|
|||
#include "agg_color_rgba.h"
|
||||
#include "agg_color_gray.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//======================================================color_interpolator
|
||||
template<class ColorT>
|
||||
struct color_interpolator
|
||||
template<class ColorT> struct color_interpolator
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
|
||||
color_interpolator(const color_type& c1, const color_type& c2, unsigned len)
|
||||
: m_c1(c1)
|
||||
, m_c2(c2)
|
||||
, m_len(len)
|
||||
, m_count(0)
|
||||
color_interpolator(const color_type& c1,
|
||||
const color_type& c2,
|
||||
unsigned len) :
|
||||
m_c1(c1),
|
||||
m_c2(c2),
|
||||
m_len(len),
|
||||
m_count(0)
|
||||
{}
|
||||
|
||||
void operator++() { ++m_count; }
|
||||
void operator ++ ()
|
||||
{
|
||||
++m_count;
|
||||
}
|
||||
|
||||
color_type color() const { return m_c1.gradient(m_c2, double(m_count) / m_len); }
|
||||
color_type color() const
|
||||
{
|
||||
return m_c1.gradient(m_c2, double(m_count) / m_len);
|
||||
}
|
||||
|
||||
private:
|
||||
color_type m_c1;
|
||||
|
@ -50,28 +58,29 @@ struct color_interpolator
|
|||
|
||||
//========================================================================
|
||||
// Fast specialization for rgba8
|
||||
template<>
|
||||
struct color_interpolator<rgba8>
|
||||
template<> struct color_interpolator<rgba8>
|
||||
{
|
||||
public:
|
||||
typedef rgba8 color_type;
|
||||
|
||||
color_interpolator(const color_type& c1, const color_type& c2, unsigned len)
|
||||
: r(c1.r, c2.r, len)
|
||||
, g(c1.g, c2.g, len)
|
||||
, b(c1.b, c2.b, len)
|
||||
, a(c1.a, c2.a, len)
|
||||
color_interpolator(const color_type& c1,
|
||||
const color_type& c2,
|
||||
unsigned len) :
|
||||
r(c1.r, c2.r, len),
|
||||
g(c1.g, c2.g, len),
|
||||
b(c1.b, c2.b, len),
|
||||
a(c1.a, c2.a, len)
|
||||
{}
|
||||
|
||||
void operator ++ ()
|
||||
{
|
||||
++r;
|
||||
++g;
|
||||
++b;
|
||||
++a;
|
||||
++r; ++g; ++b; ++a;
|
||||
}
|
||||
|
||||
color_type color() const { return color_type(r.y(), g.y(), b.y(), a.y()); }
|
||||
color_type color() const
|
||||
{
|
||||
return color_type(r.y(), g.y(), b.y(), a.y());
|
||||
}
|
||||
|
||||
private:
|
||||
agg::dda_line_interpolator<14> r, g, b, a;
|
||||
|
@ -79,32 +88,35 @@ struct color_interpolator<rgba8>
|
|||
|
||||
//========================================================================
|
||||
// Fast specialization for gray8
|
||||
template<>
|
||||
struct color_interpolator<gray8>
|
||||
template<> struct color_interpolator<gray8>
|
||||
{
|
||||
public:
|
||||
typedef gray8 color_type;
|
||||
|
||||
color_interpolator(const color_type& c1, const color_type& c2, unsigned len)
|
||||
: v(c1.v, c2.v, len)
|
||||
, a(c1.a, c2.a, len)
|
||||
color_interpolator(const color_type& c1,
|
||||
const color_type& c2,
|
||||
unsigned len) :
|
||||
v(c1.v, c2.v, len),
|
||||
a(c1.a, c2.a, len)
|
||||
{}
|
||||
|
||||
void operator ++ ()
|
||||
{
|
||||
++v;
|
||||
++a;
|
||||
++v; ++a;
|
||||
}
|
||||
|
||||
color_type color() const { return color_type(v.y(), a.y()); }
|
||||
color_type color() const
|
||||
{
|
||||
return color_type(v.y(), a.y());
|
||||
}
|
||||
|
||||
private:
|
||||
agg::dda_line_interpolator<14> v,a;
|
||||
};
|
||||
|
||||
//============================================================gradient_lut
|
||||
template<class ColorInterpolator, unsigned ColorLutSize = 256>
|
||||
class gradient_lut
|
||||
template<class ColorInterpolator,
|
||||
unsigned ColorLutSize=256> class gradient_lut
|
||||
{
|
||||
public:
|
||||
typedef ColorInterpolator interpolator_type;
|
||||
|
@ -112,9 +124,7 @@ class gradient_lut
|
|||
enum { color_lut_size = ColorLutSize };
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gradient_lut()
|
||||
: m_color_lut(color_lut_size)
|
||||
{}
|
||||
gradient_lut() : m_color_lut(color_lut_size) {}
|
||||
|
||||
// Build Gradient Lut
|
||||
// First, call remove_all(), then add_color() at least twice,
|
||||
|
@ -133,8 +143,14 @@ class gradient_lut
|
|||
// ColorF in span_gradient. All it needs is two access methods
|
||||
// size() and operator [].
|
||||
//--------------------------------------------------------------------
|
||||
static unsigned size() { return color_lut_size; }
|
||||
const color_type& operator[](unsigned i) const { return m_color_lut[i]; }
|
||||
static unsigned size()
|
||||
{
|
||||
return color_lut_size;
|
||||
}
|
||||
const color_type& operator [] (unsigned i) const
|
||||
{
|
||||
return m_color_lut[i];
|
||||
}
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -144,27 +160,32 @@ class gradient_lut
|
|||
color_type color;
|
||||
|
||||
color_point() {}
|
||||
color_point(double off, const color_type& c)
|
||||
: offset(off)
|
||||
, color(c)
|
||||
color_point(double off, const color_type& c) :
|
||||
offset(off), color(c)
|
||||
{
|
||||
if (offset < 0.0)
|
||||
offset = 0.0;
|
||||
if (offset > 1.0)
|
||||
offset = 1.0;
|
||||
if(offset < 0.0) offset = 0.0;
|
||||
if(offset > 1.0) offset = 1.0;
|
||||
}
|
||||
};
|
||||
typedef agg::pod_bvector<color_point, 4> color_profile_type;
|
||||
typedef agg::pod_array<color_type> color_lut_type;
|
||||
|
||||
static bool offset_less(const color_point& a, const color_point& b) { return a.offset < b.offset; }
|
||||
static bool offset_equal(const color_point& a, const color_point& b) { return a.offset == b.offset; }
|
||||
static bool offset_less(const color_point& a, const color_point& b)
|
||||
{
|
||||
return a.offset < b.offset;
|
||||
}
|
||||
static bool offset_equal(const color_point& a, const color_point& b)
|
||||
{
|
||||
return a.offset == b.offset;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
color_profile_type m_color_profile;
|
||||
color_lut_type m_color_lut;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S>
|
||||
void gradient_lut<T,S>::remove_all()
|
||||
|
@ -198,7 +219,9 @@ bool gradient_lut<T, S>::build_lut()
|
|||
for(i = 1; i < m_color_profile.size(); i++)
|
||||
{
|
||||
end = uround(m_color_profile[i].offset * color_lut_size);
|
||||
interpolator_type ci(m_color_profile[i - 1].color, m_color_profile[i].color, end - start + 1);
|
||||
interpolator_type ci(m_color_profile[i-1].color,
|
||||
m_color_profile[i ].color,
|
||||
end - start + 1);
|
||||
while(start < end)
|
||||
{
|
||||
m_color_lut[start] = ci.color();
|
||||
|
@ -215,6 +238,9 @@ bool gradient_lut<T, S>::build_lut()
|
|||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
47
deps/agg/include/agg_gsv_text.h
vendored
47
deps/agg/include/agg_gsv_text.h
vendored
|
@ -24,7 +24,9 @@
|
|||
#include "agg_conv_stroke.h"
|
||||
#include "agg_conv_transform.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
|
||||
//---------------------------------------------------------------gsv_text
|
||||
//
|
||||
|
@ -32,7 +34,13 @@ namespace agg {
|
|||
//
|
||||
class gsv_text
|
||||
{
|
||||
enum status { initial, next_char, start_glyph, glyph };
|
||||
enum status
|
||||
{
|
||||
initial,
|
||||
next_char,
|
||||
start_glyph,
|
||||
glyph
|
||||
};
|
||||
|
||||
public:
|
||||
gsv_text();
|
||||
|
@ -97,19 +105,28 @@ class gsv_text
|
|||
double m_h;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------gsv_text_outline
|
||||
template<class Transformer = trans_affine>
|
||||
class gsv_text_outline
|
||||
template<class Transformer = trans_affine> class gsv_text_outline
|
||||
{
|
||||
public:
|
||||
gsv_text_outline(gsv_text& text, const Transformer& trans)
|
||||
: m_polyline(text)
|
||||
, m_trans(m_polyline, trans)
|
||||
{}
|
||||
gsv_text_outline(gsv_text& text, const Transformer& trans) :
|
||||
m_polyline(text),
|
||||
m_trans(m_polyline, trans)
|
||||
{
|
||||
}
|
||||
|
||||
void width(double w) { m_polyline.width(w); }
|
||||
void width(double w)
|
||||
{
|
||||
m_polyline.width(w);
|
||||
}
|
||||
|
||||
void transformer(const Transformer* trans) { m_trans->transformer(trans); }
|
||||
void transformer(const Transformer* trans)
|
||||
{
|
||||
m_trans->transformer(trans);
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
|
@ -118,13 +135,19 @@ class gsv_text_outline
|
|||
m_polyline.line_cap(round_cap);
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y) { return m_trans.vertex(x, y); }
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return m_trans.vertex(x, y);
|
||||
}
|
||||
|
||||
private:
|
||||
conv_stroke<gsv_text> m_polyline;
|
||||
conv_transform<conv_stroke<gsv_text>, Transformer> m_trans;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
225
deps/agg/include/agg_image_accessors.h
vendored
225
deps/agg/include/agg_image_accessors.h
vendored
|
@ -18,11 +18,11 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------image_accessor_clip
|
||||
template<class PixFmt>
|
||||
class image_accessor_clip
|
||||
template<class PixFmt> class image_accessor_clip
|
||||
{
|
||||
public:
|
||||
typedef PixFmt pixfmt_type;
|
||||
|
@ -32,20 +32,28 @@ class image_accessor_clip
|
|||
enum pix_width_e { pix_width = pixfmt_type::pix_width };
|
||||
|
||||
image_accessor_clip() {}
|
||||
explicit image_accessor_clip(const pixfmt_type& pixf, const color_type& bk)
|
||||
: m_pixf(&pixf)
|
||||
explicit image_accessor_clip(const pixfmt_type& pixf,
|
||||
const color_type& bk) :
|
||||
m_pixf(&pixf)
|
||||
{
|
||||
pixfmt_type::make_pix(m_bk_buf, bk);
|
||||
}
|
||||
|
||||
void attach(const pixfmt_type& pixf) { m_pixf = &pixf; }
|
||||
void attach(const pixfmt_type& pixf)
|
||||
{
|
||||
m_pixf = &pixf;
|
||||
}
|
||||
|
||||
void background_color(const color_type& bk) { pixfmt_type::make_pix(m_bk_buf, bk); }
|
||||
void background_color(const color_type& bk)
|
||||
{
|
||||
pixfmt_type::make_pix(m_bk_buf, bk);
|
||||
}
|
||||
|
||||
private:
|
||||
AGG_INLINE const int8u* pixel() const
|
||||
{
|
||||
if (m_y >= 0 && m_y < (int)m_pixf->height() && m_x >= 0 && m_x < (int)m_pixf->width())
|
||||
if(m_y >= 0 && m_y < (int)m_pixf->height() &&
|
||||
m_x >= 0 && m_x < (int)m_pixf->width())
|
||||
{
|
||||
return m_pixf->pix_ptr(m_x, m_y);
|
||||
}
|
||||
|
@ -57,7 +65,8 @@ class image_accessor_clip
|
|||
{
|
||||
m_x = m_x0 = x;
|
||||
m_y = y;
|
||||
if (y >= 0 && y < (int)m_pixf->height() && x >= 0 && x + (int)len <= (int)m_pixf->width())
|
||||
if(y >= 0 && y < (int)m_pixf->height() &&
|
||||
x >= 0 && x+(int)len <= (int)m_pixf->width())
|
||||
{
|
||||
return m_pix_ptr = m_pixf->pix_ptr(x, y);
|
||||
}
|
||||
|
@ -67,8 +76,7 @@ class image_accessor_clip
|
|||
|
||||
AGG_INLINE const int8u* next_x()
|
||||
{
|
||||
if (m_pix_ptr)
|
||||
return m_pix_ptr += pix_width;
|
||||
if(m_pix_ptr) return m_pix_ptr += pix_width;
|
||||
++m_x;
|
||||
return pixel();
|
||||
}
|
||||
|
@ -77,7 +85,8 @@ class image_accessor_clip
|
|||
{
|
||||
++m_y;
|
||||
m_x = m_x0;
|
||||
if (m_pix_ptr && m_y >= 0 && m_y < (int)m_pixf->height())
|
||||
if(m_pix_ptr &&
|
||||
m_y >= 0 && m_y < (int)m_pixf->height())
|
||||
{
|
||||
return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y);
|
||||
}
|
||||
|
@ -92,9 +101,11 @@ class image_accessor_clip
|
|||
const int8u* m_pix_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------image_accessor_no_clip
|
||||
template<class PixFmt>
|
||||
class image_accessor_no_clip
|
||||
template<class PixFmt> class image_accessor_no_clip
|
||||
{
|
||||
public:
|
||||
typedef PixFmt pixfmt_type;
|
||||
|
@ -104,11 +115,14 @@ class image_accessor_no_clip
|
|||
enum pix_width_e { pix_width = pixfmt_type::pix_width };
|
||||
|
||||
image_accessor_no_clip() {}
|
||||
explicit image_accessor_no_clip(const pixfmt_type& pixf)
|
||||
: m_pixf(&pixf)
|
||||
explicit image_accessor_no_clip(const pixfmt_type& pixf) :
|
||||
m_pixf(&pixf)
|
||||
{}
|
||||
|
||||
void attach(const pixfmt_type& pixf) { m_pixf = &pixf; }
|
||||
void attach(const pixfmt_type& pixf)
|
||||
{
|
||||
m_pixf = &pixf;
|
||||
}
|
||||
|
||||
AGG_INLINE const int8u* span(int x, int y, unsigned)
|
||||
{
|
||||
|
@ -117,7 +131,10 @@ class image_accessor_no_clip
|
|||
return m_pix_ptr = m_pixf->pix_ptr(x, y);
|
||||
}
|
||||
|
||||
AGG_INLINE const int8u* next_x() { return m_pix_ptr += pix_width; }
|
||||
AGG_INLINE const int8u* next_x()
|
||||
{
|
||||
return m_pix_ptr += pix_width;
|
||||
}
|
||||
|
||||
AGG_INLINE const int8u* next_y()
|
||||
{
|
||||
|
@ -131,9 +148,11 @@ class image_accessor_no_clip
|
|||
const int8u* m_pix_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------image_accessor_clone
|
||||
template<class PixFmt>
|
||||
class image_accessor_clone
|
||||
template<class PixFmt> class image_accessor_clone
|
||||
{
|
||||
public:
|
||||
typedef PixFmt pixfmt_type;
|
||||
|
@ -143,25 +162,24 @@ class image_accessor_clone
|
|||
enum pix_width_e { pix_width = pixfmt_type::pix_width };
|
||||
|
||||
image_accessor_clone() {}
|
||||
explicit image_accessor_clone(const pixfmt_type& pixf)
|
||||
: m_pixf(&pixf)
|
||||
explicit image_accessor_clone(const pixfmt_type& pixf) :
|
||||
m_pixf(&pixf)
|
||||
{}
|
||||
|
||||
void attach(const pixfmt_type& pixf) { m_pixf = &pixf; }
|
||||
void attach(const pixfmt_type& pixf)
|
||||
{
|
||||
m_pixf = &pixf;
|
||||
}
|
||||
|
||||
private:
|
||||
AGG_INLINE const int8u* pixel() const
|
||||
{
|
||||
int x = m_x;
|
||||
int y = m_y;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
if (x >= (int)m_pixf->width())
|
||||
x = m_pixf->width() - 1;
|
||||
if (y >= (int)m_pixf->height())
|
||||
y = m_pixf->height() - 1;
|
||||
if(x < 0) x = 0;
|
||||
if(y < 0) y = 0;
|
||||
if(x >= (int)m_pixf->width()) x = m_pixf->width() - 1;
|
||||
if(y >= (int)m_pixf->height()) y = m_pixf->height() - 1;
|
||||
return m_pixf->pix_ptr(x, y);
|
||||
}
|
||||
|
||||
|
@ -170,7 +188,8 @@ class image_accessor_clone
|
|||
{
|
||||
m_x = m_x0 = x;
|
||||
m_y = y;
|
||||
if (y >= 0 && y < (int)m_pixf->height() && x >= 0 && x + (int)len <= (int)m_pixf->width())
|
||||
if(y >= 0 && y < (int)m_pixf->height() &&
|
||||
x >= 0 && x+(int)len <= (int)m_pixf->width())
|
||||
{
|
||||
return m_pix_ptr = m_pixf->pix_ptr(x, y);
|
||||
}
|
||||
|
@ -180,8 +199,7 @@ class image_accessor_clone
|
|||
|
||||
AGG_INLINE const int8u* next_x()
|
||||
{
|
||||
if (m_pix_ptr)
|
||||
return m_pix_ptr += pix_width;
|
||||
if(m_pix_ptr) return m_pix_ptr += pix_width;
|
||||
++m_x;
|
||||
return pixel();
|
||||
}
|
||||
|
@ -190,7 +208,8 @@ class image_accessor_clone
|
|||
{
|
||||
++m_y;
|
||||
m_x = m_x0;
|
||||
if (m_pix_ptr && m_y >= 0 && m_y < (int)m_pixf->height())
|
||||
if(m_pix_ptr &&
|
||||
m_y >= 0 && m_y < (int)m_pixf->height())
|
||||
{
|
||||
return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y);
|
||||
}
|
||||
|
@ -204,9 +223,12 @@ class image_accessor_clone
|
|||
const int8u* m_pix_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------image_accessor_wrap
|
||||
template<class PixFmt, class WrapX, class WrapY>
|
||||
class image_accessor_wrap
|
||||
template<class PixFmt, class WrapX, class WrapY> class image_accessor_wrap
|
||||
{
|
||||
public:
|
||||
typedef PixFmt pixfmt_type;
|
||||
|
@ -216,13 +238,16 @@ class image_accessor_wrap
|
|||
enum pix_width_e { pix_width = pixfmt_type::pix_width };
|
||||
|
||||
image_accessor_wrap() {}
|
||||
explicit image_accessor_wrap(const pixfmt_type& pixf)
|
||||
: m_pixf(&pixf)
|
||||
, m_wrap_x(pixf.width())
|
||||
, m_wrap_y(pixf.height())
|
||||
explicit image_accessor_wrap(const pixfmt_type& pixf) :
|
||||
m_pixf(&pixf),
|
||||
m_wrap_x(pixf.width()),
|
||||
m_wrap_y(pixf.height())
|
||||
{}
|
||||
|
||||
void attach(const pixfmt_type& pixf) { m_pixf = &pixf; }
|
||||
void attach(const pixfmt_type& pixf)
|
||||
{
|
||||
m_pixf = &pixf;
|
||||
}
|
||||
|
||||
AGG_INLINE const int8u* span(int x, int y, unsigned)
|
||||
{
|
||||
|
@ -251,83 +276,86 @@ class image_accessor_wrap
|
|||
WrapY m_wrap_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------wrap_mode_repeat
|
||||
class wrap_mode_repeat
|
||||
{
|
||||
public:
|
||||
wrap_mode_repeat() {}
|
||||
wrap_mode_repeat(unsigned size)
|
||||
: m_size(size)
|
||||
, m_add(size * (0x3FFFFFFF / size))
|
||||
, m_value(0)
|
||||
wrap_mode_repeat(unsigned size) :
|
||||
m_size(size),
|
||||
m_add(size * (0x3FFFFFFF / size)),
|
||||
m_value(0)
|
||||
{}
|
||||
|
||||
AGG_INLINE unsigned operator()(int v) { return m_value = (unsigned(v) + m_add) % m_size; }
|
||||
AGG_INLINE unsigned operator() (int v)
|
||||
{
|
||||
return m_value = (unsigned(v) + m_add) % m_size;
|
||||
}
|
||||
|
||||
AGG_INLINE unsigned operator++ ()
|
||||
{
|
||||
++m_value;
|
||||
if (m_value >= m_size)
|
||||
m_value = 0;
|
||||
if(m_value >= m_size) m_value = 0;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_size;
|
||||
unsigned m_add;
|
||||
unsigned m_value;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------wrap_mode_repeat_pow2
|
||||
class wrap_mode_repeat_pow2
|
||||
{
|
||||
public:
|
||||
wrap_mode_repeat_pow2() {}
|
||||
wrap_mode_repeat_pow2(unsigned size)
|
||||
: m_value(0)
|
||||
wrap_mode_repeat_pow2(unsigned size) : m_value(0)
|
||||
{
|
||||
m_mask = 1;
|
||||
while (m_mask < size)
|
||||
m_mask = (m_mask << 1) | 1;
|
||||
while(m_mask < size) m_mask = (m_mask << 1) | 1;
|
||||
m_mask >>= 1;
|
||||
}
|
||||
AGG_INLINE unsigned operator()(int v) { return m_value = unsigned(v) & m_mask; }
|
||||
AGG_INLINE unsigned operator() (int v)
|
||||
{
|
||||
return m_value = unsigned(v) & m_mask;
|
||||
}
|
||||
AGG_INLINE unsigned operator++ ()
|
||||
{
|
||||
++m_value;
|
||||
if (m_value > m_mask)
|
||||
m_value = 0;
|
||||
if(m_value > m_mask) m_value = 0;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_mask;
|
||||
unsigned m_value;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------wrap_mode_repeat_auto_pow2
|
||||
class wrap_mode_repeat_auto_pow2
|
||||
{
|
||||
public:
|
||||
wrap_mode_repeat_auto_pow2() {}
|
||||
wrap_mode_repeat_auto_pow2(unsigned size)
|
||||
: m_size(size)
|
||||
, m_add(size * (0x3FFFFFFF / size))
|
||||
, m_mask((m_size & (m_size - 1)) ? 0 : m_size - 1)
|
||||
, m_value(0)
|
||||
wrap_mode_repeat_auto_pow2(unsigned size) :
|
||||
m_size(size),
|
||||
m_add(size * (0x3FFFFFFF / size)),
|
||||
m_mask((m_size & (m_size-1)) ? 0 : m_size-1),
|
||||
m_value(0)
|
||||
{}
|
||||
|
||||
AGG_INLINE unsigned operator() (int v)
|
||||
{
|
||||
if (m_mask)
|
||||
return m_value = unsigned(v) & m_mask;
|
||||
if(m_mask) return m_value = unsigned(v) & m_mask;
|
||||
return m_value = (unsigned(v) + m_add) % m_size;
|
||||
}
|
||||
AGG_INLINE unsigned operator++ ()
|
||||
{
|
||||
++m_value;
|
||||
if (m_value >= m_size)
|
||||
m_value = 0;
|
||||
if(m_value >= m_size) m_value = 0;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
@ -338,36 +366,33 @@ class wrap_mode_repeat_auto_pow2
|
|||
unsigned m_value;
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------wrap_mode_reflect
|
||||
class wrap_mode_reflect
|
||||
{
|
||||
public:
|
||||
wrap_mode_reflect() {}
|
||||
wrap_mode_reflect(unsigned size)
|
||||
: m_size(size)
|
||||
, m_size2(size * 2)
|
||||
, m_add(m_size2 * (0x3FFFFFFF / m_size2))
|
||||
, m_value(0)
|
||||
wrap_mode_reflect(unsigned size) :
|
||||
m_size(size),
|
||||
m_size2(size * 2),
|
||||
m_add(m_size2 * (0x3FFFFFFF / m_size2)),
|
||||
m_value(0)
|
||||
{}
|
||||
|
||||
AGG_INLINE unsigned operator() (int v)
|
||||
{
|
||||
m_value = (unsigned(v) + m_add) % m_size2;
|
||||
if (m_value >= m_size)
|
||||
return m_size2 - m_value - 1;
|
||||
if(m_value >= m_size) return m_size2 - m_value - 1;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
AGG_INLINE unsigned operator++ ()
|
||||
{
|
||||
++m_value;
|
||||
if (m_value >= m_size2)
|
||||
m_value = 0;
|
||||
if (m_value >= m_size)
|
||||
return m_size2 - m_value - 1;
|
||||
if(m_value >= m_size2) m_value = 0;
|
||||
if(m_value >= m_size) return m_size2 - m_value - 1;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_size;
|
||||
unsigned m_size2;
|
||||
|
@ -375,13 +400,14 @@ class wrap_mode_reflect
|
|||
unsigned m_value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------wrap_mode_reflect_pow2
|
||||
class wrap_mode_reflect_pow2
|
||||
{
|
||||
public:
|
||||
wrap_mode_reflect_pow2() {}
|
||||
wrap_mode_reflect_pow2(unsigned size)
|
||||
: m_value(0)
|
||||
wrap_mode_reflect_pow2(unsigned size) : m_value(0)
|
||||
{
|
||||
m_mask = 1;
|
||||
m_size = 1;
|
||||
|
@ -394,52 +420,49 @@ class wrap_mode_reflect_pow2
|
|||
AGG_INLINE unsigned operator() (int v)
|
||||
{
|
||||
m_value = unsigned(v) & m_mask;
|
||||
if (m_value >= m_size)
|
||||
return m_mask - m_value;
|
||||
if(m_value >= m_size) return m_mask - m_value;
|
||||
return m_value;
|
||||
}
|
||||
AGG_INLINE unsigned operator++ ()
|
||||
{
|
||||
++m_value;
|
||||
m_value &= m_mask;
|
||||
if (m_value >= m_size)
|
||||
return m_mask - m_value;
|
||||
if(m_value >= m_size) return m_mask - m_value;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_size;
|
||||
unsigned m_mask;
|
||||
unsigned m_value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------wrap_mode_reflect_auto_pow2
|
||||
class wrap_mode_reflect_auto_pow2
|
||||
{
|
||||
public:
|
||||
wrap_mode_reflect_auto_pow2() {}
|
||||
wrap_mode_reflect_auto_pow2(unsigned size)
|
||||
: m_size(size)
|
||||
, m_size2(size * 2)
|
||||
, m_add(m_size2 * (0x3FFFFFFF / m_size2))
|
||||
, m_mask((m_size2 & (m_size2 - 1)) ? 0 : m_size2 - 1)
|
||||
, m_value(0)
|
||||
wrap_mode_reflect_auto_pow2(unsigned size) :
|
||||
m_size(size),
|
||||
m_size2(size * 2),
|
||||
m_add(m_size2 * (0x3FFFFFFF / m_size2)),
|
||||
m_mask((m_size2 & (m_size2-1)) ? 0 : m_size2-1),
|
||||
m_value(0)
|
||||
{}
|
||||
|
||||
AGG_INLINE unsigned operator() (int v)
|
||||
{
|
||||
m_value = m_mask ? unsigned(v) & m_mask : (unsigned(v) + m_add) % m_size2;
|
||||
if (m_value >= m_size)
|
||||
return m_size2 - m_value - 1;
|
||||
m_value = m_mask ? unsigned(v) & m_mask :
|
||||
(unsigned(v) + m_add) % m_size2;
|
||||
if(m_value >= m_size) return m_size2 - m_value - 1;
|
||||
return m_value;
|
||||
}
|
||||
AGG_INLINE unsigned operator++ ()
|
||||
{
|
||||
++m_value;
|
||||
if (m_value >= m_size2)
|
||||
m_value = 0;
|
||||
if (m_value >= m_size)
|
||||
return m_size2 - m_value - 1;
|
||||
if(m_value >= m_size2) m_value = 0;
|
||||
if(m_value >= m_size) return m_size2 - m_value - 1;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
@ -451,6 +474,8 @@ class wrap_mode_reflect_auto_pow2
|
|||
unsigned m_value;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
293
deps/agg/include/agg_image_filters.h
vendored
293
deps/agg/include/agg_image_filters.h
vendored
|
@ -24,28 +24,32 @@
|
|||
#include "agg_math.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
// See Implementation agg_image_filters.cpp
|
||||
|
||||
enum image_filter_scale_e {
|
||||
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 {
|
||||
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)
|
||||
template<class FilterF> void calculate(const FilterF& filter,
|
||||
bool normalization=true)
|
||||
{
|
||||
double r = filter.radius();
|
||||
realloc_lut(r);
|
||||
|
@ -55,7 +59,8 @@ class image_filter_lut
|
|||
{
|
||||
double x = double(i) / double(image_subpixel_scale);
|
||||
double y = filter.calc_weight(x);
|
||||
m_weight_array[pivot + i] = m_weight_array[pivot - i] =
|
||||
m_weight_array[pivot + i] =
|
||||
m_weight_array[pivot - i] =
|
||||
static_cast<std::int16_t>(iround(y * static_cast<double>(image_filter_scale)));
|
||||
}
|
||||
unsigned end = (diameter() << image_subpixel_shift) - 1;
|
||||
|
@ -66,14 +71,10 @@ class image_filter_lut
|
|||
}
|
||||
}
|
||||
|
||||
image_filter_lut()
|
||||
: m_radius(0)
|
||||
, m_diameter(0)
|
||||
, m_start(0)
|
||||
{}
|
||||
image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {}
|
||||
|
||||
template<class FilterF>
|
||||
image_filter_lut(const FilterF& filter, bool normalization = true)
|
||||
template<class FilterF> image_filter_lut(const FilterF& filter,
|
||||
bool normalization=true)
|
||||
{
|
||||
calculate(filter, normalization);
|
||||
}
|
||||
|
@ -95,43 +96,61 @@ class image_filter_lut
|
|||
pod_array<std::int16_t> m_weight_array;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------image_filter
|
||||
template<class FilterF>
|
||||
class image_filter : public image_filter_lut
|
||||
template<class FilterF> class image_filter : public image_filter_lut
|
||||
{
|
||||
public:
|
||||
image_filter() { calculate(m_filter_function); }
|
||||
|
||||
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; }
|
||||
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 * std::cos(pi * x); }
|
||||
static double calc_weight(double x)
|
||||
{
|
||||
return 0.5 + 0.5 * std::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 * std::cos(pi * x); }
|
||||
static double calc_weight(double x)
|
||||
{
|
||||
return 0.54 + 0.46 * std::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; }
|
||||
static double calc_weight(double x)
|
||||
{
|
||||
return (2.0 * x - 3.0) * x * x + 1.0;
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------image_filter_quadric
|
||||
|
@ -141,13 +160,8 @@ struct image_filter_quadric
|
|||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
@ -155,13 +169,18 @@ struct image_filter_quadric
|
|||
//------------------------------------------------image_filter_bicubic
|
||||
class image_filter_bicubic
|
||||
{
|
||||
static double pow3(double x) { return (x <= 0.0) ? 0.0 : x * x * x; }
|
||||
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));
|
||||
return
|
||||
(1.0/6.0) *
|
||||
(pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -173,15 +192,17 @@ class image_filter_kaiser
|
|||
double epsilon;
|
||||
|
||||
public:
|
||||
image_filter_kaiser(double b = 6.33)
|
||||
: a(b)
|
||||
, epsilon(1e-12)
|
||||
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; }
|
||||
double calc_weight(double x) const
|
||||
{
|
||||
return bessel_i0(a * sqrt(1. - x * x)) * i0a;
|
||||
}
|
||||
|
||||
private:
|
||||
double bessel_i0(double x) const
|
||||
|
@ -208,10 +229,8 @@ 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)));
|
||||
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.;
|
||||
}
|
||||
};
|
||||
|
@ -223,27 +242,26 @@ class image_filter_mitchell
|
|||
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)
|
||||
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));
|
||||
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
|
||||
{
|
||||
|
@ -258,6 +276,7 @@ struct image_filter_spline16
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------image_filter_spline36
|
||||
struct image_filter_spline36
|
||||
{
|
||||
|
@ -276,248 +295,156 @@ struct image_filter_spline36
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------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); }
|
||||
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); }
|
||||
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)
|
||||
{}
|
||||
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;
|
||||
if(x == 0.0) return 1.0;
|
||||
x *= pi;
|
||||
return std::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)
|
||||
{}
|
||||
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;
|
||||
if(x == 0.0) return 1.0;
|
||||
if(x > m_radius) return 0.0;
|
||||
x *= pi;
|
||||
double xr = x / m_radius;
|
||||
return (std::sin(x) / x) * (std::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)
|
||||
{}
|
||||
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;
|
||||
if(x == 0.0) return 1.0;
|
||||
if(x > m_radius) return 0.0;
|
||||
x *= pi;
|
||||
double xr = x / m_radius;
|
||||
return (std::sin(x) / x) * (0.42 + 0.5 * std::cos(xr) + 0.08 * std::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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ 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)
|
||||
{}
|
||||
};
|
||||
{ public: image_filter_blackman256() : image_filter_blackman(8.0){} };
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
63
deps/agg/include/agg_line_aa_basics.h
vendored
63
deps/agg/include/agg_line_aa_basics.h
vendored
|
@ -18,12 +18,14 @@
|
|||
#include <cstdlib>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
// See Implementation agg_line_aa_basics.cpp
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
enum line_subpixel_scale_e {
|
||||
enum line_subpixel_scale_e
|
||||
{
|
||||
line_subpixel_shift = 8, //----line_subpixel_shift
|
||||
line_subpixel_scale = 1 << line_subpixel_shift, //----line_subpixel_scale
|
||||
line_subpixel_mask = line_subpixel_scale - 1, //----line_subpixel_mask
|
||||
|
@ -32,7 +34,8 @@ enum line_subpixel_scale_e {
|
|||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
enum line_mr_subpixel_scale_e {
|
||||
enum line_mr_subpixel_scale_e
|
||||
{
|
||||
line_mr_subpixel_shift = 4, //----line_mr_subpixel_shift
|
||||
line_mr_subpixel_scale = 1 << line_mr_subpixel_shift, //----line_mr_subpixel_scale
|
||||
line_mr_subpixel_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask
|
||||
|
@ -59,7 +62,10 @@ AGG_INLINE int line_dbl_hr(int x)
|
|||
//---------------------------------------------------------------line_coord
|
||||
struct line_coord
|
||||
{
|
||||
AGG_INLINE static int conv(double x) { return iround(x * static_cast<double>(line_subpixel_scale)); }
|
||||
AGG_INLINE static int conv(double x)
|
||||
{
|
||||
return iround(x * static_cast<double>(line_subpixel_scale));
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------line_coord_sat
|
||||
|
@ -76,20 +82,18 @@ struct line_parameters
|
|||
{
|
||||
//---------------------------------------------------------------------
|
||||
line_parameters() {}
|
||||
line_parameters(int x1_, int y1_, int x2_, int y2_, int len_)
|
||||
: x1(x1_)
|
||||
, y1(y1_)
|
||||
, x2(x2_)
|
||||
, y2(y2_)
|
||||
, dx(std::abs(x2_ - x1_))
|
||||
, dy(std::abs(y2_ - y1_))
|
||||
, sx((x2_ > x1_) ? 1 : -1)
|
||||
, sy((y2_ > y1_) ? 1 : -1)
|
||||
, vertical(dy >= dx)
|
||||
, inc(vertical ? sy : sx)
|
||||
, len(len_)
|
||||
, octant((sy & 4) | (sx & 2) | int(vertical))
|
||||
{}
|
||||
line_parameters(int x1_, int y1_, int x2_, int y2_, int len_) :
|
||||
x1(x1_), y1(y1_), x2(x2_), y2(y2_),
|
||||
dx(std::abs(x2_ - x1_)),
|
||||
dy(std::abs(y2_ - y1_)),
|
||||
sx((x2_ > x1_) ? 1 : -1),
|
||||
sy((y2_ > y1_) ? 1 : -1),
|
||||
vertical(dy >= dx),
|
||||
inc(vertical ? sy : sx),
|
||||
len(len_),
|
||||
octant((sy & 4) | (sx & 2) | int(vertical))
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
unsigned orthogonal_quadrant() const { return s_orthogonal_quadrant[octant]; }
|
||||
|
@ -142,15 +146,22 @@ struct line_parameters
|
|||
static const int8u s_diagonal_quadrant[8];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// See Implementation agg_line_aa_basics.cpp
|
||||
|
||||
//----------------------------------------------------------------bisectrix
|
||||
void bisectrix(const line_parameters& l1, const line_parameters& l2, int* x, int* y);
|
||||
void bisectrix(const line_parameters& l1,
|
||||
const line_parameters& l2,
|
||||
int* x, int* y);
|
||||
|
||||
|
||||
//-------------------------------------------fix_degenerate_bisectrix_start
|
||||
void inline fix_degenerate_bisectrix_start(const line_parameters& lp, int* x, int* y)
|
||||
void inline fix_degenerate_bisectrix_start(const line_parameters& lp,
|
||||
int* x, int* y)
|
||||
{
|
||||
int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len);
|
||||
int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) -
|
||||
double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len);
|
||||
if(d < line_subpixel_scale/2)
|
||||
{
|
||||
*x = lp.x1 + (lp.y2 - lp.y1);
|
||||
|
@ -158,10 +169,13 @@ void inline fix_degenerate_bisectrix_start(const line_parameters& lp, int* x, in
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------fix_degenerate_bisectrix_end
|
||||
void inline fix_degenerate_bisectrix_end(const line_parameters& lp, int* x, int* y)
|
||||
void inline fix_degenerate_bisectrix_end(const line_parameters& lp,
|
||||
int* x, int* y)
|
||||
{
|
||||
int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len);
|
||||
int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) -
|
||||
double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len);
|
||||
if(d < line_subpixel_scale/2)
|
||||
{
|
||||
*x = lp.x2 + (lp.y2 - lp.y1);
|
||||
|
@ -169,6 +183,7 @@ void inline fix_degenerate_bisectrix_end(const line_parameters& lp, int* x, int*
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
114
deps/agg/include/agg_math.h
vendored
114
deps/agg/include/agg_math.h
vendored
|
@ -22,7 +22,8 @@
|
|||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//------------------------------------------------------vertex_dist_epsilon
|
||||
// Coinciding points maximal distance (Epsilon)
|
||||
|
@ -33,13 +34,18 @@ const double vertex_dist_epsilon = 1e-5;
|
|||
const double intersection_epsilon = 1.0e-30;
|
||||
|
||||
//------------------------------------------------------------cross_product
|
||||
AGG_INLINE double cross_product(double x1, double y1, double x2, double y2, double x, double y)
|
||||
AGG_INLINE double cross_product(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x, double y)
|
||||
{
|
||||
return (x - x2) * (y2 - y1) - (y - y2) * (x2 - x1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------point_in_triangle
|
||||
AGG_INLINE bool point_in_triangle(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y)
|
||||
AGG_INLINE bool point_in_triangle(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double x, double y)
|
||||
{
|
||||
bool cp1 = cross_product(x1, y1, x2, y2, x, y) < 0.0;
|
||||
bool cp2 = cross_product(x2, y2, x3, y3, x, y) < 0.0;
|
||||
|
@ -64,7 +70,9 @@ AGG_INLINE double calc_sq_distance(double x1, double y1, double x2, double y2)
|
|||
}
|
||||
|
||||
//------------------------------------------------calc_line_point_distance
|
||||
AGG_INLINE double calc_line_point_distance(double x1, double y1, double x2, double y2, double x, double y)
|
||||
AGG_INLINE double calc_line_point_distance(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x, double y)
|
||||
{
|
||||
double dx = x2-x1;
|
||||
double dy = y2-y1;
|
||||
|
@ -77,7 +85,9 @@ AGG_INLINE double calc_line_point_distance(double x1, double y1, double x2, doub
|
|||
}
|
||||
|
||||
//-------------------------------------------------------calc_line_point_u
|
||||
AGG_INLINE double calc_segment_point_u(double x1, double y1, double x2, double y2, double x, double y)
|
||||
AGG_INLINE double calc_segment_point_u(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x, double y)
|
||||
{
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
|
@ -94,14 +104,17 @@ AGG_INLINE double calc_segment_point_u(double x1, double y1, double x2, double y
|
|||
}
|
||||
|
||||
//---------------------------------------------calc_line_point_sq_distance
|
||||
AGG_INLINE double
|
||||
calc_segment_point_sq_distance(double x1, double y1, double x2, double y2, double x, double y, double u)
|
||||
AGG_INLINE double calc_segment_point_sq_distance(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x, double y,
|
||||
double u)
|
||||
{
|
||||
if(u <= 0)
|
||||
{
|
||||
return calc_sq_distance(x, y, x1, y1);
|
||||
}
|
||||
else if (u >= 1)
|
||||
else
|
||||
if(u >= 1)
|
||||
{
|
||||
return calc_sq_distance(x, y, x2, y2);
|
||||
}
|
||||
|
@ -109,27 +122,24 @@ AGG_INLINE double
|
|||
}
|
||||
|
||||
//---------------------------------------------calc_line_point_sq_distance
|
||||
AGG_INLINE double calc_segment_point_sq_distance(double x1, double y1, double x2, double y2, double x, double y)
|
||||
AGG_INLINE double calc_segment_point_sq_distance(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x, double y)
|
||||
{
|
||||
return calc_segment_point_sq_distance(x1, y1, x2, y2, x, y, calc_segment_point_u(x1, y1, x2, y2, x, y));
|
||||
return
|
||||
calc_segment_point_sq_distance(
|
||||
x1, y1, x2, y2, x, y,
|
||||
calc_segment_point_u(x1, y1, x2, y2, x, y));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------calc_intersection
|
||||
AGG_INLINE bool calc_intersection(double ax,
|
||||
double ay,
|
||||
double bx,
|
||||
double by,
|
||||
double cx,
|
||||
double cy,
|
||||
double dx,
|
||||
double dy,
|
||||
double* x,
|
||||
double* y)
|
||||
AGG_INLINE bool calc_intersection(double ax, double ay, double bx, double by,
|
||||
double cx, double cy, double dx, double dy,
|
||||
double* x, double* y)
|
||||
{
|
||||
double num = (ay-cy) * (dx-cx) - (ax-cx) * (dy-cy);
|
||||
double den = (bx-ax) * (dy-cy) - (by-ay) * (dx-cx);
|
||||
if (std::fabs(den) < intersection_epsilon)
|
||||
return false;
|
||||
if(std::fabs(den) < intersection_epsilon) return false;
|
||||
double r = num / den;
|
||||
*x = ax + r * (bx-ax);
|
||||
*y = ay + r * (by-ay);
|
||||
|
@ -137,8 +147,8 @@ AGG_INLINE bool calc_intersection(double ax,
|
|||
}
|
||||
|
||||
//-----------------------------------------------------intersection_exists
|
||||
AGG_INLINE bool
|
||||
intersection_exists(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
|
||||
AGG_INLINE bool intersection_exists(double x1, double y1, double x2, double y2,
|
||||
double x3, double y3, double x4, double y4)
|
||||
{
|
||||
// It's less expensive but you can't control the
|
||||
// boundary conditions: Less or LessEqual
|
||||
|
@ -146,8 +156,10 @@ AGG_INLINE bool
|
|||
double dy1 = y2 - y1;
|
||||
double dx2 = x4 - x3;
|
||||
double dy2 = y4 - y3;
|
||||
return ((x3 - x2) * dy1 - (y3 - y2) * dx1 < 0.0) != ((x4 - x2) * dy1 - (y4 - y2) * dx1 < 0.0) &&
|
||||
((x1 - x4) * dy2 - (y1 - y4) * dx2 < 0.0) != ((x2 - x4) * dy2 - (y2 - y4) * dx2 < 0.0);
|
||||
return ((x3 - x2) * dy1 - (y3 - y2) * dx1 < 0.0) !=
|
||||
((x4 - x2) * dy1 - (y4 - y2) * dx1 < 0.0) &&
|
||||
((x1 - x4) * dy2 - (y1 - y4) * dx2 < 0.0) !=
|
||||
((x2 - x4) * dy2 - (y2 - y4) * dx2 < 0.0);
|
||||
|
||||
// It's is more expensive but more flexible
|
||||
// in terms of boundary conditions.
|
||||
|
@ -162,7 +174,10 @@ AGG_INLINE bool
|
|||
}
|
||||
|
||||
//--------------------------------------------------------calc_orthogonal
|
||||
AGG_INLINE void calc_orthogonal(double thickness, double x1, double y1, double x2, double y2, double* x, double* y)
|
||||
AGG_INLINE void calc_orthogonal(double thickness,
|
||||
double x1, double y1,
|
||||
double x2, double y2,
|
||||
double* x, double* y)
|
||||
{
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
|
@ -172,8 +187,11 @@ AGG_INLINE void calc_orthogonal(double thickness, double x1, double y1, double x
|
|||
}
|
||||
|
||||
//--------------------------------------------------------dilate_triangle
|
||||
AGG_INLINE void
|
||||
dilate_triangle(double x1, double y1, double x2, double y2, double x3, double y3, double* x, double* y, double d)
|
||||
AGG_INLINE void dilate_triangle(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double *x, double* y,
|
||||
double d)
|
||||
{
|
||||
double dx1=0.0;
|
||||
double dy1=0.0;
|
||||
|
@ -192,29 +210,24 @@ AGG_INLINE void
|
|||
calc_orthogonal(d, x2, y2, x3, y3, &dx2, &dy2);
|
||||
calc_orthogonal(d, x3, y3, x1, y1, &dx3, &dy3);
|
||||
}
|
||||
*x++ = x1 + dx1;
|
||||
*y++ = y1 + dy1;
|
||||
*x++ = x2 + dx1;
|
||||
*y++ = y2 + dy1;
|
||||
*x++ = x2 + dx2;
|
||||
*y++ = y2 + dy2;
|
||||
*x++ = x3 + dx2;
|
||||
*y++ = y3 + dy2;
|
||||
*x++ = x3 + dx3;
|
||||
*y++ = y3 + dy3;
|
||||
*x++ = x1 + dx3;
|
||||
*y++ = y1 + dy3;
|
||||
*x++ = x1 + dx1; *y++ = y1 + dy1;
|
||||
*x++ = x2 + dx1; *y++ = y2 + dy1;
|
||||
*x++ = x2 + dx2; *y++ = y2 + dy2;
|
||||
*x++ = x3 + dx2; *y++ = y3 + dy2;
|
||||
*x++ = x3 + dx3; *y++ = y3 + dy3;
|
||||
*x++ = x1 + dx3; *y++ = y1 + dy3;
|
||||
}
|
||||
|
||||
//------------------------------------------------------calc_triangle_area
|
||||
AGG_INLINE double calc_triangle_area(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
AGG_INLINE double calc_triangle_area(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3)
|
||||
{
|
||||
return (x1*y2 - x2*y1 + x2*y3 - x3*y2 + x3*y1 - x1*y3) * 0.5;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------calc_polygon_area
|
||||
template<class Storage>
|
||||
double calc_polygon_area(const Storage& st)
|
||||
template<class Storage> double calc_polygon_area(const Storage& st)
|
||||
{
|
||||
unsigned i;
|
||||
double sum = 0.0;
|
||||
|
@ -238,6 +251,7 @@ double calc_polygon_area(const Storage& st)
|
|||
extern int16u g_sqrt_table[1024];
|
||||
extern int8 g_elder_bit_table[256];
|
||||
|
||||
|
||||
//---------------------------------------------------------------fast_sqrt
|
||||
//Fast integer Sqrt - really fast: no cycles, divisions or multiplications
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -251,7 +265,8 @@ AGG_INLINE unsigned fast_sqrt(unsigned val)
|
|||
//The key command here is bsr - determination the number of the most
|
||||
//significant bit of the value. For other processors
|
||||
//(and maybe compilers) the pure C "#else" section is used.
|
||||
__asm {
|
||||
__asm
|
||||
{
|
||||
mov ebx, val
|
||||
mov edx, 11
|
||||
bsr ecx, ebx
|
||||
|
@ -322,6 +337,9 @@ AGG_INLINE unsigned fast_sqrt(unsigned val)
|
|||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------besj
|
||||
// Function BESJ calculates Bessel function of first kind of order n
|
||||
// Arguments:
|
||||
|
@ -354,8 +372,7 @@ inline double besj(double x, int n)
|
|||
double b = 0;
|
||||
if(std::fabs(x) <= d)
|
||||
{
|
||||
if (n != 0)
|
||||
return 0;
|
||||
if(n != 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
double b1 = 0; // b1 is the value from the previous iteration
|
||||
|
@ -414,6 +431,7 @@ inline double besj(double x, int n)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
175
deps/agg/include/agg_math_stroke.h
vendored
175
deps/agg/include/agg_math_stroke.h
vendored
|
@ -23,19 +23,38 @@
|
|||
#include "agg_math.h"
|
||||
#include "agg_vertex_sequence.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//-------------------------------------------------------------line_cap_e
|
||||
enum line_cap_e { butt_cap, square_cap, round_cap };
|
||||
enum line_cap_e
|
||||
{
|
||||
butt_cap,
|
||||
square_cap,
|
||||
round_cap
|
||||
};
|
||||
|
||||
//------------------------------------------------------------line_join_e
|
||||
enum line_join_e { miter_join = 0, miter_join_revert = 1, round_join = 2, bevel_join = 3, miter_join_round = 4 };
|
||||
enum line_join_e
|
||||
{
|
||||
miter_join = 0,
|
||||
miter_join_revert = 1,
|
||||
round_join = 2,
|
||||
bevel_join = 3,
|
||||
miter_join_round = 4
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------inner_join_e
|
||||
enum inner_join_e { inner_bevel, inner_miter, inner_jag, inner_round };
|
||||
enum inner_join_e
|
||||
{
|
||||
inner_bevel,
|
||||
inner_miter,
|
||||
inner_jag,
|
||||
inner_round
|
||||
};
|
||||
|
||||
//------------------------------------------------------------math_stroke
|
||||
template<class VertexConsumer>
|
||||
class math_stroke
|
||||
template<class VertexConsumer> class math_stroke
|
||||
{
|
||||
public:
|
||||
typedef typename VertexConsumer::value_type coord_type;
|
||||
|
@ -61,7 +80,10 @@ class math_stroke
|
|||
double inner_miter_limit() const { return m_inner_miter_limit; }
|
||||
double approximation_scale() const { return m_approx_scale; }
|
||||
|
||||
void calc_cap(VertexConsumer& vc, const vertex_dist& v0, const vertex_dist& v1, double len);
|
||||
void calc_cap(VertexConsumer& vc,
|
||||
const vertex_dist& v0,
|
||||
const vertex_dist& v1,
|
||||
double len);
|
||||
|
||||
void calc_join(VertexConsumer& vc,
|
||||
const vertex_dist& v0,
|
||||
|
@ -71,18 +93,22 @@ class math_stroke
|
|||
double len2);
|
||||
|
||||
private:
|
||||
AGG_INLINE void add_vertex(VertexConsumer& vc, double x, double y) { vc.add(coord_type(x, y)); }
|
||||
AGG_INLINE void add_vertex(VertexConsumer& vc, double x, double y)
|
||||
{
|
||||
vc.add(coord_type(x, y));
|
||||
}
|
||||
|
||||
void calc_arc(VertexConsumer& vc, double x, double y, double dx1, double dy1, double dx2, double dy2);
|
||||
void calc_arc(VertexConsumer& vc,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2);
|
||||
|
||||
void calc_miter(VertexConsumer& vc,
|
||||
const vertex_dist& v0,
|
||||
const vertex_dist& v1,
|
||||
const vertex_dist& v2,
|
||||
double dx1,
|
||||
double dy1,
|
||||
double dx2,
|
||||
double dy2,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
line_join_e lj,
|
||||
double mlimit,
|
||||
double dbevel);
|
||||
|
@ -100,23 +126,22 @@ class math_stroke
|
|||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
template<class VC>
|
||||
math_stroke<VC>::math_stroke()
|
||||
: m_width(0.5)
|
||||
, m_width_abs(0.5)
|
||||
, m_width_eps(0.5 / 1024.0)
|
||||
, m_width_sign(1)
|
||||
, m_miter_limit(4.0)
|
||||
, m_inner_miter_limit(1.01)
|
||||
, m_approx_scale(1.0)
|
||||
, m_line_cap(butt_cap)
|
||||
, m_line_join(miter_join)
|
||||
, m_inner_join(inner_miter)
|
||||
{}
|
||||
template<class VC> math_stroke<VC>::math_stroke() :
|
||||
m_width(0.5),
|
||||
m_width_abs(0.5),
|
||||
m_width_eps(0.5/1024.0),
|
||||
m_width_sign(1),
|
||||
m_miter_limit(4.0),
|
||||
m_inner_miter_limit(1.01),
|
||||
m_approx_scale(1.0),
|
||||
m_line_cap(butt_cap),
|
||||
m_line_join(miter_join),
|
||||
m_inner_join(inner_miter)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void math_stroke<VC>::width(double w)
|
||||
template<class VC> void math_stroke<VC>::width(double w)
|
||||
{
|
||||
m_width = w * 0.5;
|
||||
if(m_width < 0)
|
||||
|
@ -133,15 +158,17 @@ void math_stroke<VC>::width(double w)
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void math_stroke<VC>::miter_limit_theta(double t)
|
||||
template<class VC> void math_stroke<VC>::miter_limit_theta(double t)
|
||||
{
|
||||
m_miter_limit = 1.0 / std::sin(t * 0.5) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void math_stroke<VC>::calc_arc(VC& vc, double x, double y, double dx1, double dy1, double dx2, double dy2)
|
||||
void math_stroke<VC>::calc_arc(VC& vc,
|
||||
double x, double y,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2)
|
||||
{
|
||||
double a1 = std::atan2(dy1 * m_width_sign, dx1 * m_width_sign);
|
||||
double a2 = std::atan2(dy2 * m_width_sign, dx2 * m_width_sign);
|
||||
|
@ -153,8 +180,7 @@ void math_stroke<VC>::calc_arc(VC& vc, double x, double y, double dx1, double dy
|
|||
add_vertex(vc, x + dx1, y + dy1);
|
||||
if(m_width_sign > 0)
|
||||
{
|
||||
if (a1 > a2)
|
||||
a2 += 2 * pi;
|
||||
if(a1 > a2) a2 += 2 * pi;
|
||||
n = int((a2 - a1) / da);
|
||||
da = (a2 - a1) / (n + 1);
|
||||
a1 += da;
|
||||
|
@ -166,8 +192,7 @@ void math_stroke<VC>::calc_arc(VC& vc, double x, double y, double dx1, double dy
|
|||
}
|
||||
else
|
||||
{
|
||||
if (a1 < a2)
|
||||
a2 -= 2 * pi;
|
||||
if(a1 < a2) a2 -= 2 * pi;
|
||||
n = int((a1 - a2) / da);
|
||||
da = (a1 - a2) / (n + 1);
|
||||
a1 -= da;
|
||||
|
@ -186,10 +211,8 @@ void math_stroke<VC>::calc_miter(VC& vc,
|
|||
const vertex_dist& v0,
|
||||
const vertex_dist& v1,
|
||||
const vertex_dist& v2,
|
||||
double dx1,
|
||||
double dy1,
|
||||
double dx2,
|
||||
double dy2,
|
||||
double dx1, double dy1,
|
||||
double dx2, double dy2,
|
||||
line_join_e lj,
|
||||
double mlimit,
|
||||
double dbevel)
|
||||
|
@ -201,16 +224,11 @@ void math_stroke<VC>::calc_miter(VC& vc,
|
|||
bool miter_limit_exceeded = true; // Assume the worst
|
||||
bool intersection_failed = true; // Assume the worst
|
||||
|
||||
if (calc_intersection(v0.x + dx1,
|
||||
v0.y - dy1,
|
||||
v1.x + dx1,
|
||||
v1.y - dy1,
|
||||
v1.x + dx2,
|
||||
v1.y - dy2,
|
||||
v2.x + dx2,
|
||||
v2.y - dy2,
|
||||
&xi,
|
||||
&yi))
|
||||
if(calc_intersection(v0.x + dx1, v0.y - dy1,
|
||||
v1.x + dx1, v1.y - dy1,
|
||||
v1.x + dx2, v1.y - dy2,
|
||||
v2.x + dx2, v2.y - dy2,
|
||||
&xi, &yi))
|
||||
{
|
||||
// Calculation of the intersection succeeded
|
||||
//---------------------
|
||||
|
@ -272,8 +290,10 @@ void math_stroke<VC>::calc_miter(VC& vc,
|
|||
if(intersection_failed)
|
||||
{
|
||||
mlimit *= m_width_sign;
|
||||
add_vertex(vc, v1.x + dx1 + dy1 * mlimit, v1.y - dy1 + dx1 * mlimit);
|
||||
add_vertex(vc, v1.x + dx2 - dy2 * mlimit, v1.y - dy2 - dx2 * mlimit);
|
||||
add_vertex(vc, v1.x + dx1 + dy1 * mlimit,
|
||||
v1.y - dy1 + dx1 * mlimit);
|
||||
add_vertex(vc, v1.x + dx2 - dy2 * mlimit,
|
||||
v1.y - dy2 - dx2 * mlimit);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -282,8 +302,10 @@ void math_stroke<VC>::calc_miter(VC& vc,
|
|||
double x2 = v1.x + dx2;
|
||||
double y2 = v1.y - dy2;
|
||||
di = (lim - dbevel) / (di - dbevel);
|
||||
add_vertex(vc, x1 + (xi - x1) * di, y1 + (yi - y1) * di);
|
||||
add_vertex(vc, x2 + (xi - x2) * di, y2 + (yi - y2) * di);
|
||||
add_vertex(vc, x1 + (xi - x1) * di,
|
||||
y1 + (yi - y1) * di);
|
||||
add_vertex(vc, x2 + (xi - x2) * di,
|
||||
y2 + (yi - y2) * di);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -292,7 +314,10 @@ void math_stroke<VC>::calc_miter(VC& vc,
|
|||
|
||||
//--------------------------------------------------------stroke_calc_cap
|
||||
template<class VC>
|
||||
void math_stroke<VC>::calc_cap(VC& vc, const vertex_dist& v0, const vertex_dist& v1, double len)
|
||||
void math_stroke<VC>::calc_cap(VC& vc,
|
||||
const vertex_dist& v0,
|
||||
const vertex_dist& v1,
|
||||
double len)
|
||||
{
|
||||
vc.remove_all();
|
||||
|
||||
|
@ -329,7 +354,8 @@ void math_stroke<VC>::calc_cap(VC& vc, const vertex_dist& v0, const vertex_dist&
|
|||
a1 += da;
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
add_vertex(vc, v0.x + std::cos(a1) * m_width, v0.y + std::sin(a1) * m_width);
|
||||
add_vertex(vc, v0.x + std::cos(a1) * m_width,
|
||||
v0.y + std::sin(a1) * m_width);
|
||||
a1 += da;
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +365,8 @@ void math_stroke<VC>::calc_cap(VC& vc, const vertex_dist& v0, const vertex_dist&
|
|||
a1 -= da;
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
add_vertex(vc, v0.x + std::cos(a1) * m_width, v0.y + std::sin(a1) * m_width);
|
||||
add_vertex(vc, v0.x + std::cos(a1) * m_width,
|
||||
v0.y + std::sin(a1) * m_width);
|
||||
a1 -= da;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +409,10 @@ void math_stroke<VC>::calc_join(VC& vc,
|
|||
break;
|
||||
|
||||
case inner_miter:
|
||||
calc_miter(vc, v0, v1, v2, dx1, dy1, dx2, dy2, miter_join_revert, limit, 0);
|
||||
calc_miter(vc,
|
||||
v0, v1, v2, dx1, dy1, dx2, dy2,
|
||||
miter_join_revert,
|
||||
limit, 0);
|
||||
break;
|
||||
|
||||
case inner_jag:
|
||||
|
@ -390,7 +420,10 @@ void math_stroke<VC>::calc_join(VC& vc,
|
|||
cp = (dx1-dx2) * (dx1-dx2) + (dy1-dy2) * (dy1-dy2);
|
||||
if(cp < len1 * len1 && cp < len2 * len2)
|
||||
{
|
||||
calc_miter(vc, v0, v1, v2, dx1, dy1, dx2, dy2, miter_join_revert, limit, 0);
|
||||
calc_miter(vc,
|
||||
v0, v1, v2, dx1, dy1, dx2, dy2,
|
||||
miter_join_revert,
|
||||
limit, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -445,16 +478,11 @@ void math_stroke<VC>::calc_join(VC& vc,
|
|||
//-------------------
|
||||
if(m_approx_scale * (m_width_abs - dbevel) < m_width_eps)
|
||||
{
|
||||
if (calc_intersection(v0.x + dx1,
|
||||
v0.y - dy1,
|
||||
v1.x + dx1,
|
||||
v1.y - dy1,
|
||||
v1.x + dx2,
|
||||
v1.y - dy2,
|
||||
v2.x + dx2,
|
||||
v2.y - dy2,
|
||||
&dx,
|
||||
&dy))
|
||||
if(calc_intersection(v0.x + dx1, v0.y - dy1,
|
||||
v1.x + dx1, v1.y - dy1,
|
||||
v1.x + dx2, v1.y - dy2,
|
||||
v2.x + dx2, v2.y - dy2,
|
||||
&dx, &dy))
|
||||
{
|
||||
add_vertex(vc, dx, dy);
|
||||
}
|
||||
|
@ -471,7 +499,11 @@ void math_stroke<VC>::calc_join(VC& vc,
|
|||
case miter_join:
|
||||
case miter_join_revert:
|
||||
case miter_join_round:
|
||||
calc_miter(vc, v0, v1, v2, dx1, dy1, dx2, dy2, m_line_join, m_miter_limit, dbevel);
|
||||
calc_miter(vc,
|
||||
v0, v1, v2, dx1, dy1, dx2, dy2,
|
||||
m_line_join,
|
||||
m_miter_limit,
|
||||
dbevel);
|
||||
break;
|
||||
|
||||
case round_join:
|
||||
|
@ -486,6 +518,9 @@ void math_stroke<VC>::calc_join(VC& vc,
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
5
deps/agg/include/agg_path_length.h
vendored
5
deps/agg/include/agg_path_length.h
vendored
|
@ -17,7 +17,8 @@
|
|||
|
||||
#include "agg_math.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
template<class VertexSource>
|
||||
double path_length(VertexSource& vs, unsigned path_id = 0)
|
||||
{
|
||||
|
@ -59,6 +60,6 @@ double path_length(VertexSource& vs, unsigned path_id = 0)
|
|||
}
|
||||
return len;
|
||||
}
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
436
deps/agg/include/agg_path_storage.h
vendored
436
deps/agg/include/agg_path_storage.h
vendored
|
@ -22,7 +22,9 @@
|
|||
#include "agg_array.h"
|
||||
#include "agg_bezier_arc.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
|
||||
//----------------------------------------------------vertex_block_storage
|
||||
template<class T, unsigned BlockShift=8, unsigned BlockPool=256>
|
||||
|
@ -30,7 +32,8 @@ class vertex_block_storage
|
|||
{
|
||||
public:
|
||||
// Allocation parameters
|
||||
enum block_scale_e {
|
||||
enum block_scale_e
|
||||
{
|
||||
block_shift = BlockShift,
|
||||
block_size = 1 << block_shift,
|
||||
block_mask = block_size - 1,
|
||||
|
@ -77,6 +80,7 @@ class vertex_block_storage
|
|||
int8u** m_cmd_blocks;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
void vertex_block_storage<T,S,P>::free_all()
|
||||
|
@ -86,7 +90,10 @@ void vertex_block_storage<T, S, P>::free_all()
|
|||
T** coord_blk = m_coord_blocks + m_total_blocks - 1;
|
||||
while(m_total_blocks--)
|
||||
{
|
||||
pod_allocator<T>::deallocate(*coord_blk, block_size * 2 + block_size / (sizeof(T) / sizeof(unsigned char)));
|
||||
pod_allocator<T>::deallocate(
|
||||
*coord_blk,
|
||||
block_size * 2 +
|
||||
block_size / (sizeof(T) / sizeof(unsigned char)));
|
||||
--coord_blk;
|
||||
}
|
||||
pod_allocator<T*>::deallocate(m_coord_blocks, m_max_blocks * 2);
|
||||
|
@ -107,29 +114,31 @@ vertex_block_storage<T, S, P>::~vertex_block_storage()
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
vertex_block_storage<T, S, P>::vertex_block_storage()
|
||||
: m_total_vertices(0)
|
||||
, m_total_blocks(0)
|
||||
, m_max_blocks(0)
|
||||
, m_coord_blocks(0)
|
||||
, m_cmd_blocks(0)
|
||||
{}
|
||||
vertex_block_storage<T,S,P>::vertex_block_storage() :
|
||||
m_total_vertices(0),
|
||||
m_total_blocks(0),
|
||||
m_max_blocks(0),
|
||||
m_coord_blocks(0),
|
||||
m_cmd_blocks(0)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
vertex_block_storage<T, S, P>::vertex_block_storage(const vertex_block_storage<T, S, P>& v)
|
||||
: m_total_vertices(0)
|
||||
, m_total_blocks(0)
|
||||
, m_max_blocks(0)
|
||||
, m_coord_blocks(0)
|
||||
, m_cmd_blocks(0)
|
||||
vertex_block_storage<T,S,P>::vertex_block_storage(const vertex_block_storage<T,S,P>& v) :
|
||||
m_total_vertices(0),
|
||||
m_total_blocks(0),
|
||||
m_max_blocks(0),
|
||||
m_coord_blocks(0),
|
||||
m_cmd_blocks(0)
|
||||
{
|
||||
*this = v;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
const vertex_block_storage<T, S, P>& vertex_block_storage<T, S, P>::operator=(const vertex_block_storage<T, S, P>& v)
|
||||
const vertex_block_storage<T,S,P>&
|
||||
vertex_block_storage<T,S,P>::operator = (const vertex_block_storage<T,S,P>& v)
|
||||
{
|
||||
remove_all();
|
||||
unsigned i;
|
||||
|
@ -151,7 +160,8 @@ inline void vertex_block_storage<T, S, P>::remove_all()
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
inline void vertex_block_storage<T, S, P>::add_vertex(double x, double y, unsigned cmd)
|
||||
inline void vertex_block_storage<T,S,P>::add_vertex(double x, double y,
|
||||
unsigned cmd)
|
||||
{
|
||||
T* coord_ptr = 0;
|
||||
*storage_ptrs(&coord_ptr) = (int8u)cmd;
|
||||
|
@ -162,7 +172,8 @@ inline void vertex_block_storage<T, S, P>::add_vertex(double x, double y, unsign
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
inline void vertex_block_storage<T, S, P>::modify_vertex(unsigned idx, double x, double y)
|
||||
inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx,
|
||||
double x, double y)
|
||||
{
|
||||
T* pv = m_coord_blocks[idx >> block_shift] + ((idx & block_mask) << 1);
|
||||
pv[0] = T(x);
|
||||
|
@ -171,7 +182,9 @@ inline void vertex_block_storage<T, S, P>::modify_vertex(unsigned idx, double x,
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
inline void vertex_block_storage<T, S, P>::modify_vertex(unsigned idx, double x, double y, unsigned cmd)
|
||||
inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx,
|
||||
double x, double y,
|
||||
unsigned cmd)
|
||||
{
|
||||
unsigned block = idx >> block_shift;
|
||||
unsigned offset = idx & block_mask;
|
||||
|
@ -183,7 +196,8 @@ inline void vertex_block_storage<T, S, P>::modify_vertex(unsigned idx, double x,
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
inline void vertex_block_storage<T, S, P>::modify_command(unsigned idx, unsigned cmd)
|
||||
inline void vertex_block_storage<T,S,P>::modify_command(unsigned idx,
|
||||
unsigned cmd)
|
||||
{
|
||||
m_cmd_blocks[idx >> block_shift][idx & block_mask] = (int8u)cmd;
|
||||
}
|
||||
|
@ -199,12 +213,8 @@ inline void vertex_block_storage<T, S, P>::swap_vertices(unsigned v1, unsigned v
|
|||
T* pv1 = m_coord_blocks[b1] + (o1 << 1);
|
||||
T* pv2 = m_coord_blocks[b2] + (o2 << 1);
|
||||
T val;
|
||||
val = pv1[0];
|
||||
pv1[0] = pv2[0];
|
||||
pv2[0] = val;
|
||||
val = pv1[1];
|
||||
pv1[1] = pv2[1];
|
||||
pv2[1] = val;
|
||||
val = pv1[0]; pv1[0] = pv2[0]; pv2[0] = val;
|
||||
val = pv1[1]; pv1[1] = pv2[1]; pv2[1] = val;
|
||||
int8u cmd = m_cmd_blocks[b1][o1];
|
||||
m_cmd_blocks[b1][o1] = m_cmd_blocks[b2][o2];
|
||||
m_cmd_blocks[b2][o2] = cmd;
|
||||
|
@ -214,8 +224,7 @@ inline void vertex_block_storage<T, S, P>::swap_vertices(unsigned v1, unsigned v
|
|||
template<class T, unsigned S, unsigned P>
|
||||
inline unsigned vertex_block_storage<T,S,P>::last_command() const
|
||||
{
|
||||
if (m_total_vertices)
|
||||
return command(m_total_vertices - 1);
|
||||
if(m_total_vertices) return command(m_total_vertices - 1);
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
|
@ -223,8 +232,7 @@ inline unsigned vertex_block_storage<T, S, P>::last_command() const
|
|||
template<class T, unsigned S, unsigned P>
|
||||
inline unsigned vertex_block_storage<T,S,P>::last_vertex(double* x, double* y) const
|
||||
{
|
||||
if (m_total_vertices)
|
||||
return vertex(m_total_vertices - 1, x, y);
|
||||
if(m_total_vertices) return vertex(m_total_vertices - 1, x, y);
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
|
@ -232,8 +240,7 @@ inline unsigned vertex_block_storage<T, S, P>::last_vertex(double* x, double* y)
|
|||
template<class T, unsigned S, unsigned P>
|
||||
inline unsigned vertex_block_storage<T,S,P>::prev_vertex(double* x, double* y) const
|
||||
{
|
||||
if (m_total_vertices > 1)
|
||||
return vertex(m_total_vertices - 2, x, y);
|
||||
if(m_total_vertices > 1) return vertex(m_total_vertices - 2, x, y);
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
||||
|
@ -270,7 +277,8 @@ inline unsigned vertex_block_storage<T, S, P>::total_vertices() const
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T, unsigned S, unsigned P>
|
||||
inline unsigned vertex_block_storage<T, S, P>::vertex(unsigned idx, double* x, double* y) const
|
||||
inline unsigned vertex_block_storage<T,S,P>::vertex(unsigned idx,
|
||||
double* x, double* y) const
|
||||
{
|
||||
unsigned nb = idx >> block_shift;
|
||||
const T* pv = m_coord_blocks[nb] + ((idx & block_mask) << 1);
|
||||
|
@ -292,15 +300,21 @@ void vertex_block_storage<T, S, P>::allocate_block(unsigned nb)
|
|||
{
|
||||
if(nb >= m_max_blocks)
|
||||
{
|
||||
T** new_coords = pod_allocator<T*>::allocate((m_max_blocks + block_pool) * 2);
|
||||
T** new_coords =
|
||||
pod_allocator<T*>::allocate((m_max_blocks + block_pool) * 2);
|
||||
|
||||
unsigned char** new_cmds = (unsigned char**)(new_coords + m_max_blocks + block_pool);
|
||||
unsigned char** new_cmds =
|
||||
(unsigned char**)(new_coords + m_max_blocks + block_pool);
|
||||
|
||||
if(m_coord_blocks)
|
||||
{
|
||||
memcpy(new_coords, m_coord_blocks, m_max_blocks * sizeof(T*));
|
||||
memcpy(new_coords,
|
||||
m_coord_blocks,
|
||||
m_max_blocks * sizeof(T*));
|
||||
|
||||
memcpy(new_cmds, m_cmd_blocks, m_max_blocks * sizeof(unsigned char*));
|
||||
memcpy(new_cmds,
|
||||
m_cmd_blocks,
|
||||
m_max_blocks * sizeof(unsigned char*));
|
||||
|
||||
pod_allocator<T*>::deallocate(m_coord_blocks, m_max_blocks * 2);
|
||||
}
|
||||
|
@ -308,9 +322,12 @@ void vertex_block_storage<T, S, P>::allocate_block(unsigned nb)
|
|||
m_cmd_blocks = new_cmds;
|
||||
m_max_blocks += block_pool;
|
||||
}
|
||||
m_coord_blocks[nb] = pod_allocator<T>::allocate(block_size * 2 + block_size / (sizeof(T) / sizeof(unsigned char)));
|
||||
m_coord_blocks[nb] =
|
||||
pod_allocator<T>::allocate(block_size * 2 +
|
||||
block_size / (sizeof(T) / sizeof(unsigned char)));
|
||||
|
||||
m_cmd_blocks[nb] = (unsigned char*)(m_coord_blocks[nb] + block_size * 2);
|
||||
m_cmd_blocks[nb] =
|
||||
(unsigned char*)(m_coord_blocks[nb] + block_size * 2);
|
||||
|
||||
m_total_blocks++;
|
||||
}
|
||||
|
@ -328,27 +345,29 @@ int8u* vertex_block_storage<T, S, P>::storage_ptrs(T** xy_ptr)
|
|||
return m_cmd_blocks[nb] + (m_total_vertices & block_mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------poly_plain_adaptor
|
||||
template<class T>
|
||||
class poly_plain_adaptor
|
||||
template<class T> class poly_plain_adaptor
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
poly_plain_adaptor()
|
||||
: m_data(0)
|
||||
, m_ptr(0)
|
||||
, m_end(0)
|
||||
, m_closed(false)
|
||||
, m_stop(false)
|
||||
poly_plain_adaptor() :
|
||||
m_data(0),
|
||||
m_ptr(0),
|
||||
m_end(0),
|
||||
m_closed(false),
|
||||
m_stop(false)
|
||||
{}
|
||||
|
||||
poly_plain_adaptor(const T* data, unsigned num_points, bool closed)
|
||||
: m_data(data)
|
||||
, m_ptr(data)
|
||||
, m_end(data + num_points * 2)
|
||||
, m_closed(closed)
|
||||
, m_stop(false)
|
||||
poly_plain_adaptor(const T* data, unsigned num_points, bool closed) :
|
||||
m_data(data),
|
||||
m_ptr(data),
|
||||
m_end(data + num_points * 2),
|
||||
m_closed(closed),
|
||||
m_stop(false)
|
||||
{}
|
||||
|
||||
void init(const T* data, unsigned num_points, bool closed)
|
||||
|
@ -379,7 +398,8 @@ class poly_plain_adaptor
|
|||
if(m_closed && !m_stop)
|
||||
{
|
||||
m_stop = true;
|
||||
return path_cmd_end_poly | static_cast<agg::path_commands_e>(path_flags_close);
|
||||
return path_cmd_end_poly
|
||||
| static_cast<agg::path_commands_e>(path_flags_close);
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
@ -392,25 +412,28 @@ class poly_plain_adaptor
|
|||
bool m_stop;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------poly_container_adaptor
|
||||
template<class Container>
|
||||
class poly_container_adaptor
|
||||
template<class Container> class poly_container_adaptor
|
||||
{
|
||||
public:
|
||||
typedef typename Container::value_type vertex_type;
|
||||
|
||||
poly_container_adaptor()
|
||||
: m_container(0)
|
||||
, m_index(0)
|
||||
, m_closed(false)
|
||||
, m_stop(false)
|
||||
poly_container_adaptor() :
|
||||
m_container(0),
|
||||
m_index(0),
|
||||
m_closed(false),
|
||||
m_stop(false)
|
||||
{}
|
||||
|
||||
poly_container_adaptor(const Container& data, bool closed)
|
||||
: m_container(&data)
|
||||
, m_index(0)
|
||||
, m_closed(closed)
|
||||
, m_stop(false)
|
||||
poly_container_adaptor(const Container& data, bool closed) :
|
||||
m_container(&data),
|
||||
m_index(0),
|
||||
m_closed(closed),
|
||||
m_stop(false)
|
||||
{}
|
||||
|
||||
void init(const Container& data, bool closed)
|
||||
|
@ -441,7 +464,8 @@ class poly_container_adaptor
|
|||
if(m_closed && !m_stop)
|
||||
{
|
||||
m_stop = true;
|
||||
return path_cmd_end_poly | static_cast<agg::path_commands_e>(path_flags_close);
|
||||
return path_cmd_end_poly
|
||||
| static_cast<agg::path_commands_e>(path_flags_close);
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
@ -453,25 +477,26 @@ class poly_container_adaptor
|
|||
bool m_stop;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------poly_container_reverse_adaptor
|
||||
template<class Container>
|
||||
class poly_container_reverse_adaptor
|
||||
template<class Container> class poly_container_reverse_adaptor
|
||||
{
|
||||
public:
|
||||
typedef typename Container::value_type vertex_type;
|
||||
|
||||
poly_container_reverse_adaptor()
|
||||
: m_container(0)
|
||||
, m_index(-1)
|
||||
, m_closed(false)
|
||||
, m_stop(false)
|
||||
poly_container_reverse_adaptor() :
|
||||
m_container(0),
|
||||
m_index(-1),
|
||||
m_closed(false),
|
||||
m_stop(false)
|
||||
{}
|
||||
|
||||
poly_container_reverse_adaptor(const Container& data, bool closed)
|
||||
: m_container(&data)
|
||||
, m_index(-1)
|
||||
, m_closed(closed)
|
||||
, m_stop(false)
|
||||
poly_container_reverse_adaptor(const Container& data, bool closed) :
|
||||
m_container(&data),
|
||||
m_index(-1),
|
||||
m_closed(closed),
|
||||
m_stop(false)
|
||||
{}
|
||||
|
||||
void init(const Container& data, bool closed)
|
||||
|
@ -502,7 +527,8 @@ class poly_container_reverse_adaptor
|
|||
if(m_closed && !m_stop)
|
||||
{
|
||||
m_stop = true;
|
||||
return path_cmd_end_poly | static_cast<agg::path_commands_e>(path_flags_close);
|
||||
return path_cmd_end_poly
|
||||
| static_cast<agg::path_commands_e>(path_flags_close);
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
|
@ -514,17 +540,19 @@ class poly_container_reverse_adaptor
|
|||
bool m_stop;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------line_adaptor
|
||||
class line_adaptor
|
||||
{
|
||||
public:
|
||||
typedef double value_type;
|
||||
|
||||
line_adaptor()
|
||||
: m_line(m_coord, 2, false)
|
||||
{}
|
||||
line_adaptor(double x1, double y1, double x2, double y2)
|
||||
: m_line(m_coord, 2, false)
|
||||
line_adaptor() : m_line(m_coord, 2, false) {}
|
||||
line_adaptor(double x1, double y1, double x2, double y2) :
|
||||
m_line(m_coord, 2, false)
|
||||
{
|
||||
m_coord[0] = x1;
|
||||
m_coord[1] = y1;
|
||||
|
@ -541,15 +569,33 @@ class line_adaptor
|
|||
m_line.rewind(0);
|
||||
}
|
||||
|
||||
void rewind(unsigned) { m_line.rewind(0); }
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_line.rewind(0);
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y) { return m_line.vertex(x, y); }
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return m_line.vertex(x, y);
|
||||
}
|
||||
|
||||
private:
|
||||
double m_coord[4];
|
||||
poly_plain_adaptor<double> m_line;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------path_base
|
||||
// A container to store vertices with their flags.
|
||||
// A path consists of a number of contours separated with "move_to"
|
||||
|
@ -562,28 +608,16 @@ class line_adaptor
|
|||
//
|
||||
// See also: vertex_source concept
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexContainer>
|
||||
class path_base
|
||||
template<class VertexContainer> class path_base
|
||||
{
|
||||
public:
|
||||
typedef VertexContainer container_type;
|
||||
typedef path_base<VertexContainer> self_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
path_base()
|
||||
: m_vertices()
|
||||
, m_iterator(0)
|
||||
{}
|
||||
void remove_all()
|
||||
{
|
||||
m_vertices.remove_all();
|
||||
m_iterator = 0;
|
||||
}
|
||||
void free_all()
|
||||
{
|
||||
m_vertices.free_all();
|
||||
m_iterator = 0;
|
||||
}
|
||||
path_base() : m_vertices(), m_iterator(0) {}
|
||||
void remove_all() { m_vertices.remove_all(); m_iterator = 0; }
|
||||
void free_all() { m_vertices.free_all(); m_iterator = 0; }
|
||||
|
||||
// Make path functions
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -601,25 +635,42 @@ class path_base
|
|||
void vline_to(double y);
|
||||
void vline_rel(double dy);
|
||||
|
||||
void arc_to(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x, double y);
|
||||
void arc_to(double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double x, double y);
|
||||
|
||||
void arc_rel(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double dx, double dy);
|
||||
void arc_rel(double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double dx, double dy);
|
||||
|
||||
void curve3(double x_ctrl, double y_ctrl, double x_to, double y_to);
|
||||
void curve3(double x_ctrl, double y_ctrl,
|
||||
double x_to, double y_to);
|
||||
|
||||
void curve3_rel(double dx_ctrl, double dy_ctrl, double dx_to, double dy_to);
|
||||
void curve3_rel(double dx_ctrl, double dy_ctrl,
|
||||
double dx_to, double dy_to);
|
||||
|
||||
void curve3(double x_to, double y_to);
|
||||
|
||||
void curve3_rel(double dx_to, double dy_to);
|
||||
|
||||
void curve4(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to);
|
||||
void curve4(double x_ctrl1, double y_ctrl1,
|
||||
double x_ctrl2, double y_ctrl2,
|
||||
double x_to, double y_to);
|
||||
|
||||
void curve4_rel(double dx_ctrl1, double dy_ctrl1, double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to);
|
||||
void curve4_rel(double dx_ctrl1, double dy_ctrl1,
|
||||
double dx_ctrl2, double dy_ctrl2,
|
||||
double dx_to, double dy_to);
|
||||
|
||||
void curve4(double x_ctrl2, double y_ctrl2, double x_to, double y_to);
|
||||
void curve4(double x_ctrl2, double y_ctrl2,
|
||||
double x_to, double y_to);
|
||||
|
||||
void curve4_rel(double x_ctrl2, double y_ctrl2,
|
||||
double x_to, double y_to);
|
||||
|
||||
void curve4_rel(double x_ctrl2, double y_ctrl2, double x_to, double y_to);
|
||||
|
||||
void end_poly(unsigned flags = path_flags_close);
|
||||
void close_polygon(unsigned flags = path_flags_none);
|
||||
|
@ -702,8 +753,7 @@ class path_base
|
|||
{
|
||||
if(calc_distance(x, y, x0, y0) > vertex_dist_epsilon)
|
||||
{
|
||||
if (is_move_to(cmd))
|
||||
cmd = path_cmd_line_to;
|
||||
if(is_move_to(cmd)) cmd = path_cmd_line_to;
|
||||
m_vertices.add_vertex(x, y, cmd);
|
||||
}
|
||||
}
|
||||
|
@ -715,23 +765,25 @@ class path_base
|
|||
}
|
||||
else
|
||||
{
|
||||
if (is_move_to(cmd))
|
||||
cmd = path_cmd_line_to;
|
||||
if(is_move_to(cmd)) cmd = path_cmd_line_to;
|
||||
}
|
||||
m_vertices.add_vertex(x, y, cmd);
|
||||
}
|
||||
}
|
||||
while(!is_stop(cmd = vs.vertex(&x, &y)))
|
||||
{
|
||||
m_vertices.add_vertex(x, y, is_move_to(cmd) ? unsigned(path_cmd_line_to) : cmd);
|
||||
m_vertices.add_vertex(x, y, is_move_to(cmd) ?
|
||||
unsigned(path_cmd_line_to) :
|
||||
cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Concatenate polygon/polyline.
|
||||
//--------------------------------------------------------------------
|
||||
template<class T>
|
||||
void concat_poly(const T* data, unsigned num_points, bool closed)
|
||||
template<class T> void concat_poly(const T* data,
|
||||
unsigned num_points,
|
||||
bool closed)
|
||||
{
|
||||
poly_plain_adaptor<T> poly(data, num_points, closed);
|
||||
concat_path(poly);
|
||||
|
@ -739,8 +791,9 @@ class path_base
|
|||
|
||||
// Join polygon/polyline continuously.
|
||||
//--------------------------------------------------------------------
|
||||
template<class T>
|
||||
void join_poly(const T* data, unsigned num_points, bool closed)
|
||||
template<class T> void join_poly(const T* data,
|
||||
unsigned num_points,
|
||||
bool closed)
|
||||
{
|
||||
poly_plain_adaptor<T> poly(data, num_points, closed);
|
||||
join_path(poly);
|
||||
|
@ -759,8 +812,7 @@ class path_base
|
|||
{
|
||||
double x, y;
|
||||
unsigned cmd = m_vertices.vertex(path_id, &x, &y);
|
||||
if (is_stop(cmd))
|
||||
break;
|
||||
if(is_stop(cmd)) break;
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
trans.transform(&x, &y);
|
||||
|
@ -786,6 +838,8 @@ class path_base
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
unsigned perceive_polygon_orientation(unsigned start, unsigned end);
|
||||
void invert_polygon(unsigned start, unsigned end);
|
||||
|
@ -805,6 +859,7 @@ unsigned path_base<VC>::start_new_path()
|
|||
return m_vertices.total_vertices();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
inline void path_base<VC>::rel_to_abs(double* x, double* y) const
|
||||
|
@ -818,7 +873,8 @@ inline void path_base<VC>::rel_to_abs(double* x, double* y) const
|
|||
*x += x2;
|
||||
*y += y2;
|
||||
}
|
||||
else if (!is_stop(m_vertices.last_command()) && is_vertex(m_vertices.prev_vertex(&x2, &y2)))
|
||||
else if (!is_stop(m_vertices.last_command()) &&
|
||||
is_vertex(m_vertices.prev_vertex(&x2, &y2)))
|
||||
{
|
||||
*x += x2;
|
||||
*y += y2;
|
||||
|
@ -890,7 +946,11 @@ inline void path_base<VC>::vline_rel(double dy)
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::arc_to(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x, double y)
|
||||
void path_base<VC>::arc_to(double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double x, double y)
|
||||
{
|
||||
if(m_vertices.total_vertices() && is_vertex(m_vertices.last_command()))
|
||||
{
|
||||
|
@ -934,13 +994,11 @@ void path_base<VC>::arc_to(double rx, double ry, double angle, bool large_arc_fl
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::arc_rel(double rx,
|
||||
double ry,
|
||||
void path_base<VC>::arc_rel(double rx, double ry,
|
||||
double angle,
|
||||
bool large_arc_flag,
|
||||
bool sweep_flag,
|
||||
double dx,
|
||||
double dy)
|
||||
double dx, double dy)
|
||||
{
|
||||
rel_to_abs(&dx, &dy);
|
||||
arc_to(rx, ry, angle, large_arc_flag, sweep_flag, dx, dy);
|
||||
|
@ -948,7 +1006,8 @@ void path_base<VC>::arc_rel(double rx,
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::curve3(double x_ctrl, double y_ctrl, double x_to, double y_to)
|
||||
void path_base<VC>::curve3(double x_ctrl, double y_ctrl,
|
||||
double x_to, double y_to)
|
||||
{
|
||||
m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3);
|
||||
m_vertices.add_vertex(x_to, y_to, path_cmd_curve3);
|
||||
|
@ -956,7 +1015,8 @@ void path_base<VC>::curve3(double x_ctrl, double y_ctrl, double x_to, double y_t
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::curve3_rel(double dx_ctrl, double dy_ctrl, double dx_to, double dy_to)
|
||||
void path_base<VC>::curve3_rel(double dx_ctrl, double dy_ctrl,
|
||||
double dx_to, double dy_to)
|
||||
{
|
||||
rel_to_abs(&dx_ctrl, &dy_ctrl);
|
||||
rel_to_abs(&dx_to, &dy_to);
|
||||
|
@ -999,7 +1059,9 @@ void path_base<VC>::curve3_rel(double dx_to, double dy_to)
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::curve4(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to)
|
||||
void path_base<VC>::curve4(double x_ctrl1, double y_ctrl1,
|
||||
double x_ctrl2, double y_ctrl2,
|
||||
double x_to, double y_to)
|
||||
{
|
||||
m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4);
|
||||
m_vertices.add_vertex(x_ctrl2, y_ctrl2, path_cmd_curve4);
|
||||
|
@ -1008,12 +1070,9 @@ void path_base<VC>::curve4(double x_ctrl1, double y_ctrl1, double x_ctrl2, doubl
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::curve4_rel(double dx_ctrl1,
|
||||
double dy_ctrl1,
|
||||
double dx_ctrl2,
|
||||
double dy_ctrl2,
|
||||
double dx_to,
|
||||
double dy_to)
|
||||
void path_base<VC>::curve4_rel(double dx_ctrl1, double dy_ctrl1,
|
||||
double dx_ctrl2, double dy_ctrl2,
|
||||
double dx_to, double dy_to)
|
||||
{
|
||||
rel_to_abs(&dx_ctrl1, &dy_ctrl1);
|
||||
rel_to_abs(&dx_ctrl2, &dy_ctrl2);
|
||||
|
@ -1025,7 +1084,8 @@ void path_base<VC>::curve4_rel(double dx_ctrl1,
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2, double x_to, double y_to)
|
||||
void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2,
|
||||
double x_to, double y_to)
|
||||
{
|
||||
double x0;
|
||||
double y0;
|
||||
|
@ -1050,7 +1110,8 @@ void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2, double x_to, double y
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
void path_base<VC>::curve4_rel(double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to)
|
||||
void path_base<VC>::curve4_rel(double dx_ctrl2, double dy_ctrl2,
|
||||
double dx_to, double dy_to)
|
||||
{
|
||||
rel_to_abs(&dx_ctrl2, &dy_ctrl2);
|
||||
rel_to_abs(&dx_to, &dy_to);
|
||||
|
@ -1155,14 +1216,14 @@ inline void path_base<VC>::rewind(unsigned path_id)
|
|||
template<class VC>
|
||||
inline unsigned path_base<VC>::vertex(double* x, double* y)
|
||||
{
|
||||
if (m_iterator >= m_vertices.total_vertices())
|
||||
return path_cmd_stop;
|
||||
if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop;
|
||||
return m_vertices.vertex(m_iterator++, x, y);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
unsigned path_base<VC>::perceive_polygon_orientation(unsigned start, unsigned end)
|
||||
unsigned path_base<VC>::perceive_polygon_orientation(unsigned start,
|
||||
unsigned end)
|
||||
{
|
||||
// Calculate signed area (double area to be exact)
|
||||
//---------------------
|
||||
|
@ -1209,42 +1270,42 @@ template<class VC>
|
|||
void path_base<VC>::invert_polygon(unsigned start)
|
||||
{
|
||||
// Skip all non-vertices at the beginning
|
||||
while (start < m_vertices.total_vertices() && !is_vertex(m_vertices.command(start)))
|
||||
++start;
|
||||
while(start < m_vertices.total_vertices() &&
|
||||
!is_vertex(m_vertices.command(start))) ++start;
|
||||
|
||||
// Skip all insignificant move_to
|
||||
while (start + 1 < m_vertices.total_vertices() && is_move_to(m_vertices.command(start)) &&
|
||||
is_move_to(m_vertices.command(start + 1)))
|
||||
++start;
|
||||
while(start+1 < m_vertices.total_vertices() &&
|
||||
is_move_to(m_vertices.command(start)) &&
|
||||
is_move_to(m_vertices.command(start+1))) ++start;
|
||||
|
||||
// Find the last vertex
|
||||
unsigned end = start + 1;
|
||||
while (end < m_vertices.total_vertices() && !is_next_poly(m_vertices.command(end)))
|
||||
++end;
|
||||
while(end < m_vertices.total_vertices() &&
|
||||
!is_next_poly(m_vertices.command(end))) ++end;
|
||||
|
||||
invert_polygon(start, end);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
unsigned path_base<VC>::arrange_polygon_orientation(unsigned start, path_flags_e orientation)
|
||||
unsigned path_base<VC>::arrange_polygon_orientation(unsigned start,
|
||||
path_flags_e orientation)
|
||||
{
|
||||
if (orientation == path_flags_none)
|
||||
return start;
|
||||
if(orientation == path_flags_none) return start;
|
||||
|
||||
// Skip all non-vertices at the beginning
|
||||
while (start < m_vertices.total_vertices() && !is_vertex(m_vertices.command(start)))
|
||||
++start;
|
||||
while(start < m_vertices.total_vertices() &&
|
||||
!is_vertex(m_vertices.command(start))) ++start;
|
||||
|
||||
// Skip all insignificant move_to
|
||||
while (start + 1 < m_vertices.total_vertices() && is_move_to(m_vertices.command(start)) &&
|
||||
is_move_to(m_vertices.command(start + 1)))
|
||||
++start;
|
||||
while(start+1 < m_vertices.total_vertices() &&
|
||||
is_move_to(m_vertices.command(start)) &&
|
||||
is_move_to(m_vertices.command(start+1))) ++start;
|
||||
|
||||
// Find the last vertex
|
||||
unsigned end = start + 1;
|
||||
while (end < m_vertices.total_vertices() && !is_next_poly(m_vertices.command(end)))
|
||||
++end;
|
||||
while(end < m_vertices.total_vertices() &&
|
||||
!is_next_poly(m_vertices.command(end))) ++end;
|
||||
|
||||
if(end - start > 2)
|
||||
{
|
||||
|
@ -1253,7 +1314,8 @@ unsigned path_base<VC>::arrange_polygon_orientation(unsigned start, path_flags_e
|
|||
// Invert polygon, set orientation flag, and skip all end_poly
|
||||
invert_polygon(start, end);
|
||||
unsigned cmd;
|
||||
while (end < m_vertices.total_vertices() && is_end_poly(cmd = m_vertices.command(end)))
|
||||
while(end < m_vertices.total_vertices() &&
|
||||
is_end_poly(cmd = m_vertices.command(end)))
|
||||
{
|
||||
m_vertices.modify_command(end++, set_orientation(cmd, orientation));
|
||||
}
|
||||
|
@ -1264,7 +1326,8 @@ unsigned path_base<VC>::arrange_polygon_orientation(unsigned start, path_flags_e
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VC>
|
||||
unsigned path_base<VC>::arrange_orientations(unsigned start, path_flags_e orientation)
|
||||
unsigned path_base<VC>::arrange_orientations(unsigned start,
|
||||
path_flags_e orientation)
|
||||
{
|
||||
if(orientation != path_flags_none)
|
||||
{
|
||||
|
@ -1336,8 +1399,7 @@ void path_base<VC>::translate(double dx, double dy, unsigned path_id)
|
|||
{
|
||||
double x, y;
|
||||
unsigned cmd = m_vertices.vertex(path_id, &x, &y);
|
||||
if (is_stop(cmd))
|
||||
break;
|
||||
if(is_stop(cmd)) break;
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
x += dx;
|
||||
|
@ -1367,9 +1429,10 @@ void path_base<VC>::translate_all_paths(double dx, double dy)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------vertex_stl_storage
|
||||
template<class Container>
|
||||
class vertex_stl_storage
|
||||
template<class Container> class vertex_stl_storage
|
||||
{
|
||||
public:
|
||||
typedef typename Container::value_type vertex_type;
|
||||
|
@ -1380,7 +1443,9 @@ class vertex_stl_storage
|
|||
|
||||
void add_vertex(double x, double y, unsigned cmd)
|
||||
{
|
||||
m_vertices.push_back(vertex_type(value_type(x), value_type(y), int8u(cmd)));
|
||||
m_vertices.push_back(vertex_type(value_type(x),
|
||||
value_type(y),
|
||||
int8u(cmd)));
|
||||
}
|
||||
|
||||
void modify_vertex(unsigned idx, double x, double y)
|
||||
|
@ -1398,7 +1463,10 @@ class vertex_stl_storage
|
|||
v.cmd = int8u(cmd);
|
||||
}
|
||||
|
||||
void modify_command(unsigned idx, unsigned cmd) { m_vertices[idx].cmd = int8u(cmd); }
|
||||
void modify_command(unsigned idx, unsigned cmd)
|
||||
{
|
||||
m_vertices[idx].cmd = int8u(cmd);
|
||||
}
|
||||
|
||||
void swap_vertices(unsigned v1, unsigned v2)
|
||||
{
|
||||
|
@ -1407,7 +1475,12 @@ class vertex_stl_storage
|
|||
m_vertices[v2] = t;
|
||||
}
|
||||
|
||||
unsigned last_command() const { return m_vertices.size() ? m_vertices[m_vertices.size() - 1].cmd : path_cmd_stop; }
|
||||
unsigned last_command() const
|
||||
{
|
||||
return m_vertices.size() ?
|
||||
m_vertices[m_vertices.size() - 1].cmd :
|
||||
path_cmd_stop;
|
||||
}
|
||||
|
||||
unsigned last_vertex(double* x, double* y) const
|
||||
{
|
||||
|
@ -1429,11 +1502,20 @@ class vertex_stl_storage
|
|||
return vertex(m_vertices.size() - 2, x, y);
|
||||
}
|
||||
|
||||
double last_x() const { return m_vertices.size() ? m_vertices[m_vertices.size() - 1].x : 0.0; }
|
||||
double last_x() const
|
||||
{
|
||||
return m_vertices.size() ? m_vertices[m_vertices.size() - 1].x : 0.0;
|
||||
}
|
||||
|
||||
double last_y() const { return m_vertices.size() ? m_vertices[m_vertices.size() - 1].y : 0.0; }
|
||||
double last_y() const
|
||||
{
|
||||
return m_vertices.size() ? m_vertices[m_vertices.size() - 1].y : 0.0;
|
||||
}
|
||||
|
||||
unsigned total_vertices() const { return m_vertices.size(); }
|
||||
unsigned total_vertices() const
|
||||
{
|
||||
return m_vertices.size();
|
||||
}
|
||||
|
||||
unsigned vertex(unsigned idx, double* x, double* y) const
|
||||
{
|
||||
|
@ -1443,7 +1525,10 @@ class vertex_stl_storage
|
|||
return v.cmd;
|
||||
}
|
||||
|
||||
unsigned command(unsigned idx) const { return m_vertices[idx].cmd; }
|
||||
unsigned command(unsigned idx) const
|
||||
{
|
||||
return m_vertices[idx].cmd;
|
||||
}
|
||||
|
||||
private:
|
||||
Container m_vertices;
|
||||
|
@ -1456,7 +1541,9 @@ typedef path_base<vertex_block_storage<double>> path_storage;
|
|||
//-----------------------------------------------------------------------
|
||||
//typedef path_base<vertex_stl_storage<pod_bvector<vertex_d> > > path_storage;
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Example of declarations path_storage with std::vector as a container
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -1467,4 +1554,5 @@ typedef path_base<vertex_block_storage<double>> path_storage;
|
|||
// typedef path_base<vertex_stl_storage<std::vector<vertex_d> > > path_storage;
|
||||
//}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
134
deps/agg/include/agg_path_storage_integer.h
vendored
134
deps/agg/include/agg_path_storage_integer.h
vendored
|
@ -19,74 +19,86 @@
|
|||
#include <cstring>
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
//---------------------------------------------------------vertex_integer
|
||||
template<class T, unsigned CoordShift = 6>
|
||||
struct vertex_integer
|
||||
namespace agg
|
||||
{
|
||||
enum path_cmd { cmd_move_to = 0, cmd_line_to = 1, cmd_curve3 = 2, cmd_curve4 = 3 };
|
||||
//---------------------------------------------------------vertex_integer
|
||||
template<class T, unsigned CoordShift=6> struct vertex_integer
|
||||
{
|
||||
enum path_cmd
|
||||
{
|
||||
cmd_move_to = 0,
|
||||
cmd_line_to = 1,
|
||||
cmd_curve3 = 2,
|
||||
cmd_curve4 = 3
|
||||
};
|
||||
|
||||
enum coord_scale_e { coord_shift = CoordShift, coord_scale = 1 << coord_shift };
|
||||
enum coord_scale_e
|
||||
{
|
||||
coord_shift = CoordShift,
|
||||
coord_scale = 1 << coord_shift
|
||||
};
|
||||
|
||||
T x,y;
|
||||
vertex_integer() {}
|
||||
vertex_integer(T x_, T y_, unsigned flag)
|
||||
: x(((x_ << 1) & ~1) | (flag & 1))
|
||||
, y(((y_ << 1) & ~1) | (flag >> 1))
|
||||
{}
|
||||
vertex_integer(T x_, T y_, unsigned flag) :
|
||||
x(((x_ << 1) & ~1) | (flag & 1)),
|
||||
y(((y_ << 1) & ~1) | (flag >> 1)) {}
|
||||
|
||||
unsigned vertex(double* x_, double* y_, double dx = 0, double dy = 0, double scale = 1.0) const
|
||||
unsigned vertex(double* x_, double* y_,
|
||||
double dx=0, double dy=0,
|
||||
double scale=1.0) const
|
||||
{
|
||||
*x_ = dx + (double(x >> 1) / coord_scale) * scale;
|
||||
*y_ = dy + (double(y >> 1) / coord_scale) * scale;
|
||||
switch(((y & 1) << 1) | (x & 1))
|
||||
{
|
||||
case cmd_move_to:
|
||||
return path_cmd_move_to;
|
||||
case cmd_line_to:
|
||||
return path_cmd_line_to;
|
||||
case cmd_curve3:
|
||||
return path_cmd_curve3;
|
||||
case cmd_curve4:
|
||||
return path_cmd_curve4;
|
||||
case cmd_move_to: return path_cmd_move_to;
|
||||
case cmd_line_to: return path_cmd_line_to;
|
||||
case cmd_curve3: return path_cmd_curve3;
|
||||
case cmd_curve4: return path_cmd_curve4;
|
||||
}
|
||||
return path_cmd_stop;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------path_storage_integer
|
||||
template<class T, unsigned CoordShift = 6>
|
||||
class path_storage_integer
|
||||
template<class T, unsigned CoordShift=6> class path_storage_integer
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef vertex_integer<T, CoordShift> vertex_integer_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
path_storage_integer()
|
||||
: m_storage()
|
||||
, m_vertex_idx(0)
|
||||
, m_closed(true)
|
||||
{}
|
||||
path_storage_integer() : m_storage(), m_vertex_idx(0), m_closed(true) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void remove_all() { m_storage.remove_all(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void move_to(T x, T y) { m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_move_to)); }
|
||||
void move_to(T x, T y)
|
||||
{
|
||||
m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_move_to));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void line_to(T x, T y) { m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_line_to)); }
|
||||
void line_to(T x, T y)
|
||||
{
|
||||
m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_line_to));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void curve3(T x_ctrl, T y_ctrl, T x_to, T y_to)
|
||||
void curve3(T x_ctrl, T y_ctrl,
|
||||
T x_to, T y_to)
|
||||
{
|
||||
m_storage.add(vertex_integer_type(x_ctrl, y_ctrl, vertex_integer_type::cmd_curve3));
|
||||
m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve3));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void curve4(T x_ctrl1, T y_ctrl1, T x_ctrl2, T y_ctrl2, T x_to, T y_to)
|
||||
void curve4(T x_ctrl1, T y_ctrl1,
|
||||
T x_ctrl2, T y_ctrl2,
|
||||
T x_to, T y_to)
|
||||
{
|
||||
m_storage.add(vertex_integer_type(x_ctrl1, y_ctrl1, vertex_integer_type::cmd_curve4));
|
||||
m_storage.add(vertex_integer_type(x_ctrl2, y_ctrl2, vertex_integer_type::cmd_curve4));
|
||||
|
@ -98,7 +110,10 @@ class path_storage_integer
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned size() const { return m_storage.size(); }
|
||||
unsigned vertex(unsigned idx, double* x, double* y) const { return m_storage[idx].vertex(x, y); }
|
||||
unsigned vertex(unsigned idx, double* x, double* y) const
|
||||
{
|
||||
return m_storage[idx].vertex(x, y);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned byte_size() const { return m_storage.size() * sizeof(vertex_integer_type); }
|
||||
|
@ -163,14 +178,10 @@ class path_storage_integer
|
|||
{
|
||||
double x, y;
|
||||
m_storage[i].vertex(&x, &y);
|
||||
if (x < bounds.x1)
|
||||
bounds.x1 = x;
|
||||
if (y < bounds.y1)
|
||||
bounds.y1 = y;
|
||||
if (x > bounds.x2)
|
||||
bounds.x2 = x;
|
||||
if (y > bounds.y2)
|
||||
bounds.y2 = y;
|
||||
if(x < bounds.x1) bounds.x1 = x;
|
||||
if(y < bounds.y1) bounds.y1 = y;
|
||||
if(x > bounds.x2) bounds.x2 = x;
|
||||
if(y > bounds.y2) bounds.y2 = y;
|
||||
}
|
||||
}
|
||||
return bounds;
|
||||
|
@ -182,36 +193,40 @@ class path_storage_integer
|
|||
bool m_closed;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------serialized_integer_path_adaptor
|
||||
template<class T, unsigned CoordShift = 6>
|
||||
class serialized_integer_path_adaptor
|
||||
template<class T, unsigned CoordShift=6> class serialized_integer_path_adaptor
|
||||
{
|
||||
public:
|
||||
typedef vertex_integer<T, CoordShift> vertex_integer_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
serialized_integer_path_adaptor()
|
||||
: m_data(0)
|
||||
, m_end(0)
|
||||
, m_ptr(0)
|
||||
, m_dx(0.0)
|
||||
, m_dy(0.0)
|
||||
, m_scale(1.0)
|
||||
, m_vertices(0)
|
||||
serialized_integer_path_adaptor() :
|
||||
m_data(0),
|
||||
m_end(0),
|
||||
m_ptr(0),
|
||||
m_dx(0.0),
|
||||
m_dy(0.0),
|
||||
m_scale(1.0),
|
||||
m_vertices(0)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
serialized_integer_path_adaptor(const int8u* data, unsigned size, double dx, double dy)
|
||||
: m_data(data)
|
||||
, m_end(data + size)
|
||||
, m_ptr(data)
|
||||
, m_dx(dx)
|
||||
, m_dy(dy)
|
||||
, m_vertices(0)
|
||||
serialized_integer_path_adaptor(const int8u* data, unsigned size,
|
||||
double dx, double dy) :
|
||||
m_data(data),
|
||||
m_end(data + size),
|
||||
m_ptr(data),
|
||||
m_dx(dx),
|
||||
m_dy(dy),
|
||||
m_vertices(0)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void init(const int8u* data, unsigned size, double dx, double dy, double scale = 1.0)
|
||||
void init(const int8u* data, unsigned size,
|
||||
double dx, double dy, double scale=1.0)
|
||||
{
|
||||
m_data = data;
|
||||
m_end = data + size;
|
||||
|
@ -222,6 +237,7 @@ class serialized_integer_path_adaptor
|
|||
m_vertices = 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void rewind(unsigned)
|
||||
{
|
||||
|
@ -272,6 +288,8 @@ class serialized_integer_path_adaptor
|
|||
unsigned m_vertices;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
40
deps/agg/include/agg_pattern_filters_rgba.h
vendored
40
deps/agg/include/agg_pattern_filters_rgba.h
vendored
|
@ -19,39 +19,52 @@
|
|||
#include "agg_line_aa_basics.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=======================================================pattern_filter_nn
|
||||
template<class ColorT>
|
||||
struct pattern_filter_nn
|
||||
template<class ColorT> struct pattern_filter_nn
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
static unsigned dilation() { return 0; }
|
||||
|
||||
static void AGG_INLINE pixel_low_res(color_type const* const* buf, color_type* p, int x, int y) { *p = buf[y][x]; }
|
||||
|
||||
static void AGG_INLINE pixel_high_res(color_type const* const* buf, color_type* p, int x, int y)
|
||||
static void AGG_INLINE pixel_low_res(color_type const* const* buf,
|
||||
color_type* p, int x, int y)
|
||||
{
|
||||
*p = buf[y >> line_subpixel_shift][x >> line_subpixel_shift];
|
||||
*p = buf[y][x];
|
||||
}
|
||||
|
||||
static void AGG_INLINE pixel_high_res(color_type const* const* buf,
|
||||
color_type* p, int x, int y)
|
||||
{
|
||||
*p = buf[y >> line_subpixel_shift]
|
||||
[x >> line_subpixel_shift];
|
||||
}
|
||||
};
|
||||
|
||||
typedef pattern_filter_nn<rgba8> pattern_filter_nn_rgba8;
|
||||
typedef pattern_filter_nn<rgba16> pattern_filter_nn_rgba16;
|
||||
|
||||
|
||||
//===========================================pattern_filter_bilinear_rgba
|
||||
template<class ColorT>
|
||||
struct pattern_filter_bilinear_rgba
|
||||
template<class ColorT> struct pattern_filter_bilinear_rgba
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
|
||||
|
||||
static unsigned dilation() { return 1; }
|
||||
|
||||
static AGG_INLINE void pixel_low_res(color_type const* const* buf, color_type* p, int x, int y) { *p = buf[y][x]; }
|
||||
static AGG_INLINE void pixel_low_res(color_type const* const* buf,
|
||||
color_type* p, int x, int y)
|
||||
{
|
||||
*p = buf[y][x];
|
||||
}
|
||||
|
||||
static AGG_INLINE void pixel_high_res(color_type const* const* buf, color_type* p, int x, int y)
|
||||
static AGG_INLINE void pixel_high_res(color_type const* const* buf,
|
||||
color_type* p, int x, int y)
|
||||
{
|
||||
calc_type r, g, b, a;
|
||||
r = g = b = a = line_subpixel_scale * line_subpixel_scale / 2;
|
||||
|
@ -64,7 +77,8 @@ struct pattern_filter_bilinear_rgba
|
|||
y &= line_subpixel_mask;
|
||||
const color_type* ptr = buf[y_lr] + x_lr;
|
||||
|
||||
weight = (line_subpixel_scale - x) * (line_subpixel_scale - y);
|
||||
weight = (line_subpixel_scale - x) *
|
||||
(line_subpixel_scale - y);
|
||||
r += weight * ptr->r;
|
||||
g += weight * ptr->g;
|
||||
b += weight * ptr->b;
|
||||
|
@ -103,6 +117,6 @@ struct pattern_filter_bilinear_rgba
|
|||
|
||||
typedef pattern_filter_bilinear_rgba<rgba8> pattern_filter_bilinear_rgba8;
|
||||
typedef pattern_filter_bilinear_rgba<rgba16> pattern_filter_bilinear_rgba16;
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
71
deps/agg/include/agg_pixfmt_amask_adaptor.h
vendored
71
deps/agg/include/agg_pixfmt_amask_adaptor.h
vendored
|
@ -16,14 +16,16 @@
|
|||
#ifndef AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED
|
||||
#define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include "agg_array.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
//==================================================pixfmt_amask_adaptor
|
||||
template<class PixFmt, class AlphaMask>
|
||||
class pixfmt_amask_adaptor
|
||||
template<class PixFmt, class AlphaMask> class pixfmt_amask_adaptor
|
||||
{
|
||||
public:
|
||||
typedef PixFmt pixfmt_type;
|
||||
|
@ -55,11 +57,10 @@ class pixfmt_amask_adaptor
|
|||
memcpy(&m_span[0], covers, len * sizeof(cover_type));
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
pixfmt_amask_adaptor(pixfmt_type& pixf, const amask_type& mask)
|
||||
: m_pixf(&pixf)
|
||||
, m_mask(&mask)
|
||||
, m_span()
|
||||
pixfmt_amask_adaptor(pixfmt_type& pixf, const amask_type& mask) :
|
||||
m_pixf(&pixf), m_mask(&mask), m_span()
|
||||
{}
|
||||
|
||||
void attach_pixfmt(pixfmt_type& pixf) { m_pixf = &pixf; }
|
||||
|
@ -77,10 +78,16 @@ class pixfmt_amask_adaptor
|
|||
unsigned height() const { return m_pixf->height(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
color_type pixel(int x, int y) { return m_pixf->pixel(x, y); }
|
||||
color_type pixel(int x, int y)
|
||||
{
|
||||
return m_pixf->pixel(x, y);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_pixel(int x, int y, const color_type& c) { m_pixf->blend_pixel(x, y, c, m_mask->pixel(x, y)); }
|
||||
void copy_pixel(int x, int y, const color_type& c)
|
||||
{
|
||||
m_pixf->blend_pixel(x, y, c, m_mask->pixel(x, y));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_pixel(int x, int y, const color_type& c, cover_type cover)
|
||||
|
@ -89,7 +96,9 @@ class pixfmt_amask_adaptor
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_hline(int x, int y, unsigned len, const color_type& c)
|
||||
void copy_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
realloc_span(len);
|
||||
m_mask->fill_hspan(x, y, &m_span[0], len);
|
||||
|
@ -97,7 +106,10 @@ class pixfmt_amask_adaptor
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_hline(int x, int y, unsigned len, const color_type& c, cover_type cover)
|
||||
void blend_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
cover_type cover)
|
||||
{
|
||||
init_span(len);
|
||||
m_mask->combine_hspan(x, y, &m_span[0], len);
|
||||
|
@ -105,7 +117,9 @@ class pixfmt_amask_adaptor
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_vline(int x, int y, unsigned len, const color_type& c)
|
||||
void copy_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
realloc_span(len);
|
||||
m_mask->fill_vspan(x, y, &m_span[0], len);
|
||||
|
@ -113,7 +127,10 @@ class pixfmt_amask_adaptor
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_vline(int x, int y, unsigned len, const color_type& c, cover_type cover)
|
||||
void blend_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
cover_type cover)
|
||||
{
|
||||
init_span(len);
|
||||
m_mask->combine_vspan(x, y, &m_span[0], len);
|
||||
|
@ -121,27 +138,39 @@ class pixfmt_amask_adaptor
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_from(const rendering_buffer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len)
|
||||
void copy_from(const rendering_buffer& from,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len)
|
||||
{
|
||||
m_pixf->copy_from(from, xdst, ydst, xsrc, ysrc, len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const cover_type* covers)
|
||||
void blend_solid_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const cover_type* covers)
|
||||
{
|
||||
init_span(len, covers);
|
||||
m_mask->combine_hspan(x, y, &m_span[0], len);
|
||||
m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const cover_type* covers)
|
||||
void blend_solid_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const cover_type* covers)
|
||||
{
|
||||
init_span(len, covers);
|
||||
m_mask->combine_vspan(x, y, &m_span[0], len);
|
||||
m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_hspan(int x, int y, unsigned len, const color_type* colors)
|
||||
{
|
||||
|
@ -159,8 +188,7 @@ class pixfmt_amask_adaptor
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan(int x,
|
||||
int y,
|
||||
void blend_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const cover_type* covers,
|
||||
|
@ -179,9 +207,9 @@ class pixfmt_amask_adaptor
|
|||
m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x,
|
||||
int y,
|
||||
void blend_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const cover_type* covers,
|
||||
|
@ -206,6 +234,7 @@ class pixfmt_amask_adaptor
|
|||
pod_array<cover_type> m_span;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
27
deps/agg/include/agg_pixfmt_base.h
vendored
27
deps/agg/include/agg_pixfmt_base.h
vendored
|
@ -20,15 +20,19 @@
|
|||
#include "agg_color_gray.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
struct pixfmt_gray_tag
|
||||
{};
|
||||
{
|
||||
};
|
||||
|
||||
struct pixfmt_rgb_tag
|
||||
{};
|
||||
{
|
||||
};
|
||||
|
||||
struct pixfmt_rgba_tag
|
||||
{};
|
||||
{
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------blender_base
|
||||
template<class ColorT, class Order = void>
|
||||
|
@ -42,7 +46,8 @@ struct blender_base
|
|||
{
|
||||
if (cover > cover_none)
|
||||
{
|
||||
rgba c(color_type::to_double(r),
|
||||
rgba c(
|
||||
color_type::to_double(r),
|
||||
color_type::to_double(g),
|
||||
color_type::to_double(b),
|
||||
color_type::to_double(a));
|
||||
|
@ -58,13 +63,17 @@ struct blender_base
|
|||
|
||||
return c;
|
||||
}
|
||||
else
|
||||
return rgba::no_color();
|
||||
else return rgba::no_color();
|
||||
}
|
||||
|
||||
static rgba get(const value_type* p, cover_type cover = cover_full)
|
||||
{
|
||||
return get(p[order_type::R], p[order_type::G], p[order_type::B], p[order_type::A], cover);
|
||||
return get(
|
||||
p[order_type::R],
|
||||
p[order_type::G],
|
||||
p[order_type::B],
|
||||
p[order_type::A],
|
||||
cover);
|
||||
}
|
||||
|
||||
static void set(value_type* p, value_type r, value_type g, value_type b, value_type a)
|
||||
|
@ -83,6 +92,6 @@ struct blender_base
|
|||
p[order_type::A] = color_type::from_double(c.a);
|
||||
}
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
284
deps/agg/include/agg_pixfmt_gray.h
vendored
284
deps/agg/include/agg_pixfmt_gray.h
vendored
|
@ -28,11 +28,11 @@
|
|||
#include "agg_pixfmt_base.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//============================================================blender_gray
|
||||
template<class ColorT>
|
||||
struct blender_gray
|
||||
template<class ColorT> struct blender_gray
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
|
@ -43,20 +43,22 @@ struct blender_gray
|
|||
// compositing function. Since the render buffer is opaque we skip the
|
||||
// initial premultiply and final demultiply.
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, value_type cv, value_type alpha, cover_type cover)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha, cover_type cover)
|
||||
{
|
||||
blend_pix(p, cv, color_type::mult_cover(alpha, cover));
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, value_type cv, value_type alpha)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha)
|
||||
{
|
||||
*p = color_type::lerp(*p, cv, alpha);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//======================================================blender_gray_pre
|
||||
template<class ColorT>
|
||||
struct blender_gray_pre
|
||||
template<class ColorT> struct blender_gray_pre
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
|
@ -66,51 +68,59 @@ struct blender_gray_pre
|
|||
// Blend pixels using the premultiplied form of Alvy-Ray Smith's
|
||||
// compositing function.
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, value_type cv, value_type alpha, cover_type cover)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha, cover_type cover)
|
||||
{
|
||||
blend_pix(p, color_type::mult_cover(cv, cover), color_type::mult_cover(alpha, cover));
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, value_type cv, value_type alpha)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha)
|
||||
{
|
||||
*p = color_type::prelerp(*p, cv, alpha);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================================apply_gamma_dir_gray
|
||||
template<class ColorT, class GammaLut>
|
||||
class apply_gamma_dir_gray
|
||||
template<class ColorT, class GammaLut> class apply_gamma_dir_gray
|
||||
{
|
||||
public:
|
||||
typedef typename ColorT::value_type value_type;
|
||||
|
||||
apply_gamma_dir_gray(const GammaLut& gamma)
|
||||
: m_gamma(gamma)
|
||||
{}
|
||||
apply_gamma_dir_gray(const GammaLut& gamma) : m_gamma(gamma) {}
|
||||
|
||||
AGG_INLINE void operator()(value_type* p) { *p = m_gamma.dir(*p); }
|
||||
AGG_INLINE void operator () (value_type* p)
|
||||
{
|
||||
*p = m_gamma.dir(*p);
|
||||
}
|
||||
|
||||
private:
|
||||
const GammaLut& m_gamma;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================================apply_gamma_inv_gray
|
||||
template<class ColorT, class GammaLut>
|
||||
class apply_gamma_inv_gray
|
||||
template<class ColorT, class GammaLut> class apply_gamma_inv_gray
|
||||
{
|
||||
public:
|
||||
typedef typename ColorT::value_type value_type;
|
||||
|
||||
apply_gamma_inv_gray(const GammaLut& gamma)
|
||||
: m_gamma(gamma)
|
||||
{}
|
||||
apply_gamma_inv_gray(const GammaLut& gamma) : m_gamma(gamma) {}
|
||||
|
||||
AGG_INLINE void operator()(value_type* p) { *p = m_gamma.inv(*p); }
|
||||
AGG_INLINE void operator () (value_type* p)
|
||||
{
|
||||
*p = m_gamma.inv(*p);
|
||||
}
|
||||
|
||||
private:
|
||||
const GammaLut& m_gamma;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=================================================pixfmt_alpha_blend_gray
|
||||
template<class Blender, class RenBuf, unsigned Step = 1, unsigned Offset = 0>
|
||||
class pixfmt_alpha_blend_gray
|
||||
|
@ -124,7 +134,8 @@ class pixfmt_alpha_blend_gray
|
|||
typedef int order_type; // A fake one
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
num_components = 1,
|
||||
pix_width = sizeof(value_type) * Step,
|
||||
pix_step = Step,
|
||||
|
@ -134,32 +145,61 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
value_type c[num_components];
|
||||
|
||||
void set(value_type v) { c[0] = v; }
|
||||
void set(value_type v)
|
||||
{
|
||||
c[0] = v;
|
||||
}
|
||||
|
||||
void set(const color_type& color) { set(color.v); }
|
||||
void set(const color_type& color)
|
||||
{
|
||||
set(color.v);
|
||||
}
|
||||
|
||||
void get(value_type& v) const { v = c[0]; }
|
||||
void get(value_type& v) const
|
||||
{
|
||||
v = c[0];
|
||||
}
|
||||
|
||||
color_type get() const { return color_type(c[0]); }
|
||||
color_type get() const
|
||||
{
|
||||
return color_type(c[0]);
|
||||
}
|
||||
|
||||
pixel_type* next() { return (pixel_type*)(c + pix_step); }
|
||||
pixel_type* next()
|
||||
{
|
||||
return (pixel_type*)(c + pix_step);
|
||||
}
|
||||
|
||||
const pixel_type* next() const { return (const pixel_type*)(c + pix_step); }
|
||||
const pixel_type* next() const
|
||||
{
|
||||
return (const pixel_type*)(c + pix_step);
|
||||
}
|
||||
|
||||
pixel_type* advance(int n) { return (pixel_type*)(c + n * pix_step); }
|
||||
pixel_type* advance(int n)
|
||||
{
|
||||
return (pixel_type*)(c + n * pix_step);
|
||||
}
|
||||
|
||||
const pixel_type* advance(int n) const { return (const pixel_type*)(c + n * pix_step); }
|
||||
const pixel_type* advance(int n) const
|
||||
{
|
||||
return (const pixel_type*)(c + n * pix_step);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, value_type v, value_type a, unsigned cover)
|
||||
AGG_INLINE void blend_pix(pixel_type* p,
|
||||
value_type v, value_type a,
|
||||
unsigned cover)
|
||||
{
|
||||
blender_type::blend_pix(p->c, v, a, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, value_type v, value_type a) { blender_type::blend_pix(p->c, v, a); }
|
||||
AGG_INLINE void blend_pix(pixel_type* p, value_type v, value_type a)
|
||||
{
|
||||
blender_type::blend_pix(p->c, v, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover)
|
||||
|
@ -168,7 +208,10 @@ class pixfmt_alpha_blend_gray
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, const color_type& c) { blender_type::blend_pix(p->c, c.v, c.a); }
|
||||
AGG_INLINE void blend_pix(pixel_type* p, const color_type& c)
|
||||
{
|
||||
blender_type::blend_pix(p->c, c.v, c.a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover)
|
||||
|
@ -204,8 +247,8 @@ class pixfmt_alpha_blend_gray
|
|||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
explicit pixfmt_alpha_blend_gray(rbuf_type& rb)
|
||||
: m_rbuf(&rb)
|
||||
explicit pixfmt_alpha_blend_gray(rbuf_type& rb) :
|
||||
m_rbuf(&rb)
|
||||
{}
|
||||
void attach(rbuf_type& rb) { m_rbuf = &rb; }
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -217,7 +260,10 @@ class pixfmt_alpha_blend_gray
|
|||
if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1)))
|
||||
{
|
||||
int stride = pixf.stride();
|
||||
m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), (r.x2 - r.x1) + 1, (r.y2 - r.y1) + 1, stride);
|
||||
m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1),
|
||||
(r.x2 - r.x1) + 1,
|
||||
(r.y2 - r.y1) + 1,
|
||||
stride);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -258,7 +304,10 @@ class pixfmt_alpha_blend_gray
|
|||
}
|
||||
|
||||
// Get pixel pointer from raw buffer pointer.
|
||||
AGG_INLINE static pixel_type* pix_value_ptr(void* p) { return (pixel_type*)((value_type*)p + pix_offset); }
|
||||
AGG_INLINE static pixel_type* pix_value_ptr(void* p)
|
||||
{
|
||||
return (pixel_type*)((value_type*)p + pix_offset);
|
||||
}
|
||||
|
||||
// Get pixel pointer from raw buffer pointer.
|
||||
AGG_INLINE static const pixel_type* pix_value_ptr(const void* p)
|
||||
|
@ -275,10 +324,16 @@ class pixfmt_alpha_blend_gray
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static color_type read_plain_color(const void* p) { return pix_value_ptr(p)->get(); }
|
||||
AGG_INLINE static color_type read_plain_color(const void* p)
|
||||
{
|
||||
return pix_value_ptr(p)->get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static void make_pix(int8u* p, const color_type& c) { ((pixel_type*)p)->set(c); }
|
||||
AGG_INLINE static void make_pix(int8u* p, const color_type& c)
|
||||
{
|
||||
((pixel_type*)p)->set(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE color_type pixel(int x, int y) const
|
||||
|
@ -291,7 +346,10 @@ class pixfmt_alpha_blend_gray
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { pix_value_ptr(x, y, 1)->set(c); }
|
||||
AGG_INLINE void copy_pixel(int x, int y, const color_type& c)
|
||||
{
|
||||
pix_value_ptr(x, y, 1)->set(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover)
|
||||
|
@ -300,27 +358,38 @@ class pixfmt_alpha_blend_gray
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c)
|
||||
AGG_INLINE void copy_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
do
|
||||
{
|
||||
p->set(c);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c)
|
||||
AGG_INLINE void copy_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
do
|
||||
{
|
||||
pix_value_ptr(x, y++, 1)->set(c);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover)
|
||||
void blend_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
|
@ -332,7 +401,8 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
p->set(c);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -340,13 +410,18 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
blend_pix(p, c, cover);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover)
|
||||
void blend_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
|
@ -355,20 +430,26 @@ class pixfmt_alpha_blend_gray
|
|||
do
|
||||
{
|
||||
pix_value_ptr(x, y++, 1)->set(c);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
blend_pix(pix_value_ptr(x, y++, 1), c, cover);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers)
|
||||
void blend_solid_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
|
@ -386,12 +467,17 @@ class pixfmt_alpha_blend_gray
|
|||
}
|
||||
p = p->next();
|
||||
++covers;
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers)
|
||||
void blend_solid_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
|
@ -408,12 +494,16 @@ class pixfmt_alpha_blend_gray
|
|||
blend_pix(p, c, *covers);
|
||||
}
|
||||
++covers;
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_hspan(int x, int y, unsigned len, const color_type* colors)
|
||||
void copy_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
|
||||
|
@ -421,20 +511,30 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
p->set(*colors++);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_vspan(int x, int y, unsigned len, const color_type* colors)
|
||||
void copy_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
do
|
||||
{
|
||||
pix_value_ptr(x, y++, 1)->set(*colors++);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover)
|
||||
void blend_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
|
||||
|
@ -444,7 +544,8 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -454,7 +555,8 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -462,20 +564,27 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover)
|
||||
void blend_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
if (covers)
|
||||
{
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -484,21 +593,22 @@ class pixfmt_alpha_blend_gray
|
|||
do
|
||||
{
|
||||
copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover);
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Function>
|
||||
void for_each_pixel(Function f)
|
||||
template<class Function> void for_each_pixel(Function f)
|
||||
{
|
||||
unsigned y;
|
||||
for (y = 0; y < height(); ++y)
|
||||
|
@ -512,32 +622,36 @@ class pixfmt_alpha_blend_gray
|
|||
{
|
||||
f(p->c);
|
||||
p = p->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class GammaLut>
|
||||
void apply_gamma_dir(const GammaLut& g)
|
||||
template<class GammaLut> void apply_gamma_dir(const GammaLut& g)
|
||||
{
|
||||
for_each_pixel(apply_gamma_dir_gray<color_type, GammaLut>(g));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class GammaLut>
|
||||
void apply_gamma_inv(const GammaLut& g)
|
||||
template<class GammaLut> void apply_gamma_inv(const GammaLut& g)
|
||||
{
|
||||
for_each_pixel(apply_gamma_inv_gray<color_type, GammaLut>(g));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class RenBuf2>
|
||||
void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len)
|
||||
void copy_from(const RenBuf2& from,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len)
|
||||
{
|
||||
if (const int8u* p = from.row_ptr(ysrc))
|
||||
{
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width);
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width,
|
||||
p + xsrc * pix_width,
|
||||
len * pix_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,10 +660,8 @@ class pixfmt_alpha_blend_gray
|
|||
template<class SrcPixelFormatRenderer>
|
||||
void blend_from_color(const SrcPixelFormatRenderer& from,
|
||||
const color_type& color,
|
||||
int xdst,
|
||||
int ydst,
|
||||
int xsrc,
|
||||
int ysrc,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len,
|
||||
int8u cover)
|
||||
{
|
||||
|
@ -565,7 +677,8 @@ class pixfmt_alpha_blend_gray
|
|||
copy_or_blend_pix(pdst, color, src_color_type::scale_cover(cover, psrc->c[0]));
|
||||
psrc = psrc->next();
|
||||
pdst = pdst->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,10 +688,8 @@ class pixfmt_alpha_blend_gray
|
|||
template<class SrcPixelFormatRenderer>
|
||||
void blend_from_lut(const SrcPixelFormatRenderer& from,
|
||||
const color_type* color_lut,
|
||||
int xdst,
|
||||
int ydst,
|
||||
int xsrc,
|
||||
int ysrc,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len,
|
||||
int8u cover)
|
||||
{
|
||||
|
@ -593,7 +704,8 @@ class pixfmt_alpha_blend_gray
|
|||
copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover);
|
||||
psrc = psrc->next();
|
||||
pdst = pdst->next();
|
||||
} while (--len);
|
||||
}
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,6 +732,6 @@ typedef pixfmt_alpha_blend_gray<blender_gray8_pre, rendering_buffer> pixfmt_gray
|
|||
typedef pixfmt_alpha_blend_gray<blender_sgray8_pre, rendering_buffer> pixfmt_sgray8_pre;
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray16_pre, rendering_buffer> pixfmt_gray16_pre;
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray32_pre, rendering_buffer> pixfmt_gray32_pre;
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
364
deps/agg/include/agg_pixfmt_rgb.h
vendored
364
deps/agg/include/agg_pixfmt_rgb.h
vendored
|
@ -29,18 +29,16 @@
|
|||
#include "agg_color_rgba.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=====================================================apply_gamma_dir_rgb
|
||||
template<class ColorT, class Order, class GammaLut>
|
||||
class apply_gamma_dir_rgb
|
||||
template<class ColorT, class Order, class GammaLut> class apply_gamma_dir_rgb
|
||||
{
|
||||
public:
|
||||
typedef typename ColorT::value_type value_type;
|
||||
|
||||
apply_gamma_dir_rgb(const GammaLut& gamma)
|
||||
: m_gamma(gamma)
|
||||
{}
|
||||
apply_gamma_dir_rgb(const GammaLut& gamma) : m_gamma(gamma) {}
|
||||
|
||||
AGG_INLINE void operator () (value_type* p)
|
||||
{
|
||||
|
@ -53,16 +51,15 @@ class apply_gamma_dir_rgb
|
|||
const GammaLut& m_gamma;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================================apply_gamma_inv_rgb
|
||||
template<class ColorT, class Order, class GammaLut>
|
||||
class apply_gamma_inv_rgb
|
||||
template<class ColorT, class Order, class GammaLut> class apply_gamma_inv_rgb
|
||||
{
|
||||
public:
|
||||
typedef typename ColorT::value_type value_type;
|
||||
|
||||
apply_gamma_inv_rgb(const GammaLut& gamma)
|
||||
: m_gamma(gamma)
|
||||
{}
|
||||
apply_gamma_inv_rgb(const GammaLut& gamma) : m_gamma(gamma) {}
|
||||
|
||||
AGG_INLINE void operator () (value_type* p)
|
||||
{
|
||||
|
@ -75,9 +72,9 @@ class apply_gamma_inv_rgb
|
|||
const GammaLut& m_gamma;
|
||||
};
|
||||
|
||||
|
||||
//=========================================================blender_rgb
|
||||
template<class ColorT, class Order>
|
||||
struct blender_rgb
|
||||
template<class ColorT, class Order> struct blender_rgb
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
|
@ -86,8 +83,10 @@ struct blender_rgb
|
|||
enum base_scale_e { base_shift = color_type::base_shift };
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE void
|
||||
blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover = 0)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned cr, unsigned cg, unsigned cb,
|
||||
unsigned alpha,
|
||||
unsigned cover=0)
|
||||
{
|
||||
p[Order::R] += (value_type)(((cr - p[Order::R]) * alpha) >> base_shift);
|
||||
p[Order::G] += (value_type)(((cg - p[Order::G]) * alpha) >> base_shift);
|
||||
|
@ -95,9 +94,9 @@ struct blender_rgb
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//======================================================blender_rgb_pre
|
||||
template<class ColorT, class Order>
|
||||
struct blender_rgb_pre
|
||||
template<class ColorT, class Order> struct blender_rgb_pre
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
|
@ -106,8 +105,10 @@ struct blender_rgb_pre
|
|||
enum base_scale_e { base_shift = color_type::base_shift };
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE void
|
||||
blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned cr, unsigned cg, unsigned cb,
|
||||
unsigned alpha,
|
||||
unsigned cover)
|
||||
{
|
||||
alpha = color_type::base_mask - alpha;
|
||||
cover = (cover + 1) << (base_shift - 8);
|
||||
|
@ -117,18 +118,22 @@ struct blender_rgb_pre
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned cr, unsigned cg, unsigned cb,
|
||||
unsigned alpha)
|
||||
{
|
||||
alpha = color_type::base_mask - alpha;
|
||||
p[Order::R] = (value_type)(((p[Order::R] * alpha) >> base_shift) + cr);
|
||||
p[Order::G] = (value_type)(((p[Order::G] * alpha) >> base_shift) + cg);
|
||||
p[Order::B] = (value_type)(((p[Order::B] * alpha) >> base_shift) + cb);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//===================================================blender_rgb_gamma
|
||||
template<class ColorT, class Order, class Gamma>
|
||||
class blender_rgb_gamma
|
||||
template<class ColorT, class Order, class Gamma> class blender_rgb_gamma
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
|
@ -139,13 +144,14 @@ class blender_rgb_gamma
|
|||
enum base_scale_e { base_shift = color_type::base_shift };
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
blender_rgb_gamma()
|
||||
: m_gamma(0)
|
||||
{}
|
||||
blender_rgb_gamma() : m_gamma(0) {}
|
||||
void gamma(const gamma_type& g) { m_gamma = &g; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover = 0)
|
||||
AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned cr, unsigned cg, unsigned cb,
|
||||
unsigned alpha,
|
||||
unsigned cover=0)
|
||||
{
|
||||
calc_type r = m_gamma->dir(p[Order::R]);
|
||||
calc_type g = m_gamma->dir(p[Order::G]);
|
||||
|
@ -159,9 +165,11 @@ class blender_rgb_gamma
|
|||
const gamma_type* m_gamma;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================pixfmt_alpha_blend_rgb
|
||||
template<class Blender, class RenBuf>
|
||||
class pixfmt_alpha_blend_rgb
|
||||
template<class Blender, class RenBuf> class pixfmt_alpha_blend_rgb
|
||||
{
|
||||
public:
|
||||
typedef RenBuf rbuf_type;
|
||||
|
@ -171,7 +179,8 @@ class pixfmt_alpha_blend_rgb
|
|||
typedef typename blender_type::order_type order_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
enum base_scale_e {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_scale = color_type::base_scale,
|
||||
base_mask = color_type::base_mask,
|
||||
|
@ -180,7 +189,9 @@ class pixfmt_alpha_blend_rgb
|
|||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c, unsigned cover)
|
||||
AGG_INLINE void copy_or_blend_pix(value_type* p,
|
||||
const color_type& c,
|
||||
unsigned cover)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -199,7 +210,8 @@ class pixfmt_alpha_blend_rgb
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c)
|
||||
AGG_INLINE void copy_or_blend_pix(value_type* p,
|
||||
const color_type& c)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -216,10 +228,11 @@ class pixfmt_alpha_blend_rgb
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
explicit pixfmt_alpha_blend_rgb(rbuf_type& rb)
|
||||
: m_rbuf(&rb)
|
||||
explicit pixfmt_alpha_blend_rgb(rbuf_type& rb) :
|
||||
m_rbuf(&rb)
|
||||
{}
|
||||
void attach(rbuf_type& rb) { m_rbuf = &rb; }
|
||||
|
||||
|
@ -231,7 +244,10 @@ class pixfmt_alpha_blend_rgb
|
|||
if(r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1)))
|
||||
{
|
||||
int stride = pixf.stride();
|
||||
m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), (r.x2 - r.x1) + 1, (r.y2 - r.y1) + 1, stride);
|
||||
m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1),
|
||||
(r.x2 - r.x1) + 1,
|
||||
(r.y2 - r.y1) + 1,
|
||||
stride);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -251,9 +267,15 @@ class pixfmt_alpha_blend_rgb
|
|||
AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE int8u* pix_ptr(int x, int y) { return m_rbuf->row_ptr(y) + x * pix_width; }
|
||||
AGG_INLINE int8u* pix_ptr(int x, int y)
|
||||
{
|
||||
return m_rbuf->row_ptr(y) + x * pix_width;
|
||||
}
|
||||
|
||||
AGG_INLINE const int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * pix_width; }
|
||||
AGG_INLINE const int8u* pix_ptr(int x, int y) const
|
||||
{
|
||||
return m_rbuf->row_ptr(y) + x * pix_width;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static void make_pix(int8u* p, const color_type& c)
|
||||
|
@ -267,7 +289,9 @@ class pixfmt_alpha_blend_rgb
|
|||
AGG_INLINE color_type pixel(int x, int y) const
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(y) + x + x + x;
|
||||
return color_type(p[order_type::R], p[order_type::G], p[order_type::B]);
|
||||
return color_type(p[order_type::R],
|
||||
p[order_type::G],
|
||||
p[order_type::B]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -285,8 +309,11 @@ class pixfmt_alpha_blend_rgb
|
|||
copy_or_blend_pix((value_type*)m_rbuf->row_ptr(x, y, 1) + x + x + x, c, cover);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c)
|
||||
AGG_INLINE void copy_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
do
|
||||
|
@ -295,27 +322,38 @@ class pixfmt_alpha_blend_rgb
|
|||
p[order_type::G] = c.g;
|
||||
p[order_type::B] = c.b;
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c)
|
||||
AGG_INLINE void copy_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p[order_type::R] = c.r;
|
||||
p[order_type::G] = c.g;
|
||||
p[order_type::B] = c.b;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover)
|
||||
void blend_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
|
||||
calc_type alpha = (calc_type(c.a) * (calc_type(cover) + 1)) >> 8;
|
||||
if(alpha == base_mask)
|
||||
|
@ -326,7 +364,8 @@ class pixfmt_alpha_blend_rgb
|
|||
p[order_type::G] = c.g;
|
||||
p[order_type::B] = c.b;
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -334,13 +373,18 @@ class pixfmt_alpha_blend_rgb
|
|||
{
|
||||
m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover);
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover)
|
||||
void blend_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -350,31 +394,40 @@ class pixfmt_alpha_blend_rgb
|
|||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
|
||||
p[order_type::R] = c.r;
|
||||
p[order_type::G] = c.g;
|
||||
p[order_type::B] = c.b;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
|
||||
m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover);
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers)
|
||||
void blend_solid_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -391,18 +444,24 @@ class pixfmt_alpha_blend_rgb
|
|||
}
|
||||
p += 3;
|
||||
++covers;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers)
|
||||
void blend_solid_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
|
||||
calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;
|
||||
if(alpha == base_mask)
|
||||
|
@ -416,14 +475,19 @@ class pixfmt_alpha_blend_rgb
|
|||
m_blender.blend_pix(p, c.r, c.g, c.b, alpha, *covers);
|
||||
}
|
||||
++covers;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_hspan(int x, int y, unsigned len, const color_type* colors)
|
||||
void copy_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -432,26 +496,38 @@ class pixfmt_alpha_blend_rgb
|
|||
p[order_type::B] = colors->b;
|
||||
++colors;
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_vspan(int x, int y, unsigned len, const color_type* colors)
|
||||
void copy_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p[order_type::R] = colors->r;
|
||||
p[order_type::G] = colors->g;
|
||||
p[order_type::B] = colors->b;
|
||||
++colors;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover)
|
||||
void blend_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x + x + x;
|
||||
|
||||
if(covers)
|
||||
{
|
||||
|
@ -459,7 +535,8 @@ class pixfmt_alpha_blend_rgb
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -469,7 +546,8 @@ class pixfmt_alpha_blend_rgb
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++);
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -477,23 +555,32 @@ class pixfmt_alpha_blend_rgb
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover)
|
||||
void blend_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
value_type* p;
|
||||
if(covers)
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -501,26 +588,29 @@ class pixfmt_alpha_blend_rgb
|
|||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
|
||||
copy_or_blend_pix(p, *colors++);
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x + x + x;
|
||||
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Function>
|
||||
void for_each_pixel(Function f)
|
||||
template<class Function> void for_each_pixel(Function f)
|
||||
{
|
||||
unsigned y;
|
||||
for(y = 0; y < height(); ++y)
|
||||
|
@ -529,45 +619,54 @@ class pixfmt_alpha_blend_rgb
|
|||
if(r.ptr)
|
||||
{
|
||||
unsigned len = r.x2 - r.x1 + 1;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(r.x1, y, len) + r.x1 * 3;
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(r.x1, y, len) + r.x1 * 3;
|
||||
do
|
||||
{
|
||||
f(p);
|
||||
p += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class GammaLut>
|
||||
void apply_gamma_dir(const GammaLut& g)
|
||||
template<class GammaLut> void apply_gamma_dir(const GammaLut& g)
|
||||
{
|
||||
for_each_pixel(apply_gamma_dir_rgb<color_type, order_type, GammaLut>(g));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class GammaLut>
|
||||
void apply_gamma_inv(const GammaLut& g)
|
||||
template<class GammaLut> void apply_gamma_inv(const GammaLut& g)
|
||||
{
|
||||
for_each_pixel(apply_gamma_inv_rgb<color_type, order_type, GammaLut>(g));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class RenBuf2>
|
||||
void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len)
|
||||
void copy_from(const RenBuf2& from,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len)
|
||||
{
|
||||
const int8u* p = from.row_ptr(ysrc);
|
||||
if(p)
|
||||
{
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width);
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width,
|
||||
p + xsrc * pix_width,
|
||||
len * pix_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class SrcPixelFormatRenderer>
|
||||
void
|
||||
blend_from(const SrcPixelFormatRenderer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len, int8u cover)
|
||||
void blend_from(const SrcPixelFormatRenderer& from,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len,
|
||||
int8u cover)
|
||||
{
|
||||
typedef typename SrcPixelFormatRenderer::order_type src_order;
|
||||
|
||||
|
@ -575,7 +674,8 @@ class pixfmt_alpha_blend_rgb
|
|||
if(psrc)
|
||||
{
|
||||
psrc += xsrc * 4;
|
||||
value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;
|
||||
|
||||
if(cover == 255)
|
||||
{
|
||||
|
@ -601,7 +701,8 @@ class pixfmt_alpha_blend_rgb
|
|||
}
|
||||
psrc += 4;
|
||||
pdst += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -615,7 +716,8 @@ class pixfmt_alpha_blend_rgb
|
|||
copy_or_blend_pix(pdst, color, cover);
|
||||
psrc += 4;
|
||||
pdst += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,10 +726,8 @@ class pixfmt_alpha_blend_rgb
|
|||
template<class SrcPixelFormatRenderer>
|
||||
void blend_from_color(const SrcPixelFormatRenderer& from,
|
||||
const color_type& color,
|
||||
int xdst,
|
||||
int ydst,
|
||||
int xsrc,
|
||||
int ysrc,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len,
|
||||
int8u cover)
|
||||
{
|
||||
|
@ -635,13 +735,17 @@ class pixfmt_alpha_blend_rgb
|
|||
const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc);
|
||||
if(psrc)
|
||||
{
|
||||
value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pdst, color, (*psrc * cover + base_mask) >> base_shift);
|
||||
copy_or_blend_pix(pdst,
|
||||
color,
|
||||
(*psrc * cover + base_mask) >> base_shift);
|
||||
++psrc;
|
||||
pdst += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -649,10 +753,8 @@ class pixfmt_alpha_blend_rgb
|
|||
template<class SrcPixelFormatRenderer>
|
||||
void blend_from_lut(const SrcPixelFormatRenderer& from,
|
||||
const color_type* color_lut,
|
||||
int xdst,
|
||||
int ydst,
|
||||
int xsrc,
|
||||
int ysrc,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len,
|
||||
int8u cover)
|
||||
{
|
||||
|
@ -660,17 +762,20 @@ class pixfmt_alpha_blend_rgb
|
|||
const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc);
|
||||
if(psrc)
|
||||
{
|
||||
value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3;
|
||||
|
||||
if(cover == 255)
|
||||
{
|
||||
do
|
||||
{
|
||||
const color_type& color = color_lut[*psrc];
|
||||
m_blender.blend_pix(pdst, color.r, color.g, color.b, color.a);
|
||||
m_blender.blend_pix(pdst,
|
||||
color.r, color.g, color.b, color.a);
|
||||
++psrc;
|
||||
pdst += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -679,7 +784,8 @@ class pixfmt_alpha_blend_rgb
|
|||
copy_or_blend_pix(pdst, color_lut[*psrc], cover);
|
||||
++psrc;
|
||||
pdst += 3;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -694,63 +800,61 @@ typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba8, order_bgr>, rendering_buffer>
|
|||
typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba16, order_rgb>, rendering_buffer> pixfmt_rgb48; //----pixfmt_rgb48
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb<rgba16, order_bgr>, rendering_buffer> pixfmt_bgr48; //----pixfmt_bgr48
|
||||
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba8, order_rgb>, rendering_buffer>
|
||||
pixfmt_rgb24_pre; //----pixfmt_rgb24_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba8, order_bgr>, rendering_buffer>
|
||||
pixfmt_bgr24_pre; //----pixfmt_bgr24_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba16, order_rgb>, rendering_buffer>
|
||||
pixfmt_rgb48_pre; //----pixfmt_rgb48_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba16, order_bgr>, rendering_buffer>
|
||||
pixfmt_bgr48_pre; //----pixfmt_bgr48_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba8, order_rgb>, rendering_buffer> pixfmt_rgb24_pre; //----pixfmt_rgb24_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba8, order_bgr>, rendering_buffer> pixfmt_bgr24_pre; //----pixfmt_bgr24_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba16, order_rgb>, rendering_buffer> pixfmt_rgb48_pre; //----pixfmt_rgb48_pre
|
||||
typedef pixfmt_alpha_blend_rgb<blender_rgb_pre<rgba16, order_bgr>, rendering_buffer> pixfmt_bgr48_pre; //----pixfmt_bgr48_pre
|
||||
|
||||
//-----------------------------------------------------pixfmt_rgb24_gamma
|
||||
template<class Gamma>
|
||||
class pixfmt_rgb24_gamma : public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer>
|
||||
template<class Gamma> class pixfmt_rgb24_gamma :
|
||||
public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer>
|
||||
{
|
||||
public:
|
||||
pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g)
|
||||
: pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer>(rb)
|
||||
pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g) :
|
||||
pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer>(rb)
|
||||
{
|
||||
this->blender().gamma(g);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------pixfmt_bgr24_gamma
|
||||
template<class Gamma>
|
||||
class pixfmt_bgr24_gamma : public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer>
|
||||
template<class Gamma> class pixfmt_bgr24_gamma :
|
||||
public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer>
|
||||
{
|
||||
public:
|
||||
pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g)
|
||||
: pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer>(rb)
|
||||
pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g) :
|
||||
pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer>(rb)
|
||||
{
|
||||
this->blender().gamma(g);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------pixfmt_rgb48_gamma
|
||||
template<class Gamma>
|
||||
class pixfmt_rgb48_gamma : public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer>
|
||||
template<class Gamma> class pixfmt_rgb48_gamma :
|
||||
public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer>
|
||||
{
|
||||
public:
|
||||
pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g)
|
||||
: pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer>(rb)
|
||||
pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g) :
|
||||
pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer>(rb)
|
||||
{
|
||||
this->blender().gamma(g);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------pixfmt_bgr48_gamma
|
||||
template<class Gamma>
|
||||
class pixfmt_bgr48_gamma : public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer>
|
||||
template<class Gamma> class pixfmt_bgr48_gamma :
|
||||
public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer>
|
||||
{
|
||||
public:
|
||||
pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g)
|
||||
: pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer>(rb)
|
||||
pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g) :
|
||||
pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer>(rb)
|
||||
{
|
||||
this->blender().gamma(g);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
627
deps/agg/include/agg_pixfmt_rgb_packed.h
vendored
627
deps/agg/include/agg_pixfmt_rgb_packed.h
vendored
File diff suppressed because it is too large
Load diff
1432
deps/agg/include/agg_pixfmt_rgba.h
vendored
1432
deps/agg/include/agg_pixfmt_rgba.h
vendored
File diff suppressed because it is too large
Load diff
91
deps/agg/include/agg_pixfmt_transposer.h
vendored
91
deps/agg/include/agg_pixfmt_transposer.h
vendored
|
@ -18,10 +18,10 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//=======================================================pixfmt_transposer
|
||||
template<class PixFmt>
|
||||
class pixfmt_transposer
|
||||
template<class PixFmt> class pixfmt_transposer
|
||||
{
|
||||
public:
|
||||
typedef PixFmt pixfmt_type;
|
||||
|
@ -31,12 +31,8 @@ class pixfmt_transposer
|
|||
typedef typename color_type::calc_type calc_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
pixfmt_transposer()
|
||||
: m_pixf(0)
|
||||
{}
|
||||
explicit pixfmt_transposer(pixfmt_type& pixf)
|
||||
: m_pixf(&pixf)
|
||||
{}
|
||||
pixfmt_transposer() : m_pixf(0) {}
|
||||
explicit pixfmt_transposer(pixfmt_type& pixf) : m_pixf(&pixf) {}
|
||||
void attach(pixfmt_type& pixf) { m_pixf = &pixf; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -44,66 +40,109 @@ class pixfmt_transposer
|
|||
AGG_INLINE unsigned height() const { return m_pixf->width(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE color_type pixel(int x, int y) const { return m_pixf->pixel(y, x); }
|
||||
AGG_INLINE color_type pixel(int x, int y) const
|
||||
{
|
||||
return m_pixf->pixel(y, x);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { m_pixf->copy_pixel(y, x, c); }
|
||||
AGG_INLINE void copy_pixel(int x, int y, const color_type& c)
|
||||
{
|
||||
m_pixf->copy_pixel(y, x, c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { m_pixf->blend_pixel(y, x, c, cover); }
|
||||
AGG_INLINE void blend_pixel(int x, int y,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
m_pixf->blend_pixel(y, x, c, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c) { m_pixf->copy_vline(y, x, len, c); }
|
||||
AGG_INLINE void copy_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
m_pixf->copy_vline(y, x, len, c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c) { m_pixf->copy_hline(y, x, len, c); }
|
||||
AGG_INLINE void copy_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
{
|
||||
m_pixf->copy_hline(y, x, len, c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover)
|
||||
AGG_INLINE void blend_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
m_pixf->blend_vline(y, x, len, c, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover)
|
||||
AGG_INLINE void blend_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
m_pixf->blend_hline(y, x, len, c, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers)
|
||||
AGG_INLINE void blend_solid_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
m_pixf->blend_solid_vspan(y, x, len, c, covers);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers)
|
||||
AGG_INLINE void blend_solid_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
m_pixf->blend_solid_hspan(y, x, len, c, covers);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_color_hspan(int x, int y, unsigned len, const color_type* colors)
|
||||
AGG_INLINE void copy_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
m_pixf->copy_color_vspan(y, x, len, colors);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_color_vspan(int x, int y, unsigned len, const color_type* colors)
|
||||
AGG_INLINE void copy_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
m_pixf->copy_color_hspan(y, x, len, colors);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void
|
||||
blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover)
|
||||
AGG_INLINE void blend_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
m_pixf->blend_color_vspan(y, x, len, colors, covers, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void
|
||||
blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover)
|
||||
AGG_INLINE void blend_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
m_pixf->blend_color_hspan(y, x, len, colors, covers, cover);
|
||||
}
|
||||
|
@ -111,6 +150,8 @@ class pixfmt_transposer
|
|||
private:
|
||||
pixfmt_type* m_pixf;
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
139
deps/agg/include/agg_rasterizer_cells_aa.h
vendored
139
deps/agg/include/agg_rasterizer_cells_aa.h
vendored
|
@ -35,15 +35,17 @@
|
|||
#include "agg_math.h"
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------rasterizer_cells_aa
|
||||
// An internal class that implements the main rasterization algorithm.
|
||||
// Used in the rasterizer. Should not be used direcly.
|
||||
template<class Cell>
|
||||
class rasterizer_cells_aa
|
||||
template<class Cell> class rasterizer_cells_aa
|
||||
{
|
||||
enum cell_block_scale_e
|
||||
{
|
||||
enum cell_block_scale_e {
|
||||
cell_block_shift = 12,
|
||||
cell_block_size = 1 << cell_block_shift,
|
||||
cell_block_mask = cell_block_size - 1,
|
||||
|
@ -75,9 +77,15 @@ class rasterizer_cells_aa
|
|||
|
||||
void sort_cells();
|
||||
|
||||
unsigned total_cells() const { return m_num_cells; }
|
||||
unsigned total_cells() const
|
||||
{
|
||||
return m_num_cells;
|
||||
}
|
||||
|
||||
unsigned scanline_num_cells(unsigned y) const { return m_sorted_y[y - m_min_y].num; }
|
||||
unsigned scanline_num_cells(unsigned y) const
|
||||
{
|
||||
return m_sorted_y[y - m_min_y].num;
|
||||
}
|
||||
|
||||
const cell_type* const* scanline_cells(unsigned y) const
|
||||
{
|
||||
|
@ -113,6 +121,9 @@ class rasterizer_cells_aa
|
|||
bool m_sorted;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Cell>
|
||||
rasterizer_cells_aa<Cell>::~rasterizer_cells_aa()
|
||||
|
@ -132,20 +143,20 @@ rasterizer_cells_aa<Cell>::~rasterizer_cells_aa()
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Cell>
|
||||
rasterizer_cells_aa<Cell>::rasterizer_cells_aa()
|
||||
: m_num_blocks(0)
|
||||
, m_max_blocks(0)
|
||||
, m_curr_block(0)
|
||||
, m_num_cells(0)
|
||||
, m_cells(0)
|
||||
, m_curr_cell_ptr(0)
|
||||
, m_sorted_cells()
|
||||
, m_sorted_y()
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
, m_sorted(false)
|
||||
rasterizer_cells_aa<Cell>::rasterizer_cells_aa() :
|
||||
m_num_blocks(0),
|
||||
m_max_blocks(0),
|
||||
m_curr_block(0),
|
||||
m_num_cells(0),
|
||||
m_cells(0),
|
||||
m_curr_cell_ptr(0),
|
||||
m_sorted_cells(),
|
||||
m_sorted_y(),
|
||||
m_min_x(0x7FFFFFFF),
|
||||
m_min_y(0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF),
|
||||
m_sorted(false)
|
||||
{
|
||||
m_style_cell.initial();
|
||||
m_curr_cell.initial();
|
||||
|
@ -174,8 +185,7 @@ AGG_INLINE void rasterizer_cells_aa<Cell>::add_curr_cell()
|
|||
{
|
||||
if((m_num_cells & cell_block_mask) == 0)
|
||||
{
|
||||
if (m_num_blocks >= cell_block_limit)
|
||||
return;
|
||||
if(m_num_blocks >= cell_block_limit) return;
|
||||
allocate_block();
|
||||
}
|
||||
*m_curr_cell_ptr++ = m_curr_cell;
|
||||
|
@ -200,7 +210,9 @@ AGG_INLINE void rasterizer_cells_aa<Cell>::set_curr_cell(int x, int y)
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Cell>
|
||||
AGG_INLINE void rasterizer_cells_aa<Cell>::render_hline(int ey, int x1, int y1, int x2, int y2)
|
||||
AGG_INLINE void rasterizer_cells_aa<Cell>::render_hline(int ey,
|
||||
int x1, int y1,
|
||||
int x2, int y2)
|
||||
{
|
||||
int ex1 = x1 >> poly_subpixel_shift;
|
||||
int ex2 = x2 >> poly_subpixel_shift;
|
||||
|
@ -315,10 +327,8 @@ void rasterizer_cells_aa<Cell>::line(int x1, int y1, int x2, int y2)
|
|||
int cy = (y1 + y2) >> 1;
|
||||
|
||||
// Bail if values are so large they are likely to wrap
|
||||
if ((std::abs(x1) >= std::numeric_limits<int>::max() / 2) ||
|
||||
(std::abs(y1) >= std::numeric_limits<int>::max() / 2) ||
|
||||
(std::abs(x2) >= std::numeric_limits<int>::max() / 2) ||
|
||||
(std::abs(y2) >= std::numeric_limits<int>::max() / 2))
|
||||
if ((std::abs(x1) >= std::numeric_limits<int>::max()/2) || (std::abs(y1) >= std::numeric_limits<int>::max()/2) ||
|
||||
(std::abs(x2) >= std::numeric_limits<int>::max()/2) || (std::abs(y2) >= std::numeric_limits<int>::max()/2))
|
||||
return;
|
||||
|
||||
line(x1, y1, cx, cy);
|
||||
|
@ -336,22 +346,14 @@ void rasterizer_cells_aa<Cell>::line(int x1, int y1, int x2, int y2)
|
|||
int x_from, x_to;
|
||||
int p, rem, mod, lift, delta, first, incr;
|
||||
|
||||
if (ex1 < m_min_x)
|
||||
m_min_x = ex1;
|
||||
if (ex1 > m_max_x)
|
||||
m_max_x = ex1;
|
||||
if (ey1 < m_min_y)
|
||||
m_min_y = ey1;
|
||||
if (ey1 > m_max_y)
|
||||
m_max_y = ey1;
|
||||
if (ex2 < m_min_x)
|
||||
m_min_x = ex2;
|
||||
if (ex2 > m_max_x)
|
||||
m_max_x = ex2;
|
||||
if (ey2 < m_min_y)
|
||||
m_min_y = ey2;
|
||||
if (ey2 > m_max_y)
|
||||
m_max_y = ey2;
|
||||
if(ex1 < m_min_x) m_min_x = ex1;
|
||||
if(ex1 > m_max_x) m_max_x = ex1;
|
||||
if(ey1 < m_min_y) m_min_y = ey1;
|
||||
if(ey1 > m_max_y) m_max_y = ey1;
|
||||
if(ex2 < m_min_x) m_min_x = ex2;
|
||||
if(ex2 > m_max_x) m_max_x = ex2;
|
||||
if(ey2 < m_min_y) m_min_y = ey2;
|
||||
if(ey2 > m_max_y) m_max_y = ey2;
|
||||
|
||||
set_curr_cell(ex1, ey1);
|
||||
|
||||
|
@ -476,7 +478,9 @@ void rasterizer_cells_aa<Cell>::allocate_block()
|
|||
{
|
||||
if(m_num_blocks >= m_max_blocks)
|
||||
{
|
||||
cell_type** new_cells = pod_allocator<cell_type*>::allocate(m_max_blocks + cell_block_pool);
|
||||
cell_type** new_cells =
|
||||
pod_allocator<cell_type*>::allocate(m_max_blocks +
|
||||
cell_block_pool);
|
||||
|
||||
if(m_cells)
|
||||
{
|
||||
|
@ -487,22 +491,30 @@ void rasterizer_cells_aa<Cell>::allocate_block()
|
|||
m_max_blocks += cell_block_pool;
|
||||
}
|
||||
|
||||
m_cells[m_num_blocks++] = pod_allocator<cell_type>::allocate(cell_block_size);
|
||||
m_cells[m_num_blocks++] =
|
||||
pod_allocator<cell_type>::allocate(cell_block_size);
|
||||
|
||||
}
|
||||
m_curr_cell_ptr = m_cells[m_curr_block++];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class T>
|
||||
static AGG_INLINE void swap_cells(T* a, T* b)
|
||||
template <class T> static AGG_INLINE void swap_cells(T* a, T* b)
|
||||
{
|
||||
T temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
enum { qsort_threshold = 9 };
|
||||
enum
|
||||
{
|
||||
qsort_threshold = 9
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Cell>
|
||||
|
@ -553,12 +565,8 @@ void qsort_cells(Cell** start, unsigned num)
|
|||
for(;;)
|
||||
{
|
||||
int x = (*base)->x;
|
||||
do
|
||||
i++;
|
||||
while ((*i)->x < x);
|
||||
do
|
||||
j--;
|
||||
while (x < (*j)->x);
|
||||
do i++; while( (*i)->x < x );
|
||||
do j--; while( x < (*j)->x );
|
||||
|
||||
if(i > j)
|
||||
{
|
||||
|
@ -617,12 +625,12 @@ void qsort_cells(Cell** start, unsigned num)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Cell>
|
||||
void rasterizer_cells_aa<Cell>::sort_cells()
|
||||
{
|
||||
if (m_sorted)
|
||||
return; // Perform sort only the first time.
|
||||
if(m_sorted) return; //Perform sort only the first time.
|
||||
|
||||
add_curr_cell();
|
||||
m_curr_cell.x = 0x7FFFFFFF;
|
||||
|
@ -630,8 +638,7 @@ void rasterizer_cells_aa<Cell>::sort_cells()
|
|||
m_curr_cell.cover = 0;
|
||||
m_curr_cell.area = 0;
|
||||
|
||||
if (m_num_cells == 0)
|
||||
return;
|
||||
if(m_num_cells == 0) return;
|
||||
|
||||
// DBG: Check to see if min/max works well.
|
||||
//for(unsigned nc = 0; nc < m_num_cells; nc++)
|
||||
|
@ -729,26 +736,23 @@ void rasterizer_cells_aa<Cell>::sort_cells()
|
|||
m_sorted = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------scanline_hit_test
|
||||
class scanline_hit_test
|
||||
{
|
||||
public:
|
||||
scanline_hit_test(int x)
|
||||
: m_x(x)
|
||||
, m_hit(false)
|
||||
{}
|
||||
scanline_hit_test(int x) : m_x(x), m_hit(false) {}
|
||||
|
||||
void reset_spans() {}
|
||||
void finalize(int) {}
|
||||
void add_cell(int x, int)
|
||||
{
|
||||
if (m_x == x)
|
||||
m_hit = true;
|
||||
if(m_x == x) m_hit = true;
|
||||
}
|
||||
void add_span(int x, int len, int)
|
||||
{
|
||||
if (m_x >= x && m_x < x + len)
|
||||
m_hit = true;
|
||||
if(m_x >= x && m_x < x+len) m_hit = true;
|
||||
}
|
||||
unsigned num_spans() const { return 1; }
|
||||
bool hit() const { return m_hit; }
|
||||
|
@ -758,6 +762,7 @@ class scanline_hit_test
|
|||
bool m_hit;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
183
deps/agg/include/agg_rasterizer_compound_aa.h
vendored
183
deps/agg/include/agg_rasterizer_compound_aa.h
vendored
|
@ -32,7 +32,8 @@
|
|||
#include "agg_rasterizer_cells_aa.h"
|
||||
#include "agg_rasterizer_sl_clip.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------cell_style_aa
|
||||
// A pixel cell. There're no constructors defined and it was done
|
||||
|
@ -68,16 +69,18 @@ struct cell_style_aa
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//===========================================================layer_order_e
|
||||
enum layer_order_e {
|
||||
enum layer_order_e
|
||||
{
|
||||
layer_unsorted, //------layer_unsorted
|
||||
layer_direct, //------layer_direct
|
||||
layer_inverse //------layer_inverse
|
||||
};
|
||||
|
||||
|
||||
//==================================================rasterizer_compound_aa
|
||||
template<class Clip = rasterizer_sl_clip_int>
|
||||
class rasterizer_compound_aa
|
||||
template<class Clip=rasterizer_sl_clip_int> class rasterizer_compound_aa
|
||||
{
|
||||
struct style_info
|
||||
{
|
||||
|
@ -96,7 +99,8 @@ class rasterizer_compound_aa
|
|||
typedef typename Clip::conv_type conv_type;
|
||||
typedef typename Clip::coord_type coord_type;
|
||||
|
||||
enum aa_scale_e {
|
||||
enum aa_scale_e
|
||||
{
|
||||
aa_shift = 8,
|
||||
aa_scale = 1 << aa_shift,
|
||||
aa_mask = aa_scale - 1,
|
||||
|
@ -105,27 +109,24 @@ class rasterizer_compound_aa
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rasterizer_compound_aa()
|
||||
: m_outline()
|
||||
, m_clipper()
|
||||
, m_filling_rule(fill_non_zero)
|
||||
, m_layer_order(layer_direct)
|
||||
, m_styles()
|
||||
, // Active Styles
|
||||
m_ast()
|
||||
, // Active Style Table (unique values)
|
||||
m_asm()
|
||||
, // Active Style Mask
|
||||
m_cells()
|
||||
, m_cover_buf()
|
||||
, m_master_alpha()
|
||||
, m_min_style(0x7FFFFFFF)
|
||||
, m_max_style(-0x7FFFFFFF)
|
||||
, m_start_x(0)
|
||||
, m_start_y(0)
|
||||
, m_scan_y(0x7FFFFFFF)
|
||||
, m_sl_start(0)
|
||||
, m_sl_len(0)
|
||||
rasterizer_compound_aa() :
|
||||
m_outline(),
|
||||
m_clipper(),
|
||||
m_filling_rule(fill_non_zero),
|
||||
m_layer_order(layer_direct),
|
||||
m_styles(), // Active Styles
|
||||
m_ast(), // Active Style Table (unique values)
|
||||
m_asm(), // Active Style Mask
|
||||
m_cells(),
|
||||
m_cover_buf(),
|
||||
m_master_alpha(),
|
||||
m_min_style(0x7FFFFFFF),
|
||||
m_max_style(-0x7FFFFFFF),
|
||||
m_start_x(0),
|
||||
m_start_y(0),
|
||||
m_scan_y(0x7FFFFFFF),
|
||||
m_sl_start(0),
|
||||
m_sl_len(0)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -156,14 +157,14 @@ class rasterizer_compound_aa
|
|||
|
||||
unsigned cmd;
|
||||
vs.rewind(path_id);
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if(m_outline.sorted()) reset();
|
||||
while(!is_stop(cmd = vs.vertex(&x, &y)))
|
||||
{
|
||||
add_vertex(x, y, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
int min_x() const { return m_outline.min_x(); }
|
||||
int min_y() const { return m_outline.min_y(); }
|
||||
|
@ -190,8 +191,7 @@ class rasterizer_compound_aa
|
|||
AGG_INLINE unsigned calculate_alpha(int area, unsigned master_alpha) const
|
||||
{
|
||||
int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift);
|
||||
if (cover < 0)
|
||||
cover = -cover;
|
||||
if(cover < 0) cover = -cover;
|
||||
if(m_filling_rule == fill_even_odd)
|
||||
{
|
||||
cover &= aa_mask2;
|
||||
|
@ -200,20 +200,17 @@ class rasterizer_compound_aa
|
|||
cover = aa_scale2 - cover;
|
||||
}
|
||||
}
|
||||
if (cover > aa_mask)
|
||||
cover = aa_mask;
|
||||
if(cover > aa_mask) cover = aa_mask;
|
||||
return (cover * master_alpha + aa_mask) >> aa_shift;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Sweeps one scanline with one style index. The style ID can be
|
||||
// determined by calling style().
|
||||
template<class Scanline>
|
||||
bool sweep_scanline(Scanline& sl, int style_idx)
|
||||
template<class Scanline> bool sweep_scanline(Scanline& sl, int style_idx)
|
||||
{
|
||||
int scan_y = m_scan_y - 1;
|
||||
if (scan_y > m_outline.max_y())
|
||||
return false;
|
||||
if(scan_y > m_outline.max_y()) return false;
|
||||
|
||||
sl.reset_spans();
|
||||
|
||||
|
@ -247,14 +244,16 @@ class rasterizer_compound_aa
|
|||
|
||||
if(area)
|
||||
{
|
||||
alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area, master_alpha);
|
||||
alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area,
|
||||
master_alpha);
|
||||
sl.add_cell(x, alpha);
|
||||
x++;
|
||||
}
|
||||
|
||||
if(num_cells && cell->x > x)
|
||||
{
|
||||
alpha = calculate_alpha(cover << (poly_subpixel_shift + 1), master_alpha);
|
||||
alpha = calculate_alpha(cover << (poly_subpixel_shift + 1),
|
||||
master_alpha);
|
||||
if(alpha)
|
||||
{
|
||||
sl.add_span(x, cell->x - x, alpha);
|
||||
|
@ -262,8 +261,7 @@ class rasterizer_compound_aa
|
|||
}
|
||||
}
|
||||
|
||||
if (sl.num_spans() == 0)
|
||||
return false;
|
||||
if(sl.num_spans() == 0) return false;
|
||||
sl.finalize(scan_y);
|
||||
return true;
|
||||
}
|
||||
|
@ -275,7 +273,8 @@ class rasterizer_compound_aa
|
|||
//--------------------------------------------------------------------
|
||||
// Disable copying
|
||||
rasterizer_compound_aa(const rasterizer_compound_aa<Clip>&);
|
||||
const rasterizer_compound_aa<Clip>& operator=(const rasterizer_compound_aa<Clip>&);
|
||||
const rasterizer_compound_aa<Clip>&
|
||||
operator = (const rasterizer_compound_aa<Clip>&);
|
||||
|
||||
private:
|
||||
rasterizer_cells_aa<cell_style_aa> m_outline;
|
||||
|
@ -298,6 +297,15 @@ class rasterizer_compound_aa
|
|||
unsigned m_sl_len;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::reset()
|
||||
|
@ -326,10 +334,12 @@ void rasterizer_compound_aa<Clip>::layer_order(layer_order_e order)
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::clip_box(double x1, double y1, double x2, double y2)
|
||||
void rasterizer_compound_aa<Clip>::clip_box(double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
reset();
|
||||
m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), conv_type::upscale(x2), conv_type::upscale(y2));
|
||||
m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1),
|
||||
conv_type::upscale(x2), conv_type::upscale(y2));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -349,46 +359,46 @@ void rasterizer_compound_aa<Clip>::styles(int left, int right)
|
|||
cell.left = (int16)left;
|
||||
cell.right = (int16)right;
|
||||
m_outline.style(cell);
|
||||
if (left >= 0 && left < m_min_style)
|
||||
m_min_style = left;
|
||||
if (left >= 0 && left > m_max_style)
|
||||
m_max_style = left;
|
||||
if (right >= 0 && right < m_min_style)
|
||||
m_min_style = right;
|
||||
if (right >= 0 && right > m_max_style)
|
||||
m_max_style = right;
|
||||
if(left >= 0 && left < m_min_style) m_min_style = left;
|
||||
if(left >= 0 && left > m_max_style) m_max_style = left;
|
||||
if(right >= 0 && right < m_min_style) m_min_style = right;
|
||||
if(right >= 0 && right > m_max_style) m_max_style = right;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::move_to(int x, int y)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
m_clipper.move_to(m_start_x = conv_type::downscale(x), m_start_y = conv_type::downscale(y));
|
||||
if(m_outline.sorted()) reset();
|
||||
m_clipper.move_to(m_start_x = conv_type::downscale(x),
|
||||
m_start_y = conv_type::downscale(y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::line_to(int x, int y)
|
||||
{
|
||||
m_clipper.line_to(m_outline, conv_type::downscale(x), conv_type::downscale(y));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::downscale(x),
|
||||
conv_type::downscale(y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::move_to_d(double x, double y)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
m_clipper.move_to(m_start_x = conv_type::upscale(x), m_start_y = conv_type::upscale(y));
|
||||
if(m_outline.sorted()) reset();
|
||||
m_clipper.move_to(m_start_x = conv_type::upscale(x),
|
||||
m_start_y = conv_type::upscale(y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::line_to_d(double x, double y)
|
||||
{
|
||||
m_clipper.line_to(m_outline, conv_type::upscale(x), conv_type::upscale(y));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::upscale(x),
|
||||
conv_type::upscale(y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -399,11 +409,13 @@ void rasterizer_compound_aa<Clip>::add_vertex(double x, double y, unsigned cmd)
|
|||
{
|
||||
move_to_d(x, y);
|
||||
}
|
||||
else if (is_vertex(cmd))
|
||||
else
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
line_to_d(x, y);
|
||||
}
|
||||
else if (is_close(cmd))
|
||||
else
|
||||
if(is_close(cmd))
|
||||
{
|
||||
m_clipper.line_to(m_outline, m_start_x, m_start_y);
|
||||
}
|
||||
|
@ -413,20 +425,23 @@ void rasterizer_compound_aa<Clip>::add_vertex(double x, double y, unsigned cmd)
|
|||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::edge(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if(m_outline.sorted()) reset();
|
||||
m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1));
|
||||
m_clipper.line_to(m_outline, conv_type::downscale(x2), conv_type::downscale(y2));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::downscale(x2),
|
||||
conv_type::downscale(y2));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_compound_aa<Clip>::edge_d(double x1, double y1, double x2, double y2)
|
||||
void rasterizer_compound_aa<Clip>::edge_d(double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if(m_outline.sorted()) reset();
|
||||
m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1));
|
||||
m_clipper.line_to(m_outline, conv_type::upscale(x2), conv_type::upscale(y2));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::upscale(x2),
|
||||
conv_type::upscale(y2));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -459,10 +474,8 @@ AGG_INLINE bool rasterizer_compound_aa<Clip>::rewind_scanlines()
|
|||
template<class Clip>
|
||||
AGG_INLINE void rasterizer_compound_aa<Clip>::add_style(int style_id)
|
||||
{
|
||||
if (style_id < 0)
|
||||
style_id = 0;
|
||||
else
|
||||
style_id -= m_min_style - 1;
|
||||
if(style_id < 0) style_id = 0;
|
||||
else style_id -= m_min_style - 1;
|
||||
|
||||
unsigned nbyte = style_id >> 3;
|
||||
unsigned mask = 1 << (style_id & 7);
|
||||
|
@ -486,8 +499,7 @@ unsigned rasterizer_compound_aa<Clip>::sweep_styles()
|
|||
{
|
||||
for(;;)
|
||||
{
|
||||
if (m_scan_y > m_outline.max_y())
|
||||
return 0;
|
||||
if(m_scan_y > m_outline.max_y()) return 0;
|
||||
unsigned num_cells = m_outline.scanline_num_cells(m_scan_y);
|
||||
const cell_style_aa* const* cells = m_outline.scanline_cells(m_scan_y);
|
||||
unsigned num_styles = m_max_style - m_min_style + 2;
|
||||
|
@ -538,7 +550,8 @@ unsigned rasterizer_compound_aa<Clip>::sweep_styles()
|
|||
while(num_cells--)
|
||||
{
|
||||
curr_cell = *cells++;
|
||||
style_id = (curr_cell->left < 0) ? 0 : curr_cell->left - m_min_style + 1;
|
||||
style_id = (curr_cell->left < 0) ? 0 :
|
||||
curr_cell->left - m_min_style + 1;
|
||||
|
||||
style = &m_styles[style_id];
|
||||
if(curr_cell->x == style->last_x)
|
||||
|
@ -557,7 +570,8 @@ unsigned rasterizer_compound_aa<Clip>::sweep_styles()
|
|||
style->num_cells++;
|
||||
}
|
||||
|
||||
style_id = (curr_cell->right < 0) ? 0 : curr_cell->right - m_min_style + 1;
|
||||
style_id = (curr_cell->right < 0) ? 0 :
|
||||
curr_cell->right - m_min_style + 1;
|
||||
|
||||
style = &m_styles[style_id];
|
||||
if(curr_cell->x == style->last_x)
|
||||
|
@ -577,8 +591,7 @@ unsigned rasterizer_compound_aa<Clip>::sweep_styles()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (m_ast.size() > 1)
|
||||
break;
|
||||
if(m_ast.size() > 1) break;
|
||||
++m_scan_y;
|
||||
}
|
||||
++m_scan_y;
|
||||
|
@ -586,10 +599,8 @@ unsigned rasterizer_compound_aa<Clip>::sweep_styles()
|
|||
if(m_layer_order != layer_unsorted)
|
||||
{
|
||||
range_adaptor<pod_vector<unsigned> > ra(m_ast, 1, m_ast.size() - 1);
|
||||
if (m_layer_order == layer_direct)
|
||||
quick_sort(ra, unsigned_greater);
|
||||
else
|
||||
quick_sort(ra, unsigned_less);
|
||||
if(m_layer_order == layer_direct) quick_sort(ra, unsigned_greater);
|
||||
else quick_sort(ra, unsigned_less);
|
||||
}
|
||||
|
||||
return m_ast.size() - 1;
|
||||
|
@ -598,7 +609,8 @@ unsigned rasterizer_compound_aa<Clip>::sweep_styles()
|
|||
//------------------------------------------------------------------------
|
||||
// Returns style ID depending of the existing style index
|
||||
template<class Clip>
|
||||
AGG_INLINE unsigned rasterizer_compound_aa<Clip>::style(unsigned style_idx) const
|
||||
AGG_INLINE
|
||||
unsigned rasterizer_compound_aa<Clip>::style(unsigned style_idx) const
|
||||
{
|
||||
return m_ast[style_idx + 1] + m_min_style - 1;
|
||||
}
|
||||
|
@ -678,6 +690,9 @@ void rasterizer_compound_aa<Clip>::master_alpha(int style, double alpha)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
47
deps/agg/include/agg_rasterizer_outline.h
vendored
47
deps/agg/include/agg_rasterizer_outline.h
vendored
|
@ -17,20 +17,21 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//======================================================rasterizer_outline
|
||||
template<class Renderer>
|
||||
class rasterizer_outline
|
||||
template<class Renderer> class rasterizer_outline
|
||||
{
|
||||
public:
|
||||
explicit rasterizer_outline(Renderer& ren)
|
||||
: m_ren(&ren)
|
||||
, m_start_x(0)
|
||||
, m_start_y(0)
|
||||
, m_vertices(0)
|
||||
explicit rasterizer_outline(Renderer& ren) :
|
||||
m_ren(&ren),
|
||||
m_start_x(0),
|
||||
m_start_y(0),
|
||||
m_vertices(0)
|
||||
{}
|
||||
void attach(Renderer& ren) { m_ren = &ren; }
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void move_to(int x, int y)
|
||||
{
|
||||
|
@ -46,10 +47,16 @@ class rasterizer_outline
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void move_to_d(double x, double y) { move_to(m_ren->coord(x), m_ren->coord(y)); }
|
||||
void move_to_d(double x, double y)
|
||||
{
|
||||
move_to(m_ren->coord(x), m_ren->coord(y));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void line_to_d(double x, double y) { line_to(m_ren->coord(x), m_ren->coord(y)); }
|
||||
void line_to_d(double x, double y)
|
||||
{
|
||||
line_to(m_ren->coord(x), m_ren->coord(y));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void close()
|
||||
|
@ -72,8 +79,7 @@ class rasterizer_outline
|
|||
{
|
||||
if(is_end_poly(cmd))
|
||||
{
|
||||
if (is_closed(cmd))
|
||||
close();
|
||||
if(is_closed(cmd)) close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -82,6 +88,7 @@ class rasterizer_outline
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class VertexSource>
|
||||
void add_path(VertexSource& vs, unsigned path_id=0)
|
||||
|
@ -97,9 +104,13 @@ class rasterizer_outline
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class VertexSource, class ColorStorage, class PathId>
|
||||
void render_all_paths(VertexSource& vs, const ColorStorage& colors, const PathId& path_id, unsigned num_paths)
|
||||
void render_all_paths(VertexSource& vs,
|
||||
const ColorStorage& colors,
|
||||
const PathId& path_id,
|
||||
unsigned num_paths)
|
||||
{
|
||||
for(unsigned i = 0; i < num_paths; i++)
|
||||
{
|
||||
|
@ -108,9 +119,9 @@ class rasterizer_outline
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Ctrl>
|
||||
void render_ctrl(Ctrl& c)
|
||||
template<class Ctrl> void render_ctrl(Ctrl& c)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < c.num_paths(); i++)
|
||||
|
@ -120,6 +131,7 @@ class rasterizer_outline
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Renderer* m_ren;
|
||||
int m_start_x;
|
||||
|
@ -127,6 +139,9 @@ class rasterizer_outline
|
|||
unsigned m_vertices;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
195
deps/agg/include/agg_rasterizer_outline_aa.h
vendored
195
deps/agg/include/agg_rasterizer_outline_aa.h
vendored
|
@ -19,17 +19,14 @@
|
|||
#include "agg_line_aa_basics.h"
|
||||
#include "agg_vertex_sequence.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
inline bool cmp_dist_start(int d)
|
||||
{
|
||||
return d > 0;
|
||||
}
|
||||
inline bool cmp_dist_end(int d)
|
||||
{
|
||||
return d <= 0;
|
||||
}
|
||||
inline bool cmp_dist_start(int d) { return d > 0; }
|
||||
inline bool cmp_dist_end(int d) { return d <= 0; }
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------line_aa_vertex
|
||||
// Vertex (x, y) with the distance to the next one. The last vertex has
|
||||
|
@ -41,22 +38,26 @@ struct line_aa_vertex
|
|||
int len;
|
||||
|
||||
line_aa_vertex() {}
|
||||
line_aa_vertex(int x_, int y_)
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
, len(0)
|
||||
{}
|
||||
line_aa_vertex(int x_, int y_) :
|
||||
x(x_),
|
||||
y(y_),
|
||||
len(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator () (const line_aa_vertex& val)
|
||||
{
|
||||
double dx = val.x - x;
|
||||
double dy = val.y - y;
|
||||
return (len = uround(sqrt(dx * dx + dy * dy))) > (line_subpixel_scale + line_subpixel_scale / 2);
|
||||
return (len = uround(sqrt(dx * dx + dy * dy))) >
|
||||
(line_subpixel_scale + line_subpixel_scale / 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------outline_aa_join_e
|
||||
enum outline_aa_join_e {
|
||||
enum outline_aa_join_e
|
||||
{
|
||||
outline_no_join, //-----outline_no_join
|
||||
outline_miter_join, //-----outline_miter_join
|
||||
outline_round_join, //-----outline_round_join
|
||||
|
@ -64,8 +65,7 @@ enum outline_aa_join_e {
|
|||
};
|
||||
|
||||
//=======================================================rasterizer_outline_aa
|
||||
template<class Renderer, class Coord = line_coord>
|
||||
class rasterizer_outline_aa
|
||||
template<class Renderer, class Coord=line_coord> class rasterizer_outline_aa
|
||||
{
|
||||
private:
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -85,19 +85,23 @@ class rasterizer_outline_aa
|
|||
typedef line_aa_vertex vertex_type;
|
||||
typedef vertex_sequence<vertex_type, 6> vertex_storage_type;
|
||||
|
||||
explicit rasterizer_outline_aa(Renderer& ren)
|
||||
: m_ren(&ren)
|
||||
, m_line_join(ren.accurate_join_only() ? outline_miter_accurate_join : outline_round_join)
|
||||
, m_round_cap(false)
|
||||
, m_start_x(0)
|
||||
, m_start_y(0)
|
||||
explicit rasterizer_outline_aa(Renderer& ren) :
|
||||
m_ren(&ren),
|
||||
m_line_join(ren.accurate_join_only() ?
|
||||
outline_miter_accurate_join :
|
||||
outline_round_join),
|
||||
m_round_cap(false),
|
||||
m_start_x(0),
|
||||
m_start_y(0)
|
||||
{}
|
||||
void attach(Renderer& ren) { m_ren = &ren; }
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void line_join(outline_aa_join_e join)
|
||||
{
|
||||
m_line_join = m_ren->accurate_join_only() ? outline_miter_accurate_join : join;
|
||||
m_line_join = m_ren->accurate_join_only() ?
|
||||
outline_miter_accurate_join :
|
||||
join;
|
||||
}
|
||||
bool line_join() const { return m_line_join; }
|
||||
|
||||
|
@ -106,16 +110,28 @@ class rasterizer_outline_aa
|
|||
bool round_cap() const { return m_round_cap; }
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void move_to(int x, int y) { m_src_vertices.modify_last(vertex_type(m_start_x = x, m_start_y = y)); }
|
||||
void move_to(int x, int y)
|
||||
{
|
||||
m_src_vertices.modify_last(vertex_type(m_start_x = x, m_start_y = y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void line_to(int x, int y) { m_src_vertices.add(vertex_type(x, y)); }
|
||||
void line_to(int x, int y)
|
||||
{
|
||||
m_src_vertices.add(vertex_type(x, y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void move_to_d(double x, double y) { move_to(Coord::conv(x), Coord::conv(y)); }
|
||||
void move_to_d(double x, double y)
|
||||
{
|
||||
move_to(Coord::conv(x), Coord::conv(y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void line_to_d(double x, double y) { line_to(Coord::conv(x), Coord::conv(y)); }
|
||||
void line_to_d(double x, double y)
|
||||
{
|
||||
line_to(Coord::conv(x), Coord::conv(y));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void render(bool close_polygon);
|
||||
|
@ -161,9 +177,13 @@ class rasterizer_outline_aa
|
|||
render(false);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class VertexSource, class ColorStorage, class PathId>
|
||||
void render_all_paths(VertexSource& vs, const ColorStorage& colors, const PathId& path_id, unsigned num_paths)
|
||||
void render_all_paths(VertexSource& vs,
|
||||
const ColorStorage& colors,
|
||||
const PathId& path_id,
|
||||
unsigned num_paths)
|
||||
{
|
||||
for(unsigned i = 0; i < num_paths; i++)
|
||||
{
|
||||
|
@ -172,9 +192,9 @@ class rasterizer_outline_aa
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Ctrl>
|
||||
void render_ctrl(Ctrl& c)
|
||||
template<class Ctrl> void render_ctrl(Ctrl& c)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < c.num_paths(); i++)
|
||||
|
@ -186,7 +206,8 @@ class rasterizer_outline_aa
|
|||
|
||||
private:
|
||||
rasterizer_outline_aa(const rasterizer_outline_aa<Renderer, Coord>&);
|
||||
const rasterizer_outline_aa<Renderer, Coord>& operator=(const rasterizer_outline_aa<Renderer, Coord>&);
|
||||
const rasterizer_outline_aa<Renderer, Coord>& operator =
|
||||
(const rasterizer_outline_aa<Renderer, Coord>&);
|
||||
|
||||
Renderer* m_ren;
|
||||
vertex_storage_type m_src_vertices;
|
||||
|
@ -196,9 +217,18 @@ class rasterizer_outline_aa
|
|||
int m_start_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template<class Renderer, class Coord>
|
||||
void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv, unsigned start, unsigned end)
|
||||
void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv,
|
||||
unsigned start,
|
||||
unsigned end)
|
||||
{
|
||||
unsigned i;
|
||||
const vertex_storage_type::value_type* v;
|
||||
|
@ -215,24 +245,15 @@ void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv, unsigned start,
|
|||
|
||||
switch(dv.flags)
|
||||
{
|
||||
case 0:
|
||||
m_ren->line3(dv.curr, dv.xb1, dv.yb1, dv.xb2, dv.yb2);
|
||||
break;
|
||||
case 1:
|
||||
m_ren->line2(dv.curr, dv.xb2, dv.yb2);
|
||||
break;
|
||||
case 2:
|
||||
m_ren->line1(dv.curr, dv.xb1, dv.yb1);
|
||||
break;
|
||||
case 3:
|
||||
m_ren->line0(dv.curr);
|
||||
break;
|
||||
case 0: m_ren->line3(dv.curr, dv.xb1, dv.yb1, dv.xb2, dv.yb2); break;
|
||||
case 1: m_ren->line2(dv.curr, dv.xb2, dv.yb2); break;
|
||||
case 2: m_ren->line1(dv.curr, dv.xb1, dv.yb1); break;
|
||||
case 3: m_ren->line0(dv.curr); break;
|
||||
}
|
||||
|
||||
if(m_line_join == outline_round_join && (dv.flags & 2) == 0)
|
||||
{
|
||||
m_ren->pie(dv.curr.x2,
|
||||
dv.curr.y2,
|
||||
m_ren->pie(dv.curr.x2, dv.curr.y2,
|
||||
dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
|
||||
dv.curr.y2 - (dv.curr.x2 - dv.curr.x1),
|
||||
dv.curr.x2 + (dv.next.y2 - dv.next.y1),
|
||||
|
@ -245,8 +266,7 @@ void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv, unsigned start,
|
|||
dv.lnext = m_src_vertices[dv.idx].len;
|
||||
|
||||
++dv.idx;
|
||||
if (dv.idx >= m_src_vertices.size())
|
||||
dv.idx = 0;
|
||||
if(dv.idx >= m_src_vertices.size()) dv.idx = 0;
|
||||
|
||||
v = &m_src_vertices[dv.idx];
|
||||
dv.x2 = v->x;
|
||||
|
@ -265,7 +285,8 @@ void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv, unsigned start,
|
|||
|
||||
case outline_miter_join:
|
||||
dv.flags >>= 1;
|
||||
dv.flags |= ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
|
||||
dv.flags |= ((dv.curr.diagonal_quadrant() ==
|
||||
dv.next.diagonal_quadrant()) << 1);
|
||||
if((dv.flags & 2) == 0)
|
||||
{
|
||||
bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2);
|
||||
|
@ -274,7 +295,8 @@ void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv, unsigned start,
|
|||
|
||||
case outline_round_join:
|
||||
dv.flags >>= 1;
|
||||
dv.flags |= ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
|
||||
dv.flags |= ((dv.curr.diagonal_quadrant() ==
|
||||
dv.next.diagonal_quadrant()) << 1);
|
||||
break;
|
||||
|
||||
case outline_miter_accurate_join:
|
||||
|
@ -285,6 +307,9 @@ void rasterizer_outline_aa<Renderer, Coord>::draw(draw_vars& dv, unsigned start,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
template<class Renderer, class Coord>
|
||||
void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
||||
|
@ -337,7 +362,8 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
|
||||
case outline_miter_join:
|
||||
case outline_round_join:
|
||||
dv.flags = (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
|
||||
dv.flags =
|
||||
(prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
|
||||
((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
|
||||
break;
|
||||
|
||||
|
@ -365,7 +391,8 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
case 1:
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
case 2:
|
||||
{
|
||||
v = &m_src_vertices[0];
|
||||
x1 = v->x;
|
||||
y1 = v->y;
|
||||
|
@ -378,7 +405,11 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
{
|
||||
m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1));
|
||||
}
|
||||
m_ren->line3(lp, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1));
|
||||
m_ren->line3(lp,
|
||||
x1 + (y2 - y1),
|
||||
y1 - (x2 - x1),
|
||||
x2 + (y2 - y1),
|
||||
y2 - (x2 - x1));
|
||||
if(m_round_cap)
|
||||
{
|
||||
m_ren->semidot(cmp_dist_end, x2, y2, x2 + (y2 - y1), y2 - (x2 - x1));
|
||||
|
@ -386,7 +417,8 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
}
|
||||
break;
|
||||
|
||||
case 3: {
|
||||
case 3:
|
||||
{
|
||||
int x3, y3;
|
||||
int lnext;
|
||||
v = &m_src_vertices[0];
|
||||
|
@ -410,18 +442,23 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
|
||||
if(m_line_join == outline_round_join)
|
||||
{
|
||||
m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1));
|
||||
m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1),
|
||||
x2 + (y2 - y1), y2 - (x2 - x1));
|
||||
|
||||
m_ren->pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1), x2 + (y3 - y2), y2 - (x3 - x2));
|
||||
m_ren->pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1),
|
||||
x2 + (y3 - y2), y2 - (x3 - x2));
|
||||
|
||||
m_ren->line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2), x3 + (y3 - y2), y3 - (x3 - x2));
|
||||
m_ren->line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2),
|
||||
x3 + (y3 - y2), y3 - (x3 - x2));
|
||||
}
|
||||
else
|
||||
{
|
||||
bisectrix(lp1, lp2, &dv.xb1, &dv.yb1);
|
||||
m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), dv.xb1, dv.yb1);
|
||||
m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1),
|
||||
dv.xb1, dv.yb1);
|
||||
|
||||
m_ren->line3(lp2, dv.xb1, dv.yb1, x3 + (y3 - y2), y3 - (x3 - x2));
|
||||
m_ren->line3(lp2, dv.xb1, dv.yb1,
|
||||
x3 + (y3 - y2), y3 - (x3 - x2));
|
||||
}
|
||||
if(m_round_cap)
|
||||
{
|
||||
|
@ -430,7 +467,8 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
dv.idx = 3;
|
||||
|
||||
v = &m_src_vertices[0];
|
||||
|
@ -468,7 +506,8 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
|
||||
case outline_miter_join:
|
||||
case outline_round_join:
|
||||
dv.flags = (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
|
||||
dv.flags =
|
||||
(prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
|
||||
((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
|
||||
break;
|
||||
|
||||
|
@ -485,23 +524,25 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
{
|
||||
if(m_line_join == outline_round_join)
|
||||
{
|
||||
m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1));
|
||||
m_ren->pie(prev.x2,
|
||||
prev.y2,
|
||||
x2 + (y2 - y1),
|
||||
y2 - (x2 - x1),
|
||||
m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1),
|
||||
x2 + (y2 - y1), y2 - (x2 - x1));
|
||||
m_ren->pie(prev.x2, prev.y2,
|
||||
x2 + (y2 - y1), y2 - (x2 - x1),
|
||||
dv.curr.x1 + (dv.curr.y2 - dv.curr.y1),
|
||||
dv.curr.y1 - (dv.curr.x2 - dv.curr.x1));
|
||||
}
|
||||
else
|
||||
{
|
||||
bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1);
|
||||
m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), dv.xb1, dv.yb1);
|
||||
m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1),
|
||||
dv.xb1, dv.yb1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ren->line1(prev, x1 + (y2 - y1), y1 - (x2 - x1));
|
||||
m_ren->line1(prev,
|
||||
x1 + (y2 - y1),
|
||||
y1 - (x2 - x1));
|
||||
}
|
||||
if((dv.flags & 2) == 0 && m_line_join != outline_round_join)
|
||||
{
|
||||
|
@ -522,9 +563,7 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_ren->line3(dv.curr,
|
||||
dv.xb1,
|
||||
dv.yb1,
|
||||
m_ren->line3(dv.curr, dv.xb1, dv.yb1,
|
||||
dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
|
||||
dv.curr.y2 - (dv.curr.x2 - dv.curr.x1));
|
||||
}
|
||||
|
@ -537,12 +576,11 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
}
|
||||
if(m_round_cap)
|
||||
{
|
||||
m_ren->semidot(cmp_dist_end,
|
||||
dv.curr.x2,
|
||||
dv.curr.y2,
|
||||
m_ren->semidot(cmp_dist_end, dv.curr.x2, dv.curr.y2,
|
||||
dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
|
||||
dv.curr.y2 - (dv.curr.x2 - dv.curr.x1));
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -550,6 +588,9 @@ void rasterizer_outline_aa<Renderer, Coord>::render(bool close_polygon)
|
|||
m_src_vertices.remove_all();
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
182
deps/agg/include/agg_rasterizer_scanline_aa.h
vendored
182
deps/agg/include/agg_rasterizer_scanline_aa.h
vendored
|
@ -33,7 +33,10 @@
|
|||
#include "agg_rasterizer_sl_clip.h"
|
||||
#include "agg_gamma_functions.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
|
||||
//-----------------------------------------------------------------cell_aa
|
||||
// A pixel cell. There're no constructors defined and it was done
|
||||
|
@ -56,9 +59,13 @@ struct cell_aa
|
|||
|
||||
void style(const cell_aa&) {}
|
||||
|
||||
int not_equal(int ex, int ey, const cell_aa&) const { return (ex - x) | (ey - y); }
|
||||
int not_equal(int ex, int ey, const cell_aa&) const
|
||||
{
|
||||
return (ex - x) | (ey - y);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//==================================================rasterizer_scanline_aa
|
||||
// Polygon rasterizer that is used to render filled polygons with
|
||||
// high-quality Anti-Aliasing. Internally, by default, the class uses
|
||||
|
@ -90,17 +97,23 @@ struct cell_aa
|
|||
//
|
||||
// filling_rule() and gamma() can be called anytime before "sweeping".
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip = rasterizer_sl_clip_int>
|
||||
class rasterizer_scanline_aa
|
||||
template<class Clip=rasterizer_sl_clip_int> class rasterizer_scanline_aa
|
||||
{
|
||||
enum status { status_initial, status_move_to, status_line_to, status_closed };
|
||||
enum status
|
||||
{
|
||||
status_initial,
|
||||
status_move_to,
|
||||
status_line_to,
|
||||
status_closed
|
||||
};
|
||||
|
||||
public:
|
||||
typedef Clip clip_type;
|
||||
typedef typename Clip::conv_type conv_type;
|
||||
typedef typename Clip::coord_type coord_type;
|
||||
|
||||
enum aa_scale_e {
|
||||
enum aa_scale_e
|
||||
{
|
||||
aa_shift = 8,
|
||||
aa_scale = 1 << aa_shift,
|
||||
aa_mask = aa_scale - 1,
|
||||
|
@ -109,30 +122,29 @@ class rasterizer_scanline_aa
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rasterizer_scanline_aa()
|
||||
: m_outline()
|
||||
, m_clipper()
|
||||
, m_filling_rule(fill_non_zero)
|
||||
, m_auto_close(true)
|
||||
, m_start_x(0)
|
||||
, m_start_y(0)
|
||||
, m_status(status_initial)
|
||||
rasterizer_scanline_aa() :
|
||||
m_outline(),
|
||||
m_clipper(),
|
||||
m_filling_rule(fill_non_zero),
|
||||
m_auto_close(true),
|
||||
m_start_x(0),
|
||||
m_start_y(0),
|
||||
m_status(status_initial)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < aa_scale; i++)
|
||||
m_gamma[i] = i;
|
||||
for(i = 0; i < aa_scale; i++) m_gamma[i] = i;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class GammaF>
|
||||
rasterizer_scanline_aa(const GammaF& gamma_function)
|
||||
: m_outline()
|
||||
, m_clipper(m_outline)
|
||||
, m_filling_rule(fill_non_zero)
|
||||
, m_auto_close(true)
|
||||
, m_start_x(0)
|
||||
, m_start_y(0)
|
||||
, m_status(status_initial)
|
||||
rasterizer_scanline_aa(const GammaF& gamma_function) :
|
||||
m_outline(),
|
||||
m_clipper(m_outline),
|
||||
m_filling_rule(fill_non_zero),
|
||||
m_auto_close(true),
|
||||
m_start_x(0),
|
||||
m_start_y(0),
|
||||
m_status(status_initial)
|
||||
{
|
||||
gamma(gamma_function);
|
||||
}
|
||||
|
@ -145,8 +157,7 @@ class rasterizer_scanline_aa
|
|||
void auto_close(bool flag) { m_auto_close = flag; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class GammaF>
|
||||
void gamma(const GammaF& gamma_function)
|
||||
template<class GammaF> void gamma(const GammaF& gamma_function)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < aa_scale; i++)
|
||||
|
@ -156,7 +167,10 @@ class rasterizer_scanline_aa
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned apply_gamma(unsigned cover) const { return m_gamma[cover]; }
|
||||
unsigned apply_gamma(unsigned cover) const
|
||||
{
|
||||
return m_gamma[cover];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void move_to(int x, int y);
|
||||
|
@ -178,8 +192,7 @@ class rasterizer_scanline_aa
|
|||
|
||||
unsigned cmd;
|
||||
vs.rewind(path_id);
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if(m_outline.sorted()) reset();
|
||||
while(!is_stop(cmd = vs.vertex(&x, &y)))
|
||||
{
|
||||
add_vertex(x, y, cmd);
|
||||
|
@ -202,8 +215,7 @@ class rasterizer_scanline_aa
|
|||
{
|
||||
int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift);
|
||||
|
||||
if (cover < 0)
|
||||
cover = -cover;
|
||||
if(cover < 0) cover = -cover;
|
||||
if(m_filling_rule == fill_even_odd)
|
||||
{
|
||||
cover &= aa_mask2;
|
||||
|
@ -212,19 +224,16 @@ class rasterizer_scanline_aa
|
|||
cover = aa_scale2 - cover;
|
||||
}
|
||||
}
|
||||
if (cover > aa_mask)
|
||||
cover = aa_mask;
|
||||
if(cover > aa_mask) cover = aa_mask;
|
||||
return m_gamma[cover];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
bool sweep_scanline(Scanline& sl)
|
||||
template<class Scanline> bool sweep_scanline(Scanline& sl)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if (m_scan_y > m_outline.max_y())
|
||||
return false;
|
||||
if(m_scan_y > m_outline.max_y()) return false;
|
||||
sl.reset_spans();
|
||||
unsigned num_cells = m_outline.scanline_num_cells(m_scan_y);
|
||||
const cell_aa* const* cells = m_outline.scanline_cells(m_scan_y);
|
||||
|
@ -243,8 +252,7 @@ class rasterizer_scanline_aa
|
|||
while(--num_cells)
|
||||
{
|
||||
cur_cell = *++cells;
|
||||
if (cur_cell->x != x)
|
||||
break;
|
||||
if(cur_cell->x != x) break;
|
||||
area += cur_cell->area;
|
||||
cover += cur_cell->cover;
|
||||
}
|
||||
|
@ -269,8 +277,7 @@ class rasterizer_scanline_aa
|
|||
}
|
||||
}
|
||||
|
||||
if (sl.num_spans())
|
||||
break;
|
||||
if(sl.num_spans()) break;
|
||||
++m_scan_y;
|
||||
}
|
||||
|
||||
|
@ -282,11 +289,13 @@ class rasterizer_scanline_aa
|
|||
//--------------------------------------------------------------------
|
||||
bool hit_test(int tx, int ty);
|
||||
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
// Disable copying
|
||||
rasterizer_scanline_aa(const rasterizer_scanline_aa<Clip>&);
|
||||
const rasterizer_scanline_aa<Clip>& operator=(const rasterizer_scanline_aa<Clip>&);
|
||||
const rasterizer_scanline_aa<Clip>&
|
||||
operator = (const rasterizer_scanline_aa<Clip>&);
|
||||
|
||||
private:
|
||||
rasterizer_cells_aa<cell_aa> m_outline;
|
||||
|
@ -300,6 +309,17 @@ class rasterizer_scanline_aa
|
|||
int m_scan_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::reset()
|
||||
|
@ -317,10 +337,12 @@ void rasterizer_scanline_aa<Clip>::filling_rule(filling_rule_e filling_rule)
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::clip_box(double x1, double y1, double x2, double y2)
|
||||
void rasterizer_scanline_aa<Clip>::clip_box(double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
reset();
|
||||
m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), conv_type::upscale(x2), conv_type::upscale(y2));
|
||||
m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1),
|
||||
conv_type::upscale(x2), conv_type::upscale(y2));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -346,11 +368,10 @@ void rasterizer_scanline_aa<Clip>::close_polygon()
|
|||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::move_to(int x, int y)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if (m_auto_close)
|
||||
close_polygon();
|
||||
m_clipper.move_to(m_start_x = conv_type::downscale(x), m_start_y = conv_type::downscale(y));
|
||||
if(m_outline.sorted()) reset();
|
||||
if(m_auto_close) close_polygon();
|
||||
m_clipper.move_to(m_start_x = conv_type::downscale(x),
|
||||
m_start_y = conv_type::downscale(y));
|
||||
m_status = status_move_to;
|
||||
}
|
||||
|
||||
|
@ -358,7 +379,9 @@ void rasterizer_scanline_aa<Clip>::move_to(int x, int y)
|
|||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::line_to(int x, int y)
|
||||
{
|
||||
m_clipper.line_to(m_outline, conv_type::downscale(x), conv_type::downscale(y));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::downscale(x),
|
||||
conv_type::downscale(y));
|
||||
m_status = status_line_to;
|
||||
}
|
||||
|
||||
|
@ -366,11 +389,10 @@ void rasterizer_scanline_aa<Clip>::line_to(int x, int y)
|
|||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::move_to_d(double x, double y)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if (m_auto_close)
|
||||
close_polygon();
|
||||
m_clipper.move_to(m_start_x = conv_type::upscale(x), m_start_y = conv_type::upscale(y));
|
||||
if(m_outline.sorted()) reset();
|
||||
if(m_auto_close) close_polygon();
|
||||
m_clipper.move_to(m_start_x = conv_type::upscale(x),
|
||||
m_start_y = conv_type::upscale(y));
|
||||
m_status = status_move_to;
|
||||
}
|
||||
|
||||
|
@ -378,7 +400,9 @@ void rasterizer_scanline_aa<Clip>::move_to_d(double x, double y)
|
|||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::line_to_d(double x, double y)
|
||||
{
|
||||
m_clipper.line_to(m_outline, conv_type::upscale(x), conv_type::upscale(y));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::upscale(x),
|
||||
conv_type::upscale(y));
|
||||
m_status = status_line_to;
|
||||
}
|
||||
|
||||
|
@ -390,11 +414,13 @@ void rasterizer_scanline_aa<Clip>::add_vertex(double x, double y, unsigned cmd)
|
|||
{
|
||||
move_to_d(x, y);
|
||||
}
|
||||
else if (is_vertex(cmd))
|
||||
else
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
line_to_d(x, y);
|
||||
}
|
||||
else if (is_close(cmd))
|
||||
else
|
||||
if(is_close(cmd))
|
||||
{
|
||||
close_polygon();
|
||||
}
|
||||
|
@ -404,21 +430,24 @@ void rasterizer_scanline_aa<Clip>::add_vertex(double x, double y, unsigned cmd)
|
|||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::edge(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if(m_outline.sorted()) reset();
|
||||
m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1));
|
||||
m_clipper.line_to(m_outline, conv_type::downscale(x2), conv_type::downscale(y2));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::downscale(x2),
|
||||
conv_type::downscale(y2));
|
||||
m_status = status_move_to;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::edge_d(double x1, double y1, double x2, double y2)
|
||||
void rasterizer_scanline_aa<Clip>::edge_d(double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
if (m_outline.sorted())
|
||||
reset();
|
||||
if(m_outline.sorted()) reset();
|
||||
m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1));
|
||||
m_clipper.line_to(m_outline, conv_type::upscale(x2), conv_type::upscale(y2));
|
||||
m_clipper.line_to(m_outline,
|
||||
conv_type::upscale(x2),
|
||||
conv_type::upscale(y2));
|
||||
m_status = status_move_to;
|
||||
}
|
||||
|
||||
|
@ -426,8 +455,7 @@ void rasterizer_scanline_aa<Clip>::edge_d(double x1, double y1, double x2, doubl
|
|||
template<class Clip>
|
||||
void rasterizer_scanline_aa<Clip>::sort()
|
||||
{
|
||||
if (m_auto_close)
|
||||
close_polygon();
|
||||
if(m_auto_close) close_polygon();
|
||||
m_outline.sort_cells();
|
||||
}
|
||||
|
||||
|
@ -435,8 +463,7 @@ void rasterizer_scanline_aa<Clip>::sort()
|
|||
template<class Clip>
|
||||
AGG_INLINE bool rasterizer_scanline_aa<Clip>::rewind_scanlines()
|
||||
{
|
||||
if (m_auto_close)
|
||||
close_polygon();
|
||||
if(m_auto_close) close_polygon();
|
||||
m_outline.sort_cells();
|
||||
if(m_outline.total_cells() == 0)
|
||||
{
|
||||
|
@ -446,14 +473,16 @@ AGG_INLINE bool rasterizer_scanline_aa<Clip>::rewind_scanlines()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template<class Clip>
|
||||
AGG_INLINE bool rasterizer_scanline_aa<Clip>::navigate_scanline(int y)
|
||||
{
|
||||
if (m_auto_close)
|
||||
close_polygon();
|
||||
if(m_auto_close) close_polygon();
|
||||
m_outline.sort_cells();
|
||||
if (m_outline.total_cells() == 0 || y < m_outline.min_y() || y > m_outline.max_y())
|
||||
if(m_outline.total_cells() == 0 ||
|
||||
y < m_outline.min_y() ||
|
||||
y > m_outline.max_y())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -465,13 +494,16 @@ AGG_INLINE bool rasterizer_scanline_aa<Clip>::navigate_scanline(int y)
|
|||
template<class Clip>
|
||||
bool rasterizer_scanline_aa<Clip>::hit_test(int tx, int ty)
|
||||
{
|
||||
if (!navigate_scanline(ty))
|
||||
return false;
|
||||
if(!navigate_scanline(ty)) return false;
|
||||
scanline_hit_test sl(tx);
|
||||
sweep_scanline(sl);
|
||||
return sl.hit();
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
86
deps/agg/include/agg_rasterizer_sl_clip.h
vendored
86
deps/agg/include/agg_rasterizer_sl_clip.h
vendored
|
@ -17,9 +17,11 @@
|
|||
|
||||
#include "agg_clip_liang_barsky.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//--------------------------------------------------------poly_max_coord_e
|
||||
enum poly_max_coord_e {
|
||||
enum poly_max_coord_e
|
||||
{
|
||||
poly_max_coord = (1 << 30) - 1 //----poly_max_coord
|
||||
};
|
||||
|
||||
|
@ -27,7 +29,10 @@ enum poly_max_coord_e {
|
|||
struct ras_conv_int
|
||||
{
|
||||
typedef int coord_type;
|
||||
static AGG_INLINE int mul_div(double a, double b, double c) { return iround(a * b / c); }
|
||||
static AGG_INLINE int mul_div(double a, double b, double c)
|
||||
{
|
||||
return iround(a * b / c);
|
||||
}
|
||||
static int xi(int v) { return v; }
|
||||
static int yi(int v) { return v; }
|
||||
static int upscale(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); }
|
||||
|
@ -55,7 +60,10 @@ struct ras_conv_int_sat
|
|||
struct ras_conv_int_3x
|
||||
{
|
||||
typedef int coord_type;
|
||||
static AGG_INLINE int mul_div(double a, double b, double c) { return iround(a * b / c); }
|
||||
static AGG_INLINE int mul_div(double a, double b, double c)
|
||||
{
|
||||
return iround(a * b / c);
|
||||
}
|
||||
static int xi(int v) { return v * 3; }
|
||||
static int yi(int v) { return v; }
|
||||
static int upscale(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); }
|
||||
|
@ -66,7 +74,10 @@ struct ras_conv_int_3x
|
|||
struct ras_conv_dbl
|
||||
{
|
||||
typedef double coord_type;
|
||||
static AGG_INLINE double mul_div(double a, double b, double c) { return a * b / c; }
|
||||
static AGG_INLINE double mul_div(double a, double b, double c)
|
||||
{
|
||||
return a * b / c;
|
||||
}
|
||||
static int xi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); }
|
||||
static int yi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); }
|
||||
static double upscale(double v) { return v; }
|
||||
|
@ -77,16 +88,22 @@ struct ras_conv_dbl
|
|||
struct ras_conv_dbl_3x
|
||||
{
|
||||
typedef double coord_type;
|
||||
static AGG_INLINE double mul_div(double a, double b, double c) { return a * b / c; }
|
||||
static AGG_INLINE double mul_div(double a, double b, double c)
|
||||
{
|
||||
return a * b / c;
|
||||
}
|
||||
static int xi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale) * 3); }
|
||||
static int yi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); }
|
||||
static double upscale(double v) { return v; }
|
||||
static double downscale(int v) { return v / static_cast<double>(poly_subpixel_scale); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------rasterizer_sl_clip
|
||||
template<class Conv>
|
||||
class rasterizer_sl_clip
|
||||
template<class Conv> class rasterizer_sl_clip
|
||||
{
|
||||
public:
|
||||
typedef Conv conv_type;
|
||||
|
@ -94,16 +111,19 @@ class rasterizer_sl_clip
|
|||
typedef rect_base<coord_type> rect_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
rasterizer_sl_clip()
|
||||
: m_clip_box(0, 0, 0, 0)
|
||||
, m_x1(0)
|
||||
, m_y1(0)
|
||||
, m_f1(0)
|
||||
, m_clipping(false)
|
||||
rasterizer_sl_clip() :
|
||||
m_clip_box(0,0,0,0),
|
||||
m_x1(0),
|
||||
m_y1(0),
|
||||
m_f1(0),
|
||||
m_clipping(false)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_clipping() { m_clipping = false; }
|
||||
void reset_clipping()
|
||||
{
|
||||
m_clipping = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void clip_box(coord_type x1, coord_type y1, coord_type x2, coord_type y2)
|
||||
|
@ -118,16 +138,16 @@ class rasterizer_sl_clip
|
|||
{
|
||||
m_x1 = x1;
|
||||
m_y1 = y1;
|
||||
if (m_clipping)
|
||||
m_f1 = clipping_flags(x1, y1, m_clip_box);
|
||||
if(m_clipping) m_f1 = clipping_flags(x1, y1, m_clip_box);
|
||||
}
|
||||
|
||||
private:
|
||||
//------------------------------------------------------------------------
|
||||
template<class Rasterizer>
|
||||
AGG_INLINE void
|
||||
line_clip_y(Rasterizer& ras, coord_type x1, coord_type y1, coord_type x2, coord_type y2, unsigned f1, unsigned f2)
|
||||
const
|
||||
AGG_INLINE void line_clip_y(Rasterizer& ras,
|
||||
coord_type x1, coord_type y1,
|
||||
coord_type x2, coord_type y2,
|
||||
unsigned f1, unsigned f2) const
|
||||
{
|
||||
f1 &= 10;
|
||||
f2 &= 10;
|
||||
|
@ -172,10 +192,12 @@ class rasterizer_sl_clip
|
|||
tx2 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1);
|
||||
ty2 = m_clip_box.y2;
|
||||
}
|
||||
ras.line(Conv::xi(tx1), Conv::yi(ty1), Conv::xi(tx2), Conv::yi(ty2));
|
||||
ras.line(Conv::xi(tx1), Conv::yi(ty1),
|
||||
Conv::xi(tx2), Conv::yi(ty2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
template<class Rasterizer>
|
||||
|
@ -266,12 +288,14 @@ class rasterizer_sl_clip
|
|||
}
|
||||
else
|
||||
{
|
||||
ras.line(Conv::xi(m_x1), Conv::yi(m_y1), Conv::xi(x2), Conv::yi(y2));
|
||||
ras.line(Conv::xi(m_x1), Conv::yi(m_y1),
|
||||
Conv::xi(x2), Conv::yi(y2));
|
||||
}
|
||||
m_x1 = x2;
|
||||
m_y1 = y2;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
rect_type m_clip_box;
|
||||
coord_type m_x1;
|
||||
|
@ -280,6 +304,9 @@ class rasterizer_sl_clip
|
|||
bool m_clipping;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------rasterizer_sl_no_clip
|
||||
class rasterizer_sl_no_clip
|
||||
{
|
||||
|
@ -287,18 +314,11 @@ class rasterizer_sl_no_clip
|
|||
typedef ras_conv_int conv_type;
|
||||
typedef int coord_type;
|
||||
|
||||
rasterizer_sl_no_clip()
|
||||
: m_x1(0)
|
||||
, m_y1(0)
|
||||
{}
|
||||
rasterizer_sl_no_clip() : m_x1(0), m_y1(0) {}
|
||||
|
||||
void reset_clipping() {}
|
||||
void clip_box(coord_type /*x1*/, coord_type /*y1*/, coord_type /*x2*/, coord_type /*y2*/) {}
|
||||
void move_to(coord_type x1, coord_type y1)
|
||||
{
|
||||
m_x1 = x1;
|
||||
m_y1 = y1;
|
||||
}
|
||||
void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; }
|
||||
|
||||
template<class Rasterizer>
|
||||
void line_to(Rasterizer& ras, coord_type x2, coord_type y2)
|
||||
|
@ -312,6 +332,7 @@ class rasterizer_sl_no_clip
|
|||
int m_x1, m_y1;
|
||||
};
|
||||
|
||||
|
||||
// -----rasterizer_sl_clip_int
|
||||
// -----rasterizer_sl_clip_int_sat
|
||||
// -----rasterizer_sl_clip_int_3x
|
||||
|
@ -324,6 +345,7 @@ typedef rasterizer_sl_clip<ras_conv_int_3x> rasterizer_sl_clip_int_3x;
|
|||
typedef rasterizer_sl_clip<ras_conv_dbl> rasterizer_sl_clip_dbl;
|
||||
typedef rasterizer_sl_clip<ras_conv_dbl_3x> rasterizer_sl_clip_dbl_3x;
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
311
deps/agg/include/agg_renderer_base.h
vendored
311
deps/agg/include/agg_renderer_base.h
vendored
|
@ -23,11 +23,11 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------renderer_base
|
||||
template<class PixelFormat>
|
||||
class renderer_base
|
||||
template<class PixelFormat> class renderer_base
|
||||
{
|
||||
public:
|
||||
typedef PixelFormat pixfmt_type;
|
||||
|
@ -36,13 +36,10 @@ class renderer_base
|
|||
typedef typename pixfmt_type::row_data row_data;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_base()
|
||||
: m_ren(0)
|
||||
, m_clip_box(1, 1, 0, 0)
|
||||
{}
|
||||
explicit renderer_base(pixfmt_type& ren)
|
||||
: m_ren(&ren)
|
||||
, m_clip_box(0, 0, ren.width() - 1, ren.height() - 1)
|
||||
renderer_base() : m_ren(0), m_clip_box(1, 1, 0, 0) {}
|
||||
explicit renderer_base(pixfmt_type& ren) :
|
||||
m_ren(&ren),
|
||||
m_clip_box(0, 0, ren.width() - 1, ren.height() - 1)
|
||||
{}
|
||||
void attach(pixfmt_type& ren)
|
||||
{
|
||||
|
@ -106,7 +103,8 @@ class renderer_base
|
|||
//--------------------------------------------------------------------
|
||||
bool inbox(int x, int y) const
|
||||
{
|
||||
return x >= m_clip_box.x1 && y >= m_clip_box.y1 && x <= m_clip_box.x2 && y <= m_clip_box.y2;
|
||||
return x >= m_clip_box.x1 && y >= m_clip_box.y1 &&
|
||||
x <= m_clip_box.x2 && y <= m_clip_box.y2;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -136,6 +134,7 @@ class renderer_base
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_pixel(int x, int y, const color_type& c)
|
||||
{
|
||||
|
@ -155,30 +154,24 @@ class renderer_base
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
color_type pixel(int x, int y) const { return inbox(x, y) ? m_ren->pixel(x, y) : color_type::no_color(); }
|
||||
color_type pixel(int x, int y) const
|
||||
{
|
||||
return inbox(x, y) ?
|
||||
m_ren->pixel(x, y) :
|
||||
color_type::no_color();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_hline(int x1, int y, int x2, const color_type& c)
|
||||
{
|
||||
if (x1 > x2)
|
||||
{
|
||||
int t = x2;
|
||||
x2 = x1;
|
||||
x1 = t;
|
||||
}
|
||||
if (y > ymax())
|
||||
return;
|
||||
if (y < ymin())
|
||||
return;
|
||||
if (x1 > xmax())
|
||||
return;
|
||||
if (x2 < xmin())
|
||||
return;
|
||||
if(x1 > x2) { int t = x2; x2 = x1; x1 = t; }
|
||||
if(y > ymax()) return;
|
||||
if(y < ymin()) return;
|
||||
if(x1 > xmax()) return;
|
||||
if(x2 < xmin()) return;
|
||||
|
||||
if (x1 < xmin())
|
||||
x1 = xmin();
|
||||
if (x2 > xmax())
|
||||
x2 = xmax();
|
||||
if(x1 < xmin()) x1 = xmin();
|
||||
if(x2 > xmax()) x2 = xmax();
|
||||
|
||||
m_ren->copy_hline(x1, y, x2 - x1 + 1, c);
|
||||
}
|
||||
|
@ -186,81 +179,51 @@ class renderer_base
|
|||
//--------------------------------------------------------------------
|
||||
void copy_vline(int x, int y1, int y2, const color_type& c)
|
||||
{
|
||||
if (y1 > y2)
|
||||
{
|
||||
int t = y2;
|
||||
y2 = y1;
|
||||
y1 = t;
|
||||
}
|
||||
if (x > xmax())
|
||||
return;
|
||||
if (x < xmin())
|
||||
return;
|
||||
if (y1 > ymax())
|
||||
return;
|
||||
if (y2 < ymin())
|
||||
return;
|
||||
if(y1 > y2) { int t = y2; y2 = y1; y1 = t; }
|
||||
if(x > xmax()) return;
|
||||
if(x < xmin()) return;
|
||||
if(y1 > ymax()) return;
|
||||
if(y2 < ymin()) return;
|
||||
|
||||
if (y1 < ymin())
|
||||
y1 = ymin();
|
||||
if (y2 > ymax())
|
||||
y2 = ymax();
|
||||
if(y1 < ymin()) y1 = ymin();
|
||||
if(y2 > ymax()) y2 = ymax();
|
||||
|
||||
m_ren->copy_vline(x, y1, y2 - y1 + 1, c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_hline(int x1, int y, int x2, const color_type& c, cover_type cover)
|
||||
void blend_hline(int x1, int y, int x2,
|
||||
const color_type& c, cover_type cover)
|
||||
{
|
||||
if (x1 > x2)
|
||||
{
|
||||
int t = x2;
|
||||
x2 = x1;
|
||||
x1 = t;
|
||||
}
|
||||
if (y > ymax())
|
||||
return;
|
||||
if (y < ymin())
|
||||
return;
|
||||
if (x1 > xmax())
|
||||
return;
|
||||
if (x2 < xmin())
|
||||
return;
|
||||
if(x1 > x2) { int t = x2; x2 = x1; x1 = t; }
|
||||
if(y > ymax()) return;
|
||||
if(y < ymin()) return;
|
||||
if(x1 > xmax()) return;
|
||||
if(x2 < xmin()) return;
|
||||
|
||||
if (x1 < xmin())
|
||||
x1 = xmin();
|
||||
if (x2 > xmax())
|
||||
x2 = xmax();
|
||||
if(x1 < xmin()) x1 = xmin();
|
||||
if(x2 > xmax()) x2 = xmax();
|
||||
|
||||
m_ren->blend_hline(x1, y, x2 - x1 + 1, c, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_vline(int x, int y1, int y2, const color_type& c, cover_type cover)
|
||||
void blend_vline(int x, int y1, int y2,
|
||||
const color_type& c, cover_type cover)
|
||||
{
|
||||
if (y1 > y2)
|
||||
{
|
||||
int t = y2;
|
||||
y2 = y1;
|
||||
y1 = t;
|
||||
}
|
||||
if (x > xmax())
|
||||
return;
|
||||
if (x < xmin())
|
||||
return;
|
||||
if (y1 > ymax())
|
||||
return;
|
||||
if (y2 < ymin())
|
||||
return;
|
||||
if(y1 > y2) { int t = y2; y2 = y1; y1 = t; }
|
||||
if(x > xmax()) return;
|
||||
if(x < xmin()) return;
|
||||
if(y1 > ymax()) return;
|
||||
if(y2 < ymin()) return;
|
||||
|
||||
if (y1 < ymin())
|
||||
y1 = ymin();
|
||||
if (y2 > ymax())
|
||||
y2 = ymax();
|
||||
if(y1 < ymin()) y1 = ymin();
|
||||
if(y2 > ymax()) y2 = ymax();
|
||||
|
||||
m_ren->blend_vline(x, y1, y2 - y1 + 1, c, cover);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_bar(int x1, int y1, int x2, int y2, const color_type& c)
|
||||
{
|
||||
|
@ -277,7 +240,8 @@ class renderer_base
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_bar(int x1, int y1, int x2, int y2, const color_type& c, cover_type cover)
|
||||
void blend_bar(int x1, int y1, int x2, int y2,
|
||||
const color_type& c, cover_type cover)
|
||||
{
|
||||
rect_i rc(x1, y1, x2, y2);
|
||||
rc.normalize();
|
||||
|
@ -286,209 +250,183 @@ class renderer_base
|
|||
int y;
|
||||
for(y = rc.y1; y <= rc.y2; y++)
|
||||
{
|
||||
m_ren->blend_hline(rc.x1, y, unsigned(rc.x2 - rc.x1 + 1), c, cover);
|
||||
m_ren->blend_hline(rc.x1,
|
||||
y,
|
||||
unsigned(rc.x2 - rc.x1 + 1),
|
||||
c,
|
||||
cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_hspan(int x, int y, int len, const color_type& c, const cover_type* covers)
|
||||
void blend_solid_hspan(int x, int y, int len,
|
||||
const color_type& c,
|
||||
const cover_type* covers)
|
||||
{
|
||||
if (y > ymax())
|
||||
return;
|
||||
if (y < ymin())
|
||||
return;
|
||||
if(y > ymax()) return;
|
||||
if(y < ymin()) return;
|
||||
|
||||
if(x < xmin())
|
||||
{
|
||||
len -= xmin() - x;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
covers += xmin() - x;
|
||||
x = xmin();
|
||||
}
|
||||
if(x + len > xmax())
|
||||
{
|
||||
len = xmax() - x + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->blend_solid_hspan(x, y, len, c, covers);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_vspan(int x, int y, int len, const color_type& c, const cover_type* covers)
|
||||
void blend_solid_vspan(int x, int y, int len,
|
||||
const color_type& c,
|
||||
const cover_type* covers)
|
||||
{
|
||||
if (x > xmax())
|
||||
return;
|
||||
if (x < xmin())
|
||||
return;
|
||||
if(x > xmax()) return;
|
||||
if(x < xmin()) return;
|
||||
|
||||
if(y < ymin())
|
||||
{
|
||||
len -= ymin() - y;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
covers += ymin() - y;
|
||||
y = ymin();
|
||||
}
|
||||
if(y + len > ymax())
|
||||
{
|
||||
len = ymax() - y + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->blend_solid_vspan(x, y, len, c, covers);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_hspan(int x, int y, int len, const color_type* colors)
|
||||
{
|
||||
if (y > ymax())
|
||||
return;
|
||||
if (y < ymin())
|
||||
return;
|
||||
if(y > ymax()) return;
|
||||
if(y < ymin()) return;
|
||||
|
||||
if(x < xmin())
|
||||
{
|
||||
int d = xmin() - x;
|
||||
len -= d;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
colors += d;
|
||||
x = xmin();
|
||||
}
|
||||
if(x + len > xmax())
|
||||
{
|
||||
len = xmax() - x + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->copy_color_hspan(x, y, len, colors);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_vspan(int x, int y, int len, const color_type* colors)
|
||||
{
|
||||
if (x > xmax())
|
||||
return;
|
||||
if (x < xmin())
|
||||
return;
|
||||
if(x > xmax()) return;
|
||||
if(x < xmin()) return;
|
||||
|
||||
if(y < ymin())
|
||||
{
|
||||
int d = ymin() - y;
|
||||
len -= d;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
colors += d;
|
||||
y = ymin();
|
||||
}
|
||||
if(y + len > ymax())
|
||||
{
|
||||
len = ymax() - y + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->copy_color_vspan(x, y, len, colors);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan(int x,
|
||||
int y,
|
||||
int len,
|
||||
void blend_color_hspan(int x, int y, int len,
|
||||
const color_type* colors,
|
||||
const cover_type* covers,
|
||||
cover_type cover = agg::cover_full)
|
||||
{
|
||||
if (y > ymax())
|
||||
return;
|
||||
if (y < ymin())
|
||||
return;
|
||||
if(y > ymax()) return;
|
||||
if(y < ymin()) return;
|
||||
|
||||
if(x < xmin())
|
||||
{
|
||||
int d = xmin() - x;
|
||||
len -= d;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if (covers)
|
||||
covers += d;
|
||||
if(len <= 0) return;
|
||||
if(covers) covers += d;
|
||||
colors += d;
|
||||
x = xmin();
|
||||
}
|
||||
if(x + len > xmax())
|
||||
{
|
||||
len = xmax() - x + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->blend_color_hspan(x, y, len, colors, covers, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan_alpha(int x,
|
||||
int y,
|
||||
int len,
|
||||
void blend_color_hspan_alpha(int x, int y, int len,
|
||||
const color_type* colors,
|
||||
value_type alpha,
|
||||
const cover_type* covers,
|
||||
cover_type cover = agg::cover_full)
|
||||
{
|
||||
if (y > ymax())
|
||||
return;
|
||||
if (y < ymin())
|
||||
return;
|
||||
if(y > ymax()) return;
|
||||
if(y < ymin()) return;
|
||||
|
||||
if(x < xmin())
|
||||
{
|
||||
int d = xmin() - x;
|
||||
len -= d;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if (covers)
|
||||
covers += d;
|
||||
if(len <= 0) return;
|
||||
if(covers) covers += d;
|
||||
colors += d;
|
||||
x = xmin();
|
||||
}
|
||||
if(x + len > xmax())
|
||||
{
|
||||
len = xmax() - x + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->blend_color_hspan_alpha(x, y, len, colors, alpha, covers, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x,
|
||||
int y,
|
||||
int len,
|
||||
void blend_color_vspan(int x, int y, int len,
|
||||
const color_type* colors,
|
||||
const cover_type* covers,
|
||||
cover_type cover = agg::cover_full)
|
||||
{
|
||||
if (x > xmax())
|
||||
return;
|
||||
if (x < xmin())
|
||||
return;
|
||||
if(x > xmax()) return;
|
||||
if(x < xmin()) return;
|
||||
|
||||
if(y < ymin())
|
||||
{
|
||||
int d = ymin() - y;
|
||||
len -= d;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if (covers)
|
||||
covers += d;
|
||||
if(len <= 0) return;
|
||||
if(covers) covers += d;
|
||||
colors += d;
|
||||
y = ymin();
|
||||
}
|
||||
if(y + len > ymax())
|
||||
{
|
||||
len = ymax() - y + 1;
|
||||
if (len <= 0)
|
||||
return;
|
||||
if(len <= 0) return;
|
||||
}
|
||||
m_ren->blend_color_vspan(x, y, len, colors, covers, cover);
|
||||
}
|
||||
|
@ -512,10 +450,8 @@ class renderer_base
|
|||
src.y1 = 0;
|
||||
}
|
||||
|
||||
if (src.x2 > wsrc)
|
||||
src.x2 = wsrc;
|
||||
if (src.y2 > hsrc)
|
||||
src.y2 = hsrc;
|
||||
if(src.x2 > wsrc) src.x2 = wsrc;
|
||||
if(src.y2 > hsrc) src.y2 = hsrc;
|
||||
|
||||
if(dst.x1 < cb.x1)
|
||||
{
|
||||
|
@ -528,24 +464,23 @@ class renderer_base
|
|||
dst.y1 = cb.y1;
|
||||
}
|
||||
|
||||
if (dst.x2 > cb.x2)
|
||||
dst.x2 = cb.x2;
|
||||
if (dst.y2 > cb.y2)
|
||||
dst.y2 = cb.y2;
|
||||
if(dst.x2 > cb.x2) dst.x2 = cb.x2;
|
||||
if(dst.y2 > cb.y2) dst.y2 = cb.y2;
|
||||
|
||||
rc.x2 = dst.x2 - dst.x1;
|
||||
rc.y2 = dst.y2 - dst.y1;
|
||||
|
||||
if (rc.x2 > src.x2 - src.x1)
|
||||
rc.x2 = src.x2 - src.x1;
|
||||
if (rc.y2 > src.y2 - src.y1)
|
||||
rc.y2 = src.y2 - src.y1;
|
||||
if(rc.x2 > src.x2 - src.x1) rc.x2 = src.x2 - src.x1;
|
||||
if(rc.y2 > src.y2 - src.y1) rc.y2 = src.y2 - src.y1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class RenBuf>
|
||||
void copy_from(const RenBuf& src, const rect_i* rect_src_ptr = 0, int dx = 0, int dy = 0)
|
||||
void copy_from(const RenBuf& src,
|
||||
const rect_i* rect_src_ptr = 0,
|
||||
int dx = 0,
|
||||
int dy = 0)
|
||||
{
|
||||
rect_i rsrc(0, 0, src.width(), src.height());
|
||||
if(rect_src_ptr)
|
||||
|
@ -575,7 +510,10 @@ class renderer_base
|
|||
}
|
||||
while(rc.y2 > 0)
|
||||
{
|
||||
m_ren->copy_from(src, rdst.x1, rdst.y1, rsrc.x1, rsrc.y1, rc.x2);
|
||||
m_ren->copy_from(src,
|
||||
rdst.x1, rdst.y1,
|
||||
rsrc.x1, rsrc.y1,
|
||||
rc.x2);
|
||||
rdst.y1 += incy;
|
||||
rsrc.y1 += incy;
|
||||
--rc.y2;
|
||||
|
@ -638,7 +576,11 @@ class renderer_base
|
|||
}
|
||||
if(len > 0)
|
||||
{
|
||||
m_ren->blend_from(src, x1dst, rdst.y1, x1src, rsrc.y1, len, cover);
|
||||
m_ren->blend_from(src,
|
||||
x1dst, rdst.y1,
|
||||
x1src, rsrc.y1,
|
||||
len,
|
||||
cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -705,7 +647,12 @@ class renderer_base
|
|||
}
|
||||
if(len > 0)
|
||||
{
|
||||
m_ren->blend_from_color(src, color, x1dst, rdst.y1, x1src, rsrc.y1, len, cover);
|
||||
m_ren->blend_from_color(src,
|
||||
color,
|
||||
x1dst, rdst.y1,
|
||||
x1src, rsrc.y1,
|
||||
len,
|
||||
cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -772,7 +719,12 @@ class renderer_base
|
|||
}
|
||||
if(len > 0)
|
||||
{
|
||||
m_ren->blend_from_lut(src, color_lut, x1dst, rdst.y1, x1src, rsrc.y1, len, cover);
|
||||
m_ren->blend_from_lut(src,
|
||||
color_lut,
|
||||
x1dst, rdst.y1,
|
||||
x1src, rsrc.y1,
|
||||
len,
|
||||
cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -788,6 +740,7 @@ class renderer_base
|
|||
rect_i m_clip_box;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
1080
deps/agg/include/agg_renderer_markers.h
vendored
1080
deps/agg/include/agg_renderer_markers.h
vendored
File diff suppressed because it is too large
Load diff
115
deps/agg/include/agg_renderer_mclip.h
vendored
115
deps/agg/include/agg_renderer_mclip.h
vendored
|
@ -24,11 +24,11 @@
|
|||
#include "agg_array.h"
|
||||
#include "agg_renderer_base.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//----------------------------------------------------------renderer_mclip
|
||||
template<class PixelFormat>
|
||||
class renderer_mclip
|
||||
template<class PixelFormat> class renderer_mclip
|
||||
{
|
||||
public:
|
||||
typedef PixelFormat pixfmt_type;
|
||||
|
@ -37,10 +37,10 @@ class renderer_mclip
|
|||
typedef renderer_base<pixfmt_type> base_ren_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
explicit renderer_mclip(pixfmt_type& pixf)
|
||||
: m_ren(pixf)
|
||||
, m_curr_cb(0)
|
||||
, m_bounds(m_ren.xmin(), m_ren.ymin(), m_ren.xmax(), m_ren.ymax())
|
||||
explicit renderer_mclip(pixfmt_type& pixf) :
|
||||
m_ren(pixf),
|
||||
m_curr_cb(0),
|
||||
m_bounds(m_ren.xmin(), m_ren.ymin(), m_ren.xmax(), m_ren.ymax())
|
||||
{}
|
||||
void attach(pixfmt_type& pixf)
|
||||
{
|
||||
|
@ -110,19 +110,18 @@ class renderer_mclip
|
|||
if(cb.clip(rect_i(0, 0, width() - 1, height() - 1)))
|
||||
{
|
||||
m_clip.add(cb);
|
||||
if (cb.x1 < m_bounds.x1)
|
||||
m_bounds.x1 = cb.x1;
|
||||
if (cb.y1 < m_bounds.y1)
|
||||
m_bounds.y1 = cb.y1;
|
||||
if (cb.x2 > m_bounds.x2)
|
||||
m_bounds.x2 = cb.x2;
|
||||
if (cb.y2 > m_bounds.y2)
|
||||
m_bounds.y2 = cb.y2;
|
||||
if(cb.x1 < m_bounds.x1) m_bounds.x1 = cb.x1;
|
||||
if(cb.y1 < m_bounds.y1) m_bounds.y1 = cb.y1;
|
||||
if(cb.x2 > m_bounds.x2) m_bounds.x2 = cb.x2;
|
||||
if(cb.y2 > m_bounds.y2) m_bounds.y2 = cb.y2;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void clear(const color_type& c) { m_ren.clear(c); }
|
||||
void clear(const color_type& c)
|
||||
{
|
||||
m_ren.clear(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_pixel(int x, int y, const color_type& c)
|
||||
|
@ -135,7 +134,8 @@ class renderer_mclip
|
|||
m_ren.ren().copy_pixel(x, y, c);
|
||||
break;
|
||||
}
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -149,7 +149,8 @@ class renderer_mclip
|
|||
m_ren.ren().blend_pixel(x, y, c, cover);
|
||||
break;
|
||||
}
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -162,7 +163,8 @@ class renderer_mclip
|
|||
{
|
||||
return m_ren.ren().pixel(x, y);
|
||||
}
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
return color_type::no_color();
|
||||
}
|
||||
|
||||
|
@ -173,7 +175,8 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.copy_hline(x1, y, x2, c);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -183,27 +186,32 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.copy_vline(x, y1, y2, c);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_hline(int x1, int y, int x2, const color_type& c, cover_type cover)
|
||||
void blend_hline(int x1, int y, int x2,
|
||||
const color_type& c, cover_type cover)
|
||||
{
|
||||
first_clip_box();
|
||||
do
|
||||
{
|
||||
m_ren.blend_hline(x1, y, x2, c, cover);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_vline(int x, int y1, int y2, const color_type& c, cover_type cover)
|
||||
void blend_vline(int x, int y1, int y2,
|
||||
const color_type& c, cover_type cover)
|
||||
{
|
||||
first_clip_box();
|
||||
do
|
||||
{
|
||||
m_ren.blend_vline(x, y1, y2, c, cover);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -213,38 +221,46 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.copy_bar(x1, y1, x2, y2, c);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_bar(int x1, int y1, int x2, int y2, const color_type& c, cover_type cover)
|
||||
void blend_bar(int x1, int y1, int x2, int y2,
|
||||
const color_type& c, cover_type cover)
|
||||
{
|
||||
first_clip_box();
|
||||
do
|
||||
{
|
||||
m_ren.blend_bar(x1, y1, x2, y2, c, cover);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_hspan(int x, int y, int len, const color_type& c, const cover_type* covers)
|
||||
void blend_solid_hspan(int x, int y, int len,
|
||||
const color_type& c, const cover_type* covers)
|
||||
{
|
||||
first_clip_box();
|
||||
do
|
||||
{
|
||||
m_ren.blend_solid_hspan(x, y, len, c, covers);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_vspan(int x, int y, int len, const color_type& c, const cover_type* covers)
|
||||
void blend_solid_vspan(int x, int y, int len,
|
||||
const color_type& c, const cover_type* covers)
|
||||
{
|
||||
first_clip_box();
|
||||
do
|
||||
{
|
||||
m_ren.blend_solid_vspan(x, y, len, c, covers);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_hspan(int x, int y, int len, const color_type* colors)
|
||||
|
@ -253,13 +269,12 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.copy_color_hspan(x, y, len, colors);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan(int x,
|
||||
int y,
|
||||
int len,
|
||||
void blend_color_hspan(int x, int y, int len,
|
||||
const color_type* colors,
|
||||
const cover_type* covers,
|
||||
cover_type cover = cover_full)
|
||||
|
@ -268,13 +283,12 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.blend_color_hspan(x, y, len, colors, covers, cover);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x,
|
||||
int y,
|
||||
int len,
|
||||
void blend_color_vspan(int x, int y, int len,
|
||||
const color_type* colors,
|
||||
const cover_type* covers,
|
||||
cover_type cover = cover_full)
|
||||
|
@ -283,17 +297,22 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.blend_color_vspan(x, y, len, colors, covers, cover);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_from(const rendering_buffer& from, const rect_i* rc = 0, int x_to = 0, int y_to = 0)
|
||||
void copy_from(const rendering_buffer& from,
|
||||
const rect_i* rc=0,
|
||||
int x_to=0,
|
||||
int y_to=0)
|
||||
{
|
||||
first_clip_box();
|
||||
do
|
||||
{
|
||||
m_ren.copy_from(from, rc, x_to, y_to);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -308,12 +327,15 @@ class renderer_mclip
|
|||
do
|
||||
{
|
||||
m_ren.blend_from(src, rect_src_ptr, dx, dy, cover);
|
||||
} while (next_clip_box());
|
||||
}
|
||||
while(next_clip_box());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
renderer_mclip(const renderer_mclip<PixelFormat>&);
|
||||
const renderer_mclip<PixelFormat>& operator=(const renderer_mclip<PixelFormat>&);
|
||||
const renderer_mclip<PixelFormat>&
|
||||
operator = (const renderer_mclip<PixelFormat>&);
|
||||
|
||||
base_ren_type m_ren;
|
||||
pod_bvector<rect_i, 4> m_clip;
|
||||
|
@ -321,6 +343,7 @@ class renderer_mclip
|
|||
rect_i m_bounds;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
637
deps/agg/include/agg_renderer_outline_aa.h
vendored
637
deps/agg/include/agg_renderer_outline_aa.h
vendored
File diff suppressed because it is too large
Load diff
394
deps/agg/include/agg_renderer_outline_image.h
vendored
394
deps/agg/include/agg_renderer_outline_image.h
vendored
|
@ -22,19 +22,21 @@
|
|||
#include "agg_rendering_buffer.h"
|
||||
#include "agg_clip_liang_barsky.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
//========================================================line_image_scale
|
||||
template<class Source>
|
||||
class line_image_scale
|
||||
template<class Source> class line_image_scale
|
||||
{
|
||||
public:
|
||||
typedef typename Source::color_type color_type;
|
||||
|
||||
line_image_scale(const Source& src, double height)
|
||||
: m_source(src)
|
||||
, m_height(height)
|
||||
, m_scale(src.height() / height)
|
||||
{}
|
||||
line_image_scale(const Source& src, double height) :
|
||||
m_source(src),
|
||||
m_height(height),
|
||||
m_scale(src.height() / height)
|
||||
{
|
||||
}
|
||||
|
||||
double width() const { return m_source.width(); }
|
||||
double height() const { return m_height; }
|
||||
|
@ -59,48 +61,49 @@ class line_image_scale
|
|||
double m_scale;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//======================================================line_image_pattern
|
||||
template<class Filter>
|
||||
class line_image_pattern
|
||||
template<class Filter> class line_image_pattern
|
||||
{
|
||||
public:
|
||||
typedef Filter filter_type;
|
||||
typedef typename filter_type::color_type color_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
line_image_pattern(const Filter& filter)
|
||||
: m_filter(&filter)
|
||||
, m_dilation(filter.dilation() + 1)
|
||||
, m_dilation_hr(m_dilation * line_subpixel_scale)
|
||||
, m_data()
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_width_hr(0)
|
||||
, m_half_height_hr(0)
|
||||
, m_offset_y_hr(0)
|
||||
{}
|
||||
line_image_pattern(const Filter& filter) :
|
||||
m_filter(&filter),
|
||||
m_dilation(filter.dilation() + 1),
|
||||
m_dilation_hr(m_dilation * line_subpixel_scale),
|
||||
m_data(),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_width_hr(0),
|
||||
m_half_height_hr(0),
|
||||
m_offset_y_hr(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Create
|
||||
//--------------------------------------------------------------------
|
||||
template<class Source>
|
||||
line_image_pattern(const Filter& filter, const Source& src)
|
||||
: m_filter(&filter)
|
||||
, m_dilation(filter.dilation() + 1)
|
||||
, m_dilation_hr(m_dilation * line_subpixel_scale)
|
||||
, m_data()
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_width_hr(0)
|
||||
, m_half_height_hr(0)
|
||||
, m_offset_y_hr(0)
|
||||
line_image_pattern(const Filter& filter, const Source& src) :
|
||||
m_filter(&filter),
|
||||
m_dilation(filter.dilation() + 1),
|
||||
m_dilation_hr(m_dilation * line_subpixel_scale),
|
||||
m_data(),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_width_hr(0),
|
||||
m_half_height_hr(0),
|
||||
m_offset_y_hr(0)
|
||||
{
|
||||
create(src);
|
||||
}
|
||||
|
||||
// Create
|
||||
//--------------------------------------------------------------------
|
||||
template<class Source>
|
||||
void create(const Source& src)
|
||||
template<class Source> void create(const Source& src)
|
||||
{
|
||||
m_height = uceil(src.height());
|
||||
m_width = uceil(src.width());
|
||||
|
@ -111,7 +114,9 @@ class line_image_pattern
|
|||
|
||||
m_data.resize((m_width + m_dilation * 2) * (m_height + m_dilation * 2));
|
||||
|
||||
m_buf.attach(&m_data[0], m_width + m_dilation * 2, m_height + m_dilation * 2, m_width + m_dilation * 2);
|
||||
m_buf.attach(&m_data[0], m_width + m_dilation * 2,
|
||||
m_height + m_dilation * 2,
|
||||
m_width + m_dilation * 2);
|
||||
unsigned x, y;
|
||||
color_type* d1;
|
||||
color_type* d2;
|
||||
|
@ -165,7 +170,10 @@ class line_image_pattern
|
|||
//--------------------------------------------------------------------
|
||||
void pixel(color_type* p, int x, int y) const
|
||||
{
|
||||
m_filter->pixel_high_res(m_buf.rows(), p, x % m_width_hr + m_dilation_hr, y + m_offset_y_hr);
|
||||
m_filter->pixel_high_res(m_buf.rows(),
|
||||
p,
|
||||
x % m_width_hr + m_dilation_hr,
|
||||
y + m_offset_y_hr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -173,7 +181,8 @@ class line_image_pattern
|
|||
|
||||
private:
|
||||
line_image_pattern(const line_image_pattern<filter_type>&);
|
||||
const line_image_pattern<filter_type>& operator=(const line_image_pattern<filter_type>&);
|
||||
const line_image_pattern<filter_type>&
|
||||
operator = (const line_image_pattern<filter_type>&);
|
||||
|
||||
protected:
|
||||
row_ptr_cache<color_type> m_buf;
|
||||
|
@ -188,9 +197,14 @@ class line_image_pattern
|
|||
int m_offset_y_hr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=================================================line_image_pattern_pow2
|
||||
template<class Filter>
|
||||
class line_image_pattern_pow2 : public line_image_pattern<Filter>
|
||||
template<class Filter> class line_image_pattern_pow2 :
|
||||
public line_image_pattern<Filter>
|
||||
{
|
||||
public:
|
||||
typedef Filter filter_type;
|
||||
|
@ -198,23 +212,19 @@ class line_image_pattern_pow2 : public line_image_pattern<Filter>
|
|||
typedef line_image_pattern<Filter> base_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
line_image_pattern_pow2(const Filter& filter)
|
||||
: line_image_pattern<Filter>(filter)
|
||||
, m_mask(line_subpixel_mask)
|
||||
{}
|
||||
line_image_pattern_pow2(const Filter& filter) :
|
||||
line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Source>
|
||||
line_image_pattern_pow2(const Filter& filter, const Source& src)
|
||||
: line_image_pattern<Filter>(filter)
|
||||
, m_mask(line_subpixel_mask)
|
||||
line_image_pattern_pow2(const Filter& filter, const Source& src) :
|
||||
line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask)
|
||||
{
|
||||
create(src);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Source>
|
||||
void create(const Source& src)
|
||||
template<class Source> void create(const Source& src)
|
||||
{
|
||||
line_image_pattern<Filter>::create(src);
|
||||
m_mask = 1;
|
||||
|
@ -231,53 +241,47 @@ class line_image_pattern_pow2 : public line_image_pattern<Filter>
|
|||
//--------------------------------------------------------------------
|
||||
void pixel(color_type* p, int x, int y) const
|
||||
{
|
||||
base_type::m_filter->pixel_high_res(base_type::m_buf.rows(),
|
||||
base_type::m_filter->pixel_high_res(
|
||||
base_type::m_buf.rows(),
|
||||
p,
|
||||
(x & m_mask) + base_type::m_dilation_hr,
|
||||
y + base_type::m_offset_y_hr);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_mask;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//===================================================distance_interpolator4
|
||||
class distance_interpolator4
|
||||
{
|
||||
public:
|
||||
//---------------------------------------------------------------------
|
||||
distance_interpolator4() {}
|
||||
distance_interpolator4(int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2,
|
||||
int sx,
|
||||
int sy,
|
||||
int ex,
|
||||
int ey,
|
||||
int len,
|
||||
double scale,
|
||||
int x,
|
||||
int y)
|
||||
: m_dx(x2 - x1)
|
||||
, m_dy(y2 - y1)
|
||||
, m_dx_start(line_mr(sx) - line_mr(x1))
|
||||
, m_dy_start(line_mr(sy) - line_mr(y1))
|
||||
, m_dx_end(line_mr(ex) - line_mr(x2))
|
||||
, m_dy_end(line_mr(ey) - line_mr(y2))
|
||||
,
|
||||
distance_interpolator4(int x1, int y1, int x2, int y2,
|
||||
int sx, int sy, int ex, int ey,
|
||||
int len, double scale, int x, int y) :
|
||||
m_dx(x2 - x1),
|
||||
m_dy(y2 - y1),
|
||||
m_dx_start(line_mr(sx) - line_mr(x1)),
|
||||
m_dy_start(line_mr(sy) - line_mr(y1)),
|
||||
m_dx_end(line_mr(ex) - line_mr(x2)),
|
||||
m_dy_end(line_mr(ey) - line_mr(y2)),
|
||||
|
||||
m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) -
|
||||
double(y + line_subpixel_scale / 2 - y2) * double(m_dx)))
|
||||
,
|
||||
double(y + line_subpixel_scale/2 - y2) * double(m_dx))),
|
||||
|
||||
m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start -
|
||||
(line_mr(y + line_subpixel_scale / 2) - line_mr(sy)) * m_dx_start)
|
||||
,
|
||||
(line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start),
|
||||
|
||||
m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end -
|
||||
(line_mr(y + line_subpixel_scale / 2) - line_mr(ey)) * m_dx_end)
|
||||
, m_len(uround(len / scale))
|
||||
(line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end),
|
||||
m_len(uround(len / scale))
|
||||
{
|
||||
double d = len * scale;
|
||||
int dx = iround(((x2 - x1) * line_subpixel_scale) / d);
|
||||
|
@ -459,57 +463,50 @@ class distance_interpolator4
|
|||
int m_len;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================line_interpolator_image
|
||||
template<class Renderer>
|
||||
class line_interpolator_image
|
||||
template<class Renderer> class line_interpolator_image
|
||||
{
|
||||
public:
|
||||
typedef Renderer renderer_type;
|
||||
typedef typename Renderer::color_type color_type;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
enum max_half_width_e { max_half_width = 64 };
|
||||
enum max_half_width_e
|
||||
{
|
||||
max_half_width = 64
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
line_interpolator_image(renderer_type& ren,
|
||||
const line_parameters& lp,
|
||||
int sx,
|
||||
int sy,
|
||||
int ex,
|
||||
int ey,
|
||||
line_interpolator_image(renderer_type& ren, const line_parameters& lp,
|
||||
int sx, int sy, int ex, int ey,
|
||||
int pattern_start,
|
||||
double scale_x)
|
||||
: m_lp(lp)
|
||||
, m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : line_dbl_hr(lp.y2 - lp.y1), lp.vertical ? lp.dy : lp.dx + 1)
|
||||
, m_di(lp.x1,
|
||||
lp.y1,
|
||||
lp.x2,
|
||||
lp.y2,
|
||||
sx,
|
||||
sy,
|
||||
ex,
|
||||
ey,
|
||||
lp.len,
|
||||
scale_x,
|
||||
lp.x1 & ~line_subpixel_mask,
|
||||
lp.y1 & ~line_subpixel_mask)
|
||||
, m_ren(ren)
|
||||
, m_x(lp.x1 >> line_subpixel_shift)
|
||||
, m_y(lp.y1 >> line_subpixel_shift)
|
||||
, m_old_x(m_x)
|
||||
, m_old_y(m_y)
|
||||
, m_count((lp.vertical ? std::abs((lp.y2 >> line_subpixel_shift) - m_y)
|
||||
: std::abs((lp.x2 >> line_subpixel_shift) - m_x)))
|
||||
, m_width(ren.subpixel_width())
|
||||
,
|
||||
double scale_x) :
|
||||
m_lp(lp),
|
||||
m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) :
|
||||
line_dbl_hr(lp.y2 - lp.y1),
|
||||
lp.vertical ? lp.dy : lp.dx + 1),
|
||||
m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x,
|
||||
lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask),
|
||||
m_ren(ren),
|
||||
m_x(lp.x1 >> line_subpixel_shift),
|
||||
m_y(lp.y1 >> line_subpixel_shift),
|
||||
m_old_x(m_x),
|
||||
m_old_y(m_y),
|
||||
m_count((lp.vertical ? std::abs((lp.y2 >> line_subpixel_shift) - m_y) :
|
||||
std::abs((lp.x2 >> line_subpixel_shift) - m_x))),
|
||||
m_width(ren.subpixel_width()),
|
||||
//m_max_extent(m_width >> (line_subpixel_shift - 2)),
|
||||
m_max_extent((m_width + line_subpixel_scale) >> line_subpixel_shift)
|
||||
, m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width())
|
||||
, m_step(0)
|
||||
m_max_extent((m_width + line_subpixel_scale) >> line_subpixel_shift),
|
||||
m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()),
|
||||
m_step(0)
|
||||
{
|
||||
agg::dda2_line_interpolator li(0,
|
||||
lp.vertical ? (lp.dy * agg::line_subpixel_scale)
|
||||
: (lp.dx * agg::line_subpixel_scale),
|
||||
agg::dda2_line_interpolator li(0, lp.vertical ?
|
||||
(lp.dy * agg::line_subpixel_scale) :
|
||||
(lp.dx * agg::line_subpixel_scale),
|
||||
lp.len);
|
||||
|
||||
unsigned i;
|
||||
|
@ -517,8 +514,7 @@ class line_interpolator_image
|
|||
for(i = 0; i < max_half_width; ++i)
|
||||
{
|
||||
m_dist_pos[i] = li.y();
|
||||
if (m_dist_pos[i] >= stop)
|
||||
break;
|
||||
if(m_dist_pos[i] >= stop) break;
|
||||
++li;
|
||||
}
|
||||
m_dist_pos[i] = 0x7FFF0000;
|
||||
|
@ -535,33 +531,29 @@ class line_interpolator_image
|
|||
m_y -= lp.inc;
|
||||
m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift;
|
||||
|
||||
if (lp.inc > 0)
|
||||
m_di.dec_y(m_x - m_old_x);
|
||||
else
|
||||
m_di.inc_y(m_x - m_old_x);
|
||||
if(lp.inc > 0) m_di.dec_y(m_x - m_old_x);
|
||||
else m_di.inc_y(m_x - m_old_x);
|
||||
|
||||
m_old_x = m_x;
|
||||
|
||||
dist1_start = dist2_start = m_di.dist_start();
|
||||
|
||||
int dx = 0;
|
||||
if (dist1_start < 0)
|
||||
++npix;
|
||||
if(dist1_start < 0) ++npix;
|
||||
do
|
||||
{
|
||||
dist1_start += m_di.dy_start();
|
||||
dist2_start -= m_di.dy_start();
|
||||
if (dist1_start < 0)
|
||||
++npix;
|
||||
if (dist2_start < 0)
|
||||
++npix;
|
||||
if(dist1_start < 0) ++npix;
|
||||
if(dist2_start < 0) ++npix;
|
||||
++dx;
|
||||
} while (m_dist_pos[dx] <= m_width);
|
||||
if (npix == 0)
|
||||
break;
|
||||
}
|
||||
while(m_dist_pos[dx] <= m_width);
|
||||
if(npix == 0) break;
|
||||
|
||||
npix = 0;
|
||||
} while (--m_step >= -m_max_extent);
|
||||
}
|
||||
while(--m_step >= -m_max_extent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -572,33 +564,29 @@ class line_interpolator_image
|
|||
m_x -= lp.inc;
|
||||
m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift;
|
||||
|
||||
if (lp.inc > 0)
|
||||
m_di.dec_x(m_y - m_old_y);
|
||||
else
|
||||
m_di.inc_x(m_y - m_old_y);
|
||||
if(lp.inc > 0) m_di.dec_x(m_y - m_old_y);
|
||||
else m_di.inc_x(m_y - m_old_y);
|
||||
|
||||
m_old_y = m_y;
|
||||
|
||||
dist1_start = dist2_start = m_di.dist_start();
|
||||
|
||||
int dy = 0;
|
||||
if (dist1_start < 0)
|
||||
++npix;
|
||||
if(dist1_start < 0) ++npix;
|
||||
do
|
||||
{
|
||||
dist1_start -= m_di.dx_start();
|
||||
dist2_start += m_di.dx_start();
|
||||
if (dist1_start < 0)
|
||||
++npix;
|
||||
if (dist2_start < 0)
|
||||
++npix;
|
||||
if(dist1_start < 0) ++npix;
|
||||
if(dist2_start < 0) ++npix;
|
||||
++dy;
|
||||
} while (m_dist_pos[dy] <= m_width);
|
||||
if (npix == 0)
|
||||
break;
|
||||
}
|
||||
while(m_dist_pos[dy] <= m_width);
|
||||
if(npix == 0) break;
|
||||
|
||||
npix = 0;
|
||||
} while (--m_step >= -m_max_extent);
|
||||
}
|
||||
while(--m_step >= -m_max_extent);
|
||||
}
|
||||
m_li.adjust_forward();
|
||||
m_step -= m_max_extent;
|
||||
|
@ -611,18 +599,15 @@ class line_interpolator_image
|
|||
m_x += m_lp.inc;
|
||||
m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift;
|
||||
|
||||
if (m_lp.inc > 0)
|
||||
m_di.inc_x(m_y - m_old_y);
|
||||
else
|
||||
m_di.dec_x(m_y - m_old_y);
|
||||
if(m_lp.inc > 0) m_di.inc_x(m_y - m_old_y);
|
||||
else m_di.dec_x(m_y - m_old_y);
|
||||
|
||||
m_old_y = m_y;
|
||||
|
||||
int s1 = m_di.dist() / m_lp.len;
|
||||
int s2 = -s1;
|
||||
|
||||
if (m_lp.inc < 0)
|
||||
s1 = -s1;
|
||||
if(m_lp.inc < 0) s1 = -s1;
|
||||
|
||||
int dist_start;
|
||||
int dist_pict;
|
||||
|
@ -657,8 +642,7 @@ class line_interpolator_image
|
|||
p1->clear();
|
||||
if(dist_end > 0 && dist_start <= 0)
|
||||
{
|
||||
if (m_lp.inc > 0)
|
||||
dist = -dist;
|
||||
if(m_lp.inc > 0) dist = -dist;
|
||||
m_ren.pixel(p1, dist_pict, s2 - dist);
|
||||
++npix;
|
||||
}
|
||||
|
@ -679,17 +663,21 @@ class line_interpolator_image
|
|||
p0->clear();
|
||||
if(dist_end > 0 && dist_start <= 0)
|
||||
{
|
||||
if (m_lp.inc > 0)
|
||||
dist = -dist;
|
||||
if(m_lp.inc > 0) dist = -dist;
|
||||
m_ren.pixel(p0, dist_pict, s2 + dist);
|
||||
++npix;
|
||||
}
|
||||
++dy;
|
||||
}
|
||||
m_ren.blend_color_vspan(m_x, m_y - dy + 1, unsigned(p1 - p0), p0);
|
||||
m_ren.blend_color_vspan(m_x,
|
||||
m_y - dy + 1,
|
||||
unsigned(p1 - p0),
|
||||
p0);
|
||||
return npix && ++m_step < m_count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
bool step_ver()
|
||||
{
|
||||
|
@ -697,18 +685,15 @@ class line_interpolator_image
|
|||
m_y += m_lp.inc;
|
||||
m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift;
|
||||
|
||||
if (m_lp.inc > 0)
|
||||
m_di.inc_y(m_x - m_old_x);
|
||||
else
|
||||
m_di.dec_y(m_x - m_old_x);
|
||||
if(m_lp.inc > 0) m_di.inc_y(m_x - m_old_x);
|
||||
else m_di.dec_y(m_x - m_old_x);
|
||||
|
||||
m_old_x = m_x;
|
||||
|
||||
int s1 = m_di.dist() / m_lp.len;
|
||||
int s2 = -s1;
|
||||
|
||||
if (m_lp.inc > 0)
|
||||
s1 = -s1;
|
||||
if(m_lp.inc > 0) s1 = -s1;
|
||||
|
||||
int dist_start;
|
||||
int dist_pict;
|
||||
|
@ -743,8 +728,7 @@ class line_interpolator_image
|
|||
p1->clear();
|
||||
if(dist_end > 0 && dist_start <= 0)
|
||||
{
|
||||
if (m_lp.inc > 0)
|
||||
dist = -dist;
|
||||
if(m_lp.inc > 0) dist = -dist;
|
||||
m_ren.pixel(p1, dist_pict, s2 + dist);
|
||||
++npix;
|
||||
}
|
||||
|
@ -765,17 +749,20 @@ class line_interpolator_image
|
|||
p0->clear();
|
||||
if(dist_end > 0 && dist_start <= 0)
|
||||
{
|
||||
if (m_lp.inc > 0)
|
||||
dist = -dist;
|
||||
if(m_lp.inc > 0) dist = -dist;
|
||||
m_ren.pixel(p0, dist_pict, s2 - dist);
|
||||
++npix;
|
||||
}
|
||||
++dx;
|
||||
}
|
||||
m_ren.blend_color_hspan(m_x - dx + 1, m_y, unsigned(p1 - p0), p0);
|
||||
m_ren.blend_color_hspan(m_x - dx + 1,
|
||||
m_y,
|
||||
unsigned(p1 - p0),
|
||||
p0);
|
||||
return npix && ++m_step < m_count;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
int pattern_end() const { return m_start + m_di.len(); }
|
||||
|
||||
|
@ -786,7 +773,8 @@ class line_interpolator_image
|
|||
|
||||
private:
|
||||
line_interpolator_image(const line_interpolator_image<Renderer>&);
|
||||
const line_interpolator_image<Renderer>& operator=(const line_interpolator_image<Renderer>&);
|
||||
const line_interpolator_image<Renderer>&
|
||||
operator = (const line_interpolator_image<Renderer>&);
|
||||
|
||||
protected:
|
||||
const line_parameters& m_lp;
|
||||
|
@ -807,6 +795,13 @@ class line_interpolator_image
|
|||
color_type m_colors[max_half_width * 2 + 4];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//===================================================renderer_outline_image
|
||||
template<class BaseRenderer, class ImagePattern>
|
||||
class renderer_outline_image
|
||||
|
@ -818,14 +813,15 @@ class renderer_outline_image
|
|||
typedef typename base_ren_type::color_type color_type;
|
||||
typedef ImagePattern pattern_type;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
renderer_outline_image(base_ren_type& ren, const pattern_type& patt)
|
||||
: m_ren(&ren)
|
||||
, m_pattern(&patt)
|
||||
, m_start(0)
|
||||
, m_scale_x(1.0)
|
||||
, m_clip_box(0, 0, 0, 0)
|
||||
, m_clipping(false)
|
||||
renderer_outline_image(base_ren_type& ren, const pattern_type& patt) :
|
||||
m_ren(&ren),
|
||||
m_pattern(&patt),
|
||||
m_start(0),
|
||||
m_scale_x(1.0),
|
||||
m_clip_box(0,0,0,0),
|
||||
m_clipping(false)
|
||||
{}
|
||||
void attach(base_ren_type& ren) { m_ren = &ren; }
|
||||
|
||||
|
@ -858,7 +854,10 @@ class renderer_outline_image
|
|||
double width() const { return double(subpixel_width()) / line_subpixel_scale; }
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void pixel(color_type* p, int x, int y) const { m_pattern->pixel(p, x, y); }
|
||||
void pixel(color_type* p, int x, int y) const
|
||||
{
|
||||
m_pattern->pixel(p, x, y);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void blend_color_hspan(int x, int y, unsigned len, const color_type* colors)
|
||||
|
@ -878,22 +877,32 @@ class renderer_outline_image
|
|||
//-------------------------------------------------------------------------
|
||||
template<class Cmp>
|
||||
void semidot(Cmp, int, int, int, int)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void pie(int, int, int, int, int, int) {}
|
||||
void pie(int, int, int, int, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void line0(const line_parameters&) {}
|
||||
void line0(const line_parameters&)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void line1(const line_parameters&, int, int) {}
|
||||
void line1(const line_parameters&, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void line2(const line_parameters&, int, int) {}
|
||||
void line2(const line_parameters&, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void line3_no_clip(const line_parameters& lp, int sx, int sy, int ex, int ey)
|
||||
void line3_no_clip(const line_parameters& lp,
|
||||
int sx, int sy, int ex, int ey)
|
||||
{
|
||||
if(lp.len > line_max_length)
|
||||
{
|
||||
|
@ -908,22 +917,24 @@ class renderer_outline_image
|
|||
|
||||
fix_degenerate_bisectrix_start(lp, &sx, &sy);
|
||||
fix_degenerate_bisectrix_end(lp, &ex, &ey);
|
||||
line_interpolator_image<self_type> li(*this, lp, sx, sy, ex, ey, m_start, m_scale_x);
|
||||
line_interpolator_image<self_type> li(*this, lp,
|
||||
sx, sy,
|
||||
ex, ey,
|
||||
m_start, m_scale_x);
|
||||
if(li.vertical())
|
||||
{
|
||||
while (li.step_ver())
|
||||
;
|
||||
while(li.step_ver()) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (li.step_hor())
|
||||
;
|
||||
while(li.step_hor()) ;
|
||||
}
|
||||
m_start += uround(lp.len / m_scale_x);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void line3(const line_parameters& lp, int sx, int sy, int ex, int ey)
|
||||
void line3(const line_parameters& lp,
|
||||
int sx, int sy, int ex, int ey)
|
||||
{
|
||||
if(m_clipping)
|
||||
{
|
||||
|
@ -937,7 +948,8 @@ class renderer_outline_image
|
|||
{
|
||||
if(flags)
|
||||
{
|
||||
line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2)));
|
||||
line_parameters lp2(x1, y1, x2, y2,
|
||||
uround(calc_distance(x1, y1, x2, y2)));
|
||||
if(flags & 1)
|
||||
{
|
||||
m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x);
|
||||
|
@ -989,6 +1001,12 @@ class renderer_outline_image
|
|||
bool m_clipping;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
48
deps/agg/include/agg_renderer_primitives.h
vendored
48
deps/agg/include/agg_renderer_primitives.h
vendored
|
@ -25,27 +25,30 @@
|
|||
#include "agg_dda_line.h"
|
||||
#include "agg_ellipse_bresenham.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//-----------------------------------------------------renderer_primitives
|
||||
template<class BaseRenderer>
|
||||
class renderer_primitives
|
||||
template<class BaseRenderer> class renderer_primitives
|
||||
{
|
||||
public:
|
||||
typedef BaseRenderer base_ren_type;
|
||||
typedef typename base_ren_type::color_type color_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
explicit renderer_primitives(base_ren_type& ren)
|
||||
: m_ren(&ren)
|
||||
, m_fill_color()
|
||||
, m_line_color()
|
||||
, m_curr_x(0)
|
||||
, m_curr_y(0)
|
||||
explicit renderer_primitives(base_ren_type& ren) :
|
||||
m_ren(&ren),
|
||||
m_fill_color(),
|
||||
m_line_color(),
|
||||
m_curr_x(0),
|
||||
m_curr_y(0)
|
||||
{}
|
||||
void attach(base_ren_type& ren) { m_ren = &ren; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static int coord(double c) { return iround(c * line_bresenham_interpolator::subpixel_scale); }
|
||||
static int coord(double c)
|
||||
{
|
||||
return iround(c * line_bresenham_interpolator::subpixel_scale);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void fill_color(const color_type& c) { m_fill_color = c; }
|
||||
|
@ -63,7 +66,10 @@ class renderer_primitives
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void solid_rectangle(int x1, int y1, int x2, int y2) { m_ren->blend_bar(x1, y1, x2, y2, m_fill_color, cover_full); }
|
||||
void solid_rectangle(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
m_ren->blend_bar(x1, y1, x2, y2, m_fill_color, cover_full);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void outlined_rectangle(int x1, int y1, int x2, int y2)
|
||||
|
@ -87,7 +93,8 @@ class renderer_primitives
|
|||
m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full);
|
||||
m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full);
|
||||
++ei;
|
||||
} while (dy < 0);
|
||||
}
|
||||
while(dy < 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -112,7 +119,8 @@ class renderer_primitives
|
|||
dx0 = dx;
|
||||
dy0 = dy;
|
||||
++ei;
|
||||
} while (dy < 0);
|
||||
}
|
||||
while(dy < 0);
|
||||
m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full);
|
||||
}
|
||||
|
||||
|
@ -139,7 +147,8 @@ class renderer_primitives
|
|||
m_ren->blend_hline(x-dx+1, y-dy, x+dx-1, m_fill_color, cover_full);
|
||||
}
|
||||
++ei;
|
||||
} while (dy < 0);
|
||||
}
|
||||
while(dy < 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -157,8 +166,7 @@ class renderer_primitives
|
|||
return;
|
||||
}
|
||||
|
||||
if (last)
|
||||
++len;
|
||||
if(last) ++len;
|
||||
|
||||
if(li.is_ver())
|
||||
{
|
||||
|
@ -166,7 +174,8 @@ class renderer_primitives
|
|||
{
|
||||
m_ren->blend_pixel(li.x2(), li.y1(), m_line_color, cover_full);
|
||||
li.vstep();
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -174,7 +183,8 @@ class renderer_primitives
|
|||
{
|
||||
m_ren->blend_pixel(li.x1(), li.y2(), m_line_color, cover_full);
|
||||
li.hstep();
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,6 +219,6 @@ class renderer_primitives
|
|||
int m_curr_y;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
84
deps/agg/include/agg_renderer_raster_text.h
vendored
84
deps/agg/include/agg_renderer_raster_text.h
vendored
|
@ -18,7 +18,8 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//==============================================renderer_raster_htext_solid
|
||||
template<class BaseRenderer, class GlyphGenerator>
|
||||
|
@ -30,9 +31,9 @@ class renderer_raster_htext_solid
|
|||
typedef typename glyph_gen_type::glyph_rect glyph_rect;
|
||||
typedef typename ren_type::color_type color_type;
|
||||
|
||||
renderer_raster_htext_solid(ren_type& ren, glyph_gen_type& glyph)
|
||||
: m_ren(&ren)
|
||||
, m_glyph(&glyph)
|
||||
renderer_raster_htext_solid(ren_type& ren, glyph_gen_type& glyph) :
|
||||
m_ren(&ren),
|
||||
m_glyph(&glyph)
|
||||
{}
|
||||
void attach(ren_type& ren) { m_ren = &ren; }
|
||||
|
||||
|
@ -55,14 +56,18 @@ class renderer_raster_htext_solid
|
|||
{
|
||||
for(i = r.y1; i <= r.y2; i++)
|
||||
{
|
||||
m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), m_color, m_glyph->span(r.y2 - i));
|
||||
m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1),
|
||||
m_color,
|
||||
m_glyph->span(r.y2 - i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = r.y1; i <= r.y2; i++)
|
||||
{
|
||||
m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), m_color, m_glyph->span(i - r.y1));
|
||||
m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1),
|
||||
m_color,
|
||||
m_glyph->span(i - r.y1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +83,8 @@ class renderer_raster_htext_solid
|
|||
color_type m_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=============================================renderer_raster_vtext_solid
|
||||
template<class BaseRenderer, class GlyphGenerator>
|
||||
class renderer_raster_vtext_solid
|
||||
|
@ -88,10 +95,11 @@ class renderer_raster_vtext_solid
|
|||
typedef typename glyph_gen_type::glyph_rect glyph_rect;
|
||||
typedef typename ren_type::color_type color_type;
|
||||
|
||||
renderer_raster_vtext_solid(ren_type& ren, glyph_gen_type& glyph)
|
||||
: m_ren(&ren)
|
||||
, m_glyph(&glyph)
|
||||
{}
|
||||
renderer_raster_vtext_solid(ren_type& ren, glyph_gen_type& glyph) :
|
||||
m_ren(&ren),
|
||||
m_glyph(&glyph)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void color(const color_type& c) { m_color = c; }
|
||||
|
@ -112,14 +120,18 @@ class renderer_raster_vtext_solid
|
|||
{
|
||||
for(i = r.y1; i <= r.y2; i++)
|
||||
{
|
||||
m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), m_color, m_glyph->span(i - r.y1));
|
||||
m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1),
|
||||
m_color,
|
||||
m_glyph->span(i - r.y1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = r.y1; i <= r.y2; i++)
|
||||
{
|
||||
m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), m_color, m_glyph->span(r.y2 - i));
|
||||
m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1),
|
||||
m_color,
|
||||
m_glyph->span(r.y2 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +147,11 @@ class renderer_raster_vtext_solid
|
|||
color_type m_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//===================================================renderer_raster_htext
|
||||
template<class ScanlineRenderer, class GlyphGenerator>
|
||||
class renderer_raster_htext
|
||||
|
@ -157,19 +174,18 @@ class renderer_raster_htext
|
|||
const cover_type* covers;
|
||||
|
||||
const_span() {}
|
||||
const_span(int x_, unsigned len_, const cover_type* covers_)
|
||||
: x(x_)
|
||||
, len(len_)
|
||||
, covers(covers_)
|
||||
const_span(int x_, unsigned len_, const cover_type* covers_) :
|
||||
x(x_), len(len_), covers(covers_)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef const const_span* const_iterator;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
scanline_single_span(int x, int y, unsigned len, const cover_type* covers)
|
||||
: m_y(y)
|
||||
, m_span(x, len, covers)
|
||||
scanline_single_span(int x, int y, unsigned len,
|
||||
const cover_type* covers) :
|
||||
m_y(y),
|
||||
m_span(x, len, covers)
|
||||
{}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -183,11 +199,15 @@ class renderer_raster_htext
|
|||
const_span m_span;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_raster_htext(ren_type& ren, glyph_gen_type& glyph)
|
||||
: m_ren(&ren)
|
||||
, m_glyph(&glyph)
|
||||
{}
|
||||
renderer_raster_htext(ren_type& ren, glyph_gen_type& glyph) :
|
||||
m_ren(&ren),
|
||||
m_glyph(&glyph)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class CharT>
|
||||
|
@ -205,14 +225,22 @@ class renderer_raster_htext
|
|||
{
|
||||
for(i = r.y1; i <= r.y2; i++)
|
||||
{
|
||||
m_ren->render(scanline_single_span(r.x1, i, (r.x2 - r.x1 + 1), m_glyph->span(r.y2 - i)));
|
||||
m_ren->render(
|
||||
scanline_single_span(r.x1,
|
||||
i,
|
||||
(r.x2 - r.x1 + 1),
|
||||
m_glyph->span(r.y2 - i)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = r.y1; i <= r.y2; i++)
|
||||
{
|
||||
m_ren->render(scanline_single_span(r.x1, i, (r.x2 - r.x1 + 1), m_glyph->span(i - r.y1)));
|
||||
m_ren->render(
|
||||
scanline_single_span(r.x1,
|
||||
i,
|
||||
(r.x2 - r.x1 + 1),
|
||||
m_glyph->span(i - r.y1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +255,10 @@ class renderer_raster_htext
|
|||
glyph_gen_type* m_glyph;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
350
deps/agg/include/agg_renderer_scanline.h
vendored
350
deps/agg/include/agg_renderer_scanline.h
vendored
|
@ -19,11 +19,14 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_renderer_base.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//================================================render_scanline_aa_solid
|
||||
template<class Scanline, class BaseRenderer, class ColorT>
|
||||
void render_scanline_aa_solid(const Scanline& sl, BaseRenderer& ren, const ColorT& color)
|
||||
void render_scanline_aa_solid(const Scanline& sl,
|
||||
BaseRenderer& ren,
|
||||
const ColorT& color)
|
||||
{
|
||||
int y = sl.y();
|
||||
unsigned num_spans = sl.num_spans();
|
||||
|
@ -34,21 +37,26 @@ void render_scanline_aa_solid(const Scanline& sl, BaseRenderer& ren, const Color
|
|||
int x = span->x;
|
||||
if(span->len > 0)
|
||||
{
|
||||
ren.blend_solid_hspan(x, y, (unsigned)span->len, color, span->covers);
|
||||
ren.blend_solid_hspan(x, y, (unsigned)span->len,
|
||||
color,
|
||||
span->covers);
|
||||
}
|
||||
else
|
||||
{
|
||||
ren.blend_hline(x, y, (unsigned)(x - span->len - 1), color, *(span->covers));
|
||||
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
|
||||
color,
|
||||
*(span->covers));
|
||||
}
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span;
|
||||
}
|
||||
}
|
||||
|
||||
//===============================================render_scanlines_aa_solid
|
||||
template<class Rasterizer, class Scanline, class BaseRenderer, class ColorT>
|
||||
void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, const ColorT& color)
|
||||
template<class Rasterizer, class Scanline,
|
||||
class BaseRenderer, class ColorT>
|
||||
void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl,
|
||||
BaseRenderer& ren, const ColorT& color)
|
||||
{
|
||||
if(ras.rewind_scanlines())
|
||||
{
|
||||
|
@ -68,21 +76,19 @@ void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
|
|||
}
|
||||
|
||||
//==============================================renderer_scanline_aa_solid
|
||||
template<class BaseRenderer>
|
||||
class renderer_scanline_aa_solid
|
||||
template<class BaseRenderer> class renderer_scanline_aa_solid
|
||||
{
|
||||
public:
|
||||
typedef BaseRenderer base_ren_type;
|
||||
typedef typename base_ren_type::color_type color_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_scanline_aa_solid()
|
||||
: m_ren(0)
|
||||
{}
|
||||
explicit renderer_scanline_aa_solid(base_ren_type& ren)
|
||||
: m_ren(&ren)
|
||||
{}
|
||||
void attach(base_ren_type& ren) { m_ren = &ren; }
|
||||
renderer_scanline_aa_solid() : m_ren(0) {}
|
||||
explicit renderer_scanline_aa_solid(base_ren_type& ren) : m_ren(&ren) {}
|
||||
void attach(base_ren_type& ren)
|
||||
{
|
||||
m_ren = &ren;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void color(const color_type& c) { m_color = c; }
|
||||
|
@ -92,8 +98,7 @@ class renderer_scanline_aa_solid
|
|||
void prepare() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
render_scanline_aa_solid(sl, *m_ren, m_color);
|
||||
}
|
||||
|
@ -103,9 +108,12 @@ class renderer_scanline_aa_solid
|
|||
color_type m_color;
|
||||
};
|
||||
|
||||
|
||||
//======================================================render_scanline_aa
|
||||
template<class Scanline, class BaseRenderer, class SpanAllocator, class SpanGenerator>
|
||||
void render_scanline_aa(const Scanline& sl, BaseRenderer& ren, SpanAllocator& alloc, SpanGenerator& span_gen)
|
||||
template<class Scanline, class BaseRenderer,
|
||||
class SpanAllocator, class SpanGenerator>
|
||||
void render_scanline_aa(const Scanline& sl, BaseRenderer& ren,
|
||||
SpanAllocator& alloc, SpanGenerator& span_gen)
|
||||
{
|
||||
int y = sl.y();
|
||||
|
||||
|
@ -117,25 +125,22 @@ void render_scanline_aa(const Scanline& sl, BaseRenderer& ren, SpanAllocator& al
|
|||
int len = span->len;
|
||||
const typename Scanline::cover_type* covers = span->covers;
|
||||
|
||||
if (len < 0)
|
||||
len = -len;
|
||||
if(len < 0) len = -len;
|
||||
typename BaseRenderer::color_type* colors = alloc.allocate(len);
|
||||
span_gen.generate(colors, x, y, len);
|
||||
ren.blend_color_hspan(x, y, len, colors, (span->len < 0) ? 0 : covers, *covers);
|
||||
ren.blend_color_hspan(x, y, len, colors,
|
||||
(span->len < 0) ? 0 : covers, *covers);
|
||||
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span;
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================render_scanline_aa_alpha
|
||||
template<class Scanline, class BaseRenderer, class SpanAllocator, class SpanGenerator>
|
||||
void render_scanline_aa_alpha(const Scanline& sl,
|
||||
BaseRenderer& ren,
|
||||
SpanAllocator& alloc,
|
||||
SpanGenerator& span_gen,
|
||||
unsigned alpha)
|
||||
template<class Scanline, class BaseRenderer,
|
||||
class SpanAllocator, class SpanGenerator>
|
||||
void render_scanline_aa_alpha(const Scanline& sl, BaseRenderer& ren,
|
||||
SpanAllocator& alloc, SpanGenerator& span_gen, unsigned alpha)
|
||||
{
|
||||
int y = sl.y();
|
||||
|
||||
|
@ -147,25 +152,23 @@ void render_scanline_aa_alpha(const Scanline& sl,
|
|||
int len = span->len;
|
||||
const typename Scanline::cover_type* covers = span->covers;
|
||||
|
||||
if (len < 0)
|
||||
len = -len;
|
||||
if(len < 0) len = -len;
|
||||
typename BaseRenderer::color_type* colors = alloc.allocate(len);
|
||||
span_gen.generate(colors, x, y, len);
|
||||
ren.blend_color_hspan_alpha(x, y, len, colors, alpha, (span->len < 0) ? 0 : covers, *covers);
|
||||
ren.blend_color_hspan_alpha(x, y, len, colors, alpha,
|
||||
(span->len < 0) ? 0 : covers, *covers);
|
||||
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=====================================================render_scanlines_aa
|
||||
template<class Rasterizer, class Scanline, class BaseRenderer, class SpanAllocator, class SpanGenerator>
|
||||
void render_scanlines_aa(Rasterizer& ras,
|
||||
Scanline& sl,
|
||||
BaseRenderer& ren,
|
||||
SpanAllocator& alloc,
|
||||
SpanGenerator& span_gen)
|
||||
template<class Rasterizer, class Scanline, class BaseRenderer,
|
||||
class SpanAllocator, class SpanGenerator>
|
||||
void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
|
||||
SpanAllocator& alloc, SpanGenerator& span_gen)
|
||||
{
|
||||
if(ras.rewind_scanlines())
|
||||
{
|
||||
|
@ -188,17 +191,17 @@ class renderer_scanline_aa
|
|||
typedef SpanGenerator span_gen_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_scanline_aa()
|
||||
: m_ren(0)
|
||||
, m_alloc(0)
|
||||
, m_span_gen(0)
|
||||
renderer_scanline_aa() : m_ren(0), m_alloc(0), m_span_gen(0) {}
|
||||
renderer_scanline_aa(base_ren_type& ren,
|
||||
alloc_type& alloc,
|
||||
span_gen_type& span_gen) :
|
||||
m_ren(&ren),
|
||||
m_alloc(&alloc),
|
||||
m_span_gen(&span_gen)
|
||||
{}
|
||||
renderer_scanline_aa(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen)
|
||||
: m_ren(&ren)
|
||||
, m_alloc(&alloc)
|
||||
, m_span_gen(&span_gen)
|
||||
{}
|
||||
void attach(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen)
|
||||
void attach(base_ren_type& ren,
|
||||
alloc_type& alloc,
|
||||
span_gen_type& span_gen)
|
||||
{
|
||||
m_ren = &ren;
|
||||
m_alloc = &alloc;
|
||||
|
@ -209,8 +212,7 @@ class renderer_scanline_aa
|
|||
void prepare() { m_span_gen->prepare(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
render_scanline_aa(sl, *m_ren, *m_alloc, *m_span_gen);
|
||||
}
|
||||
|
@ -221,6 +223,7 @@ class renderer_scanline_aa
|
|||
span_gen_type* m_span_gen;
|
||||
};
|
||||
|
||||
|
||||
//====================================================renderer_scanline_aa
|
||||
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
|
||||
class renderer_scanline_aa_alpha
|
||||
|
@ -231,19 +234,19 @@ class renderer_scanline_aa_alpha
|
|||
typedef SpanGenerator span_gen_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_scanline_aa_alpha()
|
||||
: m_ren(0)
|
||||
, m_alloc(0)
|
||||
, m_span_gen(0)
|
||||
, m_alpha(1.0)
|
||||
renderer_scanline_aa_alpha() : m_ren(0), m_alloc(0), m_span_gen(0), m_alpha(1.0) {}
|
||||
renderer_scanline_aa_alpha(base_ren_type& ren,
|
||||
alloc_type& alloc,
|
||||
span_gen_type& span_gen,
|
||||
unsigned alpha) :
|
||||
m_ren(&ren),
|
||||
m_alloc(&alloc),
|
||||
m_span_gen(&span_gen),
|
||||
m_alpha(alpha)
|
||||
{}
|
||||
renderer_scanline_aa_alpha(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen, unsigned alpha)
|
||||
: m_ren(&ren)
|
||||
, m_alloc(&alloc)
|
||||
, m_span_gen(&span_gen)
|
||||
, m_alpha(alpha)
|
||||
{}
|
||||
void attach(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen)
|
||||
void attach(base_ren_type& ren,
|
||||
alloc_type& alloc,
|
||||
span_gen_type& span_gen)
|
||||
{
|
||||
m_ren = &ren;
|
||||
m_alloc = &alloc;
|
||||
|
@ -254,8 +257,7 @@ class renderer_scanline_aa_alpha
|
|||
void prepare() { m_span_gen->prepare(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
render_scanline_aa_alpha(sl, *m_ren, *m_alloc, *m_span_gen, m_alpha);
|
||||
}
|
||||
|
@ -267,24 +269,34 @@ class renderer_scanline_aa_alpha
|
|||
unsigned m_alpha;
|
||||
};
|
||||
|
||||
|
||||
//===============================================render_scanline_bin_solid
|
||||
template<class Scanline, class BaseRenderer, class ColorT>
|
||||
void render_scanline_bin_solid(const Scanline& sl, BaseRenderer& ren, const ColorT& color)
|
||||
void render_scanline_bin_solid(const Scanline& sl,
|
||||
BaseRenderer& ren,
|
||||
const ColorT& color)
|
||||
{
|
||||
unsigned num_spans = sl.num_spans();
|
||||
typename Scanline::const_iterator span = sl.begin();
|
||||
for(;;)
|
||||
{
|
||||
ren.blend_hline(span->x, sl.y(), span->x - 1 + ((span->len < 0) ? -span->len : span->len), color, cover_full);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
ren.blend_hline(span->x,
|
||||
sl.y(),
|
||||
span->x - 1 + ((span->len < 0) ?
|
||||
-span->len :
|
||||
span->len),
|
||||
color,
|
||||
cover_full);
|
||||
if(--num_spans == 0) break;
|
||||
++span;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================render_scanlines_bin_solid
|
||||
template<class Rasterizer, class Scanline, class BaseRenderer, class ColorT>
|
||||
void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, const ColorT& color)
|
||||
template<class Rasterizer, class Scanline,
|
||||
class BaseRenderer, class ColorT>
|
||||
void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl,
|
||||
BaseRenderer& ren, const ColorT& color)
|
||||
{
|
||||
if(ras.rewind_scanlines())
|
||||
{
|
||||
|
@ -310,11 +322,12 @@ void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren
|
|||
{
|
||||
ren.blend_hline(span->x,
|
||||
sl.y(),
|
||||
span->x - 1 + ((span->len < 0) ? -span->len : span->len),
|
||||
span->x - 1 + ((span->len < 0) ?
|
||||
-span->len :
|
||||
span->len),
|
||||
ren_color,
|
||||
cover_full);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span;
|
||||
}
|
||||
}
|
||||
|
@ -322,21 +335,19 @@ void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren
|
|||
}
|
||||
|
||||
//=============================================renderer_scanline_bin_solid
|
||||
template<class BaseRenderer>
|
||||
class renderer_scanline_bin_solid
|
||||
template<class BaseRenderer> class renderer_scanline_bin_solid
|
||||
{
|
||||
public:
|
||||
typedef BaseRenderer base_ren_type;
|
||||
typedef typename base_ren_type::color_type color_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_scanline_bin_solid()
|
||||
: m_ren(0)
|
||||
{}
|
||||
explicit renderer_scanline_bin_solid(base_ren_type& ren)
|
||||
: m_ren(&ren)
|
||||
{}
|
||||
void attach(base_ren_type& ren) { m_ren = &ren; }
|
||||
renderer_scanline_bin_solid() : m_ren(0) {}
|
||||
explicit renderer_scanline_bin_solid(base_ren_type& ren) : m_ren(&ren) {}
|
||||
void attach(base_ren_type& ren)
|
||||
{
|
||||
m_ren = &ren;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void color(const color_type& c) { m_color = c; }
|
||||
|
@ -346,8 +357,7 @@ class renderer_scanline_bin_solid
|
|||
void prepare() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
render_scanline_bin_solid(sl, *m_ren, m_color);
|
||||
}
|
||||
|
@ -357,9 +367,18 @@ class renderer_scanline_bin_solid
|
|||
color_type m_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//======================================================render_scanline_bin
|
||||
template<class Scanline, class BaseRenderer, class SpanAllocator, class SpanGenerator>
|
||||
void render_scanline_bin(const Scanline& sl, BaseRenderer& ren, SpanAllocator& alloc, SpanGenerator& span_gen)
|
||||
template<class Scanline, class BaseRenderer,
|
||||
class SpanAllocator, class SpanGenerator>
|
||||
void render_scanline_bin(const Scanline& sl, BaseRenderer& ren,
|
||||
SpanAllocator& alloc, SpanGenerator& span_gen)
|
||||
{
|
||||
int y = sl.y();
|
||||
|
||||
|
@ -369,24 +388,20 @@ void render_scanline_bin(const Scanline& sl, BaseRenderer& ren, SpanAllocator& a
|
|||
{
|
||||
int x = span->x;
|
||||
int len = span->len;
|
||||
if (len < 0)
|
||||
len = -len;
|
||||
if(len < 0) len = -len;
|
||||
typename BaseRenderer::color_type* colors = alloc.allocate(len);
|
||||
span_gen.generate(colors, x, y, len);
|
||||
ren.blend_color_hspan(x, y, len, colors, 0, cover_full);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span;
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================render_scanlines_bin
|
||||
template<class Rasterizer, class Scanline, class BaseRenderer, class SpanAllocator, class SpanGenerator>
|
||||
void render_scanlines_bin(Rasterizer& ras,
|
||||
Scanline& sl,
|
||||
BaseRenderer& ren,
|
||||
SpanAllocator& alloc,
|
||||
SpanGenerator& span_gen)
|
||||
template<class Rasterizer, class Scanline, class BaseRenderer,
|
||||
class SpanAllocator, class SpanGenerator>
|
||||
void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
|
||||
SpanAllocator& alloc, SpanGenerator& span_gen)
|
||||
{
|
||||
if(ras.rewind_scanlines())
|
||||
{
|
||||
|
@ -409,17 +424,17 @@ class renderer_scanline_bin
|
|||
typedef SpanGenerator span_gen_type;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
renderer_scanline_bin()
|
||||
: m_ren(0)
|
||||
, m_alloc(0)
|
||||
, m_span_gen(0)
|
||||
renderer_scanline_bin() : m_ren(0), m_alloc(0), m_span_gen(0) {}
|
||||
renderer_scanline_bin(base_ren_type& ren,
|
||||
alloc_type& alloc,
|
||||
span_gen_type& span_gen) :
|
||||
m_ren(&ren),
|
||||
m_alloc(&alloc),
|
||||
m_span_gen(&span_gen)
|
||||
{}
|
||||
renderer_scanline_bin(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen)
|
||||
: m_ren(&ren)
|
||||
, m_alloc(&alloc)
|
||||
, m_span_gen(&span_gen)
|
||||
{}
|
||||
void attach(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen)
|
||||
void attach(base_ren_type& ren,
|
||||
alloc_type& alloc,
|
||||
span_gen_type& span_gen)
|
||||
{
|
||||
m_ren = &ren;
|
||||
m_alloc = &alloc;
|
||||
|
@ -430,8 +445,7 @@ class renderer_scanline_bin
|
|||
void prepare() { m_span_gen->prepare(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
render_scanline_bin(sl, *m_ren, *m_alloc, *m_span_gen);
|
||||
}
|
||||
|
@ -442,6 +456,7 @@ class renderer_scanline_bin
|
|||
span_gen_type* m_span_gen;
|
||||
};
|
||||
|
||||
|
||||
//========================================================render_scanlines
|
||||
template<class Rasterizer, class Scanline, class Renderer>
|
||||
void render_scanlines(Rasterizer& ras, Scanline& sl, Renderer& ren)
|
||||
|
@ -457,8 +472,10 @@ void render_scanlines(Rasterizer& ras, Scanline& sl, Renderer& ren)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================render_all_paths
|
||||
template<class Rasterizer, class Scanline, class Renderer, class VertexSource, class ColorStorage, class PathId>
|
||||
template<class Rasterizer, class Scanline, class Renderer,
|
||||
class VertexSource, class ColorStorage, class PathId>
|
||||
void render_all_paths(Rasterizer& ras,
|
||||
Scanline& sl,
|
||||
Renderer& r,
|
||||
|
@ -476,6 +493,11 @@ void render_all_paths(Rasterizer& ras,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================render_scanlines_compound
|
||||
template<class Rasterizer,
|
||||
class ScanlineAA,
|
||||
|
@ -530,11 +552,18 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
for(;;)
|
||||
{
|
||||
len = span_aa->len;
|
||||
sh.generate_span(color_span, span_aa->x, sl_aa.y(), len, style);
|
||||
sh.generate_span(color_span,
|
||||
span_aa->x,
|
||||
sl_aa.y(),
|
||||
len,
|
||||
style);
|
||||
|
||||
ren.blend_color_hspan(span_aa->x, sl_aa.y(), span_aa->len, color_span, span_aa->covers);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
ren.blend_color_hspan(span_aa->x,
|
||||
sl_aa.y(),
|
||||
span_aa->len,
|
||||
color_span,
|
||||
span_aa->covers);
|
||||
if(--num_spans == 0) break;
|
||||
++span_aa;
|
||||
}
|
||||
}
|
||||
|
@ -550,10 +579,11 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
num_spans = sl_bin.num_spans();
|
||||
for(;;)
|
||||
{
|
||||
memset(mix_buffer + span_bin->x - min_x, 0, span_bin->len * sizeof(color_type));
|
||||
memset(mix_buffer + span_bin->x - min_x,
|
||||
0,
|
||||
span_bin->len * sizeof(color_type));
|
||||
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span_bin;
|
||||
}
|
||||
|
||||
|
@ -592,9 +622,9 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
}
|
||||
++colors;
|
||||
++covers;
|
||||
} while (--len);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
}
|
||||
while(--len);
|
||||
if(--num_spans == 0) break;
|
||||
++span_aa;
|
||||
}
|
||||
}
|
||||
|
@ -607,7 +637,11 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
len = span_aa->len;
|
||||
colors = mix_buffer + span_aa->x - min_x;
|
||||
cspan = color_span;
|
||||
sh.generate_span(cspan, span_aa->x, sl_aa.y(), len, style);
|
||||
sh.generate_span(cspan,
|
||||
span_aa->x,
|
||||
sl_aa.y(),
|
||||
len,
|
||||
style);
|
||||
covers = span_aa->covers;
|
||||
do
|
||||
{
|
||||
|
@ -622,9 +656,9 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
++cspan;
|
||||
++colors;
|
||||
++covers;
|
||||
} while (--len);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
}
|
||||
while(--len);
|
||||
if(--num_spans == 0) break;
|
||||
++span_aa;
|
||||
}
|
||||
}
|
||||
|
@ -643,8 +677,7 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
mix_buffer + span_bin->x - min_x,
|
||||
0,
|
||||
cover_full);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(--num_spans == 0) break;
|
||||
++span_bin;
|
||||
}
|
||||
} // if(ras.sweep_scanline(sl_bin, -1))
|
||||
|
@ -654,7 +687,11 @@ void render_scanlines_compound(Rasterizer& ras,
|
|||
}
|
||||
|
||||
//=======================================render_scanlines_compound_layered
|
||||
template<class Rasterizer, class ScanlineAA, class BaseRenderer, class SpanAllocator, class StyleHandler>
|
||||
template<class Rasterizer,
|
||||
class ScanlineAA,
|
||||
class BaseRenderer,
|
||||
class SpanAllocator,
|
||||
class StyleHandler>
|
||||
void render_scanlines_compound_layered(Rasterizer& ras,
|
||||
ScanlineAA& sl_aa,
|
||||
BaseRenderer& ren,
|
||||
|
@ -701,11 +738,18 @@ void render_scanlines_compound_layered(Rasterizer& ras,
|
|||
for(;;)
|
||||
{
|
||||
len = span_aa->len;
|
||||
sh.generate_span(color_span, span_aa->x, sl_aa.y(), len, style);
|
||||
sh.generate_span(color_span,
|
||||
span_aa->x,
|
||||
sl_aa.y(),
|
||||
len,
|
||||
style);
|
||||
|
||||
ren.blend_color_hspan(span_aa->x, sl_aa.y(), span_aa->len, color_span, span_aa->covers);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
ren.blend_color_hspan(span_aa->x,
|
||||
sl_aa.y(),
|
||||
span_aa->len,
|
||||
color_span,
|
||||
span_aa->covers);
|
||||
if(--num_spans == 0) break;
|
||||
++span_aa;
|
||||
}
|
||||
}
|
||||
|
@ -718,9 +762,13 @@ void render_scanlines_compound_layered(Rasterizer& ras,
|
|||
|
||||
if(sl_len)
|
||||
{
|
||||
memset(mix_buffer + sl_start - min_x, 0, sl_len * sizeof(color_type));
|
||||
memset(mix_buffer + sl_start - min_x,
|
||||
0,
|
||||
sl_len * sizeof(color_type));
|
||||
|
||||
memset(cover_buffer + sl_start - min_x, 0, sl_len * sizeof(cover_type));
|
||||
memset(cover_buffer + sl_start - min_x,
|
||||
0,
|
||||
sl_len * sizeof(cover_type));
|
||||
|
||||
int sl_y = 0x7FFFFFFF;
|
||||
unsigned i;
|
||||
|
@ -765,9 +813,9 @@ void render_scanlines_compound_layered(Rasterizer& ras,
|
|||
++colors;
|
||||
++src_covers;
|
||||
++dst_covers;
|
||||
} while (--len);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
}
|
||||
while(--len);
|
||||
if(--num_spans == 0) break;
|
||||
++span_aa;
|
||||
}
|
||||
}
|
||||
|
@ -780,7 +828,11 @@ void render_scanlines_compound_layered(Rasterizer& ras,
|
|||
len = span_aa->len;
|
||||
colors = mix_buffer + span_aa->x - min_x;
|
||||
cspan = color_span;
|
||||
sh.generate_span(cspan, span_aa->x, sl_aa.y(), len, style);
|
||||
sh.generate_span(cspan,
|
||||
span_aa->x,
|
||||
sl_aa.y(),
|
||||
len,
|
||||
style);
|
||||
src_covers = span_aa->covers;
|
||||
dst_covers = cover_buffer + span_aa->x - min_x;
|
||||
do
|
||||
|
@ -799,21 +851,27 @@ void render_scanlines_compound_layered(Rasterizer& ras,
|
|||
++colors;
|
||||
++src_covers;
|
||||
++dst_covers;
|
||||
} while (--len);
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
}
|
||||
while(--len);
|
||||
if(--num_spans == 0) break;
|
||||
++span_aa;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ren.blend_color_hspan(sl_start, sl_y, sl_len, mix_buffer + sl_start - min_x, 0, cover_full);
|
||||
ren.blend_color_hspan(sl_start,
|
||||
sl_y,
|
||||
sl_len,
|
||||
mix_buffer + sl_start - min_x,
|
||||
0,
|
||||
cover_full);
|
||||
} //if(sl_len)
|
||||
} //if(num_styles == 1) ... else
|
||||
} //while((num_styles = ras.sweep_styles()) > 0)
|
||||
} //if(ras.rewind_scanlines())
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
115
deps/agg/include/agg_rendering_buffer.h
vendored
115
deps/agg/include/agg_rendering_buffer.h
vendored
|
@ -22,35 +22,37 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===========================================================row_accessor
|
||||
template<class T>
|
||||
class row_accessor
|
||||
template<class T> class row_accessor
|
||||
{
|
||||
public:
|
||||
typedef const_row_info<T> row_data;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
row_accessor()
|
||||
: m_buf(0)
|
||||
, m_start(0)
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_stride(0)
|
||||
{}
|
||||
row_accessor() :
|
||||
m_buf(0),
|
||||
m_start(0),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_stride(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
row_accessor(T* buf, unsigned width, unsigned height, int stride)
|
||||
: m_buf(0)
|
||||
, m_start(0)
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_stride(0)
|
||||
row_accessor(T* buf, unsigned width, unsigned height, int stride) :
|
||||
m_buf(0),
|
||||
m_start(0),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_stride(0)
|
||||
{
|
||||
attach(buf, width, height, stride);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void attach(T* buf, unsigned width, unsigned height, int stride)
|
||||
{
|
||||
|
@ -70,25 +72,32 @@ class row_accessor
|
|||
AGG_INLINE unsigned width() const { return m_width; }
|
||||
AGG_INLINE unsigned height() const { return m_height; }
|
||||
AGG_INLINE int stride() const { return m_stride; }
|
||||
AGG_INLINE unsigned stride_abs() const { return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); }
|
||||
AGG_INLINE unsigned stride_abs() const
|
||||
{
|
||||
return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE T* row_ptr(int, int y, unsigned) { return m_start + y * m_stride; }
|
||||
AGG_INLINE T* row_ptr(int, int y, unsigned)
|
||||
{
|
||||
return m_start + y * m_stride;
|
||||
}
|
||||
AGG_INLINE T* row_ptr(int y) { return m_start + y * m_stride; }
|
||||
AGG_INLINE const T* row_ptr(int y) const { return m_start + y * m_stride; }
|
||||
AGG_INLINE row_data row(int y) const { return row_data(0, m_width - 1, row_ptr(y)); }
|
||||
AGG_INLINE row_data row (int y) const
|
||||
{
|
||||
return row_data(0, m_width-1, row_ptr(y));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class RenBuf>
|
||||
void copy_from(const RenBuf& src)
|
||||
{
|
||||
unsigned h = height();
|
||||
if (src.height() < h)
|
||||
h = src.height();
|
||||
if(src.height() < h) h = src.height();
|
||||
|
||||
unsigned l = stride_abs();
|
||||
if (src.stride_abs() < l)
|
||||
l = src.stride_abs();
|
||||
if(src.stride_abs() < l) l = src.stride_abs();
|
||||
|
||||
l *= sizeof(T);
|
||||
|
||||
|
@ -126,29 +135,32 @@ class row_accessor
|
|||
int m_stride; // Number of bytes per row. Can be < 0
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================row_ptr_cache
|
||||
template<class T>
|
||||
class row_ptr_cache
|
||||
template<class T> class row_ptr_cache
|
||||
{
|
||||
public:
|
||||
typedef const_row_info<T> row_data;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
row_ptr_cache()
|
||||
: m_buf(0)
|
||||
, m_rows()
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_stride(0)
|
||||
{}
|
||||
row_ptr_cache() :
|
||||
m_buf(0),
|
||||
m_rows(),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_stride(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
row_ptr_cache(T* buf, unsigned width, unsigned height, int stride)
|
||||
: m_buf(0)
|
||||
, m_rows()
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_stride(0)
|
||||
row_ptr_cache(T* buf, unsigned width, unsigned height, int stride) :
|
||||
m_buf(0),
|
||||
m_rows(),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_stride(0)
|
||||
{
|
||||
attach(buf, width, height, stride);
|
||||
}
|
||||
|
@ -192,13 +204,22 @@ class row_ptr_cache
|
|||
AGG_INLINE unsigned width() const { return m_width; }
|
||||
AGG_INLINE unsigned height() const { return m_height; }
|
||||
AGG_INLINE int stride() const { return m_stride; }
|
||||
AGG_INLINE unsigned stride_abs() const { return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); }
|
||||
AGG_INLINE unsigned stride_abs() const
|
||||
{
|
||||
return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE T* row_ptr(int, int y, unsigned) { return m_rows[y]; }
|
||||
AGG_INLINE T* row_ptr(int, int y, unsigned)
|
||||
{
|
||||
return m_rows[y];
|
||||
}
|
||||
AGG_INLINE T* row_ptr(int y) { return m_rows[y]; }
|
||||
AGG_INLINE const T* row_ptr(int y) const { return m_rows[y]; }
|
||||
AGG_INLINE row_data row(int y) const { return row_data(0, m_width - 1, m_rows[y]); }
|
||||
AGG_INLINE row_data row (int y) const
|
||||
{
|
||||
return row_data(0, m_width-1, m_rows[y]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
T const* const* rows() const { return &m_rows[0]; }
|
||||
|
@ -208,12 +229,10 @@ class row_ptr_cache
|
|||
void copy_from(const RenBuf& src)
|
||||
{
|
||||
unsigned h = height();
|
||||
if (src.height() < h)
|
||||
h = src.height();
|
||||
if(src.height() < h) h = src.height();
|
||||
|
||||
unsigned l = stride_abs();
|
||||
if (src.stride_abs() < l)
|
||||
l = src.stride_abs();
|
||||
if(src.stride_abs() < l) l = src.stride_abs();
|
||||
|
||||
l *= sizeof(T);
|
||||
|
||||
|
@ -251,6 +270,9 @@ class row_ptr_cache
|
|||
int m_stride; // Number of bytes per row. Can be < 0
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================rendering_buffer
|
||||
//
|
||||
// The definition of the main type for accessing the rows in the frame
|
||||
|
@ -277,6 +299,7 @@ typedef row_ptr_cache<int8u> rendering_buffer;
|
|||
//typedef row_accessor<int8u> rendering_buffer;
|
||||
#endif
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
46
deps/agg/include/agg_rendering_buffer_dynarow.h
vendored
46
deps/agg/include/agg_rendering_buffer_dynarow.h
vendored
|
@ -22,7 +22,8 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===============================================rendering_buffer_dynarow
|
||||
// Rendering buffer class with dynamic allocation of the rows.
|
||||
|
@ -37,23 +38,28 @@ class rendering_buffer_dynarow
|
|||
typedef row_info<int8u> row_data;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
~rendering_buffer_dynarow() { init(0, 0, 0); }
|
||||
~rendering_buffer_dynarow()
|
||||
{
|
||||
init(0,0,0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
rendering_buffer_dynarow()
|
||||
: m_rows()
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_byte_width(0)
|
||||
{}
|
||||
rendering_buffer_dynarow() :
|
||||
m_rows(),
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_byte_width(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Allocate and clear the buffer
|
||||
//--------------------------------------------------------------------
|
||||
rendering_buffer_dynarow(unsigned width, unsigned height, unsigned byte_width)
|
||||
: m_rows(height)
|
||||
, m_width(width)
|
||||
, m_height(height)
|
||||
, m_byte_width(byte_width)
|
||||
rendering_buffer_dynarow(unsigned width, unsigned height,
|
||||
unsigned byte_width) :
|
||||
m_rows(height),
|
||||
m_width(width),
|
||||
m_height(height),
|
||||
m_byte_width(byte_width)
|
||||
{
|
||||
memset(&m_rows[0], 0, sizeof(row_data) * height);
|
||||
}
|
||||
|
@ -91,14 +97,8 @@ class rendering_buffer_dynarow
|
|||
int x2 = x + len - 1;
|
||||
if(r->ptr)
|
||||
{
|
||||
if (x < r->x1)
|
||||
{
|
||||
r->x1 = x;
|
||||
}
|
||||
if (x2 > r->x2)
|
||||
{
|
||||
r->x2 = x2;
|
||||
}
|
||||
if(x < r->x1) { r->x1 = x; }
|
||||
if(x2 > r->x2) { r->x2 = x2; }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,6 +130,8 @@ class rendering_buffer_dynarow
|
|||
unsigned m_byte_width; // Width in bytes
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
9
deps/agg/include/agg_rounded_rect.h
vendored
9
deps/agg/include/agg_rounded_rect.h
vendored
|
@ -23,7 +23,8 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_arc.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//------------------------------------------------------------rounded_rect
|
||||
//
|
||||
// See Implemantation agg_rounded_rect.cpp
|
||||
|
@ -38,7 +39,8 @@ class rounded_rect
|
|||
void radius(double r);
|
||||
void radius(double rx, double ry);
|
||||
void radius(double rx_bottom, double ry_bottom, double rx_top, double ry_top);
|
||||
void radius(double rx1, double ry1, double rx2, double ry2, double rx3, double ry3, double rx4, double ry4);
|
||||
void radius(double rx1, double ry1, double rx2, double ry2,
|
||||
double rx3, double ry3, double rx4, double ry4);
|
||||
void normalize_radius();
|
||||
|
||||
void approximation_scale(double s) { m_arc.approximation_scale(s); }
|
||||
|
@ -64,6 +66,7 @@ class rounded_rect
|
|||
arc m_arc;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
64
deps/agg/include/agg_scanline_bin.h
vendored
64
deps/agg/include/agg_scanline_bin.h
vendored
|
@ -30,7 +30,8 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=============================================================scanline_bin
|
||||
//
|
||||
|
@ -53,11 +54,12 @@ class scanline_bin
|
|||
typedef const span* const_iterator;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
scanline_bin()
|
||||
: m_last_x(0x7FFFFFF0)
|
||||
, m_spans()
|
||||
, m_cur_span(0)
|
||||
{}
|
||||
scanline_bin() :
|
||||
m_last_x(0x7FFFFFF0),
|
||||
m_spans(),
|
||||
m_cur_span(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset(int min_x, int max_x)
|
||||
|
@ -104,10 +106,16 @@ class scanline_bin
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void add_cells(int x, unsigned len, const void*) { add_span(x, len, 0); }
|
||||
void add_cells(int x, unsigned len, const void*)
|
||||
{
|
||||
add_span(x, len, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int y) { m_y = y; }
|
||||
void finalize(int y)
|
||||
{
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_spans()
|
||||
|
@ -131,6 +139,11 @@ class scanline_bin
|
|||
span* m_cur_span;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//===========================================================scanline32_bin
|
||||
class scanline32_bin
|
||||
{
|
||||
|
@ -141,23 +154,21 @@ class scanline32_bin
|
|||
struct span
|
||||
{
|
||||
span() {}
|
||||
span(coord_type x_, coord_type len_)
|
||||
: x(x_)
|
||||
, len(len_)
|
||||
{}
|
||||
span(coord_type x_, coord_type len_) : x(x_), len(len_) {}
|
||||
|
||||
coord_type x;
|
||||
coord_type len;
|
||||
};
|
||||
typedef pod_bvector<span, 4> span_array_type;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
class const_iterator
|
||||
{
|
||||
public:
|
||||
const_iterator(const span_array_type& spans)
|
||||
: m_spans(spans)
|
||||
, m_span_idx(0)
|
||||
const_iterator(const span_array_type& spans) :
|
||||
m_spans(spans),
|
||||
m_span_idx(0)
|
||||
{}
|
||||
|
||||
const span& operator*() const { return m_spans[m_span_idx]; }
|
||||
|
@ -170,11 +181,9 @@ class scanline32_bin
|
|||
unsigned m_span_idx;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
scanline32_bin()
|
||||
: m_max_len(0)
|
||||
, m_last_x(0x7FFFFFF0)
|
||||
{}
|
||||
scanline32_bin() : m_max_len(0), m_last_x(0x7FFFFFF0) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset(int, int)
|
||||
|
@ -212,10 +221,16 @@ class scanline32_bin
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void add_cells(int x, unsigned len, const void*) { add_span(x, len, 0); }
|
||||
void add_cells(int x, unsigned len, const void*)
|
||||
{
|
||||
add_span(x, len, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int y) { m_y = y; }
|
||||
void finalize(int y)
|
||||
{
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_spans()
|
||||
|
@ -239,6 +254,11 @@ class scanline32_bin
|
|||
span_array_type m_spans;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
839
deps/agg/include/agg_scanline_boolean_algebra.h
vendored
839
deps/agg/include/agg_scanline_boolean_algebra.h
vendored
File diff suppressed because it is too large
Load diff
76
deps/agg/include/agg_scanline_p.h
vendored
76
deps/agg/include/agg_scanline_p.h
vendored
|
@ -29,7 +29,8 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=============================================================scanline_p8
|
||||
//
|
||||
|
@ -56,13 +57,14 @@ class scanline_p8
|
|||
typedef span* iterator;
|
||||
typedef const span* const_iterator;
|
||||
|
||||
scanline_p8()
|
||||
: m_last_x(0x7FFFFFF0)
|
||||
, m_covers()
|
||||
, m_cover_ptr(0)
|
||||
, m_spans()
|
||||
, m_cur_span(0)
|
||||
{}
|
||||
scanline_p8() :
|
||||
m_last_x(0x7FFFFFF0),
|
||||
m_covers(),
|
||||
m_cover_ptr(0),
|
||||
m_spans(),
|
||||
m_cur_span(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset(int min_x, int max_x)
|
||||
|
@ -120,7 +122,9 @@ class scanline_p8
|
|||
//--------------------------------------------------------------------
|
||||
void add_span(int x, unsigned len, unsigned cover)
|
||||
{
|
||||
if (x == m_last_x + 1 && m_cur_span->len < 0 && cover == *m_cur_span->covers)
|
||||
if(x == m_last_x+1 &&
|
||||
m_cur_span->len < 0 &&
|
||||
cover == *m_cur_span->covers)
|
||||
{
|
||||
m_cur_span->len -= (int16)len;
|
||||
}
|
||||
|
@ -136,7 +140,10 @@ class scanline_p8
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int y) { m_y = y; }
|
||||
void finalize(int y)
|
||||
{
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_spans()
|
||||
|
@ -164,6 +171,13 @@ class scanline_p8
|
|||
span* m_cur_span;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================scanline32_p8
|
||||
class scanline32_p8
|
||||
{
|
||||
|
@ -175,11 +189,8 @@ class scanline32_p8
|
|||
struct span
|
||||
{
|
||||
span() {}
|
||||
span(coord_type x_, coord_type len_, const cover_type* covers_)
|
||||
: x(x_)
|
||||
, len(len_)
|
||||
, covers(covers_)
|
||||
{}
|
||||
span(coord_type x_, coord_type len_, const cover_type* covers_) :
|
||||
x(x_), len(len_), covers(covers_) {}
|
||||
|
||||
coord_type x;
|
||||
coord_type len; // If negative, it's a solid span, covers is valid
|
||||
|
@ -187,13 +198,14 @@ class scanline32_p8
|
|||
};
|
||||
typedef pod_bvector<span, 4> span_array_type;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
class const_iterator
|
||||
{
|
||||
public:
|
||||
const_iterator(const span_array_type& spans)
|
||||
: m_spans(spans)
|
||||
, m_span_idx(0)
|
||||
const_iterator(const span_array_type& spans) :
|
||||
m_spans(spans),
|
||||
m_span_idx(0)
|
||||
{}
|
||||
|
||||
const span& operator*() const { return m_spans[m_span_idx]; }
|
||||
|
@ -207,12 +219,13 @@ class scanline32_p8
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
scanline32_p8()
|
||||
: m_max_len(0)
|
||||
, m_last_x(0x7FFFFFF0)
|
||||
, m_covers()
|
||||
, m_cover_ptr(0)
|
||||
{}
|
||||
scanline32_p8() :
|
||||
m_max_len(0),
|
||||
m_last_x(0x7FFFFFF0),
|
||||
m_covers(),
|
||||
m_cover_ptr(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset(int min_x, int max_x)
|
||||
|
@ -262,7 +275,10 @@ class scanline32_p8
|
|||
//--------------------------------------------------------------------
|
||||
void add_span(int x, unsigned len, unsigned cover)
|
||||
{
|
||||
if (x == m_last_x + 1 && m_spans.size() && m_spans.last().len < 0 && cover == *m_spans.last().covers)
|
||||
if(x == m_last_x+1 &&
|
||||
m_spans.size() &&
|
||||
m_spans.last().len < 0 &&
|
||||
cover == *m_spans.last().covers)
|
||||
{
|
||||
m_spans.last().len -= coord_type(len);
|
||||
}
|
||||
|
@ -275,7 +291,10 @@ class scanline32_p8
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int y) { m_y = y; }
|
||||
void finalize(int y)
|
||||
{
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_spans()
|
||||
|
@ -302,6 +321,9 @@ class scanline32_p8
|
|||
span_array_type m_spans;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
244
deps/agg/include/agg_scanline_storage_aa.h
vendored
244
deps/agg/include/agg_scanline_storage_aa.h
vendored
|
@ -29,11 +29,12 @@
|
|||
#include <cmath>
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//----------------------------------------------scanline_cell_storage
|
||||
template<class T>
|
||||
class scanline_cell_storage
|
||||
template<class T> class scanline_cell_storage
|
||||
{
|
||||
struct extra_span
|
||||
{
|
||||
|
@ -45,25 +46,30 @@ class scanline_cell_storage
|
|||
typedef T value_type;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
~scanline_cell_storage() { remove_all(); }
|
||||
~scanline_cell_storage()
|
||||
{
|
||||
remove_all();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
scanline_cell_storage()
|
||||
: m_cells(128 - 2)
|
||||
, m_extra_storage()
|
||||
scanline_cell_storage() :
|
||||
m_cells(128-2),
|
||||
m_extra_storage()
|
||||
{}
|
||||
|
||||
|
||||
// Copying
|
||||
//---------------------------------------------------------------
|
||||
scanline_cell_storage(const scanline_cell_storage<T>& v)
|
||||
: m_cells(v.m_cells)
|
||||
, m_extra_storage()
|
||||
scanline_cell_storage(const scanline_cell_storage<T>& v) :
|
||||
m_cells(v.m_cells),
|
||||
m_extra_storage()
|
||||
{
|
||||
copy_extra_storage(v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
const scanline_cell_storage<T>& operator=(const scanline_cell_storage<T>& v)
|
||||
const scanline_cell_storage<T>&
|
||||
operator = (const scanline_cell_storage<T>& v)
|
||||
{
|
||||
remove_all();
|
||||
m_cells = v.m_cells;
|
||||
|
@ -77,7 +83,8 @@ class scanline_cell_storage
|
|||
int i;
|
||||
for(i = m_extra_storage.size()-1; i >= 0; --i)
|
||||
{
|
||||
pod_allocator<T>::deallocate(m_extra_storage[i].ptr, m_extra_storage[i].len);
|
||||
pod_allocator<T>::deallocate(m_extra_storage[i].ptr,
|
||||
m_extra_storage[i].len);
|
||||
}
|
||||
m_extra_storage.remove_all();
|
||||
m_cells.remove_all();
|
||||
|
@ -106,13 +113,11 @@ class scanline_cell_storage
|
|||
{
|
||||
if(idx >= 0)
|
||||
{
|
||||
if ((unsigned)idx >= m_cells.size())
|
||||
return 0;
|
||||
if((unsigned)idx >= m_cells.size()) return 0;
|
||||
return &m_cells[(unsigned)idx];
|
||||
}
|
||||
unsigned i = unsigned(-idx - 1);
|
||||
if (i >= m_extra_storage.size())
|
||||
return 0;
|
||||
if(i >= m_extra_storage.size()) return 0;
|
||||
return m_extra_storage[i].ptr;
|
||||
}
|
||||
|
||||
|
@ -121,13 +126,11 @@ class scanline_cell_storage
|
|||
{
|
||||
if(idx >= 0)
|
||||
{
|
||||
if ((unsigned)idx >= m_cells.size())
|
||||
return 0;
|
||||
if((unsigned)idx >= m_cells.size()) return 0;
|
||||
return &m_cells[(unsigned)idx];
|
||||
}
|
||||
unsigned i = unsigned(-idx - 1);
|
||||
if (i >= m_extra_storage.size())
|
||||
return 0;
|
||||
if(i >= m_extra_storage.size()) return 0;
|
||||
return m_extra_storage[i].ptr;
|
||||
}
|
||||
|
||||
|
@ -150,9 +153,13 @@ class scanline_cell_storage
|
|||
pod_bvector<extra_span, 6> m_extra_storage;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------scanline_storage_aa
|
||||
template<class T>
|
||||
class scanline_storage_aa
|
||||
template<class T> class scanline_storage_aa
|
||||
{
|
||||
public:
|
||||
typedef T cover_type;
|
||||
|
@ -173,6 +180,7 @@ class scanline_storage_aa
|
|||
unsigned start_span;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
class embedded_scanline
|
||||
{
|
||||
|
@ -189,12 +197,10 @@ class scanline_storage_aa
|
|||
const T* covers;
|
||||
};
|
||||
|
||||
const_iterator()
|
||||
: m_storage(0)
|
||||
{}
|
||||
const_iterator(const embedded_scanline& sl)
|
||||
: m_storage(sl.m_storage)
|
||||
, m_span_idx(sl.m_scanline.start_span)
|
||||
const_iterator() : m_storage(0) {}
|
||||
const_iterator(const embedded_scanline& sl) :
|
||||
m_storage(sl.m_storage),
|
||||
m_span_idx(sl.m_scanline.start_span)
|
||||
{
|
||||
init_span();
|
||||
}
|
||||
|
@ -224,9 +230,10 @@ class scanline_storage_aa
|
|||
|
||||
friend class const_iterator;
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
embedded_scanline(const scanline_storage_aa& storage)
|
||||
: m_storage(&storage)
|
||||
embedded_scanline(const scanline_storage_aa& storage) :
|
||||
m_storage(&storage)
|
||||
{
|
||||
init(0);
|
||||
}
|
||||
|
@ -250,17 +257,17 @@ class scanline_storage_aa
|
|||
unsigned m_scanline_idx;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
scanline_storage_aa()
|
||||
: m_covers()
|
||||
, m_spans(256 - 2)
|
||||
, // Block increment size
|
||||
m_scanlines()
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
, m_cur_scanline(0)
|
||||
scanline_storage_aa() :
|
||||
m_covers(),
|
||||
m_spans(256-2), // Block increment size
|
||||
m_scanlines(),
|
||||
m_min_x( 0x7FFFFFFF),
|
||||
m_min_y( 0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF),
|
||||
m_cur_scanline(0)
|
||||
{
|
||||
m_fake_scanline.y = 0;
|
||||
m_fake_scanline.num_spans = 0;
|
||||
|
@ -285,16 +292,13 @@ class scanline_storage_aa
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
scanline_data sl_this;
|
||||
|
||||
int y = sl.y();
|
||||
if (y < m_min_y)
|
||||
m_min_y = y;
|
||||
if (y > m_max_y)
|
||||
m_max_y = y;
|
||||
if(y < m_min_y) m_min_y = y;
|
||||
if(y > m_max_y) m_max_y = y;
|
||||
|
||||
sl_this.y = y;
|
||||
sl_this.num_spans = sl.num_spans();
|
||||
|
@ -309,21 +313,21 @@ class scanline_storage_aa
|
|||
sp.x = span_iterator->x;
|
||||
sp.len = span_iterator->len;
|
||||
int len = std::abs(int(sp.len));
|
||||
sp.covers_id = m_covers.add_cells(span_iterator->covers, unsigned(len));
|
||||
sp.covers_id =
|
||||
m_covers.add_cells(span_iterator->covers,
|
||||
unsigned(len));
|
||||
m_spans.add(sp);
|
||||
int x1 = sp.x;
|
||||
int x2 = sp.x + len - 1;
|
||||
if (x1 < m_min_x)
|
||||
m_min_x = x1;
|
||||
if (x2 > m_max_x)
|
||||
m_max_x = x2;
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(x1 < m_min_x) m_min_x = x1;
|
||||
if(x2 > m_max_x) m_max_x = x2;
|
||||
if(--num_spans == 0) break;
|
||||
++span_iterator;
|
||||
}
|
||||
m_scanlines.add(sl_this);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Iterate scanlines interface
|
||||
int min_x() const { return m_min_x; }
|
||||
|
@ -338,15 +342,14 @@ class scanline_storage_aa
|
|||
return m_scanlines.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
bool sweep_scanline(Scanline& sl)
|
||||
template<class Scanline> bool sweep_scanline(Scanline& sl)
|
||||
{
|
||||
sl.reset_spans();
|
||||
for(;;)
|
||||
{
|
||||
if (m_cur_scanline >= m_scanlines.size())
|
||||
return false;
|
||||
if(m_cur_scanline >= m_scanlines.size()) return false;
|
||||
const scanline_data& sl_this = m_scanlines[m_cur_scanline];
|
||||
|
||||
unsigned num_spans = sl_this.num_spans;
|
||||
|
@ -363,7 +366,8 @@ class scanline_storage_aa
|
|||
{
|
||||
sl.add_cells(sp.x, sp.len, covers);
|
||||
}
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
++m_cur_scanline;
|
||||
if(sl.num_spans())
|
||||
{
|
||||
|
@ -374,17 +378,18 @@ class scanline_storage_aa
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Specialization for embedded_scanline
|
||||
bool sweep_scanline(embedded_scanline& sl)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (m_cur_scanline >= m_scanlines.size())
|
||||
return false;
|
||||
if(m_cur_scanline >= m_scanlines.size()) return false;
|
||||
sl.init(m_cur_scanline);
|
||||
++m_cur_scanline;
|
||||
} while (sl.num_spans() == 0);
|
||||
}
|
||||
while(sl.num_spans() == 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -415,11 +420,13 @@ class scanline_storage_aa
|
|||
{
|
||||
size += sizeof(T) * unsigned(sp.len); // covers
|
||||
}
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
static void write_int32(int8u* dst, int32 val)
|
||||
{
|
||||
|
@ -429,6 +436,7 @@ class scanline_storage_aa
|
|||
dst[3] = ((const int8u*)&val)[3];
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void serialize(int8u* data) const
|
||||
{
|
||||
|
@ -479,11 +487,13 @@ class scanline_storage_aa
|
|||
memcpy(data, covers, unsigned(sp.len) * sizeof(T));
|
||||
data += sizeof(T) * unsigned(sp.len);
|
||||
}
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
write_int32(size_ptr, int32(unsigned(data - size_ptr)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
const scanline_data& scanline_by_index(unsigned i) const
|
||||
{
|
||||
|
@ -491,10 +501,16 @@ class scanline_storage_aa
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
const span_data& span_by_index(unsigned i) const { return (i < m_spans.size()) ? m_spans[i] : m_fake_span; }
|
||||
const span_data& span_by_index(unsigned i) const
|
||||
{
|
||||
return (i < m_spans.size()) ? m_spans[i] : m_fake_span;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
const T* covers_by_index(int i) const { return m_covers[i]; }
|
||||
const T* covers_by_index(int i) const
|
||||
{
|
||||
return m_covers[i];
|
||||
}
|
||||
|
||||
private:
|
||||
scanline_cell_storage<T> m_covers;
|
||||
|
@ -509,13 +525,16 @@ class scanline_storage_aa
|
|||
unsigned m_cur_scanline;
|
||||
};
|
||||
|
||||
|
||||
typedef scanline_storage_aa<int8u> scanline_storage_aa8; //--------scanline_storage_aa8
|
||||
typedef scanline_storage_aa<int16u> scanline_storage_aa16; //--------scanline_storage_aa16
|
||||
typedef scanline_storage_aa<int32u> scanline_storage_aa32; //--------scanline_storage_aa32
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------serialized_scanlines_adaptor_aa
|
||||
template<class T>
|
||||
class serialized_scanlines_adaptor_aa
|
||||
template<class T> class serialized_scanlines_adaptor_aa
|
||||
{
|
||||
public:
|
||||
typedef T cover_type;
|
||||
|
@ -537,12 +556,10 @@ class serialized_scanlines_adaptor_aa
|
|||
const T* covers;
|
||||
};
|
||||
|
||||
const_iterator()
|
||||
: m_ptr(0)
|
||||
{}
|
||||
const_iterator(const embedded_scanline& sl)
|
||||
: m_ptr(sl.m_ptr)
|
||||
, m_dx(sl.m_dx)
|
||||
const_iterator() : m_ptr(0) {}
|
||||
const_iterator(const embedded_scanline& sl) :
|
||||
m_ptr(sl.m_ptr),
|
||||
m_dx(sl.m_dx)
|
||||
{
|
||||
init_span();
|
||||
}
|
||||
|
@ -588,12 +605,9 @@ class serialized_scanlines_adaptor_aa
|
|||
|
||||
friend class const_iterator;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
embedded_scanline()
|
||||
: m_ptr(0)
|
||||
, m_y(0)
|
||||
, m_num_spans(0)
|
||||
{}
|
||||
embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
void reset(int, int) {}
|
||||
|
@ -601,6 +615,7 @@ class serialized_scanlines_adaptor_aa
|
|||
int y() const { return m_y; }
|
||||
const_iterator begin() const { return const_iterator(*this); }
|
||||
|
||||
|
||||
private:
|
||||
//-----------------------------------------------------------------
|
||||
int read_int32()
|
||||
|
@ -630,31 +645,34 @@ class serialized_scanlines_adaptor_aa
|
|||
int m_dx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
serialized_scanlines_adaptor_aa()
|
||||
: m_data(0)
|
||||
, m_end(0)
|
||||
, m_ptr(0)
|
||||
, m_dx(0)
|
||||
, m_dy(0)
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
serialized_scanlines_adaptor_aa() :
|
||||
m_data(0),
|
||||
m_end(0),
|
||||
m_ptr(0),
|
||||
m_dx(0),
|
||||
m_dy(0),
|
||||
m_min_x(0x7FFFFFFF),
|
||||
m_min_y(0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
serialized_scanlines_adaptor_aa(const int8u* data, unsigned size, double dx, double dy)
|
||||
: m_data(data)
|
||||
, m_end(data + size)
|
||||
, m_ptr(data)
|
||||
, m_dx(iround(dx))
|
||||
, m_dy(iround(dy))
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
serialized_scanlines_adaptor_aa(const int8u* data, unsigned size,
|
||||
double dx, double dy) :
|
||||
m_data(data),
|
||||
m_end(data + size),
|
||||
m_ptr(data),
|
||||
m_dx(iround(dx)),
|
||||
m_dy(iround(dy)),
|
||||
m_min_x(0x7FFFFFFF),
|
||||
m_min_y(0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -717,14 +735,12 @@ class serialized_scanlines_adaptor_aa
|
|||
int max_y() const { return m_max_y; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
bool sweep_scanline(Scanline& sl)
|
||||
template<class Scanline> bool sweep_scanline(Scanline& sl)
|
||||
{
|
||||
sl.reset_spans();
|
||||
for(;;)
|
||||
{
|
||||
if (m_ptr >= m_end)
|
||||
return false;
|
||||
if(m_ptr >= m_end) return false;
|
||||
|
||||
read_int32(); // Skip scanline size in bytes
|
||||
int y = read_int32() + m_dy;
|
||||
|
@ -745,7 +761,8 @@ class serialized_scanlines_adaptor_aa
|
|||
sl.add_cells(x, len, m_ptr);
|
||||
m_ptr += len * sizeof(T);
|
||||
}
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
|
||||
if(sl.num_spans())
|
||||
{
|
||||
|
@ -756,19 +773,20 @@ class serialized_scanlines_adaptor_aa
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Specialization for embedded_scanline
|
||||
bool sweep_scanline(embedded_scanline& sl)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (m_ptr >= m_end)
|
||||
return false;
|
||||
if(m_ptr >= m_end) return false;
|
||||
|
||||
unsigned byte_size = read_int32u();
|
||||
sl.init(m_ptr, m_dx, m_dy);
|
||||
m_ptr += byte_size - sizeof(int32);
|
||||
} while (sl.num_spans() == 0);
|
||||
}
|
||||
while(sl.num_spans() == 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -784,12 +802,14 @@ class serialized_scanlines_adaptor_aa
|
|||
int m_max_y;
|
||||
};
|
||||
|
||||
typedef serialized_scanlines_adaptor_aa<int8u> serialized_scanlines_adaptor_aa8; //----serialized_scanlines_adaptor_aa8
|
||||
typedef serialized_scanlines_adaptor_aa<int16u>
|
||||
serialized_scanlines_adaptor_aa16; //----serialized_scanlines_adaptor_aa16
|
||||
typedef serialized_scanlines_adaptor_aa<int32u>
|
||||
serialized_scanlines_adaptor_aa32; //----serialized_scanlines_adaptor_aa32
|
||||
|
||||
} // namespace agg
|
||||
|
||||
typedef serialized_scanlines_adaptor_aa<int8u> serialized_scanlines_adaptor_aa8; //----serialized_scanlines_adaptor_aa8
|
||||
typedef serialized_scanlines_adaptor_aa<int16u> serialized_scanlines_adaptor_aa16; //----serialized_scanlines_adaptor_aa16
|
||||
typedef serialized_scanlines_adaptor_aa<int32u> serialized_scanlines_adaptor_aa32; //----serialized_scanlines_adaptor_aa32
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
185
deps/agg/include/agg_scanline_storage_bin.h
vendored
185
deps/agg/include/agg_scanline_storage_bin.h
vendored
|
@ -21,6 +21,7 @@
|
|||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED
|
||||
#define AGG_SCANLINE_STORAGE_BIN_INCLUDED
|
||||
|
||||
|
@ -29,7 +30,9 @@
|
|||
#include <cmath>
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------scanline_storage_bin
|
||||
class scanline_storage_bin
|
||||
|
@ -50,6 +53,7 @@ class scanline_storage_bin
|
|||
unsigned start_span;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
class embedded_scanline
|
||||
{
|
||||
|
@ -59,12 +63,10 @@ class scanline_storage_bin
|
|||
class const_iterator
|
||||
{
|
||||
public:
|
||||
const_iterator()
|
||||
: m_storage(0)
|
||||
{}
|
||||
const_iterator(const embedded_scanline& sl)
|
||||
: m_storage(sl.m_storage)
|
||||
, m_span_idx(sl.m_scanline.start_span)
|
||||
const_iterator() : m_storage(0) {}
|
||||
const_iterator(const embedded_scanline& sl) :
|
||||
m_storage(sl.m_storage),
|
||||
m_span_idx(sl.m_scanline.start_span)
|
||||
{
|
||||
m_span = m_storage->span_by_index(m_span_idx);
|
||||
}
|
||||
|
@ -86,9 +88,10 @@ class scanline_storage_bin
|
|||
|
||||
friend class const_iterator;
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
embedded_scanline(const scanline_storage_bin& storage)
|
||||
: m_storage(&storage)
|
||||
embedded_scanline(const scanline_storage_bin& storage) :
|
||||
m_storage(&storage)
|
||||
{
|
||||
setup(0);
|
||||
}
|
||||
|
@ -112,16 +115,16 @@ class scanline_storage_bin
|
|||
unsigned m_scanline_idx;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
scanline_storage_bin()
|
||||
: m_spans(256 - 2)
|
||||
, // Block increment size
|
||||
m_scanlines()
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
, m_cur_scanline(0)
|
||||
scanline_storage_bin() :
|
||||
m_spans(256-2), // Block increment size
|
||||
m_scanlines(),
|
||||
m_min_x( 0x7FFFFFFF),
|
||||
m_min_y( 0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF),
|
||||
m_cur_scanline(0)
|
||||
{
|
||||
m_fake_scanline.y = 0;
|
||||
m_fake_scanline.num_spans = 0;
|
||||
|
@ -144,16 +147,13 @@ class scanline_storage_bin
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
void render(const Scanline& sl)
|
||||
template<class Scanline> void render(const Scanline& sl)
|
||||
{
|
||||
scanline_data sl_this;
|
||||
|
||||
int y = sl.y();
|
||||
if (y < m_min_y)
|
||||
m_min_y = y;
|
||||
if (y > m_max_y)
|
||||
m_max_y = y;
|
||||
if(y < m_min_y) m_min_y = y;
|
||||
if(y > m_max_y) m_max_y = y;
|
||||
|
||||
sl_this.y = y;
|
||||
sl_this.num_spans = sl.num_spans();
|
||||
|
@ -169,17 +169,15 @@ class scanline_storage_bin
|
|||
m_spans.add(sp);
|
||||
int x1 = sp.x;
|
||||
int x2 = sp.x + sp.len - 1;
|
||||
if (x1 < m_min_x)
|
||||
m_min_x = x1;
|
||||
if (x2 > m_max_x)
|
||||
m_max_x = x2;
|
||||
if (--num_spans == 0)
|
||||
break;
|
||||
if(x1 < m_min_x) m_min_x = x1;
|
||||
if(x2 > m_max_x) m_max_x = x2;
|
||||
if(--num_spans == 0) break;
|
||||
++span_iterator;
|
||||
}
|
||||
m_scanlines.add(sl_this);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Iterate scanlines interface
|
||||
int min_x() const { return m_min_x; }
|
||||
|
@ -194,15 +192,14 @@ class scanline_storage_bin
|
|||
return m_scanlines.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
bool sweep_scanline(Scanline& sl)
|
||||
template<class Scanline> bool sweep_scanline(Scanline& sl)
|
||||
{
|
||||
sl.reset_spans();
|
||||
for(;;)
|
||||
{
|
||||
if (m_cur_scanline >= m_scanlines.size())
|
||||
return false;
|
||||
if(m_cur_scanline >= m_scanlines.size()) return false;
|
||||
const scanline_data& sl_this = m_scanlines[m_cur_scanline];
|
||||
|
||||
unsigned num_spans = sl_this.num_spans;
|
||||
|
@ -211,7 +208,8 @@ class scanline_storage_bin
|
|||
{
|
||||
const span_data& sp = m_spans[span_idx++];
|
||||
sl.add_span(sp.x, sp.len, cover_full);
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
|
||||
++m_cur_scanline;
|
||||
if(sl.num_spans())
|
||||
|
@ -223,20 +221,22 @@ class scanline_storage_bin
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Specialization for embedded_scanline
|
||||
bool sweep_scanline(embedded_scanline& sl)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (m_cur_scanline >= m_scanlines.size())
|
||||
return false;
|
||||
if(m_cur_scanline >= m_scanlines.size()) return false;
|
||||
sl.setup(m_cur_scanline);
|
||||
++m_cur_scanline;
|
||||
} while (sl.num_spans() == 0);
|
||||
}
|
||||
while(sl.num_spans() == 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
unsigned byte_size() const
|
||||
{
|
||||
|
@ -251,6 +251,7 @@ class scanline_storage_bin
|
|||
return size;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
static void write_int32(int8u* dst, int32 val)
|
||||
{
|
||||
|
@ -260,6 +261,7 @@ class scanline_storage_bin
|
|||
dst[3] = ((const int8u*)&val)[3];
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void serialize(int8u* data) const
|
||||
{
|
||||
|
@ -295,10 +297,12 @@ class scanline_storage_bin
|
|||
|
||||
write_int32(data, sp.len); // len
|
||||
data += sizeof(int32);
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
const scanline_data& scanline_by_index(unsigned i) const
|
||||
{
|
||||
|
@ -306,7 +310,11 @@ class scanline_storage_bin
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
const span_data& span_by_index(unsigned i) const { return (i < m_spans.size()) ? m_spans[i] : m_fake_span; }
|
||||
const span_data& span_by_index(unsigned i) const
|
||||
{
|
||||
return (i < m_spans.size()) ? m_spans[i] : m_fake_span;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
pod_bvector<span_data, 10> m_spans;
|
||||
|
@ -320,6 +328,18 @@ class scanline_storage_bin
|
|||
unsigned m_cur_scanline;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------serialized_scanlines_adaptor_bin
|
||||
class serialized_scanlines_adaptor_bin
|
||||
{
|
||||
|
@ -341,12 +361,10 @@ class serialized_scanlines_adaptor_bin
|
|||
int32 len;
|
||||
};
|
||||
|
||||
const_iterator()
|
||||
: m_ptr(0)
|
||||
{}
|
||||
const_iterator(const embedded_scanline& sl)
|
||||
: m_ptr(sl.m_ptr)
|
||||
, m_dx(sl.m_dx)
|
||||
const_iterator() : m_ptr(0) {}
|
||||
const_iterator(const embedded_scanline& sl) :
|
||||
m_ptr(sl.m_ptr),
|
||||
m_dx(sl.m_dx)
|
||||
{
|
||||
m_span.x = read_int32() + m_dx;
|
||||
m_span.len = read_int32();
|
||||
|
@ -379,12 +397,9 @@ class serialized_scanlines_adaptor_bin
|
|||
|
||||
friend class const_iterator;
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
embedded_scanline()
|
||||
: m_ptr(0)
|
||||
, m_y(0)
|
||||
, m_num_spans(0)
|
||||
{}
|
||||
embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void reset(int, int) {}
|
||||
|
@ -392,6 +407,7 @@ class serialized_scanlines_adaptor_bin
|
|||
int y() const { return m_y; }
|
||||
const_iterator begin() const { return const_iterator(*this); }
|
||||
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------
|
||||
int read_int32()
|
||||
|
@ -421,31 +437,34 @@ class serialized_scanlines_adaptor_bin
|
|||
int m_dx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
serialized_scanlines_adaptor_bin()
|
||||
: m_data(0)
|
||||
, m_end(0)
|
||||
, m_ptr(0)
|
||||
, m_dx(0)
|
||||
, m_dy(0)
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
serialized_scanlines_adaptor_bin() :
|
||||
m_data(0),
|
||||
m_end(0),
|
||||
m_ptr(0),
|
||||
m_dx(0),
|
||||
m_dy(0),
|
||||
m_min_x(0x7FFFFFFF),
|
||||
m_min_y(0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
serialized_scanlines_adaptor_bin(const int8u* data, unsigned size, double dx, double dy)
|
||||
: m_data(data)
|
||||
, m_end(data + size)
|
||||
, m_ptr(data)
|
||||
, m_dx(iround(dx))
|
||||
, m_dy(iround(dy))
|
||||
, m_min_x(0x7FFFFFFF)
|
||||
, m_min_y(0x7FFFFFFF)
|
||||
, m_max_x(-0x7FFFFFFF)
|
||||
, m_max_y(-0x7FFFFFFF)
|
||||
serialized_scanlines_adaptor_bin(const int8u* data, unsigned size,
|
||||
double dx, double dy) :
|
||||
m_data(data),
|
||||
m_end(data + size),
|
||||
m_ptr(data),
|
||||
m_dx(iround(dx)),
|
||||
m_dy(iround(dy)),
|
||||
m_min_x(0x7FFFFFFF),
|
||||
m_min_y(0x7FFFFFFF),
|
||||
m_max_x(-0x7FFFFFFF),
|
||||
m_max_y(-0x7FFFFFFF)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -497,14 +516,12 @@ class serialized_scanlines_adaptor_bin
|
|||
int max_y() const { return m_max_y; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<class Scanline>
|
||||
bool sweep_scanline(Scanline& sl)
|
||||
template<class Scanline> bool sweep_scanline(Scanline& sl)
|
||||
{
|
||||
sl.reset_spans();
|
||||
for(;;)
|
||||
{
|
||||
if (m_ptr >= m_end)
|
||||
return false;
|
||||
if(m_ptr >= m_end) return false;
|
||||
|
||||
int y = read_int32() + m_dy;
|
||||
unsigned num_spans = read_int32();
|
||||
|
@ -514,10 +531,10 @@ class serialized_scanlines_adaptor_bin
|
|||
int x = read_int32() + m_dx;
|
||||
int len = read_int32();
|
||||
|
||||
if (len < 0)
|
||||
len = -len;
|
||||
if(len < 0) len = -len;
|
||||
sl.add_span(x, unsigned(len), cover_full);
|
||||
} while (--num_spans);
|
||||
}
|
||||
while(--num_spans);
|
||||
|
||||
if(sl.num_spans())
|
||||
{
|
||||
|
@ -528,14 +545,14 @@ class serialized_scanlines_adaptor_bin
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Specialization for embedded_scanline
|
||||
bool sweep_scanline(embedded_scanline& sl)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (m_ptr >= m_end)
|
||||
return false;
|
||||
if(m_ptr >= m_end) return false;
|
||||
|
||||
sl.init(m_ptr, m_dx, m_dy);
|
||||
|
||||
|
@ -544,7 +561,8 @@ class serialized_scanlines_adaptor_bin
|
|||
read_int32(); // Y
|
||||
int num_spans = read_int32(); // num_spans
|
||||
m_ptr += num_spans * sizeof(int32) * 2;
|
||||
} while (sl.num_spans() == 0);
|
||||
}
|
||||
while(sl.num_spans() == 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -560,6 +578,9 @@ class serialized_scanlines_adaptor_bin
|
|||
int m_max_y;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
109
deps/agg/include/agg_scanline_u.h
vendored
109
deps/agg/include/agg_scanline_u.h
vendored
|
@ -26,7 +26,8 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//=============================================================scanline_u8
|
||||
//
|
||||
// Unpacked scanline container class
|
||||
|
@ -124,10 +125,10 @@ class scanline_u8
|
|||
typedef const span* const_iterator;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
scanline_u8()
|
||||
: m_min_x(0)
|
||||
, m_last_x(0x7FFFFFF0)
|
||||
, m_cur_span(0)
|
||||
scanline_u8() :
|
||||
m_min_x(0),
|
||||
m_last_x(0x7FFFFFF0),
|
||||
m_cur_span(0)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -202,7 +203,10 @@ class scanline_u8
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int y) { m_y = y; }
|
||||
void finalize(int y)
|
||||
{
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_spans()
|
||||
|
@ -230,6 +234,9 @@ class scanline_u8
|
|||
span* m_cur_span;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================scanline_u8_am
|
||||
//
|
||||
// The scanline container with alpha-masking
|
||||
|
@ -244,14 +251,8 @@ class scanline_u8_am : public scanline_u8
|
|||
typedef base_type::cover_type cover_type;
|
||||
typedef base_type::coord_type coord_type;
|
||||
|
||||
scanline_u8_am()
|
||||
: base_type()
|
||||
, m_alpha_mask(0)
|
||||
{}
|
||||
scanline_u8_am(const AlphaMask& am)
|
||||
: base_type()
|
||||
, m_alpha_mask(&am)
|
||||
{}
|
||||
scanline_u8_am() : base_type(), m_alpha_mask(0) {}
|
||||
scanline_u8_am(const AlphaMask& am) : base_type(), m_alpha_mask(&am) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int span_y)
|
||||
|
@ -263,9 +264,13 @@ class scanline_u8_am : public scanline_u8
|
|||
unsigned count = base_type::num_spans();
|
||||
do
|
||||
{
|
||||
m_alpha_mask->combine_hspan(span->x, base_type::y(), span->covers, span->len);
|
||||
m_alpha_mask->combine_hspan(span->x,
|
||||
base_type::y(),
|
||||
span->covers,
|
||||
span->len);
|
||||
++span;
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,6 +278,9 @@ class scanline_u8_am : public scanline_u8
|
|||
const AlphaMask* m_alpha_mask;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//===========================================================scanline32_u8
|
||||
class scanline32_u8
|
||||
{
|
||||
|
@ -285,11 +293,8 @@ class scanline32_u8
|
|||
struct span
|
||||
{
|
||||
span() {}
|
||||
span(coord_type x_, coord_type len_, cover_type* covers_)
|
||||
: x(x_)
|
||||
, len(len_)
|
||||
, covers(covers_)
|
||||
{}
|
||||
span(coord_type x_, coord_type len_, cover_type* covers_) :
|
||||
x(x_), len(len_), covers(covers_) {}
|
||||
|
||||
coord_type x;
|
||||
coord_type len;
|
||||
|
@ -302,9 +307,9 @@ class scanline32_u8
|
|||
class const_iterator
|
||||
{
|
||||
public:
|
||||
const_iterator(const span_array_type& spans)
|
||||
: m_spans(spans)
|
||||
, m_span_idx(0)
|
||||
const_iterator(const span_array_type& spans) :
|
||||
m_spans(spans),
|
||||
m_span_idx(0)
|
||||
{}
|
||||
|
||||
const span& operator*() const { return m_spans[m_span_idx]; }
|
||||
|
@ -321,9 +326,9 @@ class scanline32_u8
|
|||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator(span_array_type& spans)
|
||||
: m_spans(spans)
|
||||
, m_span_idx(0)
|
||||
iterator(span_array_type& spans) :
|
||||
m_spans(spans),
|
||||
m_span_idx(0)
|
||||
{}
|
||||
|
||||
span& operator*() { return m_spans[m_span_idx]; }
|
||||
|
@ -336,11 +341,13 @@ class scanline32_u8
|
|||
unsigned m_span_idx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
scanline32_u8()
|
||||
: m_min_x(0)
|
||||
, m_last_x(0x7FFFFFF0)
|
||||
, m_covers()
|
||||
scanline32_u8() :
|
||||
m_min_x(0),
|
||||
m_last_x(0x7FFFFFF0),
|
||||
m_covers()
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -383,7 +390,9 @@ class scanline32_u8
|
|||
}
|
||||
else
|
||||
{
|
||||
m_spans.add(span(coord_type(x + m_min_x), coord_type(len), &m_covers[x]));
|
||||
m_spans.add(span(coord_type(x + m_min_x),
|
||||
coord_type(len),
|
||||
&m_covers[x]));
|
||||
}
|
||||
m_last_x = x + len - 1;
|
||||
}
|
||||
|
@ -399,13 +408,18 @@ class scanline32_u8
|
|||
}
|
||||
else
|
||||
{
|
||||
m_spans.add(span(coord_type(x + m_min_x), coord_type(len), &m_covers[x]));
|
||||
m_spans.add(span(coord_type(x + m_min_x),
|
||||
coord_type(len),
|
||||
&m_covers[x]));
|
||||
}
|
||||
m_last_x = x + len - 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int y) { m_y = y; }
|
||||
void finalize(int y)
|
||||
{
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void reset_spans()
|
||||
|
@ -432,6 +446,9 @@ class scanline32_u8
|
|||
span_array_type m_spans;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//========================================================scanline32_u8_am
|
||||
//
|
||||
// The scanline container with alpha-masking
|
||||
|
@ -447,14 +464,9 @@ class scanline32_u8_am : public scanline32_u8
|
|||
typedef base_type::cover_type cover_type;
|
||||
typedef base_type::coord_type coord_type;
|
||||
|
||||
scanline32_u8_am()
|
||||
: base_type()
|
||||
, m_alpha_mask(0)
|
||||
{}
|
||||
scanline32_u8_am(const AlphaMask& am)
|
||||
: base_type()
|
||||
, m_alpha_mask(&am)
|
||||
{}
|
||||
|
||||
scanline32_u8_am() : base_type(), m_alpha_mask(0) {}
|
||||
scanline32_u8_am(const AlphaMask& am) : base_type(), m_alpha_mask(&am) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void finalize(int span_y)
|
||||
|
@ -466,9 +478,13 @@ class scanline32_u8_am : public scanline32_u8
|
|||
unsigned count = base_type::num_spans();
|
||||
do
|
||||
{
|
||||
m_alpha_mask->combine_hspan(span->x, base_type::y(), span->covers, span->len);
|
||||
m_alpha_mask->combine_hspan(span->x,
|
||||
base_type::y(),
|
||||
span->covers,
|
||||
span->len);
|
||||
++span;
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,6 +492,9 @@ class scanline32_u8_am : public scanline32_u8
|
|||
const AlphaMask* m_alpha_mask;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
12
deps/agg/include/agg_shorten_path.h
vendored
12
deps/agg/include/agg_shorten_path.h
vendored
|
@ -19,7 +19,8 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_vertex_sequence.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===========================================================shorten_path
|
||||
template<class VertexSequence>
|
||||
|
@ -34,8 +35,7 @@ void shorten_path(VertexSequence& vs, double s, unsigned closed = 0)
|
|||
while(n)
|
||||
{
|
||||
d = vs[n].dist;
|
||||
if (d > s)
|
||||
break;
|
||||
if(d > s) break;
|
||||
vs.remove_last();
|
||||
s -= d;
|
||||
--n;
|
||||
|
@ -54,13 +54,13 @@ void shorten_path(VertexSequence& vs, double s, unsigned closed = 0)
|
|||
double y = prev.y + (last.y - prev.y) * d;
|
||||
last.x = x;
|
||||
last.y = y;
|
||||
if (!prev(last))
|
||||
vs.remove_last();
|
||||
if(!prev(last)) vs.remove_last();
|
||||
vs.close(closed != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
19
deps/agg/include/agg_simul_eq.h
vendored
19
deps/agg/include/agg_simul_eq.h
vendored
|
@ -22,11 +22,11 @@
|
|||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=============================================================swap_arrays
|
||||
template<class T>
|
||||
void swap_arrays(T* a1, T* a2, unsigned n)
|
||||
template<class T> void swap_arrays(T* a1, T* a2, unsigned n)
|
||||
{
|
||||
unsigned i;
|
||||
for(i = 0; i < n; i++)
|
||||
|
@ -37,6 +37,7 @@ void swap_arrays(T* a1, T* a2, unsigned n)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================matrix_pivot
|
||||
template<unsigned Rows, unsigned Cols>
|
||||
struct matrix_pivot
|
||||
|
@ -71,12 +72,15 @@ struct matrix_pivot
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//===============================================================simul_eq
|
||||
template<unsigned Size, unsigned RightCols>
|
||||
struct simul_eq
|
||||
{
|
||||
static bool
|
||||
solve(const double left[Size][Size], const double right[Size][RightCols], double result[Size][RightCols])
|
||||
static bool solve(const double left[Size][Size],
|
||||
const double right[Size][RightCols],
|
||||
double result[Size][RightCols])
|
||||
{
|
||||
unsigned i, j, k;
|
||||
double a1;
|
||||
|
@ -119,6 +123,7 @@ struct simul_eq
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for(k = 0; k < RightCols; k++)
|
||||
{
|
||||
int m;
|
||||
|
@ -133,8 +138,10 @@ struct simul_eq
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
11
deps/agg/include/agg_span_allocator.h
vendored
11
deps/agg/include/agg_span_allocator.h
vendored
|
@ -18,10 +18,10 @@
|
|||
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//----------------------------------------------------------span_allocator
|
||||
template<class ColorT>
|
||||
class span_allocator
|
||||
template<class ColorT> class span_allocator
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
|
@ -46,6 +46,9 @@ class span_allocator
|
|||
private:
|
||||
pod_array<color_type> m_span;
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
14
deps/agg/include/agg_span_converter.h
vendored
14
deps/agg/include/agg_span_converter.h
vendored
|
@ -18,18 +18,16 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//----------------------------------------------------------span_converter
|
||||
template<class SpanGenerator, class SpanConverter>
|
||||
class span_converter
|
||||
template<class SpanGenerator, class SpanConverter> class span_converter
|
||||
{
|
||||
public:
|
||||
typedef typename SpanGenerator::color_type color_type;
|
||||
|
||||
span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv)
|
||||
: m_span_gen(&span_gen)
|
||||
, m_span_cnv(&span_cnv)
|
||||
{}
|
||||
span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv) :
|
||||
m_span_gen(&span_gen), m_span_cnv(&span_cnv) {}
|
||||
|
||||
void attach_generator(SpanGenerator& span_gen) { m_span_gen = &span_gen; }
|
||||
void attach_converter(SpanConverter& span_cnv) { m_span_cnv = &span_cnv; }
|
||||
|
@ -53,6 +51,6 @@ class span_converter
|
|||
SpanConverter* m_span_cnv;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
88
deps/agg/include/agg_span_gouraud.h
vendored
88
deps/agg/include/agg_span_gouraud.h
vendored
|
@ -19,11 +19,11 @@
|
|||
#include "agg_basics.h"
|
||||
#include "agg_math.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//============================================================span_gouraud
|
||||
template<class ColorT>
|
||||
class span_gouraud
|
||||
template<class ColorT> class span_gouraud
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
|
@ -36,8 +36,8 @@ class span_gouraud
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_gouraud()
|
||||
: m_vertex(0)
|
||||
span_gouraud() :
|
||||
m_vertex(0)
|
||||
{
|
||||
m_cmd[0] = path_cmd_stop;
|
||||
}
|
||||
|
@ -46,14 +46,11 @@ class span_gouraud
|
|||
span_gouraud(const color_type& c1,
|
||||
const color_type& c2,
|
||||
const color_type& c3,
|
||||
double x1,
|
||||
double y1,
|
||||
double x2,
|
||||
double y2,
|
||||
double x3,
|
||||
double y3,
|
||||
double d)
|
||||
: m_vertex(0)
|
||||
double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double d) :
|
||||
m_vertex(0)
|
||||
{
|
||||
colors(c1, c2, c3);
|
||||
triangle(x1, y1, x2, y2, x3, y3, d);
|
||||
|
@ -74,7 +71,10 @@ class span_gouraud
|
|||
// It's necessary to achieve numerical stability.
|
||||
// However, the coordinates to interpolate colors are calculated
|
||||
// as miter joins (calc_intersection).
|
||||
void triangle(double x1, double y1, double x2, double y2, double x3, double y3, double d)
|
||||
void triangle(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double d)
|
||||
{
|
||||
m_coord[0].x = m_x[0] = x1;
|
||||
m_coord[0].y = m_y[0] = y1;
|
||||
|
@ -89,48 +89,22 @@ class span_gouraud
|
|||
|
||||
if(d != 0.0)
|
||||
{
|
||||
dilate_triangle(m_coord[0].x,
|
||||
m_coord[0].y,
|
||||
m_coord[1].x,
|
||||
m_coord[1].y,
|
||||
m_coord[2].x,
|
||||
m_coord[2].y,
|
||||
m_x,
|
||||
m_y,
|
||||
d);
|
||||
dilate_triangle(m_coord[0].x, m_coord[0].y,
|
||||
m_coord[1].x, m_coord[1].y,
|
||||
m_coord[2].x, m_coord[2].y,
|
||||
m_x, m_y, d);
|
||||
|
||||
calc_intersection(m_x[4],
|
||||
m_y[4],
|
||||
m_x[5],
|
||||
m_y[5],
|
||||
m_x[0],
|
||||
m_y[0],
|
||||
m_x[1],
|
||||
m_y[1],
|
||||
&m_coord[0].x,
|
||||
&m_coord[0].y);
|
||||
calc_intersection(m_x[4], m_y[4], m_x[5], m_y[5],
|
||||
m_x[0], m_y[0], m_x[1], m_y[1],
|
||||
&m_coord[0].x, &m_coord[0].y);
|
||||
|
||||
calc_intersection(m_x[0],
|
||||
m_y[0],
|
||||
m_x[1],
|
||||
m_y[1],
|
||||
m_x[2],
|
||||
m_y[2],
|
||||
m_x[3],
|
||||
m_y[3],
|
||||
&m_coord[1].x,
|
||||
&m_coord[1].y);
|
||||
calc_intersection(m_x[0], m_y[0], m_x[1], m_y[1],
|
||||
m_x[2], m_y[2], m_x[3], m_y[3],
|
||||
&m_coord[1].x, &m_coord[1].y);
|
||||
|
||||
calc_intersection(m_x[2],
|
||||
m_y[2],
|
||||
m_x[3],
|
||||
m_y[3],
|
||||
m_x[4],
|
||||
m_y[4],
|
||||
m_x[5],
|
||||
m_y[5],
|
||||
&m_coord[2].x,
|
||||
&m_coord[2].y);
|
||||
calc_intersection(m_x[2], m_y[2], m_x[3], m_y[3],
|
||||
m_x[4], m_y[4], m_x[5], m_y[5],
|
||||
&m_coord[2].x, &m_coord[2].y);
|
||||
m_cmd[3] = path_cmd_line_to;
|
||||
m_cmd[4] = path_cmd_line_to;
|
||||
m_cmd[5] = path_cmd_line_to;
|
||||
|
@ -140,7 +114,10 @@ class span_gouraud
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// Vertex Source Interface to feed the coordinates to the rasterizer
|
||||
void rewind(unsigned) { m_vertex = 0; }
|
||||
void rewind(unsigned)
|
||||
{
|
||||
m_vertex = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
unsigned vertex(double* x, double* y)
|
||||
|
@ -189,6 +166,7 @@ class span_gouraud
|
|||
unsigned m_vertex;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
63
deps/agg/include/agg_span_gouraud_gray.h
vendored
63
deps/agg/include/agg_span_gouraud_gray.h
vendored
|
@ -29,18 +29,22 @@
|
|||
#include "agg_dda_line.h"
|
||||
#include "agg_span_gouraud.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=======================================================span_gouraud_gray
|
||||
template<class ColorT>
|
||||
class span_gouraud_gray : public span_gouraud<ColorT>
|
||||
template<class ColorT> class span_gouraud_gray : public span_gouraud<ColorT>
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef span_gouraud<color_type> base_type;
|
||||
typedef typename base_type::coord_type coord_type;
|
||||
enum subpixel_scale_e { subpixel_shift = 4, subpixel_scale = 1 << subpixel_shift };
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = 4,
|
||||
subpixel_scale = 1 << subpixel_shift
|
||||
};
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -62,10 +66,8 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
void calc(double y)
|
||||
{
|
||||
double k = (y - m_y1) * m_1dy;
|
||||
if (k < 0.0)
|
||||
k = 0.0;
|
||||
if (k > 1.0)
|
||||
k = 1.0;
|
||||
if(k < 0.0) k = 0.0;
|
||||
if(k > 1.0) k = 1.0;
|
||||
m_v = m_v1 + iround(m_dv * k);
|
||||
m_a = m_a1 + iround(m_da * k);
|
||||
m_x = iround((m_x1 + m_dx * k) * subpixel_scale);
|
||||
|
@ -84,20 +86,18 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
int m_x;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
span_gouraud_gray() {}
|
||||
span_gouraud_gray(const color_type& c1,
|
||||
const color_type& c2,
|
||||
const color_type& c3,
|
||||
double x1,
|
||||
double y1,
|
||||
double x2,
|
||||
double y2,
|
||||
double x3,
|
||||
double y3,
|
||||
double d = 0)
|
||||
: base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
|
||||
double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double d = 0) :
|
||||
base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -108,7 +108,9 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
|
||||
m_y2 = int(coord[1].y);
|
||||
|
||||
m_swap = cross_product(coord[0].x, coord[0].y, coord[2].x, coord[2].y, coord[1].x, coord[1].y) < 0.0;
|
||||
m_swap = cross_product(coord[0].x, coord[0].y,
|
||||
coord[2].x, coord[2].y,
|
||||
coord[1].x, coord[1].y) < 0.0;
|
||||
|
||||
m_c1.init(coord[0], coord[2]);
|
||||
m_c2.init(coord[0], coord[1]);
|
||||
|
@ -150,8 +152,7 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
// and protect it from division by zero
|
||||
//-------------------------
|
||||
int nlen = std::abs(pc2->m_x - pc1->m_x);
|
||||
if (nlen <= 0)
|
||||
nlen = 1;
|
||||
if(nlen <= 0) nlen = 1;
|
||||
|
||||
dda_line_interpolator<14> v(pc1->m_v, pc2->m_v, nlen);
|
||||
dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen);
|
||||
|
@ -179,14 +180,8 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
{
|
||||
vv = v.y();
|
||||
va = a.y();
|
||||
if (vv < 0)
|
||||
vv = 0;
|
||||
if (vv > lim)
|
||||
vv = lim;
|
||||
if (va < 0)
|
||||
va = 0;
|
||||
if (va > lim)
|
||||
va = lim;
|
||||
if(vv < 0) vv = 0; if(vv > lim) vv = lim;
|
||||
if(va < 0) va = 0; if(va > lim) va = lim;
|
||||
span->v = (value_type)vv;
|
||||
span->a = (value_type)va;
|
||||
v += subpixel_scale;
|
||||
|
@ -220,14 +215,8 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
{
|
||||
vv = v.y();
|
||||
va = a.y();
|
||||
if (vv < 0)
|
||||
vv = 0;
|
||||
if (vv > lim)
|
||||
vv = lim;
|
||||
if (va < 0)
|
||||
va = 0;
|
||||
if (va > lim)
|
||||
va = lim;
|
||||
if(vv < 0) vv = 0; if(vv > lim) vv = lim;
|
||||
if(va < 0) va = 0; if(va > lim) va = lim;
|
||||
span->v = (value_type)vv;
|
||||
span->a = (value_type)va;
|
||||
v += subpixel_scale;
|
||||
|
@ -237,6 +226,7 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool m_swap;
|
||||
int m_y2;
|
||||
|
@ -245,6 +235,7 @@ class span_gouraud_gray : public span_gouraud<ColorT>
|
|||
gray_calc m_c3;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
82
deps/agg/include/agg_span_gouraud_rgba.h
vendored
82
deps/agg/include/agg_span_gouraud_rgba.h
vendored
|
@ -29,18 +29,22 @@
|
|||
#include "agg_dda_line.h"
|
||||
#include "agg_span_gouraud.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//=======================================================span_gouraud_rgba
|
||||
template<class ColorT>
|
||||
class span_gouraud_rgba : public span_gouraud<ColorT>
|
||||
template<class ColorT> class span_gouraud_rgba : public span_gouraud<ColorT>
|
||||
{
|
||||
public:
|
||||
typedef ColorT color_type;
|
||||
typedef typename ColorT::value_type value_type;
|
||||
typedef span_gouraud<color_type> base_type;
|
||||
typedef typename base_type::coord_type coord_type;
|
||||
enum subpixel_scale_e { subpixel_shift = 4, subpixel_scale = 1 << subpixel_shift };
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = 4,
|
||||
subpixel_scale = 1 << subpixel_shift
|
||||
};
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -66,10 +70,8 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
void calc(double y)
|
||||
{
|
||||
double k = (y - m_y1) * m_1dy;
|
||||
if (k < 0.0)
|
||||
k = 0.0;
|
||||
if (k > 1.0)
|
||||
k = 1.0;
|
||||
if(k < 0.0) k = 0.0;
|
||||
if(k > 1.0) k = 1.0;
|
||||
m_r = m_r1 + iround(m_dr * k);
|
||||
m_g = m_g1 + iround(m_dg * k);
|
||||
m_b = m_b1 + iround(m_db * k);
|
||||
|
@ -103,14 +105,11 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
span_gouraud_rgba(const color_type& c1,
|
||||
const color_type& c2,
|
||||
const color_type& c3,
|
||||
double x1,
|
||||
double y1,
|
||||
double x2,
|
||||
double y2,
|
||||
double x3,
|
||||
double y3,
|
||||
double d = 0)
|
||||
: base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
|
||||
double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3,
|
||||
double d = 0) :
|
||||
base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -121,7 +120,9 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
|
||||
m_y2 = int(coord[1].y);
|
||||
|
||||
m_swap = cross_product(coord[0].x, coord[0].y, coord[2].x, coord[2].y, coord[1].x, coord[1].y) < 0.0;
|
||||
m_swap = cross_product(coord[0].x, coord[0].y,
|
||||
coord[2].x, coord[2].y,
|
||||
coord[1].x, coord[1].y) < 0.0;
|
||||
|
||||
m_rgba1.init(coord[0], coord[2]);
|
||||
m_rgba2.init(coord[0], coord[1]);
|
||||
|
@ -163,8 +164,7 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
// and protect it from division by zero
|
||||
//-------------------------
|
||||
int nlen = std::abs(pc2->m_x - pc1->m_x);
|
||||
if (nlen <= 0)
|
||||
nlen = 1;
|
||||
if(nlen <= 0) nlen = 1;
|
||||
|
||||
dda_line_interpolator<14> r(pc1->m_r, pc2->m_r, nlen);
|
||||
dda_line_interpolator<14> g(pc1->m_g, pc2->m_g, nlen);
|
||||
|
@ -198,22 +198,10 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
vg = g.y();
|
||||
vb = b.y();
|
||||
va = a.y();
|
||||
if (vr < 0)
|
||||
vr = 0;
|
||||
if (vr > lim)
|
||||
vr = lim;
|
||||
if (vg < 0)
|
||||
vg = 0;
|
||||
if (vg > lim)
|
||||
vg = lim;
|
||||
if (vb < 0)
|
||||
vb = 0;
|
||||
if (vb > lim)
|
||||
vb = lim;
|
||||
if (va < 0)
|
||||
va = 0;
|
||||
if (va > lim)
|
||||
va = lim;
|
||||
if(vr < 0) vr = 0; if(vr > lim) vr = lim;
|
||||
if(vg < 0) vg = 0; if(vg > lim) vg = lim;
|
||||
if(vb < 0) vb = 0; if(vb > lim) vb = lim;
|
||||
if(va < 0) va = 0; if(va > lim) va = lim;
|
||||
span->r = (value_type)vr;
|
||||
span->g = (value_type)vg;
|
||||
span->b = (value_type)vb;
|
||||
|
@ -257,22 +245,10 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
vg = g.y();
|
||||
vb = b.y();
|
||||
va = a.y();
|
||||
if (vr < 0)
|
||||
vr = 0;
|
||||
if (vr > lim)
|
||||
vr = lim;
|
||||
if (vg < 0)
|
||||
vg = 0;
|
||||
if (vg > lim)
|
||||
vg = lim;
|
||||
if (vb < 0)
|
||||
vb = 0;
|
||||
if (vb > lim)
|
||||
vb = lim;
|
||||
if (va < 0)
|
||||
va = 0;
|
||||
if (va > lim)
|
||||
va = lim;
|
||||
if(vr < 0) vr = 0; if(vr > lim) vr = lim;
|
||||
if(vg < 0) vg = 0; if(vg > lim) vg = lim;
|
||||
if(vb < 0) vb = 0; if(vb > lim) vb = lim;
|
||||
if(va < 0) va = 0; if(va > lim) va = lim;
|
||||
span->r = (value_type)vr;
|
||||
span->g = (value_type)vg;
|
||||
span->b = (value_type)vb;
|
||||
|
@ -294,6 +270,8 @@ class span_gouraud_rgba : public span_gouraud<ColorT>
|
|||
rgba_calc m_rgba3;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
152
deps/agg/include/agg_span_gradient.h
vendored
152
deps/agg/include/agg_span_gradient.h
vendored
|
@ -23,23 +23,35 @@
|
|||
#include "agg_math.h"
|
||||
#include "agg_array.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
enum gradient_subpixel_scale_e {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
enum gradient_subpixel_scale_e
|
||||
{
|
||||
gradient_subpixel_shift = 4, //-----gradient_subpixel_shift
|
||||
gradient_subpixel_scale = 1 << gradient_subpixel_shift, //-----gradient_subpixel_scale
|
||||
gradient_subpixel_mask = gradient_subpixel_scale - 1 //-----gradient_subpixel_mask
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==========================================================span_gradient
|
||||
template<class ColorT, class Interpolator, class GradientF, class ColorF>
|
||||
template<class ColorT,
|
||||
class Interpolator,
|
||||
class GradientF,
|
||||
class ColorF>
|
||||
class span_gradient
|
||||
{
|
||||
public:
|
||||
typedef Interpolator interpolator_type;
|
||||
typedef ColorT color_type;
|
||||
|
||||
enum downscale_shift_e { downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift };
|
||||
enum downscale_shift_e
|
||||
{
|
||||
downscale_shift = interpolator_type::subpixel_shift -
|
||||
gradient_subpixel_shift
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_gradient() {}
|
||||
|
@ -48,13 +60,12 @@ class span_gradient
|
|||
span_gradient(interpolator_type& inter,
|
||||
const GradientF& gradient_function,
|
||||
const ColorF& color_function,
|
||||
double d1,
|
||||
double d2)
|
||||
: m_interpolator(&inter)
|
||||
, m_gradient_function(&gradient_function)
|
||||
, m_color_function(&color_function)
|
||||
, m_d1(iround(d1 * gradient_subpixel_scale))
|
||||
, m_d2(iround(d2 * gradient_subpixel_scale))
|
||||
double d1, double d2) :
|
||||
m_interpolator(&inter),
|
||||
m_gradient_function(&gradient_function),
|
||||
m_color_function(&color_function),
|
||||
m_d1(iround(d1 * gradient_subpixel_scale)),
|
||||
m_d2(iround(d2 * gradient_subpixel_scale))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -78,21 +89,20 @@ class span_gradient
|
|||
void generate(color_type* span, int x, int y, unsigned len)
|
||||
{
|
||||
int dd = m_d2 - m_d1;
|
||||
if (dd < 1)
|
||||
dd = 1;
|
||||
if(dd < 1) dd = 1;
|
||||
m_interpolator->begin(x+0.5, y+0.5, len);
|
||||
do
|
||||
{
|
||||
m_interpolator->coordinates(&x, &y);
|
||||
int d = m_gradient_function->calculate(x >> downscale_shift, y >> downscale_shift, m_d2);
|
||||
int d = m_gradient_function->calculate(x >> downscale_shift,
|
||||
y >> downscale_shift, m_d2);
|
||||
d = ((d - m_d1) * (int)m_color_function->size()) / dd;
|
||||
if (d < 0)
|
||||
d = 0;
|
||||
if (d >= (int)m_color_function->size())
|
||||
d = m_color_function->size() - 1;
|
||||
if(d < 0) d = 0;
|
||||
if(d >= (int)m_color_function->size()) d = m_color_function->size() - 1;
|
||||
*span++ = (*m_color_function)[d];
|
||||
++(*m_interpolator);
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -103,6 +113,9 @@ class span_gradient
|
|||
int m_d2;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//=====================================================gradient_linear_color
|
||||
template<class ColorT>
|
||||
struct gradient_linear_color
|
||||
|
@ -110,14 +123,15 @@ struct gradient_linear_color
|
|||
typedef ColorT color_type;
|
||||
|
||||
gradient_linear_color() {}
|
||||
gradient_linear_color(const color_type& c1, const color_type& c2, unsigned size = 256)
|
||||
: m_c1(c1)
|
||||
, m_c2(c2)
|
||||
, m_size(size)
|
||||
{}
|
||||
gradient_linear_color(const color_type& c1, const color_type& c2,
|
||||
unsigned size = 256) :
|
||||
m_c1(c1), m_c2(c2), m_size(size) {}
|
||||
|
||||
unsigned size() const { return m_size; }
|
||||
color_type operator[](unsigned v) const { return m_c1.gradient(m_c2, double(v) / double(m_size - 1)); }
|
||||
color_type operator [] (unsigned v) const
|
||||
{
|
||||
return m_c1.gradient(m_c2, double(v) / double(m_size - 1));
|
||||
}
|
||||
|
||||
void colors(const color_type& c1, const color_type& c2, unsigned size = 256)
|
||||
{
|
||||
|
@ -131,19 +145,31 @@ struct gradient_linear_color
|
|||
unsigned m_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================gradient_circle
|
||||
class gradient_circle
|
||||
{
|
||||
// Actually the same as radial. Just for compatibility
|
||||
public:
|
||||
static AGG_INLINE int calculate(int x, int y, int) { return int(fast_sqrt(x * x + y * y)); }
|
||||
static AGG_INLINE int calculate(int x, int y, int)
|
||||
{
|
||||
return int(fast_sqrt(x*x + y*y));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//==========================================================gradient_radial
|
||||
class gradient_radial
|
||||
{
|
||||
public:
|
||||
static AGG_INLINE int calculate(int x, int y, int) { return int(fast_sqrt(x * x + y * y)); }
|
||||
static AGG_INLINE int calculate(int x, int y, int)
|
||||
{
|
||||
return int(fast_sqrt(x*x + y*y));
|
||||
}
|
||||
};
|
||||
|
||||
//========================================================gradient_radial_d
|
||||
|
@ -161,19 +187,19 @@ class gradient_radial_focus
|
|||
{
|
||||
public:
|
||||
//---------------------------------------------------------------------
|
||||
gradient_radial_focus()
|
||||
: m_r(100 * gradient_subpixel_scale)
|
||||
, m_fx(0)
|
||||
, m_fy(0)
|
||||
gradient_radial_focus() :
|
||||
m_r(100 * gradient_subpixel_scale),
|
||||
m_fx(0),
|
||||
m_fy(0)
|
||||
{
|
||||
update_values();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
gradient_radial_focus(double r, double fx, double fy)
|
||||
: m_r(iround(r * gradient_subpixel_scale))
|
||||
, m_fx(iround(fx * gradient_subpixel_scale))
|
||||
, m_fy(iround(fy * gradient_subpixel_scale))
|
||||
gradient_radial_focus(double r, double fx, double fy) :
|
||||
m_r (iround(r * gradient_subpixel_scale)),
|
||||
m_fx(iround(fx * gradient_subpixel_scale)),
|
||||
m_fy(iround(fy * gradient_subpixel_scale))
|
||||
{
|
||||
update_values();
|
||||
}
|
||||
|
@ -218,20 +244,8 @@ class gradient_radial_focus
|
|||
double d = (m_r2 - (m_fx2 + m_fy2));
|
||||
if(d == 0)
|
||||
{
|
||||
if (m_fx)
|
||||
{
|
||||
if (m_fx < 0)
|
||||
++m_fx;
|
||||
else
|
||||
--m_fx;
|
||||
}
|
||||
if (m_fy)
|
||||
{
|
||||
if (m_fy < 0)
|
||||
++m_fy;
|
||||
else
|
||||
--m_fy;
|
||||
}
|
||||
if(m_fx) { if(m_fx < 0) ++m_fx; else --m_fx; }
|
||||
if(m_fy) { if(m_fy < 0) ++m_fy; else --m_fy; }
|
||||
m_fx2 = double(m_fx) * double(m_fx);
|
||||
m_fy2 = double(m_fy) * double(m_fy);
|
||||
d = (m_r2 - (m_fx2 + m_fy2));
|
||||
|
@ -248,6 +262,7 @@ class gradient_radial_focus
|
|||
double m_mul;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================gradient_x
|
||||
class gradient_x
|
||||
{
|
||||
|
@ -255,6 +270,7 @@ class gradient_x
|
|||
static int calculate(int x, int, int) { return x; }
|
||||
};
|
||||
|
||||
|
||||
//==============================================================gradient_y
|
||||
class gradient_y
|
||||
{
|
||||
|
@ -278,14 +294,20 @@ class gradient_diamond
|
|||
class gradient_xy
|
||||
{
|
||||
public:
|
||||
static AGG_INLINE int calculate(int x, int y, int d) { return std::abs(x) * std::abs(y) / d; }
|
||||
static AGG_INLINE int calculate(int x, int y, int d)
|
||||
{
|
||||
return std::abs(x) * std::abs(y) / d;
|
||||
}
|
||||
};
|
||||
|
||||
//========================================================gradient_sqrt_xy
|
||||
class gradient_sqrt_xy
|
||||
{
|
||||
public:
|
||||
static AGG_INLINE int calculate(int x, int y, int) { return fast_sqrt(std::abs(x) * std::abs(y)); }
|
||||
static AGG_INLINE int calculate(int x, int y, int)
|
||||
{
|
||||
return fast_sqrt(std::abs(x) * std::abs(y));
|
||||
}
|
||||
};
|
||||
|
||||
//==========================================================gradient_conic
|
||||
|
@ -299,19 +321,16 @@ class gradient_conic
|
|||
};
|
||||
|
||||
//=================================================gradient_repeat_adaptor
|
||||
template<class GradientF>
|
||||
class gradient_repeat_adaptor
|
||||
template<class GradientF> class gradient_repeat_adaptor
|
||||
{
|
||||
public:
|
||||
gradient_repeat_adaptor(const GradientF& gradient)
|
||||
: m_gradient(&gradient)
|
||||
{}
|
||||
gradient_repeat_adaptor(const GradientF& gradient) :
|
||||
m_gradient(&gradient) {}
|
||||
|
||||
AGG_INLINE int calculate(int x, int y, int d) const
|
||||
{
|
||||
int ret = m_gradient->calculate(x, y, d) % d;
|
||||
if (ret < 0)
|
||||
ret += d;
|
||||
if(ret < 0) ret += d;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -320,22 +339,18 @@ class gradient_repeat_adaptor
|
|||
};
|
||||
|
||||
//================================================gradient_reflect_adaptor
|
||||
template<class GradientF>
|
||||
class gradient_reflect_adaptor
|
||||
template<class GradientF> class gradient_reflect_adaptor
|
||||
{
|
||||
public:
|
||||
gradient_reflect_adaptor(const GradientF& gradient)
|
||||
: m_gradient(&gradient)
|
||||
{}
|
||||
gradient_reflect_adaptor(const GradientF& gradient) :
|
||||
m_gradient(&gradient) {}
|
||||
|
||||
AGG_INLINE int calculate(int x, int y, int d) const
|
||||
{
|
||||
int d2 = d << 1;
|
||||
int ret = m_gradient->calculate(x, y, d) % d2;
|
||||
if (ret < 0)
|
||||
ret += d2;
|
||||
if (ret >= d)
|
||||
ret = d2 - ret;
|
||||
if(ret < 0) ret += d2;
|
||||
if(ret >= d) ret = d2 - ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -343,6 +358,7 @@ class gradient_reflect_adaptor
|
|||
const GradientF* m_gradient;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
48
deps/agg/include/agg_span_gradient_alpha.h
vendored
48
deps/agg/include/agg_span_gradient_alpha.h
vendored
|
@ -18,9 +18,13 @@
|
|||
|
||||
#include "agg_span_gradient.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
//======================================================span_gradient_alpha
|
||||
template<class ColorT, class Interpolator, class GradientF, class AlphaF>
|
||||
template<class ColorT,
|
||||
class Interpolator,
|
||||
class GradientF,
|
||||
class AlphaF>
|
||||
class span_gradient_alpha
|
||||
{
|
||||
public:
|
||||
|
@ -28,7 +32,11 @@ class span_gradient_alpha
|
|||
typedef ColorT color_type;
|
||||
typedef typename color_type::value_type alpha_type;
|
||||
|
||||
enum downscale_shift_e { downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift };
|
||||
enum downscale_shift_e
|
||||
{
|
||||
downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_gradient_alpha() {}
|
||||
|
@ -37,13 +45,12 @@ class span_gradient_alpha
|
|||
span_gradient_alpha(interpolator_type& inter,
|
||||
const GradientF& gradient_function,
|
||||
const AlphaF& alpha_function,
|
||||
double d1,
|
||||
double d2)
|
||||
: m_interpolator(&inter)
|
||||
, m_gradient_function(&gradient_function)
|
||||
, m_alpha_function(&alpha_function)
|
||||
, m_d1(iround(d1 * gradient_subpixel_scale))
|
||||
, m_d2(iround(d2 * gradient_subpixel_scale))
|
||||
double d1, double d2) :
|
||||
m_interpolator(&inter),
|
||||
m_gradient_function(&gradient_function),
|
||||
m_alpha_function(&alpha_function),
|
||||
m_d1(iround(d1 * gradient_subpixel_scale)),
|
||||
m_d2(iround(d2 * gradient_subpixel_scale))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -67,22 +74,21 @@ class span_gradient_alpha
|
|||
void generate(color_type* span, int x, int y, unsigned len)
|
||||
{
|
||||
int dd = m_d2 - m_d1;
|
||||
if (dd < 1)
|
||||
dd = 1;
|
||||
if(dd < 1) dd = 1;
|
||||
m_interpolator->begin(x+0.5, y+0.5, len);
|
||||
do
|
||||
{
|
||||
m_interpolator->coordinates(&x, &y);
|
||||
int d = m_gradient_function->calculate(x >> downscale_shift, y >> downscale_shift, m_d2);
|
||||
int d = m_gradient_function->calculate(x >> downscale_shift,
|
||||
y >> downscale_shift, m_d2);
|
||||
d = ((d - m_d1) * (int)m_alpha_function->size()) / dd;
|
||||
if (d < 0)
|
||||
d = 0;
|
||||
if (d >= (int)m_alpha_function->size())
|
||||
d = m_alpha_function->size() - 1;
|
||||
if(d < 0) d = 0;
|
||||
if(d >= (int)m_alpha_function->size()) d = m_alpha_function->size() - 1;
|
||||
span->a = (*m_alpha_function)[d];
|
||||
++span;
|
||||
++(*m_interpolator);
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -93,9 +99,9 @@ class span_gradient_alpha
|
|||
int m_d2;
|
||||
};
|
||||
|
||||
|
||||
//=======================================================gradient_alpha_x
|
||||
template<class ColorT>
|
||||
struct gradient_alpha_x
|
||||
template<class ColorT> struct gradient_alpha_x
|
||||
{
|
||||
typedef typename ColorT::value_type alpha_type;
|
||||
alpha_type operator [] (alpha_type x) const { return x; }
|
||||
|
@ -115,6 +121,6 @@ struct gradient_alpha_one_munus_x_u8
|
|||
alpha_type operator [] (alpha_type x) const { return 255-x; }
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
114
deps/agg/include/agg_span_image_filter.h
vendored
114
deps/agg/include/agg_span_image_filter.h
vendored
|
@ -23,11 +23,11 @@
|
|||
#include "agg_image_filters.h"
|
||||
#include "agg_span_interpolator_linear.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-------------------------------------------------------span_image_filter
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter
|
||||
template<class Source, class Interpolator> class span_image_filter
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -35,14 +35,16 @@ class span_image_filter
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
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)
|
||||
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; }
|
||||
|
||||
|
@ -84,9 +86,13 @@ class span_image_filter
|
|||
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>>
|
||||
class span_image_resample_affine :
|
||||
public span_image_filter<Source, span_interpolator_linear<trans_affine> >
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -94,20 +100,23 @@ class span_image_resample_affine : public span_image_filter<Source, span_interpo
|
|||
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() :
|
||||
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)
|
||||
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; }
|
||||
|
@ -133,23 +142,17 @@ class span_image_resample_affine : public span_image_filter<Source, span_interpo
|
|||
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 < 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;
|
||||
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;
|
||||
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));
|
||||
|
@ -170,9 +173,12 @@ class span_image_resample_affine : public span_image_filter<Source, span_interpo
|
|||
double m_blur_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================================span_image_resample
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_resample : public span_image_filter<Source, Interpolator>
|
||||
class span_image_resample :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -180,18 +186,20 @@ class span_image_resample : public span_image_filter<Source, Interpolator>
|
|||
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() :
|
||||
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)
|
||||
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)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -203,15 +211,14 @@ class span_image_resample : public span_image_filter<Source, Interpolator>
|
|||
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)); }
|
||||
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) *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;
|
||||
|
@ -222,10 +229,8 @@ class span_image_resample : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
*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;
|
||||
if(*rx < image_subpixel_scale) *rx = image_subpixel_scale;
|
||||
if(*ry < image_subpixel_scale) *ry = image_subpixel_scale;
|
||||
}
|
||||
|
||||
int m_scale_limit;
|
||||
|
@ -233,6 +238,9 @@ class span_image_resample : public span_image_filter<Source, Interpolator>
|
|||
int m_blur_y;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
297
deps/agg/include/agg_span_image_filter_gray.h
vendored
297
deps/agg/include/agg_span_image_filter_gray.h
vendored
|
@ -27,11 +27,14 @@
|
|||
#include "agg_color_gray.h"
|
||||
#include "agg_span_image_filter.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//==============================================span_image_filter_gray_nn
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_gray_nn : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_gray_nn :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -40,23 +43,31 @@ class span_image_filter_gray_nn : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_gray_nn() {}
|
||||
span_image_filter_gray_nn(source_type& src, interpolator_type& inter)
|
||||
: base_type(src, inter, 0)
|
||||
span_image_filter_gray_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
do
|
||||
{
|
||||
base_type::interpolator().coordinates(&x, &y);
|
||||
span->v =
|
||||
*(const value_type*)base_type::source().span(x >> image_subpixel_shift, y >> image_subpixel_shift, 1);
|
||||
span->v = *(const value_type*)
|
||||
base_type::source().span(x >> image_subpixel_shift,
|
||||
y >> image_subpixel_shift,
|
||||
1);
|
||||
span->a = base_mask;
|
||||
++span;
|
||||
++base_type::interpolator();
|
||||
|
@ -64,9 +75,12 @@ class span_image_filter_gray_nn : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=========================================span_image_filter_gray_bilinear
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_gray_bilinear : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_gray_bilinear :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -75,18 +89,25 @@ class span_image_filter_gray_bilinear : public span_image_filter<Source, Interpo
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_gray_bilinear() {}
|
||||
span_image_filter_gray_bilinear(source_type& src, interpolator_type& inter)
|
||||
: base_type(src, inter, 0)
|
||||
span_image_filter_gray_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
calc_type fg;
|
||||
const value_type *fg_ptr;
|
||||
do
|
||||
|
@ -128,9 +149,11 @@ class span_image_filter_gray_bilinear : public span_image_filter<Source, Interpo
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//====================================span_image_filter_gray_bilinear_clip
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_gray_bilinear_clip :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -139,13 +162,19 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_gray_bilinear_clip() {}
|
||||
span_image_filter_gray_bilinear_clip(source_type& src, const color_type& back_color, interpolator_type& inter)
|
||||
: base_type(src, inter, 0)
|
||||
, m_back_color(back_color)
|
||||
span_image_filter_gray_bilinear_clip(source_type& src,
|
||||
const color_type& back_color,
|
||||
interpolator_type& inter) :
|
||||
base_type(src, inter, 0),
|
||||
m_back_color(back_color)
|
||||
{}
|
||||
const color_type& background_color() const { return m_back_color; }
|
||||
void background_color(const color_type& v) { m_back_color = v; }
|
||||
|
@ -153,7 +182,8 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
//--------------------------------------------------------------------
|
||||
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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
calc_type fg;
|
||||
calc_type src_alpha;
|
||||
value_type back_v = m_back_color.v;
|
||||
|
@ -177,7 +207,8 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
int x_lr = x_hr >> image_subpixel_shift;
|
||||
int y_lr = y_hr >> image_subpixel_shift;
|
||||
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy)
|
||||
if(x_lr >= 0 && y_lr >= 0 &&
|
||||
x_lr < maxx && y_lr < maxy)
|
||||
{
|
||||
fg = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
|
||||
|
@ -200,22 +231,27 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
else
|
||||
{
|
||||
unsigned weight;
|
||||
if (x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy)
|
||||
if(x_lr < -1 || y_lr < -1 ||
|
||||
x_lr > maxx || y_lr > maxy)
|
||||
{
|
||||
fg = back_v;
|
||||
src_alpha = back_a;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg = src_alpha = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
fg =
|
||||
src_alpha = 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)
|
||||
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 += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
fg += weight *
|
||||
*((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
src_alpha += weight * base_mask;
|
||||
}
|
||||
else
|
||||
|
@ -227,9 +263,11 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
x_lr++;
|
||||
|
||||
weight = x_hr * (image_subpixel_scale - y_hr);
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
if(x_lr >= 0 && y_lr >= 0 &&
|
||||
x_lr <= maxx && y_lr <= maxy)
|
||||
{
|
||||
fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
fg += weight *
|
||||
*((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
src_alpha += weight * base_mask;
|
||||
}
|
||||
else
|
||||
|
@ -242,9 +280,11 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
y_lr++;
|
||||
|
||||
weight = (image_subpixel_scale - x_hr) * y_hr;
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
if(x_lr >= 0 && y_lr >= 0 &&
|
||||
x_lr <= maxx && y_lr <= maxy)
|
||||
{
|
||||
fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
fg += weight *
|
||||
*((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
src_alpha += weight * base_mask;
|
||||
}
|
||||
else
|
||||
|
@ -256,9 +296,11 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
x_lr++;
|
||||
|
||||
weight = x_hr * y_hr;
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
if(x_lr >= 0 && y_lr >= 0 &&
|
||||
x_lr <= maxx && y_lr <= maxy)
|
||||
{
|
||||
fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
fg += weight *
|
||||
*((const value_type*)base_type::source().row_ptr(y_lr) + x_lr);
|
||||
src_alpha += weight * base_mask;
|
||||
}
|
||||
else
|
||||
|
@ -279,14 +321,16 @@ class span_image_filter_gray_bilinear_clip : public span_image_filter<Source, In
|
|||
|
||||
} while(--len);
|
||||
}
|
||||
|
||||
private:
|
||||
color_type m_back_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==============================================span_image_filter_gray_2x2
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_gray_2x2 : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_gray_2x2 :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -295,24 +339,33 @@ class span_image_filter_gray_2x2 : public span_image_filter<Source, Interpolator
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_gray_2x2() {}
|
||||
span_image_filter_gray_2x2(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, &filter)
|
||||
span_image_filter_gray_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
calc_type fg;
|
||||
|
||||
const value_type *fg_ptr;
|
||||
const int16* weight_array =
|
||||
base_type::filter().weight_array() + ((base_type::filter().diameter() / 2 - 1) << image_subpixel_shift);
|
||||
const int16* weight_array = base_type::filter().weight_array() +
|
||||
((base_type::filter().diameter()/2 - 1) <<
|
||||
image_subpixel_shift);
|
||||
do
|
||||
{
|
||||
int x_hr;
|
||||
|
@ -333,28 +386,35 @@ class span_image_filter_gray_2x2 : public span_image_filter<Source, Interpolator
|
|||
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] +
|
||||
weight = (weight_array[x_hr + image_subpixel_scale] *
|
||||
weight_array[y_hr + image_subpixel_scale] +
|
||||
image_filter_scale / 2) >>
|
||||
image_filter_shift;
|
||||
fg += 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) >>
|
||||
weight = (weight_array[x_hr] *
|
||||
weight_array[y_hr + image_subpixel_scale] +
|
||||
image_filter_scale / 2) >>
|
||||
image_filter_shift;
|
||||
fg += 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) >>
|
||||
weight = (weight_array[x_hr + image_subpixel_scale] *
|
||||
weight_array[y_hr] +
|
||||
image_filter_scale / 2) >>
|
||||
image_filter_shift;
|
||||
fg += 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;
|
||||
weight = (weight_array[x_hr] *
|
||||
weight_array[y_hr] +
|
||||
image_filter_scale / 2) >>
|
||||
image_filter_shift;
|
||||
fg += weight * *fg_ptr;
|
||||
|
||||
fg >>= image_filter_shift;
|
||||
if (fg > base_mask)
|
||||
fg = base_mask;
|
||||
if(fg > base_mask) fg = base_mask;
|
||||
|
||||
span->v = (value_type)fg;
|
||||
span->a = base_mask;
|
||||
|
@ -364,9 +424,12 @@ class span_image_filter_gray_2x2 : public span_image_filter<Source, Interpolator
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==================================================span_image_filter_gray
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_gray : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_gray :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -375,18 +438,25 @@ class span_image_filter_gray : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_gray() {}
|
||||
span_image_filter_gray(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, &filter)
|
||||
span_image_filter_gray(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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
int fg;
|
||||
const value_type *fg_ptr;
|
||||
|
@ -417,7 +487,9 @@ class span_image_filter_gray : public span_image_filter<Source, Interpolator>
|
|||
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);
|
||||
fg_ptr = (const value_type*)base_type::source().span(x_lr + start,
|
||||
y_lr + start,
|
||||
diameter);
|
||||
for(;;)
|
||||
{
|
||||
x_count = diameter;
|
||||
|
@ -425,24 +497,23 @@ class span_image_filter_gray : public span_image_filter<Source, Interpolator>
|
|||
x_hr = image_subpixel_mask - x_fract;
|
||||
for(;;)
|
||||
{
|
||||
fg += *fg_ptr * ((weight_y * weight_array[x_hr] + image_filter_scale / 2) >> image_filter_shift);
|
||||
if (--x_count == 0)
|
||||
break;
|
||||
fg += *fg_ptr *
|
||||
((weight_y * weight_array[x_hr] +
|
||||
image_filter_scale / 2) >>
|
||||
image_filter_shift);
|
||||
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;
|
||||
if(--y_count == 0) break;
|
||||
y_hr += image_subpixel_scale;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
fg >>= image_filter_shift;
|
||||
if (fg < 0)
|
||||
fg = 0;
|
||||
if (fg > base_mask)
|
||||
fg = base_mask;
|
||||
if(fg < 0) fg = 0;
|
||||
if(fg > base_mask) fg = base_mask;
|
||||
span->v = (value_type)fg;
|
||||
span->a = base_mask;
|
||||
|
||||
|
@ -453,9 +524,12 @@ class span_image_filter_gray : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=========================================span_image_resample_gray_affine
|
||||
template<class Source>
|
||||
class span_image_resample_gray_affine : public span_image_resample_affine<Source>
|
||||
class span_image_resample_gray_affine :
|
||||
public span_image_resample_affine<Source>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -464,7 +538,8 @@ class span_image_resample_gray_affine : public span_image_resample_affine<Source
|
|||
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 {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask,
|
||||
downscale_shift = image_filter_shift
|
||||
|
@ -472,14 +547,18 @@ class span_image_resample_gray_affine : public span_image_resample_affine<Source
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_resample_gray_affine() {}
|
||||
span_image_resample_gray_affine(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, filter)
|
||||
span_image_resample_gray_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
long_type fg;
|
||||
|
||||
|
@ -487,7 +566,9 @@ class span_image_resample_gray_affine : public span_image_resample_affine<Source
|
|||
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;
|
||||
int len_x_lr =
|
||||
(diameter * base_type::m_rx + image_subpixel_mask) >>
|
||||
image_subpixel_shift;
|
||||
|
||||
const int16* weight_array = base_type::filter().weight_array();
|
||||
|
||||
|
@ -501,41 +582,42 @@ class span_image_resample_gray_affine : public span_image_resample_affine<Source
|
|||
fg = 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 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_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);
|
||||
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;
|
||||
int weight = (weight_y * weight_array[x_hr] +
|
||||
image_filter_scale / 2) >>
|
||||
downscale_shift;
|
||||
|
||||
fg += *fg_ptr * weight;
|
||||
total_weight += weight;
|
||||
x_hr += base_type::m_rx_inv;
|
||||
if (x_hr >= filter_scale)
|
||||
break;
|
||||
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;
|
||||
if(y_hr >= filter_scale) break;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
fg /= total_weight;
|
||||
if (fg < 0)
|
||||
fg = 0;
|
||||
if (fg > base_mask)
|
||||
fg = base_mask;
|
||||
if(fg < 0) fg = 0;
|
||||
if(fg > base_mask) fg = base_mask;
|
||||
|
||||
span->v = (value_type)fg;
|
||||
span->a = base_mask;
|
||||
|
@ -546,9 +628,12 @@ class span_image_resample_gray_affine : public span_image_resample_affine<Source
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//================================================span_image_resample_gray
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_resample_gray : public span_image_resample<Source, Interpolator>
|
||||
class span_image_resample_gray :
|
||||
public span_image_resample<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -557,7 +642,8 @@ class span_image_resample_gray : public span_image_resample<Source, Interpolator
|
|||
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 {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask,
|
||||
downscale_shift = image_filter_shift
|
||||
|
@ -565,14 +651,17 @@ class span_image_resample_gray : public span_image_resample<Source, Interpolator
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_resample_gray() {}
|
||||
span_image_resample_gray(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, filter)
|
||||
span_image_resample_gray(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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
long_type fg;
|
||||
|
||||
int diameter = base_type::filter().diameter();
|
||||
|
@ -594,7 +683,9 @@ class span_image_resample_gray : public span_image_resample<Source, Interpolator
|
|||
|
||||
int radius_x = (diameter * rx) >> 1;
|
||||
int radius_y = (diameter * ry) >> 1;
|
||||
int len_x_lr = (diameter * rx + image_subpixel_mask) >> image_subpixel_shift;
|
||||
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;
|
||||
|
@ -602,12 +693,17 @@ class span_image_resample_gray : public span_image_resample<Source, Interpolator
|
|||
fg = 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 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_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);
|
||||
const value_type* fg_ptr =
|
||||
(const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -615,25 +711,23 @@ class span_image_resample_gray : public span_image_resample<Source, Interpolator
|
|||
x_hr = x_hr2;
|
||||
for(;;)
|
||||
{
|
||||
int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift;
|
||||
int weight = (weight_y * weight_array[x_hr] +
|
||||
image_filter_scale / 2) >>
|
||||
downscale_shift;
|
||||
fg += *fg_ptr * weight;
|
||||
total_weight += weight;
|
||||
x_hr += rx_inv;
|
||||
if (x_hr >= filter_scale)
|
||||
break;
|
||||
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;
|
||||
if(y_hr >= filter_scale) break;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
fg /= total_weight;
|
||||
if (fg < 0)
|
||||
fg = 0;
|
||||
if (fg > base_mask)
|
||||
fg = base_mask;
|
||||
if(fg < 0) fg = 0;
|
||||
if(fg > base_mask) fg = base_mask;
|
||||
|
||||
span->v = (value_type)fg;
|
||||
span->a = base_mask;
|
||||
|
@ -644,6 +738,11 @@ class span_image_resample_gray : public span_image_resample<Source, Interpolator
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
361
deps/agg/include/agg_span_image_filter_rgb.h
vendored
361
deps/agg/include/agg_span_image_filter_rgb.h
vendored
|
@ -27,11 +27,14 @@
|
|||
#include "agg_color_rgba.h"
|
||||
#include "agg_span_image_filter.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===============================================span_image_filter_rgb_nn
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgb_nn : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgb_nn :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -41,23 +44,31 @@ class span_image_filter_rgb_nn : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_rgb_nn() {}
|
||||
span_image_filter_rgb_nn(source_type& src, interpolator_type& inter)
|
||||
: base_type(src, inter, 0)
|
||||
span_image_filter_rgb_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);
|
||||
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);
|
||||
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];
|
||||
|
@ -69,9 +80,12 @@ class span_image_filter_rgb_nn : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==========================================span_image_filter_rgb_bilinear
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgb_bilinear : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgb_bilinear :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -81,18 +95,25 @@ class span_image_filter_rgb_bilinear : public span_image_filter<Source, Interpol
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_rgb_bilinear() {}
|
||||
span_image_filter_rgb_bilinear(source_type& src, interpolator_type& inter)
|
||||
: base_type(src, inter, 0)
|
||||
span_image_filter_rgb_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
calc_type fg[3];
|
||||
const value_type *fg_ptr;
|
||||
do
|
||||
|
@ -110,13 +131,16 @@ class span_image_filter_rgb_bilinear : public span_image_filter<Source, Interpol
|
|||
|
||||
unsigned weight;
|
||||
|
||||
fg[0] = fg[1] = fg[2] = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
fg[0] =
|
||||
fg[1] =
|
||||
fg[2] = 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);
|
||||
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;
|
||||
|
@ -151,9 +175,12 @@ class span_image_filter_rgb_bilinear : public span_image_filter<Source, Interpol
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================span_image_filter_rgb_bilinear_clip
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgb_bilinear_clip :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -163,13 +190,19 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_rgb_bilinear_clip() {}
|
||||
span_image_filter_rgb_bilinear_clip(source_type& src, const color_type& back_color, interpolator_type& inter)
|
||||
: base_type(src, inter, 0)
|
||||
, m_back_color(back_color)
|
||||
span_image_filter_rgb_bilinear_clip(source_type& src,
|
||||
const color_type& back_color,
|
||||
interpolator_type& inter) :
|
||||
base_type(src, inter, 0),
|
||||
m_back_color(back_color)
|
||||
{}
|
||||
const color_type& background_color() const { return m_back_color; }
|
||||
void background_color(const color_type& v) { m_back_color = v; }
|
||||
|
@ -177,7 +210,8 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
//--------------------------------------------------------------------
|
||||
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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
calc_type fg[3];
|
||||
calc_type src_alpha;
|
||||
value_type back_r = m_back_color.r;
|
||||
|
@ -204,16 +238,21 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
int y_lr = y_hr >> image_subpixel_shift;
|
||||
unsigned weight;
|
||||
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy)
|
||||
if(x_lr >= 0 && y_lr >= 0 &&
|
||||
x_lr < maxx && y_lr < maxy)
|
||||
{
|
||||
fg[0] = fg[1] = fg[2] = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
fg[0] =
|
||||
fg[1] =
|
||||
fg[2] = 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 + x_lr + x_lr;
|
||||
fg_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
|
||||
weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr);
|
||||
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++;
|
||||
|
@ -224,7 +263,8 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
fg[2] += weight * *fg_ptr++;
|
||||
|
||||
++y_lr;
|
||||
fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
fg_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
|
||||
weight = (image_subpixel_scale - x_hr) * y_hr;
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
|
@ -243,7 +283,8 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
}
|
||||
else
|
||||
{
|
||||
if (x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy)
|
||||
if(x_lr < -1 || y_lr < -1 ||
|
||||
x_lr > maxx || y_lr > maxy)
|
||||
{
|
||||
fg[order_type::R] = back_r;
|
||||
fg[order_type::G] = back_g;
|
||||
|
@ -252,15 +293,21 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
}
|
||||
else
|
||||
{
|
||||
fg[0] = fg[1] = fg[2] = src_alpha = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
fg[0] =
|
||||
fg[1] =
|
||||
fg[2] =
|
||||
src_alpha = 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)
|
||||
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 + x_lr + x_lr;
|
||||
fg_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -278,9 +325,11 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
x_lr++;
|
||||
|
||||
weight = x_hr * (image_subpixel_scale - y_hr);
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
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 + x_lr + x_lr;
|
||||
fg_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -299,9 +348,11 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
y_lr++;
|
||||
|
||||
weight = (image_subpixel_scale - x_hr) * y_hr;
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
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 + x_lr + x_lr;
|
||||
fg_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -319,9 +370,11 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
x_lr++;
|
||||
|
||||
weight = x_hr * y_hr;
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
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 + x_lr + x_lr;
|
||||
fg_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr;
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -352,14 +405,16 @@ class span_image_filter_rgb_bilinear_clip : public span_image_filter<Source, Int
|
|||
|
||||
} while(--len);
|
||||
}
|
||||
|
||||
private:
|
||||
color_type m_back_color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//===============================================span_image_filter_rgb_2x2
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgb_2x2 : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgb_2x2 :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -369,24 +424,33 @@ class span_image_filter_rgb_2x2 : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_rgb_2x2() {}
|
||||
span_image_filter_rgb_2x2(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, &filter)
|
||||
span_image_filter_rgb_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
calc_type fg[3];
|
||||
|
||||
const value_type *fg_ptr;
|
||||
const int16* weight_array =
|
||||
base_type::filter().weight_array() + ((base_type::filter().diameter() / 2 - 1) << image_subpixel_shift);
|
||||
const int16* weight_array = base_type::filter().weight_array() +
|
||||
((base_type::filter().diameter()/2 - 1) <<
|
||||
image_subpixel_shift);
|
||||
do
|
||||
{
|
||||
int x_hr;
|
||||
|
@ -407,7 +471,8 @@ class span_image_filter_rgb_2x2 : public span_image_filter<Source, Interpolator>
|
|||
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] +
|
||||
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++;
|
||||
|
@ -415,21 +480,28 @@ class span_image_filter_rgb_2x2 : public span_image_filter<Source, Interpolator>
|
|||
fg[2] += 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) >>
|
||||
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_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) >>
|
||||
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_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;
|
||||
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;
|
||||
|
@ -438,12 +510,9 @@ class span_image_filter_rgb_2x2 : public span_image_filter<Source, Interpolator>
|
|||
fg[1] >>= image_filter_shift;
|
||||
fg[2] >>= image_filter_shift;
|
||||
|
||||
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::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;
|
||||
|
||||
span->r = (value_type)fg[order_type::R];
|
||||
span->g = (value_type)fg[order_type::G];
|
||||
|
@ -457,9 +526,12 @@ class span_image_filter_rgb_2x2 : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//===================================================span_image_filter_rgb
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgb : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgb :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -469,18 +541,25 @@ class span_image_filter_rgb : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_rgb() {}
|
||||
span_image_filter_rgb(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, &filter)
|
||||
span_image_filter_rgb(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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
int fg[3];
|
||||
const value_type *fg_ptr;
|
||||
|
@ -511,7 +590,9 @@ class span_image_filter_rgb : public span_image_filter<Source, Interpolator>
|
|||
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);
|
||||
fg_ptr = (const value_type*)base_type::source().span(x_lr + start,
|
||||
y_lr + start,
|
||||
diameter);
|
||||
for(;;)
|
||||
{
|
||||
x_count = diameter;
|
||||
|
@ -519,20 +600,20 @@ class span_image_filter_rgb : public span_image_filter<Source, Interpolator>
|
|||
x_hr = image_subpixel_mask - x_fract;
|
||||
for(;;)
|
||||
{
|
||||
int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> image_filter_shift;
|
||||
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;
|
||||
|
||||
if (--x_count == 0)
|
||||
break;
|
||||
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;
|
||||
if(--y_count == 0) break;
|
||||
y_hr += image_subpixel_scale;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
@ -541,19 +622,13 @@ class span_image_filter_rgb : public span_image_filter<Source, Interpolator>
|
|||
fg[1] >>= image_filter_shift;
|
||||
fg[2] >>= 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[0] < 0) fg[0] = 0;
|
||||
if(fg[1] < 0) fg[1] = 0;
|
||||
if(fg[2] < 0) fg[2] = 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::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;
|
||||
|
||||
span->r = (value_type)fg[order_type::R];
|
||||
span->g = (value_type)fg[order_type::G];
|
||||
|
@ -567,9 +642,12 @@ class span_image_filter_rgb : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==========================================span_image_resample_rgb_affine
|
||||
template<class Source>
|
||||
class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
||||
class span_image_resample_rgb_affine :
|
||||
public span_image_resample_affine<Source>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -579,7 +657,8 @@ class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
|||
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 {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask,
|
||||
downscale_shift = image_filter_shift
|
||||
|
@ -587,14 +666,18 @@ class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_resample_rgb_affine() {}
|
||||
span_image_resample_rgb_affine(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, filter)
|
||||
span_image_resample_rgb_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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
long_type fg[3];
|
||||
|
||||
|
@ -602,7 +685,9 @@ class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
|||
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;
|
||||
int len_x_lr =
|
||||
(diameter * base_type::m_rx + image_subpixel_mask) >>
|
||||
image_subpixel_shift;
|
||||
|
||||
const int16* weight_array = base_type::filter().weight_array();
|
||||
|
||||
|
@ -616,35 +701,38 @@ class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
|||
fg[0] = fg[1] = fg[2] = 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 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_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);
|
||||
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;
|
||||
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;
|
||||
total_weight += weight;
|
||||
x_hr += base_type::m_rx_inv;
|
||||
if (x_hr >= filter_scale)
|
||||
break;
|
||||
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;
|
||||
if(y_hr >= filter_scale) break;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
|
@ -652,19 +740,13 @@ class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
|||
fg[1] /= total_weight;
|
||||
fg[2] /= 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[0] < 0) fg[0] = 0;
|
||||
if(fg[1] < 0) fg[1] = 0;
|
||||
if(fg[2] < 0) fg[2] = 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::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;
|
||||
|
||||
span->r = (value_type)fg[order_type::R];
|
||||
span->g = (value_type)fg[order_type::G];
|
||||
|
@ -677,9 +759,12 @@ class span_image_resample_rgb_affine : public span_image_resample_affine<Source>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=================================================span_image_resample_rgb
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
||||
class span_image_resample_rgb :
|
||||
public span_image_resample<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -689,7 +774,8 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
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 {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask,
|
||||
downscale_shift = image_filter_shift
|
||||
|
@ -697,14 +783,17 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_resample_rgb() {}
|
||||
span_image_resample_rgb(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, filter)
|
||||
span_image_resample_rgb(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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
long_type fg[3];
|
||||
|
||||
int diameter = base_type::filter().diameter();
|
||||
|
@ -726,7 +815,9 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
|
||||
int radius_x = (diameter * rx) >> 1;
|
||||
int radius_y = (diameter * ry) >> 1;
|
||||
int len_x_lr = (diameter * rx + image_subpixel_mask) >> image_subpixel_shift;
|
||||
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;
|
||||
|
@ -734,12 +825,17 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
fg[0] = fg[1] = fg[2] = 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 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_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);
|
||||
const value_type* fg_ptr =
|
||||
(const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -747,19 +843,19 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
x_hr = x_hr2;
|
||||
for(;;)
|
||||
{
|
||||
int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift;
|
||||
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;
|
||||
total_weight += weight;
|
||||
x_hr += rx_inv;
|
||||
if (x_hr >= filter_scale)
|
||||
break;
|
||||
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;
|
||||
if(y_hr >= filter_scale) break;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
|
@ -767,19 +863,13 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
fg[1] /= total_weight;
|
||||
fg[2] /= 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[0] < 0) fg[0] = 0;
|
||||
if(fg[1] < 0) fg[1] = 0;
|
||||
if(fg[2] < 0) fg[2] = 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::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;
|
||||
|
||||
span->r = (value_type)fg[order_type::R];
|
||||
span->g = (value_type)fg[order_type::G];
|
||||
|
@ -792,6 +882,11 @@ class span_image_resample_rgb : public span_image_resample<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
383
deps/agg/include/agg_span_image_filter_rgba.h
vendored
383
deps/agg/include/agg_span_image_filter_rgba.h
vendored
|
@ -27,11 +27,14 @@
|
|||
#include "agg_color_rgba.h"
|
||||
#include "agg_span_image_filter.h"
|
||||
|
||||
namespace agg {
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//==============================================span_image_filter_rgba_nn
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgba_nn : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgba_nn :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -41,23 +44,31 @@ class span_image_filter_rgba_nn : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
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)
|
||||
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);
|
||||
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);
|
||||
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];
|
||||
|
@ -69,9 +80,12 @@ class span_image_filter_rgba_nn : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=========================================span_image_filter_rgba_bilinear
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgba_bilinear : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgba_bilinear :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -81,18 +95,25 @@ class span_image_filter_rgba_bilinear : public span_image_filter<Source, Interpo
|
|||
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 };
|
||||
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)
|
||||
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);
|
||||
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;
|
||||
|
@ -112,13 +133,17 @@ class span_image_filter_rgba_bilinear : public span_image_filter<Source, Interpo
|
|||
|
||||
unsigned weight;
|
||||
|
||||
fg[0] = fg[1] = fg[2] = fg[3] = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
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);
|
||||
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++;
|
||||
|
@ -157,9 +182,11 @@ class span_image_filter_rgba_bilinear : public span_image_filter<Source, Interpo
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//====================================span_image_filter_rgba_bilinear_clip
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgba_bilinear_clip :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -169,21 +196,29 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
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 };
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_filter_rgba_bilinear_clip() {}
|
||||
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)
|
||||
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)
|
||||
{}
|
||||
const color_type& background_color() const { return m_back_color; }
|
||||
void background_color(const color_type& v) { m_back_color = v; }
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
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);
|
||||
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;
|
||||
|
@ -210,16 +245,22 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
|
||||
unsigned weight;
|
||||
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy)
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
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++;
|
||||
|
@ -232,7 +273,8 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
fg[3] += weight * *fg_ptr++;
|
||||
|
||||
++y_lr;
|
||||
fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + (x_lr << 2);
|
||||
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++;
|
||||
|
@ -253,7 +295,8 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
}
|
||||
else
|
||||
{
|
||||
if (x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy)
|
||||
if(x_lr < -1 || y_lr < -1 ||
|
||||
x_lr > maxx || y_lr > maxy)
|
||||
{
|
||||
fg[order_type::R] = back_r;
|
||||
fg[order_type::G] = back_g;
|
||||
|
@ -262,15 +305,21 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
}
|
||||
else
|
||||
{
|
||||
fg[0] = fg[1] = fg[2] = fg[3] = image_subpixel_scale * image_subpixel_scale / 2;
|
||||
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)
|
||||
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_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + (x_lr << 2);
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -288,9 +337,11 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
x_lr++;
|
||||
|
||||
weight = x_hr * (image_subpixel_scale - y_hr);
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
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_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + (x_lr << 2);
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -309,9 +360,11 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
y_lr++;
|
||||
|
||||
weight = (image_subpixel_scale - x_hr) * y_hr;
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
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_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + (x_lr << 2);
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -329,9 +382,11 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
x_lr++;
|
||||
|
||||
weight = x_hr * y_hr;
|
||||
if (x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy)
|
||||
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_ptr = (const value_type*)
|
||||
base_type::source().row_ptr(y_lr) + (x_lr << 2);
|
||||
|
||||
fg[0] += weight * *fg_ptr++;
|
||||
fg[1] += weight * *fg_ptr++;
|
||||
|
@ -362,14 +417,15 @@ class span_image_filter_rgba_bilinear_clip : public span_image_filter<Source, In
|
|||
|
||||
} while(--len);
|
||||
}
|
||||
|
||||
private:
|
||||
color_type m_back_color;
|
||||
};
|
||||
|
||||
|
||||
//==============================================span_image_filter_rgba_2x2
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgba_2x2 :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -379,24 +435,33 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
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 };
|
||||
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)
|
||||
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);
|
||||
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);
|
||||
const int16* weight_array = base_type::filter().weight_array() +
|
||||
((base_type::filter().diameter()/2 - 1) <<
|
||||
image_subpixel_shift);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -418,7 +483,8 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
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] +
|
||||
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++;
|
||||
|
@ -427,7 +493,9 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
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) >>
|
||||
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++;
|
||||
|
@ -435,7 +503,9 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
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) >>
|
||||
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++;
|
||||
|
@ -443,7 +513,10 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
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;
|
||||
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++;
|
||||
|
@ -454,14 +527,10 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
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];
|
||||
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];
|
||||
|
@ -474,9 +543,12 @@ class span_image_filter_rgba_2x2 : public span_image_filter<Source, Interpolator
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==================================================span_image_filter_rgba
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_filter_rgba : public span_image_filter<Source, Interpolator>
|
||||
class span_image_filter_rgba :
|
||||
public span_image_filter<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -486,18 +558,25 @@ class span_image_filter_rgba : public span_image_filter<Source, Interpolator>
|
|||
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 };
|
||||
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)
|
||||
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);
|
||||
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;
|
||||
|
@ -528,7 +607,9 @@ class span_image_filter_rgba : public span_image_filter<Source, Interpolator>
|
|||
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);
|
||||
fg_ptr = (const value_type*)base_type::source().span(x_lr + start,
|
||||
y_lr + start,
|
||||
diameter);
|
||||
for(;;)
|
||||
{
|
||||
x_count = diameter;
|
||||
|
@ -536,21 +617,21 @@ class span_image_filter_rgba : public span_image_filter<Source, Interpolator>
|
|||
x_hr = image_subpixel_mask - x_fract;
|
||||
for(;;)
|
||||
{
|
||||
int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> image_filter_shift;
|
||||
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;
|
||||
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;
|
||||
if(--y_count == 0) break;
|
||||
y_hr += image_subpixel_scale;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
@ -560,23 +641,15 @@ class span_image_filter_rgba : public span_image_filter<Source, Interpolator>
|
|||
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[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];
|
||||
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];
|
||||
|
@ -589,9 +662,12 @@ class span_image_filter_rgba : public span_image_filter<Source, Interpolator>
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//========================================span_image_resample_rgba_affine
|
||||
template<class Source>
|
||||
class span_image_resample_rgba_affine : public span_image_resample_affine<Source>
|
||||
class span_image_resample_rgba_affine :
|
||||
public span_image_resample_affine<Source>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -601,7 +677,8 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
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 {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask,
|
||||
downscale_shift = image_filter_shift
|
||||
|
@ -609,14 +686,18 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
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)
|
||||
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);
|
||||
base_type::interpolator().begin(x + base_type::filter_dx_dbl(),
|
||||
y + base_type::filter_dy_dbl(), len);
|
||||
|
||||
long_type fg[4];
|
||||
|
||||
|
@ -624,7 +705,9 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
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;
|
||||
int len_x_lr =
|
||||
(diameter * base_type::m_rx + image_subpixel_mask) >>
|
||||
image_subpixel_shift;
|
||||
|
||||
const int16* weight_array = base_type::filter().weight_array();
|
||||
|
||||
|
@ -638,22 +721,27 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
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 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_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);
|
||||
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;
|
||||
int weight = (weight_y * weight_array[x_hr] +
|
||||
image_filter_scale / 2) >>
|
||||
downscale_shift;
|
||||
|
||||
fg[0] += *fg_ptr++ * weight;
|
||||
fg[1] += *fg_ptr++ * weight;
|
||||
|
@ -661,13 +749,11 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
fg[3] += *fg_ptr++ * weight;
|
||||
total_weight += weight;
|
||||
x_hr += base_type::m_rx_inv;
|
||||
if (x_hr >= filter_scale)
|
||||
break;
|
||||
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;
|
||||
if(y_hr >= filter_scale) break;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
|
@ -676,23 +762,15 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
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[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];
|
||||
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];
|
||||
|
@ -705,9 +783,12 @@ class span_image_resample_rgba_affine : public span_image_resample_affine<Source
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==============================================span_image_resample_rgba
|
||||
template<class Source, class Interpolator>
|
||||
class span_image_resample_rgba : public span_image_resample<Source, Interpolator>
|
||||
class span_image_resample_rgba :
|
||||
public span_image_resample<Source, Interpolator>
|
||||
{
|
||||
public:
|
||||
typedef Source source_type;
|
||||
|
@ -717,7 +798,8 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
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 {
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask,
|
||||
downscale_shift = image_filter_shift
|
||||
|
@ -725,14 +807,17 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
span_image_resample_rgba() {}
|
||||
span_image_resample_rgba(source_type& src, interpolator_type& inter, const image_filter_lut& filter)
|
||||
: base_type(src, inter, filter)
|
||||
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);
|
||||
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();
|
||||
|
@ -754,7 +839,9 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
|
||||
int radius_x = (diameter * rx) >> 1;
|
||||
int radius_y = (diameter * ry) >> 1;
|
||||
int len_x_lr = (diameter * rx + image_subpixel_mask) >> image_subpixel_shift;
|
||||
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;
|
||||
|
@ -762,12 +849,17 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
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 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_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);
|
||||
const value_type* fg_ptr =
|
||||
(const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -775,20 +867,20 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
x_hr = x_hr2;
|
||||
for(;;)
|
||||
{
|
||||
int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift;
|
||||
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;
|
||||
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;
|
||||
if(y_hr >= filter_scale) break;
|
||||
fg_ptr = (const value_type*)base_type::source().next_y();
|
||||
}
|
||||
|
||||
|
@ -797,23 +889,15 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
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[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];
|
||||
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];
|
||||
|
@ -826,6 +910,11 @@ class span_image_resample_rgba : public span_image_resample<Source, Interpolator
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
37
deps/agg/include/agg_span_interpolator_adaptor.h
vendored
37
deps/agg/include/agg_span_interpolator_adaptor.h
vendored
|
@ -18,7 +18,8 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//===============================================span_interpolator_adaptor
|
||||
template<class Interpolator, class Distortion>
|
||||
|
@ -31,22 +32,33 @@ class span_interpolator_adaptor : public Interpolator
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
span_interpolator_adaptor() {}
|
||||
span_interpolator_adaptor(const trans_type& trans, const distortion_type& dist)
|
||||
: base_type(trans)
|
||||
, m_distortion(&dist)
|
||||
{}
|
||||
span_interpolator_adaptor(const trans_type& trans,
|
||||
const distortion_type& dist) :
|
||||
base_type(trans),
|
||||
m_distortion(&dist)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_interpolator_adaptor(const trans_type& trans, const distortion_type& dist, double x, double y, unsigned len)
|
||||
: base_type(trans, x, y, len)
|
||||
, m_distortion(&dist)
|
||||
{}
|
||||
span_interpolator_adaptor(const trans_type& trans,
|
||||
const distortion_type& dist,
|
||||
double x, double y, unsigned len) :
|
||||
base_type(trans, x, y, len),
|
||||
m_distortion(&dist)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const distortion_type& distortion() const { return *m_distortion; }
|
||||
const distortion_type& distortion() const
|
||||
{
|
||||
return *m_distortion;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void distortion(const distortion_type& dist) { m_distortion = dist; }
|
||||
void distortion(const distortion_type& dist)
|
||||
{
|
||||
m_distortion = dist;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void coordinates(int* x, int* y) const
|
||||
|
@ -59,6 +71,7 @@ class span_interpolator_adaptor : public Interpolator
|
|||
//--------------------------------------------------------------------
|
||||
const distortion_type* m_distortion;
|
||||
};
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
80
deps/agg/include/agg_span_interpolator_linear.h
vendored
80
deps/agg/include/agg_span_interpolator_linear.h
vendored
|
@ -20,7 +20,8 @@
|
|||
#include "agg_dda_line.h"
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//================================================span_interpolator_linear
|
||||
template<class Transformer = trans_affine, unsigned SubpixelShift = 8>
|
||||
|
@ -29,15 +30,18 @@ class span_interpolator_linear
|
|||
public:
|
||||
typedef Transformer trans_type;
|
||||
|
||||
enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift };
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = SubpixelShift,
|
||||
subpixel_scale = 1 << subpixel_shift
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_interpolator_linear() {}
|
||||
span_interpolator_linear(const trans_type& trans)
|
||||
: m_trans(&trans)
|
||||
{}
|
||||
span_interpolator_linear(const trans_type& trans, double x, double y, unsigned len)
|
||||
: m_trans(&trans)
|
||||
span_interpolator_linear(const trans_type& trans) : m_trans(&trans) {}
|
||||
span_interpolator_linear(const trans_type& trans,
|
||||
double x, double y, unsigned len) :
|
||||
m_trans(&trans)
|
||||
{
|
||||
begin(x, y, len);
|
||||
}
|
||||
|
@ -96,6 +100,11 @@ class span_interpolator_linear
|
|||
dda2_line_interpolator m_li_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=====================================span_interpolator_linear_subdiv
|
||||
template<class Transformer = trans_affine, unsigned SubpixelShift = 8>
|
||||
class span_interpolator_linear_subdiv
|
||||
|
@ -103,31 +112,33 @@ class span_interpolator_linear_subdiv
|
|||
public:
|
||||
typedef Transformer trans_type;
|
||||
|
||||
enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift };
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = SubpixelShift,
|
||||
subpixel_scale = 1 << subpixel_shift
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
span_interpolator_linear_subdiv()
|
||||
: m_subdiv_shift(4)
|
||||
, m_subdiv_size(1 << m_subdiv_shift)
|
||||
, m_subdiv_mask(m_subdiv_size - 1)
|
||||
{}
|
||||
|
||||
span_interpolator_linear_subdiv(const trans_type& trans, unsigned subdiv_shift = 4)
|
||||
: m_subdiv_shift(subdiv_shift)
|
||||
, m_subdiv_size(1 << m_subdiv_shift)
|
||||
, m_subdiv_mask(m_subdiv_size - 1)
|
||||
, m_trans(&trans)
|
||||
{}
|
||||
span_interpolator_linear_subdiv() :
|
||||
m_subdiv_shift(4),
|
||||
m_subdiv_size(1 << m_subdiv_shift),
|
||||
m_subdiv_mask(m_subdiv_size - 1) {}
|
||||
|
||||
span_interpolator_linear_subdiv(const trans_type& trans,
|
||||
double x,
|
||||
double y,
|
||||
unsigned len,
|
||||
unsigned subdiv_shift = 4)
|
||||
: m_subdiv_shift(subdiv_shift)
|
||||
, m_subdiv_size(1 << m_subdiv_shift)
|
||||
, m_subdiv_mask(m_subdiv_size - 1)
|
||||
, m_trans(&trans)
|
||||
unsigned subdiv_shift = 4) :
|
||||
m_subdiv_shift(subdiv_shift),
|
||||
m_subdiv_size(1 << m_subdiv_shift),
|
||||
m_subdiv_mask(m_subdiv_size - 1),
|
||||
m_trans(&trans) {}
|
||||
|
||||
span_interpolator_linear_subdiv(const trans_type& trans,
|
||||
double x, double y, unsigned len,
|
||||
unsigned subdiv_shift = 4) :
|
||||
m_subdiv_shift(subdiv_shift),
|
||||
m_subdiv_size(1 << m_subdiv_shift),
|
||||
m_subdiv_mask(m_subdiv_size - 1),
|
||||
m_trans(&trans)
|
||||
{
|
||||
begin(x, y, len);
|
||||
}
|
||||
|
@ -155,8 +166,7 @@ class span_interpolator_linear_subdiv
|
|||
m_src_y = y;
|
||||
m_len = len;
|
||||
|
||||
if (len > m_subdiv_size)
|
||||
len = m_subdiv_size;
|
||||
if(len > m_subdiv_size) len = m_subdiv_size;
|
||||
tx = x;
|
||||
ty = y;
|
||||
m_trans->transform(&tx, &ty);
|
||||
|
@ -179,8 +189,7 @@ class span_interpolator_linear_subdiv
|
|||
if(m_pos >= m_subdiv_size)
|
||||
{
|
||||
unsigned len = m_len;
|
||||
if (len > m_subdiv_size)
|
||||
len = m_subdiv_size;
|
||||
if(len > m_subdiv_size) len = m_subdiv_size;
|
||||
double tx = double(m_src_x) / double(subpixel_scale) + len;
|
||||
double ty = m_src_y;
|
||||
m_trans->transform(&tx, &ty);
|
||||
|
@ -213,6 +222,11 @@ class span_interpolator_linear_subdiv
|
|||
unsigned m_len;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
84
deps/agg/include/agg_span_interpolator_persp.h
vendored
84
deps/agg/include/agg_span_interpolator_persp.h
vendored
|
@ -18,7 +18,10 @@
|
|||
#include "agg_trans_perspective.h"
|
||||
#include "agg_dda_line.h"
|
||||
|
||||
namespace agg {
|
||||
namespace agg
|
||||
{
|
||||
|
||||
|
||||
|
||||
//===========================================span_interpolator_persp_exact
|
||||
template<unsigned SubpixelShift = 8>
|
||||
|
@ -27,25 +30,36 @@ class span_interpolator_persp_exact
|
|||
public:
|
||||
typedef trans_perspective trans_type;
|
||||
typedef trans_perspective::iterator_x iterator_type;
|
||||
enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift };
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = SubpixelShift,
|
||||
subpixel_scale = 1 << subpixel_shift
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_interpolator_persp_exact() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Arbitrary quadrangle transformations
|
||||
span_interpolator_persp_exact(const double* src, const double* dst) { quad_to_quad(src, dst); }
|
||||
span_interpolator_persp_exact(const double* src, const double* dst)
|
||||
{
|
||||
quad_to_quad(src, dst);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Direct transformations
|
||||
span_interpolator_persp_exact(double x1, double y1, double x2, double y2, const double* quad)
|
||||
span_interpolator_persp_exact(double x1, double y1,
|
||||
double x2, double y2,
|
||||
const double* quad)
|
||||
{
|
||||
rect_to_quad(x1, y1, x2, y2, quad);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Reverse transformations
|
||||
span_interpolator_persp_exact(const double* quad, double x1, double y1, double x2, double y2)
|
||||
span_interpolator_persp_exact(const double* quad,
|
||||
double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
quad_to_rect(quad, x1, y1, x2, y2);
|
||||
}
|
||||
|
@ -60,7 +74,8 @@ class span_interpolator_persp_exact
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// Set the direct transformations, i.e., rectangle -> quadrangle
|
||||
void rect_to_quad(double x1, double y1, double x2, double y2, const double* quad)
|
||||
void rect_to_quad(double x1, double y1, double x2, double y2,
|
||||
const double* quad)
|
||||
{
|
||||
double src[8];
|
||||
src[0] = src[6] = x1;
|
||||
|
@ -70,9 +85,11 @@ class span_interpolator_persp_exact
|
|||
quad_to_quad(src, quad);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Set the reverse transformations, i.e., quadrangle -> rectangle
|
||||
void quad_to_rect(const double* quad, double x1, double y1, double x2, double y2)
|
||||
void quad_to_rect(const double* quad,
|
||||
double x1, double y1, double x2, double y2)
|
||||
{
|
||||
double dst[8];
|
||||
dst[0] = dst[6] = x1;
|
||||
|
@ -131,6 +148,7 @@ class span_interpolator_persp_exact
|
|||
m_scale_y = dda2_line_interpolator(sy1, sy2, len);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void resynchronize(double xe, double ye, unsigned len)
|
||||
{
|
||||
|
@ -168,6 +186,8 @@ class span_interpolator_persp_exact
|
|||
m_scale_y = dda2_line_interpolator(sy1, sy2, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void operator++()
|
||||
{
|
||||
|
@ -191,7 +211,10 @@ class span_interpolator_persp_exact
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void transform(double* x, double* y) const { m_trans_dir.transform(x, y); }
|
||||
void transform(double* x, double* y) const
|
||||
{
|
||||
m_trans_dir.transform(x, y);
|
||||
}
|
||||
|
||||
private:
|
||||
trans_type m_trans_dir;
|
||||
|
@ -201,31 +224,52 @@ class span_interpolator_persp_exact
|
|||
dda2_line_interpolator m_scale_y;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//============================================span_interpolator_persp_lerp
|
||||
template<unsigned SubpixelShift = 8>
|
||||
class span_interpolator_persp_lerp
|
||||
{
|
||||
public:
|
||||
typedef trans_perspective trans_type;
|
||||
enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift };
|
||||
enum subpixel_scale_e
|
||||
{
|
||||
subpixel_shift = SubpixelShift,
|
||||
subpixel_scale = 1 << subpixel_shift
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
span_interpolator_persp_lerp() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Arbitrary quadrangle transformations
|
||||
span_interpolator_persp_lerp(const double* src, const double* dst) { quad_to_quad(src, dst); }
|
||||
span_interpolator_persp_lerp(const double* src, const double* dst)
|
||||
{
|
||||
quad_to_quad(src, dst);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Direct transformations
|
||||
span_interpolator_persp_lerp(double x1, double y1, double x2, double y2, const double* quad)
|
||||
span_interpolator_persp_lerp(double x1, double y1,
|
||||
double x2, double y2,
|
||||
const double* quad)
|
||||
{
|
||||
rect_to_quad(x1, y1, x2, y2, quad);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Reverse transformations
|
||||
span_interpolator_persp_lerp(const double* quad, double x1, double y1, double x2, double y2)
|
||||
span_interpolator_persp_lerp(const double* quad,
|
||||
double x1, double y1,
|
||||
double x2, double y2)
|
||||
{
|
||||
quad_to_rect(quad, x1, y1, x2, y2);
|
||||
}
|
||||
|
@ -240,7 +284,8 @@ class span_interpolator_persp_lerp
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// Set the direct transformations, i.e., rectangle -> quadrangle
|
||||
void rect_to_quad(double x1, double y1, double x2, double y2, const double* quad)
|
||||
void rect_to_quad(double x1, double y1, double x2, double y2,
|
||||
const double* quad)
|
||||
{
|
||||
double src[8];
|
||||
src[0] = src[6] = x1;
|
||||
|
@ -250,9 +295,11 @@ class span_interpolator_persp_lerp
|
|||
quad_to_quad(src, quad);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Set the reverse transformations, i.e., quadrangle -> rectangle
|
||||
void quad_to_rect(const double* quad, double x1, double y1, double x2, double y2)
|
||||
void quad_to_rect(const double* quad,
|
||||
double x1, double y1, double x2, double y2)
|
||||
{
|
||||
double dst[8];
|
||||
dst[0] = dst[6] = x1;
|
||||
|
@ -327,6 +374,7 @@ class span_interpolator_persp_lerp
|
|||
m_scale_y = dda2_line_interpolator(sy1, sy2, len);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void resynchronize(double xe, double ye, unsigned len)
|
||||
{
|
||||
|
@ -370,6 +418,7 @@ class span_interpolator_persp_lerp
|
|||
m_scale_y = dda2_line_interpolator(sy1, sy2, len);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void operator++()
|
||||
{
|
||||
|
@ -394,7 +443,10 @@ class span_interpolator_persp_lerp
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
void transform(double* x, double* y) const { m_trans_dir.transform(x, y); }
|
||||
void transform(double* x, double* y) const
|
||||
{
|
||||
m_trans_dir.transform(x, y);
|
||||
}
|
||||
|
||||
private:
|
||||
trans_type m_trans_dir;
|
||||
|
@ -405,6 +457,6 @@ class span_interpolator_persp_lerp
|
|||
dda2_line_interpolator m_scale_y;
|
||||
};
|
||||
|
||||
} // namespace agg
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue