Fixed crash and add suppress bad message in history and mip in cache

This commit is contained in:
Desmis
2017-02-14 08:09:42 +01:00
43 changed files with 1900 additions and 872 deletions

View File

@@ -28,7 +28,19 @@
#include <unistd.h>
//#include <chrono>
// "ceil" rounding
#define SKIPS(a,b) ((a) / (b) + ((a) % (b) > 0))
//#define SKIPS(a,b) ((a) / (b) + ((a) % (b) > 0))
namespace
{
// "ceil" rounding
template<typename T>
constexpr T skips (T a, T b)
{
return a / b + static_cast<bool> (a % b);
}
}
namespace rtengine
{
@@ -37,8 +49,8 @@ extern const Settings* settings;
Crop::Crop (ImProcCoordinator* parent, EditDataProvider *editDataProvider, bool isDetailWindow)
: PipetteBuffer (editDataProvider), origCrop (nullptr), laboCrop (nullptr), labnCrop (nullptr),
cropImg (nullptr), cbuf_real (nullptr), shbuf_real (nullptr), cshmap (nullptr), transCrop (nullptr), cieCrop (nullptr), cbuffer (nullptr), shbuffer (nullptr),
updating (false), newUpdatePending (false), skip (10), padding (0),
cropImg (nullptr), cbuf_real (nullptr), shbuf_real (nullptr), cshmap (nullptr), transCrop (nullptr), cieCrop (nullptr), cbuffer (nullptr), shbuffer (nullptr),
updating (false), newUpdatePending (false), skip (10),
cropx (0), cropy (0), cropw (-1), croph (-1),
trafx (0), trafy (0), trafw (-1), trafh (-1),
rqcropx (0), rqcropy (0), rqcropw (-1), rqcroph (-1),
@@ -116,6 +128,12 @@ void Crop::setEditSubscriber (EditSubscriber* newSubscriber)
// If oldSubscriber == NULL && newSubscriber != NULL && newSubscriber->getEditingType() == ET_PIPETTE-> the image will be allocated when necessary
}
bool Crop::hasListener()
{
MyMutex::MyLock cropLock (cropMutex);
return cropImageListener;
}
void Crop::update (int todo)
{
MyMutex::MyLock cropLock (cropMutex);
@@ -690,7 +708,7 @@ void Crop::update (int todo)
}
if (needstransform)
parent->ipf.transform (baseCrop, transCrop, cropx / skip, cropy / skip, trafx / skip, trafy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(),
parent->ipf.transform (baseCrop, transCrop, cropx / skip, cropy / skip, trafx / skip, trafy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(),
parent->imgsrc->getMetaData()->getFocalLen(), parent->imgsrc->getMetaData()->getFocalLen35mm(),
parent->imgsrc->getMetaData()->getFocusDist(), parent->imgsrc->getRotateDegree(), false);
else {
@@ -721,7 +739,7 @@ void Crop::update (int todo)
// blurmap for shadow & highlights
if ((todo & M_BLURMAP) && params.sh.enabled) {
double radius = sqrt (double (SKIPS (parent->fw, skip) * SKIPS (parent->fw, skip) + SKIPS (parent->fh, skip) * SKIPS (parent->fh, skip))) / 2.0;
double radius = sqrt (double (skips (parent->fw, skip) * skips (parent->fw, skip) + skips (parent->fh, skip) * skips (parent->fh, skip))) / 2.0;
double shradius = params.sh.radius;
if (!params.sh.hq) {
@@ -817,7 +835,8 @@ void Crop::update (int todo)
if (needslocal ) {
// if (tyty ) {
//Glib::ustring datalab2 = parent->imgsrc->getFileName() + ".mip";
Glib::ustring pop = options.getUserProfilePath() + "/";
// Glib::ustring pop = options.getUserProfilePath() + "/";
Glib::ustring pop = options.cacheBaseDir + "/mip/";
Glib::ustring datalab;
@@ -1011,7 +1030,7 @@ void Crop::update (int todo)
params.locallab.chromaref = parent->chromarefs[sp];
params.locallab.lumaref = parent->lumarefs[sp];
parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref);
parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->fw, parent->fh, locutili, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref);
lllocalcurve2.clear();
cclocalcurve2.clear();
@@ -1247,7 +1266,7 @@ void Crop::update (int todo)
params.locallab.chromaref = parent->chromarefs[sp];
params.locallab.lumaref = parent->lumarefs[sp];
parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, SKIPS (parent->fw, skip), SKIPS (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), locutili2, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref);
parent->ipf.Lab_Local (1, sp, (float**)shbuffer, labnCrop, labnCrop, trafx / skip, trafy / skip, cropx / skip, cropy / skip, skips (parent->fw, skip), skips (parent->fh, skip), parent->getFullWidth(), parent->getFullHeight(), locutili2, skip, locRETgainCurve, locallutili, lllocalcurve2, loclhCurve, cclocalcurve2, params.locallab.hueref, params.locallab.chromaref, params.locallab.lumaref);
lllocalcurve2.clear();
cclocalcurve2.clear();
@@ -1590,12 +1609,11 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte
PreviewProps cp (orx, ory, orw, orh, skip);
int orW, orH;
parent->imgsrc->getSize (cp, orW, orH);
int cw = skips (bw, skip);
int ch = skips (bh, skip);
int cw = SKIPS (bw, skip);
int ch = SKIPS (bh, skip);
leftBorder = SKIPS (rqx1 - bx1, skip);
upperBorder = SKIPS (rqy1 - by1, skip);
leftBorder = skips (rqx1 - bx1, skip);
upperBorder = skips (rqy1 - by1, skip);
if (settings->verbose) {
printf ("setsizes starts (%d, %d, %d, %d, %d, %d)\n", orW, orH, trafw, trafh, cw, ch);
@@ -1787,5 +1805,22 @@ void Crop::fullUpdate ()
parent->updaterThreadStart.unlock ();
}
int Crop::get_skip()
{
MyMutex::MyLock lock (cropMutex);
return skip;
}
int Crop::getLeftBorder()
{
MyMutex::MyLock lock (cropMutex);
return leftBorder;
}
int Crop::getUpperBorder()
{
MyMutex::MyLock lock (cropMutex);
return upperBorder;
}
}