fix Boost.GIL includes for BOOST_VERSION >= 1.69 (ref #4000)

This commit is contained in:
Artem Pavlenko 2018-12-13 15:46:57 +00:00
parent e583063ab5
commit bcb1e67507
4 changed files with 54 additions and 36 deletions

View file

@ -1,9 +1,13 @@
#include "agg_pixfmt_rgba.h" #include "agg_pixfmt_rgba.h"
#pragma GCC diagnostic push #pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp> #include <mapnik/warning_ignore.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 106900
#include <boost/gil.hpp>
#else
#include <boost/gil/gil_all.hpp> #include <boost/gil/gil_all.hpp>
#endif
#include <boost/gil/extension/toolbox/hsv.hpp> #include <boost/gil/extension/toolbox/hsv.hpp>
#include <boost/gil/extension/toolbox/hsl.hpp> #include <boost/gil/extension/toolbox/hsl.hpp>
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

View file

@ -16,7 +16,12 @@
#pragma GCC diagnostic push #pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp> #include <mapnik/warning_ignore.hpp>
#if BOOST_VERSION >= 106900
#include <boost/gil.hpp>
#else
#include <boost/gil/gil_all.hpp> #include <boost/gil/gil_all.hpp>
#endif
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
namespace boost { namespace gil { namespace boost { namespace gil {
@ -26,11 +31,11 @@ namespace boost { namespace gil {
namespace hsl_color_space namespace hsl_color_space
{ {
/// \brief Hue /// \brief Hue
struct hue_t {}; struct hue_t {};
/// \brief Saturation /// \brief Saturation
struct saturation_t {}; struct saturation_t {};
/// \brief Lightness /// \brief Lightness
struct lightness_t {}; struct lightness_t {};
} }
/// \} /// \}
@ -102,12 +107,12 @@ struct default_color_converter_impl< rgb_t, hsl_t >
if( lightness < 0.5f ) if( lightness < 0.5f )
{ {
saturation = diff saturation = diff
/ ( min_color + max_color ); / ( min_color + max_color );
} }
else else
{ {
saturation = ( max_color - min_color ) saturation = ( max_color - min_color )
/ ( 2.f - diff ); / ( 2.f - diff );
} }
@ -116,7 +121,7 @@ struct default_color_converter_impl< rgb_t, hsl_t >
if( std::abs( max_color - temp_red ) < 0.0001f ) if( std::abs( max_color - temp_red ) < 0.0001f )
{ {
// max_color is red // max_color is red
hue = ( temp_green - temp_blue ) hue = ( temp_green - temp_blue )
/ diff; / diff;
} }
@ -124,8 +129,8 @@ struct default_color_converter_impl< rgb_t, hsl_t >
{ {
// max_color is green // max_color is green
// 2.0 + (b - r) / (maxColor - minColor) // 2.0 + (b - r) / (maxColor - minColor)
hue = 2.f hue = 2.f
+ ( temp_blue - temp_red ) + ( temp_blue - temp_red )
/ diff; / diff;
} }
@ -133,13 +138,13 @@ struct default_color_converter_impl< rgb_t, hsl_t >
{ {
// max_color is blue // max_color is blue
// 4.0 + (r - g) / (maxColor - minColor) // 4.0 + (r - g) / (maxColor - minColor)
hue = 4.f hue = 4.f
+ ( temp_red - temp_green ) + ( temp_red - temp_green )
/ diff; / diff;
} }
hue /= 6.f; hue /= 6.f;
if( hue < 0.f ) if( hue < 0.f )
{ {
hue += 1.f; hue += 1.f;
@ -177,29 +182,29 @@ struct default_color_converter_impl<hsl_t,rgb_t>
float tempr, tempg, tempb; float tempr, tempg, tempb;
//Set the temporary values //Set the temporary values
if( get_color( src, lightness_t() ) < 0.5 ) if( get_color( src, lightness_t() ) < 0.5 )
{ {
temp2 = get_color( src, lightness_t() ) temp2 = get_color( src, lightness_t() )
* ( 1.f + get_color( src, saturation_t() ) ); * ( 1.f + get_color( src, saturation_t() ) );
} }
else else
{ {
temp2 = ( get_color( src, lightness_t() ) + get_color( src, saturation_t() )) temp2 = ( get_color( src, lightness_t() ) + get_color( src, saturation_t() ))
- ( get_color( src, lightness_t() ) * get_color( src, saturation_t() )); - ( get_color( src, lightness_t() ) * get_color( src, saturation_t() ));
} }
temp1 = 2.f temp1 = 2.f
* get_color( src, lightness_t() ) * get_color( src, lightness_t() )
- temp2; - temp2;
tempr = get_color( src, hue_t() ) + 1.f / 3.f; tempr = get_color( src, hue_t() ) + 1.f / 3.f;
if( tempr > 1.f ) if( tempr > 1.f )
{ {
tempr--; tempr--;
} }
tempg = get_color( src, hue_t() ); tempg = get_color( src, hue_t() );
tempb = get_color( src, hue_t() ) - 1.f / 3.f; tempb = get_color( src, hue_t() ) - 1.f / 3.f;
if( tempb < 0.f ) if( tempb < 0.f )
@ -207,7 +212,7 @@ struct default_color_converter_impl<hsl_t,rgb_t>
tempb++; tempb++;
} }
//Red //Red
if( tempr < 1.f / 6.f ) if( tempr < 1.f / 6.f )
{ {
red = temp1 + ( temp2 - temp1 ) * 6.f * tempr; red = temp1 + ( temp2 - temp1 ) * 6.f * tempr;
@ -218,7 +223,7 @@ struct default_color_converter_impl<hsl_t,rgb_t>
} }
else if( tempr < 2.f / 3.f ) else if( tempr < 2.f / 3.f )
{ {
red = temp1 + (temp2 - temp1) red = temp1 + (temp2 - temp1)
* (( 2.f / 3.f ) - tempr) * 6.f; * (( 2.f / 3.f ) - tempr) * 6.f;
} }
else else
@ -226,7 +231,7 @@ struct default_color_converter_impl<hsl_t,rgb_t>
red = temp1; red = temp1;
} }
//Green //Green
if( tempg < 1.f / 6.f ) if( tempg < 1.f / 6.f )
{ {
green = temp1 + ( temp2 - temp1 ) * 6.f * tempg; green = temp1 + ( temp2 - temp1 ) * 6.f * tempg;
@ -245,7 +250,7 @@ struct default_color_converter_impl<hsl_t,rgb_t>
green = temp1; green = temp1;
} }
//Blue //Blue
if( tempb < 1.f / 6.f ) if( tempb < 1.f / 6.f )
{ {
blue = temp1 + (temp2 - temp1) * 6.f * tempb; blue = temp1 + (temp2 - temp1) * 6.f * tempb;
@ -256,7 +261,7 @@ struct default_color_converter_impl<hsl_t,rgb_t>
} }
else if( tempb < 2.f / 3.f ) else if( tempb < 2.f / 3.f )
{ {
blue = temp1 + (temp2 - temp1) blue = temp1 + (temp2 - temp1)
* (( 2.f / 3.f ) - tempb) * 6.f; * (( 2.f / 3.f ) - tempb) * 6.f;
} }
else else

View file

@ -16,7 +16,12 @@
#pragma GCC diagnostic push #pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp> #include <mapnik/warning_ignore.hpp>
#if BOOST_VERSION >= 106900
#include <boost/gil.hpp>
#else
#include <boost/gil/gil_all.hpp> #include <boost/gil/gil_all.hpp>
#endif
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
namespace boost { namespace gil { namespace boost { namespace gil {
@ -26,11 +31,11 @@ namespace boost { namespace gil {
namespace hsv_color_space namespace hsv_color_space
{ {
/// \brief Hue /// \brief Hue
struct hue_t {}; struct hue_t {};
/// \brief Saturation /// \brief Saturation
struct saturation_t{}; struct saturation_t{};
/// \brief Value /// \brief Value
struct value_t {}; struct value_t {};
} }
/// \} /// \}
@ -86,11 +91,11 @@ struct default_color_converter_impl< rgb_t, hsv_t >
bits32f diff = max_color - min_color; bits32f diff = max_color - min_color;
if( max_color < 0.0001f ) if( max_color < 0.0001f )
{ {
saturation = 0.f; saturation = 0.f;
} }
else else
{ {
saturation = diff / max_color; saturation = diff / max_color;
} }
@ -98,10 +103,10 @@ struct default_color_converter_impl< rgb_t, hsv_t >
if( saturation < 0.0001f ) if( saturation < 0.0001f )
{ {
//it doesn't matter what value it has //it doesn't matter what value it has
hue = 0.f; hue = 0.f;
} }
else else
{ {
if( temp_red == max_color ) if( temp_red == max_color )
{ {
hue = ( temp_green - temp_blue ) hue = ( temp_green - temp_blue )
@ -109,17 +114,17 @@ struct default_color_converter_impl< rgb_t, hsv_t >
} }
else if( temp_green == max_color ) else if( temp_green == max_color )
{ {
hue = 2.f + ( temp_blue - temp_red ) hue = 2.f + ( temp_blue - temp_red )
/ diff; / diff;
} }
else else
{ {
hue = 4.f + ( temp_red - temp_green ) hue = 4.f + ( temp_red - temp_green )
/ diff; / diff;
} }
//to bring it to a number between 0 and 1 //to bring it to a number between 0 and 1
hue /= 6.f; hue /= 6.f;
if( hue < 0.f ) if( hue < 0.f )
{ {
@ -167,7 +172,7 @@ struct default_color_converter_impl<hsv_t,rgb_t>
frac = h - i; frac = h - i;
// p = value * (1 - saturation) // p = value * (1 - saturation)
p = get_color( src, value_t() ) p = get_color( src, value_t() )
* ( 1.f - get_color( src, saturation_t() )); * ( 1.f - get_color( src, saturation_t() ));
// q = value * (1 - saturation * hue_frac) // q = value * (1 - saturation * hue_frac)
@ -177,11 +182,11 @@ struct default_color_converter_impl<hsv_t,rgb_t>
// t = value * (1 - (saturation * (1 - hue_frac)) // t = value * (1 - (saturation * (1 - hue_frac))
// it grows with increasing distance from floor(hue) // it grows with increasing distance from floor(hue)
t = get_color( src, value_t() ) t = get_color( src, value_t() )
* ( 1.f - ( get_color( src, saturation_t() ) * ( 1.f - frac ))); * ( 1.f - ( get_color( src, saturation_t() ) * ( 1.f - frac )));
switch( i % 6 ) switch( i % 6 )
{ {
case 0: // red to yellow case 0: // red to yellow
{ {
red = get_color( src, value_t() ); red = get_color( src, value_t() );
@ -230,7 +235,7 @@ struct default_color_converter_impl<hsv_t,rgb_t>
case 5: // magenta to red case 5: // magenta to red
{ {
red = get_color( src, value_t() ); red = get_color( src, value_t() );
green = p; green = p;
blue = q; blue = q;
break; break;

View file

@ -30,7 +30,11 @@
#include <mapnik/util/hsl.hpp> #include <mapnik/util/hsl.hpp>
#pragma GCC diagnostic push #pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp> #include <mapnik/warning_ignore.hpp>
#if BOOST_VERSION >= 106900
#include <boost/gil.hpp>
#else
#include <boost/gil/gil_all.hpp> #include <boost/gil/gil_all.hpp>
#endif
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#pragma GCC diagnostic push #pragma GCC diagnostic push