From bae6491f9adca83b6ca2ba22e1d4eee9df80d18a Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 26 Apr 2024 22:04:35 +0800 Subject: [PATCH] Revert breaking commit as a temporary fix Reverts https://github.com/Beep6581/RawTherapee/commit/8accebe4161c581c76dda4edee027b95ec109ea9 --- rtengine/improcfun.cc | 20 -------------- rtengine/improcfun.h | 2 -- rtgui/cropwindow.cc | 10 +++---- rtgui/histogrampanel.cc | 52 ++++++++++------------------------- rtgui/histogrampanel.h | 8 +++--- rtgui/lockablecolorpicker.cc | 23 ++-------------- rtgui/lockablecolorpicker.h | 17 ++---------- rtgui/navigator.cc | 25 +++-------------- rtgui/navigator.h | 4 +-- rtgui/pointermotionlistener.h | 19 +------------ 10 files changed, 36 insertions(+), 144 deletions(-) diff --git rtengine/improcfun.cc rtengine/improcfun.cc index 2e02a352c..36b1d6544 100644 --- rtengine/improcfun.cc +++ rtengine/improcfun.cc @@ -5723,11 +5723,6 @@ void ImProcFunctions::rgb2lab(const Imagefloat &src, LabImage &dst, const Glib:: } void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, float L[], float a[], float b[], const procparams::ColorManagementParams &icm, bool consider_histogram_settings) const -{ - rgb2lab(src, x, y, w, h, L, a, b, icm, consider_histogram_settings, multiThread); -} - -void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, float L[], float a[], float b[], const procparams::ColorManagementParams &icm, bool consider_histogram_settings, bool multiThread) { // Adapted from ImProcFunctions::lab2rgb const int src_width = src.getWidth(); @@ -5840,21 +5835,6 @@ void ImProcFunctions::rgb2lab(const Image8 &src, int x, int y, int w, int h, flo } } -void ImProcFunctions::rgb2lab(std::uint8_t red, std::uint8_t green, std::uint8_t blue, float &L, float &a, float &b, const procparams::ColorManagementParams &icm, bool consider_histogram_settings) -{ - float l_channel[1]; - float a_channel[1]; - float b_channel[1]; - rtengine::Image8 buf(1, 1); - buf.r(0, 0) = red; - buf.g(0, 0) = green; - buf.b(0, 0) = blue; - ImProcFunctions::rgb2lab(buf, 0, 0, 1, 1, l_channel, a_channel, b_channel, icm, consider_histogram_settings, false); - L = l_channel[0]; - a = a_channel[0]; - b = b_channel[0]; -} - void ImProcFunctions::lab2rgb(const LabImage &src, Imagefloat &dst, const Glib::ustring &workingSpace) { TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix(workingSpace); diff --git rtengine/improcfun.h rtengine/improcfun.h index 19d8b0a03..0f23fefa9 100644 --- rtengine/improcfun.h +++ rtengine/improcfun.h @@ -117,7 +117,6 @@ class ImProcFunctions bool multiThread; void calcVignettingParams(int oW, int oH, const procparams::VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul); - static void rgb2lab(const Image8 &src, int x, int y, int w, int h, float L[], float a[], float b[], const procparams::ColorManagementParams &icm, bool consider_histogram_settings, bool multithread); void transformLuminanceOnly(Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap, bool useOriginalBuffer); @@ -502,7 +501,6 @@ enum class BlurType { Image8* lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true); void rgb2lab(const Image8 &src, int x, int y, int w, int h, float L[], float a[], float b[], const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true) const; - static void rgb2lab(std::uint8_t red, std::uint8_t green, std::uint8_t blue, float &L, float &a, float &b, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true); Imagefloat* lab2rgbOut(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm); // CieImage *ciec; void workingtrc(const Imagefloat* src, Imagefloat* dst, int cw, int ch, int mul, Glib::ustring &profile, double gampos, double slpos, int &illum, int prim, cmsHTRANSFORM &transform, bool normalizeIn = true, bool normalizeOut = true, bool keepTransForm = false) const; diff --git rtgui/cropwindow.cc rtgui/cropwindow.cc index ef2b7a52b..883928a21 100644 --- rtgui/cropwindow.cc +++ rtgui/cropwindow.cc @@ -403,7 +403,7 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y) // Add a new Color Picker rtengine::Coord imgPos; screenCoordToImage(x, y, imgPos.x, imgPos.y); - LockableColorPicker *newPicker = new LockableColorPicker(this, cropHandler.colorParams.get()); + LockableColorPicker *newPicker = new LockableColorPicker(this, &cropHandler.colorParams->outputProfile, &cropHandler.colorParams->workingProfile); colorPickers.push_back(newPicker); hoveredPicker = newPicker; updateHoveredPicker(&imgPos); @@ -1095,10 +1095,10 @@ void CropWindow::pointerMoved (int bstate, int x, int y) printf("Using \"%s\" output\n", outputProfile.c_str()); if(outputProfile==options.rtSettings.srgb) printf("OK SRGB2"); */ - pmlistener->pointerMoved (false, *cropHandler.colorParams, mx, my, -1, -1, -1); + pmlistener->pointerMoved (false, cropHandler.colorParams->outputProfile, cropHandler.colorParams->workingProfile, mx, my, -1, -1, -1); if (pmhlistener) { - pmhlistener->pointerMoved (false, *cropHandler.colorParams, mx, my, -1, -1, -1); + pmhlistener->pointerMoved (false, cropHandler.colorParams->outputProfile, cropHandler.colorParams->workingProfile, mx, my, -1, -1, -1); } } else { @@ -1145,11 +1145,11 @@ void CropWindow::pointerMoved (int bstate, int x, int y) // Updates the Navigator // TODO: possible double color conversion if rval, gval, bval come from cropHandler.cropPixbuftrue ? see issue #4583 - pmlistener->pointerMoved (true, *cropHandler.colorParams, mx, my, rval, gval, bval, isRaw); + pmlistener->pointerMoved (true, cropHandler.colorParams->outputProfile, cropHandler.colorParams->workingProfile, mx, my, rval, gval, bval, isRaw); if (pmhlistener) { // Updates the HistogramRGBArea - pmhlistener->pointerMoved (true, *cropHandler.colorParams, mx, my, rval, gval, bval); + pmhlistener->pointerMoved (true, cropHandler.colorParams->outputProfile, cropHandler.colorParams->workingProfile, mx, my, rval, gval, bval); } } } diff --git rtgui/histogrampanel.cc rtgui/histogrampanel.cc index b804218f5..86305adb9 100644 --- rtgui/histogrampanel.cc +++ rtgui/histogrampanel.cc @@ -22,11 +22,10 @@ #include "options.h" #include #include -#include "rtimage.h" #include "../rtengine/array2D.h" -#include "../rtengine/color.h" -#include "../rtengine/improcfun.h" #include "../rtengine/LUT.h" +#include "rtimage.h" +#include "../rtengine/color.h" using namespace rtengine; @@ -35,20 +34,12 @@ constexpr float HistogramArea::MIN_BRIGHT; using ScopeType = Options::ScopeType; - -namespace -{ - -const rtengine::procparams::ColorManagementParams DEFAULT_CMP; - -} - // // // HistogramPanel HistogramPanel::HistogramPanel () : pointer_moved_delayed_call( - [this](bool validPos, const rtengine::procparams::ColorManagementParams *cmp, int r, int g, int b) + [this](bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int r, int g, int b) { bool update_hist_area; @@ -61,9 +52,9 @@ HistogramPanel::HistogramPanel () : } else { // do something to show vertical bars if (histogramRGBArea) { - histogramRGBArea->updateBackBuffer(r, g, b, cmp); + histogramRGBArea->updateBackBuffer(r, g, b, profile, profileW); } - update_hist_area = histogramArea->updatePointer(r, g, b, cmp); + update_hist_area = histogramArea->updatePointer(r, g, b, profile, profileW); } if (histogramRGBArea) { histogramRGBArea->queue_draw(); @@ -632,9 +623,9 @@ void HistogramPanel::setHistRGBInvalid () histogramRGBArea->queue_draw (); } -void HistogramPanel::pointerMoved(bool validPos, const rtengine::procparams::ColorManagementParams &cmp, int x, int y, int r, int g, int b, bool isRaw) +void HistogramPanel::pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw) { - pointer_moved_delayed_call(validPos, &cmp, r, g, b); + pointer_moved_delayed_call(validPos, profile, profileW, r, g, b); } /* @@ -806,7 +797,7 @@ void HistogramRGBArea::setShow(bool show) showMode = show; } -void HistogramRGBArea::updateBackBuffer(int r, int g, int b, const rtengine::procparams::ColorManagementParams *cmp) +void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustring &profile, const Glib::ustring &profileW) { if (!get_realized () || !showMode || !( options.histogramScopeType == ScopeType::HISTOGRAM @@ -865,25 +856,19 @@ void HistogramRGBArea::updateBackBuffer(int r, int g, int b, const rtengine::pro || options.histogramScopeType == ScopeType::WAVEFORM) ) { float Lab_L, Lab_a, Lab_b; - ImProcFunctions::rgb2lab( - static_cast(r), - static_cast(g), - static_cast(b), - Lab_L, Lab_a, Lab_b, - cmp != nullptr ? *cmp : DEFAULT_CMP, - true); + rtengine::Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, Lab_L, Lab_a, Lab_b, options.rtSettings.HistogramWorking); if (needLuma) { // Luma cc->set_source_rgb(1.0, 1.0, 1.0); - drawBar(cc, Lab_L, 32768., winw, winh, s); + drawBar(cc, Lab_L, 100.0, winw, winh, s); } if (needChroma && options.histogramScopeType == ScopeType::HISTOGRAM) { // Chroma - double chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / (255. * 188); + double chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / 1.8; cc->set_source_rgb(0.9, 0.9, 0.0); - drawBar(cc, chromaval, 1.0, winw, winh, s); + drawBar(cc, chromaval, 100.0, winw, winh, s); } } } @@ -1458,7 +1443,7 @@ void HistogramArea::updateBackBuffer () setDirty(false); } -bool HistogramArea::updatePointer(int r, int g, int b, const rtengine::procparams::ColorManagementParams *cmp) +bool HistogramArea::updatePointer(int r, int g, int b, const Glib::ustring &profile, const Glib::ustring &profileW) { if (!needPointer || !(scopeType == ScopeType::VECTORSCOPE_HC || scopeType == ScopeType::VECTORSCOPE_HS)) { return false; @@ -1471,16 +1456,7 @@ bool HistogramArea::updatePointer(int r, int g, int b, const rtengine::procparam pointer_red = r; pointer_green = g; pointer_blue = b; - ImProcFunctions::rgb2lab( - static_cast(r), - static_cast(g), - static_cast(b), - L, pointer_a, pointer_b, - cmp != nullptr ? *cmp : DEFAULT_CMP, - true); - L /= 327.68f; - pointer_a /= 327.68f; - pointer_b /= 327.68f; + Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, L, pointer_a, pointer_b, options.rtSettings.HistogramWorking); updateBackBuffer(); return true; } diff --git rtgui/histogrampanel.h rtgui/histogrampanel.h index 7f165bb15..26b744546 100644 --- rtgui/histogrampanel.h +++ rtgui/histogrampanel.h @@ -99,7 +99,7 @@ public: HistogramRGBArea(); ~HistogramRGBArea() override; - void updateBackBuffer(int r, int g, int b, const rtengine::procparams::ColorManagementParams *cmp = nullptr); + void updateBackBuffer (int r, int g, int b, const Glib::ustring &profile = "", const Glib::ustring &profileW = ""); bool getShow (); void setShow(bool show); void setParent (Gtk::Grid* p) @@ -206,7 +206,7 @@ public: void updateBackBuffer (); /// Update pointer values. Returns true if widget needs redrawing. - bool updatePointer(int r, int g, int b, const rtengine::procparams::ColorManagementParams *cmp = nullptr); + bool updatePointer(int r, int g, int b, const Glib::ustring &profile = "", const Glib::ustring &profileW = ""); void update( const LUTu& histRed, const LUTu& histGreen, @@ -260,7 +260,7 @@ public: class HistogramPanel final : public Gtk::Grid, public PointerMotionListener, public DrawModeListener, public rtengine::NonCopyable { private: - DelayedCall pointer_moved_delayed_call; + DelayedCall pointer_moved_delayed_call; protected: @@ -343,7 +343,7 @@ public: histogramArea->update(histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw, vectorscopeScale, vectorscopeHC, vectorscopeHS, waveformScale, waveformRed, waveformGreen, waveformBlue, waveformLuma); } // pointermotionlistener interface - void pointerMoved (bool validPos, const rtengine::procparams::ColorManagementParams &cmp, int x, int y, int r, int g, int b, bool isRaw = false) override; + void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw = false) override; // TODO should be protected void setHistRGBInvalid (); diff --git rtgui/lockablecolorpicker.cc rtgui/lockablecolorpicker.cc index c87239b9c..0a08bb945 100644 --- rtgui/lockablecolorpicker.cc +++ rtgui/lockablecolorpicker.cc @@ -20,23 +20,15 @@ #include "lockablecolorpicker.h" #include "options.h" #include "../rtengine/color.h" -#include "../rtengine/improcfun.h" #include "../rtengine/rt_math.h" #include "../rtengine/utils.h" #include "imagearea.h" #include "multilangmgr.h" #include "navigator.h" -namespace -{ - -const rtengine::procparams::ColorManagementParams DEFAULT_CMP; - -} - -LockableColorPicker::LockableColorPicker (CropWindow* cropWindow, rtengine::procparams::ColorManagementParams *color_management_params) +LockableColorPicker::LockableColorPicker (CropWindow* cropWindow, Glib::ustring *oProfile, Glib::ustring *wProfile) : cropWindow(cropWindow), displayedValues(ColorPickerType::RGB), position(0, 0), size(Size::S15), - color_management_params(color_management_params), validity(Validity::OUTSIDE), + outputProfile(oProfile), workingProfile(wProfile), validity(Validity::OUTSIDE), r(0.f), g(0.f), b(0.f), rpreview(0.f), gpreview(0.f), bpreview(0.f), hue(0.f), sat(0.f), val(0.f), L(0.f), a(0.f), bb(0.f) {} @@ -285,16 +277,7 @@ void LockableColorPicker::setRGB (const float R, const float G, const float B, c bpreview = previewB; rtengine::Color::rgb2hsv01(r, g, b, hue, sat, val); - rtengine::ImProcFunctions::rgb2lab( - static_cast(255 * r), - static_cast(255 * g), - static_cast(255 * b), - L, a, bb, - color_management_params != nullptr ? *color_management_params : DEFAULT_CMP, - true); - L /= 327.68f; - a /= 327.68f; - bb /= 327.68f; + rtengine::Color::rgb2lab01(*outputProfile, *workingProfile, r, g, b, L, a, bb, options.rtSettings.HistogramWorking); // TODO: Really sure this function works? if (validity != Validity::OUTSIDE) { setDirty(true); diff --git rtgui/lockablecolorpicker.h rtgui/lockablecolorpicker.h index 3de6256e9..baeea41ef 100644 --- rtgui/lockablecolorpicker.h +++ rtgui/lockablecolorpicker.h @@ -24,18 +24,6 @@ class CropWindow; -namespace rtengine -{ - -namespace procparams -{ - -struct ColorManagementParams; - -} - -} - class LockablePickerToolListener { public: @@ -72,7 +60,8 @@ private: rtengine::Coord position; // Coordinate in image space rtengine::Coord anchorOffset; Size size; - rtengine::procparams::ColorManagementParams *color_management_params; + Glib::ustring *outputProfile; + Glib::ustring *workingProfile; Validity validity; float r, g, b; // red green blue in [0;1] range float rpreview, gpreview, bpreview; @@ -83,7 +72,7 @@ private: public: - LockableColorPicker (CropWindow* cropWindow, rtengine::procparams::ColorManagementParams *color_management_params); + LockableColorPicker (CropWindow* cropWindow, Glib::ustring *oProfile, Glib::ustring *wProfile); void draw (const Cairo::RefPtr &cr); diff --git rtgui/navigator.cc rtgui/navigator.cc index a02e0aff8..5e5ba59f2 100644 --- rtgui/navigator.cc +++ rtgui/navigator.cc @@ -21,26 +21,18 @@ #include "previewwindow.h" #include "toolpanel.h" #include "../rtengine/color.h" -#include "../rtengine/improcfun.h" #include "../rtengine/rt_math.h" #include "options.h" using namespace rtengine; -namespace -{ - -const rtengine::procparams::ColorManagementParams DEFAULT_CMP; - -} - Navigator::Navigator() : pointer_moved_delayed_call(50, 100), currentRGBUnit(options.navRGBUnit), currentHSVUnit(options.navHSVUnit) { pointer_moved_delayed_call.setFunction( - [this](bool validPos, const rtengine::procparams::ColorManagementParams *cmp, int x, int y, int r, int g, int b, bool isRaw) + [this](bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b, bool isRaw) { if (!validPos) { setInvalid (x, y); @@ -69,16 +61,7 @@ Navigator::Navigator() : S->set_text (s2); V->set_text (s3); - ImProcFunctions::rgb2lab( - static_cast(r), - static_cast(g), - static_cast(b), - LAB_l, LAB_a, LAB_b, - cmp != nullptr ? *cmp : DEFAULT_CMP, - true); - LAB_l /= 327.68f; - LAB_a /= 327.68f; - LAB_b /= 327.68f; + Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, LAB_l, LAB_a, LAB_b, options.rtSettings.HistogramWorking); // TODO: Really sure this function works? getLABText (LAB_l, LAB_a, LAB_b, s1, s2, s3); LAB_L->set_text (s1); LAB_A->set_text (s2); @@ -345,9 +328,9 @@ void Navigator::getLABText (float l, float a, float b, Glib::ustring &sL, Glib:: } // if !validPos then x/y contain the full image size -void Navigator::pointerMoved (bool validPos, const rtengine::procparams::ColorManagementParams &cmp, int x, int y, int r, int g, int b, bool isRaw) +void Navigator::pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw) { - pointer_moved_delayed_call(validPos, &cmp, x, y, r, g, b, isRaw); + pointer_moved_delayed_call(validPos, profile, profileW, x, y, r, g, b, isRaw); } void Navigator::cycleUnitsRGB (GdkEventButton *event) { diff --git rtgui/navigator.h rtgui/navigator.h index c16bf7ac7..4c2a3fd32 100644 --- rtgui/navigator.h +++ rtgui/navigator.h @@ -34,7 +34,7 @@ class Navigator final : typedef const double (*TMatrix)[3]; private: - DelayedCall pointer_moved_delayed_call; + DelayedCall pointer_moved_delayed_call; Options::NavigatorUnit currentRGBUnit; Options::NavigatorUnit currentHSVUnit; @@ -61,7 +61,7 @@ public: // pointermotionlistener interface // void pointerMoved (bool validPos, int x, int y, int r, int g, int b); - void pointerMoved(bool validPos, const rtengine::procparams::ColorManagementParams &cmp, int x, int y, int r, int g, int b, bool raw = false) override; + void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool raw = false) override; void setInvalid (int fullWidth = -1, int fullHeight = -1); void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB, bool isRaw = false) override; diff --git rtgui/pointermotionlistener.h rtgui/pointermotionlistener.h index 2f19ae0b9..26ca994b0 100644 --- rtgui/pointermotionlistener.h +++ rtgui/pointermotionlistener.h @@ -18,23 +18,6 @@ */ #pragma once -#include -#include - - -namespace rtengine -{ - -namespace procparams -{ - -struct ColorManagementParams; - -} - -} - - class PointerMotionListener { protected: @@ -43,7 +26,7 @@ protected: public: virtual ~PointerMotionListener() = default; - virtual void pointerMoved(bool validPos, const rtengine::procparams::ColorManagementParams &cmp, int x, int y, int r, int g, int b, bool isRaw = false) = 0; + virtual void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw = false) = 0; virtual void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB, bool isRaw = false) { sR = "--"; sG = "--"; sB = "--"; } virtual void getHSVText (float h, float s, float v, Glib::ustring &sH, Glib::ustring &sS, Glib::ustring &sV) { sH = "--"; sS = "--"; sV = "--"; } virtual void getLABText (float l, float a, float b, Glib::ustring &sL, Glib::ustring &sA, Glib::ustring &sB) { sL = "--"; sA = "--"; sB = "--"; }