sync with latest master/3.x
This commit is contained in:
commit
b55d5def0d
1119 changed files with 26663 additions and 5975 deletions
|
@ -6,7 +6,7 @@ compiler:
|
|||
|
||||
env:
|
||||
matrix:
|
||||
- DEBUG=False ENABLE_LOG=True DEFAULT_LOG_SEVERITY=debug XMLPARSER="libxml2" DEMO=False BENCHMARK=False CUSTOM_CXXFLAGS="" CUSTOM_LDFLAGS=""
|
||||
- DEBUG=False PLUGIN_LINKING=static ENABLE_LOG=True DEFAULT_LOG_SEVERITY=debug XMLPARSER="libxml2" DEMO=False BENCHMARK=False CUSTOM_CXXFLAGS="" CUSTOM_LDFLAGS=""
|
||||
- DEBUG=False ENABLE_LOG=False DEFAULT_LOG_SEVERITY=none XMLPARSER="ptree" DEMO=False BENCHMARK=True CUSTOM_CXXFLAGS="" CUSTOM_LDFLAGS=""
|
||||
|
||||
# travis + ubuntugis with gdal and postggis leads to many potential dead-end conflicts
|
||||
|
|
|
@ -77,3 +77,4 @@ Mapnik is written by Artem Pavlenko with contributions from:
|
|||
* Rich Wareham
|
||||
* Nick Whitelegg
|
||||
* Leslie Wu
|
||||
* Blake Thompson
|
||||
|
|
|
@ -8,6 +8,7 @@ For a complete change history, see the git log.
|
|||
|
||||
## 3.0.0
|
||||
|
||||
- Added new and experimental `dot` symbolizer for fast rendering of points
|
||||
- Improved support for International Text (now uses harfbuzz library for text shaping)
|
||||
- Uses latest c++11 features for better performance (especially map loading)
|
||||
- Expressions everywhere: all symbolizer properties can now be data driven expressions (with the exception of `face-name` and `fontset-name` on the `TextSymbolizer`).
|
||||
|
|
30
SConstruct
30
SConstruct
|
@ -443,6 +443,7 @@ pickle_store = [# Scons internal variables
|
|||
'PYTHON_SYS_PREFIX',
|
||||
'COLOR_PRINT',
|
||||
'HAS_CAIRO',
|
||||
'MAPNIK_HAS_DLFCN',
|
||||
'HAS_PYCAIRO',
|
||||
'HAS_LIBXML2',
|
||||
'PYTHON_IS_64BIT',
|
||||
|
@ -829,6 +830,24 @@ int main()
|
|||
rm_path(item,'CPPPATH',context.env)
|
||||
return ret
|
||||
|
||||
def CheckHasDlfcn(context, silent=False):
|
||||
if not silent:
|
||||
context.Message('Checking for dlfcn.h support ... ')
|
||||
ret = context.TryCompile("""
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
""", '.cpp')
|
||||
if silent:
|
||||
context.did_show_result=1
|
||||
context.Result(ret)
|
||||
return ret
|
||||
|
||||
def GetBoostLibVersion(context):
|
||||
ret = context.TryRun("""
|
||||
|
||||
|
@ -989,6 +1008,7 @@ conf_tests = { 'prioritize_paths' : prioritize_paths,
|
|||
'FindBoost' : FindBoost,
|
||||
'CheckBoost' : CheckBoost,
|
||||
'CheckCairoHasFreetype' : CheckCairoHasFreetype,
|
||||
'CheckHasDlfcn' : CheckHasDlfcn,
|
||||
'GetBoostLibVersion' : GetBoostLibVersion,
|
||||
'parse_config' : parse_config,
|
||||
'parse_pg_config' : parse_pg_config,
|
||||
|
@ -1199,6 +1219,11 @@ if not preconfigured:
|
|||
['harfbuzz', 'harfbuzz/hb.h',True,'C++']
|
||||
]
|
||||
|
||||
if conf.CheckHasDlfcn():
|
||||
env.Append(CPPDEFINES = '-DMAPNIK_HAS_DLCFN')
|
||||
else:
|
||||
env['SKIPPED_DEPS'].extend(['dlfcn'])
|
||||
|
||||
OPTIONAL_LIBSHEADERS = []
|
||||
|
||||
if env['JPEG']:
|
||||
|
@ -1725,8 +1750,8 @@ if not preconfigured:
|
|||
env.Append(CPPDEFINES = ndebug_defines)
|
||||
|
||||
# Common flags for g++/clang++ CXX compiler.
|
||||
# TODO: clean up code more to make -Wextra -Wsign-conversion -Wconversion -Wshadow viable
|
||||
common_cxx_flags = '-Wall -Wsign-compare %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread)
|
||||
# TODO: clean up code more to make -Wextra -Wsign-compare -Wsign-conversion -Wconversion -Wshadow viable
|
||||
common_cxx_flags = '-Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread)
|
||||
|
||||
if 'clang++' in env['CXX']:
|
||||
common_cxx_flags += ' -Wno-unknown-pragmas -Wno-unsequenced '
|
||||
|
@ -1963,6 +1988,7 @@ if not HELP_REQUESTED:
|
|||
|
||||
# build C++ tests
|
||||
SConscript('tests/cpp_tests/build.py')
|
||||
SConscript('tests/cxx/build.py')
|
||||
|
||||
if env['BENCHMARK']:
|
||||
SConscript('benchmark/build.py')
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
return iterations_;
|
||||
}
|
||||
virtual bool validate() const = 0;
|
||||
virtual void operator()() const = 0;
|
||||
virtual bool operator()() const = 0;
|
||||
virtual ~test_case() {}
|
||||
};
|
||||
|
||||
|
@ -85,35 +85,40 @@ int run(T const& test_runner, std::string const& name)
|
|||
std::clog << "test did not validate: " << name << "\n";
|
||||
return -1;
|
||||
}
|
||||
std::chrono::high_resolution_clock::time_point start;
|
||||
std::chrono::high_resolution_clock::duration elapsed;
|
||||
std::stringstream s;
|
||||
s << name << ":"
|
||||
<< std::setw(45 - (int)s.tellp()) << std::right
|
||||
<< " t:" << test_runner.threads()
|
||||
<< " i:" << test_runner.iterations();
|
||||
if (test_runner.threads() > 0)
|
||||
// run test once before timing
|
||||
// if it returns false then we'll abort timing
|
||||
if (test_runner())
|
||||
{
|
||||
using thread_group = std::vector<std::unique_ptr<std::thread> >;
|
||||
using value_type = thread_group::value_type;
|
||||
thread_group tg;
|
||||
for (std::size_t i=0;i<test_runner.threads();++i)
|
||||
std::chrono::high_resolution_clock::time_point start;
|
||||
std::chrono::high_resolution_clock::duration elapsed;
|
||||
std::stringstream s;
|
||||
s << name << ":"
|
||||
<< std::setw(45 - (int)s.tellp()) << std::right
|
||||
<< " t:" << test_runner.threads()
|
||||
<< " i:" << test_runner.iterations();
|
||||
if (test_runner.threads() > 0)
|
||||
{
|
||||
tg.emplace_back(new std::thread(test_runner));
|
||||
using thread_group = std::vector<std::unique_ptr<std::thread> >;
|
||||
using value_type = thread_group::value_type;
|
||||
thread_group tg;
|
||||
for (std::size_t i=0;i<test_runner.threads();++i)
|
||||
{
|
||||
tg.emplace_back(new std::thread(test_runner));
|
||||
}
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
std::for_each(tg.begin(), tg.end(), [](value_type & t) {if (t->joinable()) t->join();});
|
||||
elapsed = std::chrono::high_resolution_clock::now() - start;
|
||||
}
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
std::for_each(tg.begin(), tg.end(), [](value_type & t) {if (t->joinable()) t->join();});
|
||||
elapsed = std::chrono::high_resolution_clock::now() - start;
|
||||
else
|
||||
{
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
test_runner();
|
||||
elapsed = std::chrono::high_resolution_clock::now() - start;
|
||||
}
|
||||
s << std::setw(65 - (int)s.tellp()) << std::right
|
||||
<< std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count() << " milliseconds\n";
|
||||
std::clog << s.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
test_runner();
|
||||
elapsed = std::chrono::high_resolution_clock::now() - start;
|
||||
}
|
||||
s << std::setw(65 - (int)s.tellp()) << std::right
|
||||
<< std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count() << " milliseconds\n";
|
||||
std::clog << s.str();
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace benchmark {
|
|||
std::shared_ptr<image_32> image_ptr2 = std::make_shared<image_32>(reader2->width(),reader2->height());
|
||||
reader2->read(0,0,image_ptr2->data());
|
||||
|
||||
image_data_32 const& dest = image_ptr1->data();
|
||||
image_data_32 const& src = image_ptr2->data();
|
||||
image_data_rgba8 const& dest = image_ptr1->data();
|
||||
image_data_rgba8 const& src = image_ptr2->data();
|
||||
|
||||
unsigned int width = src.width();
|
||||
unsigned int height = src.height();
|
||||
|
|
21
benchmark/data/gdal-wgs.xml
Normal file
21
benchmark/data/gdal-wgs.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map[]>
|
||||
<Map
|
||||
srs="+init=epsg:4326"
|
||||
background-color="#dfd8c9">
|
||||
|
||||
<Style name="style">
|
||||
<Rule>
|
||||
<RasterSymbolizer />
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer name="layer"
|
||||
srs="+init=epsg:4326">
|
||||
<StyleName>style</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="file">./valid.geotiff.tif</Parameter>
|
||||
<Parameter name="type">gdal</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
21
benchmark/data/raster-wgs.xml
Normal file
21
benchmark/data/raster-wgs.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map[]>
|
||||
<Map
|
||||
srs="+init=epsg:4326"
|
||||
background-color="#dfd8c9">
|
||||
|
||||
<Style name="style">
|
||||
<Rule>
|
||||
<RasterSymbolizer />
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer name="layer"
|
||||
srs="+init=epsg:4326">
|
||||
<StyleName>style</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="file">./valid.geotiff.tif</Parameter>
|
||||
<Parameter name="type">raster</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
BIN
benchmark/data/valid.geotiff.tif
Normal file
BIN
benchmark/data/valid.geotiff.tif
Normal file
Binary file not shown.
|
@ -30,3 +30,21 @@ run test_font_registration 10 1000
|
|||
--height 600 \
|
||||
--iterations 20 \
|
||||
--threads 10
|
||||
|
||||
./benchmark/out/test_rendering \
|
||||
--name "gdal tiff rendering" \
|
||||
--map benchmark/data/gdal-wgs.xml \
|
||||
--extent -180.0,-120.0,180.0,120.0 \
|
||||
--width 600 \
|
||||
--height 600 \
|
||||
--iterations 20 \
|
||||
--threads 10
|
||||
|
||||
./benchmark/out/test_rendering \
|
||||
--name "raster tiff rendering" \
|
||||
--map benchmark/data/raster-wgs.xml \
|
||||
--extent -180.0,-120.0,180.0,120.0 \
|
||||
--width 600 \
|
||||
--height 600 \
|
||||
--iterations 20 \
|
||||
--threads 10
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "bench_framework.hpp"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <deque>
|
||||
#include <stdexcept>
|
||||
#include <array>
|
||||
#include <valarray>
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
// NOTE: sizeof(uint8_t) == 1
|
||||
|
@ -49,6 +50,7 @@ public:
|
|||
ensure_zero(data,size_);
|
||||
free(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -65,7 +67,7 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
// NOTE: sizeof(uint8_t) == 1
|
||||
|
@ -74,6 +76,7 @@ public:
|
|||
ensure_zero(data,size_);
|
||||
free(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -90,7 +93,7 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
uint8_t *data = static_cast<uint8_t *>(::operator new(sizeof(uint8_t) * size_));
|
||||
|
@ -98,6 +101,7 @@ public:
|
|||
ensure_zero(data,size_);
|
||||
::operator delete(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -115,7 +119,7 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
uint8_t * data = static_cast<uint8_t*>(::operator new(sizeof(uint8_t)*size_));
|
||||
|
@ -123,6 +127,7 @@ public:
|
|||
ensure_zero(data,size_);
|
||||
::operator delete(data),data=0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -139,12 +144,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::vector<uint8_t> data(size_);
|
||||
ensure_zero(&data[0],data.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -162,13 +168,14 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::vector<uint8_t> data(0);
|
||||
data.resize(size_,0);
|
||||
ensure_zero(&data[0],data.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -186,13 +193,68 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::vector<uint8_t> data(0);
|
||||
data.assign(size_,0);
|
||||
ensure_zero(&data[0],data.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class test3d : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test3d(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::deque<uint8_t> data(size_);
|
||||
for (std::size_t i=0;i<size_;++i) {
|
||||
if (data[i] != 0) {
|
||||
throw std::runtime_error("found non zero value");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class test3d : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test3d(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::deque<uint8_t> data(size_);
|
||||
for (std::size_t i=0;i<size_;++i) {
|
||||
if (data[i] != 0) {
|
||||
throw std::runtime_error("found non zero value");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -209,13 +271,14 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
uint8_t *data = (uint8_t *)calloc(size_,sizeof(uint8_t));
|
||||
ensure_zero(data,size_);
|
||||
free(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -232,12 +295,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::string data(array_.begin(),array_.end());
|
||||
ensure_zero((uint8_t *)&data[0],size_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -254,12 +318,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::string data(&array_[0],array_.size());
|
||||
ensure_zero((uint8_t *)&data[0],size_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -281,12 +346,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
std::valarray<uint8_t> data(static_cast<uint8_t>(0),static_cast<size_t>(size_));
|
||||
ensure_zero(&data[0],size_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -307,12 +373,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
boost::container::static_vector<uint8_t,256*256> data(size_,0);
|
||||
ensure_zero(&data[0],size_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
@ -353,6 +420,10 @@ int main(int argc, char** argv)
|
|||
test3c test_runner(params);
|
||||
run(test_runner,"vector/assign");
|
||||
}
|
||||
{
|
||||
test3d test_runner(params);
|
||||
run(test_runner,"deque(N)");
|
||||
}
|
||||
{
|
||||
test5 test_runner(params);
|
||||
run(test_runner,"std::string range");
|
||||
|
|
|
@ -22,11 +22,12 @@ public:
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
}
|
||||
return count == expected_count;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::size_t expected_count = mapnik::freetype_engine::face_names().size();
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
|
@ -49,6 +49,7 @@ public:
|
|||
std::clog << "warning: face creation not working as expected\n";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
{
|
||||
return mapnik::freetype_engine::register_fonts("./fonts", true);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
unsigned long count = 0;
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
|
@ -20,6 +20,7 @@ public:
|
|||
mapnik::freetype_engine::register_fonts("./fonts", true);
|
||||
count++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class test : public benchmark::test_case
|
||||
{
|
||||
mapnik::image_data_32 im_;
|
||||
mapnik::image_data_rgba8 im_;
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
|
@ -13,7 +13,7 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
|
@ -21,6 +21,7 @@ public:
|
|||
out = mapnik::save_to_string(im_,"png8:m=h:z=1");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
BENCHMARK(test,"encoding blank png")
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
mapnik::save_to_file(im_->data(),actual, "png8:m=h:z=1");
|
||||
return benchmark::compare_images(actual,expected);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
|
@ -31,6 +31,7 @@ public:
|
|||
out = mapnik::save_to_string(im_->data(),"png8:m=h:z=1");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
BENCHMARK(test,"encoding multicolor png")
|
||||
|
|
|
@ -54,7 +54,7 @@ void render(mapnik::geometry_type & geom,
|
|||
ras.add_path(path);
|
||||
agg::scanline_u8 sl;
|
||||
agg::render_scanlines(ras, sl, ren);
|
||||
mapnik::save_to_file(im,name);
|
||||
mapnik::save_to_file(im.data(),name);
|
||||
geom.rewind(0);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
render(geom2,geom.envelope(),actual);
|
||||
return benchmark::compare_images(actual,expect);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
boost::ptr_vector<mapnik::geometry_type> paths;
|
||||
if (!mapnik::from_wkt(wkt_in_, paths))
|
||||
|
@ -130,6 +130,7 @@ public:
|
|||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -189,7 +190,7 @@ public:
|
|||
render(geom2,geom.envelope(),actual);
|
||||
return benchmark::compare_images(actual,expect);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
boost::ptr_vector<mapnik::geometry_type> paths;
|
||||
if (!mapnik::from_wkt(wkt_in_, paths))
|
||||
|
@ -217,6 +218,7 @@ public:
|
|||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -265,7 +267,7 @@ public:
|
|||
render(geom2,geom.envelope(),actual);
|
||||
return benchmark::compare_images(actual,expect);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
boost::ptr_vector<mapnik::geometry_type> paths;
|
||||
if (!mapnik::from_wkt(wkt_in_, paths))
|
||||
|
@ -282,6 +284,7 @@ public:
|
|||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ public:
|
|||
mapnik::image_32 im(m.width(),m.height());
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(m,im);
|
||||
ren.apply();
|
||||
//mapnik::save_to_file(im,"test.png");
|
||||
//mapnik::save_to_file(im.data(),"test.png");
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
mapnik::Map m(256,256);
|
||||
mapnik::load_map(m,xml_);
|
||||
|
@ -39,6 +39,7 @@ public:
|
|||
mapnik::agg_renderer<mapnik::image_32> ren(m,im);
|
||||
ren.apply();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
(std::fabs(bbox.maxy() - to_.maxy()) < .5)
|
||||
);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (int i=-180;i<180;i=i+5)
|
||||
|
@ -51,6 +51,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -58,11 +58,17 @@ public:
|
|||
mapnik::image_32 im(m.width(),m.height());
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(m,im,scale_factor_);
|
||||
ren.apply();
|
||||
if (!preview_.empty()) mapnik::save_to_file(im,preview_);
|
||||
if (!preview_.empty()) {
|
||||
std::clog << "preview available at " << preview_ << "\n";
|
||||
mapnik::save_to_file(im.data(),preview_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
if (!preview_.empty()) {
|
||||
return false;
|
||||
}
|
||||
mapnik::Map m(width_,height_);
|
||||
mapnik::load_map(m,xml_);
|
||||
if (extent_.valid()) {
|
||||
|
@ -76,6 +82,7 @@ public:
|
|||
mapnik::agg_renderer<mapnik::image_32> ren(m,im,scale_factor_);
|
||||
ren.apply();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,13 +26,7 @@ template <typename Renderer> void process_layers(Renderer & ren,
|
|||
if (lyr.visible(scale_denom))
|
||||
{
|
||||
std::set<std::string> names;
|
||||
mapnik::parameters p;
|
||||
p["type"]="csv";
|
||||
p["file"]="benchmark/data/roads.csv";
|
||||
mapnik::datasource_ptr ds = mapnik::datasource_cache::instance().create(p);
|
||||
mapnik::layer l(lyr);
|
||||
l.set_datasource(ds);
|
||||
l.add_style("labels");
|
||||
ren.apply_to_layer(l,
|
||||
ren,
|
||||
map_proj,
|
||||
|
@ -56,6 +50,7 @@ class test : public benchmark::test_case
|
|||
std::shared_ptr<mapnik::Map> m_;
|
||||
double scale_factor_;
|
||||
std::string preview_;
|
||||
mutable mapnik::image_32 im_;
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
|
@ -65,7 +60,8 @@ public:
|
|||
height_(*params.get<mapnik::value_integer>("height",256)),
|
||||
m_(new mapnik::Map(width_,height_)),
|
||||
scale_factor_(*params.get<mapnik::value_double>("scale_factor",2.0)),
|
||||
preview_(*params.get<std::string>("preview",""))
|
||||
preview_(*params.get<std::string>("preview","")),
|
||||
im_(m_->width(),m_->height())
|
||||
{
|
||||
boost::optional<std::string> map = params.get<std::string>("map");
|
||||
if (!map)
|
||||
|
@ -75,6 +71,7 @@ public:
|
|||
xml_ = *map;
|
||||
|
||||
boost::optional<std::string> ext = params.get<std::string>("extent");
|
||||
mapnik::load_map(*m_,xml_,true);
|
||||
if (ext && !ext->empty())
|
||||
{
|
||||
if (!extent_.from_string(*ext))
|
||||
|
@ -82,51 +79,67 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("please provide a --extent=<minx,miny,maxx,maxy> arg");
|
||||
m_->zoom_all();
|
||||
extent_ = m_->get_current_extent();
|
||||
std::clog << "Defaulting to max extent " << extent_ << "\n";
|
||||
std::clog << " (pass --extent=<minx,miny,maxx,maxy> to restrict bounds)\n";
|
||||
}
|
||||
mapnik::load_map(*m_,xml_,true);
|
||||
}
|
||||
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::request m_req(width_,height_,extent_);
|
||||
mapnik::image_32 im(m_->width(),m_->height());
|
||||
mapnik::attributes variables;
|
||||
m_req.set_buffer_size(m_->buffer_size());
|
||||
mapnik::projection map_proj(m_->srs(),true);
|
||||
double scale_denom = mapnik::scale_denominator(m_req.scale(),map_proj.is_geographic());
|
||||
scale_denom *= scale_factor_;
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(*m_,m_req,variables,im,scale_factor_);
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(*m_,m_req,variables,im_,scale_factor_);
|
||||
ren.start_map_processing(*m_);
|
||||
std::vector<mapnik::layer> const& layers = m_->layers();
|
||||
process_layers(ren,m_req,map_proj,layers,scale_denom);
|
||||
ren.end_map_processing(*m_);
|
||||
if (!preview_.empty()) {
|
||||
std::clog << "preview available at " << preview_ << "\n";
|
||||
mapnik::save_to_file(im,preview_);
|
||||
mapnik::save_to_file(im_.data(),preview_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
if (preview_.empty()) {
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
{
|
||||
mapnik::request m_req(width_,height_,extent_);
|
||||
mapnik::image_32 im(m_->width(),m_->height());
|
||||
mapnik::attributes variables;
|
||||
m_req.set_buffer_size(m_->buffer_size());
|
||||
mapnik::projection map_proj(m_->srs(),true);
|
||||
double scale_denom = mapnik::scale_denominator(m_req.scale(),map_proj.is_geographic());
|
||||
scale_denom *= scale_factor_;
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(*m_,m_req,variables,im,scale_factor_);
|
||||
ren.start_map_processing(*m_);
|
||||
std::vector<mapnik::layer> const& layers = m_->layers();
|
||||
process_layers(ren,m_req,map_proj,layers,scale_denom);
|
||||
ren.end_map_processing(*m_);
|
||||
}
|
||||
if (!preview_.empty()) {
|
||||
return false;
|
||||
}
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
{
|
||||
mapnik::request m_req(width_,height_,extent_);
|
||||
mapnik::image_32 im(m_->width(),m_->height());
|
||||
mapnik::attributes variables;
|
||||
m_req.set_buffer_size(m_->buffer_size());
|
||||
mapnik::projection map_proj(m_->srs(),true);
|
||||
double scale_denom = mapnik::scale_denominator(m_req.scale(),map_proj.is_geographic());
|
||||
scale_denom *= scale_factor_;
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(*m_,m_req,variables,im,scale_factor_);
|
||||
ren.start_map_processing(*m_);
|
||||
std::vector<mapnik::layer> const& layers = m_->layers();
|
||||
process_layers(ren,m_req,map_proj,layers,scale_denom);
|
||||
ren.end_map_processing(*m_);
|
||||
bool diff = false;
|
||||
mapnik::image_data_rgba8 const& dest = im.data();
|
||||
mapnik::image_data_rgba8 const& src = im_.data();
|
||||
for (unsigned int y = 0; y < height_; ++y)
|
||||
{
|
||||
const unsigned int* row_from = src.getRow(y);
|
||||
const unsigned int* row_to = dest.getRow(y);
|
||||
for (unsigned int x = 0; x < width_; ++x)
|
||||
{
|
||||
if (row_from[x] != row_to[x]) diff = true;
|
||||
}
|
||||
}
|
||||
if (diff) throw std::runtime_error("images differ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@ public:
|
|||
mapnik::util::string2bool(value_,result);
|
||||
return (result == true);
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
bool result = false;
|
||||
mapnik::util::string2bool(value_,result);
|
||||
mapnik::util::string2bool(value_.data(),value_.data()+value_.size(),result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,13 +18,14 @@ public:
|
|||
if (result != 1.23456789) return false;
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
double result = 0;
|
||||
mapnik::util::string2double(value_,result);
|
||||
mapnik::util::string2double(value_.data(),value_.data()+value_.size(),result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,13 +18,14 @@ public:
|
|||
if (result != 123456789) return false;
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
mapnik::value_integer result = 0;
|
||||
mapnik::util::string2int(value_,result);
|
||||
mapnik::util::string2int(value_.data(),value_.data()+value_.size(),result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -14,13 +14,14 @@ public:
|
|||
mapnik::util::to_string(s,value_);
|
||||
return (s == "-0.1234");
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
out.clear();
|
||||
mapnik::util::to_string(out,value_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
s << value_;
|
||||
return (s.str() == "-0.1234");
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
|
@ -22,6 +22,7 @@ public:
|
|||
s << value_;
|
||||
out = s.str();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,13 +23,14 @@ public:
|
|||
utf32[3] != 0x5dd) return false;
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::u32string utf32;
|
||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
utf32 = utf32conv.from_bytes(utf8_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -52,12 +53,13 @@ public:
|
|||
utf32[3] != 0x5dd) return false;
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
std::u32string utf32;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -80,13 +82,14 @@ public:
|
|||
utf32[3] != 0x5dd) return false;
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
bool operator()() const
|
||||
{
|
||||
mapnik::transcoder tr_("utf-8");
|
||||
mapnik::value_unicode_string utf32;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
utf32 = tr_.transcode(utf8_.data(),utf8_.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# This file is part of Mapnik (c++ mapping toolkit)
|
||||
#
|
||||
# Copyright (C) 2013 Artem Pavlenko
|
||||
# Copyright (C) 2014 Artem Pavlenko
|
||||
#
|
||||
# Mapnik is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -208,4 +208,3 @@ if 'uninstall' not in COMMAND_LINE_TARGETS:
|
|||
|
||||
env['create_uninstall_target'](env, target_path)
|
||||
env['create_uninstall_target'](env, target_path_deprecated)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# This file is part of Mapnik (C++/Python mapping toolkit)
|
||||
# Copyright (C) 2009 Artem Pavlenko
|
||||
# Copyright (C) 2014 Artem Pavlenko
|
||||
#
|
||||
# Mapnik is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# This file is part of Mapnik (C++/Python mapping toolkit)
|
||||
# Copyright (C) 2011 Artem Pavlenko
|
||||
# Copyright (C) 2014 Artem Pavlenko
|
||||
#
|
||||
# Mapnik is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -44,6 +44,7 @@
|
|||
// cairo
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
#include <mapnik/cairo/cairo_context.hpp>
|
||||
#include <mapnik/cairo/cairo_image_util.hpp>
|
||||
#include <pycairo.h>
|
||||
#include <cairo.h>
|
||||
#endif
|
||||
|
@ -53,7 +54,6 @@ using mapnik::image_reader;
|
|||
using mapnik::get_image_reader;
|
||||
using mapnik::type_from_filename;
|
||||
using mapnik::save_to_file;
|
||||
using mapnik::save_to_string;
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
|
@ -73,7 +73,7 @@ PyObject* tostring1( image_32 const& im)
|
|||
// encode (png,jpeg)
|
||||
PyObject* tostring2(image_32 const & im, std::string const& format)
|
||||
{
|
||||
std::string s = save_to_string(im, format);
|
||||
std::string s = mapnik::save_to_string(im.data(), format);
|
||||
return
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
::PyBytes_FromStringAndSize
|
||||
|
@ -85,7 +85,7 @@ PyObject* tostring2(image_32 const & im, std::string const& format)
|
|||
|
||||
PyObject* tostring3(image_32 const & im, std::string const& format, mapnik::rgba_palette const& pal)
|
||||
{
|
||||
std::string s = save_to_string(im, format, pal);
|
||||
std::string s = mapnik::save_to_string(im.data(), format, pal);
|
||||
return
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
::PyBytes_FromStringAndSize
|
||||
|
@ -98,17 +98,17 @@ PyObject* tostring3(image_32 const & im, std::string const& format, mapnik::rgba
|
|||
|
||||
void save_to_file1(mapnik::image_32 const& im, std::string const& filename)
|
||||
{
|
||||
save_to_file(im,filename);
|
||||
save_to_file(im.data(),filename);
|
||||
}
|
||||
|
||||
void save_to_file2(mapnik::image_32 const& im, std::string const& filename, std::string const& type)
|
||||
{
|
||||
save_to_file(im,filename,type);
|
||||
save_to_file(im.data(),filename,type);
|
||||
}
|
||||
|
||||
void save_to_file3(mapnik::image_32 const& im, std::string const& filename, std::string const& type, mapnik::rgba_palette const& pal)
|
||||
{
|
||||
save_to_file(im,filename,type,pal);
|
||||
save_to_file(im.data(),filename,type,pal);
|
||||
}
|
||||
|
||||
bool painted(mapnik::image_32 const& im)
|
||||
|
@ -120,12 +120,12 @@ bool is_solid(mapnik::image_32 const& im)
|
|||
{
|
||||
if (im.width() > 0 && im.height() > 0)
|
||||
{
|
||||
mapnik::image_data_32 const & data = im.data();
|
||||
mapnik::image_data_32::pixel_type const* first_row = data.getRow(0);
|
||||
mapnik::image_data_32::pixel_type const first_pixel = first_row[0];
|
||||
mapnik::image_data_rgba8 const & data = im.data();
|
||||
mapnik::image_data_rgba8::pixel_type const* first_row = data.getRow(0);
|
||||
mapnik::image_data_rgba8::pixel_type const first_pixel = first_row[0];
|
||||
for (unsigned y = 0; y < im.height(); ++y)
|
||||
{
|
||||
mapnik::image_data_32::pixel_type const * row = data.getRow(y);
|
||||
mapnik::image_data_rgba8::pixel_type const * row = data.getRow(y);
|
||||
for (unsigned x = 0; x < im.width(); ++x)
|
||||
{
|
||||
if (first_pixel != row[x])
|
||||
|
@ -142,7 +142,7 @@ unsigned get_pixel(mapnik::image_32 const& im, int x, int y)
|
|||
{
|
||||
if (x < static_cast<int>(im.width()) && y < static_cast<int>(im.height()))
|
||||
{
|
||||
mapnik::image_data_32 const & data = im.data();
|
||||
mapnik::image_data_rgba8 const & data = im.data();
|
||||
return data(x,y);
|
||||
}
|
||||
PyErr_SetString(PyExc_IndexError, "invalid x,y for image dimensions");
|
||||
|
@ -217,7 +217,8 @@ void composite(image_32 & dst, image_32 & src, mapnik::composite_mode_e mode, fl
|
|||
std::shared_ptr<image_32> from_cairo(PycairoSurface* py_surface)
|
||||
{
|
||||
mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer());
|
||||
std::shared_ptr<image_32> image_ptr = std::make_shared<image_32>(surface);
|
||||
std::shared_ptr<image_32> image_ptr = std::make_shared<image_32>(cairo_image_surface_get_width(&*surface), cairo_image_surface_get_height(&*surface));
|
||||
cairo_image_to_rgba8(image_ptr->data(), surface);
|
||||
return image_ptr;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -42,18 +42,18 @@
|
|||
#include <mapnik/image_view.hpp>
|
||||
#include <sstream>
|
||||
|
||||
using mapnik::image_data_32;
|
||||
using mapnik::image_data_rgba8;
|
||||
using mapnik::image_view;
|
||||
using mapnik::save_to_file;
|
||||
|
||||
// output 'raw' pixels
|
||||
PyObject* view_tostring1(image_view<image_data_32> const& view)
|
||||
PyObject* view_tostring1(image_view<image_data_rgba8> const& view)
|
||||
{
|
||||
std::ostringstream ss(std::ios::out|std::ios::binary);
|
||||
for (unsigned i=0;i<view.height();i++)
|
||||
{
|
||||
ss.write(reinterpret_cast<const char*>(view.getRow(i)),
|
||||
view.width() * sizeof(image_view<image_data_32>::pixel_type));
|
||||
view.width() * sizeof(image_view<image_data_rgba8>::pixel_type));
|
||||
}
|
||||
return
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
|
@ -65,7 +65,7 @@ PyObject* view_tostring1(image_view<image_data_32> const& view)
|
|||
}
|
||||
|
||||
// encode (png,jpeg)
|
||||
PyObject* view_tostring2(image_view<image_data_32> const & view, std::string const& format)
|
||||
PyObject* view_tostring2(image_view<image_data_rgba8> const & view, std::string const& format)
|
||||
{
|
||||
std::string s = save_to_string(view, format);
|
||||
return
|
||||
|
@ -77,7 +77,7 @@ PyObject* view_tostring2(image_view<image_data_32> const & view, std::string con
|
|||
(s.data(),s.size());
|
||||
}
|
||||
|
||||
PyObject* view_tostring3(image_view<image_data_32> const & view, std::string const& format, mapnik::rgba_palette const& pal)
|
||||
PyObject* view_tostring3(image_view<image_data_rgba8> const & view, std::string const& format, mapnik::rgba_palette const& pal)
|
||||
{
|
||||
std::string s = save_to_string(view, format, pal);
|
||||
return
|
||||
|
@ -89,15 +89,15 @@ PyObject* view_tostring3(image_view<image_data_32> const & view, std::string con
|
|||
(s.data(),s.size());
|
||||
}
|
||||
|
||||
bool is_solid(image_view<image_data_32> const& view)
|
||||
bool is_solid(image_view<image_data_rgba8> const& view)
|
||||
{
|
||||
if (view.width() > 0 && view.height() > 0)
|
||||
{
|
||||
mapnik::image_view<image_data_32>::pixel_type const* first_row = view.getRow(0);
|
||||
mapnik::image_view<image_data_32>::pixel_type const first_pixel = first_row[0];
|
||||
mapnik::image_view<image_data_rgba8>::pixel_type const* first_row = view.getRow(0);
|
||||
mapnik::image_view<image_data_rgba8>::pixel_type const first_pixel = first_row[0];
|
||||
for (unsigned y = 0; y < view.height(); ++y)
|
||||
{
|
||||
mapnik::image_view<image_data_32>::pixel_type const * row = view.getRow(y);
|
||||
mapnik::image_view<image_data_rgba8>::pixel_type const * row = view.getRow(y);
|
||||
for (unsigned x = 0; x < view.width(); ++x)
|
||||
{
|
||||
if (first_pixel != row[x])
|
||||
|
@ -110,20 +110,20 @@ bool is_solid(image_view<image_data_32> const& view)
|
|||
return true;
|
||||
}
|
||||
|
||||
void save_view1(image_view<image_data_32> const& view,
|
||||
void save_view1(image_view<image_data_rgba8> const& view,
|
||||
std::string const& filename)
|
||||
{
|
||||
save_to_file(view,filename);
|
||||
}
|
||||
|
||||
void save_view2(image_view<image_data_32> const& view,
|
||||
void save_view2(image_view<image_data_rgba8> const& view,
|
||||
std::string const& filename,
|
||||
std::string const& type)
|
||||
{
|
||||
save_to_file(view,filename,type);
|
||||
}
|
||||
|
||||
void save_view3(image_view<image_data_32> const& view,
|
||||
void save_view3(image_view<image_data_rgba8> const& view,
|
||||
std::string const& filename,
|
||||
std::string const& type,
|
||||
mapnik::rgba_palette const& pal)
|
||||
|
@ -135,9 +135,9 @@ void save_view3(image_view<image_data_32> const& view,
|
|||
void export_image_view()
|
||||
{
|
||||
using namespace boost::python;
|
||||
class_<image_view<image_data_32> >("ImageView","A view into an image.",no_init)
|
||||
.def("width",&image_view<image_data_32>::width)
|
||||
.def("height",&image_view<image_data_32>::height)
|
||||
class_<image_view<image_data_rgba8> >("ImageView","A view into an image.",no_init)
|
||||
.def("width",&image_view<image_data_rgba8>::width)
|
||||
.def("height",&image_view<image_data_rgba8>::height)
|
||||
.def("is_solid",&is_solid)
|
||||
.def("tostring",&view_tostring1)
|
||||
.def("tostring",&view_tostring2)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -162,6 +162,11 @@ mapnik::parameter get_params_by_index(mapnik::parameters const& p, int index)
|
|||
throw boost::python::error_already_set();
|
||||
}
|
||||
|
||||
unsigned get_params_size(mapnik::parameters const& p)
|
||||
{
|
||||
return p.size();
|
||||
}
|
||||
|
||||
void add_parameter(mapnik::parameters & p, mapnik::parameter const& param)
|
||||
{
|
||||
p[param.first] = param.second;
|
||||
|
@ -191,6 +196,12 @@ std::shared_ptr<mapnik::parameter> create_parameter(mapnik::value_unicode_string
|
|||
return std::make_shared<mapnik::parameter>(key_utf8,value);
|
||||
}
|
||||
|
||||
bool contains(mapnik::parameters const& p, std::string const& key)
|
||||
{
|
||||
parameters::const_iterator pos = p.find(key);
|
||||
return pos != p.end();
|
||||
}
|
||||
|
||||
// needed for Python_Unicode to std::string (utf8) conversion
|
||||
|
||||
std::shared_ptr<mapnik::parameter> create_parameter_from_string(mapnik::value_unicode_string const& key, mapnik::value_unicode_string const& ustr)
|
||||
|
@ -227,7 +238,8 @@ void export_parameters()
|
|||
.def("get",get_params_by_key1)
|
||||
.def("__getitem__",get_params_by_key2)
|
||||
.def("__getitem__",get_params_by_index)
|
||||
.def("__len__",¶meters::size)
|
||||
.def("__len__",get_params_size)
|
||||
.def("__contains__",contains)
|
||||
.def("append",add_parameter)
|
||||
.def("iteritems",iterator<parameters>())
|
||||
;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2009 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -28,7 +28,6 @@
|
|||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wunused-local-typedef"
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
|
||||
#include "python_to_value.hpp"
|
||||
#include <boost/python/args.hpp> // for keywords, arg, etc
|
||||
#include <boost/python/converter/from_python.hpp>
|
||||
|
@ -202,13 +201,16 @@ void render(mapnik::Map const& map,
|
|||
|
||||
void render_with_vars(mapnik::Map const& map,
|
||||
mapnik::image_32& image,
|
||||
boost::python::dict const& d)
|
||||
boost::python::dict const& d,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0u,
|
||||
unsigned offset_y = 0u)
|
||||
{
|
||||
mapnik::attributes vars = mapnik::dict2attr(d);
|
||||
mapnik::request req(map.width(),map.height(),map.get_current_extent());
|
||||
req.set_buffer_size(map.buffer_size());
|
||||
python_unblock_auto_block b;
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(map,req,vars,image,1,0,0);
|
||||
mapnik::agg_renderer<mapnik::image_32> ren(map,req,vars,image,scale_factor,offset_x,offset_y);
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
@ -385,7 +387,7 @@ void render_to_file1(mapnik::Map const& map,
|
|||
{
|
||||
mapnik::image_32 image(map.width(),map.height());
|
||||
render(map,image,1.0,0,0);
|
||||
mapnik::save_to_file(image,filename,format);
|
||||
mapnik::save_to_file(image.data(),filename,format);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +406,7 @@ void render_to_file2(mapnik::Map const& map,std::string const& filename)
|
|||
{
|
||||
mapnik::image_32 image(map.width(),map.height());
|
||||
render(map,image,1.0,0,0);
|
||||
mapnik::save_to_file(image,filename);
|
||||
mapnik::save_to_file(image.data(),filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +444,7 @@ void render_to_file3(mapnik::Map const& map,
|
|||
{
|
||||
mapnik::image_32 image(map.width(),map.height());
|
||||
render(map,image,scale_factor,0,0);
|
||||
mapnik::save_to_file(image,filename,format);
|
||||
mapnik::save_to_file(image.data(),filename,format);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,12 +582,15 @@ bool has_pycairo()
|
|||
}
|
||||
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-local-typedef"
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_overloads, load_map, 2, 4)
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_string_overloads, load_map_string, 2, 4)
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3)
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2)
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(render_overloads, render, 2, 5)
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(render_with_detector_overloads, render_with_detector, 3, 6)
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
BOOST_PYTHON_MODULE(_mapnik)
|
||||
{
|
||||
|
@ -707,7 +712,15 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
"\n"
|
||||
);
|
||||
|
||||
def("render_with_vars",&render_with_vars);
|
||||
def("render_with_vars",&render_with_vars,
|
||||
(arg("map"),
|
||||
arg("image"),
|
||||
arg("vars"),
|
||||
arg("scale_factor")=1.0,
|
||||
arg("offset_x")=0,
|
||||
arg("offset_y")=0
|
||||
)
|
||||
);
|
||||
|
||||
def("render", &render, render_overloads(
|
||||
"\n"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2010 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -105,7 +105,7 @@ std::shared_ptr<mapnik::symbolizer_base::value_type> numeric_wrapper(const objec
|
|||
return result;
|
||||
}
|
||||
|
||||
struct extract_python_object : public mapnik::util::static_visitor<boost::python::object>
|
||||
struct extract_python_object
|
||||
{
|
||||
using result_type = boost::python::object;
|
||||
|
||||
|
@ -153,7 +153,7 @@ std::size_t hash_impl_2(T const& sym)
|
|||
return mapnik::symbolizer_hash::value<T>(sym);
|
||||
}
|
||||
|
||||
struct extract_underlying_type_visitor : mapnik::util::static_visitor<boost::python::object>
|
||||
struct extract_underlying_type_visitor
|
||||
{
|
||||
template <typename T>
|
||||
boost::python::object operator() (T const& sym) const
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
namespace boost { namespace python {
|
||||
|
||||
struct value_converter : public mapnik::util::static_visitor<PyObject*>
|
||||
struct value_converter
|
||||
{
|
||||
PyObject * operator() (mapnik::value_integer val) const
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2009 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2014 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2007 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -23,7 +23,7 @@
|
|||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
|
||||
// boost::optional<T> to/from converter from John Wiegley
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct register_python_conversion
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
struct python_optional : public mapnik::noncopyable
|
||||
struct python_optional : public mapnik::util::noncopyable
|
||||
{
|
||||
struct optional_to_python
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ struct python_optional : public mapnik::noncopyable
|
|||
|
||||
// to/from boost::optional<bool>
|
||||
template <>
|
||||
struct python_optional<float> : public mapnik::noncopyable
|
||||
struct python_optional<float> : public mapnik::util::noncopyable
|
||||
{
|
||||
struct optional_to_python
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ struct python_optional<float> : public mapnik::noncopyable
|
|||
|
||||
// to/from boost::optional<float>
|
||||
template <>
|
||||
struct python_optional<bool> : public mapnik::noncopyable
|
||||
struct python_optional<bool> : public mapnik::util::noncopyable
|
||||
{
|
||||
struct optional_to_python
|
||||
{
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
static mapnik::attributes dict2attr(boost::python::dict const& d)
|
||||
|
@ -46,7 +45,26 @@ namespace mapnik {
|
|||
boost::python::list keys=d.keys();
|
||||
for (int i=0; i < len(keys); ++i)
|
||||
{
|
||||
std::string key = extract<std::string>(keys[i]);
|
||||
std::string key;
|
||||
object obj_key = keys[i];
|
||||
if (PyUnicode_Check(obj_key.ptr()))
|
||||
{
|
||||
PyObject* temp = PyUnicode_AsUTF8String(obj_key.ptr());
|
||||
if (temp)
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
char* c_str = PyBytes_AsString(temp);
|
||||
#else
|
||||
char* c_str = PyString_AsString(temp);
|
||||
#endif
|
||||
key = c_str;
|
||||
Py_DecRef(temp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key = extract<std::string>(keys[i]);
|
||||
}
|
||||
object obj = d[key];
|
||||
if (PyUnicode_Check(obj.ptr()))
|
||||
{
|
||||
|
@ -64,29 +82,37 @@ namespace mapnik {
|
|||
continue;
|
||||
}
|
||||
|
||||
extract<std::string> ex0(obj);
|
||||
if (ex0.check())
|
||||
if (PyBool_Check(obj.ptr()))
|
||||
{
|
||||
vars[key] = tr_.transcode(ex0().c_str());
|
||||
continue;
|
||||
extract<mapnik::value_bool> ex(obj);
|
||||
if (ex.check())
|
||||
{
|
||||
vars[key] = ex();
|
||||
}
|
||||
}
|
||||
extract<mapnik::value_integer> ex2(obj);
|
||||
if (ex2.check())
|
||||
else if (PyFloat_Check(obj.ptr()))
|
||||
{
|
||||
vars[key] = ex2();
|
||||
continue;
|
||||
extract<mapnik::value_double> ex(obj);
|
||||
if (ex.check())
|
||||
{
|
||||
vars[key] = ex();
|
||||
}
|
||||
}
|
||||
extract<double> ex3(obj);
|
||||
if (ex3.check())
|
||||
else
|
||||
{
|
||||
vars[key] = ex3();
|
||||
continue;
|
||||
}
|
||||
extract<mapnik::value_bool> ex1(obj);
|
||||
if (ex1.check())
|
||||
{
|
||||
vars[key] = ex1();
|
||||
continue;
|
||||
extract<mapnik::value_integer> ex(obj);
|
||||
if (ex.check())
|
||||
{
|
||||
vars[key] = ex();
|
||||
}
|
||||
else
|
||||
{
|
||||
extract<std::string> ex0(obj);
|
||||
if (ex0.check())
|
||||
{
|
||||
vars[key] = tr_.transcode(ex0().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vars;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -40,6 +40,7 @@
|
|||
|
||||
#if defined(HAVE_CAIRO)
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
#include <mapnik/cairo/cairo_image_util.hpp>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
@ -309,21 +310,21 @@ int main ( int, char** )
|
|||
ren.apply();
|
||||
std::string msg("These maps have been rendered using AGG in the current directory:\n");
|
||||
#ifdef HAVE_JPEG
|
||||
save_to_file(buf,"demo.jpg","jpeg");
|
||||
save_to_file(buf.data(),"demo.jpg","jpeg");
|
||||
msg += "- demo.jpg\n";
|
||||
#endif
|
||||
#ifdef HAVE_PNG
|
||||
save_to_file(buf,"demo.png","png");
|
||||
save_to_file(buf,"demo256.png","png8");
|
||||
save_to_file(buf.data(),"demo.png","png");
|
||||
save_to_file(buf.data(),"demo256.png","png8");
|
||||
msg += "- demo.png\n";
|
||||
msg += "- demo256.png\n";
|
||||
#endif
|
||||
#ifdef HAVE_TIFF
|
||||
save_to_file(buf,"demo.tif","tiff");
|
||||
save_to_file(buf.data(),"demo.tif","tiff");
|
||||
msg += "- demo.tif\n";
|
||||
#endif
|
||||
#ifdef HAVE_WEBP
|
||||
save_to_file(buf,"demo.webp","webp");
|
||||
save_to_file(buf.data(),"demo.webp","webp");
|
||||
msg += "- demo.webp\n";
|
||||
#endif
|
||||
msg += "Have a look!\n";
|
||||
|
@ -352,8 +353,9 @@ int main ( int, char** )
|
|||
cairo_surface_write_to_png(&*image_surface, "cairo-demo.png");
|
||||
// but we can also benefit from quantization by converting
|
||||
// to a mapnik image object and then saving that
|
||||
image_32 im(image_surface);
|
||||
save_to_file(im, "cairo-demo256.png","png8");
|
||||
mapnik::image_data_rgba8 im_data(cairo_image_surface_get_width(&*image_surface), cairo_image_surface_get_height(&*image_surface));
|
||||
cairo_image_to_rgba8(im_data, image_surface);
|
||||
save_to_file(im_data, "cairo-demo256.png","png8");
|
||||
cairo_surface_finish(&*image_surface);
|
||||
|
||||
std::cout << "Three maps have been rendered using Cairo in the current directory:\n"
|
||||
|
|
|
@ -23,13 +23,7 @@
|
|||
import sys
|
||||
from os import path
|
||||
|
||||
try:
|
||||
import mapnik
|
||||
except:
|
||||
print '\n\nThe mapnik library and python bindings must have been compiled and \
|
||||
installed successfully before running this script.\n\n'
|
||||
sys.exit(1)
|
||||
|
||||
import mapnik
|
||||
|
||||
# Instanciate a map, giving it a width and height. Remember: the word "map" is
|
||||
# reserved in Python! :)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -52,4 +52,3 @@ QSize LayerDelegate::sizeHint(const QStyleOptionViewItem & /* option */,
|
|||
{
|
||||
return QSize(120,24);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <mapnik/feature_kv_iterator.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/util/timer.hpp>
|
||||
#include <mapnik/cairo/cairo_image_util.hpp>
|
||||
|
||||
#ifdef HAVE_CAIRO
|
||||
// cairo
|
||||
|
@ -539,7 +540,9 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
mapnik::cairo_renderer<mapnik::cairo_ptr> renderer(map, cairo, scaling_factor);
|
||||
renderer.apply();
|
||||
}
|
||||
image_32 buf(image_surface);
|
||||
mapnik::image_data_rgba8 data(map.width(), map.height());
|
||||
mapnik::cairo_image_to_rgba8(data, image_surface);
|
||||
image_32 buf(std::move(data));
|
||||
QImage image((uchar*)buf.raw_data(),buf.width(),buf.height(),QImage::Format_ARGB32);
|
||||
pix = QPixmap::fromImage(image.rgbSwapped());
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -22,7 +22,7 @@
|
|||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/expression_string.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/rule.hpp>
|
||||
#include <mapnik/feature_type_style.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
|
@ -35,7 +35,7 @@
|
|||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
|
||||
class node : private mapnik::noncopyable
|
||||
class node : private mapnik::util::noncopyable
|
||||
{
|
||||
struct node_base
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
struct symbolizer_info : public mapnik::util::static_visitor<QString>
|
||||
struct symbolizer_info
|
||||
{
|
||||
QString operator() (mapnik::point_symbolizer const& sym) const
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ struct symbolizer_info : public mapnik::util::static_visitor<QString>
|
|||
}
|
||||
};
|
||||
|
||||
struct symbolizer_icon : public mapnik::util::static_visitor<QIcon>
|
||||
struct symbolizer_icon
|
||||
{
|
||||
QIcon operator() (mapnik::polygon_symbolizer const& sym) const
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ struct symbolizer_icon : public mapnik::util::static_visitor<QIcon>
|
|||
{
|
||||
// FIXME!
|
||||
/*
|
||||
std::shared_ptr<mapnik::image_data_32> symbol = sym.get_image();
|
||||
std::shared_ptr<mapnik::image_data_rgba8> symbol = sym.get_image();
|
||||
if (symbol)
|
||||
{
|
||||
QImage image(symbol->getBytes(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2011 Artem Pavlenko
|
||||
* Copyright (C) 2014 Artem Pavlenko
|
||||
*
|
||||
* Mapnik is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
1281
deps/agg/include/agg_color_gray.h
vendored
1281
deps/agg/include/agg_color_gray.h
vendored
File diff suppressed because it is too large
Load diff
1859
deps/agg/include/agg_color_rgba.h
vendored
1859
deps/agg/include/agg_color_rgba.h
vendored
File diff suppressed because it is too large
Load diff
1
deps/agg/include/agg_ellipse.h
vendored
1
deps/agg/include/agg_ellipse.h
vendored
|
@ -48,6 +48,7 @@ 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();
|
||||
|
|
9
deps/agg/include/agg_gamma_functions.h
vendored
9
deps/agg/include/agg_gamma_functions.h
vendored
|
@ -120,6 +120,15 @@ 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
|
||||
|
|
184
deps/agg/include/agg_gamma_lut.h
vendored
184
deps/agg/include/agg_gamma_lut.h
vendored
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_gamma_functions.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
@ -116,6 +117,189 @@ namespace agg
|
|||
HiResT* m_dir_gamma;
|
||||
LoResT* m_inv_gamma;
|
||||
};
|
||||
|
||||
//
|
||||
// sRGB support classes
|
||||
//
|
||||
|
||||
// Optimized sRGB lookup table. The direct conversion (sRGB to linear)
|
||||
// is a straightforward lookup. The inverse conversion (linear to sRGB)
|
||||
// is implemented using binary search.
|
||||
template<class LinearType>
|
||||
class sRGB_lut_base
|
||||
{
|
||||
public:
|
||||
LinearType dir(int8u v) const
|
||||
{
|
||||
return m_dir_table[v];
|
||||
}
|
||||
|
||||
int8u inv(LinearType v) const
|
||||
{
|
||||
// Unrolled binary search.
|
||||
int8u x = 0;
|
||||
if (v > m_inv_table[128]) x = 128;
|
||||
if (v > m_inv_table[x + 64]) x += 64;
|
||||
if (v > m_inv_table[x + 32]) x += 32;
|
||||
if (v > m_inv_table[x + 16]) x += 16;
|
||||
if (v > m_inv_table[x + 8]) x += 8;
|
||||
if (v > m_inv_table[x + 4]) x += 4;
|
||||
if (v > m_inv_table[x + 2]) x += 2;
|
||||
if (v > m_inv_table[x + 1]) x += 1;
|
||||
return x;
|
||||
}
|
||||
|
||||
protected:
|
||||
LinearType m_dir_table[256];
|
||||
LinearType m_inv_table[256];
|
||||
|
||||
// Only derived classes may instantiate.
|
||||
sRGB_lut_base()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// sRGB_lut - implements sRGB conversion for the various types.
|
||||
// Base template is undefined, specializations are provided below.
|
||||
template<class LinearType>
|
||||
class sRGB_lut;
|
||||
|
||||
template<>
|
||||
class sRGB_lut<float> : public sRGB_lut_base<float>
|
||||
{
|
||||
public:
|
||||
sRGB_lut()
|
||||
{
|
||||
// Generate lookup tables.
|
||||
m_dir_table[0] = 0;
|
||||
m_inv_table[0] = 0;
|
||||
for (unsigned i = 1; i <= 255; ++i)
|
||||
{
|
||||
// Floating-point RGB is in range [0,1].
|
||||
m_dir_table[i] = float(sRGB_to_linear(i / 255.0));
|
||||
m_inv_table[i] = float(sRGB_to_linear((i - 0.5) / 255.0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class sRGB_lut<int16u> : public sRGB_lut_base<int16u>
|
||||
{
|
||||
public:
|
||||
sRGB_lut()
|
||||
{
|
||||
// Generate lookup tables.
|
||||
m_dir_table[0] = 0;
|
||||
m_inv_table[0] = 0;
|
||||
for (unsigned i = 1; i <= 255; ++i)
|
||||
{
|
||||
// 16-bit RGB is in range [0,65535].
|
||||
m_dir_table[i] = uround(65535.0 * sRGB_to_linear(i / 255.0));
|
||||
m_inv_table[i] = uround(65535.0 * sRGB_to_linear((i - 0.5) / 255.0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class sRGB_lut<int8u> : public sRGB_lut_base<int8u>
|
||||
{
|
||||
public:
|
||||
sRGB_lut()
|
||||
{
|
||||
// Generate lookup tables.
|
||||
m_dir_table[0] = 0;
|
||||
m_inv_table[0] = 0;
|
||||
for (unsigned i = 1; i <= 255; ++i)
|
||||
{
|
||||
// 8-bit RGB is handled with simple bidirectional lookup tables.
|
||||
m_dir_table[i] = uround(255.0 * sRGB_to_linear(i / 255.0));
|
||||
m_inv_table[i] = uround(255.0 * linear_to_sRGB(i / 255.0));
|
||||
}
|
||||
}
|
||||
|
||||
int8u inv(int8u v) const
|
||||
{
|
||||
// In this case, the inverse transform is a simple lookup.
|
||||
return m_inv_table[v];
|
||||
}
|
||||
};
|
||||
|
||||
// Common base class for sRGB_conv objects. Defines an internal
|
||||
// sRGB_lut object so that users don't have to.
|
||||
template<class T>
|
||||
class sRGB_conv_base
|
||||
{
|
||||
public:
|
||||
static T rgb_from_sRGB(int8u x)
|
||||
{
|
||||
return lut.dir(x);
|
||||
}
|
||||
|
||||
static int8u rgb_to_sRGB(T x)
|
||||
{
|
||||
return lut.inv(x);
|
||||
}
|
||||
|
||||
private:
|
||||
static sRGB_lut<T> lut;
|
||||
};
|
||||
|
||||
// Definition of sRGB_conv_base::lut. Due to the fact that this a template,
|
||||
// we don't need to place the definition in a cpp file. Hurrah.
|
||||
template<class T>
|
||||
sRGB_lut<T> sRGB_conv_base<T>::lut;
|
||||
|
||||
// Wrapper for sRGB-linear conversion.
|
||||
// Base template is undefined, specializations are provided below.
|
||||
template<class T>
|
||||
class sRGB_conv;
|
||||
|
||||
template<>
|
||||
class sRGB_conv<float> : public sRGB_conv_base<float>
|
||||
{
|
||||
public:
|
||||
static float alpha_from_sRGB(int8u x)
|
||||
{
|
||||
return float(x / 255.0);
|
||||
}
|
||||
|
||||
static int8u alpha_to_sRGB(float x)
|
||||
{
|
||||
if (x <= 0) return 0;
|
||||
else if (x >= 1) return 255;
|
||||
else return int8u(0.5 + x * 255);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class sRGB_conv<int16u> : public sRGB_conv_base<int16u>
|
||||
{
|
||||
public:
|
||||
static int16u alpha_from_sRGB(int8u x)
|
||||
{
|
||||
return (x << 8) | x;
|
||||
}
|
||||
|
||||
static int8u alpha_to_sRGB(int16u x)
|
||||
{
|
||||
return x >> 8;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class sRGB_conv<int8u> : public sRGB_conv_base<int8u>
|
||||
{
|
||||
public:
|
||||
static int8u alpha_from_sRGB(int8u x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
static int8u alpha_to_sRGB(int8u x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
97
deps/agg/include/agg_pixfmt_base.h
vendored
Normal file
97
deps/agg/include/agg_pixfmt_base.h
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// 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_PIXFMT_BASE_INCLUDED
|
||||
#define AGG_PIXFMT_BASE_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_gray.h"
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
struct pixfmt_gray_tag
|
||||
{
|
||||
};
|
||||
|
||||
struct pixfmt_rgb_tag
|
||||
{
|
||||
};
|
||||
|
||||
struct pixfmt_rgba_tag
|
||||
{
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------blender_base
|
||||
template<class ColorT, class Order = void>
|
||||
struct blender_base
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
|
||||
static rgba get(value_type r, value_type g, value_type b, value_type a, cover_type cover = cover_full)
|
||||
{
|
||||
if (cover > cover_none)
|
||||
{
|
||||
rgba c(
|
||||
color_type::to_double(r),
|
||||
color_type::to_double(g),
|
||||
color_type::to_double(b),
|
||||
color_type::to_double(a));
|
||||
|
||||
if (cover < cover_full)
|
||||
{
|
||||
double x = double(cover) / cover_full;
|
||||
c.r *= x;
|
||||
c.g *= x;
|
||||
c.b *= x;
|
||||
c.a *= x;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
else return rgba::no_color();
|
||||
}
|
||||
|
||||
static rgba get(const value_type* p, cover_type cover = cover_full)
|
||||
{
|
||||
return get(
|
||||
p[order_type::R],
|
||||
p[order_type::G],
|
||||
p[order_type::B],
|
||||
p[order_type::A],
|
||||
cover);
|
||||
}
|
||||
|
||||
static void set(value_type* p, value_type r, value_type g, value_type b, value_type a)
|
||||
{
|
||||
p[order_type::R] = r;
|
||||
p[order_type::G] = g;
|
||||
p[order_type::B] = b;
|
||||
p[order_type::A] = a;
|
||||
}
|
||||
|
||||
static void set(value_type* p, const rgba& c)
|
||||
{
|
||||
p[order_type::R] = color_type::from_double(c.r);
|
||||
p[order_type::G] = color_type::from_double(c.g);
|
||||
p[order_type::B] = color_type::from_double(c.b);
|
||||
p[order_type::A] = color_type::from_double(c.a);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
475
deps/agg/include/agg_pixfmt_gray.h
vendored
475
deps/agg/include/agg_pixfmt_gray.h
vendored
|
@ -25,8 +25,7 @@
|
|||
#define AGG_PIXFMT_GRAY_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_gray.h"
|
||||
#include "agg_pixfmt_base.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
namespace agg
|
||||
|
@ -38,12 +37,22 @@ namespace agg
|
|||
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 };
|
||||
typedef typename color_type::long_type long_type;
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
|
||||
unsigned alpha, unsigned cover=0)
|
||||
// Blend pixels using the non-premultiplied form of Alvy-Ray Smith's
|
||||
// compositing function. Since the render buffer is opaque we skip the
|
||||
// initial premultiply and final demultiply.
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha, cover_type cover)
|
||||
{
|
||||
*p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift);
|
||||
blend_pix(p, cv, color_type::mult_cover(alpha, cover));
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha)
|
||||
{
|
||||
*p = color_type::lerp(*p, cv, alpha);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -54,20 +63,21 @@ namespace agg
|
|||
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 };
|
||||
typedef typename color_type::long_type long_type;
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
|
||||
unsigned alpha, unsigned cover)
|
||||
// Blend pixels using the premultiplied form of Alvy-Ray Smith's
|
||||
// compositing function.
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha, cover_type cover)
|
||||
{
|
||||
alpha = color_type::base_mask - alpha;
|
||||
cover = (cover + 1) << (base_shift - 8);
|
||||
*p = (value_type)((*p * alpha + cv * cover) >> base_shift);
|
||||
blend_pix(p, color_type::mult_cover(cv, cover), color_type::mult_cover(alpha, cover));
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
|
||||
unsigned alpha)
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
value_type cv, value_type alpha)
|
||||
{
|
||||
*p = (value_type)(((*p * (color_type::base_mask - alpha)) >> base_shift) + cv);
|
||||
*p = color_type::prelerp(*p, cv, alpha);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -112,10 +122,11 @@ namespace agg
|
|||
|
||||
|
||||
//=================================================pixfmt_alpha_blend_gray
|
||||
template<class Blender, class RenBuf, unsigned Step=1, unsigned Offset=0>
|
||||
template<class Blender, class RenBuf, unsigned Step = 1, unsigned Offset = 0>
|
||||
class pixfmt_alpha_blend_gray
|
||||
{
|
||||
public:
|
||||
typedef pixfmt_gray_tag pixfmt_category;
|
||||
typedef RenBuf rbuf_type;
|
||||
typedef typename rbuf_type::row_data row_data;
|
||||
typedef Blender blender_type;
|
||||
|
@ -123,54 +134,117 @@ namespace agg
|
|||
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
|
||||
enum
|
||||
{
|
||||
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
|
||||
num_components = 1,
|
||||
pix_width = sizeof(value_type) * Step,
|
||||
pix_step = Step,
|
||||
pix_offset = Offset,
|
||||
};
|
||||
struct pixel_type
|
||||
{
|
||||
value_type c[num_components];
|
||||
|
||||
void set(value_type v)
|
||||
{
|
||||
c[0] = v;
|
||||
}
|
||||
|
||||
void set(const color_type& color)
|
||||
{
|
||||
set(color.v);
|
||||
}
|
||||
|
||||
void get(value_type& v) const
|
||||
{
|
||||
v = c[0];
|
||||
}
|
||||
|
||||
color_type get() const
|
||||
{
|
||||
return color_type(c[0]);
|
||||
}
|
||||
|
||||
pixel_type* next()
|
||||
{
|
||||
return (pixel_type*)(c + pix_step);
|
||||
}
|
||||
|
||||
const pixel_type* next() const
|
||||
{
|
||||
return (const pixel_type*)(c + pix_step);
|
||||
}
|
||||
|
||||
pixel_type* advance(int n)
|
||||
{
|
||||
return (pixel_type*)(c + n * pix_step);
|
||||
}
|
||||
|
||||
const pixel_type* advance(int n) const
|
||||
{
|
||||
return (const pixel_type*)(c + n * pix_step);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE void copy_or_blend_pix(value_type* p,
|
||||
const color_type& c,
|
||||
unsigned cover)
|
||||
AGG_INLINE void blend_pix(pixel_type* p,
|
||||
value_type v, value_type a,
|
||||
unsigned cover)
|
||||
{
|
||||
if (c.a)
|
||||
blender_type::blend_pix(p->c, v, a, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, value_type v, value_type a)
|
||||
{
|
||||
blender_type::blend_pix(p->c, v, a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover)
|
||||
{
|
||||
blender_type::blend_pix(p->c, c.v, c.a, cover);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pix(pixel_type* p, const color_type& c)
|
||||
{
|
||||
blender_type::blend_pix(p->c, c.v, c.a);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover)
|
||||
{
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8;
|
||||
if(alpha == base_mask)
|
||||
if (c.is_opaque() && cover == cover_mask)
|
||||
{
|
||||
*p = c.v;
|
||||
p->set(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
Blender::blend_pix(p, c.v, alpha, cover);
|
||||
blend_pix(p, c, cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static AGG_INLINE void copy_or_blend_pix(value_type* p,
|
||||
const color_type& c)
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c)
|
||||
{
|
||||
if (c.a)
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
if(c.a == base_mask)
|
||||
if (c.is_opaque())
|
||||
{
|
||||
*p = c.v;
|
||||
p->set(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
Blender::blend_pix(p, c.v, c.a);
|
||||
blend_pix(p, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
explicit pixfmt_alpha_blend_gray(rbuf_type& rb) :
|
||||
|
@ -183,7 +257,7 @@ namespace agg
|
|||
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)))
|
||||
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),
|
||||
|
@ -201,61 +275,98 @@ namespace agg
|
|||
AGG_INLINE int stride() const { return m_rbuf->stride(); }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); }
|
||||
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
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE int8u* pix_ptr(int x, int y)
|
||||
{
|
||||
return m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset);
|
||||
}
|
||||
|
||||
int8u* pix_ptr(int x, int y)
|
||||
AGG_INLINE const int8u* pix_ptr(int x, int y) const
|
||||
{
|
||||
return m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset);
|
||||
}
|
||||
|
||||
// Return pointer to pixel value, forcing row to be allocated.
|
||||
AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len)
|
||||
{
|
||||
return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step + pix_offset));
|
||||
}
|
||||
|
||||
// Return pointer to pixel value, or null if row not allocated.
|
||||
AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const
|
||||
{
|
||||
int8u* p = m_rbuf->row_ptr(y);
|
||||
return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step + pix_offset)) : 0;
|
||||
}
|
||||
|
||||
// Get pixel pointer from raw buffer pointer.
|
||||
AGG_INLINE static pixel_type* pix_value_ptr(void* p)
|
||||
{
|
||||
return (pixel_type*)((value_type*)p + pix_offset);
|
||||
}
|
||||
|
||||
// Get pixel pointer from raw buffer pointer.
|
||||
AGG_INLINE static const pixel_type* pix_value_ptr(const void* p)
|
||||
{
|
||||
return (const pixel_type*)((const value_type*)p + pix_offset);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static void write_plain_color(void* p, color_type c)
|
||||
{
|
||||
// Grayscale formats are implicitly premultiplied.
|
||||
c.premultiply();
|
||||
pix_value_ptr(p)->set(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static color_type read_plain_color(const void* p)
|
||||
{
|
||||
return pix_value_ptr(p)->get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static void make_pix(int8u* p, const color_type& c)
|
||||
{
|
||||
*(value_type*)p = c.v;
|
||||
((pixel_type*)p)->set(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
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);
|
||||
if (const pixel_type* p = pix_value_ptr(x, y))
|
||||
{
|
||||
return p->get();
|
||||
}
|
||||
return color_type::no_color();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
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;
|
||||
pix_value_ptr(x, y, 1)->set(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
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);
|
||||
copy_or_blend_pix(pix_value_ptr(x, y, 1), 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;
|
||||
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
do
|
||||
{
|
||||
*p = c.v;
|
||||
p += Step;
|
||||
p->set(c);
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
@ -268,12 +379,9 @@ namespace agg
|
|||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
*p = c.v;
|
||||
pix_value_ptr(x, y++, 1)->set(c);
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,29 +391,27 @@ namespace agg
|
|||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
if (c.a)
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
|
||||
calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8;
|
||||
if(alpha == base_mask)
|
||||
if (c.is_opaque() && cover == cover_mask)
|
||||
{
|
||||
do
|
||||
{
|
||||
*p = c.v;
|
||||
p += Step;
|
||||
p->set(c);
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
Blender::blend_pix(p, c.v, alpha, cover);
|
||||
p += Step;
|
||||
blend_pix(p, c, cover);
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -317,31 +423,23 @@ namespace agg
|
|||
const color_type& c,
|
||||
int8u cover)
|
||||
{
|
||||
if (c.a)
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
value_type* p;
|
||||
calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8;
|
||||
if(alpha == base_mask)
|
||||
if (c.is_opaque() && cover == cover_mask)
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
*p = c.v;
|
||||
pix_value_ptr(x, y++, 1)->set(c);
|
||||
}
|
||||
while(--len);
|
||||
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);
|
||||
blend_pix(pix_value_ptr(x, y++, 1), c, cover);
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,26 +451,24 @@ namespace agg
|
|||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
if (c.a)
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
|
||||
do
|
||||
{
|
||||
calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;
|
||||
if(alpha == base_mask)
|
||||
if (c.is_opaque() && *covers == cover_mask)
|
||||
{
|
||||
*p = c.v;
|
||||
p->set(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
Blender::blend_pix(p, c.v, alpha, *covers);
|
||||
blend_pix(p, c, *covers);
|
||||
}
|
||||
p += Step;
|
||||
p = p->next();
|
||||
++covers;
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,26 +479,23 @@ namespace agg
|
|||
const color_type& c,
|
||||
const int8u* covers)
|
||||
{
|
||||
if (c.a)
|
||||
if (!c.is_transparent())
|
||||
{
|
||||
do
|
||||
{
|
||||
calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;
|
||||
pixel_type* p = pix_value_ptr(x, y++, 1);
|
||||
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
if(alpha == base_mask)
|
||||
if (c.is_opaque() && *covers == cover_mask)
|
||||
{
|
||||
*p = c.v;
|
||||
p->set(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
Blender::blend_pix(p, c.v, alpha, *covers);
|
||||
blend_pix(p, c, *covers);
|
||||
}
|
||||
++covers;
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,16 +505,14 @@ namespace agg
|
|||
unsigned len,
|
||||
const color_type* colors)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
|
||||
do
|
||||
{
|
||||
*p = colors->v;
|
||||
p += Step;
|
||||
++colors;
|
||||
p->set(*colors++);
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -432,12 +523,9 @@ namespace agg
|
|||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
*p = colors->v;
|
||||
++colors;
|
||||
pix_value_ptr(x, y++, 1)->set(*colors++);
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -448,51 +536,41 @@ namespace agg
|
|||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
pixel_type* p = pix_value_ptr(x, y, len);
|
||||
|
||||
if(covers)
|
||||
if (covers)
|
||||
{
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
p += Step;
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cover == 255)
|
||||
if (cover == cover_mask)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(colors->a == base_mask)
|
||||
{
|
||||
*p = colors->v;
|
||||
}
|
||||
else
|
||||
{
|
||||
copy_or_blend_pix(p, *colors);
|
||||
}
|
||||
p += Step;
|
||||
++colors;
|
||||
copy_or_blend_pix(p, *colors++);
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
p += Step;
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
|
@ -500,49 +578,31 @@ namespace agg
|
|||
const int8u* covers,
|
||||
int8u cover)
|
||||
{
|
||||
value_type* p;
|
||||
if(covers)
|
||||
if (covers)
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++);
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cover == 255)
|
||||
if (cover == cover_mask)
|
||||
{
|
||||
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;
|
||||
copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++);
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover);
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -551,22 +611,19 @@ namespace agg
|
|||
template<class Function> void for_each_pixel(Function f)
|
||||
{
|
||||
unsigned y;
|
||||
for(y = 0; y < height(); ++y)
|
||||
for (y = 0; y < height(); ++y)
|
||||
{
|
||||
row_data r = m_rbuf->row(y);
|
||||
if(r.ptr)
|
||||
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;
|
||||
|
||||
pixel_type* p = pix_value_ptr(r.x1, y, len);
|
||||
do
|
||||
{
|
||||
f(p);
|
||||
p += Step;
|
||||
f(p->c);
|
||||
p = p->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -590,8 +647,7 @@ namespace agg
|
|||
int xsrc, int ysrc,
|
||||
unsigned len)
|
||||
{
|
||||
const int8u* p = from.row_ptr(ysrc);
|
||||
if(p)
|
||||
if (const int8u* p = from.row_ptr(ysrc))
|
||||
{
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width,
|
||||
p + xsrc * pix_width,
|
||||
|
@ -600,6 +656,7 @@ namespace agg
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Blend from single color, using grayscale surface as alpha channel.
|
||||
template<class SrcPixelFormatRenderer>
|
||||
void blend_from_color(const SrcPixelFormatRenderer& from,
|
||||
const color_type& color,
|
||||
|
@ -608,25 +665,26 @@ namespace agg
|
|||
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)
|
||||
typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type;
|
||||
typedef typename SrcPixelFormatRenderer::color_type src_color_type;
|
||||
|
||||
if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc))
|
||||
{
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst;
|
||||
pixel_type* pdst = pix_value_ptr(xdst, ydst, len);
|
||||
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pdst,
|
||||
color,
|
||||
(*psrc * cover + base_mask) >> base_shift);
|
||||
++psrc;
|
||||
++pdst;
|
||||
copy_or_blend_pix(pdst, color, src_color_type::scale_cover(cover, psrc->c[0]));
|
||||
psrc = psrc->next();
|
||||
pdst = pdst->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Blend from color table, using grayscale surface as indexes into table.
|
||||
// Obviously, this only works for integer value types.
|
||||
template<class SrcPixelFormatRenderer>
|
||||
void blend_from_lut(const SrcPixelFormatRenderer& from,
|
||||
const color_type* color_lut,
|
||||
|
@ -635,19 +693,19 @@ namespace agg
|
|||
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)
|
||||
typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type;
|
||||
|
||||
if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc))
|
||||
{
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst;
|
||||
pixel_type* pdst = pix_value_ptr(xdst, ydst, len);
|
||||
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pdst, color_lut[*psrc], cover);
|
||||
++psrc;
|
||||
++pdst;
|
||||
copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover);
|
||||
psrc = psrc->next();
|
||||
pdst = pdst->next();
|
||||
}
|
||||
while(--len);
|
||||
while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -655,16 +713,25 @@ namespace agg
|
|||
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 blender_gray<gray8> blender_gray8;
|
||||
typedef blender_gray<sgray8> blender_sgray8;
|
||||
typedef blender_gray<gray16> blender_gray16;
|
||||
typedef blender_gray<gray32> blender_gray32;
|
||||
|
||||
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
|
||||
typedef blender_gray_pre<gray8> blender_gray8_pre;
|
||||
typedef blender_gray_pre<sgray8> blender_sgray8_pre;
|
||||
typedef blender_gray_pre<gray16> blender_gray16_pre;
|
||||
typedef blender_gray_pre<gray32> blender_gray32_pre;
|
||||
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray8, rendering_buffer> pixfmt_gray8;
|
||||
typedef pixfmt_alpha_blend_gray<blender_sgray8, rendering_buffer> pixfmt_sgray8;
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray16, rendering_buffer> pixfmt_gray16;
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray32, rendering_buffer> pixfmt_gray32;
|
||||
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray8_pre, rendering_buffer> pixfmt_gray8_pre;
|
||||
typedef pixfmt_alpha_blend_gray<blender_sgray8_pre, rendering_buffer> pixfmt_sgray8_pre;
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray16_pre, rendering_buffer> pixfmt_gray16_pre;
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray32_pre, rendering_buffer> pixfmt_gray32_pre;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1175,7 +1175,7 @@ class dense_hashtable {
|
|||
pointer realloc_or_die(pointer /*ptr*/, size_type /*n*/) {
|
||||
fprintf(stderr, "realloc_or_die is only supported for "
|
||||
"libc_allocator_with_realloc\n");
|
||||
exit(1);
|
||||
//exit(1);
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
@ -1197,7 +1197,7 @@ class dense_hashtable {
|
|||
if (retval == NULL) {
|
||||
fprintf(stderr, "sparsehash: FATAL ERROR: failed to reallocate "
|
||||
"%lu elements for ptr %p", static_cast<unsigned long>(n), ptr);
|
||||
exit(1);
|
||||
//exit(1);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue