15 #ifndef AGG_LINE_AA_BASICS_INCLUDED 16 #define AGG_LINE_AA_BASICS_INCLUDED 19 #include "agg_basics.h" 27 enum line_subpixel_scale_e
29 line_subpixel_shift = 8,
30 line_subpixel_scale = 1 << line_subpixel_shift,
31 line_subpixel_mask = line_subpixel_scale - 1,
32 line_max_coord = (1 << 28) - 1,
33 line_max_length = 1 << (line_subpixel_shift + 10)
37 enum line_mr_subpixel_scale_e
39 line_mr_subpixel_shift = 4,
40 line_mr_subpixel_scale = 1 << line_mr_subpixel_shift,
41 line_mr_subpixel_mask = line_mr_subpixel_scale - 1
45 AGG_INLINE
int line_mr(
int x)
47 return x >> (line_subpixel_shift - line_mr_subpixel_shift);
51 AGG_INLINE
int line_hr(
int x)
53 return x << (line_subpixel_shift - line_mr_subpixel_shift);
57 AGG_INLINE
int line_dbl_hr(
int x)
59 return x << line_subpixel_shift;
65 AGG_INLINE
static int conv(
double x)
67 return iround(x * line_subpixel_scale);
74 AGG_INLINE
static int conv(
double x)
86 x1(x1_), y1(y1_), x2(x2_), y2(y2_),
87 dx(std::abs(x2_ - x1_)),
88 dy(std::abs(y2_ - y1_)),
89 sx((x2_ > x1_) ? 1 : -1),
90 sy((y2_ > y1_) ? 1 : -1),
92 inc(vertical ? sy : sx),
94 octant((sy & 4) | (sx & 2) |
int(vertical))
99 unsigned orthogonal_quadrant()
const {
return s_orthogonal_quadrant[octant]; }
100 unsigned diagonal_quadrant()
const {
return s_diagonal_quadrant[octant]; }
105 return s_orthogonal_quadrant[octant] == s_orthogonal_quadrant[lp.octant];
111 return s_diagonal_quadrant[octant] == s_diagonal_quadrant[lp.octant];
117 int xmid = (x1 + x2) >> 1;
118 int ymid = (y1 + y2) >> 1;
127 lp1.dx = std::abs(lp1.x2 - lp1.x1);
128 lp1.dy = std::abs(lp1.y2 - lp1.y1);
133 lp2.dx = std::abs(lp2.x2 - lp2.x1);
134 lp2.dy = std::abs(lp2.y2 - lp2.y1);
138 int x1, y1, x2, y2, dx, dy, sx, sy;
145 static const int8u s_orthogonal_quadrant[8];
146 static const int8u s_diagonal_quadrant[8];
163 int d = iround((
double(*x - lp.x2) *
double(lp.y2 - lp.y1) -
164 double(*y - lp.y2) *
double(lp.x2 - lp.x1)) / lp.len);
165 if(d < line_subpixel_scale/2)
167 *x = lp.x1 + (lp.y2 - lp.y1);
168 *y = lp.y1 - (lp.x2 - lp.x1);
177 int d = iround((
double(*x - lp.x2) *
double(lp.y2 - lp.y1) -
178 double(*y - lp.y2) *
double(lp.x2 - lp.x1)) / lp.len);
179 if(d < line_subpixel_scale/2)
181 *x = lp.x2 + (lp.y2 - lp.y1);
182 *y = lp.y2 - (lp.x2 - lp.x1);