/src/MapServer/src/renderers/agg/include/agg_basics.h
Line | Count | Source |
1 | | //---------------------------------------------------------------------------- |
2 | | // Anti-Grain Geometry - Version 2.4 |
3 | | // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) |
4 | | // |
5 | | // Permission to copy, use, modify, sell and distribute this software |
6 | | // is granted provided this copyright notice appears in all copies. |
7 | | // This software is provided "as is" without express or implied |
8 | | // warranty, and with no claim as to its suitability for any purpose. |
9 | | // |
10 | | //---------------------------------------------------------------------------- |
11 | | // Contact: mcseem@antigrain.com |
12 | | // mcseemagg@yahoo.com |
13 | | // http://www.antigrain.com |
14 | | //---------------------------------------------------------------------------- |
15 | | |
16 | | #ifndef AGG_BASICS_INCLUDED |
17 | | #define AGG_BASICS_INCLUDED |
18 | | |
19 | | #include <math.h> |
20 | | #include "agg_config.h" |
21 | | |
22 | | //---------------------------------------------------------AGG_CUSTOM_ALLOCATOR |
23 | | #ifdef AGG_CUSTOM_ALLOCATOR |
24 | | #include "agg_allocator.h" |
25 | | #else |
26 | | namespace mapserver |
27 | | { |
28 | | // The policy of all AGG containers and memory allocation strategy |
29 | | // in general is that no allocated data requires explicit construction. |
30 | | // It means that the allocator can be really simple; you can even |
31 | | // replace new/delete to malloc/free. The constructors and destructors |
32 | | // won't be called in this case, however everything will remain working. |
33 | | // The second argument of deallocate() is the size of the allocated |
34 | | // block. You can use this information if you wish. |
35 | | //------------------------------------------------------------pod_allocator |
36 | | template<class T> struct pod_allocator |
37 | | { |
38 | 21.7k | static T* allocate(unsigned num) { return new T [num]; }mapserver::pod_allocator<mapserver::font_cache*>::allocate(unsigned int) Line | Count | Source | 38 | 21.7k | static T* allocate(unsigned num) { return new T [num]; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::cell_aa*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::cell_aa>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::rasterizer_cells_aa<mapserver::cell_aa>::sorted_y>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_u8::span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<unsigned char>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::rgba8>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::rgba8*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::line_aa_vertex*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::line_aa_vertex>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_p8::span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<double*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<double>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<ClipperLib::IntPoint*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<ClipperLib::IntPoint>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::block_allocator::block_type>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_p8::span*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_p8::span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_u8::span*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_u8::span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_bin::span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_bin::span*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_bin::span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_dist*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_dist>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::point_base<double>*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::point_base<double> >::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_bin::span_data*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_bin::span_data>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_bin::scanline_data*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_bin::scanline_data>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<unsigned char*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_cell_storage<unsigned char>::extra_span*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_cell_storage<unsigned char>::extra_span>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::span_data*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::span_data>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::scanline_data*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::scanline_data>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_integer<int, 6u>*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_integer<int, 6u> >::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_integer<short, 6u>*>::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_integer<short, 6u> >::allocate(unsigned int) Unexecuted instantiation: mapserver::pod_allocator<unsigned int*>::allocate(unsigned int) |
39 | 405k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; }Unexecuted instantiation: mapserver::pod_allocator<mapserver::line_aa_vertex>::deallocate(mapserver::line_aa_vertex*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::line_aa_vertex*>::deallocate(mapserver::line_aa_vertex**&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::rgba8>::deallocate(mapserver::rgba8*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::rgba8*>::deallocate(mapserver::rgba8**&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::point_base<double> >::deallocate(mapserver::point_base<double>*&, unsigned int) mapserver::pod_allocator<mapserver::point_base<double>*>::deallocate(mapserver::point_base<double>**&, unsigned int) Line | Count | Source | 39 | 91.6k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_dist>::deallocate(mapserver::vertex_dist*&, unsigned int) mapserver::pod_allocator<mapserver::vertex_dist*>::deallocate(mapserver::vertex_dist**&, unsigned int) Line | Count | Source | 39 | 1.53k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<double>::deallocate(double*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<double*>::deallocate(double**&, unsigned int) mapserver::pod_allocator<mapserver::rasterizer_cells_aa<mapserver::cell_aa>::sorted_y>::deallocate(mapserver::rasterizer_cells_aa<mapserver::cell_aa>::sorted_y*&, unsigned int) Line | Count | Source | 39 | 23.5k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
mapserver::pod_allocator<mapserver::cell_aa*>::deallocate(mapserver::cell_aa**&, unsigned int) Line | Count | Source | 39 | 23.5k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::cell_aa>::deallocate(mapserver::cell_aa*&, unsigned int) mapserver::pod_allocator<unsigned char>::deallocate(unsigned char*&, unsigned int) Line | Count | Source | 39 | 23.5k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
mapserver::pod_allocator<mapserver::scanline_u8::span>::deallocate(mapserver::scanline_u8::span*&, unsigned int) Line | Count | Source | 39 | 22.6k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
mapserver::pod_allocator<mapserver::scanline_p8::span>::deallocate(mapserver::scanline_p8::span*&, unsigned int) Line | Count | Source | 39 | 893 | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::block_allocator::block_type>::deallocate(mapserver::block_allocator::block_type*&, unsigned int) mapserver::pod_allocator<mapserver::font_cache*>::deallocate(mapserver::font_cache**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<ClipperLib::IntPoint>::deallocate(ClipperLib::IntPoint*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<ClipperLib::IntPoint*>::deallocate(ClipperLib::IntPoint**&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_p8::span>::deallocate(mapserver::scanline32_p8::span*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_p8::span*>::deallocate(mapserver::scanline32_p8::span**&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_u8::span>::deallocate(mapserver::scanline32_u8::span*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_u8::span*>::deallocate(mapserver::scanline32_u8::span**&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_bin::span_data>::deallocate(mapserver::scanline_storage_bin::span_data*&, unsigned int) mapserver::pod_allocator<mapserver::scanline_storage_bin::span_data*>::deallocate(mapserver::scanline_storage_bin::span_data**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_bin::scanline_data>::deallocate(mapserver::scanline_storage_bin::scanline_data*&, unsigned int) mapserver::pod_allocator<mapserver::scanline_storage_bin::scanline_data*>::deallocate(mapserver::scanline_storage_bin::scanline_data**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
mapserver::pod_allocator<mapserver::scanline_bin::span>::deallocate(mapserver::scanline_bin::span*&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_bin::span>::deallocate(mapserver::scanline32_bin::span*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline32_bin::span*>::deallocate(mapserver::scanline32_bin::span**&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<short>::deallocate(short*&, unsigned int) Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::scanline_data>::deallocate(mapserver::scanline_storage_aa<unsigned char>::scanline_data*&, unsigned int) mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::scanline_data*>::deallocate(mapserver::scanline_storage_aa<unsigned char>::scanline_data**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::span_data>::deallocate(mapserver::scanline_storage_aa<unsigned char>::span_data*&, unsigned int) mapserver::pod_allocator<mapserver::scanline_storage_aa<unsigned char>::span_data*>::deallocate(mapserver::scanline_storage_aa<unsigned char>::span_data**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::scanline_cell_storage<unsigned char>::extra_span>::deallocate(mapserver::scanline_cell_storage<unsigned char>::extra_span*&, unsigned int) mapserver::pod_allocator<mapserver::scanline_cell_storage<unsigned char>::extra_span*>::deallocate(mapserver::scanline_cell_storage<unsigned char>::extra_span**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
mapserver::pod_allocator<unsigned char*>::deallocate(unsigned char**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_integer<int, 6u> >::deallocate(mapserver::vertex_integer<int, 6u>*&, unsigned int) mapserver::pod_allocator<mapserver::vertex_integer<int, 6u>*>::deallocate(mapserver::vertex_integer<int, 6u>**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<mapserver::vertex_integer<short, 6u> >::deallocate(mapserver::vertex_integer<short, 6u>*&, unsigned int) mapserver::pod_allocator<mapserver::vertex_integer<short, 6u>*>::deallocate(mapserver::vertex_integer<short, 6u>**&, unsigned int) Line | Count | Source | 39 | 21.7k | static void deallocate(T*& ptr, unsigned) { delete [] ptr; ptr = nullptr; } |
Unexecuted instantiation: mapserver::pod_allocator<unsigned int*>::deallocate(unsigned int**&, unsigned int) |
40 | | }; |
41 | | |
42 | | // Single object allocator. It's also can be replaced with your custom |
43 | | // allocator. The difference is that it can only allocate a single |
44 | | // object and the constructor and destructor must be called. |
45 | | // In AGG there is no need to allocate an array of objects with |
46 | | // calling their constructors (only single ones). So that, if you |
47 | | // replace these new/delete to malloc/free make sure that the in-place |
48 | | // new is called and take care of calling the destructor too. |
49 | | //------------------------------------------------------------obj_allocator |
50 | | template<class T> struct obj_allocator |
51 | | { |
52 | 0 | static T* allocate() { return new T; } |
53 | 0 | static void deallocate(T* ptr) { delete ptr; } |
54 | | }; |
55 | | } |
56 | | #endif |
57 | | |
58 | | |
59 | | //-------------------------------------------------------- Default basic types |
60 | | // |
61 | | // If the compiler has different capacity of the basic types you can redefine |
62 | | // them via the compiler command line or by generating agg_config.h that is |
63 | | // empty by default. |
64 | | // |
65 | | #ifndef AGG_INT8 |
66 | | #define AGG_INT8 signed char |
67 | | #endif |
68 | | |
69 | | #ifndef AGG_INT8U |
70 | | #define AGG_INT8U unsigned char |
71 | | #endif |
72 | | |
73 | | #ifndef AGG_INT16 |
74 | | #define AGG_INT16 short |
75 | | #endif |
76 | | |
77 | | #ifndef AGG_INT16U |
78 | | #define AGG_INT16U unsigned short |
79 | | #endif |
80 | | |
81 | | #ifndef AGG_INT32 |
82 | | #define AGG_INT32 int |
83 | | #endif |
84 | | |
85 | | #ifndef AGG_INT32U |
86 | | #define AGG_INT32U unsigned |
87 | | #endif |
88 | | |
89 | | #ifndef AGG_INT64 |
90 | | #if defined(_MSC_VER) || defined(__BORLANDC__) |
91 | | #define AGG_INT64 signed __int64 |
92 | | #define AGG_INT64_FRMT "%I64d" |
93 | | #else |
94 | | #define AGG_INT64 signed long long |
95 | | #define AGG_INT64_FRMT "%lld" |
96 | | #endif |
97 | | #endif |
98 | | |
99 | | #ifndef AGG_INT64U |
100 | | #if defined(_MSC_VER) || defined(__BORLANDC__) |
101 | | #define AGG_INT64U unsigned __int64 |
102 | | #define AGG_INT64U_FRMT "%I64u" |
103 | | #else |
104 | | #define AGG_INT64U unsigned long long |
105 | | #define AGG_INT64U_FRMT "%llu" |
106 | | #endif |
107 | | #endif |
108 | | |
109 | | //------------------------------------------------ Some fixes for MS Visual C++ |
110 | | #if defined(_MSC_VER) |
111 | | #pragma warning(disable:4786) // Identifier was truncated... |
112 | | #endif |
113 | | |
114 | | #if defined(_MSC_VER) |
115 | | #define AGG_INLINE __forceinline |
116 | | #else |
117 | | #define AGG_INLINE inline |
118 | | #endif |
119 | | |
120 | | namespace mapserver |
121 | | { |
122 | | //------------------------------------------------------------------------- |
123 | | typedef AGG_INT8 int8; //----int8 |
124 | | typedef AGG_INT8U int8u; //----int8u |
125 | | typedef AGG_INT16 int16; //----int16 |
126 | | typedef AGG_INT16U int16u; //----int16u |
127 | | typedef AGG_INT32 int32; //----int32 |
128 | | typedef AGG_INT32U int32u; //----int32u |
129 | | typedef AGG_INT64 int64; //----int64 |
130 | | typedef AGG_INT64U int64u; //----int64u |
131 | | |
132 | | #if defined(AGG_FISTP) |
133 | | #pragma warning(push) |
134 | | #pragma warning(disable : 4035) //Disable warning "no return value" |
135 | | AGG_INLINE int iround(double v) //-------iround |
136 | | { |
137 | | int t; |
138 | | __asm fld qword ptr [v] |
139 | | __asm fistp dword ptr [t] |
140 | | __asm mov eax, dword ptr [t] |
141 | | } |
142 | | AGG_INLINE unsigned uround(double v) //-------uround |
143 | | { |
144 | | unsigned t; |
145 | | __asm fld qword ptr [v] |
146 | | __asm fistp dword ptr [t] |
147 | | __asm mov eax, dword ptr [t] |
148 | | } |
149 | | #pragma warning(pop) |
150 | | AGG_INLINE unsigned ufloor(double v) //-------ufloor |
151 | | { |
152 | | return unsigned(floor(v)); |
153 | | } |
154 | | AGG_INLINE unsigned uceil(double v) //--------uceil |
155 | | { |
156 | | return unsigned(ceil(v)); |
157 | | } |
158 | | #elif defined(AGG_QIFIST) |
159 | | AGG_INLINE int iround(double v) |
160 | | { |
161 | | return int(v); |
162 | | } |
163 | | AGG_INLINE int uround(double v) |
164 | | { |
165 | | return unsigned(v); |
166 | | } |
167 | | AGG_INLINE unsigned ufloor(double v) |
168 | | { |
169 | | return unsigned(floor(v)); |
170 | | } |
171 | | AGG_INLINE unsigned uceil(double v) |
172 | | { |
173 | | return unsigned(ceil(v)); |
174 | | } |
175 | | #else |
176 | | AGG_INLINE int iround(double v) |
177 | 0 | { |
178 | 0 | #ifdef HAVE_LRINT |
179 | 0 | return lrint(v); |
180 | | #else |
181 | | return int((v < 0.0) ? v - 0.5 : v + 0.5); |
182 | | #endif |
183 | 0 | } |
184 | | AGG_INLINE int uround(double v) |
185 | 228k | { |
186 | 228k | return unsigned(v + 0.5); |
187 | 228k | } |
188 | | AGG_INLINE unsigned ufloor(double v) |
189 | 0 | { |
190 | 0 | return unsigned(v); |
191 | 0 | } |
192 | | AGG_INLINE unsigned uceil(double v) |
193 | 0 | { |
194 | 0 | return unsigned(ceil(v)); |
195 | 0 | } |
196 | | #endif |
197 | | |
198 | | //---------------------------------------------------------------saturation |
199 | | template<int Limit> struct saturation |
200 | | { |
201 | | AGG_INLINE static int iround(double v) |
202 | 0 | { |
203 | 0 | if(v < double(-Limit)) return -Limit; |
204 | 0 | if(v > double( Limit)) return Limit; |
205 | 0 | return mapserver::iround(v); |
206 | 0 | } Unexecuted instantiation: mapserver::saturation<268435455>::iround(double) Unexecuted instantiation: mapserver::saturation<1073741823>::iround(double) |
207 | | }; |
208 | | |
209 | | //------------------------------------------------------------------mul_one |
210 | | template<unsigned Shift> struct mul_one |
211 | | { |
212 | | AGG_INLINE static unsigned mul(unsigned a, unsigned b) |
213 | | { |
214 | | const unsigned q = a * b + (1 << (Shift-1)); |
215 | | return (q + (q >> Shift)) >> Shift; |
216 | | } |
217 | | }; |
218 | | |
219 | | //------------------------------------------------------------------------- |
220 | | typedef unsigned char cover_type; //----cover_type |
221 | | enum cover_scale_e |
222 | | { |
223 | | cover_shift = 8, //----cover_shift |
224 | | cover_size = 1 << cover_shift, //----cover_size |
225 | | cover_mask = cover_size - 1, //----cover_mask |
226 | | cover_none = 0, //----cover_none |
227 | | cover_full = cover_mask //----cover_full |
228 | | }; |
229 | | |
230 | | //----------------------------------------------------poly_subpixel_scale_e |
231 | | // These constants determine the subpixel accuracy, to be more precise, |
232 | | // the number of bits of the fractional part of the coordinates. |
233 | | // The possible coordinate capacity in bits can be calculated by formula: |
234 | | // sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and |
235 | | // 8-bits fractional part the capacity is 24 bits. |
236 | | enum poly_subpixel_scale_e |
237 | | { |
238 | | poly_subpixel_shift = 8, //----poly_subpixel_shift |
239 | | poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale |
240 | | poly_subpixel_mask = poly_subpixel_scale-1, //----poly_subpixel_mask |
241 | | }; |
242 | | |
243 | | //----------------------------------------------------------filling_rule_e |
244 | | enum filling_rule_e |
245 | | { |
246 | | fill_non_zero, |
247 | | fill_even_odd |
248 | | }; |
249 | | |
250 | | //-----------------------------------------------------------------------pi |
251 | | const double pi = 3.14159265358979323846; |
252 | | |
253 | | //------------------------------------------------------------------deg2rad |
254 | | inline double deg2rad(double deg) |
255 | 0 | { |
256 | 0 | return deg * pi / 180.0; |
257 | 0 | } |
258 | | |
259 | | //------------------------------------------------------------------rad2deg |
260 | | inline double rad2deg(double rad) |
261 | 0 | { |
262 | 0 | return rad * 180.0 / pi; |
263 | 0 | } |
264 | | |
265 | | //----------------------------------------------------------------rect_base |
266 | | template<class T> struct rect_base |
267 | | { |
268 | | typedef T value_type; |
269 | | typedef rect_base<T> self_type; |
270 | | T x1, y1, x2, y2; |
271 | | |
272 | | rect_base() {} |
273 | | rect_base(T x1_, T y1_, T x2_, T y2_) : |
274 | 48.9k | x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}mapserver::rect_base<int>::rect_base(int, int, int, int) Line | Count | Source | 274 | 48.9k | x1(x1_), y1(y1_), x2(x2_), y2(y2_) {} |
Unexecuted instantiation: mapserver::rect_base<double>::rect_base(double, double, double, double) |
275 | | |
276 | | void init(T x1_, T y1_, T x2_, T y2_) |
277 | | { |
278 | | x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; |
279 | | } |
280 | | |
281 | | const self_type& normalize() |
282 | | { |
283 | | T t; |
284 | | if(x1 > x2) { t = x1; x1 = x2; x2 = t; } |
285 | | if(y1 > y2) { t = y1; y1 = y2; y2 = t; } |
286 | | return *this; |
287 | | } |
288 | | |
289 | | bool clip(const self_type& r) |
290 | | { |
291 | | if(x2 > r.x2) x2 = r.x2; |
292 | | if(y2 > r.y2) y2 = r.y2; |
293 | | if(x1 < r.x1) x1 = r.x1; |
294 | | if(y1 < r.y1) y1 = r.y1; |
295 | | return x1 <= x2 && y1 <= y2; |
296 | | } |
297 | | |
298 | | bool is_valid() const |
299 | | { |
300 | | return x1 <= x2 && y1 <= y2; |
301 | | } |
302 | | |
303 | | bool hit_test(T x, T y) const |
304 | | { |
305 | | return (x >= x1 && x <= x2 && y >= y1 && y <= y2); |
306 | | } |
307 | | }; |
308 | | |
309 | | //-----------------------------------------------------intersect_rectangles |
310 | | template<class Rect> |
311 | | inline Rect intersect_rectangles(const Rect& r1, const Rect& r2) |
312 | | { |
313 | | Rect r = r1; |
314 | | |
315 | | // First process x2,y2 because the other order |
316 | | // results in Internal Compiler Error under |
317 | | // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in |
318 | | // case of "Maximize Speed" optimization option. |
319 | | //----------------- |
320 | | if(r.x2 > r2.x2) r.x2 = r2.x2; |
321 | | if(r.y2 > r2.y2) r.y2 = r2.y2; |
322 | | if(r.x1 < r2.x1) r.x1 = r2.x1; |
323 | | if(r.y1 < r2.y1) r.y1 = r2.y1; |
324 | | return r; |
325 | | } |
326 | | |
327 | | |
328 | | //---------------------------------------------------------unite_rectangles |
329 | | template<class Rect> |
330 | | inline Rect unite_rectangles(const Rect& r1, const Rect& r2) |
331 | | { |
332 | | Rect r = r1; |
333 | | if(r.x2 < r2.x2) r.x2 = r2.x2; |
334 | | if(r.y2 < r2.y2) r.y2 = r2.y2; |
335 | | if(r.x1 > r2.x1) r.x1 = r2.x1; |
336 | | if(r.y1 > r2.y1) r.y1 = r2.y1; |
337 | | return r; |
338 | | } |
339 | | |
340 | | typedef rect_base<int> rect_i; //----rect_i |
341 | | typedef rect_base<float> rect_f; //----rect_f |
342 | | typedef rect_base<double> rect_d; //----rect_d |
343 | | |
344 | | //---------------------------------------------------------path_commands_e |
345 | | enum path_commands_e |
346 | | { |
347 | | path_cmd_stop = 0, //----path_cmd_stop |
348 | | path_cmd_move_to = 1, //----path_cmd_move_to |
349 | | path_cmd_line_to = 2, //----path_cmd_line_to |
350 | | path_cmd_curve3 = 3, //----path_cmd_curve3 |
351 | | path_cmd_curve4 = 4, //----path_cmd_curve4 |
352 | | path_cmd_curveN = 5, //----path_cmd_curveN |
353 | | path_cmd_catrom = 6, //----path_cmd_catrom |
354 | | path_cmd_ubspline = 7, //----path_cmd_ubspline |
355 | | path_cmd_end_poly = 0x0F, //----path_cmd_end_poly |
356 | | path_cmd_mask = 0x0F //----path_cmd_mask |
357 | | }; |
358 | | |
359 | | //------------------------------------------------------------path_flags_e |
360 | | enum path_flags_e |
361 | | { |
362 | | path_flags_none = 0, //----path_flags_none |
363 | | path_flags_ccw = 0x10, //----path_flags_ccw |
364 | | path_flags_cw = 0x20, //----path_flags_cw |
365 | | path_flags_close = 0x40, //----path_flags_close |
366 | | path_flags_mask = 0xF0 //----path_flags_mask |
367 | | }; |
368 | | |
369 | | //---------------------------------------------------------------is_vertex |
370 | | inline bool is_vertex(unsigned c) |
371 | 0 | { |
372 | 0 | return c >= path_cmd_move_to && c < path_cmd_end_poly; |
373 | 0 | } |
374 | | |
375 | | //--------------------------------------------------------------is_drawing |
376 | | inline bool is_drawing(unsigned c) |
377 | 0 | { |
378 | 0 | return c >= path_cmd_line_to && c < path_cmd_end_poly; |
379 | 0 | } |
380 | | |
381 | | //-----------------------------------------------------------------is_stop |
382 | | inline bool is_stop(unsigned c) |
383 | 10.7k | { |
384 | 10.7k | return c == path_cmd_stop; |
385 | 10.7k | } |
386 | | |
387 | | //--------------------------------------------------------------is_move_to |
388 | | inline bool is_move_to(unsigned c) |
389 | 0 | { |
390 | 0 | return c == path_cmd_move_to; |
391 | 0 | } |
392 | | |
393 | | //--------------------------------------------------------------is_line_to |
394 | | inline bool is_line_to(unsigned c) |
395 | 0 | { |
396 | 0 | return c == path_cmd_line_to; |
397 | 0 | } |
398 | | |
399 | | //----------------------------------------------------------------is_curve |
400 | | inline bool is_curve(unsigned c) |
401 | 0 | { |
402 | 0 | return c == path_cmd_curve3 || c == path_cmd_curve4; |
403 | 0 | } |
404 | | |
405 | | //---------------------------------------------------------------is_curve3 |
406 | | inline bool is_curve3(unsigned c) |
407 | 0 | { |
408 | 0 | return c == path_cmd_curve3; |
409 | 0 | } |
410 | | |
411 | | //---------------------------------------------------------------is_curve4 |
412 | | inline bool is_curve4(unsigned c) |
413 | 0 | { |
414 | 0 | return c == path_cmd_curve4; |
415 | 0 | } |
416 | | |
417 | | //-------------------------------------------------------------is_end_poly |
418 | | inline bool is_end_poly(unsigned c) |
419 | 0 | { |
420 | 0 | return (c & path_cmd_mask) == path_cmd_end_poly; |
421 | 0 | } |
422 | | |
423 | | //----------------------------------------------------------------is_close |
424 | | inline bool is_close(unsigned c) |
425 | 0 | { |
426 | 0 | return (c & ~(path_flags_cw | path_flags_ccw)) == |
427 | 0 | (path_cmd_end_poly | path_flags_close); |
428 | 0 | } |
429 | | |
430 | | //------------------------------------------------------------is_next_poly |
431 | | inline bool is_next_poly(unsigned c) |
432 | 0 | { |
433 | 0 | return is_stop(c) || is_move_to(c) || is_end_poly(c); |
434 | 0 | } |
435 | | |
436 | | //-------------------------------------------------------------------is_cw |
437 | | inline bool is_cw(unsigned c) |
438 | 0 | { |
439 | 0 | return (c & path_flags_cw) != 0; |
440 | 0 | } |
441 | | |
442 | | //------------------------------------------------------------------is_ccw |
443 | | inline bool is_ccw(unsigned c) |
444 | 0 | { |
445 | 0 | return (c & path_flags_ccw) != 0; |
446 | 0 | } |
447 | | |
448 | | //-------------------------------------------------------------is_oriented |
449 | | inline bool is_oriented(unsigned c) |
450 | 0 | { |
451 | 0 | return (c & (path_flags_cw | path_flags_ccw)) != 0; |
452 | 0 | } |
453 | | |
454 | | //---------------------------------------------------------------is_closed |
455 | | inline bool is_closed(unsigned c) |
456 | 0 | { |
457 | 0 | return (c & path_flags_close) != 0; |
458 | 0 | } |
459 | | |
460 | | //----------------------------------------------------------get_close_flag |
461 | | inline unsigned get_close_flag(unsigned c) |
462 | 0 | { |
463 | 0 | return c & path_flags_close; |
464 | 0 | } |
465 | | |
466 | | //-------------------------------------------------------clear_orientation |
467 | | inline unsigned clear_orientation(unsigned c) |
468 | 0 | { |
469 | 0 | return c & ~(path_flags_cw | path_flags_ccw); |
470 | 0 | } |
471 | | |
472 | | //---------------------------------------------------------get_orientation |
473 | | inline unsigned get_orientation(unsigned c) |
474 | 0 | { |
475 | 0 | return c & (path_flags_cw | path_flags_ccw); |
476 | 0 | } |
477 | | |
478 | | //---------------------------------------------------------set_orientation |
479 | | inline unsigned set_orientation(unsigned c, unsigned o) |
480 | 0 | { |
481 | 0 | return clear_orientation(c) | o; |
482 | 0 | } |
483 | | |
484 | | //--------------------------------------------------------------point_base |
485 | | template<class T> struct point_base |
486 | | { |
487 | | typedef T value_type; |
488 | | T x = 0,y = 0; |
489 | 0 | point_base() = default; |
490 | 0 | point_base(T x_, T y_) : x(x_), y(y_) {} |
491 | | }; |
492 | | typedef point_base<int> point_i; //-----point_i |
493 | | typedef point_base<float> point_f; //-----point_f |
494 | | typedef point_base<double> point_d; //-----point_d |
495 | | |
496 | | //-------------------------------------------------------------vertex_base |
497 | | template<class T> struct vertex_base |
498 | | { |
499 | | typedef T value_type; |
500 | | T x,y; |
501 | | unsigned cmd; |
502 | | vertex_base() {} |
503 | | vertex_base(T x_, T y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {} |
504 | | }; |
505 | | typedef vertex_base<int> vertex_i; //-----vertex_i |
506 | | typedef vertex_base<float> vertex_f; //-----vertex_f |
507 | | typedef vertex_base<double> vertex_d; //-----vertex_d |
508 | | |
509 | | //----------------------------------------------------------------row_info |
510 | | template<class T> struct row_info |
511 | | { |
512 | | int x1, x2; |
513 | | T* ptr; |
514 | | row_info() {} |
515 | | row_info(int x1_, int x2_, T* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {} |
516 | | }; |
517 | | |
518 | | //----------------------------------------------------------const_row_info |
519 | | template<class T> struct const_row_info |
520 | | { |
521 | | int x1, x2; |
522 | | const T* ptr; |
523 | | const_row_info() {} |
524 | | const_row_info(int x1_, int x2_, const T* ptr_) : |
525 | 0 | x1(x1_), x2(x2_), ptr(ptr_) {} |
526 | | }; |
527 | | |
528 | | //------------------------------------------------------------is_equal_eps |
529 | | template<class T> inline bool is_equal_eps(T v1, T v2, T epsilon) |
530 | 0 | { |
531 | 0 | return fabs(v1 - v2) <= double(epsilon); |
532 | 0 | } |
533 | | |
534 | | } |
535 | | |
536 | | |
537 | | #endif |
538 | | |