@@ -133,6 +133,25 @@ static bool toneCurvesSimilar(cmsToneCurve* a, cmsToneCurve* b) {
133133 return true ;
134134}
135135
136+ static std::string dumpToneCurve (cmsToneCurve* c) {
137+ if (!c)
138+ return " " ;
139+
140+ std::string res = " [" ;
141+
142+ for (int i = 0 ; i <= 256 ; ++i) {
143+ double x = (double )i / 256.0 ;
144+ double y = cmsEvalToneCurveFloat (c, x);
145+ res += std::format (" {}, " , y);
146+ }
147+
148+ res.pop_back ();
149+ res.pop_back ();
150+ res += " ]" ;
151+
152+ return res;
153+ }
154+
136155std::expected<SImageDescription, std::string> SImageDescription::fromICC (const std::filesystem::path& file) {
137156 std::error_code ec;
138157 if (!std::filesystem::exists (file, ec) || ec)
@@ -205,10 +224,16 @@ std::expected<SImageDescription, std::string> SImageDescription::fromICC(const s
205224 cmsToneCurve* trcG = (cmsToneCurve*)cmsReadTag (prof, cmsSigGreenTRCTag);
206225 cmsToneCurve* trcB = (cmsToneCurve*)cmsReadTag (prof, cmsSigBlueTRCTag);
207226
227+ Log::logger->log (Log::DEBUG, " TRC R: {}" , dumpToneCurve (trcR));
228+ Log::logger->log (Log::DEBUG, " TRC G: {}" , dumpToneCurve (trcG));
229+ Log::logger->log (Log::DEBUG, " TRC B: {}" , dumpToneCurve (trcB));
230+
208231 // FIXME: make this representable...
209232 cmsToneCurve* trc = trcR;
210- if (trcR && trcG && trcB && (!toneCurvesSimilar (trcR, trcG) || !toneCurvesSimilar (trcR, trcB)))
233+ if (trcR && trcG && trcB && (!toneCurvesSimilar (trcR, trcG) || !toneCurvesSimilar (trcR, trcB))) {
234+ Log::logger->log (Log::DEBUG, " ============= End ICC load =============" );
211235 return std::unexpected (" Hyprland cannot represent split-trc profiles yet" );
236+ }
212237
213238 if (trc) {
214239 if (cmsIsToneCurveLinear (trc)) {
@@ -230,7 +255,8 @@ std::expected<SImageDescription, std::string> SImageDescription::fromICC(const s
230255 else
231256 image.transferFunction = CM_TRANSFER_FUNCTION_EXT_SRGB;
232257 } else {
233- Log::logger->log (Log::DEBUG, " TRC: Gamma fit failed" );
258+ Log::logger->log (Log::DEBUG, " TRC: Gamma fit failed, falling back to srgb" );
259+ image.transferFunction = CM_TRANSFER_FUNCTION_SRGB;
234260 }
235261 }
236262 }
0 commit comments