From 84ce72841e5a4d3cdf5eef2a711db849c3fc48b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 21 Mar 2019 20:50:43 +0100 Subject: [PATCH 1/6] Decouple `rtengine/` from `rtgui/edit.h` --- rtengine/dcrop.cc | 2 ++ rtengine/improcfun.cc | 33 +++++++++++++++++++-------------- rtengine/pipettebuffer.cc | 2 ++ rtengine/pipettebuffer.h | 15 +++++++++------ rtgui/editid.h | 2 +- rtgui/mydiagonalcurve.cc | 9 +++++++-- rtgui/myflatcurve.cc | 9 +++++++-- 7 files changed, 47 insertions(+), 25 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 0872049d8..c033dba87 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -24,6 +24,8 @@ #include "refreshmap.h" #include "rt_math.h" +#include "../rtgui/edit.h" + namespace { diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 4e2523137..91f56c015 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -17,33 +17,38 @@ * along with RawTherapee. If not, see . */ #include + #include #include + #ifdef _OPENMP #include #endif -#include "alignedbuffer.h" -#include "rtengine.h" #include "improcfun.h" + +#include "alignedbuffer.h" +#include "calc_distort.h" +#include "ciecam02.h" +#include "clutstore.h" +#include "color.h" #include "curves.h" -#include "mytime.h" +#include "EdgePreservingDecomposition.h" +#include "iccmatrices.h" #include "iccstore.h" #include "imagesource.h" -#include "rtthumbnail.h" -#include "utils.h" -#include "iccmatrices.h" -#include "color.h" -#include "calc_distort.h" -#include "rt_math.h" -#include "EdgePreservingDecomposition.h" #include "improccoordinator.h" -#include "clutstore.h" -#include "ciecam02.h" -#include "StopWatch.h" +#include "mytime.h" #include "procparams.h" -#include "../rtgui/ppversion.h" +#include "rt_math.h" +#include "rtengine.h" +#include "rtthumbnail.h" +#include "StopWatch.h" +#include "utils.h" + +#include "../rtgui/edit.h" #include "../rtgui/guiutils.h" +#include "../rtgui/ppversion.h" #undef CLIPD #define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f) diff --git a/rtengine/pipettebuffer.cc b/rtengine/pipettebuffer.cc index 8981b6480..5f5a5ce71 100644 --- a/rtengine/pipettebuffer.cc +++ b/rtengine/pipettebuffer.cc @@ -19,6 +19,8 @@ #include "pipettebuffer.h" +#include "../rtgui/edit.h" + namespace rtengine { diff --git a/rtengine/pipettebuffer.h b/rtengine/pipettebuffer.h index 139438e1d..25ff55b51 100644 --- a/rtengine/pipettebuffer.h +++ b/rtengine/pipettebuffer.h @@ -16,17 +16,22 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _PIPETTEBUFFER_H_ -#define _PIPETTEBUFFER_H_ +#pragma once -#include "../rtgui/edit.h" #include "array2D.h" -#include "iimage.h" #include "coord.h" +#include "iimage.h" + +class EditDataProvider; +class EditSubscriber; + +enum EditUniqueID : int; namespace rtengine { +class Imagefloat; + /// @brief Structure that contains information about and pointers to the Edit buffer class PipetteBuffer { @@ -92,5 +97,3 @@ public: }; } - -#endif diff --git a/rtgui/editid.h b/rtgui/editid.h index c4f9315c0..5c1cf2389 100644 --- a/rtgui/editid.h +++ b/rtgui/editid.h @@ -21,7 +21,7 @@ /// @brief List of pipette editing operation -enum EditUniqueID { +enum EditUniqueID : int { EUID_None, /// special value (default) EUID_ToneCurve1, diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index 59ac5a807..06e85728d 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -16,11 +16,16 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#include "mydiagonalcurve.h" -#include "../rtengine/curves.h" #include + #include +#include "mydiagonalcurve.h" + +#include "edit.h" + +#include "../rtengine/curves.h" + MyDiagonalCurve::MyDiagonalCurve () : MyCurve(), closest_point(0), diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index ee7a2de5f..dfc61063f 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -16,11 +16,16 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#include "myflatcurve.h" -#include "../rtengine/curves.h" #include + #include +#include "myflatcurve.h" + +#include "edit.h" + +#include "../rtengine/curves.h" + MyFlatCurve::MyFlatCurve () : MyCurve(), clampedX(0.0), From fe74625d78e9feb8c401023724097262f0ac0d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 21 Mar 2019 20:55:31 +0100 Subject: [PATCH 2/6] Fix const correctness of `RTSurface::get()` --- rtgui/rtsurface.cc | 7 ++++++- rtgui/rtsurface.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rtgui/rtsurface.cc b/rtgui/rtsurface.cc index 9f692878d..e2ae41f49 100644 --- a/rtgui/rtsurface.cc +++ b/rtgui/rtsurface.cc @@ -133,7 +133,12 @@ bool RTSurface::hasSurface() const return surface ? true : false; } -const Cairo::RefPtr& RTSurface::get() const +Cairo::RefPtr RTSurface::get() const +{ + return surface; +} + +const Cairo::RefPtr& RTSurface::get() { return surface; } diff --git a/rtgui/rtsurface.h b/rtgui/rtsurface.h index d55506269..64e68d7a1 100644 --- a/rtgui/rtsurface.h +++ b/rtgui/rtsurface.h @@ -45,7 +45,8 @@ public: int getHeight() const; bool hasSurface() const; - const Cairo::RefPtr& get() const; + Cairo::RefPtr get() const; + const Cairo::RefPtr& get(); static void init(); static void updateImages (); From 363385a8381e679a851ba5df9dfda6360f68d9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 21 Mar 2019 21:27:04 +0100 Subject: [PATCH 3/6] Streamline `RTSurface` and fix potential bug in `updateImages()` --- rtgui/rtsurface.cc | 157 +++++++++++++++++++++++---------------------- rtgui/rtsurface.h | 31 ++++----- 2 files changed, 93 insertions(+), 95 deletions(-) diff --git a/rtgui/rtsurface.cc b/rtgui/rtsurface.cc index e2ae41f49..230c3ff4f 100644 --- a/rtgui/rtsurface.cc +++ b/rtgui/rtsurface.cc @@ -19,66 +19,110 @@ #include -#include "options.h" #include "rtsurface.h" +#include "options.h" + namespace { -std::map> surfaceCache; +using SurfaceCache = std::map>; + +SurfaceCache surfaceCache; } -double RTSurface::dpiBack = 0.; -int RTSurface::scaleBack = 0; - -RTSurface::RTSurface () : RTScalable() +RTSurface::RTSurface() : + surface(new Cairo::ImageSurface(nullptr, false)) { - Cairo::RefPtr imgSurf(new Cairo::ImageSurface(nullptr, false)); - surface = imgSurf; } -RTSurface::RTSurface(const RTSurface& other) : RTScalable() +RTSurface::RTSurface(const Glib::ustring& fileName, const Glib::ustring& rtlFileName) : + RTSurface() { - surface = other.surface; + setImage(fileName, rtlFileName); } -RTSurface::RTSurface (Glib::ustring fileName, Glib::ustring rtlFileName) : RTScalable() +void RTSurface::setImage(const Glib::ustring& fileName, const Glib::ustring& rtlFileName) { - Cairo::RefPtr imgSurf(new Cairo::ImageSurface(nullptr, false)); - surface = imgSurf; - setImage (fileName, rtlFileName); -} - -void RTSurface::setImage (Glib::ustring fileName, Glib::ustring rtlFileName) -{ - Glib::ustring imageName; - - if (!rtlFileName.empty() && getDirection() == Gtk::TEXT_DIR_RTL) { - imageName = rtlFileName; - } else { - imageName = fileName; - } + const Glib::ustring& imageName = + !rtlFileName.empty() && getDirection() == Gtk::TEXT_DIR_RTL + ? rtlFileName + : fileName; changeImage (imageName); } -void RTSurface::setDPInScale (const double newDPI, const int newScale) +int RTSurface::getWidth() const { - if (getScale() != newScale || (getScale() == 1 && getDPI() != newDPI)) { - RTScalable::setDPInScale(newDPI, newScale); + return + surface + ? surface->get_width() + : -1; +} + +int RTSurface::getHeight() const +{ + return + surface + ? surface->get_height() + : -1; +} + +bool RTSurface::hasSurface() const +{ + return static_cast(surface); +} + +Cairo::RefPtr RTSurface::get() const +{ + return surface; +} + +const Cairo::RefPtr& RTSurface::get() +{ + return surface; +} + +void RTSurface::init() +{ + dpiBack = getDPI(); + scaleBack = getScale(); +} + +void RTSurface::updateImages() +{ + const double tweakedDpi = getTweakedDPI(); + + for (auto& entry : surfaceCache) { + entry.second = loadImage(entry.first, tweakedDpi); + } +} + +void RTSurface::setDPInScale(const double newDPI, const int newScale) +{ + if ( + getScale() != newScale + || ( + getScale() == 1 + && getDPI() != newDPI + ) + ) { + setDPInScale(newDPI, newScale); dpiBack = getDPI(); scaleBack = getScale(); - //printf("RTSurface::setDPInScale : New scale = %d & new DPI = %.3f (%.3f asked) -> Reloading all RTSurface\n", scaleBack, dpiBack, newDPI); + updateImages(); } } -void RTSurface::changeImage (Glib::ustring imageName) +void RTSurface::changeImage(const Glib::ustring& imageName) { - auto iterator = surfaceCache.find (imageName); + const SurfaceCache::const_iterator iterator = surfaceCache.find(imageName); - if (iterator == surfaceCache.end ()) { + if (iterator != surfaceCache.end()) { + surface = iterator->second; + } else { surface = loadImage(imageName, getTweakedDPI()); // HOMBRE: As of now, GDK_SCALE is forced to 1, so setting the Cairo::ImageSurface scale is not required @@ -92,53 +136,10 @@ void RTSurface::changeImage (Glib::ustring imageName) } */ - iterator = surfaceCache.emplace (imageName, surface).first; - } - - surface = iterator->second; -} - -int RTSurface::getWidth() const -{ - return surface ? surface->get_width() : -1; -} - -int RTSurface::getHeight() const -{ - return surface ? surface->get_height() : -1; -} - -void RTSurface::init() -{ - dpiBack = RTScalable::getDPI(); - scaleBack = RTScalable::getScale(); -} - -void RTSurface::updateImages() -{ - double res = getTweakedDPI(); - for (auto entry : surfaceCache) { - entry.second = loadImage(entry.first, res); - //printf("RTSurface::updateImages : %s\n", entry.first.c_str()); + surfaceCache.emplace(imageName, surface); } } -void RTSurface::from(Glib::RefPtr other) -{ - surface = other->surface; -} +double RTSurface::dpiBack = 0.; -bool RTSurface::hasSurface() const -{ - return surface ? true : false; -} - -Cairo::RefPtr RTSurface::get() const -{ - return surface; -} - -const Cairo::RefPtr& RTSurface::get() -{ - return surface; -} +int RTSurface::scaleBack = 0; diff --git a/rtgui/rtsurface.h b/rtgui/rtsurface.h index 64e68d7a1..c314ab1c1 100644 --- a/rtgui/rtsurface.h +++ b/rtgui/rtsurface.h @@ -19,28 +19,21 @@ #pragma once #include + #include "rtscalable.h" /** * @brief A derived class of Gtk::Image in order to handle theme-related icon sets. */ -class RTSurface : public RTScalable +class RTSurface : + public RTScalable { - -private: - - static double dpiBack; // used to keep track of master dpi change - static int scaleBack; // used to keep track of master scale change - Cairo::RefPtr surface; - void changeImage (Glib::ustring imageName); - public: + RTSurface(); + RTSurface(const Glib::ustring& fileName, const Glib::ustring& rtlFileName = {}); - RTSurface (); - RTSurface (const RTSurface& other); - RTSurface (Glib::ustring fileName, Glib::ustring rtlFileName = Glib::ustring()); + void setImage(const Glib::ustring& fileName, const Glib::ustring& rtlFileName = {}); - void setImage (Glib::ustring fileName, Glib::ustring rtlFileName = Glib::ustring()); int getWidth() const; int getHeight() const; bool hasSurface() const; @@ -49,9 +42,13 @@ public: const Cairo::RefPtr& get(); static void init(); - static void updateImages (); - static void setDPInScale (const double newDPI, const int newScale); - static void setScale (const int newScale); + static void updateImages(); + static void setDPInScale(double newDPI, int newScale); - void from(Glib::RefPtr other); +private: + void changeImage(const Glib::ustring& imageName); + + static double dpiBack; // used to keep track of master dpi change + static int scaleBack; // used to keep track of master scale change + Cairo::RefPtr surface; }; From e172dcabdaea64bb5f9fc587055b1ba9f0e98348 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Sun, 7 Jul 2019 07:48:34 -0400 Subject: [PATCH 4/6] Fix misc. typos and whitespace Found via `codespell -q 3 -I ../rawtherapy-whitelist.txt -S ./rtdata/languages -L hist,fo,reall,bloc,alph,dof,thre,makro,chang,currentry,portugues,vektor,ue` --- rtengine/LUT.h | 2 +- rtengine/color.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rtengine/LUT.h b/rtengine/LUT.h index 9f16995d0..6584eefe6 100644 --- a/rtengine/LUT.h +++ b/rtengine/LUT.h @@ -563,7 +563,7 @@ public: } } - // compress a LUT with size y into a LUT with size x (y>x) by using the passTrough LUT to calculate indexes + // compress a LUT with size y into a LUT with size x (y>x) by using the passThrough LUT to calculate indexes template::value>::type> void compressTo(LUT &dest, unsigned int numVals, const LUT &passThrough) const { diff --git a/rtengine/color.h b/rtengine/color.h index a94302e30..fb4eea458 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -102,7 +102,7 @@ private: static float computeXYZ2Lab(float f); static float computeXYZ2LabY(float f); - + public: typedef enum Channel { @@ -1094,7 +1094,7 @@ public: //very small differences between the 2 return x <= 0.003040 ? x * 12.92310 : 1.055 * exp(log(x) / sRGBGammaCurve) - 0.055;//continuous // return x <= 0.003041 ? x * 12.92310 : 1.055011 * exp(log(x) / sRGBGammaCurve) - 0.055011;//continuous - + } @@ -1111,7 +1111,7 @@ public: //very small differences between the 4 return x <= 0.039286 ? x / 12.92310 : exp(log((x + 0.055) / 1.055) * sRGBGammaCurve);//continuous // return x <= 0.039293 ? x / 12.92310 : exp(log((x + 0.055011) / 1.055011) * sRGBGammaCurve);//continuous - + } @@ -1509,8 +1509,8 @@ public: static const float C9 = 8.f, C8 = 15.f, C7 = 12.f, C4 = 7.f, C3 = 5.f, C2 = 5.f, C1 = 5.f; static const float H9 = 0.05f, H8 = 0.25f, H7 = 0.1f, H4 = 0.02f, H3 = 0.02f, H2 = 0.1f, H1 = 0.1f, H10 = -0.2f, H11 = -0.2f; - // "real" skin color : take into account a slightly usage of contrast and saturation in RT if option "skin" = 1, uses imolicit factor 1.0 - // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 + // "real" skin color : take into account a slight usage of contrast and saturation in RT if option "skin" = 1, uses implicit factor 1.0 + // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit factor 0.6 // wide area for transition, uses explicit factor 0.4 if (lum >= 85.0f) { @@ -1588,8 +1588,8 @@ public: static const float C9 = 8.f, C8 = 15.f, C7 = 12.f, C4 = 7.f, C3 = 5.f, C2 = 5.f, C1 = 5.f; static const float H9 = 0.05f, H8 = 0.25f, H7 = 0.1f, H4 = 0.02f, H3 = 0.02f, H2 = 0.1f, H1 = 0.1f, H10 = -0.2f, H11 = -0.2f; - // "real" skin color : take into account a slightly usage of contrast and saturation in RT if option "skin" = 1, uses imolicit factor 1.0 - // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 + // "real" skin color : take into account a slight usage of contrast and saturation in RT if option "skin" = 1, uses implicit factor 1.0 + // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit factor 0.6 // wide area for transition, uses explicit factor 0.4 if((b_l > -0.3f && b_r < 2.f) || basc == 0) { //range maxi skin if (lum >= 85.0f) { @@ -1704,8 +1704,8 @@ public: hue = HH; - // "real" skin color : take into account a slightly usage of contrast and saturation in RT if option "skin" = 1, uses imolicit factor 1.0 - // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit facor 0.6 + // "real" skin color : take into account a slight usage of contrast and saturation in RT if option "skin" = 1, uses implicit factor 1.0 + // wide area skin color, useful if not accurate colorimetry or if the user has changed hue and saturation, uses explicit factor 0.6 // wide area for transition, uses explicit factor 0.4 if (lum >= 85.0f) { From bcc727e1cf5e9fb6d0a85dba5d20059b82fa7440 Mon Sep 17 00:00:00 2001 From: Morgan Hardwood Date: Sun, 7 Jul 2019 22:45:30 +0200 Subject: [PATCH 5/6] Sony DSC-R1 camconst.json entry, closes #5359 Confirmed wl in commit 9ea964f5d. Updating quality level to B thanks to sample set in #5359 (not A as sample set lacks LENR). --- rtengine/camconst.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/camconst.json b/rtengine/camconst.json index 0ae967fc0..97a14f66e 100644 --- a/rtengine/camconst.json +++ b/rtengine/camconst.json @@ -2461,7 +2461,7 @@ Camera constants: "raw_crop": [ 0, 0, -8, 0 ] // 8 rightmost columns are garbage }, - { // Quality C + { // Quality B "make_model": [ "Sony DSC-R1" ], "raw_crop": [ 0, 0, 3924, 2608 ], "ranges": { "white": 16368 } From 3b78a5c22720f6128e15a34e81212b011d3f3eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Tue, 9 Jul 2019 13:18:08 +0200 Subject: [PATCH 6/6] Minor cleanups after #5315 and #5368 --- rtengine/dfmanager.cc | 6 +++--- rtgui/mydiagonalcurve.cc | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/rtengine/dfmanager.cc b/rtengine/dfmanager.cc index 4696af1a1..c41c8a180 100644 --- a/rtengine/dfmanager.cc +++ b/rtengine/dfmanager.cc @@ -257,7 +257,7 @@ void dfInfo::updateBadPixelList( RawImage *df ) } if( df->data[row][3 * col] > m[0]*threshold || df->data[row][3 * col + 1] > m[1]*threshold || df->data[row][3 * col + 2] > m[2]*threshold) { - badPixels.push_back( badPix(col, row) ); + badPixels.emplace_back(col, row); } } } @@ -571,7 +571,7 @@ int DFManager::scanBadPixelsFile( Glib::ustring filename ) while( fgets(line, sizeof(line), file ) ) { if( sscanf(line, "%d %d", &x, &y) == 2 ) { - bp.push_back( badPix(x + offset, y + offset) ); + bp.emplace_back(x + offset, y + offset); } } } @@ -592,7 +592,7 @@ std::vector *DFManager::getBadPixels ( const std::string &mak, const std bool found = false; if( !serial.empty() ) { - // search with sreial number first + // search with serial number first std::ostringstream s; s << mak << " " << mod << " " << serial; iter = bpList.find( s.str() ); diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index 64da24607..a3e7b9375 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -25,8 +25,6 @@ #include "editcallbacks.h" #include "../rtengine/curves.h" -#include -#include MyDiagonalCurve::MyDiagonalCurve () : MyCurve(),