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 24425f9ba5
commit 4698d43234
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 {};
}
/// \}
@ -98,12 +103,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 );
}
@ -112,7 +117,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;
}
@ -120,8 +125,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;
}
@ -129,13 +134,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;
@ -173,29 +178,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 )
@ -203,7 +208,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;
@ -214,7 +219,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
@ -222,7 +227,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;
@ -241,7 +246,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;
@ -252,7 +257,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 {};
}
/// \}
@ -80,11 +85,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;
}
@ -92,10 +97,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 )
@ -103,17 +108,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 )
{
@ -161,7 +166,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)
@ -171,11 +176,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() );
@ -224,7 +229,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

@ -31,7 +31,11 @@
#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