Revert "Reintroduce constexpr to COLOR4D"

This reverts commit 33da9b2327 and the
following commit dc08c48f33.

C++17 changed the behavior of static class member variables that are
constexpr defined. Previously this definition/declaration split was
valid for constexpr members, but after C++17 the static constexpr member
variables are automatically inlined, so the declaration is no longer
exported in some compilers (GCC 9/10/11 seem to have problems).

An alternate way of constexpr member variables is putting the
initialization in the class definition, but we can't init a COLOR4D
object when defining the COLOR4D class.

For now, revert this change until we can figure out the proper way of
architecting these colors.
This commit is contained in:
Ian McInerney 2023-04-06 20:11:40 +01:00
parent dc08c48f33
commit 18ea3be3f2
7 changed files with 5 additions and 45 deletions

View File

@ -521,12 +521,11 @@ COLOR4D& COLOR4D::Desaturate()
return *this;
}
// These call the 5-argument constructor to get a constexpr COLOR4D object.
// The 5th argument isn't actually used at all, so its bool value doesn't matter.
constexpr COLOR4D COLOR4D::UNSPECIFIED( 0, 0, 0, 0, true );
constexpr COLOR4D COLOR4D::WHITE( 1, 1, 1, 1, true );
constexpr COLOR4D COLOR4D::BLACK( 0, 0, 0, 1, true );
constexpr COLOR4D COLOR4D::CLEAR( 1, 0, 1, 0, true );
const COLOR4D COLOR4D::UNSPECIFIED( 0, 0, 0, 0 );
const COLOR4D COLOR4D::WHITE( 1, 1, 1, 1 );
const COLOR4D COLOR4D::BLACK( 0, 0, 0, 1 );
const COLOR4D COLOR4D::CLEAR( 1, 0, 1, 0 );
double COLOR4D::Distance( const COLOR4D& other ) const

View File

@ -72,7 +72,6 @@ target_link_libraries( cvpcb_kiface
3d-viewer
gal
common
gal # Circular dependency between gal and common now
kimath
${PCBNEW_IO_LIBRARIES}
Boost::headers

View File

@ -437,7 +437,6 @@ target_link_libraries( eeschema
# There's way too much crap coming in from common yet.
gal
common
gal # Circular dependency between gal and common now
argparse::argparse
${wxWidgets_LIBRARIES}
)
@ -481,7 +480,6 @@ target_link_libraries( eeschema_kiface
PRIVATE
common
eeschema_kiface_objects
gal # Circular dependency between gal and common now
markdown_lib
scripting
sexpr

View File

@ -112,7 +112,6 @@ target_link_libraries( gerbview
# There's way too much crap coming in from common yet.
gal
common
gal # Circular dependency between gal and common now
core
nlohmann_json
${wxWidgets_LIBRARIES}
@ -156,7 +155,6 @@ target_link_libraries( gerbview_kiface
nlohmann_json
gal
common
gal # Circular dependency between gal and common now
core
gerbview_kiface_objects
${wxWidgets_LIBRARIES}

View File

@ -129,37 +129,6 @@ public:
wxASSERT( a >= 0.0 && a <= 1.0 );
}
/**
* A COLOR4D constructor that is constexpr-capable.
*
* This constructor simply adds a 5th unused argument to differentiate it from
* the normal 4-argument constructor, so any COLOR4D instances that should be compile-time
* created should call this 5-argument version, while everyother instance should use the
* 4-argument version.
*
* @param aRed is the red component [0.0 .. 1.0].
* @param aGreen is the green component [0.0 .. 1.0].
* @param aBlue is the blue component [0.0 .. 1.0].
* @param aAlpha is the alpha value [0.0 .. 1.0].
* @param aIsConst is just an argument to differentiate this constructor from the 4-argument one,
* actual value doesn't matter.
*/
constexpr COLOR4D( double aRed, double aGreen, double aBlue, double aAlpha, bool aIsConst ) :
r( aRed ),
g( aGreen ),
b( aBlue ),
a( aAlpha )
{
/*!!!!!!!!!!!!!!!!!!!!!!
* DO NOT change these to wxASSERT or collapse this into the other constructor,
* it must remain separate to ensure COLOR4D objects can be compile-time constructed
*/
assert( r >= 0.0 && r <= 1.0 );
assert( g >= 0.0 && g <= 1.0 );
assert( b >= 0.0 && b <= 1.0 );
assert( a >= 0.0 && a <= 1.0 );
}
/**
* @param aColor is one of KiCad's palette colors.
* @see EDA_COLOR_T

View File

@ -85,7 +85,6 @@ target_link_libraries( pl_editor
# There's way too much crap coming in from common yet.
gal
common
gal # Circular dependency between gal and common now
core
${wxWidgets_LIBRARIES}
)
@ -104,7 +103,6 @@ add_library( pl_editor_kiface MODULE
target_link_libraries( pl_editor_kiface
gal
common
gal # Circular dependency between gal and common now
core
${wxWidgets_LIBRARIES}
)

View File

@ -626,7 +626,6 @@ make_lexer(
target_link_libraries( pcbnew_kiface_objects
PRIVATE
common
gal # Circular dependency between gal and common now
core
dxflib_qcad
nanosvg