Compare commits

..

203 commits

Author SHA1 Message Date
Dane Springmeyer
8226b30f1f update CHANGELOG for mapnik v0.7.3 release 2012-11-08 15:18:46 -05:00
Dane Springmeyer
4d04ed01c0 setting up for mapnik v0.7.3 release 2012-11-08 15:17:51 -05:00
Dane Springmeyer
5c0c072b21 link libmapnik and boost system to help avoid any linking errors with more recent boost - closes #1567 2012-11-08 15:07:50 -05:00
Dane Springmeyer
1c74e61249 fix string concatenation in ogr plugin 2012-11-08 15:06:30 -05:00
Dane Springmeyer
efd002a3c6 fix compile with recent clang++ (still works with older g++) 2012-11-08 15:05:51 -05:00
Dane Springmeyer
6cfbabec18 port usr/local precendence in sorting to 0.7.x from master 2012-05-07 11:04:14 -07:00
Dane Springmeyer
6737bd959f backport hextree sorting fix to 0.7.x series - refs #1087 2012-02-23 15:58:23 -08:00
Dane Springmeyer
5572514354 Add properties and methods onto shield symbolizer - refs #935 and #612 2011-10-27 10:59:02 -07:00
Robert Coup
b4f8577234 Do a proper check for BOOST_PYTHON_LIB in scons, and change it to be only the library name. re: mapnik-packaging:#3 2011-10-21 23:50:59 -07:00
Robert Coup
c5d2057d7e Add .gitignore 2011-10-21 23:50:17 -07:00
Dane Springmeyer
bc5cabeb6a add to 0.7.2 changelog 2011-10-18 11:46:55 -07:00
Dane Springmeyer
93ffb4c694 add 0.7.2 forward compatibility with mapnik 2.x text/shield symbolizer change (although this is only a deprecation warning in 2.0.0) - closes #898 2011-10-18 08:36:17 -07:00
Dane Springmeyer
75813f71c0 avoid compiler warning 2011-08-20 00:36:40 +00:00
Dane Springmeyer
e8474a57a3 better forward compatibility with mapnik2 for the text-transform property 2011-07-05 19:47:06 +00:00
Dane Springmeyer
bc0c4c7f20 ensure the fallback for mapnik2 compatibility works (bug was redeclaring 'text_convert_e') 2011-07-05 19:40:10 +00:00
Dane Springmeyer
4196bcd1e0 libpng 1.5.x compatibility 2011-07-05 19:20:32 +00:00
Dane Springmeyer
fa6eb983af backport fixes from trunk for null and multipatch shape types 2011-05-19 22:00:41 +00:00
Dane Springmeyer
fffae3c3d6 update 0.7.2 changelog 2011-05-19 22:00:13 +00:00
Robert Coup
579f4d7484 Make python bindings for cairo work when running with git and not svn 2011-02-28 21:49:53 +00:00
Dane Springmeyer
deab48dddc one last workaround for now to fix potential gdal -framework configuration problem 2011-02-06 05:30:31 +00:00
Dane Springmeyer
ba4f6feecc forward compatibility with where mapnik 2.0 is going by changing underscores to dashes - see #644 2011-02-05 02:56:18 +00:00
Dane Springmeyer
48c4a86abb backport r2570 from trunk - fix for gdal framework installer 2011-02-05 02:12:22 +00:00
Dane Springmeyer
70b5f62759 tabs -> spaces 2011-02-05 01:48:43 +00:00
Dane Springmeyer
921d77557a remove code accidentally committed in r2547 2011-02-05 01:40:46 +00:00
Dane Springmeyer
80aab72438 add missing serialization of max_char_angle_delta 2011-02-02 03:38:14 +00:00
Dane Springmeyer
72399f0b23 fix reading of height value for building_symbolizer 2011-01-28 20:47:09 +00:00
Marcin Rudowski
9e0b15f814 replace cairo_pattern with trunk implementation to remove missing rasters bug with cairo (referencing data_ after delete) 2011-01-23 15:30:49 +00:00
Marcin Rudowski
c14d063069 missing mapnik2 XML compatibility for ShieldSymbolizer 2011-01-23 15:23:24 +00:00
Dane Springmeyer
c378ddb55e boost filesystem v3 support, ported from trunk 2011-01-06 00:29:03 +00:00
Dane Springmeyer
4a962d9d9e allow clang trunk compile 2011-01-06 00:28:16 +00:00
Dane Springmeyer
2ee9c3b5f3 better handling of alpha blending - patch from cdestigter - closes #674 2010-12-21 18:59:51 +00:00
Dane Springmeyer
5646dc3e33 actually add the mapnik.dtd 2010-12-15 17:23:43 +00:00
Dane Springmeyer
5c52488666 add draft xml dtd for validating xml stylesheets - #684 2010-12-13 17:52:59 +00:00
Dane Springmeyer
b713413b5c typo 2010-12-03 16:46:46 +00:00
Dane Springmeyer
48c41c305a fix compile error in gdal plugin when building in debug mode, due to patch backported from trunk innapropriately 2010-12-03 16:39:55 +00:00
Dane Springmeyer
81f4e50e8f actually parse label_position_tolerance from xml 2010-12-01 17:40:17 +00:00
Dane Springmeyer
ed2e364cf8 scons: linking libmapnik to boost_system is required solaris in 64 bit 2010-12-01 02:48:48 +00:00
Dane Springmeyer
23a77266ab scons: solaris expects 64 bit python modules to be in a subdirectory called '64' that appears to not need an __init__.py 2010-12-01 02:00:48 +00:00
Dane Springmeyer
166e1b35a5 scons: test whether python is 64bit enabled 2010-12-01 01:42:19 +00:00
Dane Springmeyer
1b42882c90 scons: enable user configuration of C compiler - only used in configure checks 2010-11-30 18:47:41 +00:00
Robert Coup
ceb16fbb26 #584: make \n trigger line breaks in labels. 2010-11-30 02:53:41 +00:00
Dane Springmeyer
9d1f73fc42 scons: enable the customization of LTDL (libtool) paths 2010-11-23 17:04:03 +00:00
Lucio Asnaghi
b4421bc39c + backports cosmetics
+ backports avoid static string as datasource name
2010-11-16 21:20:40 +00:00
Lucio Asnaghi
980098e2d5 - backport of occi changes to 0.7.2
- address wrong usage of spatial filter
- avoid using connection pool when not needed
- support collections and multiple geometry features correctly
2010-11-16 20:48:11 +00:00
Lucio Asnaghi
3349cb5823 + avoid using static string as datasource name 2010-11-16 17:54:13 +00:00
Lucio Asnaghi
76f1de2033 + osm dataset cosmetics
+ remove static datasource name string
2010-11-16 17:52:20 +00:00
Lucio Asnaghi
6a96d6c29e + backport changes to bind properly (no ogr calls in constructor)
+ backport layer_by_index (useful a lot)
2010-11-16 17:49:42 +00:00
Lucio Asnaghi
82ed88a940 + fix resolving the table name properly
+ remove unused imports
+ don't use static string for datasource name
2010-11-16 17:47:23 +00:00
Lucio Asnaghi
d8ea5582fb + backport of small change in raster datasource from trunk 2010-11-16 17:45:42 +00:00
Dane Springmeyer
707f2dca74 osm plugin: make sure to read in data from new file - closes #542 2010-11-13 21:46:40 +00:00
Dane Springmeyer
61c0b90a7a scons: make sure to check for curl - backport of fix for #651 from trunk 2010-11-08 21:20:57 +00:00
Dane Springmeyer
0cdb4b2aea allow occi plugin to compile against > 10g 2010-11-08 21:15:12 +00:00
Dane Springmeyer
bf14a62186 whoops, make the srid mutable not the type 2010-11-08 21:11:16 +00:00
Dane Springmeyer
6b08f1c793 fix compile of occi plugin after late binding patch 2010-11-08 21:06:37 +00:00
Dane Springmeyer
3fed886576 fix spelling of initial 2010-11-08 21:05:42 +00:00
Dane Springmeyer
aa7a3f8aae fix spelling of initial_size parameter in postgis plugin 2010-11-08 21:04:01 +00:00
Dane Springmeyer
8922aab266 fix spelling of minimum_version attribute 2010-11-08 21:01:23 +00:00
Robert Coup
5bbb5fbcf0 Allow late-binding of datasources. Backport of r2291 to 0.7.2-dev branch. closes #622 2010-10-24 07:56:43 +00:00
Dane Springmeyer
448c998a63 backport r2283 (fix for shapefile dupe features) - #647 2010-10-18 17:25:45 +00:00
Dane Springmeyer
790837f344 backport fix for attaching -pthreads to cxxflags on solaris 2010-10-12 05:43:54 +00:00
Dane Springmeyer
f1caa3bbd4 backport solaris fixes for python runpaths and pthreads from trunk 2010-10-12 05:26:08 +00:00
Dane Springmeyer
503da430dc backport fixes for compiling on sunos with g++ from r2174 and r2175 2010-10-05 00:10:37 +00:00
Jon Burgess
457f632b9c Remove calls to std::exit() to match trunk. Libraries should not call exit directly. 2010-09-24 15:45:39 +00:00
Dane Springmeyer
ff31c12879 backport fixes for overly locked proj.4 code - combo of r2063 and r2181 (closes #575) 2010-09-19 18:56:18 +00:00
Dane Springmeyer
09f271b6a1 scons: fix syntax error after svn merge from trunk 2010-08-30 22:41:07 +00:00
Dane Springmeyer
d0041cd6ce backport r2172 from trunk 2010-08-26 00:10:54 +00:00
Dane Springmeyer
33cb6af2b9 backport fix from trunk (thx haoyu) for sorting paths before checking boost (r2169,2170) 2010-08-21 05:40:37 +00:00
Dane Springmeyer
3621283ca9 mapnik2 forward compatibility for 0.7.2 XML syntax 2010-08-12 07:47:13 +00:00
Dane Springmeyer
8359ff19ba bump version to 0.7.2 2010-08-12 07:44:31 +00:00
Marcin Rudowski
427f0d0776 fix blending semitransparent raster images with background: #589 2010-08-11 22:06:36 +00:00
Dane Springmeyer
eba0b6fb45 scons: tweak logic for whether a path is a 'system' path, avoiding case where a custom path like /opt/mapnik/lib would be assumed to be a standard system path 2010-07-29 16:31:41 +00:00
Dane Springmeyer
1c74f2095f correct null shapes processing - closes #573 (backport from 2077) 2010-07-26 02:16:38 +00:00
Dane Springmeyer
ea43202344 + fixed template parameter shadowing (clang++) 2010-07-24 01:33:38 +00:00
Dane Springmeyer
e7b2a5dd4a be careful with output streams 2010-07-22 03:22:12 +00:00
Dane Springmeyer
1ffe6dcf94 boost 1.35 compatibility 2010-07-20 02:55:43 +00:00
Dane Springmeyer
b505a49312 fix library linking name 2010-07-16 23:43:44 +00:00
Dane Springmeyer
9265c75028 strip the file extention of '.shp', if provided, as the shapefile driver does not expect the ext. This allows a directory of shapefiles to be indexed like: 2010-07-16 23:29:45 +00:00
Dane Springmeyer
1d7b507572 add directory for C++ tests, and first C++ test against the font engine functions 2010-07-15 23:37:35 +00:00
Dane Springmeyer
c9941cf800 add helper functions for recursively registering fonts, and ensure they match one of the known freetype2 supported fonts (by ext) - closes #559 2010-07-15 23:05:51 +00:00
Dane Springmeyer
37df6ba211 output metadata about the searched plugin directories if a plugin cannot be found - closes #568 2010-07-15 21:13:03 +00:00
Dane Springmeyer
fd4ff876b6 scons: remove the '_CPPDEFFLAGS' variable, which otherwise would place -DNone in the compiler arguments when no other configure arguments are sent to scons 2010-07-15 16:33:45 +00:00
Dane Springmeyer
ffe5da46bd remove debugging line 2010-07-15 02:18:00 +00:00
Dane Springmeyer
22e6819272 scons: ensure pycairo headers are added 2010-07-15 02:17:30 +00:00
Dane Springmeyer
6097000322 scons: making sure things exist - prepping for out of source build 2010-07-15 00:39:07 +00:00
Dane Springmeyer
9a45c9d820 scons: better handling of PYTHON_INCLUDES and HAVE_LIBXML2 2010-07-15 00:20:38 +00:00
Dane Springmeyer
d75fb586d0 scons: only apply HAS_CAIRO & HAS_PYCAIRO flags to cairo related files 2010-07-14 22:46:37 +00:00
Dane Springmeyer
b8b2b726fe scons: only apply SHAPE_MEMORY_MAPPED_FILE to shapefile driver code 2010-07-14 22:39:55 +00:00
Dane Springmeyer
3d1e3ce8ac only expose save_to_cairo_file if cairo support available 2010-07-14 18:30:06 +00:00
Dane Springmeyer
ebc3001890 scons: make sure to initialize cairo variables 2010-07-14 05:34:09 +00:00
Dane Springmeyer
fd8695c107 scons: conditionally add CXXFLAGS for headers needing Cairo support 2010-07-14 05:08:28 +00:00
Dane Springmeyer
c2988656df backport r1955,1956 - db connection fixes 2010-07-14 02:00:57 +00:00
Dane Springmeyer
c599c52a61 backport r1893 and r1902 - fixing compile for enums 2010-07-14 01:55:54 +00:00
Dane Springmeyer
d785b9c5b4 backport r1889 2010-07-14 01:47:30 +00:00
Dane Springmeyer
1387b1a8d5 backport r1890 2010-07-14 01:46:09 +00:00
Dane Springmeyer
72e37ad399 backport r1897 2010-07-14 01:44:26 +00:00
Dane Springmeyer
7a6aa1e537 backport r1891 2010-07-14 01:42:38 +00:00
Dane Springmeyer
4c506cf380 fix typo 2010-07-14 01:40:55 +00:00
Dane Springmeyer
43fea02bdd backport compiler fix from r1900 2010-07-14 01:33:19 +00:00
Dane Springmeyer
c5adca6e57 make sure to only use mutexes if THREADING=multi/MAPNIK_THREADSAFE=True 2010-07-14 01:28:04 +00:00
Dane Springmeyer
a8b147156d scons: make sure to build a .os file instead of .o 2010-07-14 01:26:21 +00:00
Dane Springmeyer
f187cb7a12 backport for #257, and r1984 2010-07-14 01:02:01 +00:00
Dane Springmeyer
28f0106126 place built python lib inside module directory to make local import easier 2010-07-13 23:53:52 +00:00
Dane Springmeyer
a6a9c19c81 place built plugin targets in input/ directory to make local registration easier 2010-07-13 23:22:54 +00:00
Dane Springmeyer
7360923338 fix typos 2010-07-13 22:04:57 +00:00
Dane Springmeyer
55f0c4da60 port fixes from trunk for gdal bilinear resampling quality (r1912,#563) 2010-07-10 11:53:40 +00:00
Dane Springmeyer
d14f8515ef create branch for a 0.7.2 release (http://trac.mapnik.org/milestone/0.7.2) 2010-07-10 11:45:41 +00:00
Marcin Rudowski
c0c86213eb handle case of empty octrees. #540 2010-03-24 17:36:59 +00:00
Marcin Rudowski
a129611c20 fixed color quantization in case of one color and transparency. #539 2010-03-24 17:20:11 +00:00
Dane Springmeyer
0f771249c6 bump abi compatibility version for osx 2010-03-21 23:19:00 +00:00
Dane Springmeyer
37f21f4289 scons: fixup logic for setting HAS_BOOST_SYSTEM SCons environment variable 2010-03-18 22:51:14 +00:00
Dane Springmeyer
4d460cc795 remove debug line 2010-03-17 22:19:19 +00:00
Dane Springmeyer
8477dcaf40 avoid potential zero division error (floating point exception) if image width and heigh == 0 (likely to happen when layer srs = 4326 and map srs = 900913) - see also #527 - avoid gdal crash on 'ERROR 1: The buffer into which the data should be read is null' 2010-03-17 22:00:00 +00:00
Dane Springmeyer
d6ef3014a3 postgis/oracle: use mapnik::boolean type for 'estimate_extent' rather than std::string, and strip double quotes as the estimated_extent function operates on single quotes - improves upon #393 2010-03-17 16:06:39 +00:00
Artem Pavlenko
e680c3c473 + remove unused *.hpp file 2010-03-17 13:46:02 +00:00
Marcin Rudowski
2384b70abe avoid introducing subpixel shift when upscaling using gdal 2010-03-17 08:34:05 +00:00
Artem Pavlenko
1ccc048a46 use rint() instead of int(round()) 2010-03-16 20:49:40 +00:00
Alberto Valverde
6dcf47530a backported r1699 from trunk 2010-03-16 18:45:53 +00:00
Marcin Rudowski
e92f75c8a1 use map instead of unavailable unordered_map, in case of boost 1.35 2010-03-15 09:18:29 +00:00
Dane Springmeyer
701bcc2144 fix syntax in rundemo for writing to png256 (also now == png8) 2010-03-12 18:28:20 +00:00
Dane Springmeyer
e387a3ba68 rollback unneeded, extra way of specifying color reduction 2010-03-12 17:00:57 +00:00
Marcin Rudowski
95b22e1292 added missing file from r1680 and updated CHANGELOG 2010-03-12 11:42:50 +00:00
Dane Springmeyer
b194c6cea4 apply mapnik-0.7.1.mr.hextree2.diff (slighly modified to accept format='png:key=val' as well as format='png256:key=val' while still maintaining default behavior of just format 'png' or 'png256' - also updated rundemo.py with a few examples 2010-03-11 23:16:17 +00:00
Dane Springmeyer
7841b9d39e properly serialize the map_buffer when saving map 2010-03-11 21:23:26 +00:00
Artem Pavlenko
8b3c390ebf + use rint(v) instead of int(round(v))
+ add rint implementation - msvc hasn't got one
+ minor cleanups
2010-03-11 15:20:04 +00:00
Artem Pavlenko
e62fb19c7c + lets postgis return geometry in native byte order
(wkb reader can handle both 'NDR' and 'XDR')
2010-03-08 12:04:41 +00:00
Artem Pavlenko
e0e3a0fefe + revert to a024c947499994e1e8aaaff2b8ea73a8eec489dd 2010-03-08 12:04:32 +00:00
Marcin Rudowski
656b520e61 png256 bugfix and improvements for r1661 2010-03-06 16:45:41 +00:00
Marcin Rudowski
e91d245228 fixed png256 for large images + improvements to palette generation: #522 2010-03-06 11:04:30 +00:00
Marcin Rudowski
61c1e2e4ed eliminate compiler warnings 2010-03-04 08:31:25 +00:00
Dane Springmeyer
49afe197c3 apply mapnik-0.7.1.mr.raster-position2.diff from mar_rud to close #475 2010-03-03 02:11:28 +00:00
Dane Springmeyer
231a273cba + calculate resolution using map's current extent 2010-03-01 01:11:32 +00:00
Dane Springmeyer
5c0beb0151 scons: add options to allow controlling link order (and include order) sent by SCons to the linker line, as predictably /usr/lib would come first and take preference over paths such as /usr/local/lib while compiles may have been against /usr/local/include - closes #484 2010-02-23 02:27:36 +00:00
Dane Springmeyer
eedd2f72a2 load_map: fix the behavior of PolygonPatternSymbolizer and LinePatternSymbolizerby truly making it optional to not supply the width, height, and type parameters and allow them to be read automatically - closes #508 2010-02-23 02:17:34 +00:00
Dane Springmeyer
0356a8399e scons: fix subtle bug in scons usage resulting in lost paths on mac os x 2010-02-22 23:50:16 +00:00
Dane Springmeyer
d093166b4a check for both 'debian' and 'Ubuntu' to figure out lib schema 2010-02-22 19:50:09 +00:00
Dane Springmeyer
cd2cd2ba51 don't install by default in lib64 on debian systems - closes #394 2010-02-22 16:46:28 +00:00
Dane Springmeyer
d78a100134 fix minor issues caught in debian packaging relating to executable status and spelling 2010-02-21 17:28:17 +00:00
Dane Springmeyer
25dd583d6e remove print statement 2010-02-21 01:00:36 +00:00
Dane Springmeyer
fedbc40541 ensure shapeindex links against boost system if available (boost >=1.35) to avoid potential problems in indirect linking on linux (essentially directly dynamically linking like we previously only did on os x) - closes #517 2010-02-21 00:33:41 +00:00
Dane Springmeyer
4b1a4d9497 assume byteorder arrives in native arch (from postgis), and therefore ensure byteswapping for wkb on big endian systems - closes #515 - TODO check breakage in other plugins as per #516 - thanks Brad Simpson for the report and fix 2010-02-19 21:08:30 +00:00
Dane Springmeyer
7ed73b3b69 apply modified patch from Mak Kolybabi fixing up postgres schema support in PostGIS plugin - closes #500 - extends #260 2010-02-19 21:00:35 +00:00
Dane Springmeyer
3a80dffb6e bump version to 0.7.1, merge r1596,r1604,r1605,r1625, and fix #512 and #504 2010-02-19 19:11:17 +00:00
Dane Springmeyer
2e957c9885 creating 0.7.1 developement branch for working towards 0.7.1 release 2010-02-19 17:44:33 +00:00
Dane Springmeyer
a0da946be9 add missed vertical_alignment change in default behavior 2010-02-03 17:37:37 +00:00
Dane Springmeyer
4bb000fa38 my first ever commit to a tag - fixup spelling of 0.7.0 release CHANGELOG 2010-01-22 03:32:13 +00:00
Artem Pavlenko
48be3fb795 + add 'packaged' revision 2010-01-16 17:18:31 +00:00
Artem Pavlenko
dc99a1e0e2 + port r1571 + r1573
Conflicts:

	plugins/input/shape/shape.cpp
2010-01-15 23:01:28 +00:00
Artem Pavlenko
b98bd4dd55 + better handling non-existing and/or wrongly defined image files 2010-01-15 22:28:34 +00:00
Artem Pavlenko
3e0dd76e1e + remove Jamroot from utils/pgsql2sqlite 2010-01-14 16:58:44 +00:00
Artem Pavlenko
9a7c73aab3 remove debug printing in shapefile driver 2010-01-14 10:23:06 +00:00
Artem Pavlenko
71acd6f48a Tagging 0.7.0 release 2010-01-14 00:45:21 +00:00
Artem Pavlenko
2c12762829 + add some stderr printing to assist debugging
dodgy shapefiles
2010-01-13 23:41:14 +00:00
Artem Pavlenko
07729249ac + fixed 'optional' measure in multipointz 2010-01-13 23:07:35 +00:00
Artem Pavlenko
2495257b86 + read z and m bounds from the header 2010-01-13 23:07:27 +00:00
Artem Pavlenko
090fdb3974 + take into account <base> when reading
width/height - fixed
2010-01-13 23:07:19 +00:00
Artem Pavlenko
4483564b5e + correct parameters order 2010-01-13 23:07:12 +00:00
Artem Pavlenko
8d7ad5b190 + implement missing support for :
multipoint
  multipointm
  multipointz
2010-01-13 17:18:01 +00:00
Artem Pavlenko
8a5e1ea736 + ident fix 2010-01-13 17:17:53 +00:00
Dane Springmeyer
b096852829 add 'gamma' attribute to PolygonSymbolizer, along with tests against simplified world borders shapefile - setting gamma to .5-.7 can remove gaps in processed_p.shp depending on background color - closes #428 2010-01-13 00:14:44 +00:00
Artem Pavlenko
17b8eda5aa + correct filter expression encoding 2010-01-12 11:42:22 +00:00
Dane Springmeyer
bbba1f73a6 update CHANGELOG for 0.7.0 release - closes #466 2010-01-12 07:06:27 +00:00
Artem Pavlenko
dbc2e45d57 + remove *.html doc files
+ update epydoc generation script
2010-01-11 23:51:01 +00:00
Dane Springmeyer
9a00128321 touchup 0.7 install doc 2010-01-11 19:41:18 +00:00
Dane Springmeyer
38514efa44 fix compiler warnings by using proper OR operator 2010-01-11 17:31:37 +00:00
Artem Pavlenko
8cd7645561 + make width,height and type optinal in following
symbolizers: 
    * point_symbolizer
    * shield_symbolizer
    * line_pattern_symbolizer
    * polygon_pattern_symbolizer
2010-01-11 13:27:38 +00:00
Dane Springmeyer
cf4c94a44b update rundemo.py to show rendering without pycairo and using jpeg quality options 2010-01-11 02:16:01 +00:00
Dane Springmeyer
79d939cb46 remove another autotools piece and mark failing tests as TODO for next release 2010-01-11 01:47:38 +00:00
Dane Springmeyer
0ac3fc46b6 remove last autotools parts from 0.7 branch 2010-01-11 01:42:14 +00:00
Dane Springmeyer
42249704d7 increment abi versions to 0.7.0 2010-01-11 01:28:42 +00:00
Dane Springmeyer
53a4d1a954 update python api docs 2010-01-11 01:17:21 +00:00
Dane Springmeyer
0370ecec90 reflect new TextSymbolizer options in python bindings and add to pickling tests 2010-01-11 01:16:17 +00:00
Dane Springmeyer
33908e616c update python api docs 2010-01-11 00:15:30 +00:00
Dane Springmeyer
0110f3bb3d remove unmaintained autotools from 0.7 branch 2010-01-11 00:05:54 +00:00
Dane Springmeyer
a381672ed7 add missing PostGIS options in python docstrings 2010-01-11 00:04:56 +00:00
Dane Springmeyer
b4a0e89a9f expose ability to write to cairo formats from python without pycairo - closes #381 2010-01-10 23:38:27 +00:00
Dane Springmeyer
a3c1f9090b revert r1348 by enforcing map clipping by layer bounds, re-opens #420, closes #486, see also http://trac.mapnik.org/wiki/BoundsClipping 2010-01-10 21:42:44 +00:00
Dane Springmeyer
17945c57ec make sure mapfileis invalid so that test passes 2010-01-10 21:41:20 +00:00
Dane Springmeyer
93c0d8cae1 undercase file ext of testing shapefile 2010-01-09 22:52:46 +00:00
Artem Pavlenko
7f103c1218 + apply #485 logic for default vertical
alignment :
   dy = 0       vertical_alignment="middle"
   dy > 0       vertical_alignment="bottom"
   dy < 0       vertical_alignment="top"
2010-01-09 15:06:48 +00:00
Artem Pavlenko
6a74155bf2 + upgrade version to 700 2010-01-09 14:47:45 +00:00
Artem Pavlenko
230f96b3cf + make it compile on win32 2010-01-09 14:46:38 +00:00
Artem Pavlenko
9a9042ce84 + avoid GCC specific features on win32 (range case in switch stmt) 2010-01-09 14:45:58 +00:00
Artem Pavlenko
29b95ac598 + removed empty virtual dtor - not needed 2010-01-08 16:44:08 +00:00
Artem Pavlenko
4b93e0f58d + fix compiler warning 2010-01-08 15:44:34 +00:00
Artem Pavlenko
7093074706 + revert mapnik2 syntax 2010-01-08 15:44:05 +00:00
Artem Pavlenko
6b96ba1a1a + remove mapnik2 syntax
+ fix compiler warnings
2010-01-08 15:43:28 +00:00
Dane Springmeyer
2484e818b8 scons: support py3k in python configuration detection 2010-01-07 17:14:39 +00:00
Dane Springmeyer
f844e13afb fix default values for vertical_alignment in the TextSymbolizer and ShieldSymbolizer - closes #468 2010-01-06 17:48:30 +00:00
Dane Springmeyer
b64fb713f3 scons: make sure help is displayed if -h or --help is supplied even if we are not able to configure successfully and add more user friendly output for dependencies that are not found 2010-01-05 23:27:13 +00:00
Dane Springmeyer
a3b3d7dde6 remove unneeded header 2010-01-05 21:30:24 +00:00
Dane Springmeyer
7f04fd83a7 apply fix from Marcin for semitransparency of png256 - closes #477 and resolves discussion at #202 2010-01-05 15:42:07 +00:00
Dane Springmeyer
9ab543bdb4 fix memory leak in load_map when using libxml2 by freeing the libxml tree as per http://xmlsoft.org/xmlmem.html - closes #473 - thanks mishok13 for the detailed report and testing 2010-01-01 22:39:17 +00:00
Dane Springmeyer
77ccb92054 merge r1497 through r1498 from trunk into 0.7 branch 2009-12-31 16:11:52 +00:00
Dane Springmeyer
f409f91250 apply patch from marcin to fix problem with occaisionaly garbled/striped png256 output along shape edges - closes #416,#445,#447, improves upon #202 2009-12-31 15:43:05 +00:00
Dane Springmeyer
cabdd341cd merge r1496 from trunk into 0.7 branch 2009-12-16 22:28:33 +00:00
Dane Springmeyer
3c655b0a0f apply r1491 + modification for BIG_ENDIAN to from mapnik2 - closes #444 2009-12-15 22:14:09 +00:00
Dane Springmeyer
354bdbd15a fix small bug in FindBoost implementation and expose ability to specify a custom library path or library name for boost_python as various packaging systems on debian are using new suffixes to support two versions of python and we need an easy way to point boost specifically at these libraries - closes #351 2009-12-15 19:17:41 +00:00
Dane Springmeyer
d1dbf89961 disable the wall clock timer as it is not portable code and we can't release at this time 2009-12-15 19:09:30 +00:00
Dane Springmeyer
798b0731e5 apply small patch from David Eastcott which fixes a problem with the insertion of character envelope fragments (as a result of overlap rejection) into the detector which in turn causes rejection of other text placement that should have been rendered. 2009-12-13 23:29:02 +00:00
Dane Springmeyer
19194dd8fa correct type 2009-12-13 23:27:43 +00:00
Dane Springmeyer
0849ba0353 add missing include 2009-12-13 23:27:00 +00:00
Dane Springmeyer
da82b6905d merge clog fix from r1478 to 0.7 branch 2009-12-11 19:53:49 +00:00
Dane Springmeyer
4389ea1642 Creating the 0.7 branch, to be the source for 0.7.x series releases, allowing the mapnik2 branch to move to trunk 2009-12-11 17:08:45 +00:00
3244 changed files with 213925 additions and 662738 deletions

View file

@ -1,94 +0,0 @@
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: Consecutive
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
# AlwaysBreakAfterReturnType:
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BitFieldColonSpacing: After
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: false # see AllowShortEnumsOnASingleLine
AfterFunction: true # see AllowShortFunctionsOnASingleLine
AfterNamespace: false
AfterStruct: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: AfterComma
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: false
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DeriveLineEnding: true
EmptyLineAfterAccessModifier: Leave
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: NoIndent
IndentPPDirectives: None
IndentRequires: true
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
# PackConstructorInitializers: CurrentLine # only clang-format > 14
PointerAlignment: Left
#QualifierAlignment: Left # only clang-format > 14
ReferenceAlignment: Left
ReflowComments: true
SortIncludes: Never
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeInheritanceColon: true
Standard: c++14
BinPackParameters: false
BreakBeforeInheritanceComma: false
IncludeCategories:
# Headers in <> without extension.
- Regex: '<([A-Za-z0-9\Q/-_\E])+>'
Priority: 1
# Headers in <> from specific external libraries.
- Regex: '<(boost)\/'
Priority: 2
# Headers in <> from specific external libraries.
- Regex: '<(mapnik)\/'
Priority: 3
# Headers in <> with extension.
- Regex: '<([A-Za-z0-9.\Q/-_\E])+>'
Priority: 4
# Headers in "" with extension.
- Regex: '"([A-Za-z0-9.\Q/-_\E])+"'
Priority: 5

2
.gitattributes vendored
View file

@ -1,2 +0,0 @@
*.svg text eol=lf
scons/** linguist-vendored

View file

@ -1,85 +0,0 @@
name: Run tests with coverage
description: Runs all mapnik tests with coverage
inputs:
cmake-preset:
description: The used CMake preset
required: true
runs:
using: composite
steps:
- name: Set PROJ_LIB
shell: bash
run: |
cmake --preset ${{ inputs.cmake-preset }} -N -L | grep -o "PROJ_LIB=.*" >> ${GITHUB_ENV}
- name: Set TEST_WRAPPER (Windows)
if: runner.os == 'Windows'
shell: bash
run: |-
echo "TEST_WRAPPER=OpenCppCoverage \
--cover_children \
--export_type binary \
--modules '*.input' \
--modules '*libmapnik*' \
--modules 'mapnik*.exe' \
--quiet \
--sources '${{ github.workspace }}' \
--" >> ${GITHUB_ENV}
- name: Test
shell: bash
env:
UPDATE: 1
run: |
${TEST_WRAPPER:-} ctest --preset ${{ inputs.cmake-preset }}
- name: Test visuals
continue-on-error: true
working-directory: build/out
shell: bash
run: |
${TEST_WRAPPER:-} ./mapnik-test-visual -j ${CTEST_PARALLEL_LEVEL} --output-dir visual-test-result
- name: Pack visual test results
working-directory: build/out
shell: bash
run: |
tar -vzcf visual-test-results.tar.gz visual-test-result
- name: Upload visual test results
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cmake-preset }}-visual-tests-${{ github.sha }}
path: build/out/visual-test-results.tar.gz
- name: Run Benchmarks (Linux & macOS)
working-directory: build/out
if: runner.os != 'Windows'
shell: bash
run: |
./run_benchmarks
- name: Collect coverage (Linux & macOS)
working-directory: build
if: runner.os != 'Windows'
shell: bash
run: |
if [ "${RUNNER_OS}" == "macOS" ]; then
LCOV_EXTRA_OPTIONS="--ignore-errors count,gcov,inconsistent,range,unused --keep-going"
fi
lcov ${LCOV_EXTRA_OPTIONS:-} --directory . --capture --output-file coverage.info
lcov ${LCOV_EXTRA_OPTIONS:-} --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info
lcov ${LCOV_EXTRA_OPTIONS:-} --list coverage.info
- name: Upload coverage to Codecov (Linux & macOS)
if: runner.os != 'Windows'
uses: codecov/codecov-action@v4
with:
files: build/coverage.info
- name: Upload coverage to Codecov (Windows)
if: runner.os == 'Windows'
uses: codecov/codecov-action@v4
with:
files: ctest.cov,build/out/mapnik-test-visual.cov

View file

@ -1,136 +0,0 @@
name: Build and Test
on:
push:
branches:
- "*"
pull_request:
branches-ignore:
- "no-ci-*"
env:
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
VCPKG_RELEASE: 2024.06.15
jobs:
checkSource:
name: Check Source Code
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: pre-commit/action@v3.0.1
buildAndTest:
name: >-
Build & Test
(${{ matrix.os }})
(C++ ${{ matrix.cxx-standard }})
${{ startsWith(matrix.os, 'macos-') && (matrix.os == 'macos-14' && '(ARM64)' || '(AMD64)') || '' }}
needs: checkSource
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-22.04
- windows-2022
cxx-standard:
- 17
steps:
- name: Checkout Mapnik
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout vcpkg
uses: actions/checkout@v4
with:
path: vcpkg
ref: ${{ env.VCPKG_RELEASE }}
repository: microsoft/vcpkg
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install required system packages
shell: bash
run: |
if [ "${RUNNER_OS}" == "Linux" ]; then
sudo apt-get update
sudo apt-get -y install \
autoconf \
autoconf-archive \
automake \
gperf \
lcov \
libxxf86vm-dev \
ninja-build \
postgresql-client
elif [ "${RUNNER_OS}" == "macOS" ]; then
brew install \
autoconf \
autoconf-archive \
automake \
lcov \
libtool \
ninja \
vcpkg
elif [ "${RUNNER_OS}" == "Windows" ]; then
choco install \
ninja \
OpenCppCoverage
echo "C:\Program Files\OpenCppCoverage" >> ${GITHUB_PATH}
fi
- name: Enable Developer Command Prompt (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Set CMAKE_BUILD_PARALLEL_LEVEL, CTEST_PARALLEL_LEVEL & PRESET
shell: bash
run: |
PRESET=$(echo "${RUNNER_OS}" | perl -ne "print lc")-ci
if [ "${RUNNER_OS}" == "Linux" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
elif [ "${RUNNER_OS}" == "macOS" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
PRESET=${PRESET}-${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
elif [ "${RUNNER_OS}" == "Windows" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
fi
echo "PRESET=${PRESET}" >> ${GITHUB_ENV}
- name: Configure CMake
shell: bash
run: |
cmake \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_CXX_STANDARD:STRING=${{ matrix.cxx-standard }} \
-DUSE_MEMORY_MAPPED_FILE:BOOL=ON \
-LA \
--preset ${PRESET}
- name: Build
shell: bash
run: |
cmake \
--build \
--preset ${PRESET}
- name: Run Tests
uses: ./.github/actions/run_tests
with:
cmake-preset: ${{ env.PRESET }}

View file

@ -1,55 +0,0 @@
name: Release Linux
on:
push:
branches:
- "*"
pull_request:
branches-ignore:
- "no-ci-*"
env:
PRESET: linux-ci-release
jobs:
build:
runs-on: "ubuntu-22.04"
steps:
- name: checkout mapnik
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: "Install required system packages"
shell: bash
run: |
sudo apt update
sudo apt install -y ninja-build\
libicu-dev \
libfreetype6-dev \
libharfbuzz-dev \
libxml2-dev \
libjpeg-dev \
libtiff-dev \
libwebp-dev \
libcairo2-dev \
libproj-dev \
libgdal-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-regex-dev
- name: Configure CMake
run: cmake -LA --preset ${{ env.PRESET }}
- name: Build
run: cmake --build --preset ${{ env.PRESET }}
- name: Package
run: cmake --build --preset ${{ env.PRESET }} --target package
- name: Upload mapnik debian package
uses: actions/upload-artifact@v4
with:
name: ${{ env.PRESET }}-deb
path: build/mapnik-*.deb

43
.gitignore vendored
View file

@ -1,29 +1,16 @@
.DS_Store
.vscode
.cache
*.gcov
*.gcda
*.gcno
*~
*.o
*.pyc
*.os
*.so
*.so.*
*.a
*.swp
*.dylib
mapnik-gyp
plugins/input/*.input
plugins/input/templates/*.input
demo/c++/rundemo
bindings/python/mapnik/paths.py
config.cache
config.log
config.py
mapnik-settings.env
mason_packages/
.mason/
.sconf_temp/
.sconsign.dblite
demo/viewer/viewer.ini
@ -31,35 +18,9 @@ tests/cpp_tests/font_registration_test
tests/python_tests/raster_colorizer_test.png
tests/python_tests/raster_colorizer_test_save.xml
utils/mapnik-config/mapnik-config
utils/mapnik-config/mapnik2.pc
utils/shapeindex/shapeindex
utils/mapnik-index/mapnik-index
utils/ogrindex/ogrindex
utils/pgsql2sqlite/pgsql2sqlite
utils/svg2png/svg2png
utils/mapnik-render/mapnik-render
demo/python/demo*
demo/python/map.xml
tests/data/sqlite/*index
demo/c++/cairo-demo.pdf
demo/c++/cairo-demo.png
demo/c++/cairo-demo256.png
demo/c++/cairo-demo.svg
demo/c++/demo.tif
demo/c++/demo.jpg
demo/c++/demo.png
demo/c++/demo256.png
demo/viewer/Makefile
demo/viewer/Makefile.Debug
demo/viewer/Makefile.Release
demo/viewer/release/
demo/viewer/ui_about.h
demo/viewer/ui_info.h
demo/viewer/ui_layer_info.h
test/standalone/*-bin
test/unit/run
test/visual/run
# cmake
build
.vs
CMakeUserPresets.json
demo/python/map.xml

23
.gitmodules vendored
View file

@ -1,23 +0,0 @@
[submodule "test/data"]
path = test/data
url = https://github.com/mapnik/test-data.git
branch = master
[submodule "test/data-visual"]
path = test/data-visual
url = https://github.com/mapnik/test-data-visual.git
branch = master
[submodule "deps/mapbox/variant"]
path = deps/mapbox/variant
url = https://github.com/mapbox/variant.git
branch = master
[submodule "deps/mapbox/geometry"]
path = deps/mapbox/geometry
url = https://github.com/mapbox/geometry.hpp.git
branch = master
[submodule "deps/mapbox/protozero"]
path = deps/mapbox/protozero
url = https://github.com/mapbox/protozero.git
branch = master
[submodule "deps/mapbox/polylabel"]
path = deps/mapbox/polylabel
url = https://github.com/mapbox/polylabel.git

View file

@ -1,16 +0,0 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
files: ^.*\.cmake|CMakeLists\.txt$
- id: end-of-file-fixer
files: ^.*\.cmake|CMakeLists\.txt$
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3
hooks:
- id: clang-format
types_or: [c++, c]

62
AUTHORS Normal file
View file

@ -0,0 +1,62 @@
# $Id: AUTHORS 746 2008-09-24 dane $
Committers
==========
- Artem Pavlenko <pavlenko -at- users.berlios.de>
- Lucio Asnaghi (OGR, Oracle, SQLite plugins)
- Jon Burgess (Core)
- Jean-Francois Doyon (Python API, OGCServer) <jfdoyon -at- gmail.com>
- Dominic Hargreaves (Stable releases)
- Tom Hughes (Cairo)
- Ben Moores (PDF branch)
- David Siegel (XML)
- Vince Spader (TextSymbolizer)
- Dane Springmeyer (Python API, SCons) <dane.springmeyer -at- gmail.com>
- David Leaver (Label Placement)
- Andreas Volz (Autotools)
- Nick Whitelegg (OSM plugin)
Patches
=======
- Andy Allen
- Justin Bronn
- Christopher Brown
- Toby Collet
- Robert Coup
- Berteun Damman
- David Eastcott
- Krzysztof Godlewski
- Beau Gunderson
- John Hague
- Aubrey Holland
- Mak Kolybabi
- Dennis Luxen
- Tom MacWright
- Michal Migurski
- Andrii Mishkovskyi
- Dražen Odobašić
- Martijn van Oosterhout
- Cameron Patrick
- Igor Podolskiy
- Reid Priedhorsky
- Brian Quinion
- Marcin Rudowski
- Christopher Schmidt
- Andreas Schneider
- Vincent Schut
- Ehud Shabtai
- Steve Singer
- Paul Smith
- Philipp Spitzer
- Dave Stubbs
- River Tarnell
- Alberto Valverde
- Shaun Walbridge
- Leslie Wu
Community Wiki
==============
- http://trac.mapnik.org/stractistics

View file

@ -1,83 +0,0 @@
## Mapnik Contributors
Mapnik is written by Artem Pavlenko with contributions from:
* Andy Allen
* AJ Ashton
* Matt Amos
* Lucio Asnaghi
* Alexandre Bonnasseau
* Justin Bronn
* Joel Brown
* Christopher Brown
* Jon Burgess
* Stephan Bösch-Plepelits
* Manel Clos
* Toby Collet
* Robert Coup
* Berteun Damman
* Petr Dlouhy
* Jiri Drbalek
* Jean-Francois Doyon
* David Eastcott
* Seth Fitzsimmons
* Sean Gillies
* Krzysztof Godlewski
* Beau Gunderson
* John Hague
* Dominic Hargreaves
* Axel Haustant
* Aubrey Holland
* Jordan Hollinger
* Tom Hughes
* Konstantin Käfer
* Mak Kolybabi
* Peter Körner
* Hermann Kraus
* Stella Laurenzo
* XinGang Li
* lightmare
* David Leaver
* Carlos López
* Dennis Luxen
* Tom MacWright
* Sara Metz
* Michal Migurski
* Andrii Mishkovskyi
* Ben Moores
* Mike Morris
* Dražen Odobašić
* Cameron Patrick
* Clint Pells
* Igor Podolskiy
* Reid Priedhorsky
* Brian Quinion
* Even Rouault
* Marcin Rudowski
* Sandro Santilli
* Christopher Schmidt
* Andreas Schneider
* Vincent Schut
* Ehud Shabtai
* David Siegel
* Steve Singer
* Paul Smith
* Vince Spader
* Philipp Spitzer
* Dane Springmeyer
* Craig de Stigter
* Dave Stubbs
* River Tarnell
* Cezary Tarnowski
* Blake Thompson
* Oliver Tonnhofer
* Jochen Topf
* Alberto Valverde
* Martijn van Oosterhout
* Andreas Volz
* Lennard voor den Dag
* Shaun Walbridge
* Rich Wareham
* Nick Whitelegg
* Leslie Wu
* Roman Galacz

427
CHANGELOG Normal file
View file

@ -0,0 +1,427 @@
# $Id: CHANGELOG 776 2008-12-7 01:30:27Z dane $
----------------
Mapnik Changelog
----------------
A simple log of core changes affecting Mapnik usage.
Developers: Please commit along with changes.
For a complete change history, see the SVN log.
Mapnik 0.7.3 Release
--------------------
Released Nov 8, 2012
(packaged from 4d04ed01c01e486160f6afd04ec15fcc0d573db0)
- Fixed linking to boost system with recent boost (#1567)
- Fixed compile with clang++
- backport hextree sorting fix to 0.7.x series - refs #1087
- Add properties and methods onto shield symbolizer - refs #935 and #612
Mapnik 0.7.2 Release
--------------------
- Added forward compatibility for Mapnik 2.0 XML syntax (https://trac.mapnik.org/wiki/Mapnik2/Changes)
- Build fixes to ensure boost_threads are not used unless THREADING=multi build option is used
- Fixes for the clang compiler
- Support for latest libpng (>= 1.5.x) (r2999)
- Fixes to the postgres pool
- Fix for correct transparency levels in png256/png8 output (#540)
- Various build system fixes, especially for gcc compiler on open solaris.
- When plugins are not found, report the searched directories (#568)
- Improved font loading support (#559)
- Fix to shapeindex for allowing indexing of directory of shapefiles like `shapeindex dir/*shp`
- Fixed handling of null and multipatch shapes in shapefile driver - avoiding inf loop (#573)
- Fixed raster alpha blending (#589,#674)
- Enhanced support for faster reprojection if proj >= 4.8 is used (#575)
- Allow for late-binding of datasources (#622)
- Fix to OSM plugin to avoid over-caching of data (#542)
- Various fixes to sqlite, ogr, and occi driver backported from trunk.
- Ensured that '\n' triggers linebreaks in text rendering (#584)
- Support for boost filesystem v3
- Fixes to cairo renderer to avoid missing images (r2526)
- Fixed reading of label_position_tolerance on text_symbolizer and height for building_symbolizer
Mapnik 0.7.1 Release
--------------------
- Backported from trunk optimization of avoiding locking in the projection code (#575)
- Rasters: Various fixes and improvements to 8bit png output (#522,#475)
- XML: Save map buffer_size when serializing map.
- SCons: Added new build options 'PRIORITIZE_LINKING' and 'LINK_PRIORITY'. The first is a boolean (default True)
of whether to use the new sorting implementation that gives explicit preference to custom or local paths
during compile and linking that will affect builds when duplicate libraries and include directories are on the
system. LINK_PRIORITY defaults to prioritizing internal sources of the mapnik source folder, then local/user
installed libraries over system libraries, but the option can be customized. Sorting not only ensures that
compiling and linking will more likely match the desired libraries but also gives more likelihood to avoid
the scenario where libraries are linked that don't match the includes libmapnik compiled against.
- XML: Fixed behavior of PolygonPatternSymbolizer and LinePatternSymbolizer whereby width, height,
and type of images is actually allowed to be optionally omitted (#508). This was added in r1543 but
only worked correctly for PointSymbolizer and ShieldSymbolizer.
- Fixed reading of PostGIS data on Big Endian systems (#515)
- PostGIS: Added better support for alternative schemas (#500)
- AGG Renderer - Enforced default gamma function on all symbolizers to ensure proper antialiasing
even when gamma is modified on the PolygonSymbolizer. (#512)
- PNG: fixed png256 for large images and some improvements to reduce color corruptions (#522)
- PNG: Added new quantization method for indexed png format using hextree with full support for alpha
channel. Also new method has some optimizations for color gradients common when using elevation based
rasters. By default old method using octree is used. (r1680, r1683, #477)
- PNG: Added initial support for passing options to png writer like number of colors, transparency
support, quantization method and possibly other in future using type parameter. For example
"png8:c=128:t=1:m=h" limits palette to 128 colors, uses only binary transparency (0 - none,
1 - binary, 2 - full), and new method of quantization using hextree (h - hextree, o - octree).
Existing type "png256" can be also written using "png8:c=256:m=o:t=2" (r1680, r1683, #477)
Mapnik 0.7.0 Release
--------------------
(Packaged from r1574)
- Core: Fixed linking to external libagg (r1297,r1299)
- Core: Completed full support for PPC (Big endian) architectures (r1352 -> r1357)
- Gdal Plugin: Added support for Gdal overviews, enabling fast loading of > 1GB rasters (#54)
* Use the gdaladdo utility to add overviews to existing GDAL datasets
- PostGIS: Added an optional 'geometry_table' parameter. The 'geometry_table' used by Mapnik to look up
metadata in the geometry_columns and calculate extents (when the 'geometry_field' and 'srid' parameters
are not supplied). If 'geometry_table' is not specified Mapnik will attempt to determine the name of the
table to query based on parsing the 'table' parameter, which may fail for complex queries with more than
one 'from' keyword. Using this parameter should allow for existing metadata and table indexes to be used
while opening the door to much more complicated subqueries being passed to the 'table' parameter without
failing (#260, #426).
- PostGIS Plugin: Added optional 'geometry_field' and 'srid' parameters. If specified these will allow
Mapnik to skip several queries to try to determine these values dynamically, and can be helpful to avoid
possible query failures during metadata lookup with complex subqueries as discussed in #260 and #436, but
also solvable by specifying the 'geometry_table' parameter. (r1300,#376)
- PostGIS: Added an optional 'extent_from_subquery' parameter that when true (while the 'extent' parameter is
not provided and 'estimate_extent' is false) will direct Mapnik to calculate the extent upon the exact table
or sql provided in the 'table' parameter. If a sub-select is used for the table parameter then this will,
in cases where the subquery limits results, provide a faster and more accurate layer extent. It will have
no effect if the 'table' parameter is simply an existing table. This parameter is false by default. (#456)
- PostGIS Plugin: Added 'bbox' token substitution ability in sql query string. This opens the door for various
complex queries that may aggregate geometries to be kept fast by allowing proper placement of the bbox
query to be used by indexes. (#415)
* Pass the bbox token inside a subquery like: !bbox!
* e.g. (Select ST_Union(geom) as geom from table where ST_Intersects(geometry,!bbox!)) as map
- PostGIS Plugin: Added 'scale_denominator' substitution ability in sql query string (#415/#465)
* Pass the scale_denominator token inside a subquery like: !scale_denominator!
* e.g. (Select * from table where field_value > !scale_denominator!) as map
- PostGIS Plugin: Added support for quoted table names (r1454) (#393)
- PostGIS: Add a 'persist_connection' option (default true), that when false will release
the idle psql connection after datasource goes out of scope (r1337) (#433,#434)
- PostGIS: Added support for BigInt (int8) postgres type (384)
- PostGIS Plugin: Throw and report errors if SQL execution fails (r1291) (#363, #242)
- PostGIS Plugin: Fixed problem in conversion of long numbers to strings (r1302,1303)
- PostGIS Plugin: Added missing support for BigInt(int8) postgres datatypes (r1250) (#384)
- OGR Plugin: Added support for reading multipoint features (#458)
- Shape Plugin: Fixed bug in file extension stripping (#413)
- Shape Plugin: Fixed missing compiler flags that causes crashing on newer g++ versions (#436)
- PNG: Fixed problem with garbled/striped png256 output along sharpe edges(#416,#445,#447,#202)
- PNG: Added support for semitransparency in png256 output (#477,#202)
- PolygonSymbolizer: Added 'gamma' attribute to allow for dilation of polygon edges - a solution
to gap artifacts or "ghost lines" between adjacent polygons and allows for slight sharpening of
the edges of non overlapping polygons. Accepts any values but 0-1 is the recommended range.
- TextSymbolizer: Large set of new attributes: 'text_convert', 'line_spacing', 'character_spacing',
'wrap_character', 'wrap_before', 'horizontal_alignment', 'justify_alignment', and 'opacity'.
* More details at changesets: r1254 and r1341
- SheildSymbolizer: Added special new attributes: 'unlock_image', 'VERTEX' placement, 'no_text' and many
attributes previously only supported in the TextSymbolizer: 'allow_overlap', 'vertical_alignment',
'horizontal_alignment', 'justify_alignment', 'wrap_width', 'wrap_character', 'wrap_before', 'text_convert',
'line_spacing', 'character_spacing', and 'opacity'.
* More details at changeset r1341
- XML: Added support for using CDATA with libxml2 parser (r1364)
- XML: Fixed memory leak in libxml2 implementation (#473)
- XML: Added function to serialize map to string, called 'mapnik.save_map_to_string()' (#396)
- XML: Added parameter to <Map> called 'minimum_version' to allow for enforcing the minimum Mapnik version
needed for XML features used in the mapfiles. Uses Major.Minor.Point syntax, for example
<Map minimum_version="0.6.1"> would throw an error if the user is running Mapnik less than 0.6.1.
- XML: Added support for relative paths when using entities and 'mapnik.load_map_from_string()' (#440)
- XML: Made width and height optional for symbolizers using images (r1543)
- XML: Ensured that default values for layers are not serialized in save_map() (r1366)
- XML: Added missing serialization of PointSymbolizer 'opacity' and 'allow_overlap' attributes (r1358)
- XML: Default text vertical_alignment now dependent on dy (#485, r1527)
- Python: Exposed ability to write to Cairo formats using 'mapnik.render_to_file()' and without pycairo (#381)
- Python: Fixed potential crash if pycairo support is enabled but python-cairo module is missing (#392)
- Python: Added 'mapnik.mapnik_svn_revision()' function to svn revision of Mapnik was compiled at.
- Python: Added 'mapnik.has_pycairo()' function to test for pycairo support (r1278) (#284)
- Python: Added 'mapnik.register_plugins()' and 'mapnik.register_fonts()' functions (r1256)
- Python: Pickling support for point_symbolizer (r1295) (#345)
- Python: Ensured mapnik::config_errors now throw RuntimeError exception instead of UserWarning exception (#442)
- Filters: Added support for '!=' as an alias to '<>' for not-equals filters (avoids &lt;&gt;) (r1326) (#427)
- SCons: Improved boost auto-detection (r1255,r1279)
- SCons: Fixed support for JOBS=N and FAST=True to enable faster compiling (r1440)
- SCons: Ensured that -h or --help will properly print help on custom Mapnik options before a user
has been able to properly run 'configure'. (r1514)
- SCons: Added ability to link to custom icu library name using ICU_LIB_NAME (r1414)
- SCons: Improved reliability of python linking on OSX (#380)
- Fonts: Added unifont to auto-installed fonts, which is used by the OSM styles as a fallback font (r1328)
Mapnik 0.6.1 Release
--------------------
(Packaged from r1247)
- XML: Fixed serialization and parsing bugs related to handling of integers and Enums (#328,#353)
- SCons: Added the ability to set the PKG_CONFIG_PATH env setting (#217)
- SCons: Improved linking to only required libraries for libmapnik (#371)
- Shape Plugin: Added compile time flag to allow disabling the use of memory mapped files (r1213) (#342)
- Core: Improved support for PPC (Big endian) architectures (r1198 -> r1213)
- Scons: Improved auto-detection of boost libs/headers (r1200) (#297)
- Plugins: Exposed list of available/registered plugins (r1180) (#246)
- SCons: Improve build support for SunCC (patches from River Tarnell) (r1168, r1169)
- Python: Pickling support for text_symbolizer (r1164) (#345)
- Python: Pickling support for proj_transform and view/coord_transform (r1163) (#345)
- Python: Pickling support for parameters (r1162) (#345)
- Python: Pickling support for stroke objects (r1161) (#345)
- Python: Pickling support for line_symbolizer (r1160) (#345)
- Python: Pickling support for projection objects (r1159) (#345)
- Python: Pickling support for shield_symbolizer (r1158) (#345)
- Python: Pickling support for polygon_symbolizer (r1157) (#345)
- Python: Pickling support for query objects (r1156) (#345)
- Python: Pickling support for pattern symbolizers (r1155) (#345)
- Python: Pickling support for raster_symbolizer (r1154) (#345)
- Python: Added 'mapnik.has_cairo()' function to test for cairo support (r1152) (#284)
- Python: Exposed dash_array get method (r1151) (#317)
- Python: Pickling support for Coord objects (#345)
- GDAL Plugin: Added an experimental option to open files in 'shared mode' (r1143)
- Python: Exposed RasterSymbolizer options in Python (r1139)
- Plugins: Fixed support for non-file based sources in GDAL and OGR plugins (#336,#337)
- Plugins: Formal inclusion of new plugin for Kismet server (r1127) (#293)
- Python: Made access to features and featuresets more Pythonic (r1121) (#171,#280,#283)
- XML: Ensured relative paths in XML are interpreted relative to XML file location (r1124) (#326)
- XML: Added ability to serialize all default symbolizer values by passing third argument to save_map(m,'file.xml',True)(r1117) (#327)
- Core: Added support for alpha transparency when writing to png256 (patch from Marcin Rudowski) (#202)
- SCons: Ensured ABI compatibility information is embedded in libmapnik.dylib on Mac OS X (#322)
- SCons: Ensured that the full 'install_name' path would be added to libmapnik.dylib on Mac OS X (#374)
- Tests: Added testing framework in Python using nose (r1101-r1105)
- Raster Plugin: Added a tile/bbox-based read policy for large (rasters width * height > 1024*1024 will be loaded in chunks) (r1089)
- OGCServer: Made lxml dependency optional (r1085) (#303)
- Rasters: Handle rounding to allow better alignment of raster layers (r1079) (#295)
- AGG Renderer: Added option to control output JPEG quality (r1078) (#198)
- Plugins: Fixed segfault in OGR Plugin with empty geometries (r1074) (#292)
Mapnik 0.6.0 Release
--------------------
(Packaged from r1066)
- Python: Added support for aspect_fix_mode (r1013)
- OGCServer Fixed axis-ordering for WMS 1.3.0 request (r1051) (#241)
- Plugins: Added option to all plugins to support using a 'base' path argument (r1042)
- Symbolizers: RasterSymbolizer now support composing modes for hillshading (r1027)
- SCons: Added options to build the rundemo and pgsql2sqlite tools (r989)
- OGCServer: Added content-length output (r986)
- SCons: Replaced LIBS/INCLUDES options for postgres and gdal with pg_config and gdal-config (r977)
- SCons: Created an optional configure stage (r973)
- Python: Added further pickling/copy support to Map, Layers, Datasources, Styles,and Rules (r907,r913,r921)
- OGCServer: Added support for load_map(), allowing reading of XML styles and layers (r901)
- OGCServer: Enabled friendly html output when in debug mode (debug=1 in ogcserver.conf) (r899)
- Plugins: Added Sqlite driver for reading sqlite databases (r881)
- Python: Exposed a number of properties for the Text Symbolizer (r869)
- Plugins: PostGIS plugin now accepts multi-line queries (r862)
- Filter parsing: Allow numbers in the filter field name.
This allows for shapefiles with columns like '1970'.
- Plugins: Added OGR driver for reading all OGR supported formats (kunitoki) (r836) (#170)
- XML: Added serialization of Fontsets (r807)
- XML: Added support for reading xml from a string (r806)
- C++: renamed mapnik::Color to mapnik::color (r796)
- Python: Made available the scale_denominator property from the map in c++ and python (r794)
- Python: Added ability to resize map and clear all layers and styles from python (r793)
- Python: Exposed Proj to/from transformation for projected coordinate systems (r792,r822) (#117)
- Memory Datasource: Added support for dynamically adding Points to map using Point Datasource (r790)
- XML: Added xml serialization for abstract, title, minzoom, maxzoom, and queryable attributes (r787)
- Core: Transformation is now skipped if srs values match exactly (r777)
- Symbolizers: 'min_distance' now honored for POINT placement using Text Symbolizer (r771)
- Plugins: PostGIS plugin now accepts a geometry_field,record_limit, cursor_size options (r769,r872)
- Python: Added ability to transform as a method on Coord and Envelope objects (r764)
- Python: Added docstrings to the Layer object (r763)
- Plugins: Loosened the type checking in Shapefile Plugin dbf reader (r762)
- Fonts: Added support for Right-to-left Hebrew text (r749)
- Core: Added a Map buffer parameter - helps to avoid cut labels at tile edges (r744)
- Symbolizers: Added opacity support to Point Symbolizer (r743)
- Symbolizers: Added support of using Points with Shield Symbolizer (r741)
- Plugins: PostGIS plugin now accepts alternate schemas (r773)
- Fonts: Added support for fallback fonts (r704)
- Cairo: Cairo support exposed in Python (r666)
- Plugins: Added OSM plugin for reading directly from OSM data (r663)
- Filters: Added support for boolean expressions (r660)
- Python: Added ability to open Image32 files (r652)
- Cairo: Cairo rendering support added (r656)
- Core: Added unicode support based on ICU (r650)
- Core: Added support for single and multi threaded variants of Mapnik (r632,r634)
- Plugins: Use memory mapped files for reading shape file (r628)
- Core: Use streams to write images (i/o refactor) (r628) (#15)

File diff suppressed because it is too large Load diff

View file

@ -1,34 +0,0 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: mapnik
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Artem
family-names: Pavlenko
identifiers:
- type: url
value: 'https://github.com/mapnik/mapnik'
description: GitHub Repository
- type: swh
value: >-
swh:1:dir:3f5758e17e9d54016ca694268da68cf6856fab58
description: Software Archive
repository-code: 'https://github.com/mapnik/mapnik'
url: 'https://mapnik.org/'
abstract: >-
Mapnik is an open source toolkit for developing
mapping applications. At the core is a C++ shared
library providing algorithms and patterns for
spatial data access and visualization.
keywords:
- mapping
- gis
- cartography
- beautiful-maps
- rendering
license: LGPL-2.1

View file

@ -1,472 +0,0 @@
cmake_minimum_required(VERSION 3.15)
# 3.15 is required since the Boost::XXXX targets was first added. https://cmake.org/cmake/help/latest/module/FindBoost.html#imported-targets
# 3.14 is required since SQLite3 Module was first added. https://cmake.org/cmake/help/latest/module/FindSQLite3.html#findsqlite3
include(cmake/GetVersion.cmake)
get_mapnik_version()
project(mapnik
VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION}
HOMEPAGE_URL "https://mapnik.org/"
DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications"
LANGUAGES CXX
)
message(STATUS "mapnik version: ${PROJECT_VERSION}")
# https://cliutils.gitlab.io/modern-cmake/chapters/features/ides.html
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON) # with newer cmake versions put all find_package in global scope
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(FeatureSummary)
include(MapnikOption)
include(MapnikMinimumVersions)
include(MapnikFindPackage)
include(MapnikInstall)
include(CTest)
add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
mapnik_option(BUILD_SHARED_PLUGINS "build dynamic plugins" ${BUILD_SHARED_LIBS}) # use BUILD_SHARED_LIBS as default option
mapnik_option(BUILD_SHARED_CRT "(only windows with msvc) use msvc shared crt" ON)
if(WIN32 AND BUILD_SHARED_PLUGINS AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "static libmapnik and dynamic plugins won't work correctly")
endif()
mapnik_option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_VARIANT "Use a external mapnik/variant. If off, use the submodule" OFF)
mapnik_option(USE_JPEG "adds jpeg support" ON)
mapnik_option(USE_PNG "adds png support" ON)
mapnik_option(USE_TIFF "adds tiff support" ON)
mapnik_option(USE_WEBP "adds webp support" ON)
mapnik_option(USE_LIBXML2 "adds libxml2 support" ON)
mapnik_option(USE_CAIRO "adds the cairo renderer" ON)
mapnik_option(USE_PROJ "adds proj support" ON)
mapnik_option(USE_GRID_RENDERER "adds grid renderer" ON)
mapnik_option(USE_SVG_RENDERER "adds svg renderer" ON)
mapnik_option(USE_BIGINT "uses 64 bit instead of 32" ON)
mapnik_option(USE_BOOST_FILESYSTEM "use boost::filesytem even if `std::filesystem` is available (since c++17)" OFF)
mapnik_option(USE_MEMORY_MAPPED_FILE "uses file cache" ON)
mapnik_option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON)
mapnik_option(USE_NO_ATEXIT "disable atexit" OFF)
mapnik_option(USE_NO_DLCLOSE "disable dlclose" OFF)
mapnik_option(USE_DEBUG_OUTPUT "enables some debug messages for development" OFF)
mapnik_option(USE_LOG "enables logging output. See log severity level." OFF)
# 0 = debug
# 1 = warn
# 2 = error
# 3 = none
set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON")
mapnik_option(USE_STATS "Enable statistics reporting" OFF)
mapnik_option(DISABLE_MAPNIK_AUTOSETUP "disables the autosetup. Need to call mapnik::setup() then" OFF)
mapnik_option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON)
mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON)
mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON)
mapnik_option(USE_PLUGIN_INPUT_GEOJSON "adds plugin input geojson" ON)
mapnik_option(USE_PLUGIN_INPUT_OGR "adds plugin input ogr" ON)
mapnik_option(USE_PLUGIN_INPUT_PGRASTER "adds plugin input pgraster" ON)
mapnik_option(USE_PLUGIN_INPUT_POSTGIS "adds plugin input postgis" ON)
mapnik_option(USE_PLUGIN_INPUT_RASTER "adds plugin input raster" ON)
mapnik_option(USE_PLUGIN_INPUT_SHAPE "adds plugin input shape" ON)
mapnik_option(USE_PLUGIN_INPUT_SQLITE "adds plugin input sqlite" ON)
mapnik_option(USE_PLUGIN_INPUT_TOPOJSON "adds plugin input topojson" ON)
mapnik_option(BUILD_DEMO_VIEWER "builds the demo viewer" ON)
mapnik_option(BUILD_DEMO_CPP "builds the demo c++ application" ON)
mapnik_option(BUILD_BENCHMARK "builds benchmark project" ON)
mapnik_option(BUILD_UTILITY_GEOMETRY_TO_WKB "builds the utility program geometry_to_wkb" ON)
mapnik_option(BUILD_UTILITY_MAPNIK_INDEX "builds the utility program mapnik_index" ON)
mapnik_option(BUILD_UTILITY_MAPNIK_RENDER "builds the utility program mapnik_render" ON)
mapnik_option(BUILD_UTILITY_OGRINDEX "builds the utility program ogrindex" OFF)
mapnik_option(BUILD_UTILITY_PGSQL2SQLITE "builds the utility program pgsql2sqlite" ON)
mapnik_option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON)
mapnik_option(BUILD_UTILITY_SVG2PNG "builds the utility program svg2png" ON)
mapnik_option(USE_BOOST_REGEX_ICU_WORKAROUND "if you don't use your system libraries and get double linked icu libraries set this to ON" OFF)
mapnik_option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/3792 if you building with libstdc++-4.9" OFF)
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ENABLED_FEATURES DISABLED_FEATURES)
include(GNUInstallDirs)
# See for more details: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
set(MAPNIK_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Install directory for binaries")
set(MAPNIK_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for libraries")
set(MAPNIK_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for archives")
set(MAPNIK_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Install directory for the headers")
set(MAPNIK_CMAKE_DIR ${MAPNIK_LIB_DIR}/cmake/mapnik CACHE STRING "Install directory of the cmake targets")
set(MAPNIK_PKGCONF_DIR ${MAPNIK_LIB_DIR}/pkgconfig CACHE STRING "Install directory for the .pc files for pkg-config")
set(MAPNIK_OUTPUT_DIR "${CMAKE_BINARY_DIR}/out")
if(WIN32)
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_BIN_DIR}/mapnik/input)
else()
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_LIB_DIR}/mapnik/input)
endif()
set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory")
message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}")
set(FONTS_INSTALL_DIR ${MAPNIK_LIB_DIR}/mapnik/fonts CACHE STRING "installs the fonts in the specified directory")
message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}")
set(MAPNIK_COMPILE_DEFS "")
set(MAPNIK_OPTIONAL_LIBS "")
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
#############################
#############################
# Begin project configuration
#############################
#############################
set(CMAKE_CXX_STANDARD 17 CACHE STRING "Sets the c++ standard. c++17 is minimum.")
set(CMAKE_CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
# add debug postfix to the libraries
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
message(STATUS "postfix for debug libraries: ${CMAKE_DEBUG_POSTFIX}")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib")
# needs to be before the first call of find_boost.
if(CMAKE_CXX_STANDARD VERSION_LESS 17)
list(APPEND MAPNIK_COMPILE_DEFS BOOST_SPIRIT_X3_HIDE_CXX17_WARNING)
endif()
if(USE_MULTITHREADED)
set(Boost_USE_MULTITHREADED ON)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_THREADSAFE)
else()
set(Boost_USE_MULTITHREADED OFF)
endif()
mapnik_find_package(PkgConfig REQUIRED)
mapnik_find_threads()
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS regex)
if(CMAKE_CXX_STANDARD VERSION_LESS 17)
set(USE_BOOST_FILESYSTEM ON CACHE BOOL "Use boost::filesystem" FORCE)
endif()
if(USE_BOOST_FILESYSTEM)
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system)
endif()
list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU)
if(USE_BOOST_REGEX_ICU_WORKAROUND)
message(STATUS "using boost regex workaround")
set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES)
endif()
include(CheckBoostRegexIcu)
check_boost_regex()
if(BOOST_REGEX_HAS_ICU)
message(STATUS "boost regex has icu support")
list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU)
endif()
mapnik_find_package(Freetype REQUIRED)
# try to find harfbuzz with the native configuration and fallback to our "own" FindHarfBuzz
mapnik_find_package(harfbuzz CONFIG QUIET)
if(harfbuzz_FOUND)
message(STATUS "Found harfbuzz native cmake")
list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz)
else()
# Use pkg-config when harfbuzz is not found.
# It might be possible that in future version harfbuzz could only be found via pkg-config.
# harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
mapnik_pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION})
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz)
endif()
if(USE_EXTERNAL_MAPBOX_GEOMETRY)
# this is used to provide a way to specify include dirs with CACHE VARIABLES
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/geometry.hpp")
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp" REQUIRED)
endif()
else()
set(MAPBOX_GEOMETRY_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
endif()
if(USE_EXTERNAL_MAPBOX_POLYLABEL)
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/polylabel")
find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp")
endif()
else()
set(MAPBOX_POLYLABEL_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir")
endif()
if(USE_EXTERNAL_MAPBOX_PROTOZERO)
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/protozero")
find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp")
endif()
else()
set(MAPBOX_PROTOZERO_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir")
endif()
if(USE_EXTERNAL_MAPBOX_VARIANT)
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/variant")
find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp")
endif()
else()
set(MAPBOX_VARIANT_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
endif()
# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope
set_property(GLOBAL PROPERTY TARGETS "")
set_property(GLOBAL PROPERTY PLUGINS "")
set_property(GLOBAL PROPERTY MAPNIK_UTILITIES "")
if(USE_GLIBC_WORKAROUND)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND)
endif()
if(USE_BIGINT)
list(APPEND MAPNIK_COMPILE_DEFS BIGINT)
endif()
if(USE_BOOST_FILESYSTEM)
list(APPEND MAPNIK_COMPILE_DEFS USE_BOOST_FILESYSTEM)
list(APPEND MAPNIK_OPTIONAL_LIBS Boost::filesystem)
endif()
if(USE_MEMORY_MAPPED_FILE)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_MEMORY_MAPPED_FILE)
endif()
if(USE_NO_ATEXIT)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_NO_ATEXIT)
endif()
if(USE_NO_DLCLOSE)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_NO_DLCLOSE)
endif()
if(USE_DEBUG_OUTPUT)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DEBUG)
endif()
if(USE_LOG)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_LOG MAPNIK_DEFAULT_LOG_SEVERITY=${USE_LOG_SEVERITY})
endif()
if(USE_STATS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATS)
endif()
if(USE_LIBXML2)
mapnik_find_package(LibXml2 REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2)
list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2)
endif()
if(USE_PNG)
mapnik_find_package(PNG REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG)
list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG)
endif()
if(USE_JPEG)
mapnik_find_package(JPEG REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG)
list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG)
endif()
if(USE_TIFF)
mapnik_find_package(TIFF REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_TIFF)
list(APPEND MAPNIK_OPTIONAL_LIBS TIFF::TIFF)
endif()
if(USE_WEBP)
mapnik_pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP)
endif()
if(USE_CAIRO)
mapnik_pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo)
endif()
if(USE_PROJ)
#https://proj.org/development/cmake.html
mapnik_find_package(PROJ QUIET)
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
if(NOT PROJ_FOUND)
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
mapnik_pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION})
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")
set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}")
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::PROJ)
else()
if(PROJ_VERSION VERSION_LESS PROJ_MIN_VERSION)
message(FATAL_ERROR "Proj needs to be at least version ${PROJ_MIN_VERSION}")
endif()
list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES})
list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $<BUILD_INTERFACE:${PROJ_INCLUDE_DIRS}>)
endif()
math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL)
message(STATUS "Using mapnik PROJ version: ${MAPNIK_PROJ_VERSION}")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION})
endif()
if(USE_GRID_RENDERER)
list(APPEND MAPNIK_COMPILE_DEFS GRID_RENDERER)
endif()
if(USE_SVG_RENDERER)
list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER)
endif()
if(NOT WIN32)
message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN)
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
endif()
if(NOT BUILD_SHARED_PLUGINS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_PLUGINS)
endif()
# when building static, this have to be public so that all depending libs know about
if(NOT BUILD_SHARED_LIBS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE)
endif()
if(DISABLE_MAPNIK_AUTOSETUP)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DISABLE_AUTOSETUP)
endif()
# force utf-8 source code processing
# see https://docs.microsoft.com/de-de/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170
add_compile_options(
"$<$<CXX_COMPILER_ID:MSVC>:/utf-8>"
"$<$<CXX_COMPILER_ID:MSVC>:/EHsc>"
)
add_library(core INTERFACE)
add_library(mapnik::core ALIAS core)
target_include_directories(core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${MAPBOX_GEOMETRY_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_POLYLABEL_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_VARIANT_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_PROTOZERO_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps>
$<INSTALL_INTERFACE:include>
${MAPNIK_OPTIONAL_LIBS_INCLUDE}
)
target_link_libraries(core INTERFACE
Threads::Threads
ICU::uc
ICU::data
ICU::i18n
Boost::headers
Boost::regex
Freetype::Freetype
${MAPNIK_OPTIONAL_LIBS}
)
target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
mapnik_install(core)
###
# forward declaring libraries to consume them when building static plugins (circle deps between mapnik <-> plugin_target)
add_library(mapnik "")
add_library(mapnik::mapnik ALIAS mapnik)
add_library(wkt STATIC "")
add_library(mapnik::wkt ALIAS wkt)
add_library(json STATIC "")
add_library(mapnik::json ALIAS json)
# end forward declaration
###
add_subdirectory(deps)
add_subdirectory(plugins)
add_subdirectory(src)
add_subdirectory(utils)
add_subdirectory(demo)
if(BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
file(COPY fonts DESTINATION "${MAPNIK_OUTPUT_DIR}")
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/packages.log" WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND INCLUDE_QUIET_PACKAGES)
# start package mapnik
include(MapnikExport)
include(MapnikExportPkgConfig)
install(DIRECTORY include/mapnik/ DESTINATION "${MAPNIK_INCLUDE_DIR}/mapnik")
install(DIRECTORY deps/agg/include/ DESTINATION "${MAPNIK_INCLUDE_DIR}/mapnik/agg")
install(DIRECTORY deps/mapnik DESTINATION "${MAPNIK_INCLUDE_DIR}")
file(GLOB TTF_FONT_FILES "fonts/*/*/*.ttf")
install(FILES ${TTF_FONT_FILES} DESTINATION "${FONTS_INSTALL_DIR}")
if(NOT USE_EXTERNAL_MAPBOX_GEOMETRY)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif()
if(NOT USE_EXTERNAL_MAPBOX_POLYLABEL)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif()
if(NOT USE_EXTERNAL_MAPBOX_PROTOZERO)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif()
if(NOT USE_EXTERNAL_MAPBOX_VARIANT)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif()
mapnik_install_targets()
include(pack)

View file

@ -1,350 +0,0 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "use-ninja",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "default-build-dir",
"hidden": true,
"binaryDir": "${sourceDir}/build"
},
{
"name": "debug-build",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"USE_DEBUG_OUTPUT": "ON",
"USE_LOG": "ON",
"USE_LOG_SEVERITY": "0"
}
},
{
"name": "release-with-debug-build",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"USE_DEBUG_OUTPUT": "OFF",
"USE_LOG": "OFF"
}
},
{
"name": "release-build",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"USE_DEBUG_OUTPUT": "OFF",
"USE_LOG": "OFF"
}
},
{
"name": "use-clang",
"hidden": true,
"inherits": [
"default-build-dir",
"use-ninja"
],
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++",
"CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++"
}
},
{
"name": "use-gcc",
"hidden": true,
"inherits": [
"default-build-dir",
"use-ninja"
],
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "use-msvc-cl",
"hidden": true,
"inherits": [
"default-build-dir",
"use-ninja"
],
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
{
"name": "use-msvc-clang-cl",
"hidden": true,
"inherits": [
"default-build-dir",
"use-ninja"
],
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl"
}
},
{
"name": "linux-clang-debug",
"displayName": "Linux clang debug",
"inherits": [
"use-clang",
"debug-build"
]
},
{
"name": "linux-clang-release",
"displayName": "Linux clang release",
"inherits": [
"use-clang",
"release-build"
]
},
{
"name": "linux-gcc-debug",
"displayName": "Linux gcc debug",
"inherits": [
"use-gcc",
"debug-build"
]
},
{
"name": "linux-gcc-release",
"displayName": "Linux gcc release",
"inherits": [
"use-gcc",
"release-build"
]
},
{
"name": "windows-arch-x64",
"hidden": true,
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "windows-default",
"displayName": "Windows x64 Debug",
"hidden": true,
"inherits": [
"use-msvc-cl",
"windows-arch-x64"
],
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Windows"
]
}
}
},
{
"name": "windows-debug",
"displayName": "Windows x64 Debug",
"inherits": [
"windows-default",
"debug-build"
]
},
{
"name": "windows-release",
"displayName": "Windows x64 Release",
"inherits": [
"windows-default",
"release-build"
]
},
{
"name": "ci-options",
"hidden": true,
"cacheVariables": {
"BUILD_TESTING": "ON",
"BUILD_DEMO_VIEWER": "OFF",
"DISABLE_MAPNIK_AUTOSETUP": "ON"
},
"toolchainFile": "vcpkg/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "windows-ci",
"description": "used by the ci pipeline",
"inherits": [
"windows-release",
"ci-options"
],
"cacheVariables": {
"INSTALL_DEPENDENCIES": "ON",
"ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/vcpkg_installed/x64-windows/bin"
},
"environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-windows/share/proj"
}
},
{
"name": "linux-ci",
"description": "used by the ci pipeline",
"inherits": [
"release-with-debug-build",
"use-gcc",
"ci-options"
],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "--coverage"
},
"environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-linux/share/proj"
}
},
{
"name": "linux-ci-release",
"description": "used by the ci pipeline for releasing",
"inherits": [
"release-build",
"linux-gcc-release"
],
"cacheVariables": {
"BUILD_TESTING": "OFF",
"BUILD_DEMO_VIEWER": "OFF",
"USE_MEMORY_MAPPED_FILE": "ON"
}
},
{
"name": "macos-ci-arm64",
"description": "used by the ci pipeline",
"inherits": [
"use-ninja",
"release-with-debug-build",
"default-build-dir",
"ci-options"
],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
},
"environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/arm64-osx/share/proj"
}
},
{
"name": "macos-ci-x64",
"description": "used by the ci pipeline",
"inherits": [
"use-ninja",
"release-with-debug-build",
"default-build-dir",
"ci-options"
],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
},
"environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-osx/share/proj"
}
}
],
"buildPresets": [
{
"name": "windows-debug",
"configurePreset": "windows-debug"
},
{
"name": "windows-release",
"configurePreset": "windows-release"
},
{
"name": "linux-clang-debug",
"configurePreset": "linux-clang-debug"
},
{
"name": "linux-clang-release",
"configurePreset": "linux-clang-release"
},
{
"name": "linux-gcc-debug",
"configurePreset": "linux-gcc-debug"
},
{
"name": "linux-gcc-release",
"configurePreset": "linux-gcc-release"
},
{
"name": "windows-ci",
"configurePreset": "windows-ci"
},
{
"name": "linux-ci",
"configurePreset": "linux-ci"
},
{
"name": "linux-ci-release",
"configurePreset": "linux-ci-release"
},
{
"name": "macos-ci-arm64",
"configurePreset": "macos-ci-arm64"
},
{
"name": "macos-ci-x64",
"configurePreset": "macos-ci-x64"
}
],
"testPresets": [
{
"name": "test-default",
"hidden": true,
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": false
}
},
{
"name": "windows-ci",
"configurePreset": "windows-ci",
"inherits": [
"test-default"
]
},
{
"name": "linux-ci",
"configurePreset": "linux-ci",
"inherits": [
"test-default"
]
},
{
"name": "macos-ci-arm64",
"configurePreset": "macos-ci-arm64",
"inherits": [
"test-default"
]
},
{
"name": "macos-ci-x64",
"configurePreset": "macos-ci-x64",
"inherits": [
"test-default"
]
}
]
}

View file

@ -1,22 +0,0 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)

36
COPYING
View file

@ -1,8 +1,8 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -10,7 +10,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@ -111,8 +111,8 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@ -455,8 +455,8 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.

210
INSTALL Normal file
View file

@ -0,0 +1,210 @@
# $Id$
INSTALLATION INSTRUCTIONS
Quick Start
-----------
For platform specific install guides see:
http://trac.mapnik.org/wiki/MapnikInstallation
Install needed dependencies::
$ sudo apt-get install libboost* libicu* libfreetype* proj # see below for full list
$ cd ~/src/mapnik
Configure the build setup::
$ python scons/scons.py configure
Build Mapnik source code::
$ python scons/scons.py
Install Mapnik library and python bindings::
$ sudo python scons/scons.py install
If on Linux then run:
$ sudo ldconfig
Run python interpreter and check installation::
>>> import mapnik
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mapnik
>>>
If you get this error ensure that Mapnik in is your PYTHONPATH.
Otherwise your setup is ready. You can now visit http://trac.mapnik.org/wiki/GettingStarted for a basic tutorial.
For help with using SCons see: http://trac.mapnik.org/wiki/UsingScons
For troubleshooting errors see: http://trac.mapnik.org/wiki/InstallationTroubleshooting.
Prerequisites
-------------
First, here is a quick list of the required software dependencies:
- Linux/UNIX with g++ compiler
- Python 2.2 or greater to build Mapnik
- Python 2.4 for python bindings (see below)
- libboost >= 1.34.0 or greater with the following libraries included:
- system
- thread
- filesystem
- regex
- iostreams
- python - required only for python bindings (see below)
- libicu - International Components for Unicode
- libpng - PNG Graphics
- libjpeg - JPEG Graphics
- libtiff - TIFF Graphics
- libz - Compression
- libfreetype2 - Font support (Install requires freetype-config)
- libxml2 - XML parsing (Install requires xml2-config)
- proj - PROJ.4 Projection library
Second, here are the optional software dependencies:
- Python 2.4 or greater for Python language bindings
- Boost 'python', required for binding Python language bindings
- Boost 'program_options' for shapeindex executable support
- Cairo - Graphics library for PDF, PS, and SVG formats
- pkg-config - Required for building with cairo support
- cairomm - C++ bindings for cairo
- pycairo - Python bindings for cairo
- libpq - PostgreSQL libraries (For PostGIS plugin support)
- libgdal - GDAL/OGR input (For gdal and ogr plugin support)
- libsqlite3 - SQLite input (needs RTree support) (sqlite plugin support)
- libocci - Oracle input plugin support
- libcurl - OSM input plugin support
If your system does NOT have one of these installed, you will need to install the mandatory ones at the very least before proceeding further.
Instructions for installing many of these dependencies on various platforms can be found at the Mapnik Community Wiki (http://trac.mapnik.org/wiki/MapnikInstallation).
On Linux and Mac OS, package management systems (such as apt for debian or macports for darwin) can be used to install most or all dependencies, but source installs may be preferrable. This is particularly true for libraries that a required for the Python bindings, where source installs may be the best way to ensure that the same python version us linked to Boost, Cairo, and Mapnik.
Note: a minimum of 256MB of RAM is recommended for the build process.
Building
--------
Once you've installed the required software packages, the simplest way to build Mapnik is to run SCons (The software builder) without any options::
$ cd ~/src/mapnik
$ python scons/scons.py configure
$ python scons/scons.py # will build sources
This should compile and link the mapnik library as well as the input plugins and the python language binding (if possible). If any mandatory dependencies are not found the build will fail, and you will need to specify custom paths to your libraries and include files.
SCons accepts a variety of options to customize your build. This allows you to specify which components are compiled, where to find dependencies, where to install mapnik, and so on.
To see the list of available options, from the root of the source distribution, run::
$ python scons/scons.py -h
For example, if you compiled your own set of Boost libraries, you might use::
$ python scons/scons.py configure BOOST_INCLUDES=/usr/local/include/ BOOST_LIBS=/usr/local/lib
Or if you installed ICU from source and you'd like to build Mapnik in Debug mode you might use::
$ python scons/scons.py configure DEBUG=True ICU_INCLUDES=/usr/local/include ICU_LIBS=/usr/local/lib
For more details on all the options see: http://trac.mapnik.org/wiki/UsingScons
Note: the Python used to run SCons does NOT have to be the same as the one used for the python bindings.
Installation
------------
Once the build has successfully completed, you can install the various files on your system by executing::
$ sudo python scons/scons.py install
By default, everything will be installed under the PREFIX '/usr/local' as such::
$PREFIX/lib: libmapnik.so (.dylib on mac os)
$PREFIX/lib/mapnik/input: input plug-ins
$PREFIX/include: mapnik include files
$PREFIX/bin: shapeindex utility
$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages/mapnik: Python bindings
If you're using the default PREFIX, you will most likely need to be root to perform the install.
Testing Installation
--------------------
First, try importing the Mapnik python module in a python interpreter, and make sure it does so without errors::
$ python
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>>
Then, try rendering the demo map, included in the Mapnik source code::
$ cd demo/python
$ python rundemo.py
If the resulting maps look good, this indicates the core components of Mapnik are installed properly, as well as the Shapefile plugin, Unicode text support (ICU), and re-projection support using Proj.
For further tests see the `tests` folder within the Mapnik source code.
Learning Mapnik
---------------
For Users:
- Visit http://trac.mapnik.org/wiki/LearningMapnik for basic tutorials on making maps with Mapnik using the Python bindings.
For Developers:
- Visit http://trac.mapnik.org/#DevelopersCorner for resources for getting involved with Mapnik development.
Mapnik Community
----------------
Mapnik has an active community of talented users and developers making amazing maps.
If you are looking for further help on installation or usage and you can't find what you are looking for from searching the users list archives (http://lists.berlios.de/pipermail/mapnik-users/) or the trac wiki (http://trac.mapnik.org/), feel free to join the Mapnik community and introduce yourself.
You can get involved by:
- Subscribing to the mapnik-users list: http://lists.berlios.de/mailman/listinfo/mapnik-users
- Subscribing to the mapnik-developers list: http://lists.berlios.de/mailman/listinfo/mapnik-devel
- Joining the #mapnik channel on irc://irc.freenode.net/mapnik
- Signing up as a user or contributer at http://www.ohloh.net/p/mapnik/
A note on projection support
----------------------------
Mapnik's core C++ library and map rendering engine support on-the-fly cartographic
reprojections.
Here is an example on how to use it::
>>> import mapnik
>>> p = mapnik.Projection('+init=epsg:27700') # British National Grid
>>> p.forward(mapnik.Coord(-1.125,51.75))
Coord(460396.920899,206113.214203) # reprojected coordinate x, y pair
>>> p.forward(mapnik.Envelope(-1.125,51.75,-1.0,50.75))
Envelope(461721.365661,94917.0749406,469024.861457,206224.090767) # reprojected extent
The Projection() instance provides inverse() and forward() methods. For details on the possible parameters,
see the PROJ.4 documentation.

View file

@ -1,204 +0,0 @@
# Mapnik Installation
Mapnik runs on Linux, OS X, Windows, and BSD systems.
## Package managers
### vcpkg
To install mapnik with vcpkg type `vcpkg install mapnik`. It will install a minimal version of mapnik and all the needed dependencies.
To install more features, type `vcpkg search mapnik` to see all available features.
## Source build
First clone mapnik from github and initialize submodules
```bash
git clone https://github.com/mapnik/mapnik.git
cd mapnik
git submodule update --init
```
To configure and build Mapnik do:
```bash
./configure
make
```
To trigger parallel compilation you can pass a JOBS value to make:
```bash
JOBS=4 make
```
Mapnik needs > 2 GB of RAM to build. If you use parallel compilation it needs more.
If you are on a system with less memory make sure you only build with one JOB:
```bash
JOBS=1 make
```
To use a Python interpreter that is not named `python` for your build, do
something like the following instead:
```bash
$ PYTHON=python3 ./configure
$ make PYTHON=python3
```
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/WindowsInstallation
Then to run the tests locally (without needing to install):
make test
Install like:
make install
If you need to uninstall do:
make uninstall
For more details see the `Building` Section below.
Platform specific install guides at https://github.com/mapnik/mapnik/wiki/Mapnik-Installation
For troubleshooting help see https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting
## Depends
Build system dependencies are:
* C++ compiler supporting `-std=c++17` (like >= g++ 9 or >= clang++ 5)
* \>= 2 GB RAM (> 5 GB for g++)
* Python 3
* Scons (a copy is bundled) or CMake >= 3.15 see [docs/cmake-usage.md](./docs/cmake-usage.md)
Mapnik Core depends on:
* Boost
- \>= 1.73 is required
- These libraries are used:
- filesystem
- system
- regex (optionally built with icu regex support)
- program_options (optionally for mapnik command line programs)
* libicuuc >= 4.0 (ideally >= 4.2) - International Components for Unicode
* libz - Zlib compression
* libfreetype - Freetype2 for font support (Install requires freetype-config)
* libxml2 - XML parsing (Install requires xml2-config)
* libharfbuzz - an OpenType text shaping engine (>=0.9.34 needed for CSS font-feature-settings support)
Mapnik Core optionally depends on:
* libpng >= 1.2.x - PNG graphics (Default enabled, if found)
* libjpeg - JPEG graphics (Default enabled, if found)
* libtiff - TIFF graphics (Default enabled, if found)
* libwebp - WEBP graphics (Default enabled, if found)
* libproj >= 7.2.0 - PROJ projection library (Default enabled, if found)
Additional optional dependencies:
* Cairo >= 1.6.0 - Graphics library for output formats like PDF, PS, and SVG
- pkg-config - Required for building with cairo support
* PostgreSQL (for PostGIS plugin support)
- libpq - PostreSQL libraries
- pg_config - PostgreSQL installation capabilities
* libgdal - GDAL/OGR input (For gdal and ogr plugin support) (>= GDAL 2.0.2 for thread safety - https://github.com/mapnik/mapnik/issues/3339)
* libsqlite3 - SQLite input (needs RTree support builtin) (sqlite plugin support)
Instructions for installing many of these dependencies on
various platforms can be found at the Mapnik Wiki:
https://github.com/mapnik/mapnik/wiki/Mapnik-Installation
## Building
The build system uses SCons, a pure python equivalent to autotools or cmake.
We provide a simple Makefile wrapper that can be used like:
./configure && make && make install
For help on what options are accepted do:
./configure --help
To interact with the local copy of scons directly you can do:
python scons/scons.py configure
You can also use a globally installed scons:
scons configure
If you want to clean your build do:
make clean
If you experience odd configure errors, try cleaning the configure caches:
make distclean
To install in a custom location do:
./configure PREFIX=/opt/mapnik
To pass custom CXXFLAGS or LDFLAGS do:
./configure CUSTOM_CXXFLAGS="-g -I/usr/include" CUSTOM_LDFLAGS="-L/usr/lib"
To pass custom paths to a dependency, like boost, do:
./configure BOOST_INCLUDES=/opt/boost/include BOOST_LIBS=/opt/boost/lib
To pass custom paths to a dependency, like icu, do:
./configure ICU_INCLUDES=/usr/local/include ICU_LIBS=/usr/local/include
For more details on usage see:
https://github.com/mapnik/mapnik/wiki/UsingScons
## Testing Installation
You can run the Mapnik tests locally (without installing) like:
make test
## Python Bindings
Python bindings are not included by default. You'll need to add those separately.
* Build from source: https://github.com/mapnik/python-mapnik
## Learning Mapnik
### Help
Mapnik has an active community of talented users and developers making beautiful maps.
If you need help or want to participate starting points include:
- Sign up and post to the mailing list: http://mapnik.org/contact/
- Join and ask questions on the #mapnik channel on irc://irc.freenode.net/mapnik
- Add your help questions to https://github.com/mapnik/mapnik-support
### Cartographers
TileMill, which uses Mapnik internally, offers great step by step tutorials for
learning advanced map styling: https://tilemill-project.github.io/tilemill/docs/crashcourse/introduction/
### Programmers
Mapnik is great for building your own mapping applications. Visit
https://github.com/mapnik/mapnik/wiki/LearningMapnik for basic
tutorials on how to programmatically use Mapnik.
### Contributors
Read [docs/contributing.md](docs/contributing.md) for resources for getting involved with Mapnik development.

109
Makefile
View file

@ -1,109 +0,0 @@
OS := $(shell uname -s)
ifeq ($(JOBS),)
JOBS:=1
endif
ifeq ($(HEAVY_JOBS),)
HEAVY_JOBS:=1
endif
all: mapnik
install:
$(PYTHON) scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1 install
release:
./scripts/publish_release.sh
test-release:
./scripts/test_release.sh
src/json/libmapnik-json.a:
# we first build memory intensive files with -j$(HEAVY_JOBS)
$(PYTHON) scons/scons.py -j$(HEAVY_JOBS) \
--config=cache --implicit-cache --max-drift=1 \
src/renderer_common/render_group_symbolizer.os \
src/renderer_common/render_markers_symbolizer.os \
src/renderer_common/render_thunk_extractor.os \
src/json/libmapnik-json.a \
src/wkt/libmapnik-wkt.a \
src/css/css_grammar_x3.os \
src/css/css_color_grammar_x3.os \
src/expression_grammar_x3.os \
src/transform_expression_grammar_x3.os \
src/image_filter_grammar_x3.os \
src/marker_helpers.os \
src/svg/svg_transform_parser.os \
src/agg/process_line_symbolizer.os \
plugins/input/geojson/geojson_datasource.os \
src/svg/svg_path_parser.os \
src/svg/svg_parser.os \
src/svg/svg_points_parser.os \
src/svg/svg_transform_parser.os \
mapnik: src/json/libmapnik-json.a
# then install the rest with -j$(JOBS)
$(PYTHON) scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1
clean:
@$(PYTHON) scons/scons.py -j$(JOBS) -c --config=cache --implicit-cache --max-drift=1
@if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi
@if test -e "config.log"; then rm "config.log"; fi
@if test -e "config.cache"; then rm "config.cache"; fi
@if test -e ".sconf_temp/"; then rm -r ".sconf_temp/"; fi
@find ./ -name "*.pyc" -exec rm {} \;
@find ./ -name "*.os" -exec rm {} \;
@find ./src/ -name "*.dylib" -exec rm {} \;
@find ./src/ -name "*.so" -exec rm {} \;
@find ./ -name "*.o" -exec rm {} \;
@find ./src/ -name "*.a" -exec rm {} \;
@find ./ -name "*.gcda" -exec rm {} \;
@find ./ -name "*.gcno" -exec rm {} \;
distclean:
if test -e "config.py"; then mv "config.py" "config.py.backup"; fi
reset: distclean
rebuild:
make uninstall && make clean && time make && make install
uninstall:
@$(PYTHON) scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1 uninstall
test/data-visual:
./scripts/ensure_test_data.sh
test/data:
./scripts/ensure_test_data.sh
test: ./test/data test/data-visual
@./test/run
check: test
bench:
./benchmark/run
demo:
cd demo/c++; ./rundemo `mapnik-config --prefix`
# note: pass --gen-suppressions=yes to create new suppression entries
grind:
@source localize.sh && \
valgrind --suppressions=./test/unit/valgrind.supp --leak-check=full --log-fd=1 ./test/visual/run | grep definitely;
@source localize.sh && \
for FILE in test/standalone/*-bin; do \
valgrind --suppressions=./test/unit/valgrind.supp --leak-check=full --log-fd=1 $${FILE} | grep definitely; \
done
@source localize.sh && \
valgrind --suppressions=./test/unit/valgrind.supp --leak-check=full --log-fd=1 ./test/unit/run | grep definitely;
render:
@for FILE in tests/data/good_maps/*xml; do \
nik2img.py $${FILE} /tmp/$$(basename $${FILE}).png; \
done
.PHONY: install mapnik clean distclean reset uninstall test demo pep8 grind render

20
README Normal file
View file

@ -0,0 +1,20 @@
See INSTALL file for installation instructions
Mapnik is an OpenSource C++/Python toolkit for developing
GIS (Geographic Information Systems) applications. At the core is a C++ shared
library providing algorithms/patterns for spatial data access and visualization.
Essentially a collection of geographic objects (map, layer, datasource, feature, geometry),
the library doesn't rely on "windowing systems" and can be deployed in any server environment.
It is intended to play fair in a multi-threaded environment and is aimed primarily,
but not exclusively, at web-based development.
High-level Python bindings (boost.python) facilitate rapid application development,
targeting zope3, django etc.
Mapnik is a free software and is released under LGPL (GNU Lesser General Public Licence) (see COPYING)
For further information see:
- http://mapnik.org
- http://trac.mapnik.org
- http://ohloh.net/p/mapnik

View file

@ -1,30 +0,0 @@
```
_/ _/ _/ _/
_/_/ _/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/
_/
_/
```
[![TravisCI](https://api.travis-ci.com/mapnik/mapnik.svg?branch=master)](http://travis-ci.com/mapnik/mapnik)
[![codecov](https://codecov.io/gh/mapnik/mapnik/branch/master/graph/badge.svg)](https://codecov.io/gh/mapnik/mapnik)
Mapnik is an open source toolkit for developing mapping applications. At the core is a C++ shared library providing algorithms and patterns for spatial data access and visualization.
Mapnik is basically a collection of geographic objects like maps, layers, datasources, features, and geometries. The library doesn't rely on any OS specific "windowing systems" and it can be deployed to any server environment. It is intended to play fair in a multi-threaded environment and is aimed primarily, but not exclusively, at web-based development.
For further information see [http://mapnik.org](http://mapnik.org) and also our [wiki documentation](https://github.com/mapnik/mapnik/wiki).
# Installation
See [INSTALL.md](INSTALL.md) for installation instructions and the [Install](https://github.com/mapnik/mapnik/wiki/Mapnik-Installation) page on the wiki for guides.
# Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](https://github.com/mapnik/mapnik/blob/master/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
# License
Mapnik software is free and is released under the LGPL v2.1 ([GNU Lesser General Public License, version 2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)). Please see [COPYING](https://github.com/mapnik/mapnik/blob/master/COPYING) for more information.

2363
SConstruct

File diff suppressed because it is too large Load diff

31
agg/SConscript Normal file
View file

@ -0,0 +1,31 @@
# This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Artem Pavlenko, Jean-Francois Doyon
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# $Id$
import glob
Import('env')
agg_env = env.Clone()
if env['SUNCC']:
cxxflags = '-O -KPIC -DNDEBUG'
else:
cxxflags = '-O%s -fPIC -DNDEBUG' % env['OPTIMIZATION']
agg_env.StaticLibrary('agg', glob.glob('./src/' + '*.cpp'), LIBS=[], CPPPATH='./include', CXXFLAGS=cxxflags)

View file

@ -19,7 +19,7 @@
#ifndef AGG_ALPHA_MASK_U8_INCLUDED
#define AGG_ALPHA_MASK_U8_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_basics.h"
#include "agg_rendering_buffer.h"

View file

@ -20,7 +20,7 @@
#ifndef AGG_ARC_INCLUDED
#define AGG_ARC_INCLUDED
#include <cmath>
#include <math.h>
#include "agg_basics.h"
namespace agg

View file

@ -15,8 +15,8 @@
#ifndef AGG_ARRAY_INCLUDED
#define AGG_ARRAY_INCLUDED
#include <cstddef>
#include <cstring>
#include <stddef.h>
#include <string.h>
#include "agg_basics.h"
namespace agg
@ -27,8 +27,8 @@ namespace agg
{
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]; }
@ -87,7 +87,7 @@ namespace agg
void clear() { m_size = 0; }
void add(const T& v) { m_array[m_size++] = v; }
void push_back(const T& v) { m_array[m_size++] = v; }
void inc_size(unsigned _size) { m_size += _size; }
void inc_size(unsigned size) { m_size += size; }
unsigned size() const { return m_size; }
const T& operator [] (unsigned i) const { return m_array[i]; }
@ -112,9 +112,9 @@ namespace agg
~pod_array() { pod_allocator<T>::deallocate(m_array, m_size); }
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) :
@ -124,20 +124,12 @@ namespace agg
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)
void resize(unsigned size)
{
rhs.m_array = nullptr;
rhs.m_size = 0;
}
void resize(unsigned _size)
{
if(_size != m_size)
if(size != m_size)
{
pod_allocator<T>::deallocate(m_array, m_size);
m_array = pod_allocator<T>::allocate(m_size = _size);
m_array = pod_allocator<T>::allocate(m_size = size);
}
}
const self_type& operator = (const self_type& v)
@ -180,8 +172,6 @@ namespace agg
pod_vector(const pod_vector<T>&);
const pod_vector<T>& operator = (const pod_vector<T>&);
pod_vector(pod_vector<T> && rhs);
// Set new capacity. All data is lost, size is set to zero.
void capacity(unsigned cap, unsigned extra_tail=0);
unsigned capacity() const { return m_capacity; }
@ -201,7 +191,7 @@ namespace agg
void add(const T& v) { m_array[m_size++] = v; }
void push_back(const T& v) { m_array[m_size++] = v; }
void insert_at(unsigned pos, const T& val);
void inc_size(unsigned _size) { m_size += _size; }
void inc_size(unsigned size) { m_size += size; }
unsigned size() const { return m_size; }
unsigned byte_size() const { return m_size * sizeof(T); }
void serialize(int8u* ptr) const;
@ -240,10 +230,10 @@ namespace agg
//------------------------------------------------------------------------
template<class T>
void pod_vector<T>::allocate(unsigned _size, unsigned extra_tail)
void pod_vector<T>::allocate(unsigned size, unsigned extra_tail)
{
capacity(_size, extra_tail);
m_size = _size;
capacity(size, extra_tail);
m_size = size;
}
@ -255,10 +245,10 @@ namespace agg
{
if(new_size > m_capacity)
{
T* _data = pod_allocator<T>::allocate(new_size);
memcpy(_data, m_array, m_size * sizeof(T));
T* data = pod_allocator<T>::allocate(new_size);
memcpy(data, m_array, m_size * sizeof(T));
pod_allocator<T>::deallocate(m_array, m_capacity);
m_array = _data;
m_array = data;
}
}
else
@ -282,17 +272,6 @@ namespace agg
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)
{
rhs.m_size = 0;
rhs.m_capacity = 0;
rhs.m_array = nullptr;
}
//------------------------------------------------------------------------
template<class T> const pod_vector<T>&
pod_vector<T>::operator = (const pod_vector<T>&v)
@ -310,11 +289,11 @@ namespace agg
//------------------------------------------------------------------------
template<class T>
void pod_vector<T>::deserialize(const int8u* _data, unsigned _byte_size)
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));
byte_size /= sizeof(T);
allocate(byte_size);
if(byte_size) memcpy(m_array, data, byte_size * sizeof(T));
}
//------------------------------------------------------------------------
@ -392,9 +371,9 @@ namespace agg
}
}
void cut_at(unsigned _size)
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; }
@ -537,11 +516,10 @@ namespace agg
if(m_num_blocks)
{
T** blk = m_blocks + m_num_blocks - 1;
while(m_num_blocks > 0)
while(m_num_blocks--)
{
pod_allocator<T>::deallocate(*blk, block_size);
--blk;
--m_num_blocks;
}
}
pod_allocator<T*>::deallocate(m_blocks, m_max_blocks);
@ -550,11 +528,11 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S>
void pod_bvector<T, S>::free_tail(unsigned _size)
void pod_bvector<T, S>::free_tail(unsigned size)
{
if(_size < m_size)
if(size < m_size)
{
unsigned nb = (_size + block_mask) >> block_shift;
unsigned nb = (size + block_mask) >> block_shift;
while(m_num_blocks > nb)
{
pod_allocator<T>::deallocate(m_blocks[--m_num_blocks], block_size);
@ -565,7 +543,7 @@ namespace agg
m_blocks = 0;
m_max_blocks = 0;
}
m_size = _size;
m_size = size;
}
}
@ -749,16 +727,16 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S>
void pod_bvector<T, S>::deserialize(const int8u* _data, unsigned _byte_size)
void pod_bvector<T, S>::deserialize(const int8u* data, unsigned byte_size)
{
remove_all();
_byte_size /= sizeof(T);
for(unsigned i = 0; i < _byte_size; ++i)
byte_size /= sizeof(T);
for(unsigned i = 0; i < byte_size; ++i)
{
T* ptr = data_ptr();
memcpy(ptr, _data, sizeof(T));
memcpy(ptr, data, sizeof(T));
++m_size;
_data += sizeof(T);
data += sizeof(T);
}
}
@ -767,27 +745,27 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S>
void pod_bvector<T, S>::deserialize(unsigned start, const T& empty_val,
const int8u* _data, unsigned _byte_size)
const int8u* data, unsigned byte_size)
{
while(m_size < start)
{
add(empty_val);
}
_byte_size /= sizeof(T);
for(unsigned i = 0; i < _byte_size; ++i)
byte_size /= sizeof(T);
for(unsigned i = 0; i < byte_size; ++i)
{
if(start + i < m_size)
{
memcpy(&((*this)[start + i]), _data, sizeof(T));
memcpy(&((*this)[start + i]), data, sizeof(T));
}
else
{
T* ptr = data_ptr();
memcpy(ptr, _data, sizeof(T));
memcpy(ptr, data, sizeof(T));
++m_size;
}
_data += sizeof(T);
data += sizeof(T);
}
}
@ -1108,8 +1086,8 @@ namespace agg
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; }

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -16,7 +16,7 @@
#ifndef AGG_BASICS_INCLUDED
#define AGG_BASICS_INCLUDED
#include <cmath>
#include <math.h>
#include "agg_config.h"
//---------------------------------------------------------AGG_CUSTOM_ALLOCATOR
@ -25,25 +25,23 @@
#else
namespace agg
{
// The policy of all AGG containers and memory allocation strategy
// 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
// replace new/delete to malloc/free. The constructors and destructors
// won't be called in this case, however everything will remain working.
// The second argument of deallocate() is the size of the allocated
// replace new/delete to malloc/free. The constructors and destructors
// won't be called in this case, however everything will remain working.
// 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
{
//static T* allocate(unsigned num) { return static_cast<T*>(::operator new(sizeof(T)*num));}
//static void deallocate(T* ptr, unsigned) { ::operator delete(ptr) ;}
static T* allocate(unsigned num) { return new T [num]; }
static void deallocate(T* ptr, unsigned) { delete [] ptr; }
};
// Single object allocator. It's also can be replaced with your custom
// allocator. The difference is that it can only allocate a single
// object and the constructor and destructor must be called.
// allocator. The difference is that it can only allocate a single
// object and the constructor and destructor must be called.
// In AGG there is no need to allocate an array of objects with
// calling their constructors (only single ones). So that, if you
// replace these new/delete to malloc/free make sure that the in-place
@ -89,12 +87,20 @@ namespace agg
#endif
#ifndef AGG_INT64
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define AGG_INT64 signed __int64
#else
#define AGG_INT64 signed long long
#endif
#endif
#ifndef AGG_INT64U
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define AGG_INT64U unsigned __int64
#else
#define AGG_INT64U unsigned long long
#endif
#endif
//------------------------------------------------ Some fixes for MS Visual C++
#if defined(_MSC_VER)
@ -119,6 +125,50 @@ namespace agg
typedef AGG_INT64 int64; //----int64
typedef AGG_INT64U int64u; //----int64u
#if defined(AGG_FISTP)
#pragma warning(push)
#pragma warning(disable : 4035) //Disable warning "no return value"
AGG_INLINE int iround(double v) //-------iround
{
int t;
__asm fld qword ptr [v]
__asm fistp dword ptr [t]
__asm mov eax, dword ptr [t]
}
AGG_INLINE unsigned uround(double v) //-------uround
{
unsigned t;
__asm fld qword ptr [v]
__asm fistp dword ptr [t]
__asm mov eax, dword ptr [t]
}
#pragma warning(pop)
AGG_INLINE unsigned ufloor(double v) //-------ufloor
{
return unsigned(floor(v));
}
AGG_INLINE unsigned uceil(double v) //--------uceil
{
return unsigned(ceil(v));
}
#elif defined(AGG_QIFIST)
AGG_INLINE int iround(double v)
{
return int(v);
}
AGG_INLINE int uround(double v)
{
return unsigned(v);
}
AGG_INLINE unsigned ufloor(double v)
{
return unsigned(floor(v));
}
AGG_INLINE unsigned uceil(double v)
{
return unsigned(ceil(v));
}
#else
AGG_INLINE int iround(double v)
{
return int((v < 0.0) ? v - 0.5 : v + 0.5);
@ -133,8 +183,9 @@ namespace agg
}
AGG_INLINE unsigned uceil(double v)
{
return unsigned(std::ceil(v));
return unsigned(ceil(v));
}
#endif
//---------------------------------------------------------------saturation
template<int Limit> struct saturation
@ -152,7 +203,7 @@ namespace agg
{
AGG_INLINE static unsigned mul(unsigned a, unsigned b)
{
unsigned q = a * b + (1 << (Shift-1));
register unsigned q = a * b + (1 << (Shift-1));
return (q + (q >> Shift)) >> Shift;
}
};
@ -162,23 +213,23 @@ namespace agg
enum cover_scale_e
{
cover_shift = 8, //----cover_shift
cover_size = 1 << cover_shift, //----cover_size
cover_mask = cover_size - 1, //----cover_mask
cover_none = 0, //----cover_none
cover_full = cover_mask //----cover_full
cover_size = 1 << cover_shift, //----cover_size
cover_mask = cover_size - 1, //----cover_mask
cover_none = 0, //----cover_none
cover_full = cover_mask //----cover_full
};
//----------------------------------------------------poly_subpixel_scale_e
// These constants determine the subpixel accuracy, to be more precise,
// the number of bits of the fractional part of the coordinates.
// These constants determine the subpixel accuracy, to be more precise,
// the number of bits of the fractional part of the coordinates.
// 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
{
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
poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale
poly_subpixel_mask = poly_subpixel_scale-1, //----poly_subpixel_mask
};
//----------------------------------------------------------filling_rule_e
@ -202,7 +253,7 @@ namespace agg
{
return rad * 180.0 / pi;
}
//----------------------------------------------------------------rect_base
template<class T> struct rect_base
{
@ -214,9 +265,9 @@ namespace agg
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_)
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()
@ -248,17 +299,17 @@ namespace agg
};
//-----------------------------------------------------intersect_rectangles
template<class Rect>
template<class Rect>
inline Rect intersect_rectangles(const Rect& r1, const Rect& r2)
{
Rect r = r1;
// First process x2,y2 because the other order
// results in Internal Compiler Error under
// Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
// First process x2,y2 because the other order
// results in Internal Compiler Error under
// 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.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;
@ -267,7 +318,7 @@ namespace agg
//---------------------------------------------------------unite_rectangles
template<class Rect>
template<class Rect>
inline Rect unite_rectangles(const Rect& r1, const Rect& r2)
{
Rect r = r1;
@ -285,26 +336,26 @@ namespace agg
//---------------------------------------------------------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
path_cmd_curve3 = 3, //----path_cmd_curve3
path_cmd_curve4 = 4, //----path_cmd_curve4
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
path_cmd_curve3 = 3, //----path_cmd_curve3
path_cmd_curve4 = 4, //----path_cmd_curve4
path_cmd_curveN = 5, //----path_cmd_curveN
path_cmd_catrom = 6, //----path_cmd_catrom
path_cmd_ubspline = 7, //----path_cmd_ubspline
path_cmd_end_poly = 0x0F, //----path_cmd_end_poly
path_cmd_mask = 0x0F //----path_cmd_mask
path_cmd_mask = 0x0F //----path_cmd_mask
};
//------------------------------------------------------------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
path_flags_none = 0, //----path_flags_none
path_flags_ccw = 0x10, //----path_flags_ccw
path_flags_cw = 0x20, //----path_flags_cw
path_flags_close = 0x40, //----path_flags_close
path_flags_mask = 0xF0 //----path_flags_mask
path_flags_mask = 0xF0 //----path_flags_mask
};
//---------------------------------------------------------------is_vertex
@ -321,7 +372,7 @@ namespace agg
//-----------------------------------------------------------------is_stop
inline bool is_stop(unsigned c)
{
{
return c == path_cmd_stop;
}
@ -365,7 +416,7 @@ namespace agg
inline bool is_close(unsigned c)
{
return (c & ~(path_flags_cw | path_flags_ccw)) ==
(path_cmd_end_poly | static_cast<path_commands_e>(path_flags_close));
(path_cmd_end_poly | path_flags_close);
}
//------------------------------------------------------------is_next_poly
@ -389,19 +440,19 @@ namespace agg
//-------------------------------------------------------------is_oriented
inline bool is_oriented(unsigned c)
{
return (c & (path_flags_cw | path_flags_ccw)) != 0;
return (c & (path_flags_cw | path_flags_ccw)) != 0;
}
//---------------------------------------------------------------is_closed
inline bool is_closed(unsigned c)
{
return (c & path_flags_close) != 0;
return (c & path_flags_close) != 0;
}
//----------------------------------------------------------get_close_flag
inline unsigned get_close_flag(unsigned c)
{
return c & path_flags_close;
return c & path_flags_close;
}
//-------------------------------------------------------clear_orientation
@ -462,17 +513,18 @@ namespace agg
int x1, x2;
const T* ptr;
const_row_info() {}
const_row_info(int x1_, int x2_, const T* 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)
{
return std::fabs(v1 - v2) <= double(epsilon);
return fabs(v1 - v2) <= double(epsilon);
}
}
#endif

View file

@ -68,7 +68,7 @@ namespace agg
*x = m_vertices[m_vertex];
*y = m_vertices[m_vertex + 1];
m_vertex += 2;
return (m_vertex == 2) ? (unsigned)path_cmd_move_to : m_cmd;
return (m_vertex == 2) ? path_cmd_move_to : m_cmd;
}
// Supplemantary functions. num_vertices() actually returns doubled

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -13,7 +13,7 @@
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Liang-Barsky clipping
// Liang-Barsky clipping
//
//----------------------------------------------------------------------------
#ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED
@ -36,7 +36,7 @@ namespace agg
};
//----------------------------------------------------------clipping_flags
// Determine the clipping code of the vertex according to the
// Determine the clipping code of the vertex according to the
// Cyrus-Beck line clipping algorithm
//
// | |
@ -52,7 +52,7 @@ namespace agg
// | |
// clip_box.x1 clip_box.x2
//
//
//
template<class T>
inline unsigned clipping_flags(T x, T y, const rect_base<T>& clip_box)
{
@ -87,7 +87,7 @@ namespace agg
const double nearzero = 1e-30;
double deltax = x2 - x1;
double deltay = y2 - y1;
double deltay = y2 - y1;
double xin;
double xout;
double yin;
@ -95,52 +95,52 @@ namespace agg
double tinx;
double tiny;
double toutx;
double touty;
double touty;
double tin1;
double tin2;
double tout1;
unsigned np = 0;
if(deltax == 0.0)
{
if(deltax == 0.0)
{
// bump off of the vertical
deltax = (x1 > clip_box.x1) ? -nearzero : nearzero;
}
if(deltay == 0.0)
{
// bump off of the horizontal
if(deltay == 0.0)
{
// bump off of the horizontal
deltay = (y1 > clip_box.y1) ? -nearzero : nearzero;
}
if(deltax > 0.0)
{
if(deltax > 0.0)
{
// points to right
xin = clip_box.x1;
xout = clip_box.x2;
}
else
else
{
xin = clip_box.x2;
xout = clip_box.x1;
}
if(deltay > 0.0)
if(deltay > 0.0)
{
// points up
yin = clip_box.y1;
yout = clip_box.y2;
}
else
else
{
yin = clip_box.y2;
yout = clip_box.y1;
}
tinx = (xin - x1) / deltax;
tiny = (yin - y1) / deltay;
if (tinx < tiny)
if (tinx < tiny)
{
// hits x first
tin1 = tinx;
@ -152,10 +152,10 @@ namespace agg
tin1 = tiny;
tin2 = tinx;
}
if(tin1 <= 1.0)
if(tin1 <= 1.0)
{
if(0.0 < tin1)
if(0.0 < tin1)
{
*x++ = (T)xin;
*y++ = (T)yin;
@ -166,21 +166,21 @@ namespace agg
{
toutx = (xout - x1) / deltax;
touty = (yout - y1) / deltay;
tout1 = (toutx < touty) ? toutx : touty;
if(tin2 > 0.0 || tout1 > 0.0)
if(tin2 > 0.0 || tout1 > 0.0)
{
if(tin2 <= tout1)
if(tin2 <= tout1)
{
if(tin2 > 0.0)
if(tin2 > 0.0)
{
if(tinx > tiny)
if(tinx > tiny)
{
*x++ = (T)xin;
*y++ = (T)(y1 + tinx * deltay);
}
else
else
{
*x++ = (T)(x1 + tiny * deltax);
*y++ = (T)yin;
@ -188,34 +188,34 @@ namespace agg
++np;
}
if(tout1 < 1.0)
if(tout1 < 1.0)
{
if(toutx < touty)
if(toutx < touty)
{
*x++ = (T)xout;
*y++ = (T)(y1 + toutx * deltay);
}
else
else
{
*x++ = (T)(x1 + touty * deltax);
*y++ = (T)yout;
}
}
else
else
{
*x++ = x2;
*y++ = y2;
}
++np;
}
else
else
{
if(tinx > tiny)
if(tinx > tiny)
{
*x++ = (T)xin;
*y++ = (T)yout;
}
else
else
{
*x++ = (T)xout;
*y++ = (T)yin;
@ -231,8 +231,8 @@ namespace agg
//----------------------------------------------------------------------------
template<class T>
bool clip_move_point(T x1, T y1, T x2, T y2,
const rect_base<T>& clip_box,
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;
@ -281,14 +281,14 @@ namespace agg
return 0;
}
if((f1 & clipping_flags_x_clipped) != 0 &&
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 &&
if((f1 & clipping_flags_y_clipped) != 0 &&
(f1 & clipping_flags_y_clipped) == (f2 & clipping_flags_y_clipped))
{
// Fully clipped
@ -299,25 +299,25 @@ namespace agg
T ty1 = *y1;
T tx2 = *x2;
T ty2 = *y2;
if(f1)
{
if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x1, y1, f1))
if(f1)
{
if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x1, y1, f1))
{
return 4;
}
if(*x1 == *x2 && *y1 == *y2)
if(*x1 == *x2 && *y1 == *y2)
{
return 4;
}
ret |= 1;
}
if(f2)
if(f2)
{
if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x2, y2, f2))
{
return 4;
}
if(*x1 == *x2 && *y1 == *y2)
if(*x1 == *x2 && *y1 == *y2)
{
return 4;
}

View file

@ -0,0 +1,414 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Adaptation for high precision colors has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
//
// Liberty Technology Systems, Inc. is the provider of
// PostScript and PDF technology for software developers.
//
//----------------------------------------------------------------------------
//
// color types gray8, gray16
//
//----------------------------------------------------------------------------
#ifndef AGG_COLOR_GRAY_INCLUDED
#define AGG_COLOR_GRAY_INCLUDED
#include "agg_basics.h"
#include "agg_color_rgba.h"
namespace agg
{
//===================================================================gray8
struct gray8
{
typedef int8u value_type;
typedef int32u calc_type;
typedef int32 long_type;
enum base_scale_e
{
base_shift = 8,
base_scale = 1 << base_shift,
base_mask = base_scale - 1
};
typedef gray8 self_type;
value_type v;
value_type a;
//--------------------------------------------------------------------
gray8() {}
//--------------------------------------------------------------------
gray8(unsigned v_, unsigned a_=base_mask) :
v(int8u(v_)), a(int8u(a_)) {}
//--------------------------------------------------------------------
gray8(const self_type& c, unsigned a_) :
v(c.v), a(value_type(a_)) {}
//--------------------------------------------------------------------
gray8(const rgba& c) :
v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
a((value_type)uround(c.a * double(base_mask))) {}
//--------------------------------------------------------------------
gray8(const rgba& c, double a_) :
v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
a((value_type)uround(a_ * double(base_mask))) {}
//--------------------------------------------------------------------
gray8(const rgba8& c) :
v((c.r*77 + c.g*150 + c.b*29) >> 8),
a(c.a) {}
//--------------------------------------------------------------------
gray8(const rgba8& c, unsigned a_) :
v((c.r*77 + c.g*150 + c.b*29) >> 8),
a(a_) {}
//--------------------------------------------------------------------
void clear()
{
v = a = 0;
}
//--------------------------------------------------------------------
const self_type& transparent()
{
a = 0;
return *this;
}
//--------------------------------------------------------------------
void opacity(double a_)
{
if(a_ < 0.0) a_ = 0.0;
if(a_ > 1.0) a_ = 1.0;
a = (value_type)uround(a_ * double(base_mask));
}
//--------------------------------------------------------------------
double opacity() const
{
return double(a) / double(base_mask);
}
//--------------------------------------------------------------------
const self_type& premultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
v = 0;
return *this;
}
v = value_type((calc_type(v) * a) >> base_shift);
return *this;
}
//--------------------------------------------------------------------
const self_type& premultiply(unsigned a_)
{
if(a == base_mask && a_ >= base_mask) return *this;
if(a == 0 || a_ == 0)
{
v = a = 0;
return *this;
}
calc_type v_ = (calc_type(v) * a_) / a;
v = value_type((v_ > a_) ? a_ : v_);
a = value_type(a_);
return *this;
}
//--------------------------------------------------------------------
const self_type& demultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
v = 0;
return *this;
}
calc_type v_ = (calc_type(v) * base_mask) / a;
v = value_type((v_ > base_mask) ? (value_type)base_mask : v_);
return *this;
}
//--------------------------------------------------------------------
self_type gradient(self_type c, double k) const
{
self_type ret;
calc_type ik = uround(k * base_scale);
ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift));
ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
return ret;
}
//--------------------------------------------------------------------
AGG_INLINE void add(const self_type& c, unsigned cover)
{
calc_type cv, ca;
if(cover == cover_mask)
{
if(c.a == base_mask)
{
*this = c;
}
else
{
cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
else
{
cv = v + ((c.v * cover + cover_mask/2) >> cover_shift);
ca = a + ((c.a * cover + cover_mask/2) >> cover_shift);
v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
//--------------------------------------------------------------------
static self_type no_color() { return self_type(0,0); }
};
//-------------------------------------------------------------gray8_pre
inline gray8 gray8_pre(unsigned v, unsigned a = gray8::base_mask)
{
return gray8(v,a).premultiply();
}
inline gray8 gray8_pre(const gray8& c, unsigned a)
{
return gray8(c,a).premultiply();
}
inline gray8 gray8_pre(const rgba& c)
{
return gray8(c).premultiply();
}
inline gray8 gray8_pre(const rgba& c, double a)
{
return gray8(c,a).premultiply();
}
inline gray8 gray8_pre(const rgba8& c)
{
return gray8(c).premultiply();
}
inline gray8 gray8_pre(const rgba8& c, unsigned a)
{
return gray8(c,a).premultiply();
}
//==================================================================gray16
struct gray16
{
typedef int16u value_type;
typedef int32u calc_type;
typedef int64 long_type;
enum base_scale_e
{
base_shift = 16,
base_scale = 1 << base_shift,
base_mask = base_scale - 1
};
typedef gray16 self_type;
value_type v;
value_type a;
//--------------------------------------------------------------------
gray16() {}
//--------------------------------------------------------------------
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 rgba& c) :
v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
a((value_type)uround(c.a * double(base_mask))) {}
//--------------------------------------------------------------------
gray16(const rgba& c, double a_) :
v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
a((value_type)uround(a_ * double(base_mask))) {}
//--------------------------------------------------------------------
gray16(const rgba8& c) :
v(c.r*77 + c.g*150 + c.b*29),
a((value_type(c.a) << 8) | c.a) {}
//--------------------------------------------------------------------
gray16(const rgba8& c, unsigned a_) :
v(c.r*77 + c.g*150 + c.b*29),
a((value_type(a_) << 8) | c.a) {}
//--------------------------------------------------------------------
void clear()
{
v = a = 0;
}
//--------------------------------------------------------------------
const self_type& transparent()
{
a = 0;
return *this;
}
//--------------------------------------------------------------------
void opacity(double a_)
{
if(a_ < 0.0) a_ = 0.0;
if(a_ > 1.0) a_ = 1.0;
a = (value_type)uround(a_ * double(base_mask));
}
//--------------------------------------------------------------------
double opacity() const
{
return double(a) / double(base_mask);
}
//--------------------------------------------------------------------
const self_type& premultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
v = 0;
return *this;
}
v = value_type((calc_type(v) * a) >> base_shift);
return *this;
}
//--------------------------------------------------------------------
const self_type& premultiply(unsigned a_)
{
if(a == base_mask && a_ >= base_mask) return *this;
if(a == 0 || a_ == 0)
{
v = a = 0;
return *this;
}
calc_type v_ = (calc_type(v) * a_) / a;
v = value_type((v_ > a_) ? a_ : v_);
a = value_type(a_);
return *this;
}
//--------------------------------------------------------------------
const self_type& demultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
v = 0;
return *this;
}
calc_type v_ = (calc_type(v) * base_mask) / a;
v = value_type((v_ > base_mask) ? base_mask : v_);
return *this;
}
//--------------------------------------------------------------------
self_type gradient(self_type c, double k) const
{
self_type ret;
calc_type ik = uround(k * base_scale);
ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift));
ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
return ret;
}
//--------------------------------------------------------------------
AGG_INLINE void add(const self_type& c, unsigned cover)
{
calc_type cv, ca;
if(cover == cover_mask)
{
if(c.a == base_mask)
{
*this = c;
}
else
{
cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
else
{
cv = v + ((c.v * cover + cover_mask/2) >> cover_shift);
ca = a + ((c.a * cover + cover_mask/2) >> cover_shift);
v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
//--------------------------------------------------------------------
static self_type no_color() { return self_type(0,0); }
};
//------------------------------------------------------------gray16_pre
inline gray16 gray16_pre(unsigned v, unsigned a = gray16::base_mask)
{
return gray16(v,a).premultiply();
}
inline gray16 gray16_pre(const gray16& c, unsigned a)
{
return gray16(c,a).premultiply();
}
inline gray16 gray16_pre(const rgba& c)
{
return gray16(c).premultiply();
}
inline gray16 gray16_pre(const rgba& c, double a)
{
return gray16(c,a).premultiply();
}
inline gray16 gray16_pre(const rgba8& c)
{
return gray16(c).premultiply();
}
inline gray16 gray16_pre(const rgba8& c, unsigned a)
{
return gray16(c,a).premultiply();
}
}
#endif

View file

@ -0,0 +1,743 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
//
// Adaptation for high precision colors has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
//
// Liberty Technology Systems, Inc. is the provider of
// PostScript and PDF technology for software developers.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
#ifndef AGG_COLOR_RGBA_INCLUDED
#define AGG_COLOR_RGBA_INCLUDED
#include <math.h>
#include "agg_basics.h"
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 }; }; //----order_rgb
struct order_bgr { enum bgr_e { B=0, G=1, R=2, rgb_tag }; }; //----order_bgr
struct order_rgba { enum rgba_e { R=0, G=1, B=2, A=3, rgba_tag }; }; //----order_rgba
struct order_argb { enum argb_e { A=0, R=1, G=2, B=3, rgba_tag }; }; //----order_argb
struct order_abgr { enum abgr_e { A=0, B=1, G=2, R=3, rgba_tag }; }; //----order_abgr
struct order_bgra { enum bgra_e { B=0, G=1, R=2, A=3, rgba_tag }; }; //----order_bgra
//====================================================================rgba
struct rgba
{
typedef double value_type;
double r;
double g;
double b;
double a;
//--------------------------------------------------------------------
rgba() {}
//--------------------------------------------------------------------
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_) {}
//--------------------------------------------------------------------
void clear()
{
r = g = b = a = 0;
}
//--------------------------------------------------------------------
const rgba& transparent()
{
a = 0.0;
return *this;
}
//--------------------------------------------------------------------
const rgba& opacity(double a_)
{
if(a_ < 0.0) a_ = 0.0;
if(a_ > 1.0) a_ = 1.0;
a = a_;
return *this;
}
//--------------------------------------------------------------------
double opacity() const
{
return a;
}
//--------------------------------------------------------------------
const rgba& premultiply()
{
r *= a;
g *= a;
b *= a;
return *this;
}
//--------------------------------------------------------------------
const rgba& premultiply(double a_)
{
if(a <= 0.0 || a_ <= 0.0)
{
r = g = b = a = 0.0;
return *this;
}
a_ /= a;
r *= a_;
g *= a_;
b *= a_;
a = a_;
return *this;
}
//--------------------------------------------------------------------
const rgba& demultiply()
{
if(a == 0)
{
r = g = b = 0;
return *this;
}
double a_ = 1.0 / a;
r *= a_;
g *= a_;
b *= a_;
return *this;
}
//--------------------------------------------------------------------
rgba gradient(rgba c, double k) const
{
rgba ret;
ret.r = r + (c.r - r) * k;
ret.g = g + (c.g - g) * k;
ret.b = b + (c.b - b) * k;
ret.a = a + (c.a - a) * k;
return ret;
}
//--------------------------------------------------------------------
static rgba no_color() { return rgba(0,0,0,0); }
//--------------------------------------------------------------------
static rgba from_wavelength(double wl, double gamma = 1.0);
//--------------------------------------------------------------------
explicit rgba(double wavelen, double gamma=1.0)
{
*this = from_wavelength(wavelen, gamma);
}
};
//----------------------------------------------------------------rgba_pre
inline rgba rgba_pre(double r, double g, double b, double a=1.0)
{
return rgba(r, g, b, a).premultiply();
}
inline rgba rgba_pre(const rgba& c)
{
return rgba(c).premultiply();
}
inline rgba rgba_pre(const rgba& c, double a)
{
return rgba(c, a).premultiply();
}
//------------------------------------------------------------------------
inline rgba rgba::from_wavelength(double wl, double gamma)
{
rgba t(0.0, 0.0, 0.0);
if(wl >= 380.0 && wl <= 440.0)
{
t.r = -1.0 * (wl - 440.0) / (440.0 - 380.0);
t.b = 1.0;
}
else
if(wl >= 440.0 && wl <= 490.0)
{
t.g = (wl - 440.0) / (490.0 - 440.0);
t.b = 1.0;
}
else
if(wl >= 490.0 && wl <= 510.0)
{
t.g = 1.0;
t.b = -1.0 * (wl - 510.0) / (510.0 - 490.0);
}
else
if(wl >= 510.0 && wl <= 580.0)
{
t.r = (wl - 510.0) / (580.0 - 510.0);
t.g = 1.0;
}
else
if(wl >= 580.0 && wl <= 645.0)
{
t.r = 1.0;
t.g = -1.0 * (wl - 645.0) / (645.0 - 580.0);
}
else
if(wl >= 645.0 && wl <= 780.0)
{
t.r = 1.0;
}
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);
t.r = pow(t.r * s, gamma);
t.g = pow(t.g * s, gamma);
t.b = pow(t.b * s, gamma);
return t;
}
//===================================================================rgba8
struct rgba8
{
typedef int8u value_type;
typedef int32u calc_type;
typedef int32 long_type;
enum base_scale_e
{
base_shift = 8,
base_scale = 1 << base_shift,
base_mask = base_scale - 1
};
typedef rgba8 self_type;
value_type r;
value_type g;
value_type b;
value_type a;
//--------------------------------------------------------------------
rgba8() {}
//--------------------------------------------------------------------
rgba8(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_)) {}
//--------------------------------------------------------------------
rgba8(const rgba& c, double a_) :
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(a_ * double(base_mask))) {}
//--------------------------------------------------------------------
rgba8(const self_type& c, unsigned a_) :
r(c.r), g(c.g), b(c.b), a(value_type(a_)) {}
//--------------------------------------------------------------------
rgba8(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))) {}
//--------------------------------------------------------------------
void clear()
{
r = g = b = a = 0;
}
//--------------------------------------------------------------------
const self_type& transparent()
{
a = 0;
return *this;
}
//--------------------------------------------------------------------
const self_type& opacity(double a_)
{
if(a_ < 0.0) a_ = 0.0;
if(a_ > 1.0) a_ = 1.0;
a = (value_type)uround(a_ * double(base_mask));
return *this;
}
//--------------------------------------------------------------------
double opacity() const
{
return double(a) / double(base_mask);
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& premultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
r = g = b = 0;
return *this;
}
r = value_type((calc_type(r) * a) >> base_shift);
g = value_type((calc_type(g) * a) >> base_shift);
b = value_type((calc_type(b) * a) >> base_shift);
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& premultiply(unsigned a_)
{
if(a == base_mask && a_ >= base_mask) return *this;
if(a == 0 || a_ == 0)
{
r = g = b = a = 0;
return *this;
}
calc_type r_ = (calc_type(r) * a_) / a;
calc_type g_ = (calc_type(g) * a_) / a;
calc_type b_ = (calc_type(b) * a_) / a;
r = value_type((r_ > a_) ? a_ : r_);
g = value_type((g_ > a_) ? a_ : g_);
b = value_type((b_ > a_) ? a_ : b_);
a = value_type(a_);
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& demultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
r = g = b = 0;
return *this;
}
calc_type r_ = (calc_type(r) * base_mask) / a;
calc_type g_ = (calc_type(g) * base_mask) / a;
calc_type b_ = (calc_type(b) * base_mask) / a;
r = value_type((r_ > calc_type(base_mask)) ? calc_type(base_mask) : r_);
g = value_type((g_ > calc_type(base_mask)) ? calc_type(base_mask) : g_);
b = value_type((b_ > calc_type(base_mask)) ? calc_type(base_mask) : b_);
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE self_type gradient(const self_type& c, double k) const
{
self_type ret;
calc_type ik = uround(k * base_scale);
ret.r = value_type(calc_type(r) + (((calc_type(c.r) - r) * ik) >> base_shift));
ret.g = value_type(calc_type(g) + (((calc_type(c.g) - g) * ik) >> base_shift));
ret.b = value_type(calc_type(b) + (((calc_type(c.b) - b) * ik) >> base_shift));
ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
return ret;
}
//--------------------------------------------------------------------
AGG_INLINE void add(const self_type& c, unsigned cover)
{
calc_type cr, cg, cb, ca;
if(cover == cover_mask)
{
if(c.a == base_mask)
{
*this = c;
}
else
{
cr = r + c.r; r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr;
cg = g + c.g; g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg;
cb = b + c.b; b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb;
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
else
{
cr = r + ((c.r * cover + cover_mask/2) >> cover_shift);
cg = g + ((c.g * cover + cover_mask/2) >> cover_shift);
cb = b + ((c.b * cover + cover_mask/2) >> cover_shift);
ca = a + ((c.a * cover + cover_mask/2) >> cover_shift);
r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr;
g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg;
b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb;
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
//--------------------------------------------------------------------
template<class GammaLUT>
AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma)
{
r = gamma.dir(r);
g = gamma.dir(g);
b = gamma.dir(b);
}
//--------------------------------------------------------------------
template<class GammaLUT>
AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma)
{
r = gamma.inv(r);
g = gamma.inv(g);
b = gamma.inv(b);
}
//--------------------------------------------------------------------
static self_type no_color() { return self_type(0,0,0,0); }
//--------------------------------------------------------------------
static self_type from_wavelength(double wl, double gamma = 1.0)
{
return self_type(rgba::from_wavelength(wl, gamma));
}
};
//-------------------------------------------------------------rgba8_pre
inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b,
unsigned a = rgba8::base_mask)
{
return rgba8(r,g,b,a).premultiply();
}
inline rgba8 rgba8_pre(const rgba8& c)
{
return rgba8(c).premultiply();
}
inline rgba8 rgba8_pre(const rgba8& c, unsigned a)
{
return rgba8(c,a).premultiply();
}
inline rgba8 rgba8_pre(const rgba& c)
{
return rgba8(c).premultiply();
}
inline rgba8 rgba8_pre(const rgba& c, double a)
{
return rgba8(c,a).premultiply();
}
//-------------------------------------------------------------rgb8_packed
inline rgba8 rgb8_packed(unsigned v)
{
return rgba8((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF);
}
//-------------------------------------------------------------bgr8_packed
inline rgba8 bgr8_packed(unsigned v)
{
return rgba8(v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF);
}
//------------------------------------------------------------argb8_packed
inline rgba8 argb8_packed(unsigned v)
{
return rgba8((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF, v >> 24);
}
//---------------------------------------------------------rgba8_gamma_dir
template<class GammaLUT>
rgba8 rgba8_gamma_dir(rgba8 c, const GammaLUT& gamma)
{
return rgba8(gamma.dir(c.r), gamma.dir(c.g), gamma.dir(c.b), c.a);
}
//---------------------------------------------------------rgba8_gamma_inv
template<class GammaLUT>
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
{
base_shift = 16,
base_scale = 1 << base_shift,
base_mask = base_scale - 1
};
typedef rgba16 self_type;
value_type r;
value_type g;
value_type b;
value_type a;
//--------------------------------------------------------------------
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(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, double a_) :
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(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, unsigned a_) :
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(( a_ << 8) | c.a)) {}
//--------------------------------------------------------------------
void clear()
{
r = g = b = a = 0;
}
//--------------------------------------------------------------------
const self_type& transparent()
{
a = 0;
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& opacity(double a_)
{
if(a_ < 0.0) a_ = 0.0;
if(a_ > 1.0) a_ = 1.0;
a = (value_type)uround(a_ * double(base_mask));
return *this;
}
//--------------------------------------------------------------------
double opacity() const
{
return double(a) / double(base_mask);
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& premultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
r = g = b = 0;
return *this;
}
r = value_type((calc_type(r) * a) >> base_shift);
g = value_type((calc_type(g) * a) >> base_shift);
b = value_type((calc_type(b) * a) >> base_shift);
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& premultiply(unsigned a_)
{
if(a == base_mask && a_ >= base_mask) return *this;
if(a == 0 || a_ == 0)
{
r = g = b = a = 0;
return *this;
}
calc_type r_ = (calc_type(r) * a_) / a;
calc_type g_ = (calc_type(g) * a_) / a;
calc_type b_ = (calc_type(b) * a_) / a;
r = value_type((r_ > a_) ? a_ : r_);
g = value_type((g_ > a_) ? a_ : g_);
b = value_type((b_ > a_) ? a_ : b_);
a = value_type(a_);
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE const self_type& demultiply()
{
if(a == base_mask) return *this;
if(a == 0)
{
r = g = b = 0;
return *this;
}
calc_type r_ = (calc_type(r) * base_mask) / a;
calc_type g_ = (calc_type(g) * base_mask) / a;
calc_type b_ = (calc_type(b) * base_mask) / a;
r = value_type((r_ > calc_type(base_mask)) ? calc_type(base_mask) : r_);
g = value_type((g_ > calc_type(base_mask)) ? calc_type(base_mask) : g_);
b = value_type((b_ > calc_type(base_mask)) ? calc_type(base_mask) : b_);
return *this;
}
//--------------------------------------------------------------------
AGG_INLINE self_type gradient(const self_type& c, double k) const
{
self_type ret;
calc_type ik = uround(k * base_scale);
ret.r = value_type(calc_type(r) + (((calc_type(c.r) - r) * ik) >> base_shift));
ret.g = value_type(calc_type(g) + (((calc_type(c.g) - g) * ik) >> base_shift));
ret.b = value_type(calc_type(b) + (((calc_type(c.b) - b) * ik) >> base_shift));
ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
return ret;
}
//--------------------------------------------------------------------
AGG_INLINE void add(const self_type& c, unsigned cover)
{
calc_type cr, cg, cb, ca;
if(cover == cover_mask)
{
if(c.a == base_mask)
{
*this = c;
}
else
{
cr = r + c.r; r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr;
cg = g + c.g; g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg;
cb = b + c.b; b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb;
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
else
{
cr = r + ((c.r * cover + cover_mask) >> cover_shift);
cg = g + ((c.g * cover + cover_mask) >> cover_shift);
cb = b + ((c.b * cover + cover_mask) >> cover_shift);
ca = a + ((c.a * cover + cover_mask) >> cover_shift);
r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr;
g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg;
b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb;
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
}
}
//--------------------------------------------------------------------
template<class GammaLUT>
AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma)
{
r = gamma.dir(r);
g = gamma.dir(g);
b = gamma.dir(b);
}
//--------------------------------------------------------------------
template<class GammaLUT>
AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma)
{
r = gamma.inv(r);
g = gamma.inv(g);
b = gamma.inv(b);
}
//--------------------------------------------------------------------
static self_type no_color() { return self_type(0,0,0,0); }
//--------------------------------------------------------------------
static self_type from_wavelength(double wl, double gamma = 1.0)
{
return self_type(rgba::from_wavelength(wl, gamma));
}
};
//--------------------------------------------------------------rgba16_pre
inline rgba16 rgba16_pre(unsigned r, unsigned g, unsigned b,
unsigned a = rgba16::base_mask)
{
return rgba16(r,g,b,a).premultiply();
}
inline rgba16 rgba16_pre(const rgba16& c, unsigned a)
{
return rgba16(c,a).premultiply();
}
inline rgba16 rgba16_pre(const rgba& c)
{
return rgba16(c).premultiply();
}
inline rgba16 rgba16_pre(const rgba& c, double a)
{
return rgba16(c,a).premultiply();
}
inline rgba16 rgba16_pre(const rgba8& c)
{
return rgba16(c).premultiply();
}
inline rgba16 rgba16_pre(const rgba8& c, unsigned a)
{
return rgba16(c,a).premultiply();
}
//------------------------------------------------------rgba16_gamma_dir
template<class GammaLUT>
rgba16 rgba16_gamma_dir(rgba16 c, const GammaLUT& gamma)
{
return rgba16(gamma.dir(c.r), gamma.dir(c.g), gamma.dir(c.b), c.a);
}
//------------------------------------------------------rgba16_gamma_inv
template<class GammaLUT>
rgba16 rgba16_gamma_inv(rgba16 c, const GammaLUT& gamma)
{
return rgba16(gamma.inv(c.r), gamma.inv(c.g), gamma.inv(c.b), c.a);
}
}
#endif

View file

@ -29,7 +29,6 @@ namespace agg
void rewind(unsigned) {}
unsigned vertex(double*, double*) { return path_cmd_stop; }
unsigned type() const { return 0; }
};
@ -50,9 +49,6 @@ namespace agg
m_source(&source),
m_status(initial)
{}
conv_adaptor_vcgen(conv_adaptor_vcgen<VertexSource, Generator, Markers> &&) = default;
void attach(VertexSource& source) { m_source = &source; }
Generator& generator() { return m_generator; }
@ -68,7 +64,6 @@ namespace agg
}
unsigned vertex(double* x, double* y);
unsigned type() const { return m_source->type(); }
private:
// Prohibit copying

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -33,11 +33,10 @@ namespace agg
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
unsigned type() const { return m_source->type(); }
private:
conv_adaptor_vpgen(const conv_adaptor_vpgen<VertexSource, VPGen>&);
const conv_adaptor_vpgen<VertexSource, VPGen>&
const conv_adaptor_vpgen<VertexSource, VPGen>&
operator = (const conv_adaptor_vpgen<VertexSource, VPGen>&);
VertexSource* m_source;
@ -52,8 +51,8 @@ namespace agg
//------------------------------------------------------------------------
template<class VertexSource, class VPGen>
void conv_adaptor_vpgen<VertexSource, VPGen>::rewind(unsigned path_id)
{
void conv_adaptor_vpgen<VertexSource, VPGen>::rewind(unsigned path_id)
{
m_source->rewind(path_id);
m_vpgen.reset();
m_start_x = 0;
@ -84,7 +83,7 @@ namespace agg
if(m_vertices < 0)
{
if(m_vertices < -1)
if(m_vertices < -1)
{
m_vertices = 0;
return path_cmd_stop;
@ -98,13 +97,12 @@ namespace agg
cmd = m_source->vertex(&tx, &ty);
if(is_vertex(cmd))
{
if(is_move_to(cmd))
if(is_move_to(cmd))
{
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 | path_flags_close;
m_start_x = tx;
m_start_y = ty;
m_vertices = -1;
@ -115,7 +113,7 @@ namespace agg
m_start_y = ty;
m_vertices = 1;
}
else
else
{
m_vpgen.line_to(tx, ty);
++m_vertices;
@ -142,8 +140,7 @@ namespace agg
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 | path_flags_close;
m_vertices = -2;
continue;
}
@ -159,3 +156,4 @@ namespace agg
#endif

View file

@ -42,16 +42,15 @@ namespace agg
conv_clip_polygon(VertexSource& vs) :
conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon>(vs) {}
void clip_box(double _x1, double _y1, double _x2, double _y2)
void clip_box(double x1, double y1, double x2, double y2)
{
base_type::vpgen().clip_box(_x1, _y1, _x2, _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(); }
double x2() const { return base_type::vpgen().x2(); }
double y2() const { return base_type::vpgen().y2(); }
unsigned type() const { return base_type::type(); }
private:
conv_clip_polygon(const conv_clip_polygon<VertexSource>&);

View file

@ -42,16 +42,15 @@ namespace agg
conv_clip_polyline(VertexSource& vs) :
conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline>(vs) {}
void clip_box(double _x1, double _y1, double _x2, double _y2)
void clip_box(double x1, double y1, double x2, double y2)
{
base_type::vpgen().clip_box(_x1, _y1, _x2, _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(); }
double x2() const { return base_type::vpgen().x2(); }
double y2() const { return base_type::vpgen().y2(); }
unsigned type() const { return base_type::type(); }
private:
conv_clip_polyline(const conv_clip_polyline<VertexSource>&);

View file

@ -62,9 +62,6 @@ namespace agg
explicit conv_curve(VertexSource& source) :
m_source(&source), m_last_x(0.0), m_last_y(0.0) {}
conv_curve(self_type &&) = default;
void attach(VertexSource& source) { m_source = &source; }
void approximation_method(curve_approximation_method_e v)
@ -157,10 +154,10 @@ namespace agg
return path_cmd_line_to;
}
double ct2_x=0;
double ct2_y=0;
double end_x=0;
double end_y=0;
double ct2_x;
double ct2_y;
double end_x;
double end_y;
unsigned cmd = m_source->vertex(x, y);
switch(cmd)

View file

@ -24,7 +24,7 @@
#ifndef AGG_CONV_GPC_INCLUDED
#define AGG_CONV_GPC_INCLUDED
#include <cmath>
#include <math.h>
#include "agg_basics.h"
#include "agg_array.h"

View file

@ -117,7 +117,7 @@ namespace agg
}
++m_num_markers;
m_mtx = m_transform;
m_mtx *= trans_affine_rotation(std::atan2(y2 - y1, x2 - x1));
m_mtx *= trans_affine_rotation(atan2(y2 - y1, x2 - x1));
m_mtx *= trans_affine_translation(x1, y1);
m_marker_shapes->rewind(m_marker - 1);
m_status = polygon;

View file

@ -0,0 +1,80 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Smooth polygon generator
//
//----------------------------------------------------------------------------
#ifndef AGG_CONV_SMOOTH_POLY1_INCLUDED
#define AGG_CONV_SMOOTH_POLY1_INCLUDED
#include "agg_basics.h"
#include "agg_vcgen_smooth_poly1.h"
#include "agg_conv_adaptor_vcgen.h"
#include "agg_conv_curve.h"
namespace agg
{
//-------------------------------------------------------conv_smooth_poly1
template<class VertexSource>
struct conv_smooth_poly1 :
public conv_adaptor_vcgen<VertexSource, vcgen_smooth_poly1>
{
typedef conv_adaptor_vcgen<VertexSource, vcgen_smooth_poly1> base_type;
conv_smooth_poly1(VertexSource& vs) :
conv_adaptor_vcgen<VertexSource, vcgen_smooth_poly1>(vs)
{
}
void smooth_value(double v) { base_type::generator().smooth_value(v); }
double smooth_value() const { return base_type::generator().smooth_value(); }
private:
conv_smooth_poly1(const conv_smooth_poly1<VertexSource>&);
const conv_smooth_poly1<VertexSource>&
operator = (const conv_smooth_poly1<VertexSource>&);
};
//-------------------------------------------------conv_smooth_poly1_curve
template<class VertexSource>
struct conv_smooth_poly1_curve :
public conv_curve<conv_smooth_poly1<VertexSource> >
{
conv_smooth_poly1_curve(VertexSource& vs) :
conv_curve<conv_smooth_poly1<VertexSource> >(m_smooth),
m_smooth(vs)
{
}
void smooth_value(double v) { m_smooth.generator().smooth_value(v); }
double smooth_value() const { return m_smooth.generator().smooth_value(); }
private:
conv_smooth_poly1_curve(const conv_smooth_poly1_curve<VertexSource>&);
const conv_smooth_poly1_curve<VertexSource>&
operator = (const conv_smooth_poly1_curve<VertexSource>&);
conv_smooth_poly1<VertexSource> m_smooth;
};
}
#endif

View file

@ -29,11 +29,10 @@ namespace agg
template<class VertexSource, class Transformer=trans_affine> class conv_transform
{
public:
conv_transform(VertexSource& source, Transformer& tr) :
conv_transform(VertexSource& source, const 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);
@ -49,13 +48,11 @@ namespace agg
return cmd;
}
void transformer(Transformer& tr)
void transformer(const Transformer& tr)
{
m_trans = &tr;
}
unsigned type() const { return m_source->type(); }
private:
conv_transform(const conv_transform<VertexSource>&);
const conv_transform<VertexSource>&

View file

@ -19,8 +19,6 @@
#include "agg_array.h"
#include <mapnik/config.hpp>
namespace agg
{
@ -34,7 +32,7 @@ namespace agg
};
//--------------------------------------------------------------curve3_inc
class MAPNIK_DECL curve3_inc
class curve3_inc
{
public:
curve3_inc() :
@ -93,7 +91,7 @@ namespace agg
//-------------------------------------------------------------curve3_div
class MAPNIK_DECL curve3_div
class curve3_div
{
public:
curve3_div() :
@ -166,7 +164,7 @@ namespace agg
//-------------------------------------------------------------curve4_points
struct MAPNIK_DECL curve4_points
struct curve4_points
{
double cp[8];
curve4_points() {}
@ -193,7 +191,7 @@ namespace agg
//-------------------------------------------------------------curve4_inc
class MAPNIK_DECL curve4_inc
class curve4_inc
{
public:
curve4_inc() :
@ -373,7 +371,7 @@ namespace agg
//-------------------------------------------------------------curve4_div
class MAPNIK_DECL curve4_div
class curve4_div
{
public:
curve4_div() :
@ -473,7 +471,7 @@ namespace agg
//-----------------------------------------------------------------curve3
class MAPNIK_DECL curve3
class curve3
{
public:
curve3() : m_approximation_method(curve_div) {}
@ -578,7 +576,7 @@ namespace agg
//-----------------------------------------------------------------curve4
class MAPNIK_DECL curve4
class curve4
{
public:
curve4() : m_approximation_method(curve_div) {}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -20,16 +20,15 @@
#ifndef AGG_DDA_LINE_INCLUDED
#define AGG_DDA_LINE_INCLUDED
#include <cstdlib>
#include <stdlib.h>
#include "agg_basics.h"
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() {}
@ -37,7 +36,7 @@ namespace agg
//--------------------------------------------------------------------
dda_line_interpolator(int y1, int y2, unsigned count) :
m_y(y1),
m_inc(((y2 - y1) * factor) / static_cast<int>(count)),
m_inc(((y2 - y1) << FractionShift) / int(count)),
m_dy(0)
{
}
@ -68,9 +67,10 @@ namespace agg
//--------------------------------------------------------------------
int y() const { return m_y + (m_dy >> (FractionShift - YShift)); }
int y() const { return m_y + (m_dy >> (FractionShift-YShift)); }
int dy() const { return m_dy; }
private:
int m_y;
int m_inc;
@ -233,16 +233,16 @@ namespace agg
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_ver(abs(m_x2_lr - m_x1_lr) < abs(m_y2_lr - m_y1_lr)),
m_len(m_ver ? abs(m_y2_lr - m_y1_lr) :
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_interpolator(m_ver ? x1 : y1,
m_ver ? x2 : y2,
m_len)
{
}
//--------------------------------------------------------------------
bool is_ver() const { return m_ver; }
unsigned len() const { return m_len; }

View file

@ -21,7 +21,7 @@
#define AGG_ELLIPSE_INCLUDED
#include "agg_basics.h"
#include <cmath>
#include <math.h>
namespace agg
{
@ -48,7 +48,6 @@ namespace agg
void approximation_scale(double scale);
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
unsigned num_steps() { return m_num; }
private:
void calc_num_steps();
@ -87,8 +86,8 @@ namespace agg
//------------------------------------------------------------------------
inline void ellipse::calc_num_steps()
{
double ra = (std::fabs(m_rx) + std::fabs(m_ry)) / 2;
double da = std::acos(ra / (ra + 0.125 / m_scale)) * 2;
double ra = (fabs(m_rx) + fabs(m_ry)) / 2;
double da = acos(ra / (ra + 0.125 / m_scale)) * 2;
m_num = uround(2*pi / da);
}
@ -109,8 +108,8 @@ namespace agg
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;
*x = m_x + std::cos(angle) * m_rx;
*y = m_y + std::sin(angle) * m_ry;
*x = m_x + cos(angle) * m_rx;
*y = m_y + sin(angle) * m_ry;
m_step++;
return ((m_step == 1) ? path_cmd_move_to : path_cmd_line_to);
}

View file

@ -16,7 +16,7 @@
#ifndef AGG_FONT_CACHE_MANAGER_INCLUDED
#define AGG_FONT_CACHE_MANAGER_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_array.h"
namespace agg

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -16,7 +16,7 @@
#ifndef AGG_GAMMA_FUNCTIONS_INCLUDED
#define AGG_GAMMA_FUNCTIONS_INCLUDED
#include <cmath>
#include <math.h>
#include "agg_basics.h"
namespace agg
@ -40,7 +40,6 @@ namespace agg
double operator() (double x) const
{
if (x == 0.0) return 0.0;
return pow(x, m_gamma);
}
@ -86,11 +85,7 @@ namespace agg
{
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;
return (x - m_start) / delta;
return (x - m_start) / (m_end - m_start);
}
private:
@ -120,15 +115,9 @@ namespace agg
double m_mul;
};
inline double sRGB_to_linear(double x)
{
return (x <= 0.04045) ? (x / 12.92) : pow((x + 0.055) / (1.055), 2.4);
}
inline double linear_to_sRGB(double x)
{
return (x <= 0.0031308) ? (x * 12.92) : (1.055 * pow(x, 1 / 2.4) - 0.055);
}
}
#endif

121
agg/include/agg_gamma_lut.h Normal file
View file

@ -0,0 +1,121 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
#ifndef AGG_GAMMA_LUT_INCLUDED
#define AGG_GAMMA_LUT_INCLUDED
#include <math.h>
#include "agg_basics.h"
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 hi_res_scale_e
{
hi_res_shift = HiResShift,
hi_res_size = 1 << hi_res_shift,
hi_res_mask = hi_res_size - 1
};
~gamma_lut()
{
pod_allocator<LoResT>::deallocate(m_inv_gamma, hi_res_size);
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))
{
unsigned i;
for(i = 0; i < gamma_size; i++)
{
m_dir_gamma[i] = HiResT(i << (hi_res_shift - gamma_shift));
}
for(i = 0; i < hi_res_size; i++)
{
m_inv_gamma[i] = LoResT(i >> (hi_res_shift - gamma_shift));
}
}
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);
}
void gamma(double g)
{
m_gamma = g;
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));
}
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));
}
}
double gamma() const
{
return m_gamma;
}
HiResT dir(LoResT v) const
{
return m_dir_gamma[unsigned(v)];
}
LoResT inv(HiResT v) const
{
return m_inv_gamma[unsigned(v)];
}
private:
gamma_lut(const self_type&);
const self_type& operator = (const self_type&);
double m_gamma;
HiResT* m_dir_gamma;
LoResT* m_inv_gamma;
};
}
#endif

View file

@ -16,7 +16,7 @@
#ifndef AGG_GLYPH_RASTER_BIN_INCLUDED
#define AGG_GLYPH_RASTER_BIN_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_basics.h"
namespace agg

View file

@ -137,7 +137,7 @@ namespace agg
//--------------------------------------------------------------------
void remove_all();
void add_color(double offset, const color_type& color);
bool build_lut();
void build_lut();
// Size-index Interface. This class can be used directly as the
// ColorF in span_gradient. All it needs is two access methods
@ -202,7 +202,7 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S>
bool gradient_lut<T,S>::build_lut()
void gradient_lut<T,S>::build_lut()
{
quick_sort(m_color_profile, offset_less);
m_color_profile.cut_at(remove_duplicates(m_color_profile, offset_equal));
@ -210,7 +210,7 @@ namespace agg
{
unsigned i;
unsigned start = uround(m_color_profile[0].offset * color_lut_size);
unsigned end = 0;
unsigned end;
color_type c = m_color_profile[0].color;
for(i = 0; i < start; i++)
{
@ -234,9 +234,7 @@ namespace agg
{
m_color_lut[end] = c;
}
return true;
}
return false;
}
}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -32,8 +32,8 @@ namespace agg
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) :
explicit image_accessor_clip(const pixfmt_type& pixf,
const color_type& bk) :
m_pixf(&pixf)
{
pixfmt_type::make_pix(m_bk_buf, bk);
@ -85,7 +85,7 @@ namespace agg
{
++m_y;
m_x = m_x0;
if(m_pix_ptr &&
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);
@ -115,8 +115,8 @@ namespace agg
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)
@ -162,8 +162,8 @@ namespace agg
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)
@ -174,8 +174,8 @@ namespace agg
private:
AGG_INLINE const int8u* pixel() const
{
int x = m_x;
int y = m_y;
register int x = m_x;
register 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;
@ -189,7 +189,7 @@ namespace agg
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())
x >= 0 && x+len <= (int)m_pixf->width())
{
return m_pix_ptr = m_pixf->pix_ptr(x, y);
}
@ -208,7 +208,7 @@ namespace agg
{
++m_y;
m_x = m_x0;
if(m_pix_ptr &&
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);
@ -238,9 +238,9 @@ namespace agg
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()),
explicit image_accessor_wrap(const pixfmt_type& pixf) :
m_pixf(&pixf),
m_wrap_x(pixf.width()),
m_wrap_y(pixf.height())
{}
@ -284,15 +284,15 @@ namespace agg
{
public:
wrap_mode_repeat() {}
wrap_mode_repeat(unsigned size) :
m_size(size),
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;
{
return m_value = (unsigned(v) + m_add) % m_size;
}
AGG_INLINE unsigned operator++ ()
@ -320,7 +320,7 @@ namespace agg
m_mask >>= 1;
}
AGG_INLINE unsigned operator() (int v)
{
{
return m_value = unsigned(v) & m_mask;
}
AGG_INLINE unsigned operator++ ()
@ -347,8 +347,8 @@ namespace agg
m_value(0)
{}
AGG_INLINE unsigned operator() (int v)
{
AGG_INLINE unsigned operator() (int v)
{
if(m_mask) return m_value = unsigned(v) & m_mask;
return m_value = (unsigned(v) + m_add) % m_size;
}
@ -372,15 +372,15 @@ namespace agg
{
public:
wrap_mode_reflect() {}
wrap_mode_reflect(unsigned size) :
m_size(size),
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;
return m_value;
@ -411,14 +411,14 @@ namespace agg
{
m_mask = 1;
m_size = 1;
while(m_mask < size)
while(m_mask < size)
{
m_mask = (m_mask << 1) | 1;
m_size <<= 1;
}
}
AGG_INLINE unsigned operator() (int v)
{
{
m_value = unsigned(v) & m_mask;
if(m_value >= m_size) return m_mask - m_value;
return m_value;
@ -451,12 +451,12 @@ namespace agg
m_value(0)
{}
AGG_INLINE unsigned operator() (int v)
{
m_value = m_mask ? unsigned(v) & m_mask :
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;
return m_value;
return m_value;
}
AGG_INLINE unsigned operator++ ()
{

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -22,25 +22,24 @@
#include "agg_array.h"
#include "agg_math.h"
#include <cstdint>
namespace agg
{
// See Implementation agg_image_filters.cpp
// See Implementation agg_image_filters.cpp
enum image_filter_scale_e
{
image_filter_shift = 14, //----image_filter_shift
image_filter_scale = 1 << image_filter_shift, //----image_filter_scale
image_filter_mask = image_filter_scale - 1 //----image_filter_mask
image_filter_scale = 1 << image_filter_shift, //----image_filter_scale
image_filter_mask = image_filter_scale - 1 //----image_filter_mask
};
enum image_subpixel_scale_e
{
image_subpixel_shift = 8, //----image_subpixel_shift
image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale
image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask
image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale
image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask
};
@ -59,13 +58,12 @@ namespace agg
{
double x = double(i) / double(image_subpixel_scale);
double y = filter.calc_weight(x);
m_weight_array[pivot + i] =
m_weight_array[pivot - i] =
static_cast<std::int16_t>(iround(y * static_cast<double>(image_filter_scale)));
m_weight_array[pivot + i] =
m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);
}
unsigned end = (diameter() << image_subpixel_shift) - 1;
m_weight_array[0] = m_weight_array[end];
if(normalization)
if(normalization)
{
normalize();
}
@ -73,7 +71,7 @@ namespace agg
image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {}
template<class FilterF> image_filter_lut(const FilterF& filter,
template<class FilterF> image_filter_lut(const FilterF& filter,
bool normalization=true)
{
calculate(filter, normalization);
@ -82,7 +80,7 @@ namespace agg
double radius() const { return m_radius; }
unsigned diameter() const { return m_diameter; }
int start() const { return m_start; }
std::int16_t const* weight_array() const { return &m_weight_array[0]; }
const int16* weight_array() const { return &m_weight_array[0]; }
void normalize();
private:
@ -93,7 +91,7 @@ namespace agg
double m_radius;
unsigned m_diameter;
int m_start;
pod_array<std::int16_t> m_weight_array;
pod_array<int16> m_weight_array;
};
@ -128,7 +126,7 @@ namespace agg
static double radius() { return 1.0; }
static double calc_weight(double x)
{
return 0.5 + 0.5 * std::cos(pi * x);
return 0.5 + 0.5 * cos(pi * x);
}
};
@ -139,7 +137,7 @@ namespace agg
static double radius() { return 1.0; }
static double calc_weight(double x)
{
return 0.54 + 0.46 * std::cos(pi * x);
return 0.54 + 0.46 * cos(pi * x);
}
};
@ -152,7 +150,7 @@ namespace agg
return (2.0 * x - 3.0) * x * x + 1.0;
}
};
//------------------------------------------------image_filter_quadric
struct image_filter_quadric
{
@ -179,7 +177,7 @@ namespace agg
static double calc_weight(double x)
{
return
(1.0/6.0) *
(1.0/6.0) *
(pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1));
}
};
@ -213,7 +211,7 @@ namespace agg
sum = 1.;
y = x * x / 4.;
t = y;
for(i = 2; t > epsilon; i++)
{
sum += t;
@ -300,7 +298,7 @@ namespace agg
struct image_filter_gaussian
{
static double radius() { return 2.0; }
static double calc_weight(double x)
static double calc_weight(double x)
{
return exp(-2.0 * x * x) * sqrt(2.0 / pi);
}
@ -310,7 +308,7 @@ namespace agg
//------------------------------------------------image_filter_bessel
struct image_filter_bessel
{
static double radius() { return 3.2383; }
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);
@ -328,7 +326,7 @@ namespace agg
{
if(x == 0.0) return 1.0;
x *= pi;
return std::sin(x) / x;
return sin(x) / x;
}
private:
double m_radius;
@ -347,7 +345,7 @@ namespace agg
if(x > m_radius) return 0.0;
x *= pi;
double xr = x / m_radius;
return (std::sin(x) / x) * (std::sin(xr) / xr);
return (sin(x) / x) * (sin(xr) / xr);
}
private:
double m_radius;
@ -366,7 +364,7 @@ namespace agg
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));
return (sin(x) / x) * (0.42 + 0.5*cos(xr) + 0.08*cos(2*xr));
}
private:
double m_radius;

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -15,13 +15,13 @@
#ifndef AGG_LINE_AA_BASICS_INCLUDED
#define AGG_LINE_AA_BASICS_INCLUDED
#include <cstdlib>
#include <stdlib.h>
#include "agg_basics.h"
namespace agg
{
// See Implementation agg_line_aa_basics.cpp
// See Implementation agg_line_aa_basics.cpp
//-------------------------------------------------------------------------
enum line_subpixel_scale_e
@ -37,26 +37,26 @@ namespace agg
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
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
};
//------------------------------------------------------------------line_mr
AGG_INLINE int line_mr(int x)
{
return x >> (line_subpixel_shift - static_cast<line_subpixel_scale_e>(line_mr_subpixel_shift));
AGG_INLINE int line_mr(int x)
{
return x >> (line_subpixel_shift - line_mr_subpixel_shift);
}
//-------------------------------------------------------------------line_hr
AGG_INLINE int line_hr(int x)
{
return x << (line_subpixel_shift - static_cast<line_subpixel_scale_e>(line_mr_subpixel_shift));
AGG_INLINE int line_hr(int x)
{
return x << (line_subpixel_shift - line_mr_subpixel_shift);
}
//---------------------------------------------------------------line_dbl_hr
AGG_INLINE int line_dbl_hr(int x)
{
return x * line_subpixel_scale;
AGG_INLINE int line_dbl_hr(int x)
{
return x << line_subpixel_shift;
}
//---------------------------------------------------------------line_coord
@ -64,7 +64,7 @@ namespace agg
{
AGG_INLINE static int conv(double x)
{
return iround(x * static_cast<double>(line_subpixel_scale));
return iround(x * line_subpixel_scale);
}
};
@ -73,7 +73,7 @@ namespace agg
{
AGG_INLINE static int conv(double x)
{
return saturation<line_max_coord>::iround(x * static_cast<double>(line_subpixel_scale));
return saturation<line_max_coord>::iround(x * line_subpixel_scale);
}
};
@ -83,9 +83,9 @@ namespace agg
//---------------------------------------------------------------------
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_)),
x1(x1_), y1(y1_), x2(x2_), y2(y2_),
dx(abs(x2_ - x1_)),
dy(abs(y2_ - y1_)),
sx((x2_ > x1_) ? 1 : -1),
sy((y2_ > y1_) ? 1 : -1),
vertical(dy >= dx),
@ -124,16 +124,16 @@ namespace agg
lp1.x2 = xmid;
lp1.y2 = ymid;
lp1.len = len2;
lp1.dx = std::abs(lp1.x2 - lp1.x1);
lp1.dy = std::abs(lp1.y2 - lp1.y1);
lp1.dx = abs(lp1.x2 - lp1.x1);
lp1.dy = abs(lp1.y2 - lp1.y1);
lp2.x1 = xmid;
lp2.y1 = ymid;
lp2.len = len2;
lp2.dx = std::abs(lp2.x2 - lp2.x1);
lp2.dy = std::abs(lp2.y2 - lp2.y1);
lp2.dx = abs(lp2.x2 - lp2.x1);
lp2.dy = abs(lp2.y2 - lp2.y1);
}
//---------------------------------------------------------------------
int x1, y1, x2, y2, dx, dy, sx, sy;
bool vertical;
@ -148,19 +148,19 @@ namespace agg
// See Implementation agg_line_aa_basics.cpp
// See Implementation agg_line_aa_basics.cpp
//----------------------------------------------------------------bisectrix
void bisectrix(const line_parameters& l1,
const line_parameters& l2,
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,
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) -
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)
{
@ -171,10 +171,10 @@ namespace agg
//---------------------------------------------fix_degenerate_bisectrix_end
void inline fix_degenerate_bisectrix_end(const line_parameters& lp,
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) -
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)
{

View file

@ -19,7 +19,7 @@
#ifndef AGG_MATH_INCLUDED
#define AGG_MATH_INCLUDED
#include <cmath>
#include <math.h>
#include "agg_basics.h"
namespace agg
@ -27,7 +27,7 @@ namespace agg
//------------------------------------------------------vertex_dist_epsilon
// Coinciding points maximal distance (Epsilon)
const double vertex_dist_epsilon = 1e-5;
const double vertex_dist_epsilon = 1e-14;
//-----------------------------------------------------intersection_epsilon
// See calc_intersection
@ -94,7 +94,7 @@ namespace agg
if(dx == 0 && dy == 0)
{
return 0;
return 0;
}
double pdx = x - x1;
@ -111,12 +111,12 @@ namespace agg
{
if(u <= 0)
{
return calc_sq_distance(x, y, x1, y1);
return calc_sq_distance(x, y, x1, y1);
}
else
if(u >= 1)
{
return calc_sq_distance(x, y, x2, y2);
return calc_sq_distance(x, y, x2, y2);
}
return calc_sq_distance(x, y, x1 + u * (x2 - x1), y1 + u * (y2 - y1));
}
@ -139,7 +139,7 @@ namespace agg
{
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(fabs(den) < intersection_epsilon) return false;
double r = num / den;
*x = ax + r * (bx-ax);
*y = ay + r * (by-ay);
@ -165,7 +165,7 @@ namespace agg
// in terms of boundary conditions.
//--------------------
//double den = (x2-x1) * (y4-y3) - (y2-y1) * (x4-x3);
//if(std::fabs(den) < intersection_epsilon) return false;
//if(fabs(den) < intersection_epsilon) return false;
//double nom1 = (x4-x3) * (y1-y3) - (y4-y3) * (x1-x3);
//double nom2 = (x2-x1) * (y1-y3) - (y2-y1) * (x1-x3);
//double ua = nom1 / den;
@ -200,7 +200,7 @@ namespace agg
double dx3=0.0;
double dy3=0.0;
double loc = cross_product(x1, y1, x2, y2, x3, y3);
if(std::fabs(loc) > intersection_epsilon)
if(fabs(loc) > intersection_epsilon)
{
if(cross_product(x1, y1, x2, y2, x3, y3) > 0.0)
{
@ -370,7 +370,7 @@ namespace agg
}
double d = 1E-6;
double b = 0;
if(std::fabs(x) <= d)
if(fabs(x) <= d)
{
if(n != 0) return 0;
return 1;
@ -378,11 +378,11 @@ namespace agg
double b1 = 0; // b1 is the value from the previous iteration
// Set up a starting order for recurrence
int m1 = (int)fabs(x) + 6;
if(std::fabs(x) > 5)
if(fabs(x) > 5)
{
m1 = (int)(std::fabs(1.4 * x + 60 / x));
m1 = (int)(fabs(1.4 * x + 60 / x));
}
int m2 = (int)(n + 2 + std::fabs(x) / 4);
int m2 = (int)(n + 2 + fabs(x) / 4);
if (m1 > m2)
{
m2 = m1;
@ -422,7 +422,7 @@ namespace agg
}
c4 += c6;
b /= c4;
if(std::fabs(b - b1) < d)
if(fabs(b - b1) < d)
{
return b;
}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -81,15 +81,15 @@ namespace agg
double approximation_scale() const { return m_approx_scale; }
void calc_cap(VertexConsumer& vc,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v0,
const vertex_dist& v1,
double len);
void calc_join(VertexConsumer& vc,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v2,
double len1,
double len1,
double len2);
private:
@ -99,15 +99,15 @@ namespace agg
}
void calc_arc(VertexConsumer& vc,
double x, double y,
double dx1, double dy1,
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& v0,
const vertex_dist& v1,
const vertex_dist& v2,
double dx1, double dy1,
double dx1, double dy1,
double dx2, double dy2,
line_join_e lj,
double mlimit,
@ -142,8 +142,8 @@ namespace agg
//-----------------------------------------------------------------------
template<class VC> void math_stroke<VC>::width(double w)
{
m_width = w * 0.5;
{
m_width = w * 0.5;
if(m_width < 0)
{
m_width_abs = -m_width;
@ -159,23 +159,23 @@ namespace agg
//-----------------------------------------------------------------------
template<class VC> void math_stroke<VC>::miter_limit_theta(double t)
{
m_miter_limit = 1.0 / std::sin(t * 0.5) ;
{
m_miter_limit = 1.0 / sin(t * 0.5) ;
}
//-----------------------------------------------------------------------
template<class VC>
template<class VC>
void math_stroke<VC>::calc_arc(VC& vc,
double x, double y,
double dx1, double dy1,
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);
double a1 = atan2(dy1 * m_width_sign, dx1 * m_width_sign);
double a2 = atan2(dy2 * m_width_sign, dx2 * m_width_sign);
double da = a1 - a2;
int i, n;
da = std::acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
add_vertex(vc, x + dx1, y + dy1);
if(m_width_sign > 0)
@ -186,7 +186,7 @@ namespace agg
a1 += da;
for(i = 0; i < n; i++)
{
add_vertex(vc, x + std::cos(a1) * m_width, y + std::sin(a1) * m_width);
add_vertex(vc, x + cos(a1) * m_width, y + sin(a1) * m_width);
a1 += da;
}
}
@ -198,7 +198,7 @@ namespace agg
a1 -= da;
for(i = 0; i < n; i++)
{
add_vertex(vc, x + std::cos(a1) * m_width, y + std::sin(a1) * m_width);
add_vertex(vc, x + cos(a1) * m_width, y + sin(a1) * m_width);
a1 -= da;
}
}
@ -206,12 +206,12 @@ namespace agg
}
//-----------------------------------------------------------------------
template<class VC>
template<class VC>
void math_stroke<VC>::calc_miter(VC& vc,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v2,
double dx1, double dy1,
double dx1, double dy1,
double dx2, double dy2,
line_join_e lj,
double mlimit,
@ -245,8 +245,8 @@ namespace agg
else
{
// Calculation of the intersection failed, most probably
// the three points lie one straight line.
// First check if v0 and v2 lie on the opposite sides of vector:
// the three points lie one straight line.
// First check if v0 and v2 lie on the opposite sides of vector:
// (v1.x, v1.y) -> (v1.x+dx1, v1.y-dy1), that is, the perpendicular
// to the line determined by vertices v0 and v1.
// This condition determines whether the next line segments continues
@ -254,10 +254,10 @@ namespace agg
//----------------
double x2 = v1.x + dx1;
double y2 = v1.y - dy1;
if((cross_product(v0.x, v0.y, v1.x, v1.y, x2, y2) < 0.0) ==
if((cross_product(v0.x, v0.y, v1.x, v1.y, x2, y2) < 0.0) ==
(cross_product(v1.x, v1.y, v2.x, v2.y, x2, y2) < 0.0))
{
// This case means that the next segment continues
// This case means that the next segment continues
// the previous one (straight line)
//-----------------
add_vertex(vc, v1.x + dx1, v1.y - dy1);
@ -272,7 +272,7 @@ namespace agg
switch(lj)
{
case miter_join_revert:
// For the compatibility with SVG, PDF, etc,
// For the compatibility with SVG, PDF, etc,
// we use a simple bevel join instead of
// "smart" bevel
//-------------------
@ -290,9 +290,9 @@ namespace agg
if(intersection_failed)
{
mlimit *= m_width_sign;
add_vertex(vc, v1.x + dx1 + dy1 * mlimit,
add_vertex(vc, v1.x + dx1 + dy1 * mlimit,
v1.y - dy1 + dx1 * mlimit);
add_vertex(vc, v1.x + dx2 - dy2 * mlimit,
add_vertex(vc, v1.x + dx2 - dy2 * mlimit,
v1.y - dy2 - dx2 * mlimit);
}
else
@ -302,9 +302,9 @@ namespace agg
double x2 = v1.x + dx2;
double y2 = v1.y - dy2;
di = (lim - dbevel) / (di - dbevel);
add_vertex(vc, x1 + (xi - x1) * di,
add_vertex(vc, x1 + (xi - x1) * di,
y1 + (yi - y1) * di);
add_vertex(vc, x2 + (xi - x2) * di,
add_vertex(vc, x2 + (xi - x2) * di,
y2 + (yi - y2) * di);
}
break;
@ -313,10 +313,10 @@ namespace agg
}
//--------------------------------------------------------stroke_calc_cap
template<class VC>
template<class VC>
void math_stroke<VC>::calc_cap(VC& vc,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v0,
const vertex_dist& v1,
double len)
{
vc.remove_all();
@ -341,7 +341,7 @@ namespace agg
}
else
{
double da = std::acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
double da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
double a1;
int i;
int n = int(pi / da);
@ -350,23 +350,23 @@ namespace agg
add_vertex(vc, v0.x - dx1, v0.y + dy1);
if(m_width_sign > 0)
{
a1 = std::atan2(dy1, -dx1);
a1 = atan2(dy1, -dx1);
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 + cos(a1) * m_width,
v0.y + sin(a1) * m_width);
a1 += da;
}
}
else
{
a1 = std::atan2(-dy1, dx1);
a1 = atan2(-dy1, dx1);
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 + cos(a1) * m_width,
v0.y + sin(a1) * m_width);
a1 -= da;
}
}
@ -375,12 +375,12 @@ namespace agg
}
//-----------------------------------------------------------------------
template<class VC>
template<class VC>
void math_stroke<VC>::calc_join(VC& vc,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v0,
const vertex_dist& v1,
const vertex_dist& v2,
double len1,
double len1,
double len2)
{
double dx1 = m_width * (v1.y - v0.y) / len1;
@ -391,12 +391,12 @@ namespace agg
vc.remove_all();
double cp = cross_product(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y);
if (cp != 0 && (cp > 0) == (m_width > 0) && m_width_abs > 0)
if(cp != 0 && (cp > 0) == (m_width > 0))
{
// Inner join
//---------------
double limit = ((len1 < len2) ? len1 : len2) / m_width_abs;
if (limit < m_inner_miter_limit)
if(limit < m_inner_miter_limit)
{
limit = m_inner_miter_limit;
}
@ -410,8 +410,8 @@ namespace agg
case inner_miter:
calc_miter(vc,
v0, v1, v2, dx1, dy1, dx2, dy2,
miter_join_revert,
v0, v1, v2, dx1, dy1, dx2, dy2,
miter_join_revert,
limit, 0);
break;
@ -421,8 +421,8 @@ namespace agg
if(cp < len1 * len1 && cp < len2 * len2)
{
calc_miter(vc,
v0, v1, v2, dx1, dy1, dx2, dy2,
miter_join_revert,
v0, v1, v2, dx1, dy1, dx2, dy2,
miter_join_revert,
limit, 0);
}
else
@ -450,7 +450,7 @@ namespace agg
// Outer join
//---------------
// Calculate the distance between v1 and
// Calculate the distance between v1 and
// the central point of the bevel line segment
//---------------
double dx = (dx1 + dx2) / 2;
@ -459,21 +459,21 @@ namespace agg
if(m_line_join == round_join || m_line_join == bevel_join)
{
// This is an optimization that reduces the number of points
// This is an optimization that reduces the number of points
// in cases of almost collinear segments. If there's no
// visible difference between bevel and miter joins we'd rather
// use miter join because it adds only one point instead of two.
// use miter join because it adds only one point instead of two.
//
// Here we calculate the middle point between the bevel points
// and then, the distance between v1 and this middle point.
// At outer joins this distance always less than stroke width,
// Here we calculate the middle point between the bevel points
// and then, the distance between v1 and this middle point.
// At outer joins this distance always less than stroke width,
// because it's actually the height of an isosceles triangle of
// v1 and its two bevel points. If the difference between this
// width and this value is small (no visible bevel) we can
// add just one point.
// width and this value is small (no visible bevel) we can
// add just one point.
//
// The constant in the expression makes the result approximately
// the same as in round joins and caps. You can safely comment
// The constant in the expression makes the result approximately
// the same as in round joins and caps. You can safely comment
// out this entire "if".
//-------------------
if(m_approx_scale * (m_width_abs - dbevel) < m_width_eps)
@ -499,9 +499,9 @@ namespace agg
case miter_join:
case miter_join_revert:
case miter_join_round:
calc_miter(vc,
v0, v1, v2, dx1, dy1, dx2, dy2,
m_line_join,
calc_miter(vc,
v0, v1, v2, dx1, dy1, dx2, dy2,
m_line_join,
m_miter_limit,
dbevel);
break;

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -16,8 +16,8 @@
#ifndef AGG_PATH_STORAGE_INCLUDED
#define AGG_PATH_STORAGE_INCLUDED
#include <cstring>
#include <cmath>
#include <string.h>
#include <math.h>
#include "agg_math.h"
#include "agg_array.h"
#include "agg_bezier_arc.h"
@ -92,7 +92,7 @@ namespace agg
{
pod_allocator<T>::deallocate(
*coord_blk,
block_size * 2 +
block_size * 2 +
block_size / (sizeof(T) / sizeof(unsigned char)));
--coord_blk;
}
@ -137,7 +137,7 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S, unsigned P>
const vertex_block_storage<T,S,P>&
const vertex_block_storage<T,S,P>&
vertex_block_storage<T,S,P>::operator = (const vertex_block_storage<T,S,P>& v)
{
remove_all();
@ -148,7 +148,7 @@ namespace agg
unsigned cmd = v.vertex(i, &x, &y);
add_vertex(x, y, cmd);
}
return *this;
return *this;
}
//------------------------------------------------------------------------
@ -160,7 +160,7 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::add_vertex(double x, double y,
inline void vertex_block_storage<T,S,P>::add_vertex(double x, double y,
unsigned cmd)
{
T* coord_ptr = 0;
@ -172,7 +172,7 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx,
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);
@ -182,8 +182,8 @@ namespace agg
//------------------------------------------------------------------------
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,
unsigned cmd)
{
unsigned block = idx >> block_shift;
@ -196,7 +196,7 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::modify_command(unsigned idx,
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;
@ -277,7 +277,7 @@ namespace agg
//------------------------------------------------------------------------
template<class T, unsigned S, unsigned P>
inline unsigned vertex_block_storage<T,S,P>::vertex(unsigned idx,
inline unsigned vertex_block_storage<T,S,P>::vertex(unsigned idx,
double* x, double* y) const
{
unsigned nb = idx >> block_shift;
@ -298,22 +298,22 @@ namespace agg
template<class T, unsigned S, unsigned P>
void vertex_block_storage<T,S,P>::allocate_block(unsigned nb)
{
if(nb >= m_max_blocks)
if(nb >= m_max_blocks)
{
T** new_coords =
T** new_coords =
pod_allocator<T*>::allocate((m_max_blocks + block_pool) * 2);
unsigned char** new_cmds =
unsigned char** new_cmds =
(unsigned char**)(new_coords + m_max_blocks + block_pool);
if(m_coord_blocks)
{
memcpy(new_coords,
m_coord_blocks,
memcpy(new_coords,
m_coord_blocks,
m_max_blocks * sizeof(T*));
memcpy(new_cmds,
m_cmd_blocks,
memcpy(new_cmds,
m_cmd_blocks,
m_max_blocks * sizeof(unsigned char*));
pod_allocator<T*>::deallocate(m_coord_blocks, m_max_blocks * 2);
@ -322,11 +322,11 @@ namespace agg
m_cmd_blocks = new_cmds;
m_max_blocks += block_pool;
}
m_coord_blocks[nb] =
pod_allocator<T>::allocate(block_size * 2 +
m_coord_blocks[nb] =
pod_allocator<T>::allocate(block_size * 2 +
block_size / (sizeof(T) / sizeof(unsigned char)));
m_cmd_blocks[nb] =
m_cmd_blocks[nb] =
(unsigned char*)(m_coord_blocks[nb] + block_size * 2);
m_total_blocks++;
@ -354,8 +354,8 @@ namespace agg
public:
typedef T value_type;
poly_plain_adaptor() :
m_data(0),
poly_plain_adaptor() :
m_data(0),
m_ptr(0),
m_end(0),
m_closed(false),
@ -363,7 +363,7 @@ namespace agg
{}
poly_plain_adaptor(const T* data, unsigned num_points, bool closed) :
m_data(data),
m_data(data),
m_ptr(data),
m_end(data + num_points * 2),
m_closed(closed),
@ -398,8 +398,7 @@ namespace agg
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 | path_flags_close;
}
return path_cmd_stop;
}
@ -422,15 +421,15 @@ namespace agg
public:
typedef typename Container::value_type vertex_type;
poly_container_adaptor() :
m_container(0),
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_container(&data),
m_index(0),
m_closed(closed),
m_stop(false)
@ -464,8 +463,7 @@ namespace agg
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 | path_flags_close;
}
return path_cmd_stop;
}
@ -485,15 +483,15 @@ namespace agg
public:
typedef typename Container::value_type vertex_type;
poly_container_reverse_adaptor() :
m_container(0),
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_container(&data),
m_index(-1),
m_closed(closed),
m_stop(false)
@ -527,8 +525,7 @@ namespace agg
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 | path_flags_close;
}
return path_cmd_stop;
}
@ -559,7 +556,7 @@ namespace agg
m_coord[2] = x2;
m_coord[3] = y2;
}
void init(double x1, double y1, double x2, double y2)
{
m_coord[0] = x1;
@ -597,10 +594,10 @@ namespace agg
//---------------------------------------------------------------path_base
// A container to store vertices with their flags.
// A path consists of a number of contours separated with "move_to"
// A container to store vertices with their flags.
// A path consists of a number of contours separated with "move_to"
// commands. The path storage can keep and maintain more than one
// path.
// path.
// To navigate to the beginning of a particular path, use rewind(path_id);
// Where path_id is what start_new_path() returns. So, when you call
// start_new_path() you need to store its return value somewhere else
@ -647,28 +644,28 @@ namespace agg
bool sweep_flag,
double dx, double dy);
void curve3(double x_ctrl, double y_ctrl,
void curve3(double x_ctrl, double y_ctrl,
double x_to, double y_to);
void curve3_rel(double dx_ctrl, double dy_ctrl,
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,
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,
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,
void curve4(double x_ctrl2, double y_ctrl2,
double x_to, double y_to);
void curve4_rel(double x_ctrl2, double y_ctrl2,
void curve4_rel(double x_ctrl2, double y_ctrl2,
double x_to, double y_to);
@ -677,8 +674,8 @@ namespace agg
// Accessors
//--------------------------------------------------------------------
const container_type& vertices() const { return m_vertices; }
container_type& vertices() { return m_vertices; }
const container_type& vertices() const { return m_vertices; }
container_type& vertices() { return m_vertices; }
unsigned total_vertices() const;
@ -702,9 +699,9 @@ namespace agg
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
// Arrange the orientation of a polygon, all polygons in a path,
// or in all paths. After calling arrange_orientations() or
// arrange_orientations_all_paths(), all the polygons will have
// Arrange the orientation of a polygon, all polygons in a path,
// or in all paths. After calling arrange_orientations() or
// arrange_orientations_all_paths(), all the polygons will have
// the same orientation, i.e. path_flags_cw or path_flags_ccw
//--------------------------------------------------------------------
unsigned arrange_polygon_orientation(unsigned start, path_flags_e orientation);
@ -712,7 +709,7 @@ namespace agg
void arrange_orientations_all_paths(path_flags_e orientation);
void invert_polygon(unsigned start);
// Flip all vertices horizontally or vertically,
// Flip all vertices horizontally or vertically,
// between x1 and x2, or between y1 and y2 respectively
//--------------------------------------------------------------------
void flip_x(double x1, double x2);
@ -720,11 +717,10 @@ namespace agg
// Concatenate path. The path is added as is.
//--------------------------------------------------------------------
template<class VertexSource>
template<class VertexSource>
void concat_path(VertexSource& vs, unsigned path_id = 0)
{
double x=0;
double y=0;
double x, y;
unsigned cmd;
vs.rewind(path_id);
while(!is_stop(cmd = vs.vertex(&x, &y)))
@ -734,12 +730,12 @@ namespace agg
}
//--------------------------------------------------------------------
// Join path. The path is joined with the existing one, that is,
// Join path. The path is joined with the existing one, that is,
// it behaves as if the pen of a plotter was always down (drawing)
template<class VertexSource>
template<class VertexSource>
void join_path(VertexSource& vs, unsigned path_id = 0)
{
double x=0.0, y=0.0;
double x, y;
unsigned cmd;
vs.rewind(path_id);
cmd = vs.vertex(&x, &y);
@ -772,16 +768,16 @@ namespace agg
}
while(!is_stop(cmd = vs.vertex(&x, &y)))
{
m_vertices.add_vertex(x, y, is_move_to(cmd) ?
unsigned(path_cmd_line_to) :
m_vertices.add_vertex(x, y, is_move_to(cmd) ?
unsigned(path_cmd_line_to) :
cmd);
}
}
}
// Concatenate polygon/polyline.
// Concatenate polygon/polyline.
//--------------------------------------------------------------------
template<class T> void concat_poly(const T* data,
template<class T> void concat_poly(const T* data,
unsigned num_points,
bool closed)
{
@ -791,7 +787,7 @@ namespace agg
// Join polygon/polyline continuously.
//--------------------------------------------------------------------
template<class T> void join_poly(const T* data,
template<class T> void join_poly(const T* data,
unsigned num_points,
bool closed)
{
@ -849,7 +845,7 @@ namespace agg
};
//------------------------------------------------------------------------
template<class VC>
template<class VC>
unsigned path_base<VC>::start_new_path()
{
if(!is_stop(m_vertices.last_command()))
@ -861,7 +857,7 @@ namespace agg
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::rel_to_abs(double* x, double* y) const
{
if(m_vertices.total_vertices())
@ -873,24 +869,18 @@ namespace agg
*x += x2;
*y += y2;
}
else if (!is_stop(m_vertices.last_command()) &&
is_vertex(m_vertices.prev_vertex(&x2, &y2)))
{
*x += x2;
*y += y2;
}
}
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::move_to(double x, double y)
{
m_vertices.add_vertex(x, y, path_cmd_move_to);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::move_rel(double dx, double dy)
{
rel_to_abs(&dx, &dy);
@ -898,14 +888,14 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::line_to(double x, double y)
{
m_vertices.add_vertex(x, y, path_cmd_line_to);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::line_rel(double dx, double dy)
{
rel_to_abs(&dx, &dy);
@ -913,14 +903,14 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::hline_to(double x)
{
m_vertices.add_vertex(x, last_y(), path_cmd_line_to);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::hline_rel(double dx)
{
double dy = 0;
@ -929,14 +919,14 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::vline_to(double y)
{
m_vertices.add_vertex(last_x(), y, path_cmd_line_to);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::vline_rel(double dy)
{
double dx = 0;
@ -945,7 +935,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::arc_to(double rx, double ry,
double angle,
bool large_arc_flag,
@ -959,12 +949,12 @@ namespace agg
double y0 = 0.0;
m_vertices.last_vertex(&x0, &y0);
rx = std::fabs(rx);
ry = std::fabs(ry);
rx = fabs(rx);
ry = fabs(ry);
// Ensure radii are valid
//-------------------------
if(rx < epsilon || ry < epsilon)
if(rx < epsilon || ry < epsilon)
{
line_to(x, y);
return;
@ -981,11 +971,10 @@ namespace agg
{
join_path(a);
}
// We are adding an explicit line_to, even if we've already add the
// bezier arc to the current path. This is to prevent subsequent smooth
// bezier curves from accidentally assuming that the previous command
// was a bezier curve as well when calculating reflection points.
line_to(x, y);
else
{
line_to(x, y);
}
}
else
{
@ -994,7 +983,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::arc_rel(double rx, double ry,
double angle,
bool large_arc_flag,
@ -1006,8 +995,8 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
void path_base<VC>::curve3(double x_ctrl, double y_ctrl,
template<class VC>
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);
@ -1015,8 +1004,8 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
void path_base<VC>::curve3_rel(double dx_ctrl, double dy_ctrl,
template<class VC>
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);
@ -1026,7 +1015,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::curve3(double x_to, double y_to)
{
double x0;
@ -1034,7 +1023,7 @@ namespace agg
if(is_vertex(m_vertices.last_vertex(&x0, &y0)))
{
double x_ctrl;
double y_ctrl;
double y_ctrl;
unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl);
if(is_curve(cmd))
{
@ -1051,7 +1040,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::curve3_rel(double dx_to, double dy_to)
{
rel_to_abs(&dx_to, &dy_to);
@ -1059,9 +1048,9 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
void path_base<VC>::curve4(double x_ctrl1, double y_ctrl1,
double x_ctrl2, double y_ctrl2,
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)
{
m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4);
@ -1070,9 +1059,9 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
void path_base<VC>::curve4_rel(double dx_ctrl1, double dy_ctrl1,
double dx_ctrl2, double dy_ctrl2,
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)
{
rel_to_abs(&dx_ctrl1, &dy_ctrl1);
@ -1084,8 +1073,8 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2,
template<class VC>
void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2,
double x_to, double y_to)
{
double x0;
@ -1093,7 +1082,7 @@ namespace agg
if(is_vertex(last_vertex(&x0, &y0)))
{
double x_ctrl1;
double y_ctrl1;
double y_ctrl1;
unsigned cmd = prev_vertex(&x_ctrl1, &y_ctrl1);
if(is_curve(cmd))
{
@ -1110,8 +1099,8 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
void path_base<VC>::curve4_rel(double dx_ctrl2, double dy_ctrl2,
template<class VC>
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);
@ -1120,7 +1109,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::end_poly(unsigned flags)
{
if(is_vertex(m_vertices.last_command()))
@ -1130,91 +1119,91 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::close_polygon(unsigned flags)
{
end_poly(path_flags_close | flags);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline unsigned path_base<VC>::total_vertices() const
{
return m_vertices.total_vertices();
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline unsigned path_base<VC>::last_vertex(double* x, double* y) const
{
return m_vertices.last_vertex(x, y);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline unsigned path_base<VC>::prev_vertex(double* x, double* y) const
{
return m_vertices.prev_vertex(x, y);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline double path_base<VC>::last_x() const
{
return m_vertices.last_x();
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline double path_base<VC>::last_y() const
{
return m_vertices.last_y();
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline unsigned path_base<VC>::vertex(unsigned idx, double* x, double* y) const
{
return m_vertices.vertex(idx, x, y);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline unsigned path_base<VC>::command(unsigned idx) const
{
return m_vertices.command(idx);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::modify_vertex(unsigned idx, double x, double y)
{
m_vertices.modify_vertex(idx, x, y);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::modify_vertex(unsigned idx, double x, double y, unsigned cmd)
{
m_vertices.modify_vertex(idx, x, y, cmd);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::modify_command(unsigned idx, unsigned cmd)
{
m_vertices.modify_command(idx, cmd);
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline void path_base<VC>::rewind(unsigned path_id)
{
m_iterator = path_id;
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
inline unsigned path_base<VC>::vertex(double* x, double* y)
{
if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop;
@ -1222,7 +1211,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
unsigned path_base<VC>::perceive_polygon_orientation(unsigned start,
unsigned end)
{
@ -1242,12 +1231,12 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::invert_polygon(unsigned start, unsigned end)
{
unsigned i;
unsigned tmp_cmd = m_vertices.command(start);
--end; // Make "end" inclusive
// Shift all commands to one position
@ -1267,45 +1256,45 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::invert_polygon(unsigned start)
{
// Skip all non-vertices at the beginning
while(start < m_vertices.total_vertices() &&
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() &&
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() &&
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,
template<class VC>
unsigned path_base<VC>::arrange_polygon_orientation(unsigned start,
path_flags_e orientation)
{
if(orientation == path_flags_none) return start;
// Skip all non-vertices at the beginning
while(start < m_vertices.total_vertices() &&
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() &&
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() &&
while(end < m_vertices.total_vertices() &&
!is_next_poly(m_vertices.command(end))) ++end;
if(end - start > 2)
@ -1315,7 +1304,7 @@ namespace agg
// Invert polygon, set orientation flag, and skip all end_poly
invert_polygon(start, end);
unsigned cmd;
while(end < m_vertices.total_vertices() &&
while(end < m_vertices.total_vertices() &&
is_end_poly(cmd = m_vertices.command(end)))
{
m_vertices.modify_command(end++, set_orientation(cmd, orientation));
@ -1326,8 +1315,8 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
unsigned path_base<VC>::arrange_orientations(unsigned start,
template<class VC>
unsigned path_base<VC>::arrange_orientations(unsigned start,
path_flags_e orientation)
{
if(orientation != path_flags_none)
@ -1346,7 +1335,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::arrange_orientations_all_paths(path_flags_e orientation)
{
if(orientation != path_flags_none)
@ -1360,7 +1349,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::flip_x(double x1, double x2)
{
unsigned i;
@ -1376,7 +1365,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::flip_y(double y1, double y2)
{
unsigned i;
@ -1392,7 +1381,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::translate(double dx, double dy, unsigned path_id)
{
unsigned num_ver = m_vertices.total_vertices();
@ -1411,7 +1400,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class VC>
template<class VC>
void path_base<VC>::translate_all_paths(double dx, double dy)
{
unsigned idx;
@ -1428,10 +1417,6 @@ namespace agg
}
}
////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------vertex_stl_storage
template<class Container> class vertex_stl_storage
{
@ -1444,8 +1429,8 @@ namespace agg
void add_vertex(double x, double y, unsigned cmd)
{
m_vertices.push_back(vertex_type(value_type(x),
value_type(y),
m_vertices.push_back(vertex_type(value_type(x),
value_type(y),
int8u(cmd)));
}
@ -1478,8 +1463,8 @@ namespace agg
unsigned last_command() const
{
return m_vertices.size() ?
m_vertices[m_vertices.size() - 1].cmd :
return m_vertices.size() ?
m_vertices[m_vertices.size() - 1].cmd :
path_cmd_stop;
}
@ -1548,12 +1533,13 @@ namespace agg
// Example of declarations path_storage with std::vector as a container
//---------------------------------------------------------------------------
//#include <vector>
//namespace agg
//{
// typedef path_base<vertex_stl_storage<std::vector<vertex_d> > > path_storage;
// typedef path_base<vertex_stl_storage<std::vector<vertex_d> > > stl_path_storage;
//}
#endif

View file

@ -16,7 +16,7 @@
#ifndef AGG_PATH_STORAGE_INTEGER_INCLUDED
#define AGG_PATH_STORAGE_INTEGER_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_array.h"
namespace agg

View file

@ -17,7 +17,7 @@
#define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_array.h"
#include "agg_rendering_buffer.h"

View file

@ -0,0 +1,670 @@
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Adaptation for high precision colors has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
//
// Liberty Technology Systems, Inc. is the provider of
// PostScript and PDF technology for software developers.
//
//----------------------------------------------------------------------------
#ifndef AGG_PIXFMT_GRAY_INCLUDED
#define AGG_PIXFMT_GRAY_INCLUDED
#include <string.h>
#include "agg_basics.h"
#include "agg_color_gray.h"
#include "agg_rendering_buffer.h"
namespace agg
{
//============================================================blender_gray
template<class ColorT> struct blender_gray
{
typedef ColorT color_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 };
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
unsigned alpha, unsigned cover=0)
{
*p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift);
}
};
//======================================================blender_gray_pre
template<class ColorT> struct blender_gray_pre
{
typedef ColorT color_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 };
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
unsigned alpha, unsigned cover)
{
alpha = color_type::base_mask - alpha;
cover = (cover + 1) << (base_shift - 8);
*p = (value_type)((*p * alpha + cv * cover) >> base_shift);
}
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
unsigned alpha)
{
*p = (value_type)(((*p * (color_type::base_mask - alpha)) >> base_shift) + cv);
}
};
//=====================================================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) {}
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
{
public:
typedef typename ColorT::value_type value_type;
apply_gamma_inv_gray(const GammaLut& gamma) : m_gamma(gamma) {}
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
{
public:
typedef RenBuf rbuf_type;
typedef typename rbuf_type::row_data row_data;
typedef Blender blender_type;
typedef typename blender_type::color_type color_type;
typedef int order_type; // A fake one
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_scale = color_type::base_scale,
base_mask = color_type::base_mask,
pix_width = sizeof(value_type),
pix_step = Step,
pix_offset = Offset
};
private:
//--------------------------------------------------------------------
static AGG_INLINE void copy_or_blend_pix(value_type* p,
const color_type& c,
unsigned cover)
{
if (c.a)
{
calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8;
if(alpha == base_mask)
{
*p = c.v;
}
else
{
Blender::blend_pix(p, c.v, alpha, cover);
}
}
}
static AGG_INLINE void copy_or_blend_pix(value_type* p,
const color_type& c)
{
if (c.a)
{
if(c.a == base_mask)
{
*p = c.v;
}
else
{
Blender::blend_pix(p, c.v, c.a);
}
}
}
public:
//--------------------------------------------------------------------
explicit pixfmt_alpha_blend_gray(rbuf_type& rb) :
m_rbuf(&rb)
{}
void attach(rbuf_type& rb) { m_rbuf = &rb; }
//--------------------------------------------------------------------
template<class PixFmt>
bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2)
{
rect_i r(x1, y1, x2, y2);
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);
return true;
}
return false;
}
//--------------------------------------------------------------------
AGG_INLINE unsigned width() const { return m_rbuf->width(); }
AGG_INLINE unsigned height() const { return m_rbuf->height(); }
AGG_INLINE int stride() const { return m_rbuf->stride(); }
//--------------------------------------------------------------------
int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); }
const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); }
row_data row(int y) const { return m_rbuf->row(y); }
const int8u* pix_ptr(int x, int y) const
{
return m_rbuf->row_ptr(y) + x * Step + Offset;
}
int8u* pix_ptr(int x, int y)
{
return m_rbuf->row_ptr(y) + x * Step + Offset;
}
//--------------------------------------------------------------------
AGG_INLINE static void make_pix(int8u* p, const color_type& c)
{
*(value_type*)p = c.v;
}
//--------------------------------------------------------------------
AGG_INLINE color_type pixel(int x, int y) const
{
value_type* p = (value_type*)m_rbuf->row_ptr(y) + x * Step + Offset;
return color_type(*p);
}
//--------------------------------------------------------------------
AGG_INLINE void copy_pixel(int x, int y, const color_type& c)
{
*((value_type*)m_rbuf->row_ptr(x, y, 1) + x * Step + Offset) = c.v;
}
//--------------------------------------------------------------------
AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover)
{
copy_or_blend_pix((value_type*)
m_rbuf->row_ptr(x, y, 1) + x * Step + Offset,
c,
cover);
}
//--------------------------------------------------------------------
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 * Step + Offset;
do
{
*p = c.v;
p += Step;
}
while(--len);
}
//--------------------------------------------------------------------
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 * Step + Offset;
*p = c.v;
}
while(--len);
}
//--------------------------------------------------------------------
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 * Step + Offset;
calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8;
if(alpha == base_mask)
{
do
{
*p = c.v;
p += Step;
}
while(--len);
}
else
{
do
{
Blender::blend_pix(p, c.v, alpha, cover);
p += Step;
}
while(--len);
}
}
}
//--------------------------------------------------------------------
void blend_vline(int x, int y,
unsigned len,
const color_type& c,
int8u cover)
{
if (c.a)
{
value_type* p;
calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8;
if(alpha == base_mask)
{
do
{
p = (value_type*)
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
*p = c.v;
}
while(--len);
}
else
{
do
{
p = (value_type*)
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
Blender::blend_pix(p, c.v, alpha, cover);
}
while(--len);
}
}
}
//--------------------------------------------------------------------
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 * Step + Offset;
do
{
calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;
if(alpha == base_mask)
{
*p = c.v;
}
else
{
Blender::blend_pix(p, c.v, alpha, *covers);
}
p += Step;
++covers;
}
while(--len);
}
}
//--------------------------------------------------------------------
void blend_solid_vspan(int x, int y,
unsigned len,
const color_type& c,
const int8u* covers)
{
if (c.a)
{
do
{
calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;
value_type* p = (value_type*)
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
if(alpha == base_mask)
{
*p = c.v;
}
else
{
Blender::blend_pix(p, c.v, alpha, *covers);
}
++covers;
}
while(--len);
}
}
//--------------------------------------------------------------------
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 * Step + Offset;
do
{
*p = colors->v;
p += Step;
++colors;
}
while(--len);
}
//--------------------------------------------------------------------
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 * Step + Offset;
*p = colors->v;
++colors;
}
while(--len);
}
//--------------------------------------------------------------------
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 * Step + Offset;
if(covers)
{
do
{
copy_or_blend_pix(p, *colors++, *covers++);
p += Step;
}
while(--len);
}
else
{
if(cover == 255)
{
do
{
if(colors->a == base_mask)
{
*p = colors->v;
}
else
{
copy_or_blend_pix(p, *colors);
}
p += Step;
++colors;
}
while(--len);
}
else
{
do
{
copy_or_blend_pix(p, *colors++, cover);
p += Step;
}
while(--len);
}
}
}
//--------------------------------------------------------------------
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 * Step + Offset;
copy_or_blend_pix(p, *colors++, *covers++);
}
while(--len);
}
else
{
if(cover == 255)
{
do
{
p = (value_type*)
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
if(colors->a == base_mask)
{
*p = colors->v;
}
else
{
copy_or_blend_pix(p, *colors);
}
++colors;
}
while(--len);
}
else
{
do
{
p = (value_type*)
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
copy_or_blend_pix(p, *colors++, cover);
}
while(--len);
}
}
}
//--------------------------------------------------------------------
template<class Function> void for_each_pixel(Function f)
{
unsigned y;
for(y = 0; y < height(); ++y)
{
row_data r = m_rbuf->row(y);
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 * Step + Offset;
do
{
f(p);
p += Step;
}
while(--len);
}
}
}
//--------------------------------------------------------------------
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)
{
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)
{
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);
}
}
//--------------------------------------------------------------------
template<class SrcPixelFormatRenderer>
void blend_from_color(const SrcPixelFormatRenderer& from,
const color_type& color,
int xdst, int ydst,
int xsrc, int ysrc,
unsigned len,
int8u cover)
{
typedef typename SrcPixelFormatRenderer::value_type src_value_type;
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;
do
{
copy_or_blend_pix(pdst,
color,
(*psrc * cover + base_mask) >> base_shift);
++psrc;
++pdst;
}
while(--len);
}
}
//--------------------------------------------------------------------
template<class SrcPixelFormatRenderer>
void blend_from_lut(const SrcPixelFormatRenderer& from,
const color_type* color_lut,
int xdst, int ydst,
int xsrc, int ysrc,
unsigned len,
int8u cover)
{
typedef typename SrcPixelFormatRenderer::value_type src_value_type;
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;
do
{
copy_or_blend_pix(pdst, color_lut[*psrc], cover);
++psrc;
++pdst;
}
while(--len);
}
}
private:
rbuf_type* m_rbuf;
};
typedef blender_gray<gray8> blender_gray8;
typedef blender_gray_pre<gray8> blender_gray8_pre;
typedef blender_gray<gray16> blender_gray16;
typedef blender_gray_pre<gray16> blender_gray16_pre;
typedef pixfmt_alpha_blend_gray<blender_gray8, rendering_buffer> pixfmt_gray8; //----pixfmt_gray8
typedef pixfmt_alpha_blend_gray<blender_gray8_pre, rendering_buffer> pixfmt_gray8_pre; //----pixfmt_gray8_pre
typedef pixfmt_alpha_blend_gray<blender_gray16, rendering_buffer> pixfmt_gray16; //----pixfmt_gray16
typedef pixfmt_alpha_blend_gray<blender_gray16_pre, rendering_buffer> pixfmt_gray16_pre; //----pixfmt_gray16_pre
}
#endif

View file

@ -24,7 +24,7 @@
#ifndef AGG_PIXFMT_RGB_INCLUDED
#define AGG_PIXFMT_RGB_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_basics.h"
#include "agg_color_rgba.h"
#include "agg_rendering_buffer.h"

View file

@ -24,7 +24,7 @@
#ifndef AGG_PIXFMT_RGB_PACKED_INCLUDED
#define AGG_PIXFMT_RGB_PACKED_INCLUDED
#include <cstring>
#include <string.h>
#include "agg_basics.h"
#include "agg_color_rgba.h"
#include "agg_rendering_buffer.h"

File diff suppressed because it is too large Load diff

View file

@ -29,9 +29,8 @@
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
#include <cstring>
#include <cstdlib>
#include <limits>
#include <string.h>
#include <math.h>
#include "agg_math.h"
#include "agg_array.h"
@ -131,11 +130,10 @@ namespace agg
if(m_num_blocks)
{
cell_type** ptr = m_cells + m_num_blocks - 1;
while(m_num_blocks > 0)
while(m_num_blocks--)
{
pod_allocator<cell_type>::deallocate(*ptr, cell_block_size);
ptr--;
--m_num_blocks;
}
pod_allocator<cell_type*>::deallocate(m_cells, m_max_blocks);
}
@ -327,8 +325,8 @@ namespace agg
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 ((abs(x1) >= INT_MAX/2) || (abs(y1) >= INT_MAX/2) ||
(abs(x2) >= INT_MAX/2) || (abs(y2) >= INT_MAX/2))
return;
line(x1, y1, cx, cy);
@ -664,26 +662,23 @@ namespace agg
cell_type* cell_ptr;
unsigned nb = m_num_cells >> cell_block_shift;
unsigned i;
while(nb > 0)
while(nb--)
{
cell_ptr = *block_ptr++;
i = cell_block_size;
while(i > 0)
while(i--)
{
m_sorted_y[cell_ptr->y - m_min_y].start++;
++cell_ptr;
--i;
}
--nb;
}
cell_ptr = *block_ptr++;
i = m_num_cells & cell_block_mask;
while(i > 0)
while(i--)
{
m_sorted_y[cell_ptr->y - m_min_y].start++;
++cell_ptr;
--i;
}
// Convert the Y-histogram into the array of starting indexes
@ -698,30 +693,27 @@ namespace agg
// Fill the cell pointer array sorted by Y
block_ptr = m_cells;
nb = m_num_cells >> cell_block_shift;
while(nb > 0)
while(nb--)
{
cell_ptr = *block_ptr++;
i = cell_block_size;
while(i > 0)
while(i--)
{
sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y];
m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr;
++curr_y.num;
++cell_ptr;
--i;
}
--nb;
}
cell_ptr = *block_ptr++;
i = m_num_cells & cell_block_mask;
while(i > 0)
while(i--)
{
sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y];
m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr;
++curr_y.num;
++cell_ptr;
--i;
}
// Finally arrange the X-arrays

View file

@ -323,65 +323,68 @@ namespace agg
int y2;
int lprev;
if(close_polygon && (m_src_vertices.size() >= 3))
if(close_polygon)
{
dv.idx = 2;
v = &m_src_vertices[m_src_vertices.size() - 1];
x1 = v->x;
y1 = v->y;
lprev = v->len;
v = &m_src_vertices[0];
x2 = v->x;
y2 = v->y;
dv.lcurr = v->len;
line_parameters prev(x1, y1, x2, y2, lprev);
v = &m_src_vertices[1];
dv.x1 = v->x;
dv.y1 = v->y;
dv.lnext = v->len;
dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr);
v = &m_src_vertices[dv.idx];
dv.x2 = v->x;
dv.y2 = v->y;
dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext);
dv.xb1 = 0;
dv.yb1 = 0;
dv.xb2 = 0;
dv.yb2 = 0;
switch(m_line_join)
if(m_src_vertices.size() >= 3)
{
case outline_no_join:
dv.flags = 3;
break;
dv.idx = 2;
case outline_miter_join:
case outline_round_join:
dv.flags =
(prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
break;
v = &m_src_vertices[m_src_vertices.size() - 1];
x1 = v->x;
y1 = v->y;
lprev = v->len;
case outline_miter_accurate_join:
dv.flags = 0;
break;
v = &m_src_vertices[0];
x2 = v->x;
y2 = v->y;
dv.lcurr = v->len;
line_parameters prev(x1, y1, x2, y2, lprev);
v = &m_src_vertices[1];
dv.x1 = v->x;
dv.y1 = v->y;
dv.lnext = v->len;
dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr);
v = &m_src_vertices[dv.idx];
dv.x2 = v->x;
dv.y2 = v->y;
dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext);
dv.xb1 = 0;
dv.yb1 = 0;
dv.xb2 = 0;
dv.yb2 = 0;
switch(m_line_join)
{
case outline_no_join:
dv.flags = 3;
break;
case outline_miter_join:
case outline_round_join:
dv.flags =
(prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) |
((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1);
break;
case outline_miter_accurate_join:
dv.flags = 0;
break;
}
if((dv.flags & 1) == 0 && m_line_join != outline_round_join)
{
bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1);
}
if((dv.flags & 2) == 0 && m_line_join != outline_round_join)
{
bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2);
}
draw(dv, 0, m_src_vertices.size());
}
if((dv.flags & 1) == 0 && m_line_join != outline_round_join)
{
bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1);
}
if((dv.flags & 2) == 0 && m_line_join != outline_round_join)
{
bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2);
}
draw(dv, 0, m_src_vertices.size());
}
else
{

View file

@ -2,15 +2,15 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
//
// The author gratefully acknowleges the support of David Turner,
// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType
// The author gratefully acknowleges the support of David Turner,
// Robert Wilhelm, and Werner Lemberg - the authors of the FreeType
// libray - in producing this work. See http://www.freetype.org for details.
//
//----------------------------------------------------------------------------
@ -19,12 +19,12 @@
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Adaptation for 32-bit screen coordinates has been sponsored by
// Adaptation for 32-bit screen coordinates has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
//
// Liberty Technology Systems, Inc. is the provider of
// PostScript and PDF technology for software developers.
//
//
//----------------------------------------------------------------------------
#ifndef AGG_RASTERIZER_SCANLINE_AA_INCLUDED
#define AGG_RASTERIZER_SCANLINE_AA_INCLUDED
@ -39,8 +39,8 @@ namespace agg
//-----------------------------------------------------------------cell_aa
// A pixel cell. There're no constructors defined and it was done
// intentionally in order to avoid extra overhead when allocating an
// A pixel cell. There're no constructors defined and it was done
// intentionally in order to avoid extra overhead when allocating an
// array of cells.
struct cell_aa
{
@ -67,10 +67,10 @@ namespace agg
//==================================================rasterizer_scanline_aa
// Polygon rasterizer that is used to render filled polygons with
// high-quality Anti-Aliasing. Internally, by default, the class uses
// integer coordinates in format 24.8, i.e. 24 bits for integer part
// and 8 bits for fractional - see poly_subpixel_shift. This class can be
// Polygon rasterizer that is used to render filled polygons with
// high-quality Anti-Aliasing. Internally, by default, the class uses
// integer coordinates in format 24.8, i.e. 24 bits for integer part
// and 8 bits for fractional - see poly_subpixel_shift. This class can be
// used in the following way:
//
// 1. filling_rule(filling_rule_e ft) - optional.
@ -79,20 +79,20 @@ namespace agg
//
// 3. reset()
//
// 4. move_to(x, y) / line_to(x, y) - make the polygon. One can create
// 4. move_to(x, y) / line_to(x, y) - make the polygon. One can create
// more than one contour, but each contour must consist of at least 3
// vertices, i.e. move_to(x1, y1); line_to(x2, y2); line_to(x3, y3);
// is the absolute minimum of vertices that define a triangle.
// The algorithm does not check either the number of vertices nor
// coincidence of their coordinates, but in the worst case it just
// coincidence of their coordinates, but in the worst case it just
// won't draw anything.
// The orger of the vertices (clockwise or counterclockwise)
// The orger of the vertices (clockwise or counterclockwise)
// is important when using the non-zero filling rule (fill_non_zero).
// In this case the vertex order of all the contours must be the same
// if you want your intersecting polygons to be without "holes".
// You actually can use different vertices order. If the contours do not
// intersect each other the order is not important anyway. If they do,
// contours with the same vertex order will be rendered without "holes"
// You actually can use different vertices order. If the contours do not
// intersect each other the order is not important anyway. If they do,
// contours with the same vertex order will be rendered without "holes"
// while the intersecting contours with different orders will have "holes".
//
// filling_rule() and gamma() can be called anytime before "sweeping".
@ -122,7 +122,7 @@ namespace agg
};
//--------------------------------------------------------------------
rasterizer_scanline_aa() :
rasterizer_scanline_aa() :
m_outline(),
m_clipper(),
m_filling_rule(fill_non_zero),
@ -136,8 +136,8 @@ namespace agg
}
//--------------------------------------------------------------------
template<class GammaF>
rasterizer_scanline_aa(const GammaF& gamma_function) :
template<class GammaF>
rasterizer_scanline_aa(const GammaF& gamma_function) :
m_outline(),
m_clipper(m_outline),
m_filling_rule(fill_non_zero),
@ -150,7 +150,7 @@ namespace agg
}
//--------------------------------------------------------------------
void reset();
void reset();
void reset_clipping();
void clip_box(double x1, double y1, double x2, double y2);
void filling_rule(filling_rule_e filling_rule);
@ -158,7 +158,7 @@ namespace agg
//--------------------------------------------------------------------
template<class GammaF> void gamma(const GammaF& gamma_function)
{
{
int i;
for(i = 0; i < aa_scale; i++)
{
@ -167,9 +167,9 @@ namespace agg
}
//--------------------------------------------------------------------
unsigned apply_gamma(unsigned cover) const
{
return m_gamma[cover];
unsigned apply_gamma(unsigned cover) const
{
return m_gamma[cover];
}
//--------------------------------------------------------------------
@ -198,7 +198,7 @@ namespace agg
add_vertex(x, y, cmd);
}
}
//--------------------------------------------------------------------
int min_x() const { return m_outline.min_x(); }
int min_y() const { return m_outline.min_y(); }
@ -237,7 +237,7 @@ namespace agg
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);
unsigned cover = 0;
int cover = 0;
while(num_cells)
{
@ -276,7 +276,7 @@ namespace agg
}
}
}
if(sl.num_spans()) break;
++m_scan_y;
}
@ -294,7 +294,7 @@ namespace agg
//--------------------------------------------------------------------
// Disable copying
rasterizer_scanline_aa(const rasterizer_scanline_aa<Clip>&);
const rasterizer_scanline_aa<Clip>&
const rasterizer_scanline_aa<Clip>&
operator = (const rasterizer_scanline_aa<Clip>&);
private:
@ -321,32 +321,32 @@ namespace agg
//------------------------------------------------------------------------
template<class Clip>
void rasterizer_scanline_aa<Clip>::reset()
{
m_outline.reset();
template<class Clip>
void rasterizer_scanline_aa<Clip>::reset()
{
m_outline.reset();
m_status = status_initial;
}
//------------------------------------------------------------------------
template<class Clip>
void rasterizer_scanline_aa<Clip>::filling_rule(filling_rule_e filling_rule)
{
m_filling_rule = filling_rule;
template<class Clip>
void rasterizer_scanline_aa<Clip>::filling_rule(filling_rule_e filling_rule)
{
m_filling_rule = filling_rule;
}
//------------------------------------------------------------------------
template<class Clip>
void rasterizer_scanline_aa<Clip>::clip_box(double x1, double y1,
template<class Clip>
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),
m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1),
conv_type::upscale(x2), conv_type::upscale(y2));
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
void rasterizer_scanline_aa<Clip>::reset_clipping()
{
reset();
@ -354,7 +354,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
void rasterizer_scanline_aa<Clip>::close_polygon()
{
if(m_status == status_line_to)
@ -365,56 +365,56 @@ namespace agg
}
//------------------------------------------------------------------------
template<class Clip>
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_clipper.move_to(m_start_x = conv_type::downscale(x),
m_start_y = conv_type::downscale(y));
m_status = status_move_to;
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
void rasterizer_scanline_aa<Clip>::line_to(int x, int y)
{
m_clipper.line_to(m_outline,
conv_type::downscale(x),
m_clipper.line_to(m_outline,
conv_type::downscale(x),
conv_type::downscale(y));
m_status = status_line_to;
}
//------------------------------------------------------------------------
template<class Clip>
void rasterizer_scanline_aa<Clip>::move_to_d(double x, double 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));
m_clipper.move_to(m_start_x = conv_type::upscale(x),
m_start_y = conv_type::upscale(y));
m_status = status_move_to;
}
//------------------------------------------------------------------------
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));
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_status = status_line_to;
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
void rasterizer_scanline_aa<Clip>::add_vertex(double x, double y, unsigned cmd)
{
if(is_move_to(cmd))
if(is_move_to(cmd))
{
move_to_d(x, y);
}
else
else
if(is_vertex(cmd))
{
line_to_d(x, y);
@ -427,32 +427,32 @@ namespace agg
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
void rasterizer_scanline_aa<Clip>::edge(int x1, int y1, int x2, int y2)
{
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),
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,
template<class Clip>
void rasterizer_scanline_aa<Clip>::edge_d(double x1, double y1,
double x2, double y2)
{
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.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_status = status_move_to;
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
void rasterizer_scanline_aa<Clip>::sort()
{
if(m_auto_close) close_polygon();
@ -460,12 +460,12 @@ namespace agg
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
AGG_INLINE bool rasterizer_scanline_aa<Clip>::rewind_scanlines()
{
if(m_auto_close) close_polygon();
m_outline.sort_cells();
if(m_outline.total_cells() == 0)
if(m_outline.total_cells() == 0)
{
return false;
}
@ -475,14 +475,14 @@ namespace agg
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
AGG_INLINE bool rasterizer_scanline_aa<Clip>::navigate_scanline(int y)
{
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;
}
@ -491,7 +491,7 @@ namespace agg
}
//------------------------------------------------------------------------
template<class Clip>
template<class Clip>
bool rasterizer_scanline_aa<Clip>::hit_test(int tx, int ty)
{
if(!navigate_scanline(ty)) return false;
@ -507,3 +507,4 @@ namespace agg
#endif

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -24,7 +24,7 @@ namespace agg
{
poly_max_coord = (1 << 30) - 1 //----poly_max_coord
};
//------------------------------------------------------------ras_conv_int
struct ras_conv_int
{
@ -35,7 +35,7 @@ namespace agg
}
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)); }
static int upscale(double v) { return iround(v * poly_subpixel_scale); }
static int downscale(int v) { return v; }
};
@ -49,9 +49,9 @@ namespace agg
}
static int xi(int v) { return v; }
static int yi(int v) { return v; }
static int upscale(double v)
{
return saturation<poly_max_coord>::iround(v * static_cast<double>(poly_subpixel_scale));
static int upscale(double v)
{
return saturation<poly_max_coord>::iround(v * poly_subpixel_scale);
}
static int downscale(int v) { return v; }
};
@ -66,7 +66,7 @@ namespace agg
}
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)); }
static int upscale(double v) { return iround(v * poly_subpixel_scale); }
static int downscale(int v) { return v; }
};
@ -78,10 +78,10 @@ namespace agg
{
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 int xi(double v) { return iround(v * poly_subpixel_scale); }
static int yi(double v) { return iround(v * poly_subpixel_scale); }
static double upscale(double v) { return v; }
static double downscale(int v) { return v / static_cast<double>(poly_subpixel_scale); }
static double downscale(int v) { return v / double(poly_subpixel_scale); }
};
//--------------------------------------------------------ras_conv_dbl_3x
@ -92,10 +92,10 @@ namespace agg
{
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 int xi(double v) { return iround(v * poly_subpixel_scale * 3); }
static int yi(double v) { return iround(v * poly_subpixel_scale); }
static double upscale(double v) { return v; }
static double downscale(int v) { return v / static_cast<double>(poly_subpixel_scale); }
static double downscale(int v) { return v / double(poly_subpixel_scale); }
};
@ -111,12 +111,12 @@ namespace agg
typedef rect_base<coord_type> rect_type;
//--------------------------------------------------------------------
rasterizer_sl_clip() :
rasterizer_sl_clip() :
m_clip_box(0,0,0,0),
m_x1(0),
m_y1(0),
m_f1(0),
m_clipping(false)
m_clipping(false)
{}
//--------------------------------------------------------------------
@ -145,8 +145,8 @@ namespace agg
//------------------------------------------------------------------------
template<class Rasterizer>
AGG_INLINE void line_clip_y(Rasterizer& ras,
coord_type x1, coord_type y1,
coord_type x2, coord_type y2,
coord_type x1, coord_type y1,
coord_type x2, coord_type y2,
unsigned f1, unsigned f2) const
{
f1 &= 10;
@ -154,7 +154,7 @@ namespace agg
if((f1 | f2) == 0)
{
// Fully visible
ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2));
ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2));
}
else
{
@ -192,8 +192,8 @@ namespace agg
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));
}
}
@ -288,8 +288,8 @@ namespace agg
}
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;
@ -317,14 +317,14 @@ namespace agg
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 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; }
template<class Rasterizer>
void line_to(Rasterizer& ras, coord_type x2, coord_type y2)
{
ras.line(m_x1, m_y1, x2, y2);
m_x1 = x2;
void line_to(Rasterizer& ras, coord_type x2, coord_type y2)
{
ras.line(m_x1, m_y1, x2, y2);
m_x1 = x2;
m_y1 = y2;
}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -32,7 +32,6 @@ namespace agg
public:
typedef PixelFormat pixfmt_type;
typedef typename pixfmt_type::color_type color_type;
typedef typename pixfmt_type::color_type::value_type value_type;
typedef typename pixfmt_type::row_data row_data;
//--------------------------------------------------------------------
@ -50,7 +49,7 @@ namespace agg
//--------------------------------------------------------------------
const pixfmt_type& ren() const { return *m_ren; }
pixfmt_type& ren() { return *m_ren; }
//--------------------------------------------------------------------
unsigned width() const { return m_ren->width(); }
unsigned height() const { return m_ren->height(); }
@ -133,7 +132,7 @@ namespace agg
}
}
}
//--------------------------------------------------------------------
void copy_pixel(int x, int y, const color_type& c)
@ -156,7 +155,7 @@ namespace agg
//--------------------------------------------------------------------
color_type pixel(int x, int y) const
{
return inbox(x, y) ?
return inbox(x, y) ?
m_ren->pixel(x, y) :
color_type::no_color();
}
@ -192,7 +191,7 @@ namespace agg
}
//--------------------------------------------------------------------
void blend_hline(int x1, int y, int x2,
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; }
@ -208,7 +207,7 @@ namespace agg
}
//--------------------------------------------------------------------
void blend_vline(int x, int y1, int y2,
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; }
@ -240,7 +239,7 @@ namespace agg
}
//--------------------------------------------------------------------
void blend_bar(int x1, int y1, int x2, int y2,
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);
@ -252,16 +251,16 @@ namespace agg
{
m_ren->blend_hline(rc.x1,
y,
unsigned(rc.x2 - rc.x1 + 1),
c,
unsigned(rc.x2 - rc.x1 + 1),
c,
cover);
}
}
}
//--------------------------------------------------------------------
void blend_solid_hspan(int x, int y, int len,
const color_type& c,
void blend_solid_hspan(int x, int y, int len,
const color_type& c,
const cover_type* covers)
{
if(y > ymax()) return;
@ -283,8 +282,8 @@ namespace agg
}
//--------------------------------------------------------------------
void blend_solid_vspan(int x, int y, int len,
const color_type& c,
void blend_solid_vspan(int x, int y, int len,
const color_type& c,
const cover_type* covers)
{
if(x > xmax()) return;
@ -353,8 +352,8 @@ namespace agg
//--------------------------------------------------------------------
void blend_color_hspan(int x, int y, int len,
const color_type* colors,
void blend_color_hspan(int x, int y, int len,
const color_type* colors,
const cover_type* covers,
cover_type cover = agg::cover_full)
{
@ -379,35 +378,8 @@ namespace agg
}
//--------------------------------------------------------------------
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(x < xmin())
{
int d = xmin() - x;
len -= 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;
}
m_ren->blend_color_hspan_alpha(x, y, len, colors, alpha, covers, cover);
}
//--------------------------------------------------------------------
void blend_color_vspan(int x, int y, int len,
const color_type* colors,
void blend_color_vspan(int x, int y, int len,
const color_type* colors,
const cover_type* covers,
cover_type cover = agg::cover_full)
{
@ -477,15 +449,15 @@ namespace agg
//--------------------------------------------------------------------
template<class RenBuf>
void copy_from(const RenBuf& src,
const rect_i* rect_src_ptr = 0,
int dx = 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)
{
rsrc.x1 = rect_src_ptr->x1;
rsrc.x1 = rect_src_ptr->x1;
rsrc.y1 = rect_src_ptr->y1;
rsrc.x2 = rect_src_ptr->x2 + 1;
rsrc.y2 = rect_src_ptr->y2 + 1;
@ -510,7 +482,7 @@ namespace agg
}
while(rc.y2 > 0)
{
m_ren->copy_from(src,
m_ren->copy_from(src,
rdst.x1, rdst.y1,
rsrc.x1, rsrc.y1,
rc.x2);
@ -523,16 +495,16 @@ namespace agg
//--------------------------------------------------------------------
template<class SrcPixelFormatRenderer>
void blend_from(const SrcPixelFormatRenderer& src,
const rect_i* rect_src_ptr = 0,
int dx = 0,
void blend_from(const SrcPixelFormatRenderer& src,
const rect_i* rect_src_ptr = 0,
int dx = 0,
int dy = 0,
cover_type cover = agg::cover_full)
{
rect_i rsrc(0, 0, src.width(), src.height());
if(rect_src_ptr)
{
rsrc.x1 = rect_src_ptr->x1;
rsrc.x1 = rect_src_ptr->x1;
rsrc.y1 = rect_src_ptr->y1;
rsrc.x2 = rect_src_ptr->x2 + 1;
rsrc.y2 = rect_src_ptr->y2 + 1;
@ -593,17 +565,17 @@ namespace agg
//--------------------------------------------------------------------
template<class SrcPixelFormatRenderer>
void blend_from_color(const SrcPixelFormatRenderer& src,
void blend_from_color(const SrcPixelFormatRenderer& src,
const color_type& color,
const rect_i* rect_src_ptr = 0,
int dx = 0,
const rect_i* rect_src_ptr = 0,
int dx = 0,
int dy = 0,
cover_type cover = agg::cover_full)
{
rect_i rsrc(0, 0, src.width(), src.height());
if(rect_src_ptr)
{
rsrc.x1 = rect_src_ptr->x1;
rsrc.x1 = rect_src_ptr->x1;
rsrc.y1 = rect_src_ptr->y1;
rsrc.x2 = rect_src_ptr->x2 + 1;
rsrc.y2 = rect_src_ptr->y2 + 1;
@ -665,17 +637,17 @@ namespace agg
//--------------------------------------------------------------------
template<class SrcPixelFormatRenderer>
void blend_from_lut(const SrcPixelFormatRenderer& src,
void blend_from_lut(const SrcPixelFormatRenderer& src,
const color_type* color_lut,
const rect_i* rect_src_ptr = 0,
int dx = 0,
const rect_i* rect_src_ptr = 0,
int dx = 0,
int dy = 0,
cover_type cover = agg::cover_full)
{
rect_i rsrc(0, 0, src.width(), src.height());
if(rect_src_ptr)
{
rsrc.x1 = rect_src_ptr->x1;
rsrc.x1 = rect_src_ptr->x1;
rsrc.y1 = rect_src_ptr->y1;
rsrc.x2 = rect_src_ptr->x2 + 1;
rsrc.y2 = rect_src_ptr->y2 + 1;

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -32,7 +32,7 @@ namespace agg
typedef typename Source::color_type color_type;
line_image_scale(const Source& src, double height) :
m_source(src),
m_source(src),
m_height(height),
m_scale(src.height() / height)
{
@ -41,8 +41,8 @@ namespace agg
double width() const { return m_source.width(); }
double height() const { return m_height; }
color_type pixel(int x, int y) const
{
color_type pixel(int x, int y) const
{
double src_y = (y + 0.5) * m_scale - 0.5;
int h = m_source.height() - 1;
int y1 = ufloor(src_y);
@ -74,7 +74,7 @@ namespace agg
line_image_pattern(const Filter& filter) :
m_filter(&filter),
m_dilation(filter.dilation() + 1),
m_dilation_hr(m_dilation * line_subpixel_scale),
m_dilation_hr(m_dilation << line_subpixel_shift),
m_data(),
m_width(0),
m_height(0),
@ -86,11 +86,11 @@ namespace agg
// Create
//--------------------------------------------------------------------
template<class Source>
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_dilation_hr(m_dilation << line_subpixel_shift),
m_data(),
m_width(0),
m_height(0),
@ -114,8 +114,8 @@ namespace agg
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_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;
@ -170,8 +170,8 @@ namespace agg
//--------------------------------------------------------------------
void pixel(color_type* p, int x, int y) const
{
m_filter->pixel_high_res(m_buf.rows(),
p,
m_filter->pixel_high_res(m_buf.rows(),
p,
x % m_width_hr + m_dilation_hr,
y + m_offset_y_hr);
}
@ -181,7 +181,7 @@ namespace agg
private:
line_image_pattern(const line_image_pattern<filter_type>&);
const line_image_pattern<filter_type>&
const line_image_pattern<filter_type>&
operator = (const line_image_pattern<filter_type>&);
protected:
@ -203,32 +203,32 @@ namespace agg
//=================================================line_image_pattern_pow2
template<class Filter> class line_image_pattern_pow2 :
template<class Filter> class line_image_pattern_pow2 :
public line_image_pattern<Filter>
{
public:
typedef Filter filter_type;
typedef typename filter_type::color_type color_type;
typedef line_image_pattern<Filter> base_type;
//--------------------------------------------------------------------
line_image_pattern_pow2(const Filter& filter) :
line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask) {}
//--------------------------------------------------------------------
template<class Source>
template<class Source>
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)
{
line_image_pattern<Filter>::create(src);
m_mask = 1;
while(m_mask < base_type::m_width)
while(m_mask < base_type::m_width)
{
m_mask <<= 1;
m_mask |= 1;
@ -242,7 +242,7 @@ namespace agg
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_buf.rows(),
p,
(x & m_mask) + base_type::m_dilation_hr,
y + base_type::m_offset_y_hr);
@ -250,13 +250,13 @@ namespace agg
private:
unsigned m_mask;
};
//===================================================distance_interpolator4
class distance_interpolator4
{
@ -264,7 +264,7 @@ namespace agg
//---------------------------------------------------------------------
distance_interpolator4() {}
distance_interpolator4(int x1, int y1, int x2, int y2,
int sx, int sy, int ex, int ey,
int sx, int sy, int ex, int ey,
int len, double scale, int x, int y) :
m_dx(x2 - x1),
m_dy(y2 - y1),
@ -273,88 +273,88 @@ namespace agg
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) -
m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) -
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 -
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),
m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end -
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))
{
double d = len * scale;
int dx = iround(((x2 - x1) * line_subpixel_scale) / d);
int dy = iround(((y2 - y1) * line_subpixel_scale) / d);
int dx = iround(((x2 - x1) << line_subpixel_shift) / d);
int dy = iround(((y2 - y1) << line_subpixel_shift) / d);
m_dx_pict = -dy;
m_dy_pict = dx;
m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict -
(y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >>
line_subpixel_shift;
m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict -
(y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >>
line_subpixel_shift;
m_dx *= line_subpixel_scale;
m_dy *= line_subpixel_scale;
m_dx_start *= line_mr_subpixel_scale;
m_dy_start *= line_mr_subpixel_scale;
m_dx_end *= line_mr_subpixel_scale;
m_dy_end *= line_mr_subpixel_scale;
m_dx <<= line_subpixel_shift;
m_dy <<= line_subpixel_shift;
m_dx_start <<= line_mr_subpixel_shift;
m_dy_start <<= line_mr_subpixel_shift;
m_dx_end <<= line_mr_subpixel_shift;
m_dy_end <<= line_mr_subpixel_shift;
}
//---------------------------------------------------------------------
void inc_x()
{
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end;
void inc_x()
{
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end;
}
//---------------------------------------------------------------------
void dec_x()
{
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end;
void dec_x()
{
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end;
}
//---------------------------------------------------------------------
void inc_y()
{
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end;
void inc_y()
{
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end;
}
//---------------------------------------------------------------------
void dec_y()
{
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end;
void dec_y()
{
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end;
}
//---------------------------------------------------------------------
void inc_x(int dy)
{
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end;
if(dy > 0)
{
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end;
}
if(dy < 0)
{
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end;
}
}
@ -362,22 +362,22 @@ namespace agg
//---------------------------------------------------------------------
void dec_x(int dy)
{
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end;
if(dy > 0)
{
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end;
}
if(dy < 0)
{
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end;
}
}
@ -385,22 +385,22 @@ namespace agg
//---------------------------------------------------------------------
void inc_y(int dx)
{
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist -= m_dx;
m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end;
if(dx > 0)
{
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end;
}
if(dx < 0)
{
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end;
}
}
@ -408,22 +408,22 @@ namespace agg
//---------------------------------------------------------------------
void dec_y(int dx)
{
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist += m_dx;
m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end;
if(dx > 0)
{
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist += m_dy;
m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end;
}
if(dx < 0)
{
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist -= m_dy;
m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end;
}
}
@ -476,19 +476,20 @@ namespace agg
//---------------------------------------------------------------------
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,
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),
line_dbl_hr(lp.y2 - lp.y1),
lp.vertical ? abs(lp.y2 - lp.y1) :
abs(lp.x2 - lp.x1) + 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),
@ -496,17 +497,17 @@ namespace agg
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_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) :
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)
{
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_shift) :
(lp.dx << agg::line_subpixel_shift),
lp.len);
unsigned i;
@ -536,7 +537,7 @@ namespace agg
m_old_x = m_x;
dist1_start = dist2_start = m_di.dist_start();
dist1_start = dist2_start = m_di.dist_start();
int dx = 0;
if(dist1_start < 0) ++npix;
@ -569,7 +570,7 @@ namespace agg
m_old_y = m_y;
dist1_start = dist2_start = m_di.dist_start();
dist1_start = dist2_start = m_di.dist_start();
int dy = 0;
if(dist1_start < 0) ++npix;
@ -641,7 +642,7 @@ namespace agg
dist_end -= m_di.dx_end();
p1->clear();
if(dist_end > 0 && dist_start <= 0)
{
{
if(m_lp.inc > 0) dist = -dist;
m_ren.pixel(p1, dist_pict, s2 - dist);
++npix;
@ -662,17 +663,17 @@ namespace agg
--p0;
p0->clear();
if(dist_end > 0 && dist_start <= 0)
{
{
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;
}
@ -727,7 +728,7 @@ namespace agg
dist_end += m_di.dy_end();
p1->clear();
if(dist_end > 0 && dist_start <= 0)
{
{
if(m_lp.inc > 0) dist = -dist;
m_ren.pixel(p1, dist_pict, s2 + dist);
++npix;
@ -748,16 +749,16 @@ namespace agg
--p0;
p0->clear();
if(dist_end > 0 && dist_start <= 0)
{
{
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),
m_ren.blend_color_hspan(m_x - dx + 1,
m_y,
unsigned(p1 - p0),
p0);
return npix && ++m_step < m_count;
}
@ -779,7 +780,7 @@ namespace agg
protected:
const line_parameters& m_lp;
dda2_line_interpolator m_li;
distance_interpolator4 m_di;
distance_interpolator4 m_di;
renderer_type& m_ren;
int m_plen;
int m_x;
@ -803,7 +804,7 @@ namespace agg
//===================================================renderer_outline_image
template<class BaseRenderer, class ImagePattern>
template<class BaseRenderer, class ImagePattern>
class renderer_outline_image
{
public:
@ -875,7 +876,7 @@ namespace agg
static bool accurate_join_only() { return true; }
//-------------------------------------------------------------------------
template<class Cmp>
template<class Cmp>
void semidot(Cmp, int, int, int, int)
{
}
@ -901,7 +902,7 @@ namespace agg
}
//-------------------------------------------------------------------------
void line3_no_clip(const line_parameters& lp,
void line3_no_clip(const line_parameters& lp,
int sx, int sy, int ex, int ey)
{
if(lp.len > line_max_length)
@ -914,26 +915,26 @@ namespace agg
line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1);
return;
}
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,
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,
void line3(const line_parameters& lp,
int sx, int sy, int ex, int ey)
{
if(m_clipping)
@ -948,17 +949,17 @@ namespace agg
{
if(flags)
{
line_parameters lp2(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);
sx = x1 + (y2 - y1);
sx = x1 + (y2 - y1);
sy = y1 - (x2 - x1);
}
else
{
while(std::abs(sx - lp.x1) + std::abs(sy - lp.y1) > 1 + lp2.len)
while(abs(sx - lp.x1) + abs(sy - lp.y1) > 1 + lp2.len)
{
sx = (lp.x1 + sx) >> 1;
sy = (lp.y1 + sy) >> 1;
@ -966,12 +967,12 @@ namespace agg
}
if(flags & 2)
{
ex = x2 + (y2 - y1);
ex = x2 + (y2 - y1);
ey = y2 - (x2 - x1);
}
else
{
while(std::abs(ex - lp.x2) + std::abs(ey - lp.y2) > 1 + lp2.len)
while(abs(ex - lp.x2) + abs(ey - lp.y2) > 1 + lp2.len)
{
ex = (lp.x2 + ex) >> 1;
ey = (lp.y2 + ey) >> 1;

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -23,9 +23,9 @@ namespace agg
{
//================================================render_scanline_aa_solid
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_aa_solid(const Scanline& sl,
BaseRenderer& ren,
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_aa_solid(const Scanline& sl,
BaseRenderer& ren,
const ColorT& color)
{
int y = sl.y();
@ -37,14 +37,14 @@ namespace agg
int x = span->x;
if(span->len > 0)
{
ren.blend_solid_hspan(x, y, (unsigned)span->len,
color,
ren.blend_solid_hspan(x, y, (unsigned)span->len,
color,
span->covers);
}
else
{
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
color,
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
color,
*(span->covers));
}
if(--num_spans == 0) break;
@ -53,16 +53,16 @@ namespace agg
}
//===============================================render_scanlines_aa_solid
template<class Rasterizer, class Scanline,
template<class Rasterizer, class Scanline,
class BaseRenderer, class ColorT>
void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl,
void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl,
BaseRenderer& ren, const ColorT& color)
{
if(ras.rewind_scanlines())
{
// Explicitly convert "color" to the BaseRenderer color type.
// For example, it can be called with color type "rgba", while
// "rgba8" is needed. Otherwise it will be implicitly
// "rgba8" is needed. Otherwise it will be implicitly
// converted in the loop many times.
//----------------------
typename BaseRenderer::color_type ren_color(color);
@ -70,7 +70,34 @@ namespace agg
sl.reset(ras.min_x(), ras.max_x());
while(ras.sweep_scanline(sl))
{
render_scanline_aa_solid(sl, ren, ren_color);
//render_scanline_aa_solid(sl, ren, ren_color);
// This code is equivalent to the above call (copy/paste).
// It's just a "manual" optimization for old compilers,
// like Microsoft Visual C++ v6.0
//-------------------------------
int y = sl.y();
unsigned num_spans = sl.num_spans();
typename Scanline::const_iterator span = sl.begin();
for(;;)
{
int x = span->x;
if(span->len > 0)
{
ren.blend_solid_hspan(x, y, (unsigned)span->len,
ren_color,
span->covers);
}
else
{
ren.blend_hline(x, y, (unsigned)(x - span->len - 1),
ren_color,
*(span->covers));
}
if(--num_spans == 0) break;
++span;
}
}
}
}
@ -89,7 +116,7 @@ namespace agg
{
m_ren = &ren;
}
//--------------------------------------------------------------------
void color(const color_type& c) { m_color = c; }
const color_type& color() const { return m_color; }
@ -102,17 +129,28 @@ namespace agg
{
render_scanline_aa_solid(sl, *m_ren, m_color);
}
private:
base_ren_type* m_ren;
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,
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();
@ -128,7 +166,7 @@ namespace agg
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,
ren.blend_color_hspan(x, y, len, colors,
(span->len < 0) ? 0 : covers, *covers);
if(--num_spans == 0) break;
@ -136,38 +174,10 @@ namespace agg
}
}
//======================================================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)
{
int y = sl.y();
unsigned num_spans = sl.num_spans();
typename Scanline::const_iterator span = sl.begin();
for(;;)
{
int x = span->x;
int len = span->len;
const typename Scanline::cover_type* covers = span->covers;
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);
if(--num_spans == 0) break;
++span;
}
}
//=====================================================render_scanlines_aa
template<class Rasterizer, class Scanline, class BaseRenderer,
template<class Rasterizer, class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
SpanAllocator& alloc, SpanGenerator& span_gen)
{
if(ras.rewind_scanlines())
@ -182,7 +192,7 @@ namespace agg
}
//====================================================renderer_scanline_aa
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
class renderer_scanline_aa
{
public:
@ -192,22 +202,22 @@ namespace agg
//--------------------------------------------------------------------
renderer_scanline_aa() : m_ren(0), m_alloc(0), m_span_gen(0) {}
renderer_scanline_aa(base_ren_type& ren,
alloc_type& alloc,
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,
void attach(base_ren_type& ren,
alloc_type& alloc,
span_gen_type& span_gen)
{
m_ren = &ren;
m_alloc = &alloc;
m_span_gen = &span_gen;
}
//--------------------------------------------------------------------
void prepare() { m_span_gen->prepare(); }
@ -224,68 +234,26 @@ namespace agg
};
//====================================================renderer_scanline_aa
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
class renderer_scanline_aa_alpha
{
public:
typedef BaseRenderer base_ren_type;
typedef SpanAllocator alloc_type;
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(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)
{
m_ren = &ren;
m_alloc = &alloc;
m_span_gen = &span_gen;
}
//--------------------------------------------------------------------
void prepare() { m_span_gen->prepare(); }
//--------------------------------------------------------------------
template<class Scanline> void render(const Scanline& sl)
{
render_scanline_aa_alpha(sl, *m_ren, *m_alloc, *m_span_gen, m_alpha);
}
private:
base_ren_type* m_ren;
alloc_type* m_alloc;
span_gen_type* m_span_gen;
unsigned m_alpha;
};
//===============================================render_scanline_bin_solid
template<class Scanline, class BaseRenderer, class ColorT>
void render_scanline_bin_solid(const Scanline& sl,
BaseRenderer& ren,
template<class Scanline, class BaseRenderer, class ColorT>
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,
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;
@ -293,16 +261,16 @@ namespace agg
}
//==============================================render_scanlines_bin_solid
template<class Rasterizer, class Scanline,
template<class Rasterizer, class Scanline,
class BaseRenderer, class ColorT>
void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl,
void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl,
BaseRenderer& ren, const ColorT& color)
{
if(ras.rewind_scanlines())
{
// Explicitly convert "color" to the BaseRenderer color type.
// For example, it can be called with color type "rgba", while
// "rgba8" is needed. Otherwise it will be implicitly
// "rgba8" is needed. Otherwise it will be implicitly
// converted in the loop many times.
//----------------------
typename BaseRenderer::color_type ren_color(color);
@ -312,7 +280,7 @@ namespace agg
{
//render_scanline_bin_solid(sl, ren, ren_color);
// This code is equivalent to the above call (copy/paste).
// This code is equivalent to the above call (copy/paste).
// It's just a "manual" optimization for old compilers,
// like Microsoft Visual C++ v6.0
//-------------------------------
@ -320,12 +288,12 @@ namespace agg
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),
ren_color,
ren.blend_hline(span->x,
sl.y(),
span->x - 1 + ((span->len < 0) ?
-span->len :
span->len),
ren_color,
cover_full);
if(--num_spans == 0) break;
++span;
@ -348,7 +316,7 @@ namespace agg
{
m_ren = &ren;
}
//--------------------------------------------------------------------
void color(const color_type& c) { m_color = c; }
const color_type& color() const { return m_color; }
@ -361,7 +329,7 @@ namespace agg
{
render_scanline_bin_solid(sl, *m_ren, m_color);
}
private:
base_ren_type* m_ren;
color_type m_color;
@ -375,9 +343,9 @@ namespace agg
//======================================================render_scanline_bin
template<class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanline_bin(const Scanline& sl, BaseRenderer& ren,
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();
@ -391,16 +359,16 @@ namespace agg
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);
ren.blend_color_hspan(x, y, len, colors, 0, cover_full);
if(--num_spans == 0) break;
++span;
}
}
//=====================================================render_scanlines_bin
template<class Rasterizer, class Scanline, class BaseRenderer,
template<class Rasterizer, class Scanline, class BaseRenderer,
class SpanAllocator, class SpanGenerator>
void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren,
SpanAllocator& alloc, SpanGenerator& span_gen)
{
if(ras.rewind_scanlines())
@ -415,7 +383,7 @@ namespace agg
}
//====================================================renderer_scanline_bin
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
template<class BaseRenderer, class SpanAllocator, class SpanGenerator>
class renderer_scanline_bin
{
public:
@ -425,22 +393,22 @@ namespace agg
//--------------------------------------------------------------------
renderer_scanline_bin() : m_ren(0), m_alloc(0), m_span_gen(0) {}
renderer_scanline_bin(base_ren_type& ren,
alloc_type& alloc,
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,
void attach(base_ren_type& ren,
alloc_type& alloc,
span_gen_type& span_gen)
{
m_ren = &ren;
m_alloc = &alloc;
m_span_gen = &span_gen;
}
//--------------------------------------------------------------------
void prepare() { m_span_gen->prepare(); }
@ -457,6 +425,14 @@ namespace agg
};
//========================================================render_scanlines
template<class Rasterizer, class Scanline, class Renderer>
void render_scanlines(Rasterizer& ras, Scanline& sl, Renderer& ren)
@ -472,15 +448,14 @@ namespace agg
}
}
//========================================================render_all_paths
template<class Rasterizer, class Scanline, class Renderer,
template<class Rasterizer, class Scanline, class Renderer,
class VertexSource, class ColorStorage, class PathId>
void render_all_paths(Rasterizer& ras,
void render_all_paths(Rasterizer& ras,
Scanline& sl,
Renderer& r,
VertexSource& vs,
const ColorStorage& as,
Renderer& r,
VertexSource& vs,
const ColorStorage& as,
const PathId& path_id,
unsigned num_paths)
{
@ -499,13 +474,13 @@ namespace agg
//=============================================render_scanlines_compound
template<class Rasterizer,
class ScanlineAA,
class ScanlineBin,
class BaseRenderer,
template<class Rasterizer,
class ScanlineAA,
class ScanlineBin,
class BaseRenderer,
class SpanAllocator,
class StyleHandler>
void render_scanlines_compound(Rasterizer& ras,
void render_scanlines_compound(Rasterizer& ras,
ScanlineAA& sl_aa,
ScanlineBin& sl_bin,
BaseRenderer& ren,
@ -552,14 +527,14 @@ namespace agg
for(;;)
{
len = span_aa->len;
sh.generate_span(color_span,
span_aa->x,
sl_aa.y(),
len,
sh.generate_span(color_span,
span_aa->x,
sl_aa.y(),
len,
style);
ren.blend_color_hspan(span_aa->x,
sl_aa.y(),
ren.blend_color_hspan(span_aa->x,
sl_aa.y(),
span_aa->len,
color_span,
span_aa->covers);
@ -579,8 +554,8 @@ namespace agg
num_spans = sl_bin.num_spans();
for(;;)
{
memset(mix_buffer + span_bin->x - min_x,
0,
memset(mix_buffer + span_bin->x - min_x,
0,
span_bin->len * sizeof(color_type));
if(--num_spans == 0) break;
@ -612,7 +587,7 @@ namespace agg
covers = span_aa->covers;
do
{
if(*covers == cover_full)
if(*covers == cover_full)
{
*colors = c;
}
@ -637,15 +612,15 @@ namespace agg
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,
sh.generate_span(cspan,
span_aa->x,
sl_aa.y(),
len,
style);
covers = span_aa->covers;
do
{
if(*covers == cover_full)
if(*covers == cover_full)
{
*colors = *cspan;
}
@ -671,8 +646,8 @@ namespace agg
num_spans = sl_bin.num_spans();
for(;;)
{
ren.blend_color_hspan(span_bin->x,
sl_bin.y(),
ren.blend_color_hspan(span_bin->x,
sl_bin.y(),
span_bin->len,
mix_buffer + span_bin->x - min_x,
0,
@ -687,12 +662,12 @@ namespace agg
}
//=======================================render_scanlines_compound_layered
template<class Rasterizer,
class ScanlineAA,
class BaseRenderer,
template<class Rasterizer,
class ScanlineAA,
class BaseRenderer,
class SpanAllocator,
class StyleHandler>
void render_scanlines_compound_layered(Rasterizer& ras,
void render_scanlines_compound_layered(Rasterizer& ras,
ScanlineAA& sl_aa,
BaseRenderer& ren,
SpanAllocator& alloc,
@ -738,14 +713,14 @@ namespace agg
for(;;)
{
len = span_aa->len;
sh.generate_span(color_span,
span_aa->x,
sl_aa.y(),
len,
sh.generate_span(color_span,
span_aa->x,
sl_aa.y(),
len,
style);
ren.blend_color_hspan(span_aa->x,
sl_aa.y(),
ren.blend_color_hspan(span_aa->x,
sl_aa.y(),
span_aa->len,
color_span,
span_aa->covers);
@ -762,12 +737,12 @@ namespace agg
if(sl_len)
{
memset(mix_buffer + sl_start - min_x,
0,
memset(mix_buffer + sl_start - min_x,
0,
sl_len * sizeof(color_type));
memset(cover_buffer + sl_start - min_x,
0,
memset(cover_buffer + sl_start - min_x,
0,
sl_len * sizeof(cover_type));
int sl_y = 0x7FFFFFFF;
@ -828,10 +803,10 @@ namespace agg
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,
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;
@ -859,8 +834,8 @@ namespace agg
}
}
}
ren.blend_color_hspan(sl_start,
sl_y,
ren.blend_color_hspan(sl_start,
sl_y,
sl_len,
mix_buffer + sl_start - min_x,
0,

View file

@ -56,14 +56,14 @@ namespace agg
//--------------------------------------------------------------------
void attach(T* buf, unsigned width, unsigned height, int stride)
{
m_buf = m_start = buf;
m_width = width;
m_height = height;
m_stride = stride;
if(stride < 0)
m_buf = m_start = buf;
m_width = width;
m_height = height;
m_stride = stride;
if(stride < 0)
{
m_start = m_buf - int(height - 1) * stride;
}
m_start = m_buf - int(height - 1) * stride;
}
}
//--------------------------------------------------------------------
@ -78,13 +78,13 @@ namespace agg
}
//--------------------------------------------------------------------
AGG_INLINE T* row_ptr(int, int y, unsigned)
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
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));
}
@ -128,7 +128,7 @@ namespace agg
private:
//--------------------------------------------------------------------
T* m_buf; // Pointer to rendering buffer
T* m_buf; // Pointer to renrdering buffer
T* m_start; // Pointer to first pixel depending on stride
unsigned m_width; // Width in pixels
unsigned m_height; // Height in pixels
@ -176,10 +176,6 @@ namespace agg
{
m_rows.resize(height);
}
else if(height == 0)
{
return;
}
T* row_ptr = m_buf;
@ -190,11 +186,10 @@ namespace agg
T** rows = &m_rows[0];
while(height > 0)
while(height--)
{
*rows++ = row_ptr;
row_ptr += stride;
--height;
}
}
@ -263,7 +258,7 @@ namespace agg
private:
//--------------------------------------------------------------------
T* m_buf; // Pointer to rendering buffer
T* m_buf; // Pointer to renrdering buffer
pod_array<T*> m_rows; // Pointers to each row of the buffer
unsigned m_width; // Width in pixels
unsigned m_height; // Height in pixels

Some files were not shown because too many files have changed in this diff Show more