Threading enhancements, cleanups

This commit is contained in:
Oliver Duis
2011-07-03 20:12:31 +02:00
parent 488aba1dd2
commit ae3d85337c
20 changed files with 160 additions and 163 deletions

View File

@@ -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) { 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 coeff3 = r1*an*an*an - r3*bn*bn*bn;
double coeff2 = 3.0 * p * (r1*an*an + r3*bn*bn); double coeff2 = 3.0 * p * (r1*an*an + r3*bn*bn);

View File

@@ -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) { 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; t1 = -A*(Dx-1.0)*Dx;
t2 = (3.0-2.0*Dx)*Dx*Dx; t2 = (3.0-2.0*Dx)*Dx*Dx;
w[3] = t1*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); w[0] = -t1*(Dx-1.0);
} }
register double rd, gd, bd; double rd, gd, bd;
double yr[4], yg[4], yb[4]; double yr[4], yg[4], yb[4];
for (int k=ys, kx=0; k<ys+4; k++, kx++) { 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; t1 = -A*(Dy-1.0)*Dy;
t2 = (3.0-2.0*Dy)*Dy*Dy; t2 = (3.0-2.0*Dy)*Dy*Dy;

View File

@@ -19,7 +19,7 @@
inline void cubintch (float** src, int xs, int ys, double Dx, double Dy, float *r, double mul) { 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; 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); w[0] = -t1*(Dx-1.0);
} }
register double rd; double rd;
double yr[4]; double yr[4];
for (int k=ys, kx=0; k<ys+4; k++, kx++) { 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; t1 = -A*(Dy-1.0)*Dy;
t2 = (3.0-2.0*Dy)*Dy*Dy; t2 = (3.0-2.0*Dy)*Dy*Dy;
w[3] = t1*Dy; w[3] = t1*Dy;

View File

@@ -53,7 +53,6 @@ Crop::~Crop () {
void Crop::setListener (DetailedCropListener* il) { void Crop::setListener (DetailedCropListener* il) {
// We can make reads in the IF, because the mProcessing lock is only needed for change // We can make reads in the IF, because the mProcessing lock is only needed for change
if (cropImageListener!=il) { if (cropImageListener!=il) {
Glib::Mutex::Lock lock(cropMutex); Glib::Mutex::Lock lock(cropMutex);
cropImageListener = il; cropImageListener = il;
} }
@@ -95,8 +94,9 @@ void Crop::update (int todo) {
int tr = TR_NONE; int tr = TR_NONE;
if (params.coarse.rotate==90) tr |= TR_R90; if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180; else if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270; else if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP; if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP; if (params.coarse.vflip) tr |= TR_VFLIP;

View File

@@ -1325,7 +1325,7 @@ void RawImageSource::dcb_correction(float (*image)[4], int x0, int y0)
for (int row=rowMin; row < rowMax; row++) { 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) { 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]) + 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]; 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 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) { 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]) + 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]; image[indx+v][3] + image[indx-v][3] + image[indx+2][3] + image[indx-2][3];

View File

@@ -223,7 +223,7 @@ namespace rtengine {
#endif #endif
for(int i = 0; i < height; i++) { for(int i = 0; i < height; i++) {
for(int j = 0; j < width; j++) { 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 ; buffer[i][j] += irangefn[hipass+0x10000] * hipass ;
} }
} }

View File

@@ -140,8 +140,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
int tr = TR_NONE; int tr = TR_NONE;
if (params.coarse.rotate==90) tr |= TR_R90; if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180; else if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270; else if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP; if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP; if (params.coarse.vflip) tr |= TR_VFLIP;

View File

@@ -135,7 +135,7 @@ class ImProcFunctions {
//void gamutmap(LabImage* ); //void gamutmap(LabImage* );
void gamutmap(float &X, float &Y, float &Z, const double p[3][3]); 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 epsilonExpInv3 = 6.0/29.0;
const float kappaInv = 27.0/24389.0; // inverse of kappa const float kappaInv = 27.0/24389.0; // inverse of kappa

View File

@@ -29,7 +29,6 @@ namespace rtengine {
const Settings* settings; const Settings* settings;
extern Glib::Mutex* dcrMutex;
Glib::Mutex* lcmsMutex = NULL; Glib::Mutex* lcmsMutex = NULL;
int init (const Settings* s) { int init (const Settings* s) {

View File

@@ -140,12 +140,12 @@ static void _convolveImageHoriz(
_KLT_FloatImage imgout) _KLT_FloatImage imgout)
{ {
float *ptrrow = imgin->data; /* Points to row's first pixel */ 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; *ppp;
register float sum; float sum;
register int radius = kernel.width / 2; int radius = kernel.width / 2;
register int ncols = imgin->ncols, nrows = imgin->nrows; int ncols = imgin->ncols, nrows = imgin->nrows;
register int i, j, k; int i, j, k;
/* Kernel width must be odd */ /* Kernel width must be odd */
assert(kernel.width % 2 == 1); assert(kernel.width % 2 == 1);
@@ -192,12 +192,12 @@ static void _convolveImageVert(
_KLT_FloatImage imgout) _KLT_FloatImage imgout)
{ {
float *ptrcol = imgin->data; /* Points to row's first pixel */ 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; *ppp;
register float sum; float sum;
register int radius = kernel.width / 2; int radius = kernel.width / 2;
register int ncols = imgin->ncols, nrows = imgin->nrows; int ncols = imgin->ncols, nrows = imgin->nrows;
register int i, j, k; int i, j, k;
/* Kernel width must be odd */ /* Kernel width must be odd */
assert(kernel.width % 2 == 1); assert(kernel.width % 2 == 1);

View File

@@ -43,7 +43,7 @@ typedef enum {SELECTING_ALL, REPLACING_SOME} selectionMode;
*/ */
#define SWAP3(list, i, j) \ #define SWAP3(list, i, j) \
{register int *pi, *pj, tmp; \ { int *pi, *pj, tmp; \
pi=list+3*(i); pj=list+3*(j); \ pi=list+3*(i); pj=list+3*(j); \
\ \
tmp=*pi; \ tmp=*pi; \
@@ -373,10 +373,10 @@ void _KLTSelectGoodFeatures(
/* Compute trackability of each image pixel as the minimum /* Compute trackability of each image pixel as the minimum
of the two eigenvalues of the Z matrix */ of the two eigenvalues of the Z matrix */
{ {
register float gx, gy; float gx, gy;
register float gxx, gxy, gyy; float gxx, gxy, gyy;
register int xx, yy; int xx, yy;
register int *ptr; int *ptr;
float val; float val;
unsigned int limit = 1; unsigned int limit = 1;
int borderx = tc->borderx; /* Must not touch cols */ int borderx = tc->borderx; /* Must not touch cols */

View File

@@ -73,9 +73,9 @@ static void _computeIntensityDifference(
int width, int height, /* size of window */ int width, int height, /* size of window */
_FloatWindow imgdiff) /* output */ _FloatWindow imgdiff) /* output */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
float g1, g2; float g1, g2;
register int i, j; int i, j;
/* Compute values */ /* Compute values */
for (j = -hh ; j <= hh ; j++) for (j = -hh ; j <= hh ; j++)
@@ -106,9 +106,9 @@ static void _computeGradientSum(
_FloatWindow gradx, /* output */ _FloatWindow gradx, /* output */
_FloatWindow grady) /* " */ _FloatWindow grady) /* " */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
float g1, g2; float g1, g2;
register int i, j; int i, j;
/* Compute values */ /* Compute values */
for (j = -hh ; j <= hh ; j++) for (j = -hh ; j <= hh ; j++)
@@ -138,9 +138,9 @@ static void _computeIntensityDifferenceLightingInsensitive(
int width, int height, /* size of window */ int width, int height, /* size of window */
_FloatWindow imgdiff) /* output */ _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; float g1, g2, sum1_squared = 0, sum2_squared = 0;
register int i, j; int i, j;
float sum1 = 0, sum2 = 0; float sum1 = 0, sum2 = 0;
float mean1, mean2,alpha,belta; float mean1, mean2,alpha,belta;
@@ -191,9 +191,9 @@ static void _computeGradientSumLightingInsensitive(
_FloatWindow gradx, /* output */ _FloatWindow gradx, /* output */
_FloatWindow grady) /* " */ _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; float g1, g2, sum1_squared = 0, sum2_squared = 0;
register int i, j; int i, j;
float sum1 = 0, sum2 = 0; float sum1 = 0, sum2 = 0;
float mean1, mean2, alpha; float mean1, mean2, alpha;
@@ -234,8 +234,8 @@ static void _compute2by2GradientMatrix(
float *gyy) float *gyy)
{ {
register float gx, gy; float gx, gy;
register int i; int i;
/* Compute values */ /* Compute values */
*gxx = 0.0; *gxy = 0.0; *gyy = 0.0; *gxx = 0.0; *gxy = 0.0; *gyy = 0.0;
@@ -264,8 +264,8 @@ static void _compute2by1ErrorVector(
float *ex, /* return values */ float *ex, /* return values */
float *ey) float *ey)
{ {
register float diff; float diff;
register int i; int i;
/* Compute values */ /* Compute values */
*ex = 0; *ey = 0; *ex = 0; *ey = 0;
@@ -618,8 +618,8 @@ static void _am_getGradientWinAffine(
_FloatWindow out_gradx, /* output */ _FloatWindow out_gradx, /* output */
_FloatWindow out_grady) /* output */ _FloatWindow out_grady) /* output */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
register int i, j; int i, j;
float mi, mj; float mi, mj;
/* Compute values */ /* Compute values */
@@ -646,8 +646,8 @@ static void _am_computeAffineMappedImage(
int width, int height, /* size of window */ int width, int height, /* size of window */
_FloatWindow imgdiff) /* output */ _FloatWindow imgdiff) /* output */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
register int i, j; int i, j;
float mi, mj; float mi, mj;
/* Compute values */ /* Compute values */
@@ -669,12 +669,12 @@ static void _am_getSubFloatImage(
float x, float y, /* center of window */ float x, float y, /* center of window */
_KLT_FloatImage window) /* output */ _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 x0 = (int) x;
int y0 = (int) y; int y0 = (int) y;
float * windata = window->data; float * windata = window->data;
int offset; int offset;
register int i, j; int i, j;
assert(x0 - hw >= 0); assert(x0 - hw >= 0);
assert(y0 - hh >= 0); assert(y0 - hh >= 0);
@@ -708,9 +708,9 @@ static void _am_computeIntensityDifferenceAffine(
int width, int height, /* size of window */ int width, int height, /* size of window */
_FloatWindow imgdiff) /* output */ _FloatWindow imgdiff) /* output */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
float g1, g2; float g1, g2;
register int i, j; int i, j;
float mi, mj; float mi, mj;
/* Compute values */ /* Compute values */
@@ -736,8 +736,8 @@ static void _am_compute6by6GradientMatrix(
int height, int height,
float **T) /* return values */ float **T) /* return values */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
register int i, j; int i, j;
float gx, gy, gxx, gxy, gyy, x, y, xx, xy, yy; float gx, gy, gxx, gxy, gyy, x, y, xx, xy, yy;
@@ -813,9 +813,9 @@ static void _am_compute6by1ErrorVector(
int height, int height,
float **e) /* return values */ float **e) /* return values */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
register int i, j; int i, j;
register float diff, diffgradx, diffgrady; float diff, diffgradx, diffgrady;
/* Set values to zero */ /* Set values to zero */
for(i = 0; i < 6; i++) e[i][0] = 0.0; for(i = 0; i < 6; i++) e[i][0] = 0.0;
@@ -852,8 +852,8 @@ static void _am_compute4by4GradientMatrix(
int height, int height,
float **T) /* return values */ float **T) /* return values */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
register int i, j; int i, j;
float gx, gy, x, y; float gx, gy, x, y;
@@ -907,9 +907,9 @@ static void _am_compute4by1ErrorVector(
int height, int height,
float **e) /* return values */ float **e) /* return values */
{ {
register int hw = width/2, hh = height/2; int hw = width/2, hh = height/2;
register int i, j; int i, j;
register float diff, diffgradx, diffgrady; float diff, diffgradx, diffgrady;
/* Set values to zero */ /* Set values to zero */
for(i = 0; i < 4; i++) e[i][0] = 0.0; for(i = 0; i < 4; i++) e[i][0] = 0.0;

View File

@@ -844,7 +844,7 @@ void RawImageSource::vflip (Imagefloat* image) {
int width = image->width; int width = image->width;
int height = image->height; int height = image->height;
register float tmp; float tmp;
for (int i=0; i<height/2; i++) for (int i=0; i<height/2; i++)
for (int j=0; j<width; j++) { for (int j=0; j<width; j++) {
tmp = image->r[i][j]; tmp = image->r[i][j];

View File

@@ -412,7 +412,7 @@ void StdImageSource::vflip (Imagefloat* image) {
int width = image->width; int width = image->width;
int height = image->height; int height = image->height;
register float tmp; float tmp;
for (int i=0; i<height/2; i++) for (int i=0; i<height/2; i++)
for (int j=0; j<width; j++) { for (int j=0; j<width; j++) {
tmp = image->r[i][j]; tmp = image->r[i][j];

View File

@@ -64,7 +64,7 @@ void BatchQueue::addEntries ( std::vector<BatchQueueEntry*> &entries, bool head)
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
for( std::vector<BatchQueueEntry*>::iterator entry = entries.begin(); entry != entries.end();entry++ ){ for( std::vector<BatchQueueEntry*>::iterator entry = entries.begin(); entry != entries.end();entry++ ){
@@ -127,7 +127,7 @@ void BatchQueue::loadBatchQueue( )
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
Glib::ustring savedQueueFile; Glib::ustring savedQueueFile;
@@ -222,7 +222,7 @@ void BatchQueue::cancelItems (std::vector<ThumbBrowserEntryBase*>* items) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
for (int i=0; i<items->size(); i++) { for (int i=0; i<items->size(); i++) {
@@ -254,7 +254,7 @@ void BatchQueue::headItems (std::vector<ThumbBrowserEntryBase*>* items) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
for (int i=items->size()-1; i>=0; i--) { for (int i=items->size()-1; i>=0; i--) {
BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i]; BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i];
@@ -281,7 +281,7 @@ void BatchQueue::tailItems (std::vector<ThumbBrowserEntryBase*>* items) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
for (int i=0; i<items->size(); i++) { for (int i=0; i<items->size(); i++) {
BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i]; BatchQueueEntry* entry = (BatchQueueEntry*)(*items)[i];
@@ -300,9 +300,10 @@ void BatchQueue::tailItems (std::vector<ThumbBrowserEntryBase*>* items) {
} }
void BatchQueue::selectAll () { void BatchQueue::selectAll () {
{// TODO: Check for Linux {
// TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
lastClicked = NULL; lastClicked = NULL;
@@ -316,14 +317,18 @@ void BatchQueue::selectAll () {
} }
queue_draw (); queue_draw ();
} }
void BatchQueue::startProcessing () { void BatchQueue::startProcessing () {
if (!processing && fd.size()>0) {
BatchQueueEntry* next;
{
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
entryMutex.lock(); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
if (!processing && fd.size()>0) { next = (BatchQueueEntry*)fd[0];
BatchQueueEntry* next = (BatchQueueEntry*)fd[0];
// tag it as processing // tag it as processing
next->processing = true; next->processing = true;
processing = next; processing = next;
@@ -335,21 +340,13 @@ void BatchQueue::startProcessing () {
processing->selected = false; processing->selected = false;
} }
// TODO: Check for Linux
#ifdef WIN32
entryMutex.unlock();
#endif
// remove button set // remove button set
next->removeButtonSet (); next->removeButtonSet ();
}
// start batch processing // start batch processing
rtengine::startBatchProcessing (next->job, this, options.tunnelMetaData); rtengine::startBatchProcessing (next->job, this, options.tunnelMetaData);
queue_draw (); 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 // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
fd.erase (fd.begin()); fd.erase (fd.begin());

View File

@@ -361,7 +361,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin(); std::vector<ThumbBrowserEntryBase*>::iterator i = fd.begin();
@@ -378,7 +378,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) {
FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) { FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++) 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; entry->selected = false;
fd.erase (i); fd.erase (i);
std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), entry); std::vector<ThumbBrowserEntryBase*>::iterator j = std::find (selected.begin(), selected.end(), entry);
l.release();
if (j!=selected.end()) { if (j!=selected.end()) {
selected.erase (j); selected.erase (j);
notifySelectionListener (); notifySelectionListener ();
} }
if (lastClicked==entry) if (lastClicked==entry)
lastClicked = NULL; lastClicked = NULL;
redraw (); redraw ();
return (FileBrowserEntry*)entry; return (FileBrowserEntry*)entry;
} }
return NULL; return NULL;
@@ -402,12 +407,13 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) {
FileBrowserEntry* FileBrowser::findEntry (const Glib::ustring& fname) { FileBrowserEntry* FileBrowser::findEntry (const Glib::ustring& fname) {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++) for (std::vector<ThumbBrowserEntryBase*>::iterator i=fd.begin(); i!=fd.end(); i++)
if ((*i)->filename==fname) if ((*i)->filename==fname)
return (FileBrowserEntry*)*i; return (FileBrowserEntry*)*i;
return NULL; return NULL;
} }
@@ -425,10 +431,9 @@ void FileBrowser::close () {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
selected.clear (); selected.clear ();
notifySelectionListener (); notifySelectionListener ();
@@ -485,7 +490,7 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
selected.clear (); selected.clear ();
@@ -750,10 +755,10 @@ void FileBrowser::applyFilter (const BrowserFilter& filter) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::WriterLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); i++) for (int i=0; i<fd.size(); i++) {
if (checkFilter (fd[i])) if (checkFilter (fd[i]))
numFiltered++; numFiltered++;
else if (fd[i]->selected ) { else if (fd[i]->selected ) {
@@ -765,6 +770,7 @@ void FileBrowser::applyFilter (const BrowserFilter& filter) {
selchanged = true; selchanged = true;
} }
} }
}
if (selchanged) if (selchanged)
notifySelectionListener (); notifySelectionListener ();
@@ -928,7 +934,7 @@ void FileBrowser::buttonPressed (LWButton* button, int actionCode, void* actionD
void FileBrowser::openNextImage () { void FileBrowser::openNextImage () {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
if (fd.size()>0) { if (fd.size()>0) {
@@ -951,7 +957,7 @@ void FileBrowser::openNextImage () {
void FileBrowser::openPrevImage () { void FileBrowser::openPrevImage () {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
if (fd.size()>0) { if (fd.size()>0) {

View File

@@ -1233,14 +1233,14 @@ void FileCatalog::filterChanged () {
_refreshProgressBar(); _refreshProgressBar();
} }
int FileCatalog::reparseDirectory () { void FileCatalog::reparseDirectory () {
if (selectedDirectory=="") if (selectedDirectory=="")
return 0; return;
if (!safe_file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) { if (!safe_file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) {
closeDir (); closeDir ();
return 0; return;
} }
std::vector<Glib::ustring> nfileNameList = getFileList (); std::vector<Glib::ustring> nfileNameList = getFileList ();
@@ -1271,7 +1271,6 @@ int FileCatalog::reparseDirectory () {
} }
fileNameList = nfileNameList; fileNameList = nfileNameList;
return 1;
} }
#ifdef WIN32 #ifdef WIN32

View File

@@ -204,7 +204,7 @@ class FileCatalog : public Gtk::VBox,
void on_realize(); 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); 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 _openImage (std::vector<Thumbnail*> tmb);
void zoomIn (); void zoomIn ();

View File

@@ -56,7 +56,7 @@ ThumbBrowserBase::ThumbBrowserBase ()
void ThumbBrowserBase::scrollChanged () { void ThumbBrowserBase::scrollChanged () {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); i++) for (int i=0; i<fd.size(); i++)
@@ -139,7 +139,7 @@ void ThumbBrowserBase::configScrollBars () {
void ThumbBrowserBase::arrangeFiles () { void ThumbBrowserBase::arrangeFiles () {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
int N = fd.size (); 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) { bool ThumbBrowserBase::Internal::on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(parent->entryMutex); Glib::RWLock::ReaderLock l(parent->entryRW);
#endif #endif
Glib::ustring ttip = ""; Glib::ustring ttip = "";
@@ -322,7 +322,7 @@ void ThumbBrowserBase::buttonPressed (int x, int y, int button, GdkEventType typ
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); i++) for (int i=0; i<fd.size(); i++)
@@ -429,7 +429,7 @@ bool ThumbBrowserBase::Internal::on_expose_event(GdkEventExpose* event) {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(parent->entryMutex); Glib::RWLock::ReaderLock l(parent->entryRW);
#endif #endif
int w = get_width(); int w = get_width();
@@ -455,7 +455,7 @@ bool ThumbBrowserBase::Internal::on_button_release_event (GdkEventButton* event)
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(parent->entryMutex); Glib::RWLock::ReaderLock l(parent->entryRW);
#endif #endif
int w = get_width(); 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) { bool ThumbBrowserBase::Internal::on_motion_notify_event (GdkEventMotion* event) {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(parent->entryMutex); Glib::RWLock::ReaderLock l(parent->entryRW);
#endif #endif
int w = get_width(); int w = get_width();
@@ -518,7 +518,7 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight); for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight);
@@ -536,13 +536,11 @@ void ThumbBrowserBase::refreshThumbImages () {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
int previewHeight = getCurrentThumbSize(); int previewHeight = getCurrentThumbSize();
for (int i=0; i<fd.size(); i++){ for (int i=0; i<fd.size(); i++) fd[i]->resize (previewHeight);// TODO!!! Might be performance bottleneck
fd[i]->resize (previewHeight);// TODO!!! Might be performance bottleneck
}
} }
redraw (); redraw ();
@@ -551,12 +549,10 @@ void ThumbBrowserBase::refreshThumbImages () {
void ThumbBrowserBase::refreshQuickThumbImages () { void ThumbBrowserBase::refreshQuickThumbImages () {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); ++i){ for (int i=0; i<fd.size(); ++i) fd[i]->refreshQuickThumbnailImage ();
fd[i]->refreshQuickThumbnailImage ();
}
} }
void ThumbBrowserBase::refreshEditedState (const std::set<Glib::ustring>& efiles) { 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 // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); i++) for (int i=0; i<fd.size(); i++)
@@ -589,7 +585,7 @@ void ThumbBrowserBase::enableTabMode(bool enable) {
if (options.thumbSizeTab!=options.thumbSize) { if (options.thumbSizeTab!=options.thumbSize) {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
for (int i=0; i<fd.size(); i++) for (int i=0; i<fd.size(); i++)
@@ -634,7 +630,7 @@ int ThumbBrowserBase::getEffectiveHeight() {
{ {
// TODO: Check for Linux // TODO: Check for Linux
#ifdef WIN32 #ifdef WIN32
Glib::Mutex::Lock lock(entryMutex); Glib::RWLock::ReaderLock l(entryRW);
#endif #endif
// Filtered items do not change in size, so take a non-filtered // Filtered items do not change in size, so take a non-filtered

View File

@@ -75,8 +75,7 @@ class ThumbBrowserBase : public Gtk::VBox {
int eventTime; 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*> fd;
std::vector<ThumbBrowserEntryBase*> selected; std::vector<ThumbBrowserEntryBase*> selected;
ThumbBrowserEntryBase* lastClicked; ThumbBrowserEntryBase* lastClicked;