File indexing completed on 2024-05-12 04:44:34
0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com> 0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT 0003 0004 // Own header 0005 #include "lchadouble.h" 0006 0007 #include <type_traits> 0008 0009 #include <lcms2.h> 0010 0011 /** @internal 0012 * 0013 * @file 0014 * 0015 * This file defines some static asserts for the data type 0016 * @ref PerceptualColor::LchaDouble. */ 0017 0018 namespace PerceptualColor 0019 { 0020 // We are using double. Check that we stay compatible with cmsCIELCh 0021 // which is based on cmsFloat64Number. 0022 static_assert(std::is_same_v<cmsFloat64Number, double>); 0023 0024 static_assert(sizeof(double) == sizeof(cmsFloat64Number)); 0025 0026 static_assert(std::is_trivially_copyable_v<LchaDouble>); 0027 static_assert(std::is_trivial_v<LchaDouble>); 0028 0029 static_assert(std::is_standard_layout_v<LchaDouble>); 0030 0031 static_assert(std::is_default_constructible_v<LchaDouble>); 0032 static_assert(std::is_trivially_default_constructible_v<LchaDouble>); 0033 static_assert(std::is_nothrow_default_constructible_v<LchaDouble>); 0034 0035 static_assert(std::is_copy_constructible_v<LchaDouble>); 0036 static_assert(std::is_trivially_copy_constructible_v<LchaDouble>); 0037 static_assert(std::is_nothrow_copy_constructible_v<LchaDouble>); 0038 0039 static_assert(std::is_move_constructible_v<LchaDouble>); 0040 static_assert(std::is_trivially_move_constructible_v<LchaDouble>); 0041 static_assert(std::is_nothrow_move_constructible_v<LchaDouble>); 0042 0043 /** @brief Adds QDebug() support for data type 0044 * @ref PerceptualColor::LchaDouble 0045 * 0046 * @param dbg Existing debug object 0047 * @param value Value to stream into the debug object 0048 * @returns Debug object with value streamed in 0049 * 0050 * @internal 0051 * 0052 * @todo This is originally declared in the global namespace instead of 0053 * the @ref PerceptualColor namespace, because the supported value was 0054 * a <tt>typedef</tt> for a LittleCMS type in the global; when declaring 0055 * this function in @ref PerceptualColor namespace, it did not work 0056 * in the global namespace. Now, things have changed. But we should write 0057 * a unit test for if it works in global namespace! */ 0058 QDebug operator<<(QDebug dbg, const PerceptualColor::LchaDouble &value) 0059 { 0060 dbg.nospace() << "LchaDouble(" << value.l << "% " << value.c << " " << value.h << "° " << value.a << ")"; 0061 return dbg.maybeSpace(); 0062 } 0063 0064 /** @brief Compares coordinates with another object. 0065 * 0066 * @param other The object to compare with 0067 * @returns <tt>true</tt> if all three coordinates @ref l, @ref c and @ref h 0068 * of <em>this</em> object are all equal to the coordinates of <em>other</em>. 0069 * <tt>false</tt> otherwise. Note that two objects with equal @ref l and 0070 * equal @ref c, but one with h = 5° and the other with h = 365°, are 0071 * considered non-equal thought both describe the same point in the 0072 * coordinate space. */ 0073 bool LchaDouble::hasSameCoordinates(const PerceptualColor::LchaDouble &other) const 0074 { 0075 return ((l == other.l) && (c == other.c) && (h == other.h) && (a == other.a)); 0076 } 0077 0078 } // namespace PerceptualColor