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
// cropCall: calling crop, used to prevent self-updates ...doesn't seem to be used
void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
{
MyMutex::MyLock processingLock(mProcessing);
int numofphases = 14;
constexpr int numofphases = 14;
int readyphase = 0;
bwAutoR = bwAutoG = bwAutoB = -9000.f;
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);
}
bool highDetailNeeded = options.prevdemo == PD_Sidecar ? true : (todo & M_HIGHQUAL);
// Check if any detail crops need high detail. If not, take a fast path short cut
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
highDetailNeeded = true;
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;
ColorManagementParams cmp = params.icm;
@ -603,8 +599,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
satPR = (int) 100.f * (moyS - 0.85f * eqty);
}
if (actListener) {
//if(params.blackwhite.enabled) {actListener->autoColorTonChanged(0, satTH, satPR);}
if (actListener && params.colorToning.enabled) {
if (params.blackwhite.enabled && params.colorToning.autosat) {
actListener->autoColorTonChanged(0, satTH, satPR); //hide sliders only if autosat
indi = 0;
@ -621,8 +616,6 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
} else if (params.colorToning.method == "Splitlr") {
indi = 2;
}
//actListener->autoColorTonChanged(indi, satTH, satPR);
}
}
}
@ -899,13 +892,15 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
lastOutputBPC = params.icm.outputBPC;
ipf.updateColorProfiles(monitorProfile, monitorIntent, softProof, gamutCheck);
}
}
// process crop, if needed
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
}
if (panningRelatedChange) {
progress("Conversion to RGB...", 100 * readyphase / numofphases);
if ((todo != CROP && todo != MINUPDATE) || (todo & M_MONITOR)) {
@ -944,6 +939,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall)
updateLRGBHistograms();
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();
while (changeSinceLast) {
const bool panningRelatedChange = params.isPanningRelatedChange(nextParams);
params = nextParams;
int change = changeSinceLast;
changeSinceLast = 0;
@ -1421,7 +1418,7 @@ void ImProcCoordinator::process()
// M_VOID means no update, and is a bit higher that the rest
if (change & (M_VOID - 1)) {
updatePreviewImage(change);
updatePreviewImage(change, panningRelatedChange);
}
paramsUpdateMutex.lock();

View File

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

View File

@ -1646,7 +1646,9 @@ bool LensProfParams::operator ==(const LensProfParams& other) const
&& useCA == other.useCA
&& lfCameraMake == other.lfCameraMake
&& lfCameraModel == other.lfCameraModel
&& lfLens == other.lfLens;
&& lfLens == other.lfLens
&& useDist == other.useDist
&& useVign == other.useVign;
}
bool LensProfParams::operator !=(const LensProfParams& other) const
@ -5046,6 +5048,73 @@ int ProcParams::write(const Glib::ustring& fname, const Glib::ustring& content)
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)
{
if (createInstance) {

View File

@ -1488,6 +1488,9 @@ public:
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:
/** Write the ProcParams's text in the file of the given name.
* @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)
: 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)
{
@ -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)
: 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)
{
@ -155,7 +155,6 @@ void Thumbnail::_generateThumbnailImage ()
tpp->getAutoWBMultipliers(cfs.redAWBMul, cfs.greenAWBMul, cfs.blueAWBMul);
_saveThumbnail ();
cfs.supported = true;
needsReProcessing = true;
cfs.save (getCacheFileName ("data", ".txt"));
@ -368,7 +367,6 @@ void Thumbnail::clearProcParams (int whoClearedIt)
cfs.recentlySaved = false;
pparamsValid = false;
needsReProcessing = true;
//TODO: run though customprofilebuilder?
// 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;
@ -421,26 +419,21 @@ bool Thumbnail::hasProcParams ()
void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoChangedIt, bool updateCacheNow)
{
const bool needsReprocessing = pparams.isThumbRelatedChange(pp);
{
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) {
cfs.recentlySaved = false;
} else if (pparamsValid && !updateCacheNow) {
// nothing to do
return;
}
// do not update rank, colorlabel and inTrash
int rank = getRank();
int colorlabel = getColorLabel();
int inTrash = getStage();
const int rank = getRank();
const int colorlabel = getColorLabel();
const int inTrash = getStage();
if (pe) {
pe->combine(pparams, pp, true);
@ -449,7 +442,6 @@ void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoCh
}
pparamsValid = true;
needsReProcessing = true;
setRank(rank);
setColorLabel(colorlabel);
@ -458,15 +450,16 @@ void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoCh
if (updateCacheNow) {
updateCache();
}
} // end of mutex lock
if (needsReprocessing) {
for (size_t i = 0; i < listeners.size(); i++) {
listeners[i]->procParamsChanged (this, whoChangedIt);
}
}
}
bool Thumbnail::isRecentlySaved ()
bool Thumbnail::isRecentlySaved () const
{
return cfs.recentlySaved;
@ -495,17 +488,17 @@ void Thumbnail::imageRemovedFromQueue ()
enqueueNumber--;
}
bool Thumbnail::isEnqueued ()
bool Thumbnail::isEnqueued () const
{
return enqueueNumber > 0;
}
bool Thumbnail::isPixelShift ()
bool Thumbnail::isPixelShift () const
{
return cfs.isPixelShift;
}
bool Thumbnail::isHDR ()
bool Thumbnail::isHDR () const
{
return cfs.isHDR;
}
@ -694,13 +687,13 @@ void Thumbnail::generateExifDateTimeStrings ()
dateTimeString = ostr.str ();
}
const Glib::ustring& Thumbnail::getExifString ()
const Glib::ustring& Thumbnail::getExifString () const
{
return exifString;
}
const Glib::ustring& Thumbnail::getDateTimeString ()
const Glib::ustring& Thumbnail::getDateTimeString () const
{
return dateTimeString;
@ -798,7 +791,6 @@ int Thumbnail::infoFromImage (const Glib::ustring& fname, std::unique_ptr<rtengi
void Thumbnail::_loadThumbnail(bool firstTrial)
{
needsReProcessing = true;
tw = -1;
th = options.maxThumbnailHeight;
delete tpp;

View File

@ -49,7 +49,6 @@ class Thumbnail
rtengine::procparams::ProcParams pparams;
bool pparamsValid;
bool needsReProcessing;
bool imageLoading;
// 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 ();
bool hasProcParams ();
bool hasProcParams () const;
const rtengine::procparams::ProcParams& getProcParams ();
const rtengine::procparams::ProcParams& getProcParamsU (); // Unprotected version
@ -94,21 +93,21 @@ public:
void notifylisterners_procParamsChanged(int whoChangedIt);
bool isQuick()
bool isQuick() const
{
return cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL;
}
bool isPParamsValid()
bool isPParamsValid() const
{
return pparamsValid;
}
bool isRecentlySaved ();
bool isRecentlySaved () const;
void imageDeveloped ();
void imageEnqueued ();
void imageRemovedFromQueue ();
bool isEnqueued ();
bool isPixelShift ();
bool isHDR ();
bool isEnqueued () const;
bool isPixelShift () const;
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
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 getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h);
const Glib::ustring& getExifString ();
const Glib::ustring& getDateTimeString ();
void getCamWB (double& temp, double& green)
const Glib::ustring& getExifString () const;
const Glib::ustring& getDateTimeString () const;
void getCamWB (double& temp, double& green) const
{
if (tpp) {
tpp->getCamWB (temp, green);
@ -143,7 +142,7 @@ public:
}
ThFileType getType ();
Glib::ustring getFileName ()
Glib::ustring getFileName () const
{
return fname;
}
@ -155,12 +154,12 @@ public:
{
return &cfs;
}
std::string getMD5 ()
std::string getMD5 () const
{
return cfs.md5;
}
int getRank ()
int getRank () const
{
return pparams.rank;
}
@ -172,7 +171,7 @@ public:
}
}
int getColorLabel ()
int getColorLabel () const
{
return pparams.colorlabel;
}
@ -184,7 +183,7 @@ public:
}
}
int getStage ()
int getStage () const
{
return pparams.inTrash;
}