Batch queue/preview stability enhancements; see issue #611

This commit is contained in:
Oliver Duis
2011-04-02 11:12:22 +02:00
parent 5af8524ae2
commit 0de4f199f0
20 changed files with 138 additions and 139 deletions

View File

@@ -53,16 +53,16 @@ Crop::~Crop () {
void Crop::setListener (DetailedCropListener* il) {
// We can make reads in the IF, because the mProcessing lock is only needed for change
if (cropImageListener!=il) {
parent->mProcessing.lock();
Glib::Mutex::Lock lock(cropMutex);
cropImageListener = il;
parent->mProcessing.unlock();
}
}
void Crop::update (int todo) {
Glib::Mutex::Lock lock(cropMutex);
ProcParams& params = parent->params;
cropMutex.lock ();
parent->ipf.setScale (skip);
@@ -178,8 +178,6 @@ void Crop::update (int todo) {
cropImageListener->setDetailedCrop (final, params.crop, rqcropx, rqcropy, rqcropw, rqcroph, skip);
delete final;
}
cropMutex.unlock ();
}
void Crop::freeAll () {
@@ -306,14 +304,21 @@ if (settings->verbose) printf ("setcropsizes before lock\n");
return changed;
}
void Crop::fullUpdate () {
// Try a simple, threadless update flag first
bool Crop::tryUpdate() {
bool needsFullUpdate = true;
// If there are more update request, the following WHILE will collect it
if (updating) {
needsNext = true;
return;
needsFullUpdate = false;
} else updating = true;
return needsFullUpdate;
}
updating = true;
// Full update, should be called via thread
void Crop::fullUpdate () {
parent->updaterThreadStart.lock ();
if (parent->updaterRunning && parent->thread) {
@@ -324,7 +329,7 @@ void Crop::fullUpdate () {
}
if (parent->plistener)
parent->plistener->setProgressState (1);
parent->plistener->setProgressState (true);
needsNext = true;
while (needsNext) {
@@ -333,10 +338,10 @@ void Crop::fullUpdate () {
}
updating = false;
if (parent->plistener)
parent->plistener->setProgressState (0);
parent->updaterThreadStart.unlock ();
if (parent->plistener)
parent->plistener->setProgressState (false);
}
}

View File

@@ -66,7 +66,10 @@ class Crop : public DetailedCrop {
bool hasListener () { return cropImageListener; }
void update (int todo);
void setWindow (int cx, int cy, int cw, int ch, int skip) { setCropSizes (cx, cy, cw, ch, skip, false); }
void fullUpdate ();
bool tryUpdate (); // First try, only make fullUpdate if this returns false
void fullUpdate (); // called via thread
void setListener (DetailedCropListener* il);
void destroy () { delete this; }
int get_skip () { return skip;}

View File

@@ -135,7 +135,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
imgsrc->demosaic( rp );
}
if (todo & M_INIT) {
minit.lock ();
Glib::Mutex::Lock lock(minit);
if (settings->verbose) printf ("Applying white balance, color correction & sRBG conversion...\n");
currWB = ColorTemp (params.wb.temperature, params.wb.green);
if (params.wb.method=="Camera")
@@ -163,7 +164,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
progress ("Sample ...",45);
imgsrc->getImage (currWB, tr, orig_prev, pp, params.hlrecovery, params.icm, params.raw);
ipf.firstAnalysis (orig_prev, &params, vhist16, imgsrc->getGamma());
minit.unlock ();
}
progress ("Rotate / Distortion...",50);
@@ -569,7 +569,7 @@ void ImProcCoordinator::startProcessing () {
void ImProcCoordinator::process () {
if (plistener)
plistener->setProgressState (1);
plistener->setProgressState (true);
paramsUpdateMutex.lock ();
while (changeSinceLast) {
@@ -585,7 +585,7 @@ void ImProcCoordinator::process () {
updaterRunning = false;
if (plistener)
plistener->setProgressState (0);
plistener->setProgressState (false);
}
ProcParams* ImProcCoordinator::getParamsForUpdate (ProcEvent change) {

View File

@@ -104,8 +104,8 @@ namespace rtengine {
* @param str is the textual information corresponding to the progress */
virtual void setProgressStr (Glib::ustring str) {}
/** This member function is called when the state of the processing has been changed.
* @param state =1 if the processing has been started, =0 if it has been stopped */
virtual void setProgressState (int state) {}
* @param inProcessing =true if the processing has been started, =false if it has been stopped */
virtual void setProgressState (bool inProcessing) {}
/** This member function is called when an error occurs during the operation.
* @param descr is the error message */
virtual void error (Glib::ustring descr) {}
@@ -221,6 +221,9 @@ namespace rtengine {
public:
/** Sets the window defining the crop. */
virtual void setWindow (int cx, int cy, int cw, int ch, int skip) {}
/** First try to update (threadless update). If it returns false, make a full update */
virtual bool tryUpdate () { return false; }
/** Perform a full recalculation of the part of the image corresponding to the crop. */
virtual void fullUpdate () {}
/** Sets the listener of the crop. */