reduce updates to preview, panning background, navigator and thumbs, fixes #4834

This commit is contained in:
heckflosse 2018-09-27 18:16:29 +02:00
parent 080033765c
commit 095cb010e5
6 changed files with 824 additions and 764 deletions

View File

@ -140,36 +140,32 @@ DetailedCrop* ImProcCoordinator::createCrop(::EditDataProvider *editDataProvider
// todo: bitmask containing desired actions, taken from changesSinceLast // todo: bitmask containing desired actions, taken from changesSinceLast
// cropCall: calling crop, used to prevent self-updates ...doesn't seem to be used void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
{ {
MyMutex::MyLock processingLock(mProcessing); MyMutex::MyLock processingLock(mProcessing);
int numofphases = 14;
constexpr int numofphases = 14;
int readyphase = 0; int readyphase = 0;
bwAutoR = bwAutoG = bwAutoB = -9000.f; bool highDetailNeeded = options.prevdemo == PD_Sidecar ? true : (todo & M_HIGHQUAL);
if (todo == CROP && ipf.needsPCVignetting()) {
todo |= TRANSFORM; // Change about Crop does affect TRANSFORM
}
bool highDetailNeeded = false;
if (options.prevdemo == PD_Sidecar) {
highDetailNeeded = true; //i#2664
} else {
highDetailNeeded = (todo & M_HIGHQUAL);
}
// Check if any detail crops need high detail. If not, take a fast path short cut // Check if any detail crops need high detail. If not, take a fast path short cut
if (!highDetailNeeded) { if (!highDetailNeeded) {
for (size_t i = 0; i < crops.size(); i++) for (size_t i = 0; i < crops.size(); i++) {
if (crops[i]->get_skip() == 1) { // skip=1 -> full resolution if (crops[i]->get_skip() == 1) { // skip=1 -> full resolution
highDetailNeeded = true; highDetailNeeded = true;
break; break;
} }
} }
}
if (((todo & ALL) == ALL) || panningRelatedChange || (highDetailNeeded && options.prevdemo != PD_Sidecar)) {
bwAutoR = bwAutoG = bwAutoB = -9000.f;
if (todo == CROP && ipf.needsPCVignetting()) {
todo |= TRANSFORM; // Change about Crop does affect TRANSFORM
}
RAWParams rp = params.raw; RAWParams rp = params.raw;
ColorManagementParams cmp = params.icm; ColorManagementParams cmp = params.icm;
@ -603,8 +599,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
satPR = (int) 100.f * (moyS - 0.85f * eqty); satPR = (int) 100.f * (moyS - 0.85f * eqty);
} }
if (actListener) { if (actListener && params.colorToning.enabled) {
//if(params.blackwhite.enabled) {actListener->autoColorTonChanged(0, satTH, satPR);}
if (params.blackwhite.enabled && params.colorToning.autosat) { if (params.blackwhite.enabled && params.colorToning.autosat) {
actListener->autoColorTonChanged(0, satTH, satPR); //hide sliders only if autosat actListener->autoColorTonChanged(0, satTH, satPR); //hide sliders only if autosat
indi = 0; indi = 0;
@ -621,8 +616,6 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
} else if (params.colorToning.method == "Splitlr") { } else if (params.colorToning.method == "Splitlr") {
indi = 2; indi = 2;
} }
//actListener->autoColorTonChanged(indi, satTH, satPR);
} }
} }
} }
@ -899,13 +892,15 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
lastOutputBPC = params.icm.outputBPC; lastOutputBPC = params.icm.outputBPC;
ipf.updateColorProfiles(monitorProfile, monitorIntent, softProof, gamutCheck); ipf.updateColorProfiles(monitorProfile, monitorIntent, softProof, gamutCheck);
} }
}
// process crop, if needed // process crop, if needed
for (size_t i = 0; i < crops.size(); i++) for (size_t i = 0; i < crops.size(); i++)
if (crops[i]->hasListener() && cropCall != crops[i]) { if (crops[i]->hasListener() && (panningRelatedChange || crops[i]->get_skip() == 1)) {
crops[i]->update(todo); // may call ourselves crops[i]->update(todo); // may call ourselves
} }
if (panningRelatedChange) {
progress("Conversion to RGB...", 100 * readyphase / numofphases); progress("Conversion to RGB...", 100 * readyphase / numofphases);
if ((todo != CROP && todo != MINUPDATE) || (todo & M_MONITOR)) { if ((todo != CROP && todo != MINUPDATE) || (todo & M_MONITOR)) {
@ -944,6 +939,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
updateLRGBHistograms(); updateLRGBHistograms();
hListener->histogramChanged(histRed, histGreen, histBlue, histLuma, histToneCurve, histLCurve, histCCurve, /*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRedRaw, histGreenRaw, histBlueRaw, histChroma, histLRETI); hListener->histogramChanged(histRed, histGreen, histBlue, histLuma, histToneCurve, histLCurve, histCCurve, /*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRedRaw, histGreenRaw, histBlueRaw, histChroma, histLRETI);
} }
}
} }
@ -1414,6 +1410,7 @@ void ImProcCoordinator::process()
paramsUpdateMutex.lock(); paramsUpdateMutex.lock();
while (changeSinceLast) { while (changeSinceLast) {
const bool panningRelatedChange = params.isPanningRelatedChange(nextParams);
params = nextParams; params = nextParams;
int change = changeSinceLast; int change = changeSinceLast;
changeSinceLast = 0; changeSinceLast = 0;
@ -1421,7 +1418,7 @@ void ImProcCoordinator::process()
// M_VOID means no update, and is a bit higher that the rest // M_VOID means no update, and is a bit higher that the rest
if (change & (M_VOID - 1)) { if (change & (M_VOID - 1)) {
updatePreviewImage(change); updatePreviewImage(change, panningRelatedChange);
} }
paramsUpdateMutex.lock(); paramsUpdateMutex.lock();

View File

@ -179,7 +179,7 @@ protected:
void reallocAll (); void reallocAll ();
void updateLRGBHistograms (); void updateLRGBHistograms ();
void setScale (int prevscale); void setScale (int prevscale);
void updatePreviewImage (int todo, Crop* cropCall = nullptr); void updatePreviewImage (int todo, bool panningRelatedChange);
MyMutex mProcessing; MyMutex mProcessing;
ProcParams params; ProcParams params;

View File

@ -1646,7 +1646,9 @@ bool LensProfParams::operator ==(const LensProfParams& other) const
&& useCA == other.useCA && useCA == other.useCA
&& lfCameraMake == other.lfCameraMake && lfCameraMake == other.lfCameraMake
&& lfCameraModel == other.lfCameraModel && lfCameraModel == other.lfCameraModel
&& lfLens == other.lfLens; && lfLens == other.lfLens
&& useDist == other.useDist
&& useVign == other.useVign;
} }
bool LensProfParams::operator !=(const LensProfParams& other) const bool LensProfParams::operator !=(const LensProfParams& other) const
@ -5046,6 +5048,73 @@ int ProcParams::write(const Glib::ustring& fname, const Glib::ustring& content)
return error; return error;
} }
bool ProcParams::isThumbRelatedChange(const ProcParams &newParams) const
{
return toneCurve != newParams.toneCurve
|| labCurve != newParams.labCurve
|| localContrast != newParams.localContrast
|| rgbCurves != newParams.rgbCurves
|| colorToning != newParams.colorToning
|| vibrance != newParams.vibrance
|| wb != newParams.wb
|| colorappearance != newParams.colorappearance
|| epd != newParams.epd
|| fattal != newParams.fattal
|| sh != newParams.sh
|| crop != newParams.crop
|| coarse != newParams.coarse
|| commonTrans != newParams.commonTrans
|| rotate != newParams.rotate
|| distortion != newParams.distortion
|| lensProf != newParams.lensProf
|| perspective != newParams.perspective
|| gradient != newParams.gradient
|| pcvignette != newParams.pcvignette
|| cacorrection != newParams.cacorrection
|| vignetting != newParams.vignetting
|| chmixer != newParams.chmixer
|| blackwhite != newParams.blackwhite
|| icm != newParams.icm
|| hsvequalizer != newParams.hsvequalizer
|| filmSimulation != newParams.filmSimulation
|| softlight != newParams.softlight;
}
bool ProcParams::isPanningRelatedChange(const ProcParams &newParams) const
{
return toneCurve != newParams.toneCurve
|| labCurve != newParams.labCurve
|| localContrast != newParams.localContrast
|| rgbCurves != newParams.rgbCurves
|| colorToning != newParams.colorToning
|| vibrance != newParams.vibrance
|| wb != newParams.wb
|| colorappearance != newParams.colorappearance
|| epd != newParams.epd
|| fattal != newParams.fattal
|| sh != newParams.sh
|| crop != newParams.crop
|| coarse != newParams.coarse
|| commonTrans != newParams.commonTrans
|| rotate != newParams.rotate
|| distortion != newParams.distortion
|| lensProf != newParams.lensProf
|| perspective != newParams.perspective
|| gradient != newParams.gradient
|| pcvignette != newParams.pcvignette
|| cacorrection != newParams.cacorrection
|| vignetting != newParams.vignetting
|| chmixer != newParams.chmixer
|| blackwhite != newParams.blackwhite
|| icm != newParams.icm
|| hsvequalizer != newParams.hsvequalizer
|| filmSimulation != newParams.filmSimulation
|| softlight != newParams.softlight
|| raw != newParams.raw
|| retinex != newParams.retinex
|| dirpyrequalizer != newParams.dirpyrequalizer;
}
PartialProfile::PartialProfile(bool createInstance, bool paramsEditedValue) PartialProfile::PartialProfile(bool createInstance, bool paramsEditedValue)
{ {
if (createInstance) { if (createInstance) {

View File

@ -1488,6 +1488,9 @@ public:
bool operator ==(const ProcParams& other) const; bool operator ==(const ProcParams& other) const;
bool operator !=(const ProcParams& other) const; bool operator !=(const ProcParams& other) const;
bool isThumbRelatedChange(const ProcParams &newParams) const;
bool isPanningRelatedChange(const ProcParams &newParams) const;
private: private:
/** Write the ProcParams's text in the file of the given name. /** Write the ProcParams's text in the file of the given name.
* @param fname the name of the file * @param fname the name of the file

View File

@ -37,7 +37,7 @@ using namespace rtengine::procparams;
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf)
: fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(nullptr), : fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(nullptr),
pparamsValid(false), needsReProcessing(true), imageLoading(false), lastImg(nullptr), pparamsValid(false), imageLoading(false), lastImg(nullptr),
lastW(0), lastH(0), lastScale(0), initial_(false) lastW(0), lastH(0), lastScale(0), initial_(false)
{ {
@ -65,7 +65,7 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageDa
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5)
: fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(nullptr), pparamsValid(false), : fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(nullptr), pparamsValid(false),
needsReProcessing(true), imageLoading(false), lastImg(nullptr), imageLoading(false), lastImg(nullptr),
lastW(0), lastH(0), lastScale(0.0), initial_(true) lastW(0), lastH(0), lastScale(0.0), initial_(true)
{ {
@ -155,7 +155,6 @@ void Thumbnail::_generateThumbnailImage ()
tpp->getAutoWBMultipliers(cfs.redAWBMul, cfs.greenAWBMul, cfs.blueAWBMul); tpp->getAutoWBMultipliers(cfs.redAWBMul, cfs.greenAWBMul, cfs.blueAWBMul);
_saveThumbnail (); _saveThumbnail ();
cfs.supported = true; cfs.supported = true;
needsReProcessing = true;
cfs.save (getCacheFileName ("data", ".txt")); cfs.save (getCacheFileName ("data", ".txt"));
@ -368,7 +367,6 @@ void Thumbnail::clearProcParams (int whoClearedIt)
cfs.recentlySaved = false; cfs.recentlySaved = false;
pparamsValid = false; pparamsValid = false;
needsReProcessing = true;
//TODO: run though customprofilebuilder? //TODO: run though customprofilebuilder?
// probably not as this is the only option to set param values to default // probably not as this is the only option to set param values to default
@ -413,7 +411,7 @@ void Thumbnail::clearProcParams (int whoClearedIt)
} }
} }
bool Thumbnail::hasProcParams () bool Thumbnail::hasProcParams () const
{ {
return pparamsValid; return pparamsValid;
@ -421,26 +419,21 @@ bool Thumbnail::hasProcParams ()
void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoChangedIt, bool updateCacheNow) void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoChangedIt, bool updateCacheNow)
{ {
const bool needsReprocessing = pparams.isThumbRelatedChange(pp);
{ {
MyMutex::MyLock lock(mutex); MyMutex::MyLock lock(mutex);
if (pparams.sharpening.threshold.isDouble() != pp.sharpening.threshold.isDouble()) {
printf("WARNING: Sharpening different!\n");
}
if (pparams.vibrance.psthreshold.isDouble() != pp.vibrance.psthreshold.isDouble()) {
printf("WARNING: Vibrance different!\n");
}
if (pparams != pp) { if (pparams != pp) {
cfs.recentlySaved = false; cfs.recentlySaved = false;
} else if (pparamsValid && !updateCacheNow) {
// nothing to do
return;
} }
// do not update rank, colorlabel and inTrash // do not update rank, colorlabel and inTrash
int rank = getRank(); const int rank = getRank();
int colorlabel = getColorLabel(); const int colorlabel = getColorLabel();
int inTrash = getStage(); const int inTrash = getStage();
if (pe) { if (pe) {
pe->combine(pparams, pp, true); pe->combine(pparams, pp, true);
@ -449,7 +442,6 @@ void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoCh
} }
pparamsValid = true; pparamsValid = true;
needsReProcessing = true;
setRank(rank); setRank(rank);
setColorLabel(colorlabel); setColorLabel(colorlabel);
@ -458,15 +450,16 @@ void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoCh
if (updateCacheNow) { if (updateCacheNow) {
updateCache(); updateCache();
} }
} // end of mutex lock } // end of mutex lock
if (needsReprocessing) {
for (size_t i = 0; i < listeners.size(); i++) { for (size_t i = 0; i < listeners.size(); i++) {
listeners[i]->procParamsChanged (this, whoChangedIt); listeners[i]->procParamsChanged (this, whoChangedIt);
} }
} }
}
bool Thumbnail::isRecentlySaved () bool Thumbnail::isRecentlySaved () const
{ {
return cfs.recentlySaved; return cfs.recentlySaved;
@ -495,17 +488,17 @@ void Thumbnail::imageRemovedFromQueue ()
enqueueNumber--; enqueueNumber--;
} }
bool Thumbnail::isEnqueued () bool Thumbnail::isEnqueued () const
{ {
return enqueueNumber > 0; return enqueueNumber > 0;
} }
bool Thumbnail::isPixelShift () bool Thumbnail::isPixelShift () const
{ {
return cfs.isPixelShift; return cfs.isPixelShift;
} }
bool Thumbnail::isHDR () bool Thumbnail::isHDR () const
{ {
return cfs.isHDR; return cfs.isHDR;
} }
@ -694,13 +687,13 @@ void Thumbnail::generateExifDateTimeStrings ()
dateTimeString = ostr.str (); dateTimeString = ostr.str ();
} }
const Glib::ustring& Thumbnail::getExifString () const Glib::ustring& Thumbnail::getExifString () const
{ {
return exifString; return exifString;
} }
const Glib::ustring& Thumbnail::getDateTimeString () const Glib::ustring& Thumbnail::getDateTimeString () const
{ {
return dateTimeString; return dateTimeString;
@ -798,7 +791,6 @@ int Thumbnail::infoFromImage (const Glib::ustring& fname, std::unique_ptr<rtengi
void Thumbnail::_loadThumbnail(bool firstTrial) void Thumbnail::_loadThumbnail(bool firstTrial)
{ {
needsReProcessing = true;
tw = -1; tw = -1;
th = options.maxThumbnailHeight; th = options.maxThumbnailHeight;
delete tpp; delete tpp;

View File

@ -49,7 +49,6 @@ class Thumbnail
rtengine::procparams::ProcParams pparams; rtengine::procparams::ProcParams pparams;
bool pparamsValid; bool pparamsValid;
bool needsReProcessing;
bool imageLoading; bool imageLoading;
// these are the data of the result image of the last getthumbnailimage call (for caching purposes) // these are the data of the result image of the last getthumbnailimage call (for caching purposes)
@ -81,7 +80,7 @@ public:
Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5); Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5);
~Thumbnail (); ~Thumbnail ();
bool hasProcParams (); bool hasProcParams () const;
const rtengine::procparams::ProcParams& getProcParams (); const rtengine::procparams::ProcParams& getProcParams ();
const rtengine::procparams::ProcParams& getProcParamsU (); // Unprotected version const rtengine::procparams::ProcParams& getProcParamsU (); // Unprotected version
@ -94,21 +93,21 @@ public:
void notifylisterners_procParamsChanged(int whoChangedIt); void notifylisterners_procParamsChanged(int whoChangedIt);
bool isQuick() bool isQuick() const
{ {
return cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL; return cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL;
} }
bool isPParamsValid() bool isPParamsValid() const
{ {
return pparamsValid; return pparamsValid;
} }
bool isRecentlySaved (); bool isRecentlySaved () const;
void imageDeveloped (); void imageDeveloped ();
void imageEnqueued (); void imageEnqueued ();
void imageRemovedFromQueue (); void imageRemovedFromQueue ();
bool isEnqueued (); bool isEnqueued () const;
bool isPixelShift (); bool isPixelShift () const;
bool isHDR (); bool isHDR () const;
// unsigned char* getThumbnailImage (int &w, int &h, int fixwh=1); // fixwh = 0: fix w and calculate h, =1: fix h and calculate w // unsigned char* getThumbnailImage (int &w, int &h, int fixwh=1); // fixwh = 0: fix w and calculate h, =1: fix h and calculate w
rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale); rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
@ -116,9 +115,9 @@ public:
void getThumbnailSize (int &w, int &h, const rtengine::procparams::ProcParams *pparams = nullptr); void getThumbnailSize (int &w, int &h, const rtengine::procparams::ProcParams *pparams = nullptr);
void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h); void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h);
const Glib::ustring& getExifString (); const Glib::ustring& getExifString () const;
const Glib::ustring& getDateTimeString (); const Glib::ustring& getDateTimeString () const;
void getCamWB (double& temp, double& green) void getCamWB (double& temp, double& green) const
{ {
if (tpp) { if (tpp) {
tpp->getCamWB (temp, green); tpp->getCamWB (temp, green);
@ -143,7 +142,7 @@ public:
} }
ThFileType getType (); ThFileType getType ();
Glib::ustring getFileName () Glib::ustring getFileName () const
{ {
return fname; return fname;
} }
@ -155,12 +154,12 @@ public:
{ {
return &cfs; return &cfs;
} }
std::string getMD5 () std::string getMD5 () const
{ {
return cfs.md5; return cfs.md5;
} }
int getRank () int getRank () const
{ {
return pparams.rank; return pparams.rank;
} }
@ -172,7 +171,7 @@ public:
} }
} }
int getColorLabel () int getColorLabel () const
{ {
return pparams.colorlabel; return pparams.colorlabel;
} }
@ -184,7 +183,7 @@ public:
} }
} }
int getStage () int getStage () const
{ {
return pparams.inTrash; return pparams.inTrash;
} }