From 871c75e4948322434e24982c432674217f7ca9ce Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sat, 8 Apr 2017 10:13:53 +0200 Subject: [PATCH 01/10] Correctly apply LCP "distortion" correction for Fisheye lenses Note: as discussed e.g. at http://lensfun.sourceforge.net/manual/corrections.html, this is really a combination of distortion correction and change of projection (from fisheye to rectilinear), but "distortion correction" is how the Adobe camera model calls it, and this is how it appears in the RT gui --- rtengine/iptransform.cc | 38 +++++++++++++++++++------------ rtengine/lcp.cc | 50 ++++++++++++++++++++++++++++++++--------- rtengine/lcp.h | 3 ++- 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 04ba4966d..399711c2e 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -85,16 +85,17 @@ float normn (float a, float b, int n) } } -void correct_distortion (const rtengine::LCPMapper *lcp, double &x, double &y, - int cx, int cy) + +void correct_distortion(const rtengine::LCPMapper *lcp, double &x, double &y, + int cx, int cy, double scale) { assert (lcp); x += cx; y += cy; - lcp->correctDistortion (x, y); - x -= cx; - y -= cy; + lcp->correctDistortion(x, y, scale); + x -= (cx * scale); + y -= (cy * scale); } } @@ -156,11 +157,14 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, double x_d = src[i].x, y_d = src[i].y; if (pLCPMap && params->lensProf.useDist) { - correct_distortion (pLCPMap, x_d, y_d, 0, 0); + correct_distortion (pLCPMap, x_d, y_d, 0, 0, ascale); + } else { + x_d *= ascale; + y_d *= ascale; } - y_d = ascale * (y_d - h2); - x_d = ascale * (x_d - w2); + x_d += ascale * (0 - w2); // centering x coord & scale + y_d += ascale * (0 - h2); // centering y coord & scale if (needsPerspective()) { // horizontal perspective transformation @@ -799,11 +803,14 @@ void ImProcFunctions::transformHighQuality (Imagefloat* original, Imagefloat* tr double x_d = x, y_d = y; if (enableLCPDist) { - correct_distortion (pLCPMap, x_d, y_d, cx, cy); // must be first transform + correct_distortion(pLCPMap, x_d, y_d, cx, cy, ascale); // must be first transform + } else { + x_d *= ascale; + y_d *= ascale; } - x_d = ascale * (x_d + cx - w2); // centering x coord & scale - y_d = ascale * (y_d + cy - h2); // centering y coord & scale + x_d += ascale * (cx - w2); // centering x coord & scale + y_d += ascale * (cy - h2); // centering y coord & scale double vig_x_d = 0., vig_y_d = 0.; @@ -976,11 +983,14 @@ void ImProcFunctions::transformPreview (Imagefloat* original, Imagefloat* transf double x_d = x, y_d = y; if (pLCPMap && params->lensProf.useDist) { - correct_distortion (pLCPMap, x_d, y_d, cx, cy); // must be first transform + correct_distortion(pLCPMap, x_d, y_d, cx, cy, ascale); // must be first transform + } else { + x_d *= ascale; + y_d *= ascale; } - y_d = ascale * (y_d + cy - h2); // centering y coord & scale - x_d = ascale * (x_d + cx - w2); // centering x coord & scale + x_d += ascale * (cx - w2); // centering x coord & scale + y_d += ascale * (cy - h2); // centering y coord & scale double vig_x_d = 0., vig_y_d = 0.; diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index fdf46270f..d2d18b7d8 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -198,24 +198,52 @@ LCPMapper::LCPMapper(LCPProfile* pProf, float focalLength, float focalLength35mm } enableCA = !vignette && focusDist > 0; + isFisheye = pProf->isFisheye; } -void LCPMapper::correctDistortion(double& x, double& y) const +void LCPMapper::correctDistortion(double& x, double& y, double scale) const { - double xd = (x - mc.x0) / mc.fx, yd = (y - mc.y0) / mc.fy; + if (isFisheye) { + double u = x * scale; + double v = y * scale; + double u0 = mc.x0 * scale; + double v0 = mc.y0 * scale; + double du = (u - u0); + double dv = (v - v0); + double fx = mc.fx; + double fy = mc.fy; + double k1 = mc.param[0]; + double k2 = mc.param[1]; + double r = sqrt(du * du + dv * dv); + double f = sqrt(fx*fy / (scale * scale)); + double th = atan2(r, f); + double th2 = th * th; + double cfact = (((k2 * th2 + k1) * th2 + 1) * th) / r; + double ud = cfact * fx * du + u0; + double vd = cfact * fy * dv + v0; - const LCPModelCommon::Param aDist = mc.param; - double rsqr = xd * xd + yd * yd; - double xfac = aDist[swapXY ? 3 : 4], yfac = aDist[swapXY ? 4 : 3]; + x = ud; + y = vd; + } else { + x *= scale; + y *= scale; + double x0 = mc.x0 * scale; + double y0 = mc.y0 * scale; + double xd = (x - x0) / mc.fx, yd = (y - y0) / mc.fy; - double commonFac = (((aDist[2] * rsqr + aDist[1]) * rsqr + aDist[0]) * rsqr + 1.) - + 2. * (yfac * yd + xfac * xd); + const LCPModelCommon::Param aDist = mc.param; + double rsqr = xd * xd + yd * yd; + double xfac = aDist[swapXY ? 3 : 4], yfac = aDist[swapXY ? 4 : 3]; - double xnew = xd * commonFac + xfac * rsqr; - double ynew = yd * commonFac + yfac * rsqr; + double commonFac = (((aDist[2] * rsqr + aDist[1]) * rsqr + aDist[0]) * rsqr + 1.) + + 2. * (yfac * yd + xfac * xd); - x = xnew * mc.fx + mc.x0; - y = ynew * mc.fy + mc.y0; + double xnew = xd * commonFac + xfac * rsqr; + double ynew = yd * commonFac + yfac * rsqr; + + x = xnew * mc.fx + x0; + y = ynew * mc.fy + y0; + } } void LCPMapper::correctCA(double& x, double& y, int channel) const diff --git a/rtengine/lcp.h b/rtengine/lcp.h index e108e61b7..8cfcd5694 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -142,6 +142,7 @@ class LCPMapper bool swapXY; LCPModelCommon mc; LCPModelCommon chrom[3]; // in order RedGreen/Green/BlueGreen + bool isFisheye; public: bool enableCA; // is the mapper capable if CA correction? @@ -150,7 +151,7 @@ public: LCPMapper(LCPProfile* pProf, float focalLength, float focalLength35mm, float focusDist, float aperture, bool vignette, bool useCADistP, int fullWidth, int fullHeight, const CoarseTransformParams& coarse, int rawRotationDeg); - void correctDistortion(double& x, double& y) const; // MUST be the first stage + void correctDistortion(double& x, double& y, double scale) const; // MUST be the first stage void correctCA(double& x, double& y, int channel) const; void processVignetteLine(int width, int y, float *line) const; void processVignetteLine3Channels(int width, int y, float *line) const; From 3464c0ec9221cb842af6b4f3bf8d9b19377d2418 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sat, 8 Apr 2017 19:58:32 +0200 Subject: [PATCH 02/10] fixed glitch in handling crop windows at the edges of the image when LCP distortion correction is enabled --- rtengine/dcrop.cc | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 18cb927aa..351ce1f08 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -1145,15 +1145,33 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); if (check_need_larger_crop_for_lcp_distortion(parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) { - double dW = double(parent->fw) * 0.15 / skip; // TODO - this is hardcoded ATM! - double dH = double(parent->fh) * 0.15 / skip; // this is an estimate of the max - // distortion relative to the image - // size. BUT IS 15% REALLY ENOUGH? - // In fact, is there a better way?? - orx = max(int(orx - dW/2.0), 0); - ory = max(int(ory - dH/2.0), 0); - orw = min(int(orw + dW), parent->fw - orx); - orh = min(int(orh + dH), parent->fh - ory); + // TODO - this is an estimate of the max distortion relative to the image size. ATM it is hardcoded to be 15%, which seems enough. If not, need to revise + int dW = int(double(parent->fw) * 0.15 / (2 * skip)); + int dH = int(double(parent->fh) * 0.15 / (2 * skip)); + int x1 = orx - dW; + int x2 = orx + orw + dW; + int y1 = ory - dH; + int y2 = ory + orh + dH; + if (x1 < 0) { + x2 += -x1; + x1 = 0; + } + if (x2 > parent->fw) { + x1 -= x2 - parent->fw; + x2 = parent->fw; + } + if (y1 < 0) { + y2 += -y1; + y1 = 0; + } + if (y2 > parent->fh) { + y1 -= y2 - parent->fh; + y2 = parent->fh; + } + orx = max(x1, 0); + ory = max(y1, 0); + orw = min(x2 - x1, parent->fw - orx); + orh = min(y2 - y1, parent->fh - ory); } From 6e55f6bab5ac9289c4bacf2e6cded9b92c3a3d24 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 8 Apr 2017 22:41:46 +0200 Subject: [PATCH 03/10] Fixed a lot of issues reported by cppcheck 1.78 --- rtengine/CA_correct_RT.cc | 7 +- rtengine/EdgePreservingDecomposition.cc | 3 + rtengine/PF_correct_RT.cc | 111 +++++++++++------------ rtengine/cfa_linedn_RT.cc | 2 +- rtengine/color.cc | 2 +- rtengine/color.h | 2 +- rtengine/curves.h | 2 +- rtengine/diagonalcurves.cc | 3 +- rtengine/dirpyr_equalizer.cc | 7 +- rtengine/flatcurves.cc | 6 +- rtengine/fujicompressed.cc | 6 +- rtengine/hilite_recon.cc | 6 +- rtengine/iccjpeg.cc | 3 +- rtengine/iccstore.cc | 2 +- rtengine/iimage.h | 18 ++++ rtengine/imagefloat.cc | 4 +- rtengine/imageio.cc | 2 +- rtengine/imagesource.h | 2 +- rtengine/improccoordinator.cc | 3 + rtengine/improcfun.cc | 112 ++++++++++++------------ rtengine/improcfun.h | 4 +- rtengine/ipsharpen.cc | 18 ++-- rtengine/iptransform.cc | 1 - rtengine/ipwavelet.cc | 2 +- rtengine/pipettebuffer.cc | 6 -- rtengine/pixelshift.cc | 3 +- rtengine/previewimage.cc | 49 ++++------- rtengine/procparams.cc | 1 - rtengine/rawimagesource.cc | 6 +- rtengine/rawimagesource.h | 4 +- rtengine/rtthumbnail.cc | 6 +- rtengine/stdimagesource.cc | 2 +- rtengine/stdimagesource.h | 2 +- rtgui/batchqueue.cc | 1 - rtgui/editorpanel.cc | 6 -- rtgui/filebrowser.cc | 1 - rtgui/guiutils.cc | 6 +- rtgui/guiutils.h | 4 +- rtgui/inspector.cc | 48 +++++----- rtgui/inspector.h | 4 +- rtgui/preferences.cc | 3 +- 41 files changed, 226 insertions(+), 254 deletions(-) diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index 8471a1393..e1493ae40 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -45,15 +45,14 @@ bool LinEqSolve(int nDim, double* pfMatr, double* pfVect, double* pfSolution) // //============================================================================== - double fMaxElem; double fAcc; - int i, j, k, m; + int i, j, k; for(k = 0; k < (nDim - 1); k++) { // base row of matrix // search of line with max element - fMaxElem = fabs( pfMatr[k * nDim + k] ); - m = k; + double fMaxElem = fabs( pfMatr[k * nDim + k] ); + int m = k; for (i = k + 1; i < nDim; i++) { if(fMaxElem < fabs(pfMatr[i * nDim + k]) ) { diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 43a68f024..8c1ca56a7 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -395,6 +395,9 @@ SSEFUNCTION void MultiDiagonalSymmetricMatrix::VectorProduct(float* RESTRICT Pro } } } +#ifdef _OPENMP + static_cast(chunkSize); // to silence cppcheck warning +#endif } bool MultiDiagonalSymmetricMatrix::CreateIncompleteCholeskyFactorization(int MaxFillAbove) diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index 6808fd4eb..cfe1e2ba3 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -663,12 +663,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d const int width = src->W, height = src->H; const float piid = 3.14159265f / 180.f; - float shfabs, shmed; - int i1, j1, tot; + int i1, j1; const float eps = 1.0f; const float eps2 = 0.01f; - float shsum, dirsh, norm, sum; float** sraa; sraa = new float*[height]; @@ -848,13 +846,13 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d __m128 onev = F2V(1.0f); #endif // __SSE2__ #ifdef _OPENMP - #pragma omp for private(shfabs, shmed,i1,j1) + #pragma omp for private(i1,j1) #endif for (int i = 0; i < height; i++) { for (j = 0; j < 2; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -879,8 +877,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d } for (; j < width - 2; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -893,8 +891,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d #else for (; j < width - 2; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -907,8 +905,8 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d #endif for (; j < width; j++) { - shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->sh_p[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -927,7 +925,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d { int j; #ifdef _OPENMP - #pragma omp for private(shsum,norm,dirsh,sum,i1,j1) schedule(dynamic,16) + #pragma omp for private(i1,j1) schedule(dynamic,16) #endif for (int i = 0; i < height; i++) { @@ -936,10 +934,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -953,7 +951,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d sum += src->sh_p[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); + float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); shsum += dirsh * src->sh_p[i1][j1]; norm += dirsh; } @@ -972,10 +970,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -989,7 +987,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d sum += src->sh_p[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); + float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); shsum += dirsh * src->sh_p[i1][j1]; norm += dirsh; } @@ -1008,10 +1006,10 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -1025,7 +1023,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d sum += src->sh_p[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); + float dirsh = 1.f / (SQR(src->sh_p[i1][j1] - src->sh_p[i][j]) + eps); shsum += dirsh * src->sh_p[i1][j1]; norm += dirsh; } @@ -1272,13 +1270,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d t1.set(); const int width = src->W, height = src->H; -// const float piid=3.14159265f/180.f; - float shfabs, shmed; - int i1, j1, tot; + int i1, j1; const float eps = 1.0f; const float eps2 = 0.01f; - float shsum, dirsh, norm, sum; float** sraa; sraa = new float*[height]; @@ -1455,13 +1450,13 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d __m128 onev = F2V(1.0f); #endif // __SSE2__ #ifdef _OPENMP - #pragma omp for private(shfabs, shmed,i1,j1) + #pragma omp for private(i1,j1) #endif for (int i = 0; i < height; i++) { for (j = 0; j < 2; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -1474,7 +1469,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d #ifdef __SSE2__ for (; j < width - 5; j += 4) { - shfabsv = vabsf(LVFU(src->L[i][j]) - LVFU(tmL[i][j])); + vfloat shfabsv = vabsf(LVFU(src->L[i][j]) - LVFU(tmL[i][j])); shmedv = ZEROV; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) @@ -1486,8 +1481,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d } for (; j < width - 2; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -1500,8 +1495,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d #else for (; j < width - 2; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -1514,8 +1509,8 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d #endif for (; j < width; j++) { - shfabs = fabs(src->L[i][j] - tmL[i][j]); - shmed = 0.0f; + float shfabs = fabs(src->L[i][j] - tmL[i][j]); + float shmed = 0.0f; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -1534,7 +1529,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d { int j; #ifdef _OPENMP - #pragma omp for private(shsum,norm,dirsh,sum,i1,j1) schedule(dynamic,16) + #pragma omp for private(i1,j1) schedule(dynamic,16) #endif for (int i = 0; i < height; i++) { @@ -1543,10 +1538,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = 0; j1 <= j + 2; j1++ ) { @@ -1560,7 +1555,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d sum += src->L[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); + float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); shsum += dirsh * src->L[i1][j1]; norm += dirsh; } @@ -1579,10 +1574,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 <= j + 2; j1++ ) { @@ -1596,7 +1591,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d sum += src->L[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); + float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); shsum += dirsh * src->L[i1][j1]; norm += dirsh; } @@ -1615,10 +1610,10 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d continue; } - norm = 0.0f; - shsum = 0.0f; - sum = 0.0f; - tot = 0; + float norm = 0.0f; + float shsum = 0.0f; + float sum = 0.0f; + int tot = 0; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) for (j1 = j - 2; j1 < width; j1++ ) { @@ -1632,7 +1627,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d sum += src->L[i1][j1]; tot++; - dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); + float dirsh = 1.f / (SQR(src->L[i1][j1] - src->L[i][j]) + eps); shsum += dirsh * src->L[i1][j1]; norm += dirsh; } diff --git a/rtengine/cfa_linedn_RT.cc b/rtengine/cfa_linedn_RT.cc index 21fcfb1e5..b5578898b 100644 --- a/rtengine/cfa_linedn_RT.cc +++ b/rtengine/cfa_linedn_RT.cc @@ -46,7 +46,7 @@ void RawImageSource::CLASS cfa_linedn(float noise) const float clip_pt = 0.8 * initialGain * 65535.0; - float eps = 1e-5; //tolerance to avoid dividing by zero + const float eps = 1e-5; //tolerance to avoid dividing by zero const float gauss[5] = {0.20416368871516755, 0.18017382291138087, 0.1238315368057753, 0.0662822452863612, 0.02763055063889883}; const float rolloff[8] = {0, 0.135335, 0.249352, 0.411112, 0.606531, 0.800737, 0.945959, 1}; //gaussian with sigma=3 diff --git a/rtengine/color.cc b/rtengine/color.cc index acb50eae5..f045a84d9 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -1817,7 +1817,7 @@ void Color::Lab2Yuv(float L, float a, float b, float &Y, float &u, float &v) v = 9.0 * Y / (X + 15 * Y + 3 * Z) - v0; } -void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, double wp[3][3]) +void Color::Yuv2Lab(float Yin, float u, float v, float &L, float &a, float &b, const double wp[3][3]) { float u1 = u + u0; float v1 = v + v0; diff --git a/rtengine/color.h b/rtengine/color.h index 6fda40f12..5889095ca 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -498,7 +498,7 @@ public: * @param a channel [-42000 ; +42000] ; can be more than 42000 (return value) * @param b channel [-42000 ; +42000] ; can be more than 42000 (return value) */ - static void Yuv2Lab(float Y, float u, float v, float &L, float &a, float &b, double wp[3][3]); + static void Yuv2Lab(float Y, float u, float v, float &L, float &a, float &b, const double wp[3][3]); /** diff --git a/rtengine/curves.h b/rtengine/curves.h index cd4384bb4..c20b78772 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -273,7 +273,7 @@ public: } float R = hlrange / (val * comp); - return log(1.0 + Y) * R; + return log1p(Y) * R; } else { return exp_scale; } diff --git a/rtengine/diagonalcurves.cc b/rtengine/diagonalcurves.cc index 9ab17a0f4..1c75e3059 100644 --- a/rtengine/diagonalcurves.cc +++ b/rtengine/diagonalcurves.cc @@ -33,7 +33,6 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) { ppn = poly_pn > 65500 ? 65500 : poly_pn; - bool identity = true; if (ppn < 500) { hashSize = 100; // Arbitrary cut-off value, but mutliple of 10 @@ -46,6 +45,7 @@ DiagonalCurve::DiagonalCurve (const std::vector& p, int poly_pn) if (p.size() < 3) { kind = DCT_Empty; } else { + bool identity = true; kind = (DiagonalCurveType)p[0]; if (kind == DCT_Linear || kind == DCT_Spline || kind == DCT_NURBS) { @@ -364,7 +364,6 @@ double DiagonalCurve::getVal (double t) const } return poly_y[k_lo] + (t - poly_x[k_lo]) * dyByDx[k_lo]; - break; } case DCT_Empty : diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index e0527140b..8f3ebae9f 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -368,9 +368,6 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float idirpyr_eq_channelcam(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold , h_p, C_p, skinprot, b_l, t_l, t_r); } - - scale = scales[0]; - idirpyr_eq_channelcam(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r); @@ -625,7 +622,7 @@ SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** da //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) +void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r , int choice) { const float skinprotneg = -skinprot; const float factorHard = (1.f - skinprotneg / 100.f); @@ -717,7 +714,7 @@ void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fin } -void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r) +void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r) { const float skinprotneg = -skinprot; diff --git a/rtengine/flatcurves.cc b/rtengine/flatcurves.cc index ae1a895ff..fe5ecc5e1 100644 --- a/rtengine/flatcurves.cc +++ b/rtengine/flatcurves.cc @@ -30,9 +30,8 @@ FlatCurve::FlatCurve (const std::vector& p, bool isPeriodic, int poly_pn poly_x.clear(); poly_y.clear(); - bool identity = true; - if (p.size() > 4) { + bool identity = true; kind = (FlatCurveType)p[0]; if (kind == FCT_MinMaxCPoints) { @@ -146,7 +145,6 @@ void FlatCurve::CtrlPoints_set () double length; double dx; double dy; - double xp1, xp2, yp2, xp3; bool startLinear, endLinear; startLinear = (rightTangent[i] == 0.) || (y[i] == y[i + 1]); @@ -171,6 +169,7 @@ void FlatCurve::CtrlPoints_set () sc_length[k++] = length; total_length += length; } else { + double xp1, xp2, yp2, xp3; if (startLinear) { xp1 = x[i]; } else { @@ -363,7 +362,6 @@ double FlatCurve::getVal (double t) const } return poly_y[k_lo] + (t - poly_x[k_lo]) * dyByDx[k_lo]; - break; } /*case Parametric : { diff --git a/rtengine/fujicompressed.cc b/rtengine/fujicompressed.cc index 75ca46c04..c5dfa8f13 100644 --- a/rtengine/fujicompressed.cc +++ b/rtengine/fujicompressed.cc @@ -151,7 +151,6 @@ void CLASS copy_line_to_xtrans (struct fuji_compressed_block* info, int cur_line ushort *lineBufB[3]; ushort *lineBufG[6]; ushort *lineBufR[3]; - unsigned pixel_count; ushort* line_buf; int index; @@ -169,7 +168,7 @@ void CLASS copy_line_to_xtrans (struct fuji_compressed_block* info, int cur_line } while (row_count < 6) { - pixel_count = 0; + unsigned pixel_count = 0; while (static_cast(pixel_count) < cur_block_width) { switch (xtrans_abs[row_count][ (pixel_count % 6)]) { @@ -203,7 +202,6 @@ void CLASS copy_line_to_bayer (struct fuji_compressed_block *info, int cur_line, ushort *lineBufB[3]; ushort *lineBufG[6]; ushort *lineBufR[3]; - unsigned pixel_count; ushort *line_buf; int fuji_bayer[2][2]; @@ -227,7 +225,7 @@ void CLASS copy_line_to_bayer (struct fuji_compressed_block *info, int cur_line, } while (row_count < 6) { - pixel_count = 0; + unsigned pixel_count = 0; while (static_cast(pixel_count) < cur_block_width) { switch (fuji_bayer[row_count & 1][pixel_count & 1]) { diff --git a/rtengine/hilite_recon.cc b/rtengine/hilite_recon.cc index b0b211e3d..f9e630f9d 100644 --- a/rtengine/hilite_recon.cc +++ b/rtengine/hilite_recon.cc @@ -217,7 +217,6 @@ void RawImageSource::boxblur_resamp(float **src, float **dst, float ** temp, int #pragma omp parallel #endif { - float tempval; #ifdef _OPENMP #pragma omp for #endif @@ -227,7 +226,7 @@ void RawImageSource::boxblur_resamp(float **src, float **dst, float ** temp, int for (int row = 0; row < H; row++) { int len = box + 1; - tempval = src[row][0] / len; + float tempval = src[row][0] / len; for (int j = 1; j <= box; j++) { tempval += src[row][j] / len; @@ -339,12 +338,11 @@ void RawImageSource::boxblur_resamp(float **src, float **dst, float ** temp, int // process remaining columns #pragma omp single { - float tempval; //vertical blur for (int col = (W / samp) - ((W / samp) % numCols); col < W / samp; col++) { int len = box + 1; - tempval = temp[0][col] / len; + float tempval = temp[0][col] / len; for (int i = 1; i <= box; i++) { tempval += temp[i][col] / len; diff --git a/rtengine/iccjpeg.cc b/rtengine/iccjpeg.cc index 31aa0ec7c..5e652296f 100644 --- a/rtengine/iccjpeg.cc +++ b/rtengine/iccjpeg.cc @@ -55,7 +55,6 @@ write_icc_profile (j_compress_ptr cinfo, { unsigned int num_markers; /* total number of markers we'll write */ int cur_marker = 1; /* per spec, counting starts at 1 */ - unsigned int length; /* number of bytes to write in this marker */ /* Calculate the number of markers we'll need, rounding up of course */ num_markers = icc_data_len / MAX_DATA_BYTES_IN_MARKER; @@ -66,7 +65,7 @@ write_icc_profile (j_compress_ptr cinfo, while (icc_data_len > 0) { /* length of profile to put in this marker */ - length = icc_data_len; + unsigned int length = icc_data_len; /* number of bytes to write in this marker */ if (length > MAX_DATA_BYTES_IN_MARKER) { length = MAX_DATA_BYTES_IN_MARKER; diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 4c749e3c4..5aff1d335 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -864,7 +864,7 @@ cmsHPROFILE rtengine::ICCStore::makeStdGammaProfile(cmsHPROFILE iprof) } tags[tag_count]; const uint32_t gamma = 0x239; - int gamma_size =(gamma == 0 || gamma == 256) ? 12 : 14; + int gamma_size = 14; int data_size =(gamma_size + 3) & ~3; for (uint32_t i = 0; i < tag_count; i++) { diff --git a/rtengine/iimage.h b/rtengine/iimage.h index b06a188bc..149ed3787 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -376,6 +376,9 @@ public: v(y, x) = tmp; } } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } } @@ -460,6 +463,9 @@ public: v(i, j) = v(i, x); v(i, x) = temp; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void vflip () @@ -482,6 +488,9 @@ public: v(i, j) = v(y, j); v(y, j) = temp; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void calcHist(unsigned int *hist16) @@ -790,6 +799,9 @@ public: b(y, x) = tmp; } } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } } @@ -878,6 +890,9 @@ public: b(i, j) = b(i, x); b(i, x) = temp; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void vflip () @@ -908,6 +923,9 @@ public: b(i, j) = b(y, j); b(y, j) = tempB; } +#ifdef _OPENMP + static_cast(bigImage); // to silence cppcheck warning +#endif } void calcGrayscaleHist(unsigned int *hist16) diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index a0a7e293c..30871c9b1 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -447,10 +447,8 @@ void Imagefloat::calcCroppedHistogram(const ProcParams ¶ms, float scale, LUT #pragma omp for nowait for (int y = y1; y < y2; y++) { - int i; - for (int x = x1; x < x2; x++) { - i = (int)(facRed * r(y, x) + facGreen * g(y, x) + facBlue * b(y, x)); + int i = (int)(facRed * r(y, x) + facGreen * g(y, x) + facBlue * b(y, x)); if (i < 0) { i = 0; diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index 197055858..8bc5362fd 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -696,7 +696,7 @@ int ImageIO::getTIFFSampleFormat (Glib::ustring fname, IIOSampleFormat &sFormat, sFormat = IIOSF_HALF; return IMIO_SUCCESS; }*/ - if ((samplesperpixel == 3 || samplesperpixel == 4) && bitspersample == 32) { + if (bitspersample == 32) { sFormat = IIOSF_FLOAT; return IMIO_SUCCESS; } diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 8b4377c89..d6d0a618f 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -101,7 +101,7 @@ public: } virtual void getFullSize (int& w, int& h, int tr = TR_NONE) {} - virtual void getSize (PreviewProps pp, int& w, int& h) = 0; + virtual void getSize (const PreviewProps &pp, int& w, int& h) = 0; virtual int getRotateDegree() const { return 0; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 5aa70e75d..f9bbda301 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -608,6 +608,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) #endif lhist16 += lhist16thr; } +#ifdef _OPENMP + static_cast(numThreads); // to silence cppcheck warning +#endif CurveFactory::complexLCurve (params.labCurve.brightness, params.labCurve.contrast, params.labCurve.lcurve, lhist16, lumacurve, histLCurve, scale == 1 ? 1 : 16, utili); } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 362fdc09a..c68158634 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -181,6 +181,9 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro histogram += hist; } +#ifdef _OPENMP + static_cast(numThreads); // to silence cppcheck warning +#endif } else { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { @@ -212,7 +215,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh LUTf dLcurve; LUTu hist16JCAM; bool jp = false; - float val; //preparate for histograms CIECAM if(pW != 1) { //only with improccoordinator @@ -222,7 +224,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh hist16JCAM.clear(); for (int i = 0; i < 32768; i++) { //# 32768*1.414 approximation maxi for chroma - val = (double)i / 32767.0; + float val = (double)i / 32767.0; dLcurve[i] = CLIPD(val); } } @@ -230,7 +232,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh LUTf dCcurve; LUTu hist16_CCAM; bool chropC = false; - float valc; if(pW != 1) { //only with improccoordinator dCcurve(65536, 0); @@ -238,7 +239,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh hist16_CCAM.clear(); for (int i = 0; i < 48000; i++) { //# 32768*1.414 approximation maxi for chroma - valc = (double)i / 47999.0; + float valc = (double)i / 47999.0; dCcurve[i] = CLIPD(valc); } } @@ -1208,9 +1209,9 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh artifact = 1.f; } - int hotbad = 0; float chrom = 50.f; { + int hotbad = 0; ImProcFunctions::badpixcam (ncie, artifact, 5, 2 , b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect , chrom, hotbad); //enabled remove artifacts for cbDL } } @@ -1233,15 +1234,15 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh //if(params->dirpyrequalizer.enabled) if(execsharp) { if(params->dirpyrequalizer.enabled /*&& (execsharp)*/) { - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; //not disabled in case of ! always 0 // if (params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; if(rtt == 1) { + float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + int choice = 0; //not disabled in case of ! always 0 dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM } } @@ -1314,7 +1315,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh double chsacol = 327.; int libr = 0; int colch = 0; - float sa_t; if(curveMode == ColorAppearanceParams::TC_MODE_BRIGHT) { brli = 70.0; @@ -1358,7 +1358,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh if(colch == 0) { posc = CLIP((int)(ncie->C_p[i][j] * chsacol)); //450.0 approximative factor for s 320 for M } else if(colch == 1) { - sa_t = 100.f * sqrt(ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 + float sa_t = 100.f * sqrt(ncie->C_p[i][j] / ncie->Q_p[i][j]); //Q_p always > 0 posc = CLIP((int)(sa_t * chsacol)); } else /*if(colch == 2)*/ { posc = CLIP((int)(ncie->M_p[i][j] * chsacol)); @@ -2590,15 +2590,15 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //if(params->dirpyrequalizer.enabled) if(execsharp) { if(params->dirpyrequalizer.enabled /*&& execsharp*/) { - float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; - float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; - float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; - float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; - int choice = 0; // I have not suppress this statement in case of !! always to 0 // if(params->dirpyrequalizer.algo=="FI") choice=0; // else if(params->dirpyrequalizer.algo=="LA") choice=1; if(rtt == 1) { + float b_l = static_cast(params->dirpyrequalizer.hueskin.value[0]) / 100.0f; + float t_l = static_cast(params->dirpyrequalizer.hueskin.value[1]) / 100.0f; + float b_r = static_cast(params->dirpyrequalizer.hueskin.value[2]) / 100.0f; + float t_r = static_cast(params->dirpyrequalizer.hueskin.value[3]) / 100.0f; + int choice = 0; // I have not suppress this statement in case of !! always to 0 lab->deleteLab(); dirpyr_equalizercam(ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scalecd); //contrast by detail adapted to CIECAM lab->reallocLab(); @@ -2999,10 +2999,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer {wprof[2][0], wprof[2][1], wprof[2][2]} }; - // For tonecurve histogram - float lumimulf[3] = {static_cast(lumimul[0]), static_cast(lumimul[1]), static_cast(lumimul[2])}; - - bool mixchannels = (params->chmixer.red[0] != 100 || params->chmixer.red[1] != 0 || params->chmixer.red[2] != 0 || params->chmixer.green[0] != 0 || params->chmixer.green[1] != 100 || params->chmixer.green[2] != 0 || params->chmixer.blue[0] != 0 || params->chmixer.blue[1] != 0 || params->chmixer.blue[2] != 100); @@ -3219,9 +3215,6 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float gamvalr = 125.f; float gamvalg = 125.f; float gamvalb = 125.f; - double nr = 0; - double ng = 0; - double nb = 0; bool computeMixerAuto = params->blackwhite.autoc && (autor < -5000.f); if(bwrgam < 0) { @@ -3260,6 +3253,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer histToneCurveCompression = log2(65536 / toneCurveHistSize); } + // For tonecurve histogram + const float lumimulf[3] = {static_cast(lumimul[0]), static_cast(lumimul[1]), static_cast(lumimul[2])}; + #define TS 112 @@ -4406,6 +4402,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer //end auto chmix if (computeMixerAuto) { // auto channel-mixer + double nr = 0; + double ng = 0; + double nb = 0; + #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 16) reduction(+:nr,ng,nb) #endif @@ -4938,9 +4938,6 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go rlob = rlo; } - //second degree - float aa, bb, cc; - float v0 = 0.15f; //fixed value of reducac=0.3 //secondeg_end (reducac, v0, aa, bb, cc); @@ -4951,6 +4948,9 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go kl = (-1.f / 0.85f) * v + (1.f) / 0.85f; //Low light ==> decrease action after v=0.15 } } else { //color + float v0 = 0.15f; + //second degree + float aa, bb, cc; secondeg_end (reducac, v0, aa, bb, cc); float aab, bbb; secondeg_begin (0.7f, v0, aab, bbb); @@ -5010,7 +5010,6 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go // mid tones float km; float v0m = 0.5f; //max action - float v0mm = 0.5f; //max if(v < v0m) { float aam, bbm; @@ -5018,6 +5017,7 @@ void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go secondeg_begin (reducac, vend, aam, bbm); km = aam * v * v + bbm * v; //verification = good } else { + float v0mm = 0.5f; //max float aamm, bbmm, ccmm; secondeg_end (reducac, v0mm, aamm, bbmm, ccmm); km = aamm * v * v + bbmm * v + ccmm; //verification good @@ -5205,17 +5205,16 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g kl = aab * v * v + bbb * v; } - //rl gl bl - float RedL, GreenL, BlueL; - float krl = rl / (rl + gl + bl); - float kgl = gl / (rl + gl + bl); - float kbl = bl / (rl + gl + bl); if(SatLow > 0.f) { - float kmgb; + //rl gl bl + float krl = rl / (rl + gl + bl); + float kgl = gl / (rl + gl + bl); + float kbl = bl / (rl + gl + bl); + float RedL, GreenL, BlueL; if(g < 20000.f || b < 20000.f || r < 20000.f) { - kmgb = min(r, g, b); //I have tested ...0.85 compromise... + float kmgb = min(r, g, b); //I have tested ...0.85 compromise... kl *= pow((kmgb / 20000.f), 0.85f); } @@ -5262,10 +5261,9 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g kh = aa0 * v * v + bb0 * v; } - float kmgb; if(g > 45535.f || b > 45535.f || r > 45535.f) { - kmgb = max(r, g, b); + float kmgb = max(r, g, b); float cora = 1.f / (45535.f - 65535.f); float corb = 1.f - cora * 45535.f; float cor = kmgb * cora + corb; @@ -5277,12 +5275,12 @@ void ImProcFunctions::toning2col (float r, float g, float b, float &ro, float &g kh*=cor;*/ } - float RedH, GreenH, BlueH; - float krh = rh / (rh + gh + bh); - float kgh = gh / (rh + gh + bh); - float kbh = bh / (rh + gh + bh); if(SatHigh > 0.f) { + float RedH, GreenH, BlueH; + float krh = rh / (rh + gh + bh); + float kgh = gh / (rh + gh + bh); + float kbh = bh / (rh + gh + bh); RedH = 1.f + (SatHigh * krh) * kh * rlh * balanH; //1.2 if(krh > 0.f) { @@ -5610,14 +5608,14 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu const float amountchroma = (float) settings->amchroma; TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); - double wip[3][3] = { + const double wip[3][3] = { {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} }; TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params->icm.working); - double wp[3][3] = { + const double wp[3][3] = { {wprof[0][0], wprof[0][1], wprof[0][2]}, {wprof[1][0], wprof[1][1], wprof[1][2]}, {wprof[2][0], wprof[2][1], wprof[2][2]} @@ -5774,7 +5772,6 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu float l_r;//Luminance Lab in 0..1 l_r = Lprov1 / 100.f; { - float khue = 1.9f; //in reserve in case of! float valparam = float((lhCurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f)); //get l_r=f(H) float valparamneg; valparamneg = valparam; @@ -5788,6 +5785,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } else //for negative { + float khue = 1.9f; //in reserve in case of! l_r *= (1.f + khue * valparamneg); } } @@ -5894,7 +5892,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if (clut) { // begin C=f(L) - float factorskin, factorsat, factor, factorskinext, interm; + float factorskin, factorsat, factor, factorskinext; float chromaCfactor = (clcurve[LL * 655.35f]) / (LL * 655.35f); //apply C=f(L) float curf = 0.7f; //empirical coeff because curve is more progressive float scale = 100.0f / 100.1f; //reduction in normal zone for curve C @@ -5928,7 +5926,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if(chromaCfactor > 1.0) { - interm = (chromaCfactor - 1.0f) * 100.0f; + float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; } else { @@ -5954,7 +5952,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu }//Lab C=f(C) pipette if (ccut) { - float factorskin, factorsat, factor, factorskinext, interm; + float factorskin, factorsat, factor, factorskinext; float chroma = sqrt(SQR(atmp) + SQR(btmp) + 0.001f); float chromaCfactor = (satcurve[chroma * adjustr]) / (chroma * adjustr); //apply C=f(C) float curf = 0.7f; //empirical coeff because curve is more progressive @@ -5989,7 +5987,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu } if(chromaCfactor > 1.0) { - interm = (chromaCfactor - 1.0f) * 100.0f; + float interm = (chromaCfactor - 1.0f) * 100.0f; factorskin = 1.0f + (interm * scale) / 100.0f; factorskinext = 1.0f + (interm * scaleext) / 100.0f; } else { @@ -6649,15 +6647,15 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double return; } - lodev = (lodev / (log(2.f) * losum)); - hidev = (hidev / (log(2.f) * hisum)); +// lodev = (lodev / (log(2.f) * losum)); +// hidev = (hidev / (log(2.f) * hisum)); - if (octile[6] > log((float)imax + 1.f) / log2(2.f)) { //if very overxposed image + if (octile[6] > log1p((float)imax) / log2(2.f)) { //if very overxposed image octile[6] = 1.5f * octile[5] - 0.5f * octile[4]; overex = 2; } - if (octile[7] > log((float)imax + 1.f) / log2(2.f)) { //if overexposed + if (octile[7] > log1p((float)imax) / log2(2.f)) { //if overexposed octile[7] = 1.5f * octile[6] - 0.5f * octile[5]; overex = 1; } @@ -6730,10 +6728,10 @@ void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double median <<= histcompr; shc <<= histcompr; - //prevent division by 0 - if (lodev == 0.f) { - lodev = 1.f; - } +// //prevent division by 0 +// if (lodev == 0.f) { +// lodev = 1.f; +// } //compute exposure compensation as geometric mean of the amount that //sets the mean or median at middle gray, and the amount that sets the estimated top @@ -6929,7 +6927,7 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si int dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 1, dist_amount); if(dist_result == -1) { // not enough features found, try increasing max. number of features by factor 4 - dist_result = calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount); + calcDistortion (thumbGray, rawGray, width, h_thumb, 4, dist_amount); } delete thumbGray; diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index e70083b0b..028e55a33 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -331,8 +331,8 @@ public: void dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet void dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale); - void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); - void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); + void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice); + void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r); void defringe (LabImage* lab); void defringecam (CieImage* ncie); void badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad); diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index 5b96fc971..00196591e 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -267,26 +267,26 @@ void ImProcFunctions::sharpenHaloCtrl (float** luminance, float** blurmap, float #endif for (int i = 2; i < H - 2; i++) { - float max1 = 0, max2 = 0, min1 = 0, min2 = 0, maxn, minn, np1, np2, np3, min_, max_, labL; + float max1 = 0, max2 = 0, min1 = 0, min2 = 0; for (int j = 2; j < W - 2; j++) { // compute 3 iterations, only forward - np1 = 2.f * (nL[i - 2][j] + nL[i - 2][j + 1] + nL[i - 2][j + 2] + nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2]) / 27.f + nL[i - 1][j + 1] / 3.f; - np2 = 2.f * (nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2]) / 27.f + nL[i] [j + 1] / 3.f; - np3 = 2.f * (nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2] + nL[i + 2][j] + nL[i + 2][j + 1] + nL[i + 2][j + 2]) / 27.f + nL[i + 1][j + 1] / 3.f; + float np1 = 2.f * (nL[i - 2][j] + nL[i - 2][j + 1] + nL[i - 2][j + 2] + nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2]) / 27.f + nL[i - 1][j + 1] / 3.f; + float np2 = 2.f * (nL[i - 1][j] + nL[i - 1][j + 1] + nL[i - 1][j + 2] + nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2]) / 27.f + nL[i] [j + 1] / 3.f; + float np3 = 2.f * (nL[i] [j] + nL[i] [j + 1] + nL[i] [j + 2] + nL[i + 1][j] + nL[i + 1][j + 1] + nL[i + 1][j + 2] + nL[i + 2][j] + nL[i + 2][j + 1] + nL[i + 2][j + 2]) / 27.f + nL[i + 1][j + 1] / 3.f; // Max/Min of all these deltas and the last two max/min - maxn = max(np1, np2, np3); - minn = min(np1, np2, np3); - max_ = max(max1, max2, maxn); - min_ = min(min1, min2, minn); + float maxn = max(np1, np2, np3); + float minn = min(np1, np2, np3); + float max_ = max(max1, max2, maxn); + float min_ = min(min1, min2, minn); // Shift the queue max1 = max2; max2 = maxn; min1 = min2; min2 = minn; - labL = luminance[i][j]; + float labL = luminance[i][j]; if (max_ < labL) { max_ = labL; diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 04ba4966d..3c6d47344 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -390,7 +390,6 @@ static void calcGradientParams (int oW, int oH, const GradientParams& gradient, // division with extremely small numbers gp.transpose = true; gradient_angle += 0.5 * rtengine::RT_PI; - cosgrad = cos (gradient_angle); double gxc = gradient_center_x; gradient_center_x = 1.0 - gradient_center_y; gradient_center_y = gxc; diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 5e0188856..629dfcb66 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -149,7 +149,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int MunsellDebugInfo* MunsDebugInfo = new MunsellDebugInfo(); #endif TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working); - double wip[3][3] = { + const double wip[3][3] = { {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, {wiprof[2][0], wiprof[2][1], wiprof[2][2]} diff --git a/rtengine/pipettebuffer.cc b/rtengine/pipettebuffer.cc index 6f6d9dcef..8981b6480 100644 --- a/rtengine/pipettebuffer.cc +++ b/rtengine/pipettebuffer.cc @@ -28,12 +28,6 @@ PipetteBuffer::PipetteBuffer(::EditDataProvider *dataProvider) : PipetteBuffer::~PipetteBuffer() { flush(); -#ifndef NDEBUG - imgFloatBuffer = (Imagefloat*)(0xbaadf00d); -#endif -#ifndef NDEBUG - LabBuffer = (LabImage*)(0xbaadf00d); -#endif } void PipetteBuffer::createBuffer(int width, int height) diff --git a/rtengine/pixelshift.cc b/rtengine/pixelshift.cc index 744950ba8..0a6d24688 100644 --- a/rtengine/pixelshift.cc +++ b/rtengine/pixelshift.cc @@ -994,10 +994,11 @@ void RawImageSource::pixelshift(int winx, int winy, int winw, int winh, const RA #ifdef PIXELSHIFTDEV if(detectMotion || (adaptive && checkGreen)) { bool skipNext = false; + float gridMax = 0.f; #else if(adaptive && checkGreen) { -#endif float gridMax; +#endif #ifdef PIXELSHIFTDEV diff --git a/rtengine/previewimage.cc b/rtengine/previewimage.cc index 1bf11dc17..29b319d2c 100644 --- a/rtengine/previewimage.cc +++ b/rtengine/previewimage.cc @@ -76,23 +76,17 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext previewImage = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24, w, h); previewImage->flush(); - #pragma omp parallel - { - const unsigned char *src; - unsigned char *dst; - #pragma omp for schedule(static,10) + #pragma omp parallel for + for (unsigned int i = 0; i < (unsigned int)(h); ++i) { + const unsigned char *src = data + i * w * 3; + unsigned char *dst = previewImage->get_data() + i * w * 4; - for (unsigned int i = 0; i < (unsigned int)(h); ++i) { - src = data + i * w * 3; - dst = previewImage->get_data() + i * w * 4; + for (unsigned int j = 0; j < (unsigned int)(w); ++j) { + unsigned char r = *(src++); + unsigned char g = *(src++); + unsigned char b = *(src++); - for (unsigned int j = 0; j < (unsigned int)(w); ++j) { - unsigned char r = *(src++); - unsigned char g = *(src++); - unsigned char b = *(src++); - - poke255_uc(dst, r, g, b); - } + poke255_uc(dst, r, g, b); } } previewImage->mark_dirty(); @@ -139,29 +133,22 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext if (data) { int w, h; - // double scale = 1.; w = output->getWidth(); h = output->getHeight(); previewImage = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24, w, h); previewImage->flush(); - #pragma omp parallel - { - const unsigned char *src; - unsigned char *dst; - #pragma omp for schedule(static,10) + #pragma omp parallel for + for (unsigned int i = 0; i < (unsigned int)(h); i++) { + const unsigned char *src = data + i * w * 3; + unsigned char *dst = previewImage->get_data() + i * w * 4; - for (unsigned int i = 0; i < (unsigned int)(h); i++) { - src = data + i * w * 3; - dst = previewImage->get_data() + i * w * 4; + for (unsigned int j = 0; j < (unsigned int)(w); j++) { + unsigned char r = *(src++); + unsigned char g = *(src++); + unsigned char b = *(src++); - for (unsigned int j = 0; j < (unsigned int)(w); j++) { - unsigned char r = *(src++); - unsigned char g = *(src++); - unsigned char b = *(src++); - - poke255_uc(dst, r, g, b); - } + poke255_uc(dst, r, g, b); } } diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 35d690eb4..cad810205 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -8339,7 +8339,6 @@ bool ProcParams::operator== (const ProcParams& other) && wavelet.sup == other.wavelet.sup && wavelet.sky == other.wavelet.sky && wavelet.thres == other.wavelet.thres - && wavelet.threshold == other.wavelet.threshold && wavelet.chroma == other.wavelet.chroma && wavelet.chro == other.wavelet.chro && wavelet.tmr == other.wavelet.tmr diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 7c99801c6..e178906d4 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -501,7 +501,7 @@ RawImageSource::~RawImageSource () //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::transformRect (PreviewProps pp, int tran, int &ssx1, int &ssy1, int &width, int &height, int &fw) +void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1, int &ssy1, int &width, int &height, int &fw) { int pp_x = pp.getX() + border; int pp_y = pp.getY() + border; @@ -1490,7 +1490,7 @@ void RawImageSource::getFullSize (int& w, int& h, int tr) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::getSize (PreviewProps pp, int& w, int& h) +void RawImageSource::getSize (const PreviewProps &pp, int& w, int& h) { w = pp.getWidth() / pp.getSkip() + (pp.getWidth() % pp.getSkip() > 0); h = pp.getHeight() / pp.getSkip() + (pp.getHeight() % pp.getSkip() > 0); @@ -2297,7 +2297,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar } } else { TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (cmp.working); - float wp[3][3] = { + const float wp[3][3] = { {static_cast(wprof[0][0]), static_cast(wprof[0][1]), static_cast(wprof[0][2])}, {static_cast(wprof[1][0]), static_cast(wprof[1][1]), static_cast(wprof[1][2])}, {static_cast(wprof[2][0]), static_cast(wprof[2][1]), static_cast(wprof[2][2])} diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index cfcda8477..2c0ac6f19 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -97,7 +97,7 @@ protected: void hphd_green (float** hpmap); void processFalseColorCorrectionThread (Imagefloat* im, array2D &rbconv_Y, array2D &rbconv_I, array2D &rbconv_Q, array2D &rbout_I, array2D &rbout_Q, const int row_from, const int row_to); void hlRecovery (const std::string &method, float* red, float* green, float* blue, int width, float* hlmax); - void transformRect (PreviewProps pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); + void transformRect (const PreviewProps &pp, int tran, int &sx1, int &sy1, int &width, int &height, int &fw); void transformPosition (int x, int y, int tran, int& tx, int& ty); unsigned FC(int row, int col) @@ -156,7 +156,7 @@ public: } void getFullSize (int& w, int& h, int tr = TR_NONE); - void getSize (PreviewProps pp, int& w, int& h); + void getSize (const PreviewProps &pp, int& w, int& h); int getRotateDegree() const { return ri->get_rotateDegree(); diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 16fd4dc5d..00b660036 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -964,7 +964,6 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei gm = camwbGreen / gm; bm = camwbBlue / bm; double mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm; - double logDefGain = 0.0; float rmi, gmi, bmi; rmi = rm * defGain / mul_lum; @@ -1083,6 +1082,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei int hlcomprthresh = params.toneCurve.hlcomprthresh; if (params.toneCurve.autoexp && aeHistogram) { + double logDefGain = 0.0; ipf.getAutoExp (aeHistogram, aeHistCompression, logDefGain, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh); } @@ -1487,7 +1487,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width) // to utilize the 8 bit color range of the thumbnail we brighten it and apply gamma correction unsigned char* tmpdata = new unsigned char[thumbImg->getHeight() * trim_width]; - int ix = 0, max; + int ix = 0; if (gammaCorrected) { // if it's gamma correct (usually a RAW), we have the problem that there is a lot noise etc. that makes the maximum way too high. @@ -1571,7 +1571,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width) } } else { // If it's not gamma corrected (usually a JPG) we take the normal maximum - max = 0; + int max = 0; if (thumbImg->getType() == sImage8) { Image8 *image = static_cast(thumbImg); diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index 5e7001028..87f25a497 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -285,7 +285,7 @@ void StdImageSource::getFullSize (int& w, int& h, int tr) } } -void StdImageSource::getSize (PreviewProps pp, int& w, int& h) +void StdImageSource::getSize (const PreviewProps &pp, int& w, int& h) { w = pp.getWidth() / pp.getSkip() + (pp.getWidth() % pp.getSkip() > 0); h = pp.getHeight() / pp.getSkip() + (pp.getHeight() % pp.getSkip() > 0); diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index baff5559d..330c08244 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -66,7 +66,7 @@ public: } void getFullSize (int& w, int& h, int tr = TR_NONE); - void getSize (PreviewProps pp, int& w, int& h); + void getSize (const PreviewProps &pp, int& w, int& h); ImageData* getImageData () { diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index fae7bdf6b..0cd53279c 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -62,7 +62,6 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCa p++; pmenu.attach (*Gtk::manage(cancel = new MyImageMenuItem (M("FILEBROWSER_POPUPCANCELJOB"), "gtk-close.png")), 0, 1, p, p + 1); - p++; pmenu.show_all (); diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 5160f695f..3e3ca1bfb 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -2113,12 +2113,6 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) // No histogram if (!oldPosition) { // An histogram actually exist, we delete it - if (oldPosition == 1) { - removeIfThere (leftbox, histogramPanel, false); - } else if (oldPosition == 2) { - removeIfThere (vboxright, histogramPanel, false); - } - delete histogramPanel; histogramPanel = nullptr; } diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index 2979b556f..eedb6e262 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -375,7 +375,6 @@ FileBrowser::FileBrowser () pmenu->attach (*Gtk::manage(new Gtk::SeparatorMenuItem ()), 0, 1, p, p + 1); p++; pmenu->attach (*Gtk::manage(cachemenu = new Gtk::MenuItem (M("FILEBROWSER_CACHE"))), 0, 1, p, p + 1); - p++; pmenu->show_all (); diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 9da116e11..48e5c6b4d 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -1460,8 +1460,6 @@ bool BackBuffer::setDrawRectangle(Cairo::Format format, int newX, int newY, int */ void BackBuffer::copyRGBCharData(const unsigned char *srcData, int srcX, int srcY, int srcW, int srcH, int srcRowStride, int dstX, int dstY) { - const unsigned char *src; - unsigned char *dst; unsigned char r, g, b; if (!surface) { @@ -1483,8 +1481,8 @@ void BackBuffer::copyRGBCharData(const unsigned char *srcData, int srcX, int src break; } - src = srcData + i * srcRowStride; - dst = dstData + ((dstY + i) * surfW + dstX) * 4; + const unsigned char *src = srcData + i * srcRowStride; + unsigned char *dst = dstData + ((dstY + i) * surfW + dstX) * 4; for (int j = 0; j < srcW; ++j) { if (dstX + j >= surfW) { diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index ed342f5af..c27862c6e 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -322,7 +322,7 @@ class MyComboBoxText : public Gtk::ComboBoxText void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; public: - MyComboBoxText (bool has_entry = false); + explicit MyComboBoxText (bool has_entry = false); void setPreferredWidth (int minimum_width, int natural_width); void connect(const sigc::connection &connection) { myConnection = connection; } @@ -439,7 +439,7 @@ private: void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; public: - MyProgressBar(int width); + explicit MyProgressBar(int width); MyProgressBar(); void setPreferredWidth(int width); diff --git a/rtgui/inspector.cc b/rtgui/inspector.cc index 6de56e81b..79839b5f9 100644 --- a/rtgui/inspector.cc +++ b/rtgui/inspector.cc @@ -56,30 +56,30 @@ InspectorBuffer::~InspectorBuffer() { } */ -int InspectorBuffer::infoFromImage (const Glib::ustring& fname) -{ - - rtengine::ImageMetaData* idata = rtengine::ImageMetaData::fromFile (fname, nullptr); - - if (!idata) { - return 0; - } - - int deg = 0; - - if (idata->hasExif()) { - if (idata->getOrientation() == "Rotate 90 CW" ) { - deg = 90; - } else if (idata->getOrientation() == "Rotate 180" ) { - deg = 180; - } else if (idata->getOrientation() == "Rotate 270 CW") { - deg = 270; - } - } - - delete idata; - return deg; -} +//int InspectorBuffer::infoFromImage (const Glib::ustring& fname) +//{ +// +// rtengine::ImageMetaData* idata = rtengine::ImageMetaData::fromFile (fname, nullptr); +// +// if (!idata) { +// return 0; +// } +// +// int deg = 0; +// +// if (idata->hasExif()) { +// if (idata->getOrientation() == "Rotate 90 CW" ) { +// deg = 90; +// } else if (idata->getOrientation() == "Rotate 180" ) { +// deg = 180; +// } else if (idata->getOrientation() == "Rotate 270 CW") { +// deg = 270; +// } +// } +// +// delete idata; +// return deg; +//} Inspector::Inspector () : currImage(nullptr), zoom(0.0), active(false) { diff --git a/rtgui/inspector.h b/rtgui/inspector.h index 305558817..f68912dc1 100644 --- a/rtgui/inspector.h +++ b/rtgui/inspector.h @@ -25,8 +25,8 @@ class InspectorBuffer { -private: - int infoFromImage (const Glib::ustring& fname); +//private: +// int infoFromImage (const Glib::ustring& fname); public: BackBuffer imgBuffer; diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 8130e2dfc..27088ed47 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -1518,10 +1518,9 @@ void Preferences::parseThemeDir (Glib::ustring dirname) Glib::ustring fname = Glib::build_filename(dirname, *i); Glib::ustring sname = *i; - bool keepIt = false; - // ignore directories and filter out unsupported theme if (regex->match(sname, matchInfo) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR) && sname.size() >= 4) { + bool keepIt = false; Glib::ustring fname2 = matchInfo.fetch(1); Glib::ustring minMinor = matchInfo.fetch(2); Glib::ustring maxMinor = matchInfo.fetch(3); From 36cd8b7787142257a682a87420527cec0d316efe Mon Sep 17 00:00:00 2001 From: Morgan Hardwood Date: Sun, 9 Apr 2017 15:04:57 +0200 Subject: [PATCH 04/10] Mostly macOS-related changes to CMake and build scripts, #3678 --- CMakeLists.txt | 61 ++++++--- tools/osx/executable_loader.in | 60 ++++++--- tools/osx/libiconv_1.15_rt.patch | 30 +++++ tools/osx/macosx_bundle.sh | 225 ++++++++++++++++--------------- 4 files changed, 227 insertions(+), 149 deletions(-) create mode 100644 tools/osx/libiconv_1.15_rt.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index a7e29e03a..f17cee83e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,11 +114,18 @@ option (AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI # set install directories if (WIN32 OR APPLE) + if(BUILD_BUNDLE) + message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option if force to ON on Windows and macOS.") + endif() set (BUILD_BUNDLE ON FORCE) endif(WIN32 OR APPLE) if (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) - set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") + if (APPLE) + set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MacOS") + else (APPLE) + set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") + endif (APPLE) endif (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) if (BUILD_BUNDLE) @@ -132,7 +139,11 @@ endif (NOT DEFINED BINDIR) if (NOT DEFINED DATADIR) if (BUILD_BUNDLE) - set (DATADIR .) + if (APPLE) + set (DATADIR "../Resources") + else (APPLE) + set (DATADIR .) + endif (APPLE) else (BUILD_BUNDLE) set (DATADIR "${CMAKE_INSTALL_PREFIX}/share/rawtherapee") endif (BUILD_BUNDLE) @@ -140,7 +151,11 @@ endif (NOT DEFINED DATADIR) if (NOT DEFINED LIBDIR) if (BUILD_BUNDLE) - set (LIBDIR .) + if (APPLE) + set (LIBDIR "../Frameworks") + else (APPLE) + set (LIBDIR .) + endif (APPLE) else (BUILD_BUNDLE) # Respect CMAKE_INSTALL_LIBDIR if set if (DEFINED CMAKE_INSTALL_LIBDIR) @@ -157,7 +172,7 @@ endif (NOT DEFINED LIBDIR) if (NOT DEFINED DOCDIR) if (BUILD_BUNDLE) - set (DOCDIR ./doc) + set (DOCDIR "${DATADIR}/share/doc") else (BUILD_BUNDLE) set (DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") endif (BUILD_BUNDLE) @@ -165,7 +180,7 @@ endif (NOT DEFINED DOCDIR) if (NOT DEFINED CREDITSDIR) if (BUILD_BUNDLE) - set (CREDITSDIR .) + set (CREDITSDIR "${DATADIR}") else (BUILD_BUNDLE) set (CREDITSDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") endif (BUILD_BUNDLE) @@ -173,7 +188,7 @@ endif (NOT DEFINED CREDITSDIR) if (NOT DEFINED LICENCEDIR) if (BUILD_BUNDLE) - set (LICENCEDIR .) + set (LICENCEDIR "${DATADIR}") else (BUILD_BUNDLE) set (LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") endif (BUILD_BUNDLE) @@ -181,7 +196,8 @@ endif (NOT DEFINED LICENCEDIR) if (NOT DEFINED DESKTOPDIR) if (UNIX) - set (DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") + set (DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") # Absolute + #set (DESKTOPDIR "${DATADIR}/share/applications") # Relative endif (UNIX) endif (NOT DEFINED DESKTOPDIR) @@ -197,12 +213,24 @@ if (NOT DEFINED APPDATADIR) endif (UNIX) endif (NOT DEFINED APPDATADIR) -# non-bundle builds has to use absolute paths -if (NOT BUILD_BUNDLE AND NOT (IS_ABSOLUTE "${BINDIR}" AND IS_ABSOLUTE "${DATADIR}" AND IS_ABSOLUTE "${LIBDIR}" AND IS_ABSOLUTE "${DOCDIR}" AND IS_ABSOLUTE "${CREDITSDIR}" AND IS_ABSOLUTE "${LICENCEDIR}")) - message (FATAL_ERROR "The paths has to be absolute or use -DBUILD_BUNDLE=ON") +# Enforce absolute paths for non-bundle builds. +if(NOT BUILD_BUNDLE) + if(NOT (IS_ABSOLUTE "${BINDIR}")) + message (FATAL_ERROR "The BINDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT (IS_ABSOLUTE "${DATADIR}")) + message (FATAL_ERROR "The DATADIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT (IS_ABSOLUTE "${LIBDIR}")) + message (FATAL_ERROR "The LIBDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT (IS_ABSOLUTE "${DOCDIR}")) + message (FATAL_ERROR "The DOCDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT (IS_ABSOLUTE "${CREDITSDIR}")) + message (FATAL_ERROR "The CREDITSDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT (IS_ABSOLUTE "${LICENCEDIR}")) + message (FATAL_ERROR "The LICENCEDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + endif() endif () -# MyMutex + # MyMutex if (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") add_definitions (-DSTRICT_MUTEX=1) else (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") @@ -338,7 +366,7 @@ elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) set(PROC_BIT_DEPTH 64 bits) endif (CMAKE_SIZEOF_VOID_P EQUAL 4) -# Get comiler name and version +# Get compiler name and version # only cmake > 2.8.7 knows CMAKE_*_COMPILER_VERSION if (CMAKE_VERSION VERSION_GREATER 2.8.7) get_filename_component(COMPILER_INFO ${CMAKE_C_COMPILER} NAME_WE) @@ -393,13 +421,16 @@ install (FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") install (FILES LICENSE.txt DESTINATION "${LICENCEDIR}") install (FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") install (FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) +if (UNIX OR WIN32) + install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${DOCDIR}/man") +endif () if (WIN32) install (DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") -endif (WIN32) +endif () if (UNIX) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") install (FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") -endif (UNIX) +endif () + add_subdirectory (rtexif) add_subdirectory (rtengine) diff --git a/tools/osx/executable_loader.in b/tools/osx/executable_loader.in index 5f1911edb..535d37ec1 100644 --- a/tools/osx/executable_loader.in +++ b/tools/osx/executable_loader.in @@ -1,31 +1,47 @@ -#!/bin/bash +#!/usr/bin/env bash -cwd="$(cd "$(dirname "$0")"; pwd)" +cd "$(dirname "$0")" || exit 1 + +cwd="$(pwd)" app="${cwd%/Contents/*}" -etc="${cwd}"/etc +lib="${app}/Contents/Frameworks" +resources="${app}/Contents/Resources" +etc="${resources}"/etc -# for different os x versions -# see https://github.com/Beep6581/RawTherapee/issues/1779 -cups_dir=/tmp/RT4 -install -d ${cups_dir} -cp -f /usr/lib/libcups.2.dylib ${cups_dir} +### Pending deletion: +# See https://github.com/Beep6581/RawTherapee/issues/1779 +# cups_dir=/tmp/RT5 +# install -d "${cups_dir}" +# cp -f /usr/lib/libcups.2.dylib "${cups_dir}" +# export DYLD_LIBRARY_PATH="${lib}:${cups_dir}" -export DYLD_LIBRARY_PATH="${cwd}"/lib:${cups_dir} -export GTK_EXE_PREFIX="${cwd}" -export GTK_DATA_PREFIX="${cwd}" -export GTK_IM_MODULE_FILE="${etc}"/gtk-2.0/gtk.immodules -export GDK_PIXBUF_MODULE_FILE="${etc}"/gtk-2.0/gdk-pixbuf.loaders -export XDG_DATA_DIRS="${cwd}"/share -export PANGO_RC_FILE="${etc}"/pango/pangorc +# export GTK_EXE_PREFIX="${resources}" +# export GTK_DATA_PREFIX="${resources}" +# export XDG_DATA_DIRS="${resources}/share" +# export GTK_IM_MODULE_FILE="${etc}/gtk-3.0/gtk.immodules" -# environment variables for X11 backend -if test -d "${etc}"/fonts; then - export FONTCONFIG_PATH="${etc}"/fonts -fi +export DYLD_LIBRARY_PATH="${lib}" -# strip out system argument -case $1 in -psn_*) shift;; esac +export GTK_PATH="${lib}/gtk-3.0/3.0.0" +export XDG_DATA_HOME="${resources}/share" +export GSETTINGS_SCHEMA_DIR="${resources}/share/glib-2.0/schemas" +export GDK_PIXBUF_MODULE_FILE="${etc}/gtk-3.0/gdk-pixbuf.loaders" +export GDK_PIXBUF_MODULEDIR="${lib}/gdk-pixbuf-2.0/2.10.0/loaders" + +export RT_SETTINGS="${HOME}/Library/Application Support/RawTherapee/config" +export RT_CACHE="${HOME}/Library/Application Support/RawTherapee/cache" + +### Pending deletion: +# Environment variables for X11 backend +#if [[ -d ${etc}/fonts ]]; then +# export FONTCONFIG_PATH="${etc}/fonts" +#fi + +# Strip out system argument +case "$1" in + -psn_*) shift ;; +esac ln -sf "${app}" /tmp -exec "${cwd}"/rawtherapee-bin "$@" +exec "${cwd}/rawtherapee-bin" "$@" diff --git a/tools/osx/libiconv_1.15_rt.patch b/tools/osx/libiconv_1.15_rt.patch new file mode 100644 index 000000000..ca434154b --- /dev/null +++ b/tools/osx/libiconv_1.15_rt.patch @@ -0,0 +1,30 @@ +diff --git a/lib/iconv.c b/lib/iconv.c +index 31853a7..630a498 100644 +--- a/lib/iconv.c ++++ b/lib/iconv.c +@@ -611,4 +611,25 @@ strong_alias (libiconv, iconv) + strong_alias (libiconv_close, iconv_close) + #endif + ++#undef iconv_open ++#undef iconv ++#undef iconv_close ++ ++LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode) ++{ ++ return libiconv_open(tocode, fromcode); ++} ++ ++LIBICONV_DLL_EXPORTED size_t iconv (iconv_t icd, ++ ICONV_CONST char * * inbuf, size_t *inbytesleft, ++ char * * outbuf, size_t *outbytesleft) ++{ ++ return libiconv(icd, inbuf, inbytesleft, outbuf, outbytesleft); ++} ++ ++LIBICONV_DLL_EXPORTED int iconv_close (iconv_t icd) ++{ ++ return libiconv_close(icd); ++} ++ + #endif diff --git a/tools/osx/macosx_bundle.sh b/tools/osx/macosx_bundle.sh index 89e0c23b0..26cf87250 100644 --- a/tools/osx/macosx_bundle.sh +++ b/tools/osx/macosx_bundle.sh @@ -1,17 +1,26 @@ -#!/bin/bash +#!/usr/bin/env bash -# Required variables -# ------------------ -# these are very important variables. Must be set into rtdata/CMakeLists.txt! +# Required variables, must be set in rtdata/CMakeLists.txt # - PROJECT_NAME -# - PROJECT_SOURCE_DIR # - PROJECT_VERSION (if without git) +# - PROJECT_SOURCE_DIR # - CMAKE_BUILD_TYPE # - PROC_BIT_DEPTH # - GTK_PREFIX -function message { - printf '\e[34m-- %s\e[m\n' "$*" +# Formatting +fNormal="$(tput sgr0)" +fBold="$(tput bold)" +# Colors depend upon the user's terminal emulator color scheme - what is readable for you may be not readable for someone else. +fMagenta="$(tput setaf 5)" +fRed="$(tput setaf 1)" + +function msg { + printf "\n${fBold}-- %s${fNormal}\n" "${@}" +} + +function msgError { + printf "\n${fBold}Error:${fNormal}\n%s\n" "${@}" } function GetDependencies { @@ -25,14 +34,14 @@ function CheckLink { done } -# source check -if test ! -d "${CMAKE_BUILD_TYPE}"; then - printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n" +# Source check +if [[ ! -d "${CMAKE_BUILD_TYPE}" ]]; then + msgError "${PWD}/${CMAKE_BUILD_TYPE} folder does not exist. Please execute 'make install' first." exit 1 fi -# update project version -if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then +# Update project version +if [[ -x "$(which git)" && -d "${PROJECT_SOURCE_DIR}/.git" ]]; then ### This section is copied from tools/generateReleaseInfo # Get version description. # Depending on whether you checked out a branch (dev) or a tag (release), @@ -62,25 +71,11 @@ if test -x "$(which git)" -a -d "${PROJECT_SOURCE_DIR}/.git"; then fi -# if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling, -# 'MINIMUM_VERSION' will be used host OS X version. -MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" -if test ! -n "${MINIMUM_SYSTEM_VERSION}"; then +MINIMUM_SYSTEM_VERSION="$(otool -l "${CMAKE_BUILD_TYPE}"/MacOS/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')" +if [[ -z "${MINIMUM_SYSTEM_VERSION}" ]]; then MINIMUM_SYSTEM_VERSION="$(sw_vers -productVersion | cut -d. -f-2)" fi -# check for pango-querymodules. Pango 1.38.0 and above do not include it. -# https://github.com/Homebrew/homebrew/issues/44764#issuecomment-146795820 -PangoVer="$(brew list --versions pango)" -PangoVer="${PangoVer//./}" -# Only check the first 4 digits, so that "1.36.99" (13699) doesn't test greater than "1.38.0" (1380) -PangoVer="${PangoVer:0:4}" -if [[ "$PangoVer" -ge "1380" ]]; then - ExistPangoQuerymodules="false" -else - ExistPangoQuerymodules="true" -fi - case ${PROC_BIT_DEPTH} in 64) arch=x86_64;; 32) arch=i386;; @@ -97,127 +92,133 @@ GTK_PREFIX: ${GTK_PREFIX} PWD: ${PWD} __EOS__ -APP="${PROJECT_NAME}".app -CONTENTS="${APP}"/Contents -RESOURCES="${CONTENTS}"/Resources -MACOS="${CONTENTS}"/MacOS -LIB="${MACOS}"/lib -ETC="${MACOS}"/etc -EXECUTABLE="${MACOS}"/rawtherapee +APP="${PROJECT_NAME}.app" +CONTENTS="${APP}/Contents" +RESOURCES="${CONTENTS}/Resources" +MACOS="${CONTENTS}/MacOS" +LIB="${CONTENTS}/Frameworks" +ETC="${RESOURCES}/etc" +EXECUTABLE="${MACOS}/rawtherapee" -message "Removing old files" +msg "Removing old files:" rm -rf "${APP}" "${PROJECT_NAME}_*.dmg" -message "Creating bundle container" +msg "Creating bundle container:" install -d "${RESOURCES}" \ -"${MACOS}" \ -"${LIB}" \ -"${ETC}" + "${MACOS}" \ + "${LIB}" \ + "${ETC}" -message "Copying release files" -ditto "${CMAKE_BUILD_TYPE}" "${MACOS}" +msg "Copying release files:" +ditto "${CMAKE_BUILD_TYPE}/MacOS" "${MACOS}" +ditto "${CMAKE_BUILD_TYPE}/Resources" "${RESOURCES}" -message "Copying dependencies from ${GTK_PREFIX}" +msg "Copying dependencies from ${GTK_PREFIX}:" CheckLink "${EXECUTABLE}" -message "Copying library modules from ${GTK_PREFIX}" -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0 -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/gtk-2.0 -ditto --arch "${arch}" {"${GTK_PREFIX}"/lib,"${LIB}"}/pango +msg "Copying library modules from ${GTK_PREFIX}:" +ditto --arch "${arch}" {"${GTK_PREFIX}/lib","${LIB}"}/gdk-pixbuf-2.0 +ditto --arch "${arch}" {"${GTK_PREFIX}/lib","${LIB}"}/gtk-3.0 -message "Removing static libraries and cache files" +msg "Removing static libraries and cache files:" find -E "${LIB}" -type f -regex '.*\.(a|la|cache)$' | while read; do rm "${REPLY}"; done -message "Copying configuration files from ${GTK_PREFIX}" -install -d "${ETC}"/{gtk-2.0,pango} -cp "${GTK_PREFIX}"/etc/gtk-2.0/im-multipress.conf "${ETC}"/gtk-2.0 -"${GTK_PREFIX}"/bin/gdk-pixbuf-query-loaders "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}"/gtk-2.0/gdk-pixbuf.loaders -"${GTK_PREFIX}"/bin/gtk-query-immodules-2.0 "${LIB}"/gtk-2.0/*/immodules/*.so > "${ETC}"/gtk-2.0/gtk.immodules -sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/gtk-2.0/gdk-pixbuf.loaders \ -"${ETC}"/gtk-2.0/gtk.immodules -if [[ "$ExistPangoQuerymodules" = "true" ]]; then - "${GTK_PREFIX}"/bin/pango-querymodules "${LIB}"/pango/*/modules/*.so > "${ETC}"/pango/pango.modules - sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/pango/pango.modules - printf "[Pango]\nModuleFiles = /tmp/${ETC}/pango/pango.modules" > "${ETC}"/pango/pangorc -fi +msg "Copying configuration files from ${GTK_PREFIX}:" +install -d "${ETC}/gtk-3.0" +cp "${GTK_PREFIX}/etc/gtk-3.0/im-multipress.conf" "${ETC}/gtk-3.0" +"${GTK_PREFIX}/bin/gdk-pixbuf-query-loaders" "${LIB}"/gdk-pixbuf-2.0/*/loaders/*.so > "${ETC}/gtk-3.0/gdk-pixbuf.loaders" +"${GTK_PREFIX}/bin/gtk-query-immodules-3.0" "${LIB}"/gtk-3.0/*/immodules/*.so > "${ETC}/gtk-3.0/gtk.immodules" +sed -i "" -e "s|${PWD}|/tmp|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules" -message "Copying shared files from ${GTK_PREFIX}" -cp -R "${GTK_PREFIX}"/share/mime "${MACOS}"/share -# gtk themes -ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc -ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc -install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0 -(cd "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ln -s ../../Clearlooks/gtk-2.0/gtkrc) +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/glib-2.0/schemas +"${GTK_PREFIX}/bin/glib-compile-schemas" "${RESOURCES}/share/glib-2.0/schemas" + +msg "Copying shared files from ${GTK_PREFIX}:" +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/mime +# GTK3 themes +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/themes/Mac/gtk-3.0/gtk-keys.css +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/themes/Default/gtk-3.0/gtk-keys.css +# Adwaita icons +iconfolders=("16x16/actions" "16x16/devices" "16x16/mimetypes" "16x16/places" "16x16/status" "48x48/devices") +for f in "${iconfolders[@]}"; do + ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/icons/Adwaita/"$f" +done +ditto {"${GTK_PREFIX}","${RESOURCES}"}/share/icons/Adwaita/index.theme +"${GTK_PREFIX}/bin/gtk-update-icon-cache-3.0" "${RESOURCES}/share/icons/Adwaita" + +### Pending deletion: # fontconfig files (X11 backend only) -if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then - message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)" - cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}" -fi +# if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then +# msg "Installing fontconfig files (Using X11 backend. FONTCONFIG_PATH will be set by executable loader.)" +# cp -RL "${GTK_PREFIX}/etc/fonts" "${ETC}" +# fi - - -# install names +# Install names find -E "${MACOS}" -type f -regex '.*/(rawtherapee|.*\.(dylib|so))' | while read x; do - message "Modifying install names: ${x}" + msg "Modifying install names: ${x}" { # id - case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac - # names - GetDependencies "${x}" | while read y; do - echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" - done -} | bash -v + case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac + # names + GetDependencies "${x}" | while read y; do + echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'" + done + } | bash -v done -message "Registering @loader_path into the executable" +msg "Registering @loader_path into the executable:" echo " install_name_tool -add_rpath @loader_path/lib '${EXECUTABLE}'" | bash -v +msg "Installing required application bundle files:" +PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}/tools/osx" - -message "Installing required application bundle files" -PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/tools/osx -# executable loader -# note: executable is renamed to 'rawtherapee-bin'. -mv "${MACOS}"/rawtherapee{,-bin} -install -m 0755 "${PROJECT_SOURCE_DATA_DIR}"/executable_loader.in "${MACOS}"/rawtherapee -# app bundle resources -cp "${PROJECT_SOURCE_DATA_DIR}"/{rawtherapee,profile}.icns "${RESOURCES}" -cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${CONTENTS}" -install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/Info.plist.in "${CONTENTS}"/Info.plist +# Executable loader +# Note: executable is renamed to 'rawtherapee-bin'. +mv "${MACOS}/rawtherapee" "${MACOS}/rawtherapee-bin" +install -m 0755 "${PROJECT_SOURCE_DATA_DIR}/executable_loader.in" "${MACOS}/rawtherapee" +# App bundle resources +cp "${PROJECT_SOURCE_DATA_DIR}/"{rawtherapee,profile}.icns "${RESOURCES}" +cp "${PROJECT_SOURCE_DATA_DIR}/PkgInfo" "${CONTENTS}" +install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/Info.plist.in" "${CONTENTS}/Info.plist" sed -i "" -e "s|@version@|${PROJECT_FULL_VERSION}| s|@shortVersion@|${PROJECT_VERSION}| s|@arch@|${arch}|" \ -"${CONTENTS}"/Info.plist -plutil -convert binary1 "${CONTENTS}"/Info.plist + "${CONTENTS}/Info.plist" +plutil -convert binary1 "${CONTENTS}/Info.plist" function CreateDmg { - local srcdir="$(mktemp -dt $$)" + local srcDir="$(mktemp -dt $$)" - message "Preparing disk image sources at ${srcdir}" - mv "${APP}" "${srcdir}" - cp AboutThisBuild.txt "${srcdir}" - ln -s /Applications "${srcdir}" + msg "Preparing disk image sources at ${srcDir}:" + cp -R "${APP}" "${srcDir}" + cp AboutThisBuild.txt "${srcDir}" + ln -s /Applications "${srcDir}" - # web bookmarks + # Web bookmarks function CreateWebloc { - defaults write "${srcdir}/$1" URL "$2" - mv "${srcdir}/$1".{plist,webloc} + defaults write "${srcDir}/$1" URL "$2" + mv "${srcDir}/$1".{plist,webloc} } - CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com' - CreateWebloc 'Online Manual' 'http://rawpedia.rawtherapee.com/' + CreateWebloc 'Website' 'http://www.rawtherapee.com/' + CreateWebloc 'Manual' 'http://rawpedia.rawtherapee.com/' - # disk image name + # Disk image name dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}" - if ! echo "${CMAKE_BUILD_TYPE}" | grep -sqi "release"; then - dmg_name="${dmg_name}_$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')" + lower_build_type="$(tr '[:upper:]' '[:lower:]' <<< "$CMAKE_BUILD_TYPE")" + if [[ ${lower_build_type} != release ]]; then + dmg_name="${dmg_name}_${lower_build_type}" fi - message "Creating disk image" - hdiutil create -format UDBZ -srcdir "${srcdir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}".dmg + msg "Creating disk image:" + hdiutil create -format UDBZ -srcdir "${srcDir}" -volname "${PROJECT_NAME}_${PROJECT_FULL_VERSION}" "${dmg_name}.dmg" - message "Removing disk image caches" - rm -rf "${srcdir}" + # Zip disk image for redistribution + zip "${dmg_name}.zip" "${dmg_name}.dmg" AboutThisBuild.txt + rm "${dmg_name}.dmg" + + msg "Removing disk image caches:" + rm -rf "${srcDir}" } CreateDmg From cd731e101539a3b6623feb68bc7cb530b8ef29f2 Mon Sep 17 00:00:00 2001 From: Morgan Hardwood Date: Sun, 9 Apr 2017 15:08:32 +0200 Subject: [PATCH 05/10] Style and formatting cleanup of /CMakeLists.txt, #3678 --- CMakeLists.txt | 614 ++++++++++++++++++++++++------------------------- 1 file changed, 307 insertions(+), 307 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f17cee83e..944b134de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,256 +1,256 @@ -if (WIN32) +if(WIN32) cmake_minimum_required(VERSION 2.8.4) -else (WIN32) +else() cmake_minimum_required(VERSION 2.6) -endif (WIN32) +endif() -# must stay before the 'project' command +# Must stay before the 'project' command: if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4") set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE) - # users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the command line to their current version of Eclipse + # Users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the + # command line to their current version of Eclipse: #set(CMAKE_ECLIPSE_VERSION "4.6.0" CACHE STRING "Eclipse version" FORCE) endif() PROJECT(RawTherapee) -# the default target is 'Debug' -if (CMAKE_BUILD_TYPE STREQUAL "") - set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel." FORCE) -endif () +# The default target is Debug: +if(CMAKE_BUILD_TYPE STREQUAL "") + set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel" FORCE) +endif() -string (TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) -# Set required C and C++ standards and check GCC version -SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") -SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +# Set required C and C++ standards and check GCC version: +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9") message(FATAL_ERROR "Building RawTherapee requires using GCC version 4.9 or higher!") endif() -# We might want to build using the old C++ ABI, even when using a new GCC version -if (USE_OLD_CXX_ABI) +# We might want to build using the old C++ ABI, even when using a new GCC version: +if(USE_OLD_CXX_ABI) add_definitions (-D_GLIBCXX_USE_CXX11_ABI=0) endif() -if (UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") +if(UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") add_definitions (-D_DEBUG) -else () +else() add_definitions (-DNDEBUG) add_definitions (-D_DNDEBUG) -endif () +endif() message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") -# Examples: "" = ~/.config/RawTherapee, "latesttag" = ~/.config/RawTherapee4.2, "_testing" = ~/.config/RawTherapee_testing -set (CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") +# Cache name suffix examples: "" = ~/.config/RawTherapee, "5" = ~/.config/RawTherapee-5, "_testing" = ~/.config/RawTherapee_testing +set(CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") -# By default, we don't use specific processor target, so PROC_TARGET_NUMBER is set to 0. If can specify other values to select specific -# processor targets, which list can be found in ProcessorTargets.cmake. -set (PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") +# By default we don't use a specific processor target, so PROC_TARGET_NUMBER is set to 0. +# Specify other values to optimize for specific processor architecture as listed in ProcessorTargets.cmake: +set(PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)") -# The following line set special compilation flags for RTEngine, and will be added to CMAKE_CXX_FLAGS -set (RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") +# Set special compilation flags for rtengine which get added to CMAKE_CXX_FLAGS: +set(RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine") -#loading the processor targets list -include (ProcessorTargets.cmake) -set (PROC_LABEL "undefined" CACHE STRING "Target processor label, unused if PROC_TARGET_NUMBER = 0 or 2") -set (PROC_FLAGS "" CACHE STRING "Target processor related build/link flags") -if ((NOT(PROC_TARGET_NUMBER EQUAL 0)) AND (NOT(PROC_TARGET_NUMBER EQUAL 2))) - set (PROC_LABEL ${PROC_TARGET_${PROC_TARGET_NUMBER}_LABEL}) -endif () -if (NOT(PROC_TARGET_NUMBER EQUAL 0)) - set (PROC_FLAGS ${PROC_TARGET_${PROC_TARGET_NUMBER}_FLAGS}) -endif () -if (UNIX AND PROC_LABEL STREQUAL "undefined") +# Loads the ProcessorTargets list: +include(ProcessorTargets.cmake) +set(PROC_LABEL "undefined" CACHE STRING "Target processor label, unused if PROC_TARGET_NUMBER = 0 or 2") +set(PROC_FLAGS "" CACHE STRING "Target processor related build/link flags") +if((NOT (PROC_TARGET_NUMBER EQUAL 0)) AND (NOT (PROC_TARGET_NUMBER EQUAL 2))) + set(PROC_LABEL ${PROC_TARGET_${PROC_TARGET_NUMBER}_LABEL}) +endif() +if(NOT(PROC_TARGET_NUMBER EQUAL 0)) + set(PROC_FLAGS ${PROC_TARGET_${PROC_TARGET_NUMBER}_FLAGS}) +endif() +if(UNIX AND PROC_LABEL STREQUAL "undefined") execute_process(COMMAND uname -p OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE cpu) - if ("${cpu}" STREQUAL "unknown") + if("${cpu}" STREQUAL "unknown") set(PROC_LABEL "${CMAKE_SYSTEM_PROCESSOR}") - else () - set (PROC_LABEL "${cpu}") - endif () -endif () + else() + set(PROC_LABEL "${cpu}") + endif() +endif() -# if it exists, the PROC_FORCED_LABEL value is loaded in PROC_LABEL to override the one of ProcessorTargets -if (DEFINED PROC_FORCED_LABEL) - set (PROC_LABEL ${PROC_FORCED_LABEL}) -endif (DEFINED PROC_FORCED_LABEL) +# If PROC_FORCED_LABEL exists, its value is loaded in PROC_LABEL to override the one from ProcessorTargets: +if(DEFINED PROC_FORCED_LABEL) + set(PROC_LABEL ${PROC_FORCED_LABEL}) +endif() -# adding the proc flags to the build flags +# Add the proc flags to the build flags: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROC_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROC_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PROC_FLAGS}") -#stop compile on typos like std:swap (missing colon will be detected as unused label) +# Stop compilation on typos such as std:swap (missing colon will be detected as unused label): set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-label") -if (WIN32) - # we additionnally look in the MinGW path first then in the Gtkmm path, - # so if you wish to build some dependant library, you have to install them in MinGW to use them +if(WIN32) + # Add additional paths. Look in the MinGW path first, then in the Gtkmm path. + # If you wish to build some dependent libraries, you have to install them in MinGW to use them: set(CMAKE_PREFIX_PATH $ENV{MINGW_BASEPATH} $ENV{GTKMM_BASEPATH} CACHE STRING "Additional search paths") -endif (WIN32) +endif() -if (APPLE) - if (CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR - CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib") - message (STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") - endif () -endif (APPLE) +if(APPLE) + if(CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib") + message(STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") + endif() +endif() option(USE_EXPERIMENTAL_LANG_VERSIONS "Build RT with -std=c++0x" OFF) -option (BUILD_SHARED "Build rawtherapee with shared libraries" OFF) -option (WITH_BZIP "Build with Bzip2 support" ON) -option (WITH_MYFILE_MMAP "Build using memory mapped file" ON) -option (WITH_LTO "Build with link-time optimizations" OFF) -option (WITH_SAN "Build with run-time sanitizer" OFF) -option (WITH_PROF "Build with profiling instrumentation" OFF) -option (OPTION_OMP "Build with OpenMP support" ON) -option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) -option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) -option (AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) +option(BUILD_SHARED "Build rawtherapee with shared libraries" OFF) +option(WITH_BZIP "Build with Bzip2 support" ON) +option(WITH_MYFILE_MMAP "Build using memory mapped file" ON) +option(WITH_LTO "Build with link-time optimizations" OFF) +option(WITH_SAN "Build with run-time sanitizer" OFF) +option(WITH_PROF "Build with profiling instrumentation" OFF) +option(OPTION_OMP "Build with OpenMP support" ON) +option(STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) +option(TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) +option(AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) -# set install directories -if (WIN32 OR APPLE) +# Set installation directories: +if(WIN32 OR APPLE) if(BUILD_BUNDLE) message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option if force to ON on Windows and macOS.") endif() set (BUILD_BUNDLE ON FORCE) -endif(WIN32 OR APPLE) +endif() -if (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) - if (APPLE) - set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MacOS") - else (APPLE) - set (BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") - endif (APPLE) -endif (NOT DEFINED BUNDLE_BASE_INSTALL_DIR) - -if (BUILD_BUNDLE) - set (BINDIR .) - set (CMAKE_INSTALL_PREFIX "${BUNDLE_BASE_INSTALL_DIR}") -endif (BUILD_BUNDLE) - -if (NOT DEFINED BINDIR) - set (BINDIR "${CMAKE_INSTALL_PREFIX}/bin") -endif (NOT DEFINED BINDIR) - -if (NOT DEFINED DATADIR) - if (BUILD_BUNDLE) - if (APPLE) - set (DATADIR "../Resources") - else (APPLE) - set (DATADIR .) - endif (APPLE) - else (BUILD_BUNDLE) - set (DATADIR "${CMAKE_INSTALL_PREFIX}/share/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED DATADIR) - -if (NOT DEFINED LIBDIR) - if (BUILD_BUNDLE) - if (APPLE) - set (LIBDIR "../Frameworks") - else (APPLE) - set (LIBDIR .) - endif (APPLE) - else (BUILD_BUNDLE) - # Respect CMAKE_INSTALL_LIBDIR if set - if (DEFINED CMAKE_INSTALL_LIBDIR) - if (IS_ABSOLUTE "${LIBDIR}") - set (LIBDIR "${CMAKE_INSTALL_LIBDIR}") - else (IS_ABSOLUTE "${LIBDIR}") - set (LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") - endif (IS_ABSOLUTE "${LIBDIR}") - else (DEFINED CMAKE_INSTALL_LIBDIR) - set (LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") - endif (DEFINED CMAKE_INSTALL_LIBDIR) - endif (BUILD_BUNDLE) -endif (NOT DEFINED LIBDIR) - -if (NOT DEFINED DOCDIR) - if (BUILD_BUNDLE) - set (DOCDIR "${DATADIR}/share/doc") - else (BUILD_BUNDLE) - set (DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED DOCDIR) - -if (NOT DEFINED CREDITSDIR) - if (BUILD_BUNDLE) - set (CREDITSDIR "${DATADIR}") - else (BUILD_BUNDLE) - set (CREDITSDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED CREDITSDIR) - -if (NOT DEFINED LICENCEDIR) - if (BUILD_BUNDLE) - set (LICENCEDIR "${DATADIR}") - else (BUILD_BUNDLE) - set (LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") - endif (BUILD_BUNDLE) -endif (NOT DEFINED LICENCEDIR) - -if (NOT DEFINED DESKTOPDIR) - if (UNIX) - set (DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") # Absolute - #set (DESKTOPDIR "${DATADIR}/share/applications") # Relative - endif (UNIX) -endif (NOT DEFINED DESKTOPDIR) - -if (NOT DEFINED ICONSDIR) - if (UNIX) - set (ICONSDIR "${CMAKE_INSTALL_PREFIX}/share/icons") - endif (UNIX) -endif (NOT DEFINED ICONSDIR) - -if (NOT DEFINED APPDATADIR) - if (UNIX) - set (APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata") - endif (UNIX) -endif (NOT DEFINED APPDATADIR) - -# Enforce absolute paths for non-bundle builds. -if(NOT BUILD_BUNDLE) - if(NOT (IS_ABSOLUTE "${BINDIR}")) - message (FATAL_ERROR "The BINDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT (IS_ABSOLUTE "${DATADIR}")) - message (FATAL_ERROR "The DATADIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT (IS_ABSOLUTE "${LIBDIR}")) - message (FATAL_ERROR "The LIBDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT (IS_ABSOLUTE "${DOCDIR}")) - message (FATAL_ERROR "The DOCDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT (IS_ABSOLUTE "${CREDITSDIR}")) - message (FATAL_ERROR "The CREDITSDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT (IS_ABSOLUTE "${LICENCEDIR}")) - message (FATAL_ERROR "The LICENCEDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") +if(NOT DEFINED BUNDLE_BASE_INSTALL_DIR) + if(APPLE) + set(BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MacOS") + else() + set(BUNDLE_BASE_INSTALL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}") endif() -endif () +endif() - # MyMutex -if (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - add_definitions (-DSTRICT_MUTEX=1) -else (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - add_definitions (-DSTRICT_MUTEX=0) -endif (STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") +if(BUILD_BUNDLE) + set(BINDIR .) + set(CMAKE_INSTALL_PREFIX "${BUNDLE_BASE_INSTALL_DIR}") +endif() -# MyRWMutex -if (TRACE_MYRWMUTEX) - add_definitions (-DTRACE_MYRWMUTEX=1) -else (TRACE_MYRWMUTEX) - add_definitions (-DTRACE_MYRWMUTEX=0) -endif (TRACE_MYRWMUTEX) +if(NOT DEFINED BINDIR) + set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +endif() -if (AUTO_GDK_FLUSH) - add_definitions (-DAUTO_GDK_FLUSH=1) -else (AUTO_GDK_FLUSH) - add_definitions (-DAUTO_GDK_FLUSH=0) -endif (AUTO_GDK_FLUSH) +if(NOT DEFINED DATADIR) + if(BUILD_BUNDLE) + if(APPLE) + set(DATADIR "../Resources") + else() + set(DATADIR .) + endif() + else() + set(DATADIR "${CMAKE_INSTALL_PREFIX}/share/rawtherapee") + endif() +endif() -# check for libraries +if(NOT DEFINED LIBDIR) + if(BUILD_BUNDLE) + if(APPLE) + set(LIBDIR "../Frameworks") + else() + set(LIBDIR .) + endif() + else() + # Respect CMAKE_INSTALL_LIBDIR if set + if(DEFINED CMAKE_INSTALL_LIBDIR) + if(IS_ABSOLUTE "${LIBDIR}") + set(LIBDIR "${CMAKE_INSTALL_LIBDIR}") + else() + set(LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + endif() + else() + set(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") + endif() + endif() +endif() + +if(NOT DEFINED DOCDIR) + if(BUILD_BUNDLE) + set(DOCDIR "${DATADIR}/share/doc") + else() + set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() + +if(NOT DEFINED CREDITSDIR) + if(BUILD_BUNDLE) + set(CREDITSDIR "${DATADIR}") + else() + set(CREDITSDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() + +if(NOT DEFINED LICENCEDIR) + if(BUILD_BUNDLE) + set(LICENCEDIR "${DATADIR}") + else() + set(LICENCEDIR "${CMAKE_INSTALL_PREFIX}/share/doc/rawtherapee") + endif() +endif() + +if(NOT DEFINED DESKTOPDIR) + if(UNIX) + set(DESKTOPDIR "${CMAKE_INSTALL_PREFIX}/share/applications") # Absolute + #set(DESKTOPDIR "${DATADIR}/share/applications") # Relative + endif() +endif() + +if(NOT DEFINED ICONSDIR) + if(UNIX) + set(ICONSDIR "${CMAKE_INSTALL_PREFIX}/share/icons") + endif() +endif() + +if(NOT DEFINED APPDATADIR) + if(UNIX) + set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata") + endif() +endif() + +# Enforce absolute paths for non-bundle builds: +if(NOT BUILD_BUNDLE) + if(NOT(IS_ABSOLUTE "${BINDIR}")) + message(FATAL_ERROR "The BINDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT(IS_ABSOLUTE "${DATADIR}")) + message(FATAL_ERROR "The DATADIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT(IS_ABSOLUTE "${LIBDIR}")) + message(FATAL_ERROR "The LIBDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT(IS_ABSOLUTE "${DOCDIR}")) + message(FATAL_ERROR "The DOCDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT(IS_ABSOLUTE "${CREDITSDIR}")) + message(FATAL_ERROR "The CREDITSDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + elseif(NOT(IS_ABSOLUTE "${LICENCEDIR}")) + message(FATAL_ERROR "The LICENCEDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") + endif() +endif() + +# MyMutex: +if(STRICT_MUTEX OR UPPER_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + add_definitions(-DSTRICT_MUTEX=1) +else() + add_definitions(-DSTRICT_MUTEX=0) +endif() + +# MyRWMutex: +if(TRACE_MYRWMUTEX) + add_definitions(-DTRACE_MYRWMUTEX=1) +else() + add_definitions(-DTRACE_MYRWMUTEX=0) +endif() + +if(AUTO_GDK_FLUSH) + add_definitions(-DAUTO_GDK_FLUSH=1) +else() + add_definitions(-DAUTO_GDK_FLUSH=0) +endif() + +# Check for libraries: find_package(PkgConfig) pkg_check_modules (GTK REQUIRED gtk+-3.0>=3.16) pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.44) @@ -262,121 +262,119 @@ pkg_check_modules (GIOMM REQUIRED giomm-2.4>=2.44) pkg_check_modules (GTHREAD REQUIRED gthread-2.0>=2.44) pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.44) pkg_check_modules (SIGC REQUIRED sigc++-2.0>=2.3.1) -# NOTE: The new mechanism has been tested with BUILD_SHARED = OFF -if (WIN32) - add_definitions (-DWIN32) - add_definitions (-D_WIN32) - if (MINGW) - add_definitions (-D__MINGW32__) - endif (MINGW) - if (CMAKE_SIZEOF_VOID_P EQUAL 4) - add_definitions (-DWINVER=0x0501) - endif (CMAKE_SIZEOF_VOID_P EQUAL 4) - set (EXTRA_LIB "-lws2_32 -lshlwapi") -endif (WIN32) -# you may need lcms v1.xx for older version : pkg_check_modules (LCMS REQUIRED lcms<=1.99) -pkg_check_modules (LCMS REQUIRED lcms2>=2.6) -pkg_check_modules (EXPAT REQUIRED expat>=2.1) -pkg_check_modules (FFTW3F REQUIRED fftw3f) -pkg_check_modules (IPTCDATA REQUIRED libiptcdata) -find_package (JPEG REQUIRED) -find_package (PNG REQUIRED) -find_package (TIFF REQUIRED) -find_package (ZLIB REQUIRED) -# link witz bzip -if (WITH_BZIP) +if(WIN32) + add_definitions(-DWIN32) + add_definitions(-D_WIN32) + if(MINGW) + add_definitions(-D__MINGW32__) + endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + add_definitions(-DWINVER=0x0501) + endif() + set(EXTRA_LIB "-lws2_32 -lshlwapi") +endif() + +pkg_check_modules(LCMS REQUIRED lcms2>=2.6) +pkg_check_modules(EXPAT REQUIRED expat>=2.1) +pkg_check_modules(FFTW3F REQUIRED fftw3f) +pkg_check_modules(IPTCDATA REQUIRED libiptcdata) +find_package(JPEG REQUIRED) +find_package(PNG REQUIRED) +find_package(TIFF REQUIRED) +find_package(ZLIB REQUIRED) + +# Link with bzip: +if(WITH_BZIP) find_package(BZip2) - if (BZIP2_FOUND) - add_definitions (-DBZIP_SUPPORT) - set (EXTRA_INCDIR ${BZIP2_INCLUDE_DIR}) - set (EXTRA_LIB ${EXTRA_LIB} ${BZIP2_LIBRARIES}) - endif (BZIP2_FOUND) -endif (WITH_BZIP) + if(BZIP2_FOUND) + add_definitions(-DBZIP_SUPPORT) + set(EXTRA_INCDIR ${BZIP2_INCLUDE_DIR}) + set(EXTRA_LIB ${EXTRA_LIB} ${BZIP2_LIBRARIES}) + endif() +endif() -#Check for libcanberra-gtk3 (sound events on Linux) -if (UNIX AND (NOT APPLE)) - pkg_check_modules (CANBERRA-GTK REQUIRED libcanberra-gtk3) -endif (UNIX AND (NOT APPLE)) +# Check for libcanberra-gtk3 (sound events on Linux): +if(UNIX AND(NOT APPLE)) + pkg_check_modules(CANBERRA-GTK REQUIRED libcanberra-gtk3) +endif() -if (WITH_MYFILE_MMAP) - add_definitions (-DMYFILE_MMAP) -endif (WITH_MYFILE_MMAP) +if(WITH_MYFILE_MMAP) + add_definitions(-DMYFILE_MMAP) +endif() -if (WITH_LTO) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") -endif (WITH_LTO) +if(WITH_LTO) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") +endif() -if (WITH_SAN) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") -endif (WITH_SAN) +if(WITH_SAN) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") +endif() -if (WITH_PROF) - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") - SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") -endif (WITH_PROF) +if(WITH_PROF) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") +endif() -if (OPTION_OMP) +if(OPTION_OMP) find_package(OpenMP) - if (OPENMP_FOUND) + if(OPENMP_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Werror=unknown-pragmas -Wall -Wno-unused-result -Wno-deprecated-declarations") - endif (OPENMP_FOUND) -endif (OPTION_OMP) + endif() +endif() -# find out whether we are building out of source +# Find out whether we are building out of source: get_filename_component(ABS_SOURCE_DIR "${PROJECT_SOURCE_DIR}" ABSOLUTE) get_filename_component(ABS_BINARY_DIR "${CMAKE_BINARY_DIR}" ABSOLUTE) -set (OUT_OF_SOURCE_BUILD TRUE) -if (ABS_SOURCE_DIR STREQUAL ABS_BINARY_DIR) - set (OUT_OF_SOURCE_BUILD FALSE) - message (WARNING "You are performing an in-source build. This is discouraged. For an explanation and the advantages of out-of-source builds, please refer to http://www.cmake.org/Wiki/CMake_FAQ#What_is_an_.22out-of-source.22_build.3F") -endif () +set(OUT_OF_SOURCE_BUILD TRUE) +if(ABS_SOURCE_DIR STREQUAL ABS_BINARY_DIR) + set(OUT_OF_SOURCE_BUILD FALSE) + message(WARNING "You are performing an in-source build. This is discouraged. For an explanation and the advantages of out-of-source builds, please refer to http://www.cmake.org/Wiki/CMake_FAQ#What_is_an_.22out-of-source.22_build.3F") +endif() -# XXX remove files triggering the below check to prevent every developer from -# needing manual manual work. We will remove this after some time to have a -# clean build system without file modifications in the source tree again. +# Remove files which could require manual work. +# We will remove this after some time to have a clean build system without file modifications in the source tree again. (?) set(OOSB_FILES "${PROJECT_SOURCE_DIR}/rtdata/rawtherapee.desktop" "${PROJECT_SOURCE_DIR}/rtgui/version.h" "${PROJECT_SOURCE_DIR}/rtgui/config.h" "${PROJECT_SOURCE_DIR}/AboutThisBuild.txt") -if (OUT_OF_SOURCE_BUILD) +if(OUT_OF_SOURCE_BUILD) foreach(f ${OOSB_FILES}) - file (REMOVE "${f}") - endforeach(f) -endif () + file(REMOVE "${f}") + endforeach() +endif() -# check for generated files in the source tree which should not be there when -# doing out of source builds. Without checking for this it might happen that old -# versions are used for the compilation -if (OUT_OF_SOURCE_BUILD) +# Check for generated files in the source tree which should not be there when doing an out-of-source build. +# Without checking for this it might happen that old versions are used for the compilation: +if(OUT_OF_SOURCE_BUILD) foreach(f ${OOSB_FILES}) - if (EXISTS "${f}") - message (SEND_ERROR "Generated \"${f}\" found inside the source tree. Please remove it as it is a relic of the old build system and prevents valid compilation now.") - endif () - endforeach(f) -endif () + if(EXISTS "${f}") + message(SEND_ERROR "Generated \"${f}\" found inside the source tree. Please remove it as it is a relic of the old build system and prevents valid compilation now.") + endif() + endforeach() +endif() -## BEGIN: Create AboutThisBuild.txt and other version-dependent files. -# set the bit number information of the platform -if (CMAKE_SIZEOF_VOID_P EQUAL 4) +### Start generating AboutThisBuild.txt +# Set the platform bit-depth: +if(CMAKE_SIZEOF_VOID_P EQUAL 4) set(PROC_BIT_DEPTH 32 bits) -elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) +elseif() set(PROC_BIT_DEPTH 64 bits) -endif (CMAKE_SIZEOF_VOID_P EQUAL 4) +endif() -# Get compiler name and version -# only cmake > 2.8.7 knows CMAKE_*_COMPILER_VERSION -if (CMAKE_VERSION VERSION_GREATER 2.8.7) +# Get compiler name and version. +# Only CMake > 2.8.7 knows CMAKE_*_COMPILER_VERSION +if(CMAKE_VERSION VERSION_GREATER 2.8.7) get_filename_component(COMPILER_INFO ${CMAKE_C_COMPILER} NAME_WE) set(COMPILER_INFO "${COMPILER_INFO} ${CMAKE_C_COMPILER_VERSION}") -else () +else() execute_process(COMMAND gcc -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) set(COMPILER_INFO "gcc ${GCC_VERSION}") -endif () +endif() -# Get c++ and linker flags for rtengine (the gui's c++ flags may have less flags) +# Get C++ and linker flags for rtengine (the GUI's C++ flags may have fewer flags): set(CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} ${RTENGINE_CXX_FLAGS}") set(LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}}") @@ -390,49 +388,51 @@ set(ABOUT_COMMAND_WITH_ARGS ${CMAKE_COMMAND} -DOPTION_OMP:STRING=${OPTION_OMP} -DWITH_MYFILE_MMAP:STRING=${WITH_MYFILE_MMAP}) -if (WIN32) +if(WIN32) list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Windows -DCXX_FLAGS:STRING="${CXX_FLAGS}" -DLFLAGS:STRING="${LFLAGS}" -DCOMPILER_INFO:STRING="${COMPILER_INFO}" -DCMAKE_INSTALL_PREFIX:STRING="${CMAKE_INSTALL_PREFIX}" -DBIT_DEPTH:STRING="${CMAKE_SIZEOF_VOID_P}") -elseif (APPLE) +elseif(APPLE) list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Apple -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO}) -else (WIN32) +else() list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Linux -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO}) -endif (WIN32) +endif() list(APPEND ABOUT_COMMAND_WITH_ARGS -P "${PROJECT_SOURCE_DIR}/UpdateInfo.cmake") add_custom_target(UpdateInfo ALL COMMAND ${ABOUT_COMMAND_WITH_ARGS} COMMENT "Creating AboutThisBuild.txt and other version-dependent files") +### End generating AboutThisBuild.txt -## END: Generating AboutThisBuild.txt +install(FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") +install(FILES LICENSE.txt DESTINATION "${LICENCEDIR}") +install(FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") +install(FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) -install (FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") -install (FILES LICENSE.txt DESTINATION "${LICENCEDIR}") -install (FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") -install (FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) -if (UNIX OR WIN32) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${DOCDIR}/man") -endif () -if (WIN32) - install (DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") -endif () -if (UNIX) - install (FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") -endif () +if(UNIX OR WIN32) + install(FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${DOCDIR}/man") +endif() +if(WIN32) + install(DIRECTORY "licenses" DESTINATION "${LICENCEDIR}") +endif() + +if(UNIX) + install(FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}") +endif() + +add_subdirectory(rtexif) +add_subdirectory(rtengine) +add_subdirectory(rtgui) +add_subdirectory(rtdata) -add_subdirectory (rtexif) -add_subdirectory (rtengine) -add_subdirectory (rtgui) -add_subdirectory (rtdata) From 0c0d8bfe4313978f358501db5b829940d7b26755 Mon Sep 17 00:00:00 2001 From: Morgan Hardwood Date: Sun, 9 Apr 2017 15:17:27 +0200 Subject: [PATCH 06/10] Small comment and explanation cleanup in /CMakeLists.txt, #3678. --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 944b134de..b583cb4fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") # Cache name suffix examples: "" = ~/.config/RawTherapee, "5" = ~/.config/RawTherapee-5, "_testing" = ~/.config/RawTherapee_testing +# Use "" for stable releases and "5-dev" for anything else. set(CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix") # By default we don't use a specific processor target, so PROC_TARGET_NUMBER is set to 0. @@ -100,8 +101,8 @@ if(APPLE) endif() endif() -option(USE_EXPERIMENTAL_LANG_VERSIONS "Build RT with -std=c++0x" OFF) -option(BUILD_SHARED "Build rawtherapee with shared libraries" OFF) +option(USE_EXPERIMENTAL_LANG_VERSIONS "Build with -std=c++0x" OFF) +option(BUILD_SHARED "Build with shared libraries" OFF) option(WITH_BZIP "Build with Bzip2 support" ON) option(WITH_MYFILE_MMAP "Build using memory mapped file" ON) option(WITH_LTO "Build with link-time optimizations" OFF) @@ -109,8 +110,9 @@ option(WITH_SAN "Build with run-time sanitizer" OFF) option(WITH_PROF "Build with profiling instrumentation" OFF) option(OPTION_OMP "Build with OpenMP support" ON) option(STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) -option(TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) +option(TRACE_MYRWMUTEX "Trace custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) option(AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI thread; set it ON if you experience X Server warning/errors" OFF) +#option(TARGET32BIT "Build for 32-bit architecture when ON, otherwise 64-bit. Default is OFF" OFF) # Set installation directories: if(WIN32 OR APPLE) From 5de2ff4b60423a6cfcdb9e91aaba52111726e893 Mon Sep 17 00:00:00 2001 From: Morgan Hardwood Date: Sun, 9 Apr 2017 15:44:59 +0200 Subject: [PATCH 07/10] CMake - Man page location for Linux fixed, #3678 --- CMakeLists.txt | 9 ++++++--- rtdata/CMakeLists.txt | 4 ---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b583cb4fc..30e1d1fc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ else() cmake_minimum_required(VERSION 2.6) endif() -# Must stay before the 'project' command: +# Must stay before the PROJECT() command: if(${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4") set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE) # Users building with Eclipse should set CMAKE_ECLIPSE_VERSION through the @@ -117,7 +117,7 @@ option(AUTO_GDK_FLUSH "Use gdk_flush on all gdk_thread_leave other than the GUI # Set installation directories: if(WIN32 OR APPLE) if(BUILD_BUNDLE) - message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option if force to ON on Windows and macOS.") + message(STATUS "You have set BUILD_BUNDLE=ON but this is not necessary - the option is forced to ON for Windows and macOS.") endif() set (BUILD_BUNDLE ON FORCE) endif() @@ -414,6 +414,7 @@ list(APPEND ABOUT_COMMAND_WITH_ARGS -P "${PROJECT_SOURCE_DIR}/UpdateInfo.cmake") add_custom_target(UpdateInfo ALL COMMAND ${ABOUT_COMMAND_WITH_ARGS} COMMENT "Creating AboutThisBuild.txt and other version-dependent files") + ### End generating AboutThisBuild.txt install(FILES AUTHORS.txt DESTINATION "${CREDITSDIR}") @@ -421,8 +422,10 @@ install(FILES LICENSE.txt DESTINATION "${LICENCEDIR}") install(FILES "${CMAKE_BINARY_DIR}/AboutThisBuild.txt" DESTINATION "${CREDITSDIR}") install(FILES RELEASE_NOTES.txt DESTINATION "${CREDITSDIR}" OPTIONAL) +# The standard location for man pages in Linux is /usr/share/man +# Use "manpath" to see the search paths for man pages on your system. if(UNIX OR WIN32) - install(FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${DOCDIR}/man") + install(FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") endif() if(WIN32) diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 5967bd70a..0bb356172 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -48,10 +48,6 @@ install (DIRECTORY ${IMAGESDIR} DESTINATION "${DATADIR}" FILES_MATCHING PATTERN install (DIRECTORY ${IMAGESDIR} DESTINATION "${DATADIR}" FILES_MATCHING PATTERN "*.png") install (FILES ${OPTIONSFILE} DESTINATION "${DATADIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ RENAME options) -if (WIN32) - install (FILES "${PROJECT_SOURCE_DIR}/doc/manpage/rawtherapee.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1") -endif (WIN32) - if (APPLE) # CMake escapes first item quote character. Do not remove 'DUMMY_VARIABLE='. set (MACOSX_BUNDLE_COMMAND DUMMY_VARIABLE= From 7f71c611cbc47539818eb73b02ee776e5d7a2637 Mon Sep 17 00:00:00 2001 From: Morgan Hardwood Date: Sun, 9 Apr 2017 16:10:29 +0200 Subject: [PATCH 08/10] CMake - Cleaner absolute path checking, #3678. --- CMakeLists.txt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30e1d1fc5..d1893ca33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,19 +217,11 @@ endif() # Enforce absolute paths for non-bundle builds: if(NOT BUILD_BUNDLE) - if(NOT(IS_ABSOLUTE "${BINDIR}")) - message(FATAL_ERROR "The BINDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT(IS_ABSOLUTE "${DATADIR}")) - message(FATAL_ERROR "The DATADIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT(IS_ABSOLUTE "${LIBDIR}")) - message(FATAL_ERROR "The LIBDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT(IS_ABSOLUTE "${DOCDIR}")) - message(FATAL_ERROR "The DOCDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT(IS_ABSOLUTE "${CREDITSDIR}")) - message(FATAL_ERROR "The CREDITSDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - elseif(NOT(IS_ABSOLUTE "${LICENCEDIR}")) - message(FATAL_ERROR "The LICENCEDIR path has to be absolute, or use -DBUILD_BUNDLE=ON") - endif() + foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR) + if(NOT (IS_ABSOLUTE "${${path}}")) + message (FATAL_ERROR "The ${path} path has to be absolute when using -DBUILD_BUNDLE=OFF") + endif() + endforeach() endif() # MyMutex: From ffd80a96e2e652fbbf4f992da85009a719900d77 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 9 Apr 2017 19:19:46 +0200 Subject: [PATCH 09/10] Fix warning in PF_correct_RT.cc --- rtengine/PF_correct_RT.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index cfe1e2ba3..6e1fe75d6 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -1469,7 +1469,7 @@ SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, d #ifdef __SSE2__ for (; j < width - 5; j += 4) { - vfloat shfabsv = vabsf(LVFU(src->L[i][j]) - LVFU(tmL[i][j])); + shfabsv = vabsf(LVFU(src->L[i][j]) - LVFU(tmL[i][j])); shmedv = ZEROV; for (i1 = max(0, i - 2); i1 <= min(i + 2, height - 1); i1++ ) From 8f1e2cee42a7ace6d2ac8e6fa35d4089d45831c1 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sun, 9 Apr 2017 21:17:22 +0200 Subject: [PATCH 10/10] properly reset the `editedHandle` field of `MyFlatCurve` when cleaning up the curve editor Tentative fix for #3813 --- rtgui/myflatcurve.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index c98268683..210fb42f2 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -1194,6 +1194,7 @@ void MyFlatCurve::pipetteMouseOver (CurveEditor *ce, EditDataProvider *provider, // occurs when leaving the preview area -> cleanup the curve editor pipetteR = pipetteG = pipetteB = -1.f; lit_point = -1; + editedHandle = FCT_EditedHandle_None; return; }