Threading enhancements, cleanups
This commit is contained in:
parent
488aba1dd2
commit
ae3d85337c
@ -28,7 +28,7 @@ inline double tightestroot (double L, double a, double b, double r1, double r2,
|
||||
|
||||
inline double tightestroot (double L, double a, double b, double r1, double r2, double r3) {
|
||||
|
||||
register double an = a/500.0, bn = b/200.0, p = (L+16.0)/116.0;
|
||||
double an = a/500.0, bn = b/200.0, p = (L+16.0)/116.0;
|
||||
|
||||
double coeff3 = r1*an*an*an - r3*bn*bn*bn;
|
||||
double coeff2 = 3.0 * p * (r1*an*an + r3*bn*bn);
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
inline void cubint (Imagefloat* src, int xs, int ys, double Dx, double Dy, float *r, float *g, float *b, double mul) {
|
||||
|
||||
register double w[4];
|
||||
double w[4];
|
||||
|
||||
{
|
||||
register double t1, t2;
|
||||
double t1, t2;
|
||||
t1 = -A*(Dx-1.0)*Dx;
|
||||
t2 = (3.0-2.0*Dx)*Dx*Dx;
|
||||
w[3] = t1*Dx;
|
||||
@ -33,7 +33,7 @@ inline void cubint (Imagefloat* src, int xs, int ys, double Dx, double Dy, float
|
||||
w[0] = -t1*(Dx-1.0);
|
||||
}
|
||||
|
||||
register double rd, gd, bd;
|
||||
double rd, gd, bd;
|
||||
double yr[4], yg[4], yb[4];
|
||||
|
||||
for (int k=ys, kx=0; k<ys+4; k++, kx++) {
|
||||
@ -48,7 +48,7 @@ inline void cubint (Imagefloat* src, int xs, int ys, double Dx, double Dy, float
|
||||
|
||||
|
||||
{
|
||||
register double t1, t2;
|
||||
double t1, t2;
|
||||
|
||||
t1 = -A*(Dy-1.0)*Dy;
|
||||
t2 = (3.0-2.0*Dy)*Dy*Dy;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
inline void cubintch (float** src, int xs, int ys, double Dx, double Dy, float *r, double mul) {
|
||||
|
||||
register double w[4];
|
||||
double w[4];
|
||||
|
||||
{
|
||||
register double t1, t2;
|
||||
@ -31,7 +31,7 @@ inline void cubintch (float** src, int xs, int ys, double Dx, double Dy, float *
|
||||
w[0] = -t1*(Dx-1.0);
|
||||
}
|
||||
|
||||
register double rd;
|
||||
double rd;
|
||||
double yr[4];
|
||||
|
||||
for (int k=ys, kx=0; k<ys+4; k++, kx++) {
|
||||
@ -44,7 +44,7 @@ inline void cubintch (float** src, int xs, int ys, double Dx, double Dy, float *
|
||||
|
||||
|
||||
{
|
||||
register double t1, t2;
|
||||
double t1, t2;
|
||||
t1 = -A*(Dy-1.0)*Dy;
|
||||
t2 = (3.0-2.0*Dy)*Dy*Dy;
|
||||
w[3] = t1*Dy;
|
||||
|
@ -53,10 +53,9 @@ 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) {
|
||||
|
||||
Glib::Mutex::Lock lock(cropMutex);
|
||||
cropImageListener = il;
|
||||
}
|
||||
cropImageListener = il;
|
||||
}
|
||||
}
|
||||
|
||||
void Crop::update (int todo) {
|
||||
@ -95,8 +94,9 @@ void Crop::update (int todo) {
|
||||
|
||||
int tr = TR_NONE;
|
||||
if (params.coarse.rotate==90) tr |= TR_R90;
|
||||
if (params.coarse.rotate==180) tr |= TR_R180;
|
||||
if (params.coarse.rotate==270) tr |= TR_R270;
|
||||
else if (params.coarse.rotate==180) tr |= TR_R180;
|
||||
else if (params.coarse.rotate==270) tr |= TR_R270;
|
||||
|
||||
if (params.coarse.hflip) tr |= TR_HFLIP;
|
||||
if (params.coarse.vflip) tr |= TR_VFLIP;
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ void RawImageSource::dcb_correction(float (*image)[4], int x0, int y0)
|
||||
|
||||
for (int row=rowMin; row < rowMax; row++) {
|
||||
for (int col = colMin+(FC(y0-TILEBORDER+row,x0-TILEBORDER+colMin)&1),indx=row*CACHESIZE+col,c=FC(y0-TILEBORDER+row,x0-TILEBORDER+col); col < colMax; col+=2, indx+=2) {
|
||||
register float current = 4.f * image[indx][3] +
|
||||
float current = 4.f * image[indx][3] +
|
||||
2.f * (image[indx+u][3] + image[indx-u][3] + image[indx+1][3] + image[indx-1][3]) +
|
||||
image[indx+v][3] + image[indx-v][3] + image[indx+2][3] + image[indx-2][3];
|
||||
|
||||
@ -1401,7 +1401,7 @@ void RawImageSource::dcb_correction2(float (*image)[4], int x0, int y0)
|
||||
|
||||
for (int row=rowMin; row < rowMax; row++) {
|
||||
for (int col = colMin+(FC(y0-TILEBORDER+row,x0-TILEBORDER+colMin)&1),indx=row*CACHESIZE+col,c=FC(y0-TILEBORDER+row,x0-TILEBORDER+col); col < colMax; col+=2, indx+=2) {
|
||||
register float current = 4.f * image[indx][3] +
|
||||
float current = 4.f * image[indx][3] +
|
||||
2.f * (image[indx+u][3] + image[indx-u][3] + image[indx+1][3] + image[indx-1][3]) +
|
||||
image[indx+v][3] + image[indx-v][3] + image[indx+2][3] + image[indx-2][3];
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace rtengine {
|
||||
#endif
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++) {
|
||||
register float hipass = (data_fine[i][j]-data_coarse[i][j]);
|
||||
float hipass = (data_fine[i][j]-data_coarse[i][j]);
|
||||
buffer[i][j] += irangefn[hipass+0x10000] * hipass ;
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +140,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
|
||||
|
||||
int tr = TR_NONE;
|
||||
if (params.coarse.rotate==90) tr |= TR_R90;
|
||||
if (params.coarse.rotate==180) tr |= TR_R180;
|
||||
if (params.coarse.rotate==270) tr |= TR_R270;
|
||||
else if (params.coarse.rotate==180) tr |= TR_R180;
|
||||
else if (params.coarse.rotate==270) tr |= TR_R270;
|
||||
|
||||
if (params.coarse.hflip) tr |= TR_HFLIP;
|
||||
if (params.coarse.vflip) tr |= TR_VFLIP;
|
||||
|
||||
|
@ -135,7 +135,7 @@ class ImProcFunctions {
|
||||
//void gamutmap(LabImage* );
|
||||
void gamutmap(float &X, float &Y, float &Z, const double p[3][3]);
|
||||
|
||||
static inline float f2xyz(register float f) {
|
||||
static inline float f2xyz(float f) {
|
||||
const float epsilonExpInv3 = 6.0/29.0;
|
||||
const float kappaInv = 27.0/24389.0; // inverse of kappa
|
||||
|
||||
|
@ -29,7 +29,6 @@ namespace rtengine {
|
||||
|
||||
const Settings* settings;
|
||||
|
||||
extern Glib::Mutex* dcrMutex;
|
||||
Glib::Mutex* lcmsMutex = NULL;
|
||||
|
||||
int init (const Settings* s) {
|
||||
|
@ -140,12 +140,12 @@ static void _convolveImageHoriz(
|
||||
_KLT_FloatImage imgout)
|
||||
{
|
||||
float *ptrrow = imgin->data; /* Points to row's first pixel */
|
||||
register float *ptrout = imgout->data, /* Points to next output pixel */
|
||||
float *ptrout = imgout->data, /* Points to next output pixel */
|
||||
*ppp;
|
||||
register float sum;
|
||||
register int radius = kernel.width / 2;
|
||||
register int ncols = imgin->ncols, nrows = imgin->nrows;
|
||||
register int i, j, k;
|
||||
float sum;
|
||||
int radius = kernel.width / 2;
|
||||
int ncols = imgin->ncols, nrows = imgin->nrows;
|
||||
int i, j, k;
|
||||
|
||||
/* Kernel width must be odd */
|
||||
assert(kernel.width % 2 == 1);
|
||||
@ -192,12 +192,12 @@ static void _convolveImageVert(
|
||||
_KLT_FloatImage imgout)
|
||||
{
|
||||
float *ptrcol = imgin->data; /* Points to row's first pixel */
|
||||
register float *ptrout = imgout->data, /* Points to next output pixel */
|
||||
float *ptrout = imgout->data, /* Points to next output pixel */
|
||||
*ppp;
|
||||
register float sum;
|
||||
register int radius = kernel.width / 2;
|
||||
register int ncols = imgin->ncols, nrows = imgin->nrows;
|
||||
register int i, j, k;
|
||||
float sum;
|
||||
int radius = kernel.width / 2;
|
||||
int ncols = imgin->ncols, nrows = imgin->nrows;
|
||||
int i, j, k;
|
||||
|
||||
/* Kernel width must be odd */
|
||||
assert(kernel.width % 2 == 1);
|
||||
|
@ -43,7 +43,7 @@ typedef enum {SELECTING_ALL, REPLACING_SOME} selectionMode;
|
||||
*/
|
||||
|
||||
#define SWAP3(list, i, j) \
|
||||
{register int *pi, *pj, tmp; \
|
||||
{ int *pi, *pj, tmp; \
|
||||
pi=list+3*(i); pj=list+3*(j); \
|
||||
\
|
||||
tmp=*pi; \
|
||||
@ -373,10 +373,10 @@ void _KLTSelectGoodFeatures(
|
||||
/* Compute trackability of each image pixel as the minimum
|
||||
of the two eigenvalues of the Z matrix */
|
||||
{
|
||||
register float gx, gy;
|
||||
register float gxx, gxy, gyy;
|
||||
register int xx, yy;
|
||||
register int *ptr;
|
||||
float gx, gy;
|
||||
float gxx, gxy, gyy;
|
||||
int xx, yy;
|
||||
int *ptr;
|
||||
float val;
|
||||
unsigned int limit = 1;
|
||||
int borderx = tc->borderx; /* Must not touch cols */
|
||||
|
@ -73,9 +73,9 @@ static void _computeIntensityDifference(
|
||||
int width, int height, /* size of window */
|
||||
_FloatWindow imgdiff) /* output */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
int hw = width/2, hh = height/2;
|
||||
float g1, g2;
|
||||
register int i, j;
|
||||
int i, j;
|
||||
|
||||
/* Compute values */
|
||||
for (j = -hh ; j <= hh ; j++)
|
||||
@ -106,9 +106,9 @@ static void _computeGradientSum(
|
||||
_FloatWindow gradx, /* output */
|
||||
_FloatWindow grady) /* " */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
int hw = width/2, hh = height/2;
|
||||
float g1, g2;
|
||||
register int i, j;
|
||||
int i, j;
|
||||
|
||||
/* Compute values */
|
||||
for (j = -hh ; j <= hh ; j++)
|
||||
@ -138,9 +138,9 @@ static void _computeIntensityDifferenceLightingInsensitive(
|
||||
int width, int height, /* size of window */
|
||||
_FloatWindow imgdiff) /* output */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
int hw = width/2, hh = height/2;
|
||||
float g1, g2, sum1_squared = 0, sum2_squared = 0;
|
||||
register int i, j;
|
||||
int i, j;
|
||||
|
||||
float sum1 = 0, sum2 = 0;
|
||||
float mean1, mean2,alpha,belta;
|
||||
@ -191,9 +191,9 @@ static void _computeGradientSumLightingInsensitive(
|
||||
_FloatWindow gradx, /* output */
|
||||
_FloatWindow grady) /* " */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
int hw = width/2, hh = height/2;
|
||||
float g1, g2, sum1_squared = 0, sum2_squared = 0;
|
||||
register int i, j;
|
||||
int i, j;
|
||||
|
||||
float sum1 = 0, sum2 = 0;
|
||||
float mean1, mean2, alpha;
|
||||
@ -234,8 +234,8 @@ static void _compute2by2GradientMatrix(
|
||||
float *gyy)
|
||||
|
||||
{
|
||||
register float gx, gy;
|
||||
register int i;
|
||||
float gx, gy;
|
||||
int i;
|
||||
|
||||
/* Compute values */
|
||||
*gxx = 0.0; *gxy = 0.0; *gyy = 0.0;
|
||||
@ -264,8 +264,8 @@ static void _compute2by1ErrorVector(
|
||||
float *ex, /* return values */
|
||||
float *ey)
|
||||
{
|
||||
register float diff;
|
||||
register int i;
|
||||
float diff;
|
||||
int i;
|
||||
|
||||
/* Compute values */
|
||||
*ex = 0; *ey = 0;
|
||||
@ -618,8 +618,8 @@ static void _am_getGradientWinAffine(
|
||||
_FloatWindow out_gradx, /* output */
|
||||
_FloatWindow out_grady) /* output */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
register int i, j;
|
||||
int hw = width/2, hh = height/2;
|
||||
int i, j;
|
||||
float mi, mj;
|
||||
|
||||
/* Compute values */
|
||||
@ -646,8 +646,8 @@ static void _am_computeAffineMappedImage(
|
||||
int width, int height, /* size of window */
|
||||
_FloatWindow imgdiff) /* output */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
register int i, j;
|
||||
int hw = width/2, hh = height/2;
|
||||
int i, j;
|
||||
float mi, mj;
|
||||
|
||||
/* Compute values */
|
||||
@ -669,12 +669,12 @@ static void _am_getSubFloatImage(
|
||||
float x, float y, /* center of window */
|
||||
_KLT_FloatImage window) /* output */
|
||||
{
|
||||
register int hw = window->ncols/2, hh = window->nrows/2;
|
||||
int hw = window->ncols/2, hh = window->nrows/2;
|
||||
int x0 = (int) x;
|
||||
int y0 = (int) y;
|
||||
float * windata = window->data;
|
||||
int offset;
|
||||
register int i, j;
|
||||
int i, j;
|
||||
|
||||
assert(x0 - hw >= 0);
|
||||
assert(y0 - hh >= 0);
|
||||
@ -708,9 +708,9 @@ static void _am_computeIntensityDifferenceAffine(
|
||||
int width, int height, /* size of window */
|
||||
_FloatWindow imgdiff) /* output */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
int hw = width/2, hh = height/2;
|
||||
float g1, g2;
|
||||
register int i, j;
|
||||
int i, j;
|
||||
float mi, mj;
|
||||
|
||||
/* Compute values */
|
||||
@ -736,8 +736,8 @@ static void _am_compute6by6GradientMatrix(
|
||||
int height,
|
||||
float **T) /* return values */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
register int i, j;
|
||||
int hw = width/2, hh = height/2;
|
||||
int i, j;
|
||||
float gx, gy, gxx, gxy, gyy, x, y, xx, xy, yy;
|
||||
|
||||
|
||||
@ -813,9 +813,9 @@ static void _am_compute6by1ErrorVector(
|
||||
int height,
|
||||
float **e) /* return values */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
register int i, j;
|
||||
register float diff, diffgradx, diffgrady;
|
||||
int hw = width/2, hh = height/2;
|
||||
int i, j;
|
||||
float diff, diffgradx, diffgrady;
|
||||
|
||||
/* Set values to zero */
|
||||
for(i = 0; i < 6; i++) e[i][0] = 0.0;
|
||||
@ -852,8 +852,8 @@ static void _am_compute4by4GradientMatrix(
|
||||
int height,
|
||||
float **T) /* return values */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
register int i, j;
|
||||
int hw = width/2, hh = height/2;
|
||||
int i, j;
|
||||
float gx, gy, x, y;
|
||||
|
||||
|
||||
@ -907,9 +907,9 @@ static void _am_compute4by1ErrorVector(
|
||||
int height,
|
||||
float **e) /* return values */
|
||||
{
|
||||
register int hw = width/2, hh = height/2;
|
||||
register int i, j;
|
||||
register float diff, diffgradx, diffgrady;
|
||||
int hw = width/2, hh = height/2;
|
||||
int i, j;
|
||||
float diff, diffgradx, diffgrady;
|
||||
|
||||
/* Set values to zero */
|
||||
for(i = 0; i < 4; i++) e[i][0] = 0.0;
|
||||
|
@ -844,7 +844,7 @@ void RawImageSource::vflip (Imagefloat* image) {
|
||||
int width = image->width;
|
||||
int height = image->height;
|
||||
|
||||
register float tmp;
|
||||
float tmp;
|
||||
for (int i=0; i<height/2; i++)
|
||||
for (int j=0; j<width; j++) {
|
||||
tmp = image->r[i][j];
|
||||
|
@ -412,7 +412,7 @@ void StdImageSource::vflip (Imagefloat* image) {
|
||||
int width = image->width;
|
||||
int height = image->height;
|
||||
|
||||
register float tmp;
|
||||
float tmp;
|
||||
for (int i=0; i<height/2; i++)
|
||||
for (int j=0; j<width; j++) {
|
||||
tmp = image->r[i][j];
|
||||
|
@ -64,7 +64,7 @@ void BatchQueue::addEntries ( std::vector<BatchQueueEntry*> &entries, bool head)
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for( std::vector<BatchQueueEntry*>::iterator entry = entries.begin(); entry != entries.end();entry++ ){
|
||||
@ -127,7 +127,7 @@ void BatchQueue::loadBatchQueue( )
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
Glib::ustring savedQueueFile;
|
||||
@ -222,7 +222,7 @@ void BatchQueue::cancelItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<items->size(); i++) {
|
||||
@ -254,7 +254,7 @@ void BatchQueue::headItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
for (int i=items->size()-1; i>=0; i--) {
|
||||
BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i];
|
||||
@ -281,7 +281,7 @@ void BatchQueue::tailItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
for (int i=0; i<items->size(); i++) {
|
||||
BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i];
|
||||
@ -300,9 +300,10 @@ void BatchQueue::tailItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
}
|
||||
|
||||
void BatchQueue::selectAll () {
|
||||
{// TODO: Check for Linux
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
lastClicked = NULL;
|
||||
@ -316,40 +317,36 @@ void BatchQueue::selectAll () {
|
||||
}
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
void BatchQueue::startProcessing () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
entryMutex.lock();
|
||||
#endif
|
||||
|
||||
if (!processing && fd.size()>0) {
|
||||
BatchQueueEntry* next = (BatchQueueEntry*)fd[0];
|
||||
// tag it as processing
|
||||
next->processing = true;
|
||||
processing = next;
|
||||
// remove from selection
|
||||
if (processing->selected) {
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator pos = std::find (selected.begin(), selected.end(), processing);
|
||||
if (pos!=selected.end())
|
||||
selected.erase (pos);
|
||||
processing->selected = false;
|
||||
BatchQueueEntry* next;
|
||||
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
next = (BatchQueueEntry*)fd[0];
|
||||
// tag it as processing
|
||||
next->processing = true;
|
||||
processing = next;
|
||||
// remove from selection
|
||||
if (processing->selected) {
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator pos = std::find (selected.begin(), selected.end(), processing);
|
||||
if (pos!=selected.end())
|
||||
selected.erase (pos);
|
||||
processing->selected = false;
|
||||
}
|
||||
|
||||
// remove button set
|
||||
next->removeButtonSet ();
|
||||
}
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
entryMutex.unlock();
|
||||
#endif
|
||||
|
||||
// remove button set
|
||||
next->removeButtonSet ();
|
||||
// start batch processing
|
||||
rtengine::startBatchProcessing (next->job, this, options.tunnelMetaData);
|
||||
queue_draw ();
|
||||
} else {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
entryMutex.unlock();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,7 +402,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
fd.erase (fd.begin());
|
||||
|
@ -361,16 +361,16 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin();
|
||||
while (i!=fd.end() && *entry < *((FileBrowserEntry*)*i))
|
||||
i++;
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin();
|
||||
while (i!=fd.end() && *entry < *((FileBrowserEntry*)*i))
|
||||
i++;
|
||||
|
||||
fd.insert (i, entry);
|
||||
fd.insert (i, entry);
|
||||
|
||||
initEntry (entry);
|
||||
initEntry (entry);
|
||||
}
|
||||
redraw ();
|
||||
}
|
||||
@ -378,7 +378,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) {
|
||||
FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++)
|
||||
@ -387,13 +387,18 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
|
||||
entry->selected = false;
|
||||
fd.erase (i);
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), entry);
|
||||
|
||||
l.release();
|
||||
|
||||
if (j!=selected.end()) {
|
||||
selected.erase (j);
|
||||
notifySelectionListener ();
|
||||
}
|
||||
|
||||
if (lastClicked==entry)
|
||||
lastClicked = NULL;
|
||||
redraw ();
|
||||
|
||||
return (FileBrowserEntry*)entry;
|
||||
}
|
||||
return NULL;
|
||||
@ -402,12 +407,13 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
|
||||
FileBrowserEntry* FileBrowser::findEntry (const Glib::ustring& fname) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++)
|
||||
if ((*i)->filename==fname)
|
||||
return (FileBrowserEntry*)*i;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -425,19 +431,18 @@ void FileBrowser::close () {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
|
||||
selected.clear ();
|
||||
notifySelectionListener ();
|
||||
|
||||
// The listener merges parameters with old values, so delete afterwards
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
{
|
||||
delete fd[i];
|
||||
}
|
||||
fd.clear ();
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
{
|
||||
delete fd[i];
|
||||
}
|
||||
fd.clear ();
|
||||
}
|
||||
|
||||
lastClicked = NULL;
|
||||
@ -485,15 +490,15 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
selected.clear ();
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
if (checkFilter (fd[i])) {
|
||||
fd[i]->selected = true;
|
||||
selected.push_back (fd[i]);
|
||||
}
|
||||
selected.clear ();
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
if (checkFilter (fd[i])) {
|
||||
fd[i]->selected = true;
|
||||
selected.push_back (fd[i]);
|
||||
}
|
||||
}
|
||||
queue_draw ();
|
||||
notifySelectionListener ();
|
||||
@ -750,19 +755,20 @@ void FileBrowser::applyFilter (const BrowserFilter& filter) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::WriterLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
if(checkFilter (fd[i]))
|
||||
numFiltered++;
|
||||
else if (fd[i]->selected ) {
|
||||
fd[i]->selected = false;
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), fd[i]);
|
||||
selected.erase (j);
|
||||
if (lastClicked==fd[i])
|
||||
lastClicked = NULL;
|
||||
selchanged = true;
|
||||
for (int i=0; i<fd.size(); i++) {
|
||||
if (checkFilter (fd[i]))
|
||||
numFiltered++;
|
||||
else if (fd[i]->selected ) {
|
||||
fd[i]->selected = false;
|
||||
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), fd[i]);
|
||||
selected.erase (j);
|
||||
if (lastClicked==fd[i])
|
||||
lastClicked = NULL;
|
||||
selchanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -928,7 +934,7 @@ void FileBrowser::buttonPressed (LWButton* button, int actionCode, void* actionD
|
||||
void FileBrowser::openNextImage () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
if (fd.size()>0) {
|
||||
@ -951,7 +957,7 @@ void FileBrowser::openNextImage () {
|
||||
void FileBrowser::openPrevImage () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
if (fd.size()>0) {
|
||||
|
@ -1233,14 +1233,14 @@ void FileCatalog::filterChanged () {
|
||||
_refreshProgressBar();
|
||||
}
|
||||
|
||||
int FileCatalog::reparseDirectory () {
|
||||
void FileCatalog::reparseDirectory () {
|
||||
|
||||
if (selectedDirectory=="")
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (!safe_file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) {
|
||||
closeDir ();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> nfileNameList = getFileList ();
|
||||
@ -1271,7 +1271,6 @@ int FileCatalog::reparseDirectory () {
|
||||
}
|
||||
|
||||
fileNameList = nfileNameList;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -204,7 +204,7 @@ class FileCatalog : public Gtk::VBox,
|
||||
|
||||
void on_realize();
|
||||
void on_dir_changed (const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<Gio::File>& other_file, Gio::FileMonitorEvent event_type, bool internal);
|
||||
int reparseDirectory ();
|
||||
void reparseDirectory ();
|
||||
void _openImage (std::vector<Thumbnail*> tmb);
|
||||
|
||||
void zoomIn ();
|
||||
|
@ -56,7 +56,7 @@ ThumbBrowserBase::ThumbBrowserBase ()
|
||||
void ThumbBrowserBase::scrollChanged () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@ -139,7 +139,7 @@ void ThumbBrowserBase::configScrollBars () {
|
||||
void ThumbBrowserBase::arrangeFiles () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
int N = fd.size ();
|
||||
@ -259,7 +259,7 @@ void ThumbBrowserBase::Internal::on_realize()
|
||||
bool ThumbBrowserBase::Internal::on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
Glib::ustring ttip = "";
|
||||
@ -322,7 +322,7 @@ void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType typ
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@ -429,7 +429,7 @@ bool ThumbBrowserBase::Internal::on_expose_event(GdkEventExpose* event) {
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
int w = get_width();
|
||||
@ -455,7 +455,7 @@ bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event)
|
||||
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
int w = get_width();
|
||||
@ -470,7 +470,7 @@ bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event)
|
||||
bool ThumbBrowserBase::Internal::on_motion_notify_event (GdkEventMotion* event) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(parent->entryMutex);
|
||||
Glib::RWLock::ReaderLock l(parent->entryRW);
|
||||
#endif
|
||||
|
||||
int w = get_width();
|
||||
@ -518,7 +518,7 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight);
|
||||
@ -536,13 +536,11 @@ void ThumbBrowserBase::refreshThumbImages () {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
int previewHeight = getCurrentThumbSize();
|
||||
for (int i=0; i<fd.size(); i++){
|
||||
fd[i]->resize (previewHeight);// TODO!!! Might be performance bottleneck
|
||||
}
|
||||
for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight);// TODO!!! Might be performance bottleneck
|
||||
}
|
||||
|
||||
redraw ();
|
||||
@ -551,12 +549,10 @@ void ThumbBrowserBase::refreshThumbImages () {
|
||||
void ThumbBrowserBase::refreshQuickThumbImages () {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); ++i){
|
||||
fd[i]->refreshQuickThumbnailImage ();
|
||||
}
|
||||
for (int i=0; i<fd.size(); ++i) fd[i]->refreshQuickThumbnailImage ();
|
||||
}
|
||||
|
||||
void ThumbBrowserBase::refreshEditedState (const std::set<Glib::ustring>& efiles) {
|
||||
@ -565,7 +561,7 @@ void ThumbBrowserBase::refreshEditedState (const std::set<Glib::ustring>& efiles
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@ -589,7 +585,7 @@ void ThumbBrowserBase::enableTabMode(bool enable) {
|
||||
if (options.thumbSizeTab!=options.thumbSize) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<fd.size(); i++)
|
||||
@ -634,7 +630,7 @@ int ThumbBrowserBase::getEffectiveHeight() {
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(entryMutex);
|
||||
Glib::RWLock::ReaderLock l(entryRW);
|
||||
#endif
|
||||
|
||||
// Filtered items do not change in size, so take a non-filtered
|
||||
|
@ -75,8 +75,7 @@ class ThumbBrowserBase : public Gtk::VBox {
|
||||
|
||||
int eventTime;
|
||||
|
||||
Glib::Mutex entryMutex; // Locks access to following vectors
|
||||
|
||||
Glib::RWLock entryRW; // Locks access to following vectors
|
||||
std::vector<ThumbBrowserEntryBase*> fd;
|
||||
std::vector<ThumbBrowserEntryBase*> selected;
|
||||
ThumbBrowserEntryBase* lastClicked;
|
||||
|
Loading…
x
Reference in New Issue
Block a user