TIFF I/O - use memory mapping in tiff_reader.cpp
when MAPNIK_MEMORY_MAPPED_FILE
is defined.
This commit is contained in:
parent
34a622f48e
commit
3a475517c0
2 changed files with 39 additions and 22 deletions
|
@ -113,11 +113,13 @@ struct tiff_io_traits
|
|||
using input_stream_type = std::istream;
|
||||
};
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
template <>
|
||||
struct tiff_io_traits<boost::interprocess::ibufferstream>
|
||||
{
|
||||
using input_stream_type = boost::interprocess::ibufferstream;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -208,8 +210,11 @@ namespace
|
|||
|
||||
image_reader* create_tiff_reader(std::string const& filename)
|
||||
{
|
||||
//return new tiff_reader<std::filebuf>(filename);
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
return new tiff_reader<boost::interprocess::ibufferstream>(filename);
|
||||
#else
|
||||
return new tiff_reader<std::filebuf>(filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
image_reader* create_tiff_reader2(char const * data, std::size_t size)
|
||||
|
@ -224,8 +229,14 @@ const bool registered2 = register_image_reader("tiff", create_tiff_reader2);
|
|||
|
||||
template <typename T>
|
||||
tiff_reader<T>::tiff_reader(std::string const& filename)
|
||||
: source_(),
|
||||
stream_(),//&source_),
|
||||
:
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
stream_(),
|
||||
#else
|
||||
source_(),
|
||||
stream_(&source_),
|
||||
#endif
|
||||
|
||||
tif_(nullptr),
|
||||
read_method_(generic),
|
||||
rows_per_strip_(0),
|
||||
|
|
|
@ -14,8 +14,14 @@
|
|||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
#include "../../../src/tiff_reader.cpp"
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
using source_type = boost::interprocess::ibufferstream;
|
||||
#else
|
||||
using source_type = std::filebuf;
|
||||
#endif
|
||||
|
||||
#define TIFF_ASSERT(filename) \
|
||||
mapnik::tiff_reader<boost::interprocess::ibufferstream> tiff_reader(filename); \
|
||||
mapnik::tiff_reader<source_type> tiff_reader(filename); \
|
||||
REQUIRE( tiff_reader.width() == 256 ); \
|
||||
REQUIRE( tiff_reader.height() == 256 ); \
|
||||
REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG ); \
|
||||
|
@ -141,7 +147,7 @@ void test_tiff_reader(std::string const& pattern)
|
|||
if (boost::iends_with(path,".tif")
|
||||
&& boost::istarts_with(mapnik::util::basename(path), pattern))
|
||||
{
|
||||
mapnik::tiff_reader< boost::interprocess::ibufferstream> tiff_reader(path);
|
||||
mapnik::tiff_reader<source_type> tiff_reader(path);
|
||||
auto width = tiff_reader.width();
|
||||
auto height = tiff_reader.height();
|
||||
{
|
||||
|
@ -180,7 +186,7 @@ TEST_CASE("tiff io")
|
|||
SECTION("scan rgb8 striped")
|
||||
{
|
||||
std::string filename("./test/data/tiff/scan_512x512_rgb8_striped.tif");
|
||||
mapnik::tiff_reader< boost::interprocess::ibufferstream> tiff_reader(filename);
|
||||
mapnik::tiff_reader<source_type> tiff_reader(filename);
|
||||
REQUIRE( tiff_reader.width() == 512 );
|
||||
REQUIRE( tiff_reader.height() == 512 );
|
||||
REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG );
|
||||
|
@ -210,7 +216,7 @@ TEST_CASE("tiff io")
|
|||
|
||||
SECTION("scan rgb8 tiled") {
|
||||
std::string filename("./test/data/tiff/scan_512x512_rgb8_tiled.tif");
|
||||
mapnik::tiff_reader< boost::interprocess::ibufferstream> tiff_reader(filename);
|
||||
mapnik::tiff_reader<source_type> tiff_reader(filename);
|
||||
REQUIRE( tiff_reader.width() == 512 );
|
||||
REQUIRE( tiff_reader.height() == 512 );
|
||||
REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG );
|
||||
|
|
Loading…
Reference in a new issue