Performance improvement adding many files to queue
see issue 900
This commit is contained in:
@@ -62,6 +62,18 @@ BatchQueue::~BatchQueue ()
|
|||||||
delete pmenu;
|
delete pmenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce the max size of a thumb, since thumb is processed synchronously on adding to queue
|
||||||
|
// leading to very long waiting when adding more images
|
||||||
|
int BatchQueue::calcMaxThumbnailHeight() {
|
||||||
|
return MIN(options.maxThumbnailHeight, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function for virtual override in thumbbrowser base
|
||||||
|
int BatchQueue::getMaxThumbnailHeight() const {
|
||||||
|
return calcMaxThumbnailHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BatchQueue::rightClicked (ThumbBrowserEntryBase* entry) {
|
void BatchQueue::rightClicked (ThumbBrowserEntryBase* entry) {
|
||||||
|
|
||||||
pmenu->popup (3, this->eventTime);
|
pmenu->popup (3, this->eventTime);
|
||||||
@@ -163,11 +175,11 @@ void BatchQueue::loadBatchQueue( )
|
|||||||
if( thumb ){
|
if( thumb ){
|
||||||
rtengine::ProcessingJob* job = rtengine::ProcessingJob::create(source, thumb->getType() == FT_Raw, pparams);
|
rtengine::ProcessingJob* job = rtengine::ProcessingJob::create(source, thumb->getType() == FT_Raw, pparams);
|
||||||
|
|
||||||
int prevh = options.maxThumbnailHeight;
|
int prevh = getMaxThumbnailHeight();
|
||||||
int prevw = prevh;
|
int prevw = prevh;
|
||||||
guint8* prev = NULL;
|
guint8* prev = NULL;
|
||||||
double tmpscale;
|
double tmpscale;
|
||||||
rtengine::IImage8* img = thumb->processThumbImage(pparams, options.maxThumbnailHeight, tmpscale);
|
rtengine::IImage8* img = thumb->processThumbImage(pparams, prevh, tmpscale);
|
||||||
if (img) {
|
if (img) {
|
||||||
prevw = img->getWidth();
|
prevw = img->getWidth();
|
||||||
prevh = img->getHeight();
|
prevh = img->getHeight();
|
||||||
|
@@ -40,6 +40,7 @@ class BatchQueue : public ThumbBrowserBase,
|
|||||||
public LWButtonListener {
|
public LWButtonListener {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
int getMaxThumbnailHeight() const;
|
||||||
|
|
||||||
BatchQueueEntry* processing; // holds the currently processed image
|
BatchQueueEntry* processing; // holds the currently processed image
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ class BatchQueue : public ThumbBrowserBase,
|
|||||||
void loadBatchQueue ();
|
void loadBatchQueue ();
|
||||||
|
|
||||||
static Glib::ustring calcAutoFileNameBase (const Glib::ustring& origFileName);
|
static Glib::ustring calcAutoFileNameBase (const Glib::ustring& origFileName);
|
||||||
|
static int calcMaxThumbnailHeight();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -832,25 +832,35 @@ void FileCatalog::developRequested (std::vector<FileBrowserEntry*> tbe) {
|
|||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
std::vector<BatchQueueEntry*> entries;
|
std::vector<BatchQueueEntry*> entries;
|
||||||
|
|
||||||
|
#pragma omp parallel for ordered
|
||||||
for (size_t i=0; i<tbe.size(); i++) {
|
for (size_t i=0; i<tbe.size(); i++) {
|
||||||
rtengine::procparams::ProcParams params = tbe[i]->thumbnail->getProcParams();
|
rtengine::procparams::ProcParams params = tbe[i]->thumbnail->getProcParams();
|
||||||
rtengine::ProcessingJob* pjob = rtengine::ProcessingJob::create (tbe[i]->filename, tbe[i]->thumbnail->getType()==FT_Raw, params);
|
rtengine::ProcessingJob* pjob = rtengine::ProcessingJob::create (tbe[i]->filename, tbe[i]->thumbnail->getType()==FT_Raw, params);
|
||||||
double tmpscale;
|
double tmpscale;
|
||||||
rtengine::IImage8* img = tbe[i]->thumbnail->processThumbImage (params, options.maxThumbnailHeight, tmpscale);
|
rtengine::IImage8* img = tbe[i]->thumbnail->processThumbImage (params, BatchQueue::calcMaxThumbnailHeight(), tmpscale);
|
||||||
|
|
||||||
|
int pw, ph;
|
||||||
|
guint8* prev=NULL;
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
int pw = img->getWidth ();
|
pw = img->getWidth ();
|
||||||
int ph = img->getHeight ();
|
ph = img->getHeight ();
|
||||||
guint8* prev = new guint8 [pw*ph*3];
|
prev = new guint8 [pw*ph*3];
|
||||||
memcpy (prev, img->getData (), pw*ph*3);
|
memcpy (prev, img->getData (), pw*ph*3);
|
||||||
img->free();
|
img->free();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
tbe[i]->thumbnail->getThumbnailSize (pw, ph);
|
||||||
|
}
|
||||||
|
|
||||||
|
// processThumbImage is the processing intensive part, but adding to queue must be ordered
|
||||||
|
#pragma omp ordered
|
||||||
|
{
|
||||||
entries.push_back(new BatchQueueEntry (pjob, params, tbe[i]->filename, prev, pw, ph, tbe[i]->thumbnail));
|
entries.push_back(new BatchQueueEntry (pjob, params, tbe[i]->filename, prev, pw, ph, tbe[i]->thumbnail));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
int pw, ph;
|
|
||||||
tbe[i]->thumbnail->getThumbnailSize (pw, ph);
|
|
||||||
entries.push_back(new BatchQueueEntry (pjob, params, tbe[i]->filename, NULL, pw, ph, tbe[i]->thumbnail));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
listener->addBatchQueueJobs( entries );
|
listener->addBatchQueueJobs( entries );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -478,13 +478,13 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) {
|
|||||||
int optThumbSize=getCurrentThumbSize();
|
int optThumbSize=getCurrentThumbSize();
|
||||||
if (zoomIn)
|
if (zoomIn)
|
||||||
for (i=0; i<options.thumbnailZoomRatios.size(); i++) {
|
for (i=0; i<options.thumbnailZoomRatios.size(); i++) {
|
||||||
newHeight = (int)(options.thumbnailZoomRatios[i] * options.maxThumbnailHeight);
|
newHeight = (int)(options.thumbnailZoomRatios[i] * getMaxThumbnailHeight());
|
||||||
if (newHeight > optThumbSize)
|
if (newHeight > optThumbSize)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (i=options.thumbnailZoomRatios.size()-1; i>=0; i--) {
|
for (i=options.thumbnailZoomRatios.size()-1; i>=0; i--) {
|
||||||
newHeight = (int)(options.thumbnailZoomRatios[i] * options.maxThumbnailHeight);
|
newHeight = (int)(options.thumbnailZoomRatios[i] * getMaxThumbnailHeight());
|
||||||
if (newHeight < optThumbSize)
|
if (newHeight < optThumbSize)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include <thumbbrowserentrybase.h>
|
#include <thumbbrowserentrybase.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <options.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class handling the list of ThumbBrowserEntry objects and their position in it's allocated space
|
* Class handling the list of ThumbBrowserEntry objects and their position in it's allocated space
|
||||||
@@ -52,6 +53,7 @@ class ThumbBrowserBase : public Gtk::VBox {
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual int getMaxThumbnailHeight() const { return options.maxThumbnailHeight; } // Differs between batch and file
|
||||||
|
|
||||||
Internal internal;
|
Internal internal;
|
||||||
Gtk::HScrollbar hscroll;
|
Gtk::HScrollbar hscroll;
|
||||||
|
Reference in New Issue
Block a user