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"
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 106900
#include <boost/gil.hpp>
#else
#include <boost/gil/gil_all.hpp>
#endif
#include <boost/gil/extension/toolbox/hsv.hpp>
#include <boost/gil/extension/toolbox/hsl.hpp>
#pragma GCC diagnostic pop

View file

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

View file

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

View file

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