From 46ea6a5b1af1da3bc785a85031728bccd9a30be6 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Fri, 13 Mar 2015 17:28:22 -0500 Subject: [PATCH] Added impl for image_view_any and fix to benchmark that was missing include for mapnik/color.hpp --- benchmark/test_polygon_clipping.cpp | 1 + include/mapnik/image.hpp | 2 +- include/mapnik/image_view.hpp | 2 +- include/mapnik/image_view_any.hpp | 124 ++---------------------- src/build.py | 1 + src/image_view_any.cpp | 143 ++++++++++++++++++++++++++++ 6 files changed, 156 insertions(+), 117 deletions(-) create mode 100644 src/image_view_any.cpp diff --git a/benchmark/test_polygon_clipping.cpp b/benchmark/test_polygon_clipping.cpp index c26ffa03b..9b8d9c996 100644 --- a/benchmark/test_polygon_clipping.cpp +++ b/benchmark/test_polygon_clipping.cpp @@ -10,6 +10,7 @@ #include #include #include +#include // agg #include "agg_conv_clip_polygon.h" // clipper diff --git a/include/mapnik/image.hpp b/include/mapnik/image.hpp index bccd0652b..833a9989e 100644 --- a/include/mapnik/image.hpp +++ b/include/mapnik/image.hpp @@ -68,7 +68,7 @@ private: } // end ns detail template -class image +class MAPNIK_DECL image { public: using pixel = T; diff --git a/include/mapnik/image_view.hpp b/include/mapnik/image_view.hpp index b53d3c8cd..f9d13977f 100644 --- a/include/mapnik/image_view.hpp +++ b/include/mapnik/image_view.hpp @@ -28,7 +28,7 @@ namespace mapnik { template -class image_view +class MAPNIK_DECL image_view { public: using pixel = typename T::pixel; diff --git a/include/mapnik/image_view_any.hpp b/include/mapnik/image_view_any.hpp index 90bb0dbe4..0dddde1f7 100644 --- a/include/mapnik/image_view_any.hpp +++ b/include/mapnik/image_view_any.hpp @@ -40,81 +40,6 @@ using image_view_base = util::variant; -namespace detail { - -struct get_view_width_visitor -{ - template - std::size_t operator()(T const& data) const - { - return data.width(); - } -}; - -struct get_view_height_visitor -{ - template - std::size_t operator()(T const& data) const - { - return data.height(); - } -}; - -struct get_view_size_visitor -{ - template - unsigned operator()(T const& data) const - { - return data.getSize(); - } -}; - -struct get_view_dtype_visitor -{ - template - image_dtype operator()(T const& data) const - { - return data.get_dtype(); - } -}; - -struct get_view_row_size_visitor -{ - template - unsigned operator()(T const& data) const - { - return data.getRowSize(); - } -}; - -struct get_view_premultiplied_visitor -{ - template - bool operator()(T const& data) const - { - return data.get_premultiplied(); - } -}; - -struct get_view_offset_visitor -{ - template - double operator()(T const& data) const - { - return data.get_offset(); - } -}; - -struct get_view_scaling_visitor -{ - template - 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 diff --git a/src/build.py b/src/build.py index 064c2e683..00bb95346 100644 --- a/src/build.py +++ b/src/build.py @@ -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 diff --git a/src/image_view_any.cpp b/src/image_view_any.cpp new file mode 100644 index 000000000..afe5a4b90 --- /dev/null +++ b/src/image_view_any.cpp @@ -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 + +namespace mapnik { + +namespace detail { + +struct get_view_width_visitor +{ + template + std::size_t operator()(T const& data) const + { + return data.width(); + } +}; + +struct get_view_height_visitor +{ + template + std::size_t operator()(T const& data) const + { + return data.height(); + } +}; + +struct get_view_size_visitor +{ + template + unsigned operator()(T const& data) const + { + return data.getSize(); + } +}; + +struct get_view_dtype_visitor +{ + template + image_dtype operator()(T const& data) const + { + return data.get_dtype(); + } +}; + +struct get_view_row_size_visitor +{ + template + unsigned operator()(T const& data) const + { + return data.getRowSize(); + } +}; + +struct get_view_premultiplied_visitor +{ + template + bool operator()(T const& data) const + { + return data.get_premultiplied(); + } +}; + +struct get_view_offset_visitor +{ + template + double operator()(T const& data) const + { + return data.get_offset(); + } +}; + +struct get_view_scaling_visitor +{ + template + 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