Internal preview window optimization; see issue #589

This commit is contained in:
Oliver Duis
2011-03-21 19:09:21 +01:00
parent 825cd3a3c9
commit 52b9fb3767
6 changed files with 33 additions and 59 deletions

View File

@@ -105,12 +105,15 @@ DetailedCrop* ImProcCoordinator::createCrop () {
return new Crop (this);
}
// todo: bitmask containing desired actions, taken from changesSinceLast
// cropCall: calling crop, used to prevent self-updates
void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
mProcessing.lock ();
ipf.setScale (scale);
// Check if any detail crops need high detail. If not, take a fast path short cut
bool highDetailNeeded=false;
for (int i=0; i<crops.size(); i++)
if (crops[i]->get_skip() == 1 ){
@@ -128,10 +131,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
if ( todo & M_PREPROC)
imgsrc->preprocess( rp );
if( todo & M_RAW){
if( !highDetailNeeded ){
fineDetailsProcessed = false;
}else
fineDetailsProcessed = true;
fineDetailsProcessed = highDetailNeeded;
imgsrc->demosaic( rp );
}
if (todo & M_INIT) {
@@ -159,7 +159,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
imgsrc->getFullSize (fw, fh, tr);
PreviewProps pp (0, 0, fw, fh, scale);
setScale (scale, true);
setScale (scale);
progress ("Sample ...",45);
imgsrc->getImage (currWB, tr, orig_prev, pp, params.hlrecovery, params.icm, params.raw);
ipf.firstAnalysis (orig_prev, &params, vhist16, imgsrc->getGamma());
@@ -168,16 +168,16 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
progress ("Rotate / Distortion...",50);
bool needstransform = ipf.needsTransform();
// Remove transformation if unneeded
if (!needstransform && orig_prev!=oprevi) {
delete oprevi;
oprevi = orig_prev;
}
if (needstransform && orig_prev==oprevi)
oprevi = new Image16 (pW, pH);
if ((todo & M_TRANSFORM) && needstransform)
if ((todo & M_TRANSFORM) && needstransform) {
if (oprevi==orig_prev) oprevi = new Image16 (pW, pH);
ipf.transform (orig_prev, oprevi, 0, 0, 0, 0, pW, pH);
}
progress ("Shadow/highlight...",55);
if ((todo & M_BLURMAP) && params.sh.enabled) {
@@ -265,7 +265,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
// process crop, if needed
for (int i=0; i<crops.size(); i++)
if (crops[i]->hasListener () && cropCall != crops[i] )
crops[i]->update (todo, true);
crops[i]->update (todo); // may call outselves
progress ("Conversion to RGB...",95);
if (todo!=CROP) {
@@ -277,6 +277,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
catch(char * str)
{
progress ("Error converting file...",0);
previmg->getMutex().unlock();
mProcessing.unlock ();
return;
}
@@ -331,13 +332,10 @@ void ImProcCoordinator::freeAll () {
allocated = false;
}
void ImProcCoordinator::setScale (int prevscale, bool internal) {
void ImProcCoordinator::setScale (int prevscale) {
if (settings->verbose) printf ("setscale before lock\n");
if (!internal)
mProcessing.lock ();
tr = TR_NONE;
if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180;
@@ -383,8 +381,6 @@ if (settings->verbose) printf ("setscale before lock\n");
sizeListeners[i]->sizeChanged (fullw, fullh, fw, fh);
if (settings->verbose) printf ("setscale ends2\n");
if (!internal)
mProcessing.unlock ();
}
@@ -528,29 +524,6 @@ void ImProcCoordinator::fullUpdatePreviewImage () {
updaterThreadStart.unlock ();
}
void ImProcCoordinator::fullUpdateDetailedCrops () {
if (destroying)
return;
updaterThreadStart.lock ();
if (updaterRunning && thread) {
changeSinceLast = 0;
thread->join ();
}
if (plistener)
plistener->setProgressState (1);
for (int i=0; i<crops.size(); i++)
crops[i]->update (ALL, true);
if (plistener)
plistener->setProgressState (0);
updaterThreadStart.unlock ();
}
void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname) {