Added impl for image_view_any and fix to benchmark that was missing include for mapnik/color.hpp

This commit is contained in:
Blake Thompson 2015-03-13 17:28:22 -05:00
parent c262e51428
commit 46ea6a5b1a
6 changed files with 156 additions and 117 deletions

View file

@ -10,6 +10,7 @@
#include <mapnik/util/fs.hpp>
#include <mapnik/polygon_clipper.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/color.hpp>
// agg
#include "agg_conv_clip_polygon.h"
// clipper

View file

@ -68,7 +68,7 @@ private:
} // end ns detail
template <typename T>
class image
class MAPNIK_DECL image
{
public:
using pixel = T;

View file

@ -28,7 +28,7 @@
namespace mapnik {
template <typename T>
class image_view
class MAPNIK_DECL image_view
{
public:
using pixel = typename T::pixel;

View file

@ -40,81 +40,6 @@ using image_view_base = util::variant<image_view_rgba8,
image_view_gray64s,
image_view_gray64f>;
namespace detail {
struct get_view_width_visitor
{
template <typename T>
std::size_t operator()(T const& data) const
{
return data.width();
}
};
struct get_view_height_visitor
{
template <typename T>
std::size_t operator()(T const& data) const
{
return data.height();
}
};
struct get_view_size_visitor
{
template <typename T>
unsigned operator()(T const& data) const
{
return data.getSize();
}
};
struct get_view_dtype_visitor
{
template <typename T>
image_dtype operator()(T const& data) const
{
return data.get_dtype();
}
};
struct get_view_row_size_visitor
{
template <typename T>
unsigned operator()(T const& data) const
{
return data.getRowSize();
}
};
struct get_view_premultiplied_visitor
{
template <typename T>
bool operator()(T const& data) const
{
return data.get_premultiplied();
}
};
struct get_view_offset_visitor
{
template <typename T>
double operator()(T const& data) const
{
return data.get_offset();
}
};
struct get_view_scaling_visitor
{
template <typename T>
double operator()(T const& data) const
{
return data.get_scaling();
}
};
} // namespace detail
struct image_view_any : image_view_base
{
image_view_any() = default;
@ -123,47 +48,16 @@ struct image_view_any : image_view_base
image_view_any(T && data) noexcept
: image_view_base(std::move(data)) {}
std::size_t width() const
{
return util::apply_visitor(detail::get_view_width_visitor(),*this);
}
std::size_t height() const
{
return util::apply_visitor(detail::get_view_height_visitor(),*this);
}
unsigned getSize() const
{
return util::apply_visitor(detail::get_view_size_visitor(),*this);
}
unsigned getRowSize() const
{
return util::apply_visitor(detail::get_view_row_size_visitor(),*this);
}
bool get_premultiplied() const
{
return util::apply_visitor(detail::get_view_premultiplied_visitor(),*this);
}
double get_offset() const
{
return util::apply_visitor(detail::get_view_offset_visitor(),*this);
}
double get_scaling() const
{
return util::apply_visitor(detail::get_view_scaling_visitor(),*this);
}
image_dtype get_dtype() const
{
return util::apply_visitor(detail::get_view_dtype_visitor(),*this);
}
std::size_t width() const;
std::size_t height() const;
unsigned getSize() const;
unsigned getRowSize() const;
bool get_premultiplied() const;
double get_offset() const;
double get_scaling() const;
image_dtype get_dtype() const;
};
}
} // end mapnik ns
#endif // MAPNIK_IMAGE_VIEW_ANY_HPP

View file

@ -176,6 +176,7 @@ source = Split(
cairo_io.cpp
image.cpp
image_view.cpp
image_view_any.cpp
image_any.cpp
image_null.cpp
image_util.cpp

143
src/image_view_any.cpp Normal file
View file

@ -0,0 +1,143 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#include <mapnik/image_view_any.hpp>
namespace mapnik {
namespace detail {
struct get_view_width_visitor
{
template <typename T>
std::size_t operator()(T const& data) const
{
return data.width();
}
};
struct get_view_height_visitor
{
template <typename T>
std::size_t operator()(T const& data) const
{
return data.height();
}
};
struct get_view_size_visitor
{
template <typename T>
unsigned operator()(T const& data) const
{
return data.getSize();
}
};
struct get_view_dtype_visitor
{
template <typename T>
image_dtype operator()(T const& data) const
{
return data.get_dtype();
}
};
struct get_view_row_size_visitor
{
template <typename T>
unsigned operator()(T const& data) const
{
return data.getRowSize();
}
};
struct get_view_premultiplied_visitor
{
template <typename T>
bool operator()(T const& data) const
{
return data.get_premultiplied();
}
};
struct get_view_offset_visitor
{
template <typename T>
double operator()(T const& data) const
{
return data.get_offset();
}
};
struct get_view_scaling_visitor
{
template <typename T>
double operator()(T const& data) const
{
return data.get_scaling();
}
};
} // end namespace detail
std::size_t image_view_any::width() const
{
return util::apply_visitor(detail::get_view_width_visitor(),*this);
}
std::size_t image_view_any::height() const
{
return util::apply_visitor(detail::get_view_height_visitor(),*this);
}
unsigned image_view_any::getSize() const
{
return util::apply_visitor(detail::get_view_size_visitor(),*this);
}
unsigned image_view_any::getRowSize() const
{
return util::apply_visitor(detail::get_view_row_size_visitor(),*this);
}
bool image_view_any::get_premultiplied() const
{
return util::apply_visitor(detail::get_view_premultiplied_visitor(),*this);
}
double image_view_any::get_offset() const
{
return util::apply_visitor(detail::get_view_offset_visitor(),*this);
}
double image_view_any::get_scaling() const
{
return util::apply_visitor(detail::get_view_scaling_visitor(),*this);
}
image_dtype image_view_any::get_dtype() const
{
return util::apply_visitor(detail::get_view_dtype_visitor(),*this);
}
} // end mapnik ns